CMS 3D CMS Logo

GlobalHitsProdHist.cc
Go to the documentation of this file.
1 
11 
13  : fName(""),
14  verbosity(0),
15  frequency(0),
16  vtxunit(0),
17  getAllProvenances(false),
18  printProvenanceInfo(false),
19  G4VtxSrc_Token_(consumes<edm::SimVertexContainer>((iPSet.getParameter<edm::InputTag>("G4VtxSrc")))),
20  G4TrkSrc_Token_(consumes<edm::SimTrackContainer>(iPSet.getParameter<edm::InputTag>("G4TrkSrc"))),
21  tGeomToken_(esConsumes()),
22  cscGeomToken_(esConsumes()),
23  dtGeomToken_(esConsumes()),
24  rpcGeomToken_(esConsumes()),
25  caloGeomToken_(esConsumes()),
26  count(0) {
27  std::string MsgLoggerCat = "GlobalHitsProdHist_GlobalHitsProdHist";
28 
29  // get information from parameter set
30  fName = iPSet.getUntrackedParameter<std::string>("Name");
31  verbosity = iPSet.getUntrackedParameter<int>("Verbosity");
32  frequency = iPSet.getUntrackedParameter<int>("Frequency");
33  vtxunit = iPSet.getUntrackedParameter<int>("VtxUnit");
34  edm::ParameterSet m_Prov = iPSet.getParameter<edm::ParameterSet>("ProvenanceLookup");
35  getAllProvenances = m_Prov.getUntrackedParameter<bool>("GetAllProvenances");
36  printProvenanceInfo = m_Prov.getUntrackedParameter<bool>("PrintProvenanceInfo");
37 
38  // get Labels to use to extract information
39  PxlBrlLowSrc_ = iPSet.getParameter<edm::InputTag>("PxlBrlLowSrc");
40  PxlBrlHighSrc_ = iPSet.getParameter<edm::InputTag>("PxlBrlHighSrc");
41  PxlFwdLowSrc_ = iPSet.getParameter<edm::InputTag>("PxlFwdLowSrc");
42  PxlFwdHighSrc_ = iPSet.getParameter<edm::InputTag>("PxlFwdHighSrc");
43 
44  SiTIBLowSrc_ = iPSet.getParameter<edm::InputTag>("SiTIBLowSrc");
45  SiTIBHighSrc_ = iPSet.getParameter<edm::InputTag>("SiTIBHighSrc");
46  SiTOBLowSrc_ = iPSet.getParameter<edm::InputTag>("SiTOBLowSrc");
47  SiTOBHighSrc_ = iPSet.getParameter<edm::InputTag>("SiTOBHighSrc");
48  SiTIDLowSrc_ = iPSet.getParameter<edm::InputTag>("SiTIDLowSrc");
49  SiTIDHighSrc_ = iPSet.getParameter<edm::InputTag>("SiTIDHighSrc");
50  SiTECLowSrc_ = iPSet.getParameter<edm::InputTag>("SiTECLowSrc");
51  SiTECHighSrc_ = iPSet.getParameter<edm::InputTag>("SiTECHighSrc");
52 
53  MuonCscSrc_ = iPSet.getParameter<edm::InputTag>("MuonCscSrc");
54  MuonDtSrc_ = iPSet.getParameter<edm::InputTag>("MuonDtSrc");
55  MuonRpcSrc_ = iPSet.getParameter<edm::InputTag>("MuonRpcSrc");
56 
57  ECalEBSrc_ = iPSet.getParameter<edm::InputTag>("ECalEBSrc");
58  ECalEESrc_ = iPSet.getParameter<edm::InputTag>("ECalEESrc");
59  ECalESSrc_ = iPSet.getParameter<edm::InputTag>("ECalESSrc");
60 
61  HCalSrc_ = iPSet.getParameter<edm::InputTag>("HCalSrc");
62 
63  // use value of first digit to determine default output level (inclusive)
64  // 0 is none, 1 is basic, 2 is fill output, 3 is gather output
65  verbosity %= 10;
66 
67  // print out Parameter Set information being used
68  if (verbosity >= 0) {
69  edm::LogInfo(MsgLoggerCat)
70  << "\n===============================\n"
71  << "Initialized as EDProducer with parameter values:\n"
72  << " Name = " << fName << "\n"
73  << " Verbosity = " << verbosity << "\n"
74  << " Frequency = " << frequency << "\n"
75  << " VtxUnit = " << vtxunit << "\n"
76  << " GetProv = " << getAllProvenances << "\n"
77  << " PrintProv = " << printProvenanceInfo << "\n"
78  << " PxlBrlLowSrc = " << PxlBrlLowSrc_.label() << ":" << PxlBrlLowSrc_.instance() << "\n"
79  << " PxlBrlHighSrc = " << PxlBrlHighSrc_.label() << ":" << PxlBrlHighSrc_.instance() << "\n"
80  << " PxlFwdLowSrc = " << PxlFwdLowSrc_.label() << ":" << PxlBrlLowSrc_.instance() << "\n"
81  << " PxlFwdHighSrc = " << PxlFwdHighSrc_.label() << ":" << PxlBrlHighSrc_.instance() << "\n"
82  << " SiTIBLowSrc = " << SiTIBLowSrc_.label() << ":" << SiTIBLowSrc_.instance() << "\n"
83  << " SiTIBHighSrc = " << SiTIBHighSrc_.label() << ":" << SiTIBHighSrc_.instance() << "\n"
84  << " SiTOBLowSrc = " << SiTOBLowSrc_.label() << ":" << SiTOBLowSrc_.instance() << "\n"
85  << " SiTOBHighSrc = " << SiTOBHighSrc_.label() << ":" << SiTOBHighSrc_.instance() << "\n"
86  << " SiTIDLowSrc = " << SiTIDLowSrc_.label() << ":" << SiTIDLowSrc_.instance() << "\n"
87  << " SiTIDHighSrc = " << SiTIDHighSrc_.label() << ":" << SiTIDHighSrc_.instance() << "\n"
88  << " SiTECLowSrc = " << SiTECLowSrc_.label() << ":" << SiTECLowSrc_.instance() << "\n"
89  << " SiTECHighSrc = " << SiTECHighSrc_.label() << ":" << SiTECHighSrc_.instance() << "\n"
90  << " MuonCscSrc = " << MuonCscSrc_.label() << ":" << MuonCscSrc_.instance() << "\n"
91  << " MuonDtSrc = " << MuonDtSrc_.label() << ":" << MuonDtSrc_.instance() << "\n"
92  << " MuonRpcSrc = " << MuonRpcSrc_.label() << ":" << MuonRpcSrc_.instance() << "\n"
93  << " ECalEBSrc = " << ECalEBSrc_.label() << ":" << ECalEBSrc_.instance() << "\n"
94  << " ECalEESrc = " << ECalEESrc_.label() << ":" << ECalEESrc_.instance() << "\n"
95  << " ECalESSrc = " << ECalESSrc_.label() << ":" << ECalESSrc_.instance() << "\n"
96  << " HCalSrc = " << HCalSrc_.label() << ":" << HCalSrc_.instance() << "\n"
97  << "===============================\n";
98  }
99 
100  // create histograms
101  Char_t hname[200];
102  Char_t htitle[200];
103 
104  // MCGeant
105  sprintf(hname, "hMCRGP1");
106  histName_.push_back(hname);
107  sprintf(htitle, "RawGenParticles");
108  hMCRGP[0] = new TH1F(hname, htitle, 100, 0., 5000.);
109  sprintf(hname, "hMCRGP2");
110  histName_.push_back(hname);
111  hMCRGP[1] = new TH1F(hname, htitle, 100, 0., 500.);
112  for (Int_t i = 0; i < 2; ++i) {
113  hMCRGP[i]->GetXaxis()->SetTitle("Number of Raw Generated Particles");
114  hMCRGP[i]->GetYaxis()->SetTitle("Count");
115  histMap_[hMCRGP[i]->GetName()] = hMCRGP[i];
116  }
117 
118  sprintf(hname, "hMCG4Vtx1");
119  histName_.push_back(hname);
120  sprintf(htitle, "G4 Vertices");
121  hMCG4Vtx[0] = new TH1F(hname, htitle, 100, 0., 50000.);
122  sprintf(hname, "hMCG4Vtx2");
123  histName_.push_back(hname);
124  hMCG4Vtx[1] = new TH1F(hname, htitle, 100, -0.5, 99.5);
125  for (Int_t i = 0; i < 2; ++i) {
126  hMCG4Vtx[i]->GetXaxis()->SetTitle("Number of Vertices");
127  hMCG4Vtx[i]->GetYaxis()->SetTitle("Count");
128  histMap_[hMCG4Vtx[i]->GetName()] = hMCG4Vtx[i];
129  }
130 
131  sprintf(hname, "hMCG4Trk1");
132  histName_.push_back(hname);
133  sprintf(htitle, "G4 Tracks");
134  hMCG4Trk[0] = new TH1F(hname, htitle, 150, 0., 15000.);
135  sprintf(hname, "hMCG4Trk2");
136  histName_.push_back(hname);
137  hMCG4Trk[1] = new TH1F(hname, htitle, 150, -0.5, 99.5);
138  for (Int_t i = 0; i < 2; ++i) {
139  hMCG4Trk[i]->GetXaxis()->SetTitle("Number of Tracks");
140  hMCG4Trk[i]->GetYaxis()->SetTitle("Count");
141  histMap_[hMCG4Trk[i]->GetName()] = hMCG4Trk[i];
142  }
143 
144  sprintf(hname, "hGeantVtxX1");
145  histName_.push_back(hname);
146  sprintf(htitle, "Geant vertex x/micrometer");
147  hGeantVtxX[0] = new TH1F(hname, htitle, 100, -8000000., 8000000.);
148  sprintf(hname, "hGeantVtxX2");
149  histName_.push_back(hname);
150  hGeantVtxX[1] = new TH1F(hname, htitle, 100, -50., 50.);
151  for (Int_t i = 0; i < 2; ++i) {
152  hGeantVtxX[i]->GetXaxis()->SetTitle("x of Vertex (um)");
153  hGeantVtxX[i]->GetYaxis()->SetTitle("Count");
154  histMap_[hGeantVtxX[i]->GetName()] = hGeantVtxX[i];
155  }
156 
157  sprintf(hname, "hGeantVtxY1");
158  histName_.push_back(hname);
159  sprintf(htitle, "Geant vertex y/micrometer");
160  hGeantVtxY[0] = new TH1F(hname, htitle, 100, -8000000, 8000000.);
161  sprintf(hname, "hGeantVtxY2");
162  histName_.push_back(hname);
163  hGeantVtxY[1] = new TH1F(hname, htitle, 100, -50., 50.);
164  for (Int_t i = 0; i < 2; ++i) {
165  hGeantVtxY[i]->GetXaxis()->SetTitle("y of Vertex (um)");
166  hGeantVtxY[i]->GetYaxis()->SetTitle("Count");
167  histMap_[hGeantVtxY[i]->GetName()] = hGeantVtxY[i];
168  }
169 
170  sprintf(hname, "hGeantVtxZ1");
171  histName_.push_back(hname);
172  sprintf(htitle, "Geant vertex z/millimeter");
173  hGeantVtxZ[0] = new TH1F(hname, htitle, 100, -11000., 11000.);
174  sprintf(hname, "hGeantVtxZ2");
175  histName_.push_back(hname);
176  hGeantVtxZ[1] = new TH1F(hname, htitle, 100, -250., 250.);
177  for (Int_t i = 0; i < 2; ++i) {
178  hGeantVtxZ[i]->GetXaxis()->SetTitle("z of Vertex (mm)");
179  hGeantVtxZ[i]->GetYaxis()->SetTitle("Count");
180  histMap_[hGeantVtxZ[i]->GetName()] = hGeantVtxZ[i];
181  }
182 
183  sprintf(hname, "hGeantTrkPt");
184  histName_.push_back(hname);
185  sprintf(htitle, "Geant track pt/GeV");
186  hGeantTrkPt = new TH1F(hname, htitle, 100, 0., 200.);
187  hGeantTrkPt->GetXaxis()->SetTitle("pT of Track (GeV)");
188  hGeantTrkPt->GetYaxis()->SetTitle("Count");
189  histMap_[hGeantTrkPt->GetName()] = hGeantTrkPt;
190 
191  sprintf(hname, "hGeantTrkE");
192  histName_.push_back(hname);
193  sprintf(htitle, "Geant track E/GeV");
194  hGeantTrkE = new TH1F(hname, htitle, 100, 0., 5000.);
195  hGeantTrkE->GetXaxis()->SetTitle("E of Track (GeV)");
196  hGeantTrkE->GetYaxis()->SetTitle("Count");
197  histMap_[hGeantTrkE->GetName()] = hGeantTrkE;
198 
199  // ECal
200  sprintf(hname, "hCaloEcal1");
201  histName_.push_back(hname);
202  sprintf(htitle, "Ecal hits");
203  hCaloEcal[0] = new TH1F(hname, htitle, 100, 0., 10000.);
204  sprintf(hname, "hCaloEcal2");
205  histName_.push_back(hname);
206  hCaloEcal[1] = new TH1F(hname, htitle, 100, -0.5, 99.5);
207 
208  sprintf(hname, "hCaloEcalE1");
209  histName_.push_back(hname);
210  sprintf(htitle, "Ecal hits, energy/GeV");
211  hCaloEcalE[0] = new TH1F(hname, htitle, 100, 0., 10.);
212  sprintf(hname, "hCaloEcalE2");
213  histName_.push_back(hname);
214  hCaloEcalE[1] = new TH1F(hname, htitle, 100, 0., 0.1);
215 
216  sprintf(hname, "hCaloEcalToF1");
217  histName_.push_back(hname);
218  sprintf(htitle, "Ecal hits, ToF/ns");
219  hCaloEcalToF[0] = new TH1F(hname, htitle, 100, 0., 1000.);
220  sprintf(hname, "hCaloEcalToF2");
221  histName_.push_back(hname);
222  hCaloEcalToF[1] = new TH1F(hname, htitle, 100, 0., 100.);
223 
224  for (Int_t i = 0; i < 2; ++i) {
225  hCaloEcal[i]->GetXaxis()->SetTitle("Number of Hits");
226  hCaloEcal[i]->GetYaxis()->SetTitle("Count");
227  histMap_[hCaloEcal[i]->GetName()] = hCaloEcal[i];
228  hCaloEcalE[i]->GetXaxis()->SetTitle("Energy of Hits (GeV)");
229  hCaloEcalE[i]->GetYaxis()->SetTitle("Count");
230  histMap_[hCaloEcalE[i]->GetName()] = hCaloEcalE[i];
231  hCaloEcalToF[i]->GetXaxis()->SetTitle("Time of Flight of Hits (ns)");
232  hCaloEcalToF[i]->GetYaxis()->SetTitle("Count");
233  histMap_[hCaloEcalToF[i]->GetName()] = hCaloEcalToF[i];
234  }
235 
236  sprintf(hname, "hCaloEcalPhi");
237  histName_.push_back(hname);
238  sprintf(htitle, "Ecal hits, phi/rad");
239  hCaloEcalPhi = new TH1F(hname, htitle, 100, -3.2, 3.2);
240  hCaloEcalPhi->GetXaxis()->SetTitle("Phi of Hits (rad)");
241  hCaloEcalPhi->GetYaxis()->SetTitle("Count");
242  histMap_[hCaloEcalPhi->GetName()] = hCaloEcalPhi;
243 
244  sprintf(hname, "hCaloEcalEta");
245  histName_.push_back(hname);
246  sprintf(htitle, "Ecal hits, eta");
247  hCaloEcalEta = new TH1F(hname, htitle, 100, -5.5, 5.5);
248  hCaloEcalEta->GetXaxis()->SetTitle("Eta of Hits");
249  hCaloEcalEta->GetYaxis()->SetTitle("Count");
250  histMap_[hCaloEcalEta->GetName()] = hCaloEcalEta;
251 
252  sprintf(hname, "hCaloPreSh1");
253  histName_.push_back(hname);
254  sprintf(htitle, "PreSh hits");
255  hCaloPreSh[0] = new TH1F(hname, htitle, 100, 0., 10000.);
256  sprintf(hname, "hCaloPreSh2");
257  histName_.push_back(hname);
258  hCaloPreSh[1] = new TH1F(hname, htitle, 100, -0.5, 99.5);
259 
260  sprintf(hname, "hCaloPreShE1");
261  histName_.push_back(hname);
262  sprintf(htitle, "PreSh hits, energy/GeV");
263  hCaloPreShE[0] = new TH1F(hname, htitle, 100, 0., 10.);
264  sprintf(hname, "hCaloPreShE2");
265  histName_.push_back(hname);
266  hCaloPreShE[1] = new TH1F(hname, htitle, 100, 0., 0.1);
267 
268  sprintf(hname, "hCaloPreShToF1");
269  histName_.push_back(hname);
270  sprintf(htitle, "PreSh hits, ToF/ns");
271  hCaloPreShToF[0] = new TH1F(hname, htitle, 100, 0., 1000.);
272  sprintf(hname, "hCaloPreShToF2");
273  histName_.push_back(hname);
274  hCaloPreShToF[1] = new TH1F(hname, htitle, 100, 0., 100.);
275 
276  for (Int_t i = 0; i < 2; ++i) {
277  hCaloPreSh[i]->GetXaxis()->SetTitle("Number of Hits");
278  hCaloPreSh[i]->GetYaxis()->SetTitle("Count");
279  histMap_[hCaloPreSh[i]->GetName()] = hCaloPreSh[i];
280  hCaloPreShE[i]->GetXaxis()->SetTitle("Energy of Hits (GeV)");
281  hCaloPreShE[i]->GetYaxis()->SetTitle("Count");
282  histMap_[hCaloPreShE[i]->GetName()] = hCaloPreShE[i];
283  hCaloPreShToF[i]->GetXaxis()->SetTitle("Time of Flight of Hits (ns)");
284  hCaloPreShToF[i]->GetYaxis()->SetTitle("Count");
285  histMap_[hCaloPreShToF[i]->GetName()] = hCaloPreShToF[i];
286  }
287 
288  sprintf(hname, "hCaloPreShPhi");
289  histName_.push_back(hname);
290  sprintf(htitle, "PreSh hits, phi/rad");
291  hCaloPreShPhi = new TH1F(hname, htitle, 100, -3.2, 3.2);
292  hCaloPreShPhi->GetXaxis()->SetTitle("Phi of Hits (rad)");
293  hCaloPreShPhi->GetYaxis()->SetTitle("Count");
294  histMap_[hCaloPreShPhi->GetName()] = hCaloPreShPhi;
295 
296  sprintf(hname, "hCaloPreShEta");
297  histName_.push_back(hname);
298  sprintf(htitle, "PreSh hits, eta");
299  hCaloPreShEta = new TH1F(hname, htitle, 100, -5.5, 5.5);
300  hCaloPreShEta->GetXaxis()->SetTitle("Eta of Hits");
301  hCaloPreShEta->GetYaxis()->SetTitle("Count");
302  histMap_[hCaloPreShEta->GetName()] = hCaloPreShEta;
303 
304  // Hcal
305  sprintf(hname, "hCaloHcal1");
306  histName_.push_back(hname);
307  sprintf(htitle, "Hcal hits");
308  hCaloHcal[0] = new TH1F(hname, htitle, 100, 0., 10000.);
309  sprintf(hname, "hCaloHcal2");
310  histName_.push_back(hname);
311  hCaloHcal[1] = new TH1F(hname, htitle, 100, -0.5, 99.5);
312 
313  sprintf(hname, "hCaloHcalE1");
314  histName_.push_back(hname);
315  sprintf(htitle, "Hcal hits, energy/GeV");
316  hCaloHcalE[0] = new TH1F(hname, htitle, 100, 0., 10.);
317  sprintf(hname, "hCaloHcalE2");
318  histName_.push_back(hname);
319  hCaloHcalE[1] = new TH1F(hname, htitle, 100, 0., 0.1);
320 
321  sprintf(hname, "hCaloHcalToF1");
322  histName_.push_back(hname);
323  sprintf(htitle, "Hcal hits, ToF/ns");
324  hCaloHcalToF[0] = new TH1F(hname, htitle, 100, 0., 1000.);
325  sprintf(hname, "hCaloHcalToF2");
326  histName_.push_back(hname);
327  hCaloHcalToF[1] = new TH1F(hname, htitle, 100, 0., 100.);
328 
329  for (Int_t i = 0; i < 2; ++i) {
330  hCaloHcal[i]->GetXaxis()->SetTitle("Number of Hits");
331  hCaloHcal[i]->GetYaxis()->SetTitle("Count");
332  histMap_[hCaloHcal[i]->GetName()] = hCaloHcal[i];
333  hCaloHcalE[i]->GetXaxis()->SetTitle("Energy of Hits (GeV)");
334  hCaloHcalE[i]->GetYaxis()->SetTitle("Count");
335  histMap_[hCaloHcalE[i]->GetName()] = hCaloHcalE[i];
336  hCaloHcalToF[i]->GetXaxis()->SetTitle("Time of Flight of Hits (ns)");
337  hCaloHcalToF[i]->GetYaxis()->SetTitle("Count");
338  histMap_[hCaloHcalToF[i]->GetName()] = hCaloHcalToF[i];
339  }
340 
341  sprintf(hname, "hCaloHcalPhi");
342  histName_.push_back(hname);
343  sprintf(htitle, "Hcal hits, phi/rad");
344  hCaloHcalPhi = new TH1F(hname, htitle, 100, -3.2, 3.2);
345  hCaloHcalPhi->GetXaxis()->SetTitle("Phi of Hits (rad)");
346  hCaloHcalPhi->GetYaxis()->SetTitle("Count");
347  histMap_[hCaloHcalPhi->GetName()] = hCaloHcalPhi;
348 
349  sprintf(hname, "hCaloHcalEta");
350  histName_.push_back(hname);
351  sprintf(htitle, "Hcal hits, eta");
352  hCaloHcalEta = new TH1F(hname, htitle, 100, -5.5, 5.5);
353  hCaloHcalEta->GetXaxis()->SetTitle("Eta of Hits");
354  hCaloHcalEta->GetYaxis()->SetTitle("Count");
355  histMap_[hCaloHcalEta->GetName()] = hCaloHcalEta;
356 
357  // tracker
358  sprintf(hname, "hTrackerPx1");
359  histName_.push_back(hname);
360  sprintf(htitle, "Pixel hits");
361  hTrackerPx[0] = new TH1F(hname, htitle, 100, 0., 10000.);
362  sprintf(hname, "hTrackerPx2");
363  histName_.push_back(hname);
364  hTrackerPx[1] = new TH1F(hname, htitle, 100, -0.5, 99.5);
365  for (Int_t i = 0; i < 2; ++i) {
366  hTrackerPx[i]->GetXaxis()->SetTitle("Number of Pixel Hits");
367  hTrackerPx[i]->GetYaxis()->SetTitle("Count");
368  histMap_[hTrackerPx[i]->GetName()] = hTrackerPx[i];
369  }
370 
371  sprintf(hname, "hTrackerPxPhi");
372  histName_.push_back(hname);
373  sprintf(htitle, "Pixel hits phi/rad");
374  hTrackerPxPhi = new TH1F(hname, htitle, 100, -3.2, 3.2);
375  hTrackerPxPhi->GetXaxis()->SetTitle("Phi of Hits (rad)");
376  hTrackerPxPhi->GetYaxis()->SetTitle("Count");
377  histMap_[hTrackerPxPhi->GetName()] = hTrackerPxPhi;
378 
379  sprintf(hname, "hTrackerPxEta");
380  histName_.push_back(hname);
381  sprintf(htitle, "Pixel hits eta");
382  hTrackerPxEta = new TH1F(hname, htitle, 100, -3.5, 3.5);
383  hTrackerPxEta->GetXaxis()->SetTitle("Eta of Hits");
384  hTrackerPxEta->GetYaxis()->SetTitle("Count");
385  histMap_[hTrackerPxEta->GetName()] = hTrackerPxEta;
386 
387  sprintf(hname, "hTrackerPxBToF");
388  histName_.push_back(hname);
389  sprintf(htitle, "Pixel barrel hits, ToF/ns");
390  hTrackerPxBToF = new TH1F(hname, htitle, 100, 0., 40.);
391  hTrackerPxBToF->GetXaxis()->SetTitle("Time of Flight of Hits (ns)");
392  hTrackerPxBToF->GetYaxis()->SetTitle("Count");
393  histMap_[hTrackerPxBToF->GetName()] = hTrackerPxBToF;
394 
395  sprintf(hname, "hTrackerPxBR");
396  histName_.push_back(hname);
397  sprintf(htitle, "Pixel barrel hits, R/cm");
398  hTrackerPxBR = new TH1F(hname, htitle, 100, 0., 50.);
399  hTrackerPxBR->GetXaxis()->SetTitle("R of Hits (cm)");
400  hTrackerPxBR->GetYaxis()->SetTitle("Count");
401  histMap_[hTrackerPxBR->GetName()] = hTrackerPxBR;
402 
403  sprintf(hname, "hTrackerPxFToF");
404  histName_.push_back(hname);
405  sprintf(htitle, "Pixel forward hits, ToF/ns");
406  hTrackerPxFToF = new TH1F(hname, htitle, 100, 0., 50.);
407  hTrackerPxFToF->GetXaxis()->SetTitle("Time of Flight of Hits (ns)");
408  hTrackerPxFToF->GetYaxis()->SetTitle("Count");
409  histMap_[hTrackerPxFToF->GetName()] = hTrackerPxFToF;
410 
411  sprintf(hname, "hTrackerPxFZ");
412  histName_.push_back(hname);
413  sprintf(htitle, "Pixel forward hits, Z/cm");
414  hTrackerPxFZ = new TH1F(hname, htitle, 200, -100., 100.);
415  hTrackerPxFZ->GetXaxis()->SetTitle("Z of Hits (cm)");
416  hTrackerPxFZ->GetYaxis()->SetTitle("Count");
417  histMap_[hTrackerPxFZ->GetName()] = hTrackerPxFZ;
418 
419  sprintf(hname, "hTrackerSi1");
420  histName_.push_back(hname);
421  sprintf(htitle, "Silicon hits");
422  hTrackerSi[0] = new TH1F(hname, htitle, 100, 0., 10000.);
423  sprintf(hname, "hTrackerSi2");
424  histName_.push_back(hname);
425  hTrackerSi[1] = new TH1F(hname, htitle, 100, -0.5, 99.5);
426  for (Int_t i = 0; i < 2; ++i) {
427  hTrackerSi[i]->GetXaxis()->SetTitle("Number of Silicon Hits");
428  hTrackerSi[i]->GetYaxis()->SetTitle("Count");
429  histMap_[hTrackerSi[i]->GetName()] = hTrackerSi[i];
430  }
431 
432  sprintf(hname, "hTrackerSiPhi");
433  histName_.push_back(hname);
434  sprintf(htitle, "Silicon hits phi/rad");
435  hTrackerSiPhi = new TH1F(hname, htitle, 100, -3.2, 3.2);
436  hTrackerSiPhi->GetXaxis()->SetTitle("Phi of Hits (rad)");
437  hTrackerSiPhi->GetYaxis()->SetTitle("Count");
438  histMap_[hTrackerSiPhi->GetName()] = hTrackerSiPhi;
439 
440  sprintf(hname, "hTrackerSiEta");
441  histName_.push_back(hname);
442  sprintf(htitle, "Silicon hits eta");
443  hTrackerSiEta = new TH1F(hname, htitle, 100, -3.5, 3.5);
444  hTrackerSiEta->GetXaxis()->SetTitle("Eta of Hits");
445  hTrackerSiEta->GetYaxis()->SetTitle("Count");
446  histMap_[hTrackerSiEta->GetName()] = hTrackerSiEta;
447 
448  sprintf(hname, "hTrackerSiBToF");
449  histName_.push_back(hname);
450  sprintf(htitle, "Silicon barrel hits, ToF/ns");
451  hTrackerSiBToF = new TH1F(hname, htitle, 100, 0., 50.);
452  hTrackerSiBToF->GetXaxis()->SetTitle("Time of Flight of Hits (ns)");
453  hTrackerSiBToF->GetYaxis()->SetTitle("Count");
454  histMap_[hTrackerSiBToF->GetName()] = hTrackerSiBToF;
455 
456  sprintf(hname, "hTrackerSiBR");
457  histName_.push_back(hname);
458  sprintf(htitle, "Silicon barrel hits, R/cm");
459  hTrackerSiBR = new TH1F(hname, htitle, 100, 0., 200.);
460  hTrackerSiBR->GetXaxis()->SetTitle("R of Hits (cm)");
461  hTrackerSiBR->GetYaxis()->SetTitle("Count");
462  histMap_[hTrackerSiBR->GetName()] = hTrackerSiBR;
463 
464  sprintf(hname, "hTrackerSiFToF");
465  histName_.push_back(hname);
466  sprintf(htitle, "Silicon forward hits, ToF/ns");
467  hTrackerSiFToF = new TH1F(hname, htitle, 100, 0., 75.);
468  hTrackerSiFToF->GetXaxis()->SetTitle("Time of Flight of Hits (ns)");
469  hTrackerSiFToF->GetYaxis()->SetTitle("Count");
470  histMap_[hTrackerSiFToF->GetName()] = hTrackerSiFToF;
471 
472  sprintf(hname, "hTrackerSiFZ");
473  histName_.push_back(hname);
474  sprintf(htitle, "Silicon forward hits, Z/cm");
475  hTrackerSiFZ = new TH1F(hname, htitle, 200, -300., 300.);
476  hTrackerSiFZ->GetXaxis()->SetTitle("Z of Hits (cm)");
477  hTrackerSiFZ->GetYaxis()->SetTitle("Count");
478  histMap_[hTrackerSiFZ->GetName()] = hTrackerSiFZ;
479 
480  // muon
481  sprintf(hname, "hMuon1");
482  histName_.push_back(hname);
483  sprintf(htitle, "Muon hits");
484  hMuon[0] = new TH1F(hname, htitle, 100, 0., 10000.);
485  sprintf(hname, "hMuon2");
486  histName_.push_back(hname);
487  hMuon[1] = new TH1F(hname, htitle, 100, -0.5, 99.5);
488  for (Int_t i = 0; i < 2; ++i) {
489  hMuon[i]->GetXaxis()->SetTitle("Number of Muon Hits");
490  hMuon[i]->GetYaxis()->SetTitle("Count");
491  histMap_[hMuon[i]->GetName()] = hMuon[i];
492  }
493 
494  sprintf(hname, "hMuonPhi");
495  histName_.push_back(hname);
496  sprintf(htitle, "Muon hits phi/rad");
497  hMuonPhi = new TH1F(hname, htitle, 100, -3.2, 3.2);
498  hMuonPhi->GetXaxis()->SetTitle("Phi of Hits (rad)");
499  hMuonPhi->GetYaxis()->SetTitle("Count");
500  histMap_[hMuonPhi->GetName()] = hMuonPhi;
501 
502  sprintf(hname, "hMuonEta");
503  histName_.push_back(hname);
504  sprintf(htitle, "Muon hits eta");
505  hMuonEta = new TH1F(hname, htitle, 100, -3.5, 3.5);
506  hMuonEta->GetXaxis()->SetTitle("Eta of Hits");
507  hMuonEta->GetYaxis()->SetTitle("Count");
508  histMap_[hMuonEta->GetName()] = hMuonEta;
509 
510  sprintf(hname, "hMuonCscToF1");
511  histName_.push_back(hname);
512  sprintf(htitle, "Muon CSC hits, ToF/ns");
513  hMuonCscToF[0] = new TH1F(hname, htitle, 100, 0., 250.);
514  sprintf(hname, "hMuonCscToF2");
515  histName_.push_back(hname);
516  hMuonCscToF[1] = new TH1F(hname, htitle, 100, 0., 50.);
517  for (Int_t i = 0; i < 2; ++i) {
518  hMuonCscToF[i]->GetXaxis()->SetTitle("Time of Flight of Hits (ns)");
519  hMuonCscToF[i]->GetYaxis()->SetTitle("Count");
520  histMap_[hMuonCscToF[i]->GetName()] = hMuonCscToF[i];
521  }
522 
523  sprintf(hname, "hMuonCscZ");
524  histName_.push_back(hname);
525  sprintf(htitle, "Muon CSC hits, Z/cm");
526  hMuonCscZ = new TH1F(hname, htitle, 200, -1500., 1500.);
527  hMuonCscZ->GetXaxis()->SetTitle("Z of Hits (cm)");
528  hMuonCscZ->GetYaxis()->SetTitle("Count");
529  histMap_[hMuonCscZ->GetName()] = hMuonCscZ;
530 
531  sprintf(hname, "hMuonDtToF1");
532  histName_.push_back(hname);
533  sprintf(htitle, "Muon DT hits, ToF/ns");
534  hMuonDtToF[0] = new TH1F(hname, htitle, 100, 0., 250.);
535  sprintf(hname, "hMuonDtToF2");
536  histName_.push_back(hname);
537  hMuonDtToF[1] = new TH1F(hname, htitle, 100, 0., 50.);
538  for (Int_t i = 0; i < 2; ++i) {
539  hMuonDtToF[i]->GetXaxis()->SetTitle("Time of Flight of Hits (ns)");
540  hMuonDtToF[i]->GetYaxis()->SetTitle("Count");
541  histMap_[hMuonDtToF[i]->GetName()] = hMuonDtToF[i];
542  }
543 
544  sprintf(hname, "hMuonDtR");
545  histName_.push_back(hname);
546  sprintf(htitle, "Muon DT hits, R/cm");
547  hMuonDtR = new TH1F(hname, htitle, 100, 0., 1500.);
548  hMuonDtR->GetXaxis()->SetTitle("R of Hits (cm)");
549  hMuonDtR->GetYaxis()->SetTitle("Count");
550  histMap_[hMuonDtR->GetName()] = hMuonDtR;
551 
552  sprintf(hname, "hMuonRpcFToF1");
553  histName_.push_back(hname);
554  sprintf(htitle, "Muon RPC forward hits, ToF/ns");
555  hMuonRpcFToF[0] = new TH1F(hname, htitle, 100, 0., 250.);
556  sprintf(hname, "hMuonRpcFToF2");
557  histName_.push_back(hname);
558  hMuonRpcFToF[1] = new TH1F(hname, htitle, 100, 0., 50.);
559  for (Int_t i = 0; i < 2; ++i) {
560  hMuonRpcFToF[i]->GetXaxis()->SetTitle("Time of Flight of Hits (ns)");
561  hMuonRpcFToF[i]->GetYaxis()->SetTitle("Count");
562  histMap_[hMuonRpcFToF[i]->GetName()] = hMuonRpcFToF[i];
563  }
564 
565  sprintf(hname, "hMuonRpcFZ");
566  histName_.push_back(hname);
567  sprintf(htitle, "Muon RPC forward hits, Z/cm");
568  hMuonRpcFZ = new TH1F(hname, htitle, 201, -1500., 1500.);
569  hMuonRpcFZ->GetXaxis()->SetTitle("Z of Hits (cm)");
570  hMuonRpcFZ->GetYaxis()->SetTitle("Count");
571  histMap_[hMuonRpcFZ->GetName()] = hMuonRpcFZ;
572 
573  sprintf(hname, "hMuonRpcBToF1");
574  histName_.push_back(hname);
575  sprintf(htitle, "Muon RPC barrel hits, ToF/ns");
576  hMuonRpcBToF[0] = new TH1F(hname, htitle, 100, 0., 250.);
577  sprintf(hname, "hMuonRpcBToF2");
578  histName_.push_back(hname);
579  hMuonRpcBToF[1] = new TH1F(hname, htitle, 100, 0., 50.);
580  for (Int_t i = 0; i < 2; ++i) {
581  hMuonRpcBToF[i]->GetXaxis()->SetTitle("Time of Flight of Hits (ns)");
582  hMuonRpcBToF[i]->GetYaxis()->SetTitle("Count");
583  histMap_[hMuonRpcBToF[i]->GetName()] = hMuonRpcBToF[i];
584  }
585 
586  sprintf(hname, "hMuonRpcBR");
587  histName_.push_back(hname);
588  sprintf(htitle, "Muon RPC barrel hits, R/cm");
589  hMuonRpcBR = new TH1F(hname, htitle, 100, 0., 1500.);
590  hMuonRpcBR->GetXaxis()->SetTitle("R of Hits (cm)");
591  hMuonRpcBR->GetYaxis()->SetTitle("Count");
592  histMap_[hMuonRpcBR->GetName()] = hMuonRpcBR;
593 
594  // create persistent objects
595  for (std::size_t i = 0; i < histName_.size(); ++i) {
596  produces<TH1F, edm::Transition::EndRun>(histName_[i]).setBranchAlias(histName_[i]);
597  }
598 }
599 
601 
603 
605  std::string MsgLoggerCat = "GlobalHitsProdHist_endJob";
606  if (verbosity >= 0)
607  edm::LogInfo(MsgLoggerCat) << "Terminating having processed " << count << " events.";
608  return;
609 }
610 
612  std::string MsgLoggerCat = "GlobalHitsProdHist_produce";
613 
614  // keep track of number of events processed
615  ++count;
616 
617  // get event id information
618  edm::RunNumber_t nrun = iEvent.id().run();
619  edm::EventNumber_t nevt = iEvent.id().event();
620 
621  if (verbosity > 0) {
622  edm::LogInfo(MsgLoggerCat) << "Processing run " << nrun << ", event " << nevt << " (" << count << " events total)";
623  } else if (verbosity == 0) {
624  if (nevt % frequency == 0 || nevt == 1) {
625  edm::LogInfo(MsgLoggerCat) << "Processing run " << nrun << ", event " << nevt << " (" << count
626  << " events total)";
627  }
628  }
629 
630  // look at information available in the event
631  if (getAllProvenances) {
632  std::vector<const edm::StableProvenance *> AllProv;
633  iEvent.getAllStableProvenance(AllProv);
634 
635  if (verbosity >= 0)
636  edm::LogInfo(MsgLoggerCat) << "Number of Provenances = " << AllProv.size();
637 
638  if (printProvenanceInfo && (verbosity >= 0)) {
639  TString eventout("\nProvenance info:\n");
640 
641  for (unsigned int i = 0; i < AllProv.size(); ++i) {
642  eventout += "\n ******************************";
643  eventout += "\n Module : ";
644  eventout += AllProv[i]->moduleLabel();
645  eventout += "\n ProductID : ";
646  eventout += AllProv[i]->productID().id();
647  eventout += "\n ClassName : ";
648  eventout += AllProv[i]->className();
649  eventout += "\n InstanceName : ";
650  eventout += AllProv[i]->productInstanceName();
651  eventout += "\n BranchName : ";
652  eventout += AllProv[i]->branchName();
653  }
654  eventout += "\n ******************************\n";
655  edm::LogInfo(MsgLoggerCat) << eventout << "\n";
656  printProvenanceInfo = false;
657  }
658  getAllProvenances = false;
659  }
660 
661  // call fill functions
662  // gather G4MC information from event
663  fillG4MC(iEvent);
664  // gather Tracker information from event
665  fillTrk(iEvent, iSetup);
666  // gather muon information from event
667  fillMuon(iEvent, iSetup);
668  // gather Ecal information from event
669  fillECal(iEvent, iSetup);
670  // gather Hcal information from event
671  fillHCal(iEvent, iSetup);
672 
673  if (verbosity > 0)
674  edm::LogInfo(MsgLoggerCat) << "Done gathering data from event.";
675 
676  return;
677 }
678 
680  std::string MsgLoggerCat = "GlobalHitsProdHist_endRun";
681 
682  TString eventout;
683  TString eventoutw;
684  bool warning = false;
685 
686  if (verbosity > 0)
687  edm::LogInfo(MsgLoggerCat) << "\nStoring histograms.";
688 
689  // store persistent objects
690  std::map<std::string, TH1F *>::iterator iter;
691  for (std::size_t i = 0; i < histName_.size(); ++i) {
692  iter = histMap_.find(histName_[i]);
693  if (iter != histMap_.end()) {
694  std::unique_ptr<TH1F> hist1D(iter->second);
695  eventout += "\n Storing histogram " + histName_[i];
696  iRun.put(std::move(hist1D), histName_[i]);
697  } else {
698  warning = true;
699  eventoutw += "\n Unable to find histogram with name " + histName_[i];
700  }
701  }
702 
703  if (verbosity > 0) {
704  edm::LogInfo(MsgLoggerCat) << eventout << "\n";
705  if (warning)
706  edm::LogWarning(MsgLoggerCat) << eventoutw << "\n";
707  }
708  return;
709 }
710 
711 //==================fill and store functions================================
713  std::string MsgLoggerCat = "GlobalHitsProdHist_fillG4MC";
714 
715  TString eventout;
716  if (verbosity > 0)
717  eventout = "\nGathering info:";
718 
720  // get MC information
723  std::vector<edm::Handle<edm::HepMCProduct>> AllHepMCEvt;
724  iEvent.getManyByType(AllHepMCEvt);
725 
726  // loop through products and extract VtxSmearing if available. Any of them
727  // should have the information needed
728  for (unsigned int i = 0; i < AllHepMCEvt.size(); ++i) {
729  HepMCEvt = AllHepMCEvt[i];
730  if ((HepMCEvt.provenance()->branchDescription()).moduleLabel() == "generatorSmeared")
731  break;
732  }
733 
734  if (!HepMCEvt.isValid()) {
735  edm::LogWarning(MsgLoggerCat) << "Unable to find HepMCProduct in event!";
736  return;
737  } else {
738  eventout += "\n Using HepMCProduct: ";
739  eventout += (HepMCEvt.provenance()->branchDescription()).moduleLabel();
740  }
741  const HepMC::GenEvent *MCEvt = HepMCEvt->GetEvent();
742  nRawGenPart = MCEvt->particles_size();
743 
744  if (verbosity > 1) {
745  eventout += "\n Number of Raw Particles collected:......... ";
746  eventout += nRawGenPart;
747  }
748 
749  if (hMCRGP[0])
750  hMCRGP[0]->Fill((float)nRawGenPart);
751  if (hMCRGP[1])
752  hMCRGP[1]->Fill((float)nRawGenPart);
753 
755  // get G4Vertex information
757  // convert unit stored in SimVertex to mm
758  float unit = 0.;
759  if (vtxunit == 0)
760  unit = 1.; // already in mm
761  if (vtxunit == 1)
762  unit = 10.; // stored in cm, convert to mm
763 
765  iEvent.getByToken(G4VtxSrc_Token_, G4VtxContainer);
766  if (!G4VtxContainer.isValid()) {
767  edm::LogWarning(MsgLoggerCat) << "Unable to find SimVertex in event!";
768  return;
769  }
770  int i = 0;
771  edm::SimVertexContainer::const_iterator itVtx;
772  for (itVtx = G4VtxContainer->begin(); itVtx != G4VtxContainer->end(); ++itVtx) {
773  ++i;
774 
775  const math::XYZTLorentzVector G4Vtx1(
776  itVtx->position().x(), itVtx->position().y(), itVtx->position().z(), itVtx->position().e());
777 
778  double G4Vtx[4];
779  G4Vtx1.GetCoordinates(G4Vtx);
780 
781  if (hGeantVtxX[0])
782  hGeantVtxX[0]->Fill((G4Vtx[0] * unit) / micrometer);
783  if (hGeantVtxX[1])
784  hGeantVtxX[1]->Fill((G4Vtx[0] * unit) / micrometer);
785 
786  if (hGeantVtxY[0])
787  hGeantVtxY[0]->Fill((G4Vtx[1] * unit) / micrometer);
788  if (hGeantVtxY[1])
789  hGeantVtxY[1]->Fill((G4Vtx[1] * unit) / micrometer);
790 
791  if (hGeantVtxZ[0])
792  hGeantVtxZ[0]->Fill((G4Vtx[2] * unit) / millimeter);
793  if (hGeantVtxZ[1])
794  hGeantVtxZ[1]->Fill((G4Vtx[2] * unit) / millimeter);
795  }
796 
797  if (verbosity > 1) {
798  eventout += "\n Number of G4Vertices collected:............ ";
799  eventout += i;
800  }
801 
802  if (hMCG4Vtx[0])
803  hMCG4Vtx[0]->Fill((float)i);
804  if (hMCG4Vtx[1])
805  hMCG4Vtx[1]->Fill((float)i);
806 
808  // get G4Track information
811  iEvent.getByToken(G4TrkSrc_Token_, G4TrkContainer);
812  if (!G4TrkContainer.isValid()) {
813  edm::LogWarning(MsgLoggerCat) << "Unable to find SimTrack in event!";
814  return;
815  }
816  i = 0;
817  edm::SimTrackContainer::const_iterator itTrk;
818  for (itTrk = G4TrkContainer->begin(); itTrk != G4TrkContainer->end(); ++itTrk) {
819  ++i;
820 
821  const math::XYZTLorentzVector G4Trk1(
822  itTrk->momentum().x(), itTrk->momentum().y(), itTrk->momentum().z(), itTrk->momentum().e());
823  double G4Trk[4];
824  G4Trk1.GetCoordinates(G4Trk);
825 
826  if (hGeantTrkPt)
827  hGeantTrkPt->Fill(sqrt(G4Trk[0] * G4Trk[0] + G4Trk[1] * G4Trk[1]));
828  if (hGeantTrkE)
829  hGeantTrkE->Fill(G4Trk[3]);
830  }
831 
832  if (verbosity > 1) {
833  eventout += "\n Number of G4Tracks collected:.............. ";
834  eventout += i;
835  }
836 
837  if (hMCG4Trk[0])
838  hMCG4Trk[0]->Fill((float)i);
839  if (hMCG4Trk[1])
840  hMCG4Trk[1]->Fill((float)i);
841 
842  if (verbosity > 0)
843  edm::LogInfo(MsgLoggerCat) << eventout << "\n";
844 
845  return;
846 }
847 
849  nPxlHits = 0;
850  std::string MsgLoggerCat = "GlobalHitsProdHist_fillTrk";
851 
852  TString eventout;
853  if (verbosity > 0)
854  eventout = "\nGathering info:";
855 
856  // access the tracker geometry
857  const auto &theTrackerGeometry = iSetup.getHandle(tGeomToken_);
858  if (!theTrackerGeometry.isValid()) {
859  edm::LogWarning(MsgLoggerCat) << "Unable to find TrackerDigiGeometryRecord in event!";
860  return;
861  }
862  const TrackerGeometry &theTracker(*theTrackerGeometry);
863 
864  // iterator to access containers
865  edm::PSimHitContainer::const_iterator itHit;
866 
868  // get Pixel Barrel information
870  edm::PSimHitContainer thePxlBrlHits;
871  // extract low container
872  edm::Handle<edm::PSimHitContainer> PxlBrlLowContainer;
873  iEvent.getByToken(PxlBrlLowSrc_Token_, PxlBrlLowContainer);
874  if (!PxlBrlLowContainer.isValid()) {
875  edm::LogWarning(MsgLoggerCat) << "Unable to find TrackerHitsPixelBarrelLowTof in event!";
876  return;
877  }
878  // extract high container
879  edm::Handle<edm::PSimHitContainer> PxlBrlHighContainer;
880  iEvent.getByToken(PxlBrlHighSrc_Token_, PxlBrlHighContainer);
881  if (!PxlBrlHighContainer.isValid()) {
882  edm::LogWarning(MsgLoggerCat) << "Unable to find TrackerHitsPixelBarrelHighTof in event!";
883  return;
884  }
885  // place both containers into new container
886  thePxlBrlHits.insert(thePxlBrlHits.end(), PxlBrlLowContainer->begin(), PxlBrlLowContainer->end());
887  thePxlBrlHits.insert(thePxlBrlHits.end(), PxlBrlHighContainer->begin(), PxlBrlHighContainer->end());
888 
889  // cycle through new container
890  int i = 0, j = 0;
891  for (itHit = thePxlBrlHits.begin(); itHit != thePxlBrlHits.end(); ++itHit) {
892  ++i;
893 
894  // create a DetId from the detUnitId
895  DetId theDetUnitId(itHit->detUnitId());
896  int detector = theDetUnitId.det();
897  int subdetector = theDetUnitId.subdetId();
898 
899  // check that expected detector is returned
900  if ((detector == dTrk) && (subdetector == sdPxlBrl)) {
901  // get the GeomDetUnit from the geometry using theDetUnitID
902  const GeomDetUnit *theDet = theTracker.idToDetUnit(theDetUnitId);
903 
904  if (!theDet) {
905  edm::LogWarning(MsgLoggerCat) << "Unable to get GeomDetUnit from PxlBrlHits for Hit " << i;
906  continue;
907  }
908 
909  ++j;
910 
911  // get the Surface of the hit (knows how to go from local <-> global)
912  const BoundPlane &bSurface = theDet->surface();
913 
914  if (hTrackerPxBToF)
915  hTrackerPxBToF->Fill(itHit->tof());
916  if (hTrackerPxBR)
917  hTrackerPxBR->Fill(bSurface.toGlobal(itHit->localPosition()).perp());
918  if (hTrackerPxPhi)
919  hTrackerPxPhi->Fill(bSurface.toGlobal(itHit->localPosition()).phi());
920  if (hTrackerPxEta)
921  hTrackerPxEta->Fill(bSurface.toGlobal(itHit->localPosition()).eta());
922 
923  } else {
924  edm::LogWarning(MsgLoggerCat) << "PxlBrl PSimHit " << i << " is expected to be (det,subdet) = (" << dTrk << ","
925  << sdPxlBrl << "); value returned is: (" << detector << "," << subdetector << ")";
926  continue;
927  } // end detector type check
928  } // end loop through PxlBrl Hits
929 
930  if (verbosity > 1) {
931  eventout += "\n Number of Pixel Barrel Hits collected:..... ";
932  eventout += j;
933  }
934 
935  nPxlHits += j;
936 
938  // get Pixel Forward information
940  edm::PSimHitContainer thePxlFwdHits;
941  // extract low container
942  edm::Handle<edm::PSimHitContainer> PxlFwdLowContainer;
943  iEvent.getByToken(PxlFwdLowSrc_Token_, PxlFwdLowContainer);
944  if (!PxlFwdLowContainer.isValid()) {
945  edm::LogWarning(MsgLoggerCat) << "Unable to find TrackerHitsPixelEndcapLowTof in event!";
946  return;
947  }
948  // extract high container
949  edm::Handle<edm::PSimHitContainer> PxlFwdHighContainer;
950  iEvent.getByToken(PxlFwdHighSrc_Token_, PxlFwdHighContainer);
951  if (!PxlFwdHighContainer.isValid()) {
952  edm::LogWarning("GlobalHitsProdHist_fillTrk") << "Unable to find TrackerHitsPixelEndcapHighTof in event!";
953  return;
954  }
955  // place both containers into new container
956  thePxlFwdHits.insert(thePxlFwdHits.end(), PxlFwdLowContainer->begin(), PxlFwdLowContainer->end());
957  thePxlFwdHits.insert(thePxlFwdHits.end(), PxlFwdHighContainer->begin(), PxlFwdHighContainer->end());
958 
959  // cycle through new container
960  i = 0;
961  j = 0;
962  for (itHit = thePxlFwdHits.begin(); itHit != thePxlFwdHits.end(); ++itHit) {
963  ++i;
964 
965  // create a DetId from the detUnitId
966  DetId theDetUnitId(itHit->detUnitId());
967  int detector = theDetUnitId.det();
968  int subdetector = theDetUnitId.subdetId();
969 
970  // check that expected detector is returned
971  if ((detector == dTrk) && (subdetector == sdPxlFwd)) {
972  // get the GeomDetUnit from the geometry using theDetUnitID
973  const GeomDetUnit *theDet = theTracker.idToDetUnit(theDetUnitId);
974 
975  if (!theDet) {
976  edm::LogWarning(MsgLoggerCat) << "Unable to get GeomDetUnit from PxlFwdHits for Hit " << i;
977  ;
978  continue;
979  }
980 
981  ++j;
982 
983  // get the Surface of the hit (knows how to go from local <-> global)
984  const BoundPlane &bSurface = theDet->surface();
985 
986  if (hTrackerPxFToF)
987  hTrackerPxFToF->Fill(itHit->tof());
988  if (hTrackerPxFZ)
989  hTrackerPxFZ->Fill(bSurface.toGlobal(itHit->localPosition()).z());
990  if (hTrackerPxPhi)
991  hTrackerPxPhi->Fill(bSurface.toGlobal(itHit->localPosition()).phi());
992  if (hTrackerPxEta)
993  hTrackerPxEta->Fill(bSurface.toGlobal(itHit->localPosition()).eta());
994 
995  } else {
996  edm::LogWarning(MsgLoggerCat) << "PxlFwd PSimHit " << i << " is expected to be (det,subdet) = (" << dTrk << ","
997  << sdPxlFwd << "); value returned is: (" << detector << "," << subdetector << ")";
998  continue;
999  } // end detector type check
1000  } // end loop through PxlFwd Hits
1001 
1002  if (verbosity > 1) {
1003  eventout += "\n Number of Pixel Forward Hits collected:.... ";
1004  eventout += j;
1005  }
1006 
1007  nPxlHits += j;
1008 
1009  if (hTrackerPx[0])
1010  hTrackerPx[0]->Fill((float)nPxlHits);
1011  if (hTrackerPx[1])
1012  hTrackerPx[1]->Fill((float)nPxlHits);
1013 
1015  // get Silicon Barrel information
1017  nSiHits = 0;
1018  edm::PSimHitContainer theSiBrlHits;
1019  // extract TIB low container
1020  edm::Handle<edm::PSimHitContainer> SiTIBLowContainer;
1021  iEvent.getByToken(SiTIBLowSrc_Token_, SiTIBLowContainer);
1022  if (!SiTIBLowContainer.isValid()) {
1023  edm::LogWarning(MsgLoggerCat) << "Unable to find TrackerHitsTIBLowTof in event!";
1024  return;
1025  }
1026  // extract TIB high container
1027  edm::Handle<edm::PSimHitContainer> SiTIBHighContainer;
1028  iEvent.getByToken(SiTIBHighSrc_Token_, SiTIBHighContainer);
1029  if (!SiTIBHighContainer.isValid()) {
1030  edm::LogWarning(MsgLoggerCat) << "Unable to find TrackerHitsTIBHighTof in event!";
1031  return;
1032  }
1033  // extract TOB low container
1034  edm::Handle<edm::PSimHitContainer> SiTOBLowContainer;
1035  iEvent.getByToken(SiTOBLowSrc_Token_, SiTOBLowContainer);
1036  if (!SiTOBLowContainer.isValid()) {
1037  edm::LogWarning(MsgLoggerCat) << "Unable to find TrackerHitsTOBLowTof in event!";
1038  return;
1039  }
1040  // extract TOB high container
1041  edm::Handle<edm::PSimHitContainer> SiTOBHighContainer;
1042  iEvent.getByToken(SiTOBHighSrc_Token_, SiTOBHighContainer);
1043  if (!SiTOBHighContainer.isValid()) {
1044  edm::LogWarning(MsgLoggerCat) << "Unable to find TrackerHitsTOBHighTof in event!";
1045  return;
1046  }
1047  // place all containers into new container
1048  theSiBrlHits.insert(theSiBrlHits.end(), SiTIBLowContainer->begin(), SiTIBLowContainer->end());
1049  theSiBrlHits.insert(theSiBrlHits.end(), SiTIBHighContainer->begin(), SiTIBHighContainer->end());
1050  theSiBrlHits.insert(theSiBrlHits.end(), SiTOBLowContainer->begin(), SiTOBLowContainer->end());
1051  theSiBrlHits.insert(theSiBrlHits.end(), SiTOBHighContainer->begin(), SiTOBHighContainer->end());
1052 
1053  // cycle through new container
1054  i = 0;
1055  j = 0;
1056  for (itHit = theSiBrlHits.begin(); itHit != theSiBrlHits.end(); ++itHit) {
1057  ++i;
1058 
1059  // create a DetId from the detUnitId
1060  DetId theDetUnitId(itHit->detUnitId());
1061  int detector = theDetUnitId.det();
1062  int subdetector = theDetUnitId.subdetId();
1063 
1064  // check that expected detector is returned
1065  if ((detector == dTrk) && ((subdetector == sdSiTIB) || (subdetector == sdSiTOB))) {
1066  // get the GeomDetUnit from the geometry using theDetUnitID
1067  const GeomDetUnit *theDet = theTracker.idToDetUnit(theDetUnitId);
1068 
1069  if (!theDet) {
1070  edm::LogWarning(MsgLoggerCat) << "Unable to get GeomDetUnit from SiBrlHits for Hit " << i;
1071  continue;
1072  }
1073 
1074  ++j;
1075 
1076  // get the Surface of the hit (knows how to go from local <-> global)
1077  const BoundPlane &bSurface = theDet->surface();
1078 
1079  if (hTrackerSiBToF)
1080  hTrackerSiBToF->Fill(itHit->tof());
1081  if (hTrackerSiBR)
1082  hTrackerSiBR->Fill(bSurface.toGlobal(itHit->localPosition()).perp());
1083  if (hTrackerSiPhi)
1084  hTrackerSiPhi->Fill(bSurface.toGlobal(itHit->localPosition()).phi());
1085  if (hTrackerSiEta)
1086  hTrackerSiEta->Fill(bSurface.toGlobal(itHit->localPosition()).eta());
1087 
1088  } else {
1089  edm::LogWarning(MsgLoggerCat) << "SiBrl PSimHit " << i << " is expected to be (det,subdet) = (" << dTrk << ","
1090  << sdSiTIB << " || " << sdSiTOB << "); value returned is: (" << detector << ","
1091  << subdetector << ")";
1092  continue;
1093  } // end detector type check
1094  } // end loop through SiBrl Hits
1095 
1096  if (verbosity > 1) {
1097  eventout += "\n Number of Silicon Barrel Hits collected:... ";
1098  eventout += j;
1099  }
1100 
1101  nSiHits += j;
1102 
1104  // get Silicon Forward information
1106  edm::PSimHitContainer theSiFwdHits;
1107  // extract TID low container
1108  edm::Handle<edm::PSimHitContainer> SiTIDLowContainer;
1109  iEvent.getByToken(SiTIDLowSrc_Token_, SiTIDLowContainer);
1110  if (!SiTIDLowContainer.isValid()) {
1111  edm::LogWarning(MsgLoggerCat) << "Unable to find TrackerHitsTIDLowTof in event!";
1112  return;
1113  }
1114  // extract TID high container
1115  edm::Handle<edm::PSimHitContainer> SiTIDHighContainer;
1116  iEvent.getByToken(SiTIDHighSrc_Token_, SiTIDHighContainer);
1117  if (!SiTIDHighContainer.isValid()) {
1118  edm::LogWarning("GlobalHitsProdHist_fillTrk") << "Unable to find TrackerHitsTIDHighTof in event!";
1119  return;
1120  }
1121  // extract TEC low container
1122  edm::Handle<edm::PSimHitContainer> SiTECLowContainer;
1123  iEvent.getByToken(SiTECLowSrc_Token_, SiTECLowContainer);
1124  if (!SiTECLowContainer.isValid()) {
1125  edm::LogWarning(MsgLoggerCat) << "Unable to find TrackerHitsTECLowTof in event!";
1126  return;
1127  }
1128  // extract TEC high container
1129  edm::Handle<edm::PSimHitContainer> SiTECHighContainer;
1130  iEvent.getByToken(SiTECHighSrc_Token_, SiTECHighContainer);
1131  if (!SiTECHighContainer.isValid()) {
1132  edm::LogWarning(MsgLoggerCat) << "Unable to find TrackerHitsTECHighTof in event!";
1133  return;
1134  }
1135  // place all containers into new container
1136  theSiFwdHits.insert(theSiFwdHits.end(), SiTIDLowContainer->begin(), SiTIDLowContainer->end());
1137  theSiFwdHits.insert(theSiFwdHits.end(), SiTIDHighContainer->begin(), SiTIDHighContainer->end());
1138  theSiFwdHits.insert(theSiFwdHits.end(), SiTECLowContainer->begin(), SiTECLowContainer->end());
1139  theSiFwdHits.insert(theSiFwdHits.end(), SiTECHighContainer->begin(), SiTECHighContainer->end());
1140 
1141  // cycle through container
1142  i = 0;
1143  j = 0;
1144  for (itHit = theSiFwdHits.begin(); itHit != theSiFwdHits.end(); ++itHit) {
1145  ++i;
1146 
1147  // create a DetId from the detUnitId
1148  DetId theDetUnitId(itHit->detUnitId());
1149  int detector = theDetUnitId.det();
1150  int subdetector = theDetUnitId.subdetId();
1151 
1152  // check that expected detector is returned
1153  if ((detector == dTrk) && ((subdetector == sdSiTID) || (subdetector == sdSiTEC))) {
1154  // get the GeomDetUnit from the geometry using theDetUnitID
1155  const GeomDetUnit *theDet = theTracker.idToDetUnit(theDetUnitId);
1156 
1157  if (!theDet) {
1158  edm::LogWarning(MsgLoggerCat) << "Unable to get GeomDetUnit from SiFwdHits Hit " << i;
1159  return;
1160  }
1161 
1162  ++j;
1163 
1164  // get the Surface of the hit (knows how to go from local <-> global)
1165  const BoundPlane &bSurface = theDet->surface();
1166 
1167  if (hTrackerSiFToF)
1168  hTrackerSiFToF->Fill(itHit->tof());
1169  if (hTrackerSiFZ)
1170  hTrackerSiFZ->Fill(bSurface.toGlobal(itHit->localPosition()).z());
1171  if (hTrackerSiPhi)
1172  hTrackerSiPhi->Fill(bSurface.toGlobal(itHit->localPosition()).phi());
1173  if (hTrackerSiEta)
1174  hTrackerSiEta->Fill(bSurface.toGlobal(itHit->localPosition()).eta());
1175 
1176  } else {
1177  edm::LogWarning(MsgLoggerCat) << "SiFwd PSimHit " << i << " is expected to be (det,subdet) = (" << dTrk << ","
1178  << sdSiTOB << " || " << sdSiTEC << "); value returned is: (" << detector << ","
1179  << subdetector << ")";
1180  continue;
1181  } // end check detector type
1182  } // end loop through SiFwd Hits
1183 
1184  if (verbosity > 1) {
1185  eventout += "\n Number of Silicon Forward Hits collected:.. ";
1186  eventout += j;
1187  }
1188 
1189  nSiHits += j;
1190 
1191  if (hTrackerSi[0])
1192  hTrackerSi[0]->Fill((float)nSiHits);
1193  if (hTrackerSi[1])
1194  hTrackerSi[1]->Fill((float)nSiHits);
1195 
1196  if (verbosity > 0)
1197  edm::LogInfo(MsgLoggerCat) << eventout << "\n";
1198 
1199  return;
1200 }
1201 
1203  nMuonHits = 0;
1204  std::string MsgLoggerCat = "GlobalHitsProdHist_fillMuon";
1205 
1206  TString eventout;
1207  if (verbosity > 0)
1208  eventout = "\nGathering info:";
1209 
1210  // iterator to access containers
1211  edm::PSimHitContainer::const_iterator itHit;
1212 
1214  // access the CSC Muon
1216  // access the CSC Muon geometry
1217  const auto &theCSCGeometry = iSetup.getHandle(cscGeomToken_);
1218  if (!theCSCGeometry.isValid()) {
1219  edm::LogWarning(MsgLoggerCat) << "Unable to find MuonGeometryRecord for the CSCGeometry in event!";
1220  return;
1221  }
1222  const CSCGeometry &theCSCMuon(*theCSCGeometry);
1223 
1224  // get Muon CSC information
1225  edm::Handle<edm::PSimHitContainer> MuonCSCContainer;
1226  iEvent.getByToken(MuonCscSrc_Token_, MuonCSCContainer);
1227  if (!MuonCSCContainer.isValid()) {
1228  edm::LogWarning(MsgLoggerCat) << "Unable to find MuonCSCHits in event!";
1229  return;
1230  }
1231 
1232  // cycle through container
1233  int i = 0, j = 0;
1234  for (itHit = MuonCSCContainer->begin(); itHit != MuonCSCContainer->end(); ++itHit) {
1235  ++i;
1236 
1237  // create a DetId from the detUnitId
1238  DetId theDetUnitId(itHit->detUnitId());
1239  int detector = theDetUnitId.det();
1240  int subdetector = theDetUnitId.subdetId();
1241 
1242  // check that expected detector is returned
1243  if ((detector == dMuon) && (subdetector == sdMuonCSC)) {
1244  // get the GeomDetUnit from the geometry using theDetUnitID
1245  const GeomDetUnit *theDet = theCSCMuon.idToDetUnit(theDetUnitId);
1246 
1247  if (!theDet) {
1248  edm::LogWarning(MsgLoggerCat) << "Unable to get GeomDetUnit from theCSCMuon for hit " << i;
1249  continue;
1250  }
1251 
1252  ++j;
1253 
1254  // get the Surface of the hit (knows how to go from local <-> global)
1255  const BoundPlane &bSurface = theDet->surface();
1256 
1257  if (hMuonCscToF[0])
1258  hMuonCscToF[0]->Fill(itHit->tof());
1259  if (hMuonCscToF[1])
1260  hMuonCscToF[1]->Fill(itHit->tof());
1261  if (hMuonCscZ)
1262  hMuonCscZ->Fill(bSurface.toGlobal(itHit->localPosition()).z());
1263  if (hMuonPhi)
1264  hMuonPhi->Fill(bSurface.toGlobal(itHit->localPosition()).phi());
1265  if (hMuonEta)
1266  hMuonEta->Fill(bSurface.toGlobal(itHit->localPosition()).eta());
1267 
1268  } else {
1269  edm::LogWarning(MsgLoggerCat) << "MuonCsc PSimHit " << i << " is expected to be (det,subdet) = (" << dMuon << ","
1270  << sdMuonCSC << "); value returned is: (" << detector << "," << subdetector << ")";
1271  continue;
1272  } // end detector type check
1273  } // end loop through CSC Hits
1274 
1275  if (verbosity > 1) {
1276  eventout += "\n Number of CSC muon Hits collected:......... ";
1277  eventout += j;
1278  }
1279 
1280  nMuonHits += j;
1281 
1283  // access the DT Muon
1285  // access the DT Muon geometry
1286  const auto &theDTGeometry = iSetup.getHandle(dtGeomToken_);
1287  if (!theDTGeometry.isValid()) {
1288  edm::LogWarning(MsgLoggerCat) << "Unable to find MuonGeometryRecord for the DTGeometry in event!";
1289  return;
1290  }
1291  const DTGeometry &theDTMuon(*theDTGeometry);
1292 
1293  // get Muon DT information
1294  edm::Handle<edm::PSimHitContainer> MuonDtContainer;
1295  iEvent.getByToken(MuonDtSrc_Token_, MuonDtContainer);
1296  if (!MuonDtContainer.isValid()) {
1297  edm::LogWarning(MsgLoggerCat) << "Unable to find MuonDTHits in event!";
1298  return;
1299  }
1300 
1301  // cycle through container
1302  i = 0, j = 0;
1303  for (itHit = MuonDtContainer->begin(); itHit != MuonDtContainer->end(); ++itHit) {
1304  ++i;
1305 
1306  // create a DetId from the detUnitId
1307  DetId theDetUnitId(itHit->detUnitId());
1308  int detector = theDetUnitId.det();
1309  int subdetector = theDetUnitId.subdetId();
1310 
1311  // check that expected detector is returned
1312  if ((detector == dMuon) && (subdetector == sdMuonDT)) {
1313  // CSC uses wires and layers rather than the full detID
1314  // get the wireId
1315  DTWireId wireId(itHit->detUnitId());
1316 
1317  // get the DTLayer from the geometry using the wireID
1318  const DTLayer *theDet = theDTMuon.layer(wireId.layerId());
1319 
1320  if (!theDet) {
1321  edm::LogWarning(MsgLoggerCat) << "Unable to get GeomDetUnit from theDtMuon for hit " << i;
1322  continue;
1323  }
1324 
1325  ++j;
1326 
1327  // get the Surface of the hit (knows how to go from local <-> global)
1328  const BoundPlane &bSurface = theDet->surface();
1329 
1330  if (hMuonDtToF[0])
1331  hMuonDtToF[0]->Fill(itHit->tof());
1332  if (hMuonDtToF[1])
1333  hMuonDtToF[1]->Fill(itHit->tof());
1334  if (hMuonDtR)
1335  hMuonDtR->Fill(bSurface.toGlobal(itHit->localPosition()).perp());
1336  if (hMuonPhi)
1337  hMuonPhi->Fill(bSurface.toGlobal(itHit->localPosition()).phi());
1338  if (hMuonEta)
1339  hMuonEta->Fill(bSurface.toGlobal(itHit->localPosition()).eta());
1340 
1341  } else {
1342  edm::LogWarning(MsgLoggerCat) << "MuonDt PSimHit " << i << " is expected to be (det,subdet) = (" << dMuon << ","
1343  << sdMuonDT << "); value returned is: (" << detector << "," << subdetector << ")";
1344  continue;
1345  } // end detector type check
1346  } // end loop through DT Hits
1347 
1348  if (verbosity > 1) {
1349  eventout += "\n Number of DT muon Hits collected:.......... ";
1350  eventout += j;
1351  }
1352 
1353  nMuonHits += j;
1354 
1355  // int RPCBrl = 0, RPCFwd = 0;
1357  // access the RPC Muon
1359  // access the RPC Muon geometry
1360  const auto &theRPCGeometry = iSetup.getHandle(rpcGeomToken_);
1361  if (!theRPCGeometry.isValid()) {
1362  edm::LogWarning(MsgLoggerCat) << "Unable to find MuonGeometryRecord for the RPCGeometry in event!";
1363  return;
1364  }
1365  const RPCGeometry &theRPCMuon(*theRPCGeometry);
1366 
1367  // get Muon RPC information
1368  edm::Handle<edm::PSimHitContainer> MuonRPCContainer;
1369  iEvent.getByToken(MuonRpcSrc_Token_, MuonRPCContainer);
1370  if (!MuonRPCContainer.isValid()) {
1371  edm::LogWarning(MsgLoggerCat) << "Unable to find MuonRPCHits in event!";
1372  return;
1373  }
1374 
1375  // cycle through container
1376  i = 0, j = 0;
1377  int RPCBrl = 0, RPCFwd = 0;
1378  for (itHit = MuonRPCContainer->begin(); itHit != MuonRPCContainer->end(); ++itHit) {
1379  ++i;
1380 
1381  // create a DetID from the detUnitId
1382  DetId theDetUnitId(itHit->detUnitId());
1383  int detector = theDetUnitId.det();
1384  int subdetector = theDetUnitId.subdetId();
1385 
1386  // check that expected detector is returned
1387  if ((detector == dMuon) && (subdetector == sdMuonRPC)) {
1388  // get an RPCDetID from the detUnitID
1389  RPCDetId RPCId(itHit->detUnitId());
1390 
1391  // find the region of the RPC hit
1392  int region = RPCId.region();
1393 
1394  // get the GeomDetUnit from the geometry using the RPCDetId
1395  const GeomDetUnit *theDet = theRPCMuon.idToDetUnit(theDetUnitId);
1396 
1397  if (!theDet) {
1398  edm::LogWarning(MsgLoggerCat) << "Unable to get GeomDetUnit from theRPCMuon for hit " << i;
1399  continue;
1400  }
1401 
1402  ++j;
1403 
1404  // get the Surface of the hit (knows how to go from local <-> global)
1405  const BoundPlane &bSurface = theDet->surface();
1406 
1407  // gather necessary information
1408  if ((region == sdMuonRPCRgnFwdp) || (region == sdMuonRPCRgnFwdn)) {
1409  ++RPCFwd;
1410 
1411  if (hMuonRpcFToF[0])
1412  hMuonRpcFToF[0]->Fill(itHit->tof());
1413  if (hMuonRpcFToF[1])
1414  hMuonRpcFToF[1]->Fill(itHit->tof());
1415  if (hMuonRpcFZ)
1416  hMuonRpcFZ->Fill(bSurface.toGlobal(itHit->localPosition()).z());
1417  if (hMuonPhi)
1418  hMuonPhi->Fill(bSurface.toGlobal(itHit->localPosition()).phi());
1419  if (hMuonEta)
1420  hMuonEta->Fill(bSurface.toGlobal(itHit->localPosition()).eta());
1421 
1422  } else if (region == sdMuonRPCRgnBrl) {
1423  ++RPCBrl;
1424 
1425  if (hMuonRpcBToF[0])
1426  hMuonRpcBToF[0]->Fill(itHit->tof());
1427  if (hMuonRpcBToF[1])
1428  hMuonRpcBToF[1]->Fill(itHit->tof());
1429  if (hMuonRpcBR)
1430  hMuonRpcBR->Fill(bSurface.toGlobal(itHit->localPosition()).perp());
1431  if (hMuonPhi)
1432  hMuonPhi->Fill(bSurface.toGlobal(itHit->localPosition()).phi());
1433  if (hMuonEta)
1434  hMuonEta->Fill(bSurface.toGlobal(itHit->localPosition()).eta());
1435 
1436  } else {
1437  edm::LogWarning(MsgLoggerCat) << "Invalid region for RPC Muon hit" << i;
1438  continue;
1439  } // end check of region
1440  } else {
1441  edm::LogWarning(MsgLoggerCat) << "MuonRpc PSimHit " << i << " is expected to be (det,subdet) = (" << dMuon << ","
1442  << sdMuonRPC << "); value returned is: (" << detector << "," << subdetector << ")";
1443  continue;
1444  } // end detector type check
1445  } // end loop through RPC Hits
1446 
1447  if (verbosity > 1) {
1448  eventout += "\n Number of RPC muon Hits collected:......... ";
1449  eventout += j;
1450  eventout += "\n RPC Barrel muon Hits:............ ";
1451  eventout += RPCBrl;
1452  eventout += "\n RPC Forward muon Hits:........... ";
1453  eventout += RPCFwd;
1454  }
1455 
1456  nMuonHits += j;
1457 
1458  if (hMuon[0])
1459  hMuon[0]->Fill((float)nMuonHits);
1460  if (hMuon[1])
1461  hMuon[1]->Fill((float)nMuonHits);
1462 
1463  if (verbosity > 0)
1464  edm::LogInfo(MsgLoggerCat) << eventout << "\n";
1465 
1466  return;
1467 }
1468 
1470  std::string MsgLoggerCat = "GlobalHitsProdHist_fillECal";
1471 
1472  TString eventout;
1473  if (verbosity > 0)
1474  eventout = "\nGathering info:";
1475 
1476  // access the calorimeter geometry
1477  const auto &theCaloGeometry = iSetup.getHandle(caloGeomToken_);
1478  if (!theCaloGeometry.isValid()) {
1479  edm::LogWarning(MsgLoggerCat) << "Unable to find CaloGeometryRecord in event!";
1480  return;
1481  }
1482  const CaloGeometry &theCalo(*theCaloGeometry);
1483 
1484  // iterator to access containers
1485  edm::PCaloHitContainer::const_iterator itHit;
1486 
1488  // get ECal information
1490  edm::PCaloHitContainer theECalHits;
1491  // extract EB container
1493  iEvent.getByToken(ECalEBSrc_Token_, EBContainer);
1494  if (!EBContainer.isValid()) {
1495  edm::LogWarning(MsgLoggerCat) << "Unable to find EcalHitsEB in event!";
1496  return;
1497  }
1498  // extract EE container
1500  iEvent.getByToken(ECalEESrc_Token_, EEContainer);
1501  if (!EEContainer.isValid()) {
1502  edm::LogWarning(MsgLoggerCat) << "Unable to find EcalHitsEE in event!";
1503  return;
1504  }
1505  // place both containers into new container
1506  theECalHits.insert(theECalHits.end(), EBContainer->begin(), EBContainer->end());
1507  theECalHits.insert(theECalHits.end(), EEContainer->begin(), EEContainer->end());
1508 
1509  // cycle through new container
1510  int i = 0, j = 0;
1511  for (itHit = theECalHits.begin(); itHit != theECalHits.end(); ++itHit) {
1512  ++i;
1513 
1514  // create a DetId from the detUnitId
1515  DetId theDetUnitId(itHit->id());
1516  int detector = theDetUnitId.det();
1517  int subdetector = theDetUnitId.subdetId();
1518 
1519  // check that expected detector is returned
1520  if ((detector == dEcal) && ((subdetector == sdEcalBrl) || (subdetector == sdEcalFwd))) {
1521  // get the Cell geometry
1522  auto theDet = (theCalo.getSubdetectorGeometry(theDetUnitId))->getGeometry(theDetUnitId);
1523 
1524  if (!theDet) {
1525  edm::LogWarning(MsgLoggerCat) << "Unable to get CaloCellGeometry from ECalHits for Hit " << i;
1526  continue;
1527  }
1528 
1529  ++j;
1530 
1531  // get the global position of the cell
1532  const GlobalPoint &globalposition = theDet->getPosition();
1533 
1534  if (hCaloEcalE[0])
1535  hCaloEcalE[0]->Fill(itHit->energy());
1536  if (hCaloEcalE[1])
1537  hCaloEcalE[1]->Fill(itHit->energy());
1538  if (hCaloEcalToF[0])
1539  hCaloEcalToF[0]->Fill(itHit->time());
1540  if (hCaloEcalToF[1])
1541  hCaloEcalToF[1]->Fill(itHit->time());
1542  if (hCaloEcalPhi)
1543  hCaloEcalPhi->Fill(globalposition.phi());
1544  if (hCaloEcalEta)
1545  hCaloEcalEta->Fill(globalposition.eta());
1546 
1547  } else {
1548  edm::LogWarning(MsgLoggerCat) << "ECal PCaloHit " << i << " is expected to be (det,subdet) = (" << dEcal << ","
1549  << sdEcalBrl << " || " << sdEcalFwd << "); value returned is: (" << detector << ","
1550  << subdetector << ")";
1551  continue;
1552  } // end detector type check
1553  } // end loop through ECal Hits
1554 
1555  if (verbosity > 1) {
1556  eventout += "\n Number of ECal Hits collected:............. ";
1557  eventout += j;
1558  }
1559 
1560  if (hCaloEcal[0])
1561  hCaloEcal[0]->Fill((float)j);
1562  if (hCaloEcal[1])
1563  hCaloEcal[1]->Fill((float)j);
1564 
1566  // Get Preshower information
1568  // extract PreShower container
1569  edm::Handle<edm::PCaloHitContainer> PreShContainer;
1570  iEvent.getByToken(ECalESSrc_Token_, PreShContainer);
1571  if (!PreShContainer.isValid()) {
1572  edm::LogWarning(MsgLoggerCat) << "Unable to find EcalHitsES in event!";
1573  return;
1574  }
1575 
1576  // cycle through container
1577  i = 0, j = 0;
1578  for (itHit = PreShContainer->begin(); itHit != PreShContainer->end(); ++itHit) {
1579  ++i;
1580 
1581  // create a DetId from the detUnitId
1582  DetId theDetUnitId(itHit->id());
1583  int detector = theDetUnitId.det();
1584  int subdetector = theDetUnitId.subdetId();
1585 
1586  // check that expected detector is returned
1587  if ((detector == dEcal) && (subdetector == sdEcalPS)) {
1588  // get the Cell geometry
1589  auto theDet = (theCalo.getSubdetectorGeometry(theDetUnitId))->getGeometry(theDetUnitId);
1590 
1591  if (!theDet) {
1592  edm::LogWarning(MsgLoggerCat) << "Unable to get CaloCellGeometry from PreShContainer for Hit " << i;
1593  continue;
1594  }
1595 
1596  ++j;
1597 
1598  // get the global position of the cell
1599  const GlobalPoint &globalposition = theDet->getPosition();
1600 
1601  if (hCaloPreShE[0])
1602  hCaloPreShE[0]->Fill(itHit->energy());
1603  if (hCaloPreShE[1])
1604  hCaloPreShE[1]->Fill(itHit->energy());
1605  if (hCaloPreShToF[0])
1606  hCaloPreShToF[0]->Fill(itHit->time());
1607  if (hCaloPreShToF[1])
1608  hCaloPreShToF[1]->Fill(itHit->time());
1609  if (hCaloPreShPhi)
1610  hCaloPreShPhi->Fill(globalposition.phi());
1611  if (hCaloPreShEta)
1612  hCaloPreShEta->Fill(globalposition.eta());
1613 
1614  } else {
1615  edm::LogWarning(MsgLoggerCat) << "PreSh PCaloHit " << i << " is expected to be (det,subdet) = (" << dEcal << ","
1616  << sdEcalPS << "); value returned is: (" << detector << "," << subdetector << ")";
1617  continue;
1618  } // end detector type check
1619  } // end loop through PreShower Hits
1620 
1621  if (verbosity > 1) {
1622  eventout += "\n Number of PreSh Hits collected:............ ";
1623  eventout += j;
1624  }
1625 
1626  if (hCaloPreSh[0])
1627  hCaloPreSh[0]->Fill((float)j);
1628  if (hCaloPreSh[1])
1629  hCaloPreSh[1]->Fill((float)j);
1630 
1631  if (verbosity > 0)
1632  edm::LogInfo(MsgLoggerCat) << eventout << "\n";
1633 
1634  return;
1635 }
1636 
1638  std::string MsgLoggerCat = "GlobalHitsProdHist_fillHCal";
1639 
1640  TString eventout;
1641  if (verbosity > 0)
1642  eventout = "\nGathering info:";
1643 
1644  // access the calorimeter geometry
1645  const auto &theCaloGeometry = iSetup.getHandle(caloGeomToken_);
1646  if (!theCaloGeometry.isValid()) {
1647  edm::LogWarning(MsgLoggerCat) << "Unable to find CaloGeometryRecord in event!";
1648  return;
1649  }
1650  const CaloGeometry &theCalo(*theCaloGeometry);
1651 
1652  // iterator to access containers
1653  edm::PCaloHitContainer::const_iterator itHit;
1654 
1656  // get HCal information
1658  // extract HCal container
1660  iEvent.getByToken(HCalSrc_Token_, HCalContainer);
1661  if (!HCalContainer.isValid()) {
1662  edm::LogWarning(MsgLoggerCat) << "Unable to find HCalHits in event!";
1663  return;
1664  }
1665 
1666  // cycle through container
1667  int i = 0, j = 0;
1668  for (itHit = HCalContainer->begin(); itHit != HCalContainer->end(); ++itHit) {
1669  ++i;
1670 
1671  // create a DetId from the detUnitId
1672  DetId theDetUnitId(itHit->id());
1673  int detector = theDetUnitId.det();
1674  int subdetector = theDetUnitId.subdetId();
1675 
1676  // check that expected detector is returned
1677  if ((detector == dHcal) && ((subdetector == sdHcalBrl) || (subdetector == sdHcalEC) || (subdetector == sdHcalOut) ||
1678  (subdetector == sdHcalFwd))) {
1679  // get the Cell geometry
1680  const HcalGeometry *theDet = dynamic_cast<const HcalGeometry *>(theCalo.getSubdetectorGeometry(theDetUnitId));
1681 
1682  if (!theDet) {
1683  edm::LogWarning(MsgLoggerCat) << "Unable to get HcalGeometry from HCalContainer for Hit " << i;
1684  continue;
1685  }
1686 
1687  ++j;
1688 
1689  // get the global position of the cell
1690  const GlobalPoint &globalposition = theDet->getPosition(theDetUnitId);
1691 
1692  if (hCaloHcalE[0])
1693  hCaloHcalE[0]->Fill(itHit->energy());
1694  if (hCaloHcalE[1])
1695  hCaloHcalE[1]->Fill(itHit->energy());
1696  if (hCaloHcalToF[0])
1697  hCaloHcalToF[0]->Fill(itHit->time());
1698  if (hCaloHcalToF[1])
1699  hCaloHcalToF[1]->Fill(itHit->time());
1700  if (hCaloHcalPhi)
1701  hCaloHcalPhi->Fill(globalposition.phi());
1702  if (hCaloHcalEta)
1703  hCaloHcalEta->Fill(globalposition.eta());
1704 
1705  } else {
1706  edm::LogWarning(MsgLoggerCat) << "HCal PCaloHit " << i << " is expected to be (det,subdet) = (" << dHcal << ","
1707  << sdHcalBrl << " || " << sdHcalEC << " || " << sdHcalOut << " || " << sdHcalFwd
1708  << "); value returned is: (" << detector << "," << subdetector << ")";
1709  continue;
1710  } // end detector type check
1711  } // end loop through HCal Hits
1712 
1713  if (verbosity > 1) {
1714  eventout += "\n Number of HCal Hits collected:............. ";
1715  eventout += j;
1716  }
1717 
1718  if (hCaloHcal[0])
1719  hCaloHcal[0]->Fill((float)j);
1720  if (hCaloHcal[1])
1721  hCaloHcal[1]->Fill((float)j);
1722 
1723  if (verbosity > 0)
1724  edm::LogInfo(MsgLoggerCat) << eventout << "\n";
1725 
1726  return;
1727 }
edm::InputTag SiTECHighSrc_
edm::EDGetTokenT< edm::PSimHitContainer > PxlFwdHighSrc_Token_
edm::EDGetTokenT< edm::PSimHitContainer > SiTECHighSrc_Token_
static const int dEcal
edm::InputTag SiTIDLowSrc_
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
static const int dTrk
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::vector< PCaloHit > PCaloHitContainer
void beginJob() override
static const int sdMuonRPCRgnFwdn
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
edm::EDGetTokenT< edm::PSimHitContainer > PxlBrlHighSrc_Token_
static const int sdHcalOut
static const int sdMuonDT
edm::InputTag SiTECLowSrc_
edm::EDGetTokenT< edm::PSimHitContainer > PxlBrlLowSrc_Token_
edm::EDGetTokenT< edm::PSimHitContainer > SiTOBHighSrc_Token_
edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeomToken_
std::string const & instance() const
Definition: InputTag.h:37
TString subdetector
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
static const int sdSiTID
T eta() const
Definition: PV3DBase.h:73
edm::InputTag MuonRpcSrc_
unsigned long long EventNumber_t
static const int sdEcalPS
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > tGeomToken_
const GeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
Definition: RPCGeometry.cc:30
static const int sdMuonRPC
edm::EDGetTokenT< edm::PSimHitContainer > MuonRpcSrc_Token_
std::string const & label() const
Definition: InputTag.h:36
edm::InputTag MuonCscSrc_
Provenance const * provenance() const
Definition: HandleBase.h:74
void fillHCal(edm::Event &, const edm::EventSetup &)
edm::InputTag SiTIBLowSrc_
T getUntrackedParameter(std::string const &, T const &) const
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
std::map< std::string, TH1F * > histMap_
edm::EDGetTokenT< edm::PCaloHitContainer > ECalESSrc_Token_
std::vector< std::string > histName_
int iEvent
Definition: GenABIO.cc:224
void fillG4MC(edm::Event &)
static const int sdSiTIB
edm::InputTag PxlFwdHighSrc_
edm::InputTag MuonDtSrc_
static const int sdPxlBrl
T sqrt(T t)
Definition: SSEVec.h:19
static const int sdMuonCSC
static const int sdEcalFwd
edm::ESGetToken< CSCGeometry, MuonGeometryRecord > cscGeomToken_
edm::InputTag ECalEESrc_
void endRunProduce(edm::Run &, const edm::EventSetup &) override
edm::InputTag SiTOBHighSrc_
void produce(edm::Event &, const edm::EventSetup &) override
BranchDescription const & branchDescription() const
Definition: Provenance.h:45
static const int sdSiTOB
static const int sdEcalBrl
edm::ESGetToken< RPCGeometry, MuonGeometryRecord > rpcGeomToken_
edm::EDGetTokenT< edm::SimTrackContainer > G4TrkSrc_Token_
static const int sdMuonRPCRgnFwdp
void fillTrk(edm::Event &, const edm::EventSetup &)
static const int sdMuonRPCRgnBrl
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:151
T perp() const
Magnitude of transverse component.
Basic3DVector unit() const
edm::EDGetTokenT< edm::PSimHitContainer > SiTIDLowSrc_Token_
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:37
edm::EDGetTokenT< edm::PSimHitContainer > SiTIDHighSrc_Token_
Log< level::Info, false > LogInfo
Definition: DetId.h:17
edm::EDGetTokenT< edm::PSimHitContainer > SiTOBLowSrc_Token_
static const int dHcal
edm::InputTag ECalESSrc_
edm::InputTag SiTIBHighSrc_
edm::EDGetTokenT< edm::PCaloHitContainer > ECalEBSrc_Token_
edm::EDGetTokenT< edm::PCaloHitContainer > ECalEESrc_Token_
edm::EDGetTokenT< edm::PSimHitContainer > SiTIBHighSrc_Token_
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
edm::EDGetTokenT< edm::PSimHitContainer > SiTIBLowSrc_Token_
edm::InputTag PxlFwdLowSrc_
std::vector< SimVertex > SimVertexContainer
static const int sdHcalFwd
void put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Run.h:109
edm::EDGetTokenT< edm::PCaloHitContainer > HCalSrc_Token_
void fillECal(edm::Event &, const edm::EventSetup &)
static const int sdHcalBrl
edm::EDGetTokenT< edm::PSimHitContainer > SiTECLowSrc_Token_
void endJob() override
edm::EDGetTokenT< edm::PSimHitContainer > MuonCscSrc_Token_
edm::EDGetTokenT< edm::PSimHitContainer > MuonDtSrc_Token_
bool isValid() const
Definition: HandleBase.h:70
edm::EDGetTokenT< edm::SimVertexContainer > G4VtxSrc_Token_
static const int sdSiTEC
edm::InputTag PxlBrlHighSrc_
static const int dMuon
HLT enums.
void fillMuon(edm::Event &, const edm::EventSetup &)
GlobalPoint getPosition(const DetId &id) const
edm::InputTag PxlBrlLowSrc_
std::vector< PSimHit > PSimHitContainer
unsigned int RunNumber_t
static const int sdPxlFwd
edm::InputTag SiTOBLowSrc_
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeomToken_
Log< level::Warning, false > LogWarning
edm::EDGetTokenT< edm::PSimHitContainer > PxlFwdLowSrc_Token_
GlobalHitsProdHist(const edm::ParameterSet &)
edm::InputTag ECalEBSrc_
std::vector< SimTrack > SimTrackContainer
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:34
static const int sdHcalEC
def move(src, dest)
Definition: eostools.py:511
edm::InputTag SiTIDHighSrc_
Definition: Run.h:45
const GeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
Definition: CSCGeometry.cc:89
const DTLayer * layer(const DTLayerId &id) const
Return a layer given its id.
Definition: DTGeometry.cc:96