Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-04 02:02:28

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