CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DumpSimGeometry.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: DumpSimGeometry
4 // Class: DumpSimGeometry
5 //
13 //
14 // Original Author: Chris D Jones
15 // Created: Wed Sep 26 08:27:23 EDT 2007
16 //
17 //
18 
19 // system include files
20 #include <memory>
21 #include <iostream>
22 
23 // user include files
26 
29 
31 
35 
37 
38 #include "TGeoManager.h"
39 #include "TGeoMatrix.h"
40 
41 #include "TFile.h"
42 #include "TError.h"
43 #include "TSystem.h"
44 
45 //
46 // class declaration
47 //
48 
50 {
51 public:
52  explicit DumpSimGeometry(const edm::ParameterSet&);
54 
55 private:
56 
57  virtual void analyze(const edm::Event&, const edm::EventSetup&) override;
58 
61 };
62 
63 
64 //
65 // constructors and destructor
66 //
68 {
69  m_tag = ps.getUntrackedParameter<std::string>("tag", "unknown");
70  m_outputFileName = ps.getUntrackedParameter<std::string>("outputFileName", "cmsSimGeom.root");
71 
72 }
73 
74 
76 {
77  // do anything here that needs to be done at desctruction time
78  // (e.g. close files, deallocate resources etc.)
79 }
80 
81 
82 // ------------ method called to for each event ------------
83 void
85 {
86  std::cout << "In the DumpSimGeometry::analyze method..." << std::endl;
87  using namespace edm;
88 
90  iSetup.get<DisplayGeomRecord>().get(geoh);
91  const TGeoManager *geom = geoh.product(); // const_cast<TGeoManager*>(geoh.product());
92 
93  int level = 1 + geom->GetTopVolume()->CountNodes(100, 3);
94 
95  std::cout << "In the DumpSimGeometry::analyze method...obtained main geometry, level="
96  << level << std::endl;
97 
98  // TFile f(TString::Format("cmsSimGeom-%d.root", level), "RECREATE");
99  TFile f(m_outputFileName.c_str(), "RECREATE");
100  f.WriteTObject(geom);
101  f.WriteTObject(new TNamed("CMSSW_VERSION", gSystem->Getenv( "CMSSW_VERSION" )));
102  f.WriteTObject(new TNamed("tag", m_tag.c_str()));
103  f.Close();
104 }
105 
106 //define this as a plug-in
std::string m_tag
T getUntrackedParameter(std::string const &, T const &) const
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
int iEvent
Definition: GenABIO.cc:230
double f[11][100]
const T & get() const
Definition: EventSetup.h:56
virtual void analyze(const edm::Event &, const edm::EventSetup &) override
std::string m_outputFileName
tuple cout
Definition: gather_cfg.py:121
tuple level
Definition: testEve_cfg.py:34
DumpSimGeometry(const edm::ParameterSet &)