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 void
40 {
41  dd4hep::Detector& description = dd4hep::Detector::getInstance();
42 
43  std::string name( "DD4hep_CompactLoader" );
44 
45  const char* files[] = { m_confGeomXMLFiles.c_str(), nullptr };
46  description.apply( name.c_str(), 2, (char**)files );
47 
48  for( const auto& it : m_files )
49  std::cout << it << std::endl;
50 
52  std::cout << "DD Vector Registry size: " << registry->size() << "\n";
53  for( const auto& p: *registry ) {
54  std::cout << " " << p.first << " => ";
55  for( const auto& i : p.second )
56  std::cout << i << ", ";
57  std::cout << '\n';
58  }
59 }
60 
61 void
63 {
64  // FIXME: It does not clean up:
65  // dd4hep::Detector::getInstance().destroyInstance();
66 }
67 
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