CMS 3D CMS Logo

DDTestDumpFile.cc
Go to the documentation of this file.
7 #include "DD4hep/Detector.h"
8 #include "DD4hep/DD4hepRootPersistency.h"
9 
10 #include "TGeoManager.h"
11 #include "TFile.h"
12 #include "TSystem.h"
13 
14 #include <iostream>
15 #include <string>
16 
17 using namespace std;
18 using namespace cms;
19 using namespace dd4hep;
20 
22 public:
23  explicit DDTestDumpFile( const edm::ParameterSet& );
24 
25  void beginJob() override {}
26  void analyze( edm::Event const& iEvent, edm::EventSetup const& ) override;
27  void endJob() override {}
28 
29 private:
32 };
33 
35 {
36  m_tag = iConfig.getUntrackedParameter<std::string>( "tag", "unknown" );
37  m_outputFileName = iConfig.getUntrackedParameter<std::string>( "outputFileName", "cmsDD4HepGeom.root" );
38 }
39 
40 void
42 {
43  std::cout << "DDTestDumpFile::analyze:\n";
45  iEventSetup.get<DetectorDescriptionRcd>().get(description);
46 
47  TGeoManager& geom = description->description().manager();
48 
49  int level = 1 + geom.GetTopVolume()->CountNodes( 100, 3 );
50 
51  std::cout << "In the DDTestDumpFile::analyze method...obtained main geometry, level="
52  << level << std::endl;
53 
54  TFile file( m_outputFileName.c_str(), "RECREATE" );
55  file.WriteTObject( &geom );
56  file.WriteTObject( new TNamed( "CMSSW_VERSION", gSystem->Getenv( "CMSSW_VERSION" )));
57  file.WriteTObject( new TNamed( "tag", m_tag.c_str()));
58  file.Close();
59 }
60 
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 &)
Namespace of DDCMS conversion namespace.
T get() const
Definition: EventSetup.h:68
virtual example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
dd4hep::Detector & description() const
Definition: DDDetector.h:21