CMS 3D CMS Logo

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