CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 public:
51  explicit DumpSimGeometry(const edm::ParameterSet&);
52  ~DumpSimGeometry() override;
53 
54 private:
55  void analyze(const edm::Event&, const edm::EventSetup&) override;
56 
60 };
61 
62 //
63 // constructors and destructor
64 //
66  m_tag = ps.getUntrackedParameter<std::string>("tag", "unknown");
67  m_outputFileName = ps.getUntrackedParameter<std::string>("outputFileName", "cmsSimGeom.root");
68 }
69 
71  // do anything here that needs to be done at desctruction time
72  // (e.g. close files, deallocate resources etc.)
73 }
74 
75 // ------------ method called to for each event ------------
77  std::cout << "In the DumpSimGeometry::analyze method..." << std::endl;
78  using namespace edm;
79 
81  const TGeoManager* geom = geoh.product(); // const_cast<TGeoManager*>(geoh.product());
82 
83  int level = 1 + geom->GetTopVolume()->CountNodes(100, 3);
84 
85  std::cout << "In the DumpSimGeometry::analyze method...obtained main geometry, level=" << level << std::endl;
86 
87  // TFile f(TString::Format("cmsSimGeom-%d.root", level), "RECREATE");
88  TFile f(m_outputFileName.c_str(), "RECREATE");
89  f.WriteTObject(geom);
90  f.WriteTObject(new TNamed("CMSSW_VERSION", gSystem->Getenv("CMSSW_VERSION")));
91  f.WriteTObject(new TNamed("tag", m_tag.c_str()));
92  f.Close();
93 }
94 
95 //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:16
int iEvent
Definition: GenABIO.cc:224
~DumpSimGeometry() override
void analyze(const edm::Event &, const edm::EventSetup &) override
ESTransientHandle< T > getTransientHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:162
std::string m_outputFileName
tuple cout
Definition: gather_cfg.py:144
tuple level
Definition: testEve_cfg.py:47
DumpSimGeometry(const edm::ParameterSet &)
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
const edm::ESGetToken< TGeoManager, DisplayGeomRecord > m_geomToken