CMS 3D CMS Logo

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