/DetectorDescription/Parser/test/testDDCompactView.cpp

https://github.com/aivanov-cern/cmssw · C++ · 135 lines · 83 code · 22 blank · 30 comment · 5 complexity · 19f7836ae1b1dd25223cc30eafb31ca3 MD5 · raw file

  1. /***************************************************************************
  2. main.cpp - description
  3. -------------------
  4. begin : Wed Oct 24 17:36:15 PDT 2001
  5. author : 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. * mec: 2008-08-05 : need to make this an analyzer instead? *
  16. * for now use the "main" of cmssw *
  17. ***************************************************************************/
  18. #include <iostream>
  19. #include <stdlib.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/DDLParser.h"
  25. #include "DetectorDescription/Parser/interface/FIPConfiguration.h"
  26. #include "DetectorDescription/Core/src/DDCheck.h"
  27. #include "DetectorDescription/Core/interface/DDExpandedView.h"
  28. #include "DetectorDescription/Core/interface/DDExpandedNode.h"
  29. #include "DetectorDescription/Core/interface/DDCompactView.h"
  30. int main(int argc, char *argv[])
  31. {
  32. // Copied from example stand-alone program in Message Logger July 18, 2007
  33. std::string const kProgramName = argv[0];
  34. int rc = 0;
  35. try {
  36. // A. Instantiate a plug-in manager first.
  37. edm::AssertHandler ah;
  38. // B. Load the message service plug-in. Forget this and bad things happen!
  39. // In particular, the job hangs as soon as the output buffer fills up.
  40. // That's because, without the message service, there is no mechanism for
  41. // emptying the buffers.
  42. boost::shared_ptr<edm::Presence> theMessageServicePresence;
  43. theMessageServicePresence = boost::shared_ptr<edm::Presence>(edm::PresenceFactory::get()->
  44. makePresence("MessageServicePresence").release());
  45. // C. Manufacture a configuration and establish it.
  46. std::string config =
  47. "import FWCore.ParameterSet.Config as cms\n"
  48. "process = cms.Process('TEST')\n"
  49. "process.maxEvents = cms.untracked.PSet(\n"
  50. " input = cms.untracked.int32(5)\n"
  51. ")\n"
  52. "process.source = cms.Source('EmptySource')\n"
  53. "process.JobReportService = cms.Service('JobReportService')\n"
  54. "process.InitRootHandlers = cms.Service('InitRootHandlers')\n"
  55. // "process.MessageLogger = cms.Service('MessageLogger')\n"
  56. "process.m1 = cms.EDProducer('IntProducer',\n"
  57. " ivalue = cms.int32(11)\n"
  58. ")\n"
  59. "process.out = cms.OutputModule('PoolOutputModule',\n"
  60. " fileName = cms.untracked.string('testStandalone.root')\n"
  61. ")\n"
  62. "process.p = cms.Path(process.m1)\n"
  63. "process.e = cms.EndPath(process.out)\n";
  64. // D. Create the services.
  65. edm::ServiceToken tempToken(edm::ServiceRegistry::createServicesFromConfig(config));
  66. // E. Make the services available.
  67. edm::ServiceRegistry::Operate operate(tempToken);
  68. // END Copy from example stand-alone program in Message Logger July 18, 2007
  69. std::cout << "main::initialize DDL parser" << std::endl;
  70. DDCompactView cpv;
  71. DDLParser myP(cpv); // = DDLParser::instance();
  72. FIPConfiguration dp(cpv);
  73. dp.readConfig("DetectorDescription/Parser/test/cmsIdealGeometryXML.xml");
  74. std::cout << "main::about to start parsing" << std::endl;
  75. myP.parse(dp);
  76. std::cout << "main::completed Parser" << std::endl;
  77. std::cout << std::endl << std::endl << "main::Start checking!" << std::endl << std::endl;
  78. DDCheckMaterials(std::cout);
  79. DDExpandedView ev(cpv);
  80. std::cout << "== got the epv ==" << std::endl;
  81. while ( ev.next() ) {
  82. if ( ev.logicalPart().name().name() == "MBAT" ) {
  83. std::cout << ev.geoHistory() << std::endl;
  84. }
  85. if ( ev.logicalPart().name().name() == "MUON" ) {
  86. std::cout << ev.geoHistory() << std::endl;
  87. }
  88. }
  89. // cpv.clear();
  90. std::cout << "cleared DDCompactView. " << std::endl;
  91. }
  92. // Deal with any exceptions that may have been thrown.
  93. catch (cms::Exception& e) {
  94. std::cout << "cms::Exception caught in "
  95. << kProgramName
  96. << "\n"
  97. << e.explainSelf();
  98. rc = 1;
  99. }
  100. catch (std::exception& e) {
  101. std::cout << "Standard library exception caught in "
  102. << kProgramName
  103. << "\n"
  104. << e.what();
  105. rc = 1;
  106. }
  107. catch (...) {
  108. std::cout << "Unknown exception caught in "
  109. << kProgramName;
  110. rc = 2;
  111. }
  112. return rc;
  113. }