CMS 3D CMS Logo

DDTestDumpFile.cc
Go to the documentation of this file.
4 #include "DD4hep/Detector.h"
5 #include "DD4hep/DD4hepRootPersistency.h"
6 
7 #include "TGeoManager.h"
8 #include "TFile.h"
9 #include "TSystem.h"
10 
11 #include <iostream>
12 #include <string>
13 
15 public:
16  explicit DDTestDumpFile( const edm::ParameterSet& );
17 
18  void beginJob() override {}
19  void analyze( edm::Event const& iEvent, edm::EventSetup const& ) override;
20  void endJob() override {}
21 
22 private:
25 };
26 
28 {
29  m_tag = iConfig.getUntrackedParameter<std::string>( "tag", "unknown" );
30  m_outputFileName = iConfig.getUntrackedParameter<std::string>( "outputFileName", "cmsDD4HepGeom.root" );
31 }
32 
33 void
35 {
36  std::cout << "DDTestDumpFile::analyze:\n";
37  dd4hep::Detector& description = dd4hep::Detector::getInstance();
38  TGeoManager& geom = description.manager();
39 
40  int level = 1 + geom.GetTopVolume()->CountNodes( 100, 3 );
41 
42  std::cout << "In the DDTestDumpFile::analyze method...obtained main geometry, level="
43  << level << std::endl;
44 
45  TFile file( m_outputFileName.c_str(), "RECREATE" );
46  file.WriteTObject( &geom );
47  file.WriteTObject( new TNamed( "CMSSW_VERSION", gSystem->Getenv( "CMSSW_VERSION" )));
48  file.WriteTObject( new TNamed( "tag", m_tag.c_str()));
49  file.Close();
50 }
51 
T getUntrackedParameter(std::string const &, T const &) const
std::string m_outputFileName
void beginJob() override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void endJob() override
void analyze(edm::Event const &iEvent, edm::EventSetup const &) override
int iEvent
Definition: GenABIO.cc:230
std::string m_tag
DDTestDumpFile(const edm::ParameterSet &)