CMS 3D CMS Logo

DDTestDumpFile.cc
Go to the documentation of this file.
8 #include "DD4hep/Detector.h"
9 #include "DD4hep/DD4hepRootPersistency.h"
10 
11 #include "TGeoManager.h"
12 #include "TFile.h"
13 #include "TSystem.h"
14 
15 #include <iostream>
16 #include <string>
17 
18 using namespace std;
19 using namespace cms;
20 using namespace edm;
21 using namespace dd4hep;
22 
23 class DDTestDumpFile : public one::EDAnalyzer<> {
24 public:
25  explicit DDTestDumpFile(const ParameterSet&);
26 
27  void beginJob() override {}
28  void analyze(Event const& iEvent, EventSetup const&) override;
29  void endJob() override {}
30 
31 private:
32  const string m_tag;
33  const string m_outputFileName;
35 };
36 
38  : m_tag(iConfig.getUntrackedParameter<string>("tag", "unknown")),
39  m_outputFileName(iConfig.getUntrackedParameter<string>("outputFileName", "cmsDD4HepGeom.root")),
40  m_label(iConfig.getParameter<ESInputTag>("DDDetector"))
41 {}
42 
43 void
44 DDTestDumpFile::analyze(const Event&, const EventSetup& iEventSetup)
45 {
46  LogVerbatim("Geometry") << "DDTestDumpFile::analyze: " << m_label;
48  iEventSetup.get<GeometryFileRcd>().get(m_label.module(), det);
49 
50  TGeoManager& geom = det->description()->manager();
51 
52  int level = 1 + geom.GetTopVolume()->CountNodes( 100, 3 );
53 
54  LogVerbatim("Geometry") << "In the DDTestDumpFile::analyze method...obtained main geometry, level="
55  << level;
56 
57  TFile file(m_outputFileName.c_str(), "RECREATE");
58  file.WriteTObject(&geom );
59  file.WriteTObject(new TNamed("CMSSW_VERSION", gSystem->Getenv("CMSSW_VERSION")));
60  file.WriteTObject(new TNamed("tag", m_tag.c_str()));
61  file.Close();
62 }
63 
const string m_tag
void beginJob() override
void endJob() override
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
const ESInputTag m_label
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void analyze(Event const &iEvent, EventSetup const &) override
DDTestDumpFile(const ParameterSet &)
Namespace of DDCMS conversion namespace.
const string m_outputFileName
HLT enums.
T get() const
Definition: EventSetup.h:71
const std::string & module() const
Definition: ESInputTag.h:99
Detector const * description() const
Definition: DDDetector.h:24