CMS 3D CMS Logo

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