CMS 3D CMS Logo

DumpFWRecoGeometry.cc
Go to the documentation of this file.
8 
9 #include "TFile.h"
10 #include "TTree.h"
11 #include "TError.h"
12 #include "TSystem.h"
13 
15 public:
17  ~DumpFWRecoGeometry(void) override {}
18 
19 private:
20  void analyze(const edm::Event& event, const edm::EventSetup& eventSetup) override;
21  void beginJob(void) override;
22  void endJob(void) override;
23 
24  int m_level;
28 };
29 
31  : m_level(config.getUntrackedParameter<int>("level", 1)),
32  m_tag(config.getUntrackedParameter<std::string>("tagInfo", "unknown")),
33 
34  m_outputFileName(config.getUntrackedParameter<std::string>("outputFileName", "cmsRecoGeo.root")),
35  m_geomToken(esConsumes()) {}
36 
38  using namespace edm;
39 
40  ESTransientHandle<FWRecoGeometry> geoh = eventSetup.getTransientHandle(m_geomToken);
41  TFile file(m_outputFileName.c_str(), "RECREATE");
42 
43  TTree* tree = new TTree("idToGeo", "raw detector id association with geometry ANT");
44 
45  UInt_t v_id;
46  Float_t v_vertex[24];
47  Float_t v_params[9];
48  Float_t v_shape[5];
49  Float_t v_translation[3];
50  Float_t v_matrix[9];
51 
52  tree->SetBranchStyle(0);
53  tree->Branch("id", &v_id, "id/i");
54  tree->Branch("points", &v_vertex, "points[24]/F");
55  tree->Branch("topology", &v_params, "topology[9]/F");
56  tree->Branch("shape", &v_shape, "shape[5]/F");
57  tree->Branch("translation", &v_translation, "translation[3]/F");
58  tree->Branch("matrix", &v_matrix, "matrix[9]/F");
59 
60  for (FWRecoGeom::InfoMapItr it = geoh.product()->idToName.begin(), end = geoh.product()->idToName.end(); it != end;
61  ++it) {
62  v_id = it->id;
63  for (unsigned int i = 0; i < 24; ++i)
64  v_vertex[i] = it->points[i];
65  for (unsigned int i = 0; i < 9; ++i)
66  v_params[i] = it->topology[i];
67  for (unsigned int i = 0; i < 5; ++i)
68  v_shape[i] = it->shape[i];
69  for (unsigned int i = 0; i < 3; ++i)
70  v_translation[i] = it->translation[i];
71  for (unsigned int i = 0; i < 9; ++i)
72  v_matrix[i] = it->matrix[i];
73  tree->Fill();
74  }
75  file.WriteTObject(tree);
76 
77  file.WriteTObject(new TNamed("CMSSW_VERSION", gSystem->Getenv("CMSSW_VERSION")));
78  file.WriteTObject(new TNamed("tag", m_tag.c_str()));
79  file.WriteTObject(&geoh.product()->extraDet, "ExtraDetectors");
80  file.WriteTObject(new TNamed("PRODUCER_VERSION", "1")); // version 2 changes pixel parameters
81 
82  file.WriteTObject(new TNamed("TrackerTopology", geoh.product()->trackerTopologyXML));
83 
84  file.Close();
85 }
86 
88 
90 
std::vector< FWRecoGeom::Info >::const_iterator InfoMapItr
Definition: FWRecoGeom.h:24
std::string trackerTopologyXML
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
~DumpFWRecoGeometry(void) override
for(int i=first, nt=offsets[nh];i< nt;i+=gridDim.x *blockDim.x)
Definition: config.py:1
FWRecoGeom::InfoMap idToName
std::string m_outputFileName
const edm::ESGetToken< FWRecoGeometry, FWRecoGeometryRecord > m_geomToken
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void analyze(const edm::Event &event, const edm::EventSetup &eventSetup) override
void beginJob(void) override
DumpFWRecoGeometry(const edm::ParameterSet &config)
T const * product() const
void endJob(void) override
TObjArray extraDet
HLT enums.
Definition: tree.py:1
Definition: event.py:1