CMS 3D CMS Logo

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