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