CMS 3D CMS Logo

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