CMS 3D CMS Logo

DDCMSDetector.cc
Go to the documentation of this file.
7 #include "DD4hep/Detector.h"
8 
9 #include <memory>
10 #include <string>
11 
13 public:
14  explicit DDCMSDetector(const edm::ParameterSet& p);
15 
16  void beginJob() override {}
17  void analyze( edm::Event const& iEvent, edm::EventSetup const& ) override;
18  void endJob() override;
19 
20 private:
21 
23  std::vector< std::string > m_relFiles;
24  std::vector< std::string > m_files;
25 };
26 
28 {
29  m_confGeomXMLFiles = edm::FileInPath( iConfig.getParameter<std::string>( "confGeomXMLFiles" )).fullPath();
30 
31  m_relFiles = iConfig.getParameter<std::vector<std::string> >( "geomXMLFiles" );
32  for( const auto& it : m_relFiles ) {
33  edm::FileInPath fp( it );
34  m_files.emplace_back( fp.fullPath());
35  }
36 }
37 
38 #include "DD4hep/DetElement.h"
39 
40 void
42 {
43  dd4hep::Detector& description = dd4hep::Detector::getInstance();
44 
45  std::string name( "DD4hep_CompactLoader" );
46 
47  const char* files[] = { m_confGeomXMLFiles.c_str(), nullptr };
48  description.apply( name.c_str(), 2, (char**)files );
49 
50  for( const auto& it : m_files )
51  std::cout << it << std::endl;
52 
54  std::cout << "DD Vector Registry size: " << registry->size() << "\n";
55  for( const auto& p: *registry ) {
56  std::cout << " " << p.first << " => ";
57  for( const auto& i : p.second )
58  std::cout << i << ", ";
59  std::cout << '\n';
60  }
61  std::cout << "Iterate over the detectors:\n";
62  for( dd4hep::Detector::HandleMap::const_iterator i = description.detectors().begin(); i != description.detectors().end(); ++i ) {
63  dd4hep::DetElement det( (*i).second );
64  std::cout << (*i).first << ": " << det.path() << "\n";
65  }
66  std::cout << "..done!\n";
67 }
68 
69 void
71 {
72  // FIXME: It does not clean up:
73  // dd4hep::Detector::getInstance().destroyInstance();
74 }
75 
T getParameter(std::string const &) const
std::vector< std::string > m_relFiles
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< std::string > m_files
DDCMSDetector(const edm::ParameterSet &p)
void analyze(edm::Event const &iEvent, edm::EventSetup const &) override
int iEvent
Definition: GenABIO.cc:230
std::string m_confGeomXMLFiles
void endJob() override
std::string fullPath() const
Definition: FileInPath.cc:197
static Interceptor::Registry registry("Interceptor")
void beginJob() override