Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:05:35

0001 #include <exception>
0002 #include <fstream>
0003 #include <memory>
0004 #include <string>
0005 
0006 #include "DetectorDescription/Core/interface/DDCompactView.h"
0007 #include "DetectorDescription/Core/interface/DDExpandedNode.h"
0008 #include "DetectorDescription/Core/interface/DDExpandedView.h"
0009 #include "DetectorDescription/RegressionTest/src/DDCheck.h"
0010 #include "DetectorDescription/Core/interface/Material.h"
0011 #include "DetectorDescription/Parser/interface/DDLParser.h"
0012 #include "DetectorDescription/Parser/interface/FIPConfiguration.h"
0013 #include "FWCore/ParameterSetReader/interface/ParameterSetReader.h"
0014 #include "FWCore/PluginManager/interface/PresenceFactory.h"
0015 #include "FWCore/PluginManager/interface/ProblemTracker.h"
0016 #include "FWCore/ServiceRegistry/interface/ServiceRegistry.h"
0017 #include "FWCore/ServiceRegistry/interface/ServiceToken.h"
0018 #include "FWCore/Utilities/interface/Exception.h"
0019 #include "FWCore/Utilities/interface/Presence.h"
0020 
0021 using namespace xercesc;
0022 
0023 int main(int argc, char* argv[]) {
0024   // Copied from example stand-alone program in Message Logger July 18, 2007
0025   std::string const kProgramName = argv[0];
0026   int rc = 0;
0027 
0028   try {
0029     // A.  Instantiate a plug-in manager first.
0030     edm::AssertHandler ah;
0031 
0032     // B.  Load the message service plug-in.  Forget this and bad things happen!
0033     //     In particular, the job hangs as soon as the output buffer fills up.
0034     //     That's because, without the message service, there is no mechanism for
0035     //     emptying the buffers.
0036     std::shared_ptr<edm::Presence> theMessageServicePresence;
0037     theMessageServicePresence =
0038         std::shared_ptr<edm::Presence>(edm::PresenceFactory::get()->makePresence("SingleThreadMSPresence").release());
0039 
0040     // C.  Manufacture a configuration and establish it.
0041     std::string config =
0042         "import FWCore.ParameterSet.Config as cms\n"
0043         "process = cms.Process('TEST')\n"
0044         "process.maxEvents = cms.untracked.PSet(\n"
0045         "    input = cms.untracked.int32(5)\n"
0046         ")\n"
0047         "process.source = cms.Source('EmptySource')\n"
0048         "process.JobReportService = cms.Service('JobReportService')\n"
0049         "process.InitRootHandlers = cms.Service('InitRootHandlers')\n"
0050         // "process.MessageLogger = cms.Service('MessageLogger')\n"
0051         "process.m1 = cms.EDProducer('IntProducer',\n"
0052         "    ivalue = cms.int32(11)\n"
0053         ")\n"
0054         "process.out = cms.OutputModule('PoolOutputModule',\n"
0055         "    fileName = cms.untracked.string('testStandalone.root')\n"
0056         ")\n"
0057         "process.p = cms.Path(process.m1)\n"
0058         "process.e = cms.EndPath(process.out)\n";
0059 
0060     // D.  Create the services.
0061     std::unique_ptr<edm::ParameterSet> params;
0062     edm::makeParameterSets(config, params);
0063     edm::ServiceToken tempToken(edm::ServiceRegistry::createServicesFromConfig(std::move(params)));
0064 
0065     // E.  Make the services available.
0066     edm::ServiceRegistry::Operate operate(tempToken);
0067 
0068     // END Copy from example stand-alone program in Message Logger July 18, 2007
0069 
0070     std::cout << "main::initialize DDL parser\n";
0071 
0072     DDCompactView cpv;
0073     DDLParser myP(cpv);
0074 
0075     std::cout << "main::about to start parsing main configuration... \n";
0076     FIPConfiguration dp(cpv);
0077     dp.readConfig("DetectorDescription/Parser/test/cmsIdealGeometryXML.xml");
0078     myP.parse(dp);
0079 
0080     std::cout << "main::completed Parser" << std::endl;
0081 
0082     std::cout << std::endl << std::endl << "main::Start checking!" << std::endl << std::endl;
0083     DDCheckMaterials(std::cout);
0084 
0085     std::cout << "edge size of produce graph:" << cpv.graph().edge_size() << std::endl;
0086 
0087     DDExpandedView ev(cpv);
0088     std::cout << "== got the epv ==" << std::endl;
0089     // for now just count!
0090     std::ofstream plist("plist.out");
0091     int numPhysParts(0);
0092     while (ev.next()) {
0093       ++numPhysParts;
0094       plist << ev.geoHistory() << std::endl;
0095     }
0096     plist.close();
0097     std::cout << "Traversing the tree went to " << numPhysParts << " nodes, or \"PhysicalParts\" in online db terms."
0098               << std::endl;
0099   }
0100   //  Deal with any exceptions that may have been thrown.
0101   catch (cms::Exception& e) {
0102     std::cout << "cms::Exception caught in " << kProgramName << "\n" << e.explainSelf();
0103     rc = 1;
0104   } catch (std::exception& e) {
0105     std::cout << "Standard library exception caught in " << kProgramName << "\n" << e.what();
0106     rc = 1;
0107   } catch (...) {
0108     std::cout << "Unknown exception caught in " << kProgramName;
0109     rc = 2;
0110   }
0111 
0112   return rc;
0113 }