/DetectorDescription/Parser/test/dumpDDCompactView.cpp

https://github.com/aivanov-cern/cmssw · C++ · 165 lines · 94 code · 28 blank · 43 comment · 5 complexity · 57ba7e394e36c03ea7ec2541e75465b4 MD5 · raw file

  1. /***************************************************************************
  2. main.cpp - description
  3. -------------------
  4. begin : Wed Oct 24 17:36:15 PDT 2001
  5. author : 2001 Michael Case
  6. email : case@ucdhep.ucdavis.edu
  7. ***************************************************************************/
  8. /***************************************************************************
  9. * *
  10. * This program is free software; you can redistribute it and/or modify *
  11. * it under the terms of the GNU General Public License as published by *
  12. * the Free Software Foundation; either version 2 of the License, or *
  13. * (at your option) any later version. *
  14. * *
  15. ***************************************************************************/
  16. #include <iostream>
  17. #include <stdlib.h>
  18. #include <fstream>
  19. #include "DetectorDescription/Parser/interface/DDLParser.h"
  20. #include "FWCore/PluginManager/interface/ProblemTracker.h"
  21. #include "FWCore/PluginManager/interface/PresenceFactory.h"
  22. #include "FWCore/PythonParameterSet/interface/MakeParameterSets.h"
  23. #include "FWCore/ServiceRegistry/interface/Service.h"
  24. #include "DetectorDescription/Parser/interface/FIPConfiguration.h"
  25. #include "DetectorDescription/Core/src/DDCheck.h"
  26. #include "DetectorDescription/Core/src/DDCheckMaterials.cc"
  27. #include "DetectorDescription/Core/interface/DDCompactView.h"
  28. #include "DetectorDescription/Core/interface/adjgraph.h"
  29. #include "DetectorDescription/Core/src/Material.h"
  30. int main(int argc, char *argv[])
  31. {
  32. typedef DDCompactView::graph_type::const_adj_iterator adjl_iterator;
  33. // Copied from example stand-alone program in Message Logger July 18, 2007
  34. std::string const kProgramName = argv[0];
  35. int rc = 0;
  36. try {
  37. // A. Instantiate a plug-in manager first.
  38. edm::AssertHandler ah;
  39. // B. Load the message service plug-in. Forget this and bad things happen!
  40. // In particular, the job hangs as soon as the output buffer fills up.
  41. // That's because, without the message service, there is no mechanism for
  42. // emptying the buffers.
  43. boost::shared_ptr<edm::Presence> theMessageServicePresence;
  44. theMessageServicePresence = boost::shared_ptr<edm::Presence>(edm::PresenceFactory::get()->
  45. makePresence("MessageServicePresence").release());
  46. // C. Manufacture a configuration and establish it.
  47. std::string config =
  48. "import FWCore.ParameterSet.Config as cms\n"
  49. "process = cms.Process('TEST')\n"
  50. "process.maxEvents = cms.untracked.PSet(\n"
  51. " input = cms.untracked.int32(5)\n"
  52. ")\n"
  53. "process.source = cms.Source('EmptySource')\n"
  54. "process.JobReportService = cms.Service('JobReportService')\n"
  55. "process.InitRootHandlers = cms.Service('InitRootHandlers')\n"
  56. // "process.MessageLogger = cms.Service('MessageLogger')\n"
  57. "process.m1 = cms.EDProducer('IntProducer',\n"
  58. " ivalue = cms.int32(11)\n"
  59. ")\n"
  60. "process.out = cms.OutputModule('PoolOutputModule',\n"
  61. " fileName = cms.untracked.string('testStandalone.root')\n"
  62. ")\n"
  63. "process.p = cms.Path(process.m1)\n"
  64. "process.e = cms.EndPath(process.out)\n";
  65. // D. Create the services.
  66. edm::ServiceToken tempToken(edm::ServiceRegistry::createServicesFromConfig(config));
  67. // E. Make the services available.
  68. edm::ServiceRegistry::Operate operate(tempToken);
  69. // END Copy from example stand-alone program in Message Logger July 18, 2007
  70. std::cout << "main::initialize DDL parser" << std::endl;
  71. DDCompactView cpv;
  72. DDLParser myP(cpv);// = DDLParser::instance();
  73. // std::cout << "main:: about to start parsing field configuration..." << std::endl;
  74. // FIPConfiguration dp2;
  75. // dp2.readConfig("Geometry/CMSCommonData/data/FieldConfiguration.xml");
  76. // myP->parse(dp2);
  77. std::cout << "main::about to start parsing main configuration... " << std::endl;
  78. FIPConfiguration dp(cpv);
  79. dp.readConfig("DetectorDescription/Parser/test/cmsIdealGeometryXML.xml");
  80. myP.parse(dp);
  81. std::cout << "main::completed Parser" << std::endl;
  82. std::cout << std::endl << std::endl << "main::Start checking!" << std::endl << std::endl;
  83. DDCheckMaterials(std::cout);
  84. // cpv.setRoot(DDLogicalPart(DDName("cms:World")));
  85. std::cout << "edge size of produce graph:" << cpv.writeableGraph().edge_size() << std::endl;
  86. const DDCompactView::graph_type& gt = cpv.graph();
  87. adjl_iterator git = gt.begin();
  88. adjl_iterator gend = gt.end();
  89. DDCompactView::graph_type::index_type i=0;
  90. for (; git != gend; ++git) {
  91. const DDLogicalPart & ddLP = gt.nodeData(git);
  92. std::cout << ++i << " P " << ddLP.name() << std::endl;
  93. if (git->size()) {
  94. DDCompactView::graph_type::edge_list::const_iterator cit = git->begin();
  95. DDCompactView::graph_type::edge_list::const_iterator cend = git->end();
  96. for (; cit != cend; ++cit) {
  97. const DDLogicalPart & ddcurLP = gt.nodeData(cit->first);
  98. std::cout << ++i << " c--> " << gt.edgeData(cit->second)->copyno_ << " " << ddcurLP.name() << std::endl;
  99. }
  100. }
  101. }
  102. cpv.writeableGraph().clear();
  103. // cpv.clear();
  104. std::cout << "cleared DDCompactView. " << std::endl;
  105. // DDExpandedView ev(cpv);
  106. // std::cout << "== got the epv ==" << std::endl;
  107. // while ( ev.next() ) {
  108. // if ( ev.logicalPart().name().name() == "MBAT" ) {
  109. // std::cout << ev.geoHistory() << std::endl;
  110. // }
  111. // if ( ev.logicalPart().name().name() == "MUON" ) {
  112. // std::cout << ev.geoHistory() << std::endl;
  113. // }
  114. // }
  115. }
  116. // Deal with any exceptions that may have been thrown.
  117. catch (cms::Exception& e) {
  118. std::cout << "cms::Exception caught in "
  119. << kProgramName
  120. << "\n"
  121. << e.explainSelf();
  122. rc = 1;
  123. }
  124. catch (std::exception& e) {
  125. std::cout << "Standard library exception caught in "
  126. << kProgramName
  127. << "\n"
  128. << e.what();
  129. rc = 1;
  130. }
  131. catch (...) {
  132. std::cout << "Unknown exception caught in "
  133. << kProgramName;
  134. rc = 2;
  135. }
  136. return rc;
  137. }