CMS 3D CMS Logo

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