CMS 3D CMS Logo

TrackerHitAnalyzer.cc
Go to the documentation of this file.
2 
9 
12 
15 
16 // tracker info
23 
24 // data in edm::event
27 //#include "SimDataFormats/Vertex/interface/SimVertexContainer.h"
31 
32 // helper files
33 #include "CLHEP/Units/GlobalSystemOfUnits.h"
34 #include <CLHEP/Vector/LorentzVector.h>
35 
36 #include <cstdlib>
37 #include <map>
38 #include <memory>
39 #include <vector>
40 
42  : verbose_(ps.getUntrackedParameter<bool>("Verbosity", false)),
43  edmPSimHitContainer_pxlBrlLow_Token_(
44  consumes<edm::PSimHitContainer>(ps.getParameter<edm::InputTag>("PxlBrlLowSrc"))),
45  edmPSimHitContainer_pxlBrlHigh_Token_(
46  consumes<edm::PSimHitContainer>(ps.getParameter<edm::InputTag>("PxlBrlHighSrc"))),
47  edmPSimHitContainer_pxlFwdLow_Token_(
48  consumes<edm::PSimHitContainer>(ps.getParameter<edm::InputTag>("PxlFwdLowSrc"))),
49  edmPSimHitContainer_pxlFwdHigh_Token_(
50  consumes<edm::PSimHitContainer>(ps.getParameter<edm::InputTag>("PxlFwdHighSrc"))),
51  edmPSimHitContainer_siTIBLow_Token_(
52  consumes<edm::PSimHitContainer>(ps.getParameter<edm::InputTag>("SiTIBLowSrc"))),
53  edmPSimHitContainer_siTIBHigh_Token_(
54  consumes<edm::PSimHitContainer>(ps.getParameter<edm::InputTag>("SiTIBHighSrc"))),
55  edmPSimHitContainer_siTOBLow_Token_(
56  consumes<edm::PSimHitContainer>(ps.getParameter<edm::InputTag>("SiTOBLowSrc"))),
57  edmPSimHitContainer_siTOBHigh_Token_(
58  consumes<edm::PSimHitContainer>(ps.getParameter<edm::InputTag>("SiTOBHighSrc"))),
59  edmPSimHitContainer_siTIDLow_Token_(
60  consumes<edm::PSimHitContainer>(ps.getParameter<edm::InputTag>("SiTIDLowSrc"))),
61  edmPSimHitContainer_siTIDHigh_Token_(
62  consumes<edm::PSimHitContainer>(ps.getParameter<edm::InputTag>("SiTIDHighSrc"))),
63  edmPSimHitContainer_siTECLow_Token_(
64  consumes<edm::PSimHitContainer>(ps.getParameter<edm::InputTag>("SiTECLowSrc"))),
65  edmPSimHitContainer_siTECHigh_Token_(
66  consumes<edm::PSimHitContainer>(ps.getParameter<edm::InputTag>("SiTECHighSrc"))),
67  edmSimTrackContainerToken_(consumes<edm::SimTrackContainer>(ps.getParameter<edm::InputTag>("G4TrkSrc"))),
68  fDBE(nullptr),
69  conf_(ps),
70  runStandalone(ps.getParameter<bool>("runStandalone")),
71  fOutputFile(ps.getUntrackedParameter<std::string>("outputFile", "TrackerHitHisto.root")),
72  pixelOutput(ps.getParameter<bool>("pixelOutput")) {}
73 
77 
78  Char_t hname1[50], htitle1[80];
79  Char_t hname2[50], htitle2[80];
80  Char_t hname3[50], htitle3[80];
81  Char_t hname4[50], htitle4[80];
82  Char_t hname5[50], htitle5[80];
83  Char_t hname6[50], htitle6[80];
84 
85  if (fDBE) {
86  if (verbose_) {
87  fDBE->setVerbose(1);
88  } else {
89  fDBE->setVerbose(0);
90  }
91  }
92 
93  if (fDBE) {
94  if (verbose_)
96  }
97 
98  if (fDBE != nullptr) {
99  // fDBE->setCurrentFolder("TrackerHitsV/TrackerHitTask");
100 
101  // is there any way to record CPU Info ???
102  // if so, it can be done once - via beginJob()
103  int nbin = 5000;
104 
105  ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/");
106  htofeta = ibooker.book2D("tof_eta", "Time of flight vs eta", nbin, -3.0, 3.0, 200, -100, 100);
107  htofphi = ibooker.book2D("tof_phi", "Time of flight vs phi", nbin, -180, 180, 200, -100, 100);
108  htofr = ibooker.book2D("tof_r", "Time of flight vs r", nbin, 0, 300, 200, -100, 100);
109  htofz = ibooker.book2D("tof_z", "Time of flight vs z", nbin, -280, 280, 200, -100, 100);
110 
111  const float E2NEL = 1.;
112 
113  const char *Region[] = {"005", "051", "115", "152", "225", "253", "-050", "-105", "-151", "-215", "-252", "-325"};
114  nbin = 200;
115 
116  // Energy loss histograms
117  for (int i = 0; i < 12; i++) {
118  sprintf(htitle1, "Energy loss in TIB %s", Region[i]);
119  sprintf(htitle2, "Energy loss in TOB %s", Region[i]);
120  sprintf(htitle3, "Energy loss in TID %s", Region[i]);
121  sprintf(htitle4, "Energy loss in TEC %s", Region[i]);
122  if (pixelOutput)
123  sprintf(htitle5, "Energy loss in BPIX %s", Region[i]);
124  if (pixelOutput)
125  sprintf(htitle6, "Energy loss in FPIX %s", Region[i]);
126 
127  sprintf(hname1, "Eloss_TIB_%i", i + 1);
128  sprintf(hname2, "Eloss_TOB_%i", i + 1);
129  sprintf(hname3, "Eloss_TID_%i", i + 1);
130  sprintf(hname4, "Eloss_TEC_%i", i + 1);
131  if (pixelOutput)
132  sprintf(hname5, "Eloss_BPIX_%i", i + 1);
133  if (pixelOutput)
134  sprintf(hname6, "Eloss_FPIX_%i", i + 1);
135 
136  ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/TIBHit");
137  h1e[i] = ibooker.book1D(hname1, htitle1, nbin, 0.0, 0.001 * E2NEL);
138  ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/TOBHit");
139  h2e[i] = ibooker.book1D(hname2, htitle2, nbin, 0.0, 0.001 * E2NEL);
140  ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/TIDHit");
141  h3e[i] = ibooker.book1D(hname3, htitle3, nbin, 0.0, 0.001 * E2NEL);
142  ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/TECHit");
143  h4e[i] = ibooker.book1D(hname4, htitle4, nbin, 0.0, 0.001 * E2NEL);
144  if (pixelOutput) {
145  ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/BPIXHit");
146  h5e[i] = ibooker.book1D(hname5, htitle5, nbin, 0.0, 0.001 * E2NEL);
147  ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/FPIXHit");
148  h6e[i] = ibooker.book1D(hname6, htitle6, nbin, 0.0, 0.001 * E2NEL);
149  }
150  }
151 
152  // limits
153  const float high[] = {0.03, 0.03, 0.02, 0.03, 0.03, 0.03};
154  const float low[] = {-0.03, -0.03, -0.02, -0.03, -0.03, -0.03};
155 
156  for (int i = 0; i < 12; i++) {
157  sprintf(htitle1, "Entryx-Exitx in TIB %s", Region[i]);
158  sprintf(htitle2, "Entryx-Exitx in TOB %s", Region[i]);
159  sprintf(htitle3, "Entryx-Exitx in TID %s", Region[i]);
160  sprintf(htitle4, "Entryx-Exitx in TEC %s", Region[i]);
161  if (pixelOutput)
162  sprintf(htitle5, "Entryx-Exitx in BPIX %s", Region[i]);
163  if (pixelOutput)
164  sprintf(htitle6, "Entryx-Exitx in FPIX %s", Region[i]);
165 
166  sprintf(hname1, "Entryx-Exitx_TIB_%i", i + 1);
167  sprintf(hname2, "Entryx-Exitx_TOB_%i", i + 1);
168  sprintf(hname3, "Entryx-Exitx_TID_%i", i + 1);
169  sprintf(hname4, "Entryx-Exitx_TEC_%i", i + 1);
170  if (pixelOutput)
171  sprintf(hname5, "Entryx-Exitx_BPIX_%i", i + 1);
172  if (pixelOutput)
173  sprintf(hname6, "Entryx-Exitx_FPIX_%i", i + 1);
174 
175  ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/TIBHit");
176  h1ex[i] = ibooker.book1D(hname1, htitle1, nbin, low[0], high[0]);
177  ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/TOBHit");
178  h2ex[i] = ibooker.book1D(hname2, htitle2, nbin, low[1], high[1]);
179  ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/TIDHit");
180  h3ex[i] = ibooker.book1D(hname3, htitle3, nbin, low[2], high[2]);
181  ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/TECHit");
182  h4ex[i] = ibooker.book1D(hname4, htitle4, nbin, low[3], high[3]);
183  if (pixelOutput) {
184  ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/BPIXHit");
185  h5ex[i] = ibooker.book1D(hname5, htitle5, nbin, low[4], high[4]);
186  ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/FPIXHit");
187  h6ex[i] = ibooker.book1D(hname6, htitle6, nbin, low[5], high[5]);
188  }
189  }
190 
191  const float high0[] = {0.05, 0.06, 0.03, 0.03, 0.03, 0.03};
192  const float low0[] = {-0.05, -0.06, -0.03, -0.03, -0.03, -0.03};
193 
194  for (int i = 0; i < 12; i++) {
195  sprintf(htitle1, "Entryy-Exity in TIB %s", Region[i]);
196  sprintf(htitle2, "Entryy-Exity in TOB %s", Region[i]);
197  sprintf(htitle3, "Entryy-Exity in TID %s", Region[i]);
198  sprintf(htitle4, "Entryy-Exity in TEC %s", Region[i]);
199  if (pixelOutput)
200  sprintf(htitle5, "Entryy-Exity in BPIX %s", Region[i]);
201  if (pixelOutput)
202  sprintf(htitle6, "Entryy-Exity in FPIX %s", Region[i]);
203 
204  sprintf(hname1, "Entryy-Exity_TIB_%i", i + 1);
205  sprintf(hname2, "Entryy-Exity_TOB_%i", i + 1);
206  sprintf(hname3, "Entryy-Exity_TID_%i", i + 1);
207  sprintf(hname4, "Entryy-Exity_TEC_%i", i + 1);
208  if (pixelOutput)
209  sprintf(hname5, "Entryy-Exity_BPIX_%i", i + 1);
210  if (pixelOutput)
211  sprintf(hname6, "Entryy-Exity_FPIX_%i", i + 1);
212 
213  ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/TIBHit");
214  h1ey[i] = ibooker.book1D(hname1, htitle1, nbin, low0[0], high0[0]);
215  ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/TOBHit");
216  h2ey[i] = ibooker.book1D(hname2, htitle2, nbin, low0[1], high0[1]);
217  ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/TIDHit");
218  h3ey[i] = ibooker.book1D(hname3, htitle3, nbin, low0[2], high0[2]);
219  ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/TECHit");
220  h4ey[i] = ibooker.book1D(hname4, htitle4, nbin, low0[3], high0[3]);
221  if (pixelOutput) {
222  ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/BPIXHit");
223  h5ey[i] = ibooker.book1D(hname5, htitle5, nbin, low0[4], high0[4]);
224  ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/FPIXHit");
225  h6ey[i] = ibooker.book1D(hname6, htitle6, nbin, low0[5], high0[5]);
226  }
227  }
228 
229  const float high1[] = {0.05, 0.06, 0.05, 0.06, 0.05, 0.05};
230  const float low1[] = {0., 0., 0., 0., 0., 0.};
231 
232  for (int i = 0; i < 12; i++) {
233  sprintf(htitle1, "abs(Entryz-Exitz) in TIB %s", Region[i]);
234  sprintf(htitle2, "abs(Entryz-Exitz) in TOB %s", Region[i]);
235  sprintf(htitle3, "abs(Entryz-Exitz) in TID %s", Region[i]);
236  sprintf(htitle4, "abs(Entryz-Exitz) in TEC %s", Region[i]);
237  if (pixelOutput)
238  sprintf(htitle5, "abs(Entryz-Exitz) in BPIX %s", Region[i]);
239  if (pixelOutput)
240  sprintf(htitle6, "abs(Entryz-Exitz) in FPIX %s", Region[i]);
241 
242  sprintf(hname1, "Entryz-Exitz_TIB_%i", i + 1);
243  sprintf(hname2, "Entryz-Exitz_TOB_%i", i + 1);
244  sprintf(hname3, "Entryz-Exitz_TID_%i", i + 1);
245  sprintf(hname4, "Entryz-Exitz_TEC_%i", i + 1);
246  if (pixelOutput)
247  sprintf(hname5, "Entryz-Exitz_BPIX_%i", i + 1);
248  if (pixelOutput)
249  sprintf(hname6, "Entryz-Exitz_FPIX_%i", i + 1);
250 
251  ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/TIBHit");
252  h1ez[i] = ibooker.book1D(hname1, htitle1, nbin, low1[0], high1[0]);
253  ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/TOBHit");
254  h2ez[i] = ibooker.book1D(hname2, htitle2, nbin, low1[1], high1[1]);
255  ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/TIDHit");
256  h3ez[i] = ibooker.book1D(hname3, htitle3, nbin, low1[2], high1[2]);
257  ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/TECHit");
258  h4ez[i] = ibooker.book1D(hname4, htitle4, nbin, low1[3], high1[3]);
259  if (pixelOutput) {
260  ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/BPIXHit");
261  h5ez[i] = ibooker.book1D(hname5, htitle5, nbin, low1[4], high1[4]);
262  ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/FPIXHit");
263  h6ez[i] = ibooker.book1D(hname6, htitle6, nbin, low1[5], high1[5]);
264  }
265  }
266 
267  const float high2[] = {3.2, 5.0, 5.5, 6.2, 0.85, 0.5};
268  const float low2[] = {-3.2, -5.0, -5.5, -6.2, -0.85, -0.5};
269 
270  for (int i = 0; i < 12; i++) {
271  sprintf(htitle1, "Localx in TIB %s", Region[i]);
272  sprintf(htitle2, "Localx in TOB %s", Region[i]);
273  sprintf(htitle3, "Localx in TID %s", Region[i]);
274  sprintf(htitle4, "Localx in TEC %s", Region[i]);
275  if (pixelOutput)
276  sprintf(htitle5, "Localx in BPIX %s", Region[i]);
277  if (pixelOutput)
278  sprintf(htitle6, "Localx in FPIX %s", Region[i]);
279 
280  sprintf(hname1, "Localx_TIB_%i", i + 1);
281  sprintf(hname2, "Localx_TOB_%i", i + 1);
282  sprintf(hname3, "Localx_TID_%i", i + 1);
283  sprintf(hname4, "Localx_TEC_%i", i + 1);
284  if (pixelOutput)
285  sprintf(hname5, "Localx_BPIX_%i", i + 1);
286  if (pixelOutput)
287  sprintf(hname6, "Localx_FPIX_%i", i + 1);
288 
289  ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/TIBHit");
290  h1lx[i] = ibooker.book1D(hname1, htitle1, nbin, low2[0], high2[0]);
291  ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/TOBHit");
292  h2lx[i] = ibooker.book1D(hname2, htitle2, nbin, low2[1], high2[1]);
293  ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/TIDHit");
294  h3lx[i] = ibooker.book1D(hname3, htitle3, nbin, low2[2], high2[2]);
295  ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/TECHit");
296  h4lx[i] = ibooker.book1D(hname4, htitle4, nbin, low2[3], high2[3]);
297  if (pixelOutput) {
298  ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/BPIXHit");
299  h5lx[i] = ibooker.book1D(hname5, htitle5, nbin, low2[4], high2[4]);
300  ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/FPIXHit");
301  h6lx[i] = ibooker.book1D(hname6, htitle6, nbin, low2[5], high2[5]);
302  }
303  }
304 
305  const float high3[] = {6.0, 10., 5.6, 10.5, 3.4, 0.52};
306  const float low3[] = {-6.0, -10., -5.6, -10.5, -3.4, -0.52};
307 
308  for (int i = 0; i < 12; i++) {
309  sprintf(htitle1, "Localy in TIB %s", Region[i]);
310  sprintf(htitle2, "Localy in TOB %s", Region[i]);
311  sprintf(htitle3, "Localy in TID %s", Region[i]);
312  sprintf(htitle4, "Localy in TEC %s", Region[i]);
313  if (pixelOutput)
314  sprintf(htitle5, "Localy in BPIX %s", Region[i]);
315  if (pixelOutput)
316  sprintf(htitle6, "Localy in FPIX %s", Region[i]);
317 
318  sprintf(hname1, "Localy_TIB_%i", i + 1);
319  sprintf(hname2, "Localy_TOB_%i", i + 1);
320  sprintf(hname3, "Localy_TID_%i", i + 1);
321  sprintf(hname4, "Localy_TEC_%i", i + 1);
322  if (pixelOutput)
323  sprintf(hname5, "Localy_BPIX_%i", i + 1);
324  if (pixelOutput)
325  sprintf(hname6, "Localy_FPIX_%i", i + 1);
326 
327  ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/TIBHit");
328  h1ly[i] = ibooker.book1D(hname1, htitle1, nbin, low3[0], high3[0]);
329  ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/TOBHit");
330  h2ly[i] = ibooker.book1D(hname2, htitle2, nbin, low3[1], high3[1]);
331  ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/TIDHit");
332  h3ly[i] = ibooker.book1D(hname3, htitle3, nbin, low3[2], high3[2]);
333  ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/TECHit");
334  h4ly[i] = ibooker.book1D(hname4, htitle4, nbin, low3[3], high3[3]);
335  if (pixelOutput) {
336  ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/BPIXHit");
337  h5ly[i] = ibooker.book1D(hname5, htitle5, nbin, low3[4], high3[4]);
338  ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/FPIXHit");
339  h6ly[i] = ibooker.book1D(hname6, htitle6, nbin, low3[5], high3[5]);
340  }
341  }
342  }
343 }
344 
346  // don't try to delete any pointers - they're handled by DQM machinery
347 }
348 
350  // According to the previous code some profile plots were created here
351  // However, these profile plots are not in the final root file
352  // For now we comment out these plots (since they are not created in any case)
353  // Then, if needed we will consider moving the booking of the profileplots to
354  // the bookHistograms function and here we will do the profile
355 
356  // Save root file only in standalone mode
357  if (runStandalone && !fOutputFile.empty() && fDBE) {
359  }
360 }
361 
363  edm::LogInfo("EventInfo") << " Run = " << e.id().run() << " Event = " << e.id().event();
364 
365  // iterator to access containers
366  edm::PSimHitContainer::const_iterator itHit;
368  // get Pixel Barrel information
370  // extract low container
371  edm::Handle<edm::PSimHitContainer> PxlBrlLowContainer;
372  e.getByToken(edmPSimHitContainer_pxlBrlLow_Token_, PxlBrlLowContainer);
373  if (!PxlBrlLowContainer.isValid()) {
374  edm::LogError("TrackerHitAnalyzer::analyze") << "Unable to find TrackerHitsPixelBarrelLowTof in event!";
375  return;
376  }
377  // extract high container
378  edm::Handle<edm::PSimHitContainer> PxlBrlHighContainer;
379  e.getByToken(edmPSimHitContainer_pxlBrlHigh_Token_, PxlBrlHighContainer);
380  if (!PxlBrlHighContainer.isValid()) {
381  edm::LogError("TrackerHitAnalyzer::analyze") << "Unable to find TrackerHitsPixelBarrelHighTof in event!";
382  return;
383  }
385  // get Pixel Forward information
387  // extract low container
388  edm::Handle<edm::PSimHitContainer> PxlFwdLowContainer;
389  e.getByToken(edmPSimHitContainer_pxlFwdLow_Token_, PxlFwdLowContainer);
390  if (!PxlFwdLowContainer.isValid()) {
391  edm::LogError("TrackerHitAnalyzer::analyze") << "Unable to find TrackerHitsPixelEndcapLowTof in event!";
392  return;
393  }
394  // extract high container
395  edm::Handle<edm::PSimHitContainer> PxlFwdHighContainer;
396  e.getByToken(edmPSimHitContainer_pxlFwdHigh_Token_, PxlFwdHighContainer);
397  if (!PxlFwdHighContainer.isValid()) {
398  edm::LogError("TrackerHitAnalyzer::analyze") << "Unable to find TrackerHitsPixelEndcapHighTof in event!";
399  return;
400  }
402  // get Silicon TIB information
404  // extract TIB low container
405  edm::Handle<edm::PSimHitContainer> SiTIBLowContainer;
406  e.getByToken(edmPSimHitContainer_siTIBLow_Token_, SiTIBLowContainer);
407  if (!SiTIBLowContainer.isValid()) {
408  edm::LogError("TrackerHitProducer::analyze") << "Unable to find TrackerHitsTIBLowTof in event!";
409  return;
410  }
412  // extract TIB high container
413  edm::Handle<edm::PSimHitContainer> SiTIBHighContainer;
414  e.getByToken(edmPSimHitContainer_siTIBHigh_Token_, SiTIBHighContainer);
415  if (!SiTIBHighContainer.isValid()) {
416  edm::LogError("TrackerHitProducer::analyze") << "Unable to find TrackerHitsTIBHighTof in event!";
417  return;
418  }
420  // get Silicon TOB information
422  // extract TOB low container
423  edm::Handle<edm::PSimHitContainer> SiTOBLowContainer;
424  e.getByToken(edmPSimHitContainer_siTOBLow_Token_, SiTOBLowContainer);
425  if (!SiTOBLowContainer.isValid()) {
426  edm::LogError("TrackerHitProducer::analyze") << "Unable to find TrackerHitsTOBLowTof in event!";
427  return;
428  }
430  // extract TOB high container
431  edm::Handle<edm::PSimHitContainer> SiTOBHighContainer;
432  e.getByToken(edmPSimHitContainer_siTOBHigh_Token_, SiTOBHighContainer);
433  if (!SiTOBHighContainer.isValid()) {
434  edm::LogError("TrackerHitProducer::analyze") << "Unable to find TrackerHitsTOBHighTof in event!";
435  return;
436  }
437 
439  // get Silicon TID information
441  // extract TID low container
442  edm::Handle<edm::PSimHitContainer> SiTIDLowContainer;
443  e.getByToken(edmPSimHitContainer_siTIDLow_Token_, SiTIDLowContainer);
444  if (!SiTIDLowContainer.isValid()) {
445  edm::LogError("TrackerHitProducer::analyze") << "Unable to find TrackerHitsTIDLowTof in event!";
446  return;
447  }
449  // extract TID high container
450  edm::Handle<edm::PSimHitContainer> SiTIDHighContainer;
451  e.getByToken(edmPSimHitContainer_siTIDHigh_Token_, SiTIDHighContainer);
452  if (!SiTIDHighContainer.isValid()) {
453  edm::LogError("TrackerHitProducer::analyze") << "Unable to find TrackerHitsTIDHighTof in event!";
454  return;
455  }
457  // get Silicon TEC information
459  // extract TEC low container
460  edm::Handle<edm::PSimHitContainer> SiTECLowContainer;
461  e.getByToken(edmPSimHitContainer_siTECLow_Token_, SiTECLowContainer);
462  if (!SiTECLowContainer.isValid()) {
463  edm::LogError("TrackerHitProducer::analyze") << "Unable to find TrackerHitsTECLowTof in event!";
464  return;
465  }
467  // extract TEC high container
468  edm::Handle<edm::PSimHitContainer> SiTECHighContainer;
469  e.getByToken(edmPSimHitContainer_siTECHigh_Token_, SiTECHighContainer);
470  if (!SiTECHighContainer.isValid()) {
471  edm::LogError("TrackerHitProducer::analyze") << "Unable to find TrackerHitsTECHighTof in event!";
472  return;
473  }
474 
476  // get G4Track information
478 
480  e.getByToken(edmSimTrackContainerToken_, G4TrkContainer);
481  if (!G4TrkContainer.isValid()) {
482  edm::LogError("TrackerHitAnalyzer::analyze") << "Unable to find SimTrack in event!";
483  return;
484  }
485 
486  // Get geometry information
487 
489  c.get<TrackerDigiGeometryRecord>().get(tracker);
490 
491  int ir = -100;
492  edm::SimTrackContainer::const_iterator itTrk;
493  for (itTrk = G4TrkContainer->begin(); itTrk != G4TrkContainer->end(); ++itTrk) {
494  // std::cout << "itTrk = "<< itTrk << std::endl;
495  double eta = 0, p = 0;
496  const CLHEP::HepLorentzVector &G4Trk = CLHEP::HepLorentzVector(
497  itTrk->momentum().x(), itTrk->momentum().y(), itTrk->momentum().z(), itTrk->momentum().e());
498  p = sqrt(G4Trk[0] * G4Trk[0] + G4Trk[1] * G4Trk[1] + G4Trk[2] * G4Trk[2]);
499  if (p == 0)
500  edm::LogError("TrackerHitAnalyzer::analyze") << "TrackerTest::INFO: Primary has p = 0 ";
501  else {
502  double costheta = G4Trk[2] / p;
503  double theta = acos(TMath::Min(TMath::Max(costheta, -1.), 1.));
504  eta = -log(tan(theta / 2));
505 
506  if (eta > 0.0 && eta <= 0.5)
507  ir = 0;
508  if (eta > 0.5 && eta <= 1.0)
509  ir = 1;
510  if (eta > 1.0 && eta <= 1.5)
511  ir = 2;
512  if (eta > 1.5 && eta <= 2.0)
513  ir = 3;
514  if (eta > 2.0 && eta <= 2.5)
515  ir = 4;
516  if (eta > 2.5)
517  ir = 5;
518 
519  if (eta > -0.5 && eta <= 0.0)
520  ir = 6;
521  if (eta > -1.0 && eta <= -0.5)
522  ir = 7;
523  if (eta > -1.5 && eta <= -1.0)
524  ir = 8;
525  if (eta > -2.0 && eta <= -1.5)
526  ir = 9;
527  if (eta > -2.5 && eta <= -2.0)
528  ir = 10;
529  if (eta <= -2.5)
530  ir = 11;
531  // edm::LogInfo("EventInfo") << " eta = " << eta << " ir = " <<
532  // ir;
533  // std::cout << " " << std::endl;
534  // std::cout << "eta " << eta << " ir = " << ir << std::endl;
535  // std::cout << " " << std::endl;
536  }
537  }
539  // get Pixel information
541  // If Phase 1, do not run - will run in new Phase 1 module
542 
543  if (pixelOutput) {
544  for (itHit = PxlBrlLowContainer->begin(); itHit != PxlBrlLowContainer->end(); ++itHit) {
545  DetId detid = DetId(itHit->detUnitId());
546  const GeomDetUnit *det = (const GeomDetUnit *)tracker->idToDetUnit(detid);
547  GlobalPoint gpos = det->toGlobal(itHit->localPosition());
548  htofeta->Fill(gpos.eta(), itHit->timeOfFlight());
549  htofphi->Fill(gpos.phi().degrees(), itHit->timeOfFlight());
550  htofr->Fill(gpos.mag(), itHit->timeOfFlight());
551  htofz->Fill(gpos.z(), itHit->timeOfFlight());
552 
553  h5e[ir]->Fill(itHit->energyLoss());
554  h5ex[ir]->Fill(itHit->entryPoint().x() - itHit->exitPoint().x());
555  h5ey[ir]->Fill(itHit->entryPoint().y() - itHit->exitPoint().y());
556  h5ez[ir]->Fill(std::fabs(itHit->entryPoint().z() - itHit->exitPoint().z()));
557  h5lx[ir]->Fill(itHit->localPosition().x());
558  h5ly[ir]->Fill(itHit->localPosition().y());
559  }
560  for (itHit = PxlBrlHighContainer->begin(); itHit != PxlBrlHighContainer->end(); ++itHit) {
561  DetId detid = DetId(itHit->detUnitId());
562  const GeomDetUnit *det = (const GeomDetUnit *)tracker->idToDetUnit(detid);
563  GlobalPoint gpos = det->toGlobal(itHit->localPosition());
564  htofeta->Fill(gpos.eta(), itHit->timeOfFlight());
565  htofphi->Fill(gpos.phi().degrees(), itHit->timeOfFlight());
566  htofr->Fill(gpos.mag(), itHit->timeOfFlight());
567  htofz->Fill(gpos.z(), itHit->timeOfFlight());
568 
569  h5e[ir]->Fill(itHit->energyLoss());
570  h5ex[ir]->Fill(itHit->entryPoint().x() - itHit->exitPoint().x());
571  h5ey[ir]->Fill(itHit->entryPoint().y() - itHit->exitPoint().y());
572  h5ez[ir]->Fill(std::fabs(itHit->entryPoint().z() - itHit->exitPoint().z()));
573  h5lx[ir]->Fill(itHit->localPosition().x());
574  h5ly[ir]->Fill(itHit->localPosition().y());
575  }
576  for (itHit = PxlFwdLowContainer->begin(); itHit != PxlFwdLowContainer->end(); ++itHit) {
577  DetId detid = DetId(itHit->detUnitId());
578  const GeomDetUnit *det = (const GeomDetUnit *)tracker->idToDetUnit(detid);
579  GlobalPoint gpos = det->toGlobal(itHit->localPosition());
580  htofeta->Fill(gpos.eta(), itHit->timeOfFlight());
581  htofphi->Fill(gpos.phi().degrees(), itHit->timeOfFlight());
582  htofr->Fill(gpos.mag(), itHit->timeOfFlight());
583  htofz->Fill(gpos.z(), itHit->timeOfFlight());
584 
585  h6e[ir]->Fill(itHit->energyLoss());
586  h6ex[ir]->Fill(itHit->entryPoint().x() - itHit->exitPoint().x());
587  h6ey[ir]->Fill(itHit->entryPoint().y() - itHit->exitPoint().y());
588  h6ez[ir]->Fill(std::fabs(itHit->entryPoint().z() - itHit->exitPoint().z()));
589  h6lx[ir]->Fill(itHit->localPosition().x());
590  h6ly[ir]->Fill(itHit->localPosition().y());
591  }
592  for (itHit = PxlFwdHighContainer->begin(); itHit != PxlFwdHighContainer->end(); ++itHit) {
593  DetId detid = DetId(itHit->detUnitId());
594  const GeomDetUnit *det = (const GeomDetUnit *)tracker->idToDetUnit(detid);
595  GlobalPoint gpos = det->toGlobal(itHit->localPosition());
596  htofeta->Fill(gpos.eta(), itHit->timeOfFlight());
597  htofphi->Fill(gpos.phi().degrees(), itHit->timeOfFlight());
598  htofr->Fill(gpos.mag(), itHit->timeOfFlight());
599  htofz->Fill(gpos.z(), itHit->timeOfFlight());
600 
601  h6e[ir]->Fill(itHit->energyLoss());
602  h6ex[ir]->Fill(itHit->entryPoint().x() - itHit->exitPoint().x());
603  h6ey[ir]->Fill(itHit->entryPoint().y() - itHit->exitPoint().y());
604  h6ez[ir]->Fill(std::fabs(itHit->entryPoint().z() - itHit->exitPoint().z()));
605  h6lx[ir]->Fill(itHit->localPosition().x());
606  h6ly[ir]->Fill(itHit->localPosition().y());
607  }
608  }
610  // get TIB information
612  for (itHit = SiTIBLowContainer->begin(); itHit != SiTIBLowContainer->end(); ++itHit) {
613  DetId detid = DetId(itHit->detUnitId());
614  const GeomDetUnit *det = (const GeomDetUnit *)tracker->idToDetUnit(detid);
615  GlobalPoint gpos = det->toGlobal(itHit->localPosition());
616  htofeta->Fill(gpos.eta(), itHit->timeOfFlight());
617  htofphi->Fill(gpos.phi().degrees(), itHit->timeOfFlight());
618  htofr->Fill(gpos.mag(), itHit->timeOfFlight());
619  htofz->Fill(gpos.z(), itHit->timeOfFlight());
620 
621  h1e[ir]->Fill(itHit->energyLoss());
622  h1ex[ir]->Fill(itHit->entryPoint().x() - itHit->exitPoint().x());
623  h1ey[ir]->Fill(itHit->entryPoint().y() - itHit->exitPoint().y());
624  h1ez[ir]->Fill(std::fabs(itHit->entryPoint().z() - itHit->exitPoint().z()));
625  h1lx[ir]->Fill(itHit->localPosition().x());
626  h1ly[ir]->Fill(itHit->localPosition().y());
627  }
628  for (itHit = SiTIBHighContainer->begin(); itHit != SiTIBHighContainer->end(); ++itHit) {
629  DetId detid = DetId(itHit->detUnitId());
630  const GeomDetUnit *det = (const GeomDetUnit *)tracker->idToDetUnit(detid);
631  GlobalPoint gpos = det->toGlobal(itHit->localPosition());
632  htofeta->Fill(gpos.eta(), itHit->timeOfFlight());
633  htofphi->Fill(gpos.phi().degrees(), itHit->timeOfFlight());
634  htofr->Fill(gpos.mag(), itHit->timeOfFlight());
635  htofz->Fill(gpos.z(), itHit->timeOfFlight());
636 
637  h1e[ir]->Fill(itHit->energyLoss());
638  h1ex[ir]->Fill(itHit->entryPoint().x() - itHit->exitPoint().x());
639  h1ey[ir]->Fill(itHit->entryPoint().y() - itHit->exitPoint().y());
640  h1ez[ir]->Fill(std::fabs(itHit->entryPoint().z() - itHit->exitPoint().z()));
641  h1lx[ir]->Fill(itHit->localPosition().x());
642  h1ly[ir]->Fill(itHit->localPosition().y());
643  }
645  // get TOB information
647  for (itHit = SiTOBLowContainer->begin(); itHit != SiTOBLowContainer->end(); ++itHit) {
648  DetId detid = DetId(itHit->detUnitId());
649  const GeomDetUnit *det = (const GeomDetUnit *)tracker->idToDetUnit(detid);
650  GlobalPoint gpos = det->toGlobal(itHit->localPosition());
651  htofeta->Fill(gpos.eta(), itHit->timeOfFlight());
652  htofphi->Fill(gpos.phi().degrees(), itHit->timeOfFlight());
653  htofr->Fill(gpos.mag(), itHit->timeOfFlight());
654  htofz->Fill(gpos.z(), itHit->timeOfFlight());
655 
656  h2e[ir]->Fill(itHit->energyLoss());
657  h2ex[ir]->Fill(itHit->entryPoint().x() - itHit->exitPoint().x());
658  h2ey[ir]->Fill(itHit->entryPoint().y() - itHit->exitPoint().y());
659  h2ez[ir]->Fill(std::fabs(itHit->entryPoint().z() - itHit->exitPoint().z()));
660  h2lx[ir]->Fill(itHit->localPosition().x());
661  h2ly[ir]->Fill(itHit->localPosition().y());
662  }
663  for (itHit = SiTOBHighContainer->begin(); itHit != SiTOBHighContainer->end(); ++itHit) {
664  DetId detid = DetId(itHit->detUnitId());
665  const GeomDetUnit *det = (const GeomDetUnit *)tracker->idToDetUnit(detid);
666  GlobalPoint gpos = det->toGlobal(itHit->localPosition());
667  htofeta->Fill(gpos.eta(), itHit->timeOfFlight());
668  htofphi->Fill(gpos.phi().degrees(), itHit->timeOfFlight());
669  htofr->Fill(gpos.mag(), itHit->timeOfFlight());
670  htofz->Fill(gpos.z(), itHit->timeOfFlight());
671 
672  h2e[ir]->Fill(itHit->energyLoss());
673  h2ex[ir]->Fill(itHit->entryPoint().x() - itHit->exitPoint().x());
674  h2ey[ir]->Fill(itHit->entryPoint().y() - itHit->exitPoint().y());
675  h2ez[ir]->Fill(std::fabs(itHit->entryPoint().z() - itHit->exitPoint().z()));
676  h2lx[ir]->Fill(itHit->localPosition().x());
677  h2ly[ir]->Fill(itHit->localPosition().y());
678  }
680  // get TID information
682  for (itHit = SiTIDLowContainer->begin(); itHit != SiTIDLowContainer->end(); ++itHit) {
683  DetId detid = DetId(itHit->detUnitId());
684  const GeomDetUnit *det = (const GeomDetUnit *)tracker->idToDetUnit(detid);
685  GlobalPoint gpos = det->toGlobal(itHit->localPosition());
686  htofeta->Fill(gpos.eta(), itHit->timeOfFlight());
687  htofphi->Fill(gpos.phi().degrees(), itHit->timeOfFlight());
688  htofr->Fill(gpos.mag(), itHit->timeOfFlight());
689  htofz->Fill(gpos.z(), itHit->timeOfFlight());
690 
691  h3e[ir]->Fill(itHit->energyLoss());
692  h3ex[ir]->Fill(itHit->entryPoint().x() - itHit->exitPoint().x());
693  h3ey[ir]->Fill(itHit->entryPoint().y() - itHit->exitPoint().y());
694  h3ez[ir]->Fill(std::fabs(itHit->entryPoint().z() - itHit->exitPoint().z()));
695  h3lx[ir]->Fill(itHit->localPosition().x());
696  h3ly[ir]->Fill(itHit->localPosition().y());
697  }
698  for (itHit = SiTIDHighContainer->begin(); itHit != SiTIDHighContainer->end(); ++itHit) {
699  DetId detid = DetId(itHit->detUnitId());
700  const GeomDetUnit *det = (const GeomDetUnit *)tracker->idToDetUnit(detid);
701  GlobalPoint gpos = det->toGlobal(itHit->localPosition());
702  htofeta->Fill(gpos.eta(), itHit->timeOfFlight());
703  htofphi->Fill(gpos.phi().degrees(), itHit->timeOfFlight());
704  htofr->Fill(gpos.mag(), itHit->timeOfFlight());
705  htofz->Fill(gpos.z(), itHit->timeOfFlight());
706 
707  h3e[ir]->Fill(itHit->energyLoss());
708  h3ex[ir]->Fill(itHit->entryPoint().x() - itHit->exitPoint().x());
709  h3ey[ir]->Fill(itHit->entryPoint().y() - itHit->exitPoint().y());
710  h3ez[ir]->Fill(std::fabs(itHit->entryPoint().z() - itHit->exitPoint().z()));
711  h3lx[ir]->Fill(itHit->localPosition().x());
712  h3ly[ir]->Fill(itHit->localPosition().y());
713  }
715  // get TEC information
717  for (itHit = SiTECLowContainer->begin(); itHit != SiTECLowContainer->end(); ++itHit) {
718  DetId detid = DetId(itHit->detUnitId());
719  const GeomDetUnit *det = (const GeomDetUnit *)tracker->idToDetUnit(detid);
720  GlobalPoint gpos = det->toGlobal(itHit->localPosition());
721  htofeta->Fill(gpos.eta(), itHit->timeOfFlight());
722  htofphi->Fill(gpos.phi().degrees(), itHit->timeOfFlight());
723  htofr->Fill(gpos.mag(), itHit->timeOfFlight());
724  htofz->Fill(gpos.z(), itHit->timeOfFlight());
725 
726  h4e[ir]->Fill(itHit->energyLoss());
727  h4ex[ir]->Fill(itHit->entryPoint().x() - itHit->exitPoint().x());
728  h4ey[ir]->Fill(itHit->entryPoint().y() - itHit->exitPoint().y());
729  h4ez[ir]->Fill(std::fabs(itHit->entryPoint().z() - itHit->exitPoint().z()));
730  h4lx[ir]->Fill(itHit->localPosition().x());
731  h4ly[ir]->Fill(itHit->localPosition().y());
732  }
733  for (itHit = SiTECHighContainer->begin(); itHit != SiTECHighContainer->end(); ++itHit) {
734  DetId detid = DetId(itHit->detUnitId());
735  const GeomDetUnit *det = (const GeomDetUnit *)tracker->idToDetUnit(detid);
736  GlobalPoint gpos = det->toGlobal(itHit->localPosition());
737  htofeta->Fill(gpos.eta(), itHit->timeOfFlight());
738  htofphi->Fill(gpos.phi().degrees(), itHit->timeOfFlight());
739  htofr->Fill(gpos.mag(), itHit->timeOfFlight());
740  htofz->Fill(gpos.z(), itHit->timeOfFlight());
741 
742  h4e[ir]->Fill(itHit->energyLoss());
743  h4ex[ir]->Fill(itHit->entryPoint().x() - itHit->exitPoint().x());
744  h4ey[ir]->Fill(itHit->entryPoint().y() - itHit->exitPoint().y());
745  h4ez[ir]->Fill(std::fabs(itHit->entryPoint().z() - itHit->exitPoint().z()));
746  h4lx[ir]->Fill(itHit->localPosition().x());
747  h4ly[ir]->Fill(itHit->localPosition().y());
748  }
749 
750  return;
751 }
752 
RunNumber_t run() const
Definition: EventID.h:39
MonitorElement * h1e[12]
EventNumber_t event() const
Definition: EventID.h:41
void bookHistograms(DQMStore::IBooker &ibooker, const edm::Run &run, const edm::EventSetup &es) override
MonitorElement * h2lx[12]
MonitorElement * h4e[12]
MonitorElement * h1lx[12]
MonitorElement * h6ex[12]
MonitorElement * h1ey[12]
edm::EDGetTokenT< edm::PSimHitContainer > edmPSimHitContainer_siTECLow_Token_
MonitorElement * h3ly[12]
MonitorElement * h5ez[12]
MonitorElement * h4ex[12]
edm::EDGetTokenT< edm::SimTrackContainer > edmSimTrackContainerToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
MonitorElement * h1ez[12]
~TrackerHitAnalyzer() override
Destructor.
MonitorElement * h3ez[12]
edm::EDGetTokenT< edm::PSimHitContainer > edmPSimHitContainer_pxlBrlLow_Token_
#define nullptr
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
Geom::Theta< T > theta() const
MonitorElement * h5ey[12]
MonitorElement * h3lx[12]
edm::EDGetTokenT< edm::PSimHitContainer > edmPSimHitContainer_siTOBLow_Token_
edm::EDGetTokenT< edm::PSimHitContainer > edmPSimHitContainer_pxlFwdLow_Token_
T Min(T a, T b)
Definition: MathUtil.h:39
MonitorElement * htofr
MonitorElement * h6ly[12]
MonitorElement * h5ex[12]
MonitorElement * h5ly[12]
void Fill(long long x)
MonitorElement * htofeta
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
edm::EDGetTokenT< edm::PSimHitContainer > edmPSimHitContainer_siTIBLow_Token_
void analyze(const edm::Event &e, const edm::EventSetup &c) override
Analyze.
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::EDGetTokenT< edm::PSimHitContainer > edmPSimHitContainer_siTOBHigh_Token_
T mag() const
Definition: PV3DBase.h:67
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:268
T sqrt(T t)
Definition: SSEVec.h:18
MonitorElement * h1ex[12]
T z() const
Definition: PV3DBase.h:64
MonitorElement * h2e[12]
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:106
MonitorElement * h6ey[12]
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
MonitorElement * h4lx[12]
void setVerbose(unsigned level)
Definition: DQMStore.cc:531
bool isValid() const
Definition: HandleBase.h:74
MonitorElement * h2ex[12]
MonitorElement * h6ez[12]
edm::EDGetTokenT< edm::PSimHitContainer > edmPSimHitContainer_siTIDLow_Token_
MonitorElement * h2ez[12]
MonitorElement * htofz
T Max(T a, T b)
Definition: MathUtil.h:44
Definition: DetId.h:18
MonitorElement * htofphi
void showDirStructure() const
Definition: DQMStore.cc:3307
edm::EDGetTokenT< edm::PSimHitContainer > edmPSimHitContainer_pxlBrlHigh_Token_
MonitorElement * h5lx[12]
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:109
MonitorElement * h4ey[12]
MonitorElement * h1ly[12]
void save(std::string const &filename, std::string const &path="", std::string const &pattern="", std::string const &rewrite="", uint32_t run=0, uint32_t lumi=0, SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, std::string const &fileupdate="RECREATE")
Definition: DQMStore.cc:2465
MonitorElement * h4ly[12]
T eta() const
Definition: PV3DBase.h:76
MonitorElement * h3ex[12]
edm::EventID id() const
Definition: EventBase.h:59
MonitorElement * h3ey[12]
HLT enums.
MonitorElement * h2ey[12]
T get() const
Definition: EventSetup.h:71
MonitorElement * h2ly[12]
MonitorElement * h3e[12]
edm::EDGetTokenT< edm::PSimHitContainer > edmPSimHitContainer_siTIBHigh_Token_
std::vector< PSimHit > PSimHitContainer
edm::EDGetTokenT< edm::PSimHitContainer > edmPSimHitContainer_pxlFwdHigh_Token_
TrackerHitAnalyzer(const edm::ParameterSet &ps)
Constructor.
edm::EDGetTokenT< edm::PSimHitContainer > edmPSimHitContainer_siTECHigh_Token_
MonitorElement * h6e[12]
std::vector< SimTrack > SimTrackContainer
edm::EDGetTokenT< edm::PSimHitContainer > edmPSimHitContainer_siTIDHigh_Token_
void endJob() override
MonitorElement * h5e[12]
MonitorElement * h6lx[12]
Definition: Run.h:45
MonitorElement * h4ez[12]