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