CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GlobalHitsProducer.cc
Go to the documentation of this file.
1 
12 
14  fName(""), verbosity(0), frequency(0), vtxunit(0), label(""),
15  getAllProvenances(false), printProvenanceInfo(false), nRawGenPart(0),
16  //ECalEBSrc_(""), ECalEESrc_(""), ECalESSrc_(""), HCalSrc_(""),
17  //PxlBrlLowSrc_(""), PxlBrlHighSrc_(""), PxlFwdLowSrc_(""),
18  //PxlFwdHighSrc_(""), SiTIBLowSrc_(""), SiTIBHighSrc_(""),
19  //SiTOBLowSrc_(""), SiTOBHighSrc_(""), SiTIDLowSrc_(""),
20  //SiTIDHighSrc_(""), SiTECLowSrc_(""), SiTECHighSrc_(""),
21  //MuonDtSrc_(""), MuonCscSrc_(""), MuonRpcSrc_(""),
22  count(0)
23 {
24  std::string MsgLoggerCat = "GlobalHitsProducer_GlobalHitsProducer";
25 
26  // get information from parameter set
27  fName = iPSet.getUntrackedParameter<std::string>("Name");
28  verbosity = iPSet.getUntrackedParameter<int>("Verbosity");
29  frequency = iPSet.getUntrackedParameter<int>("Frequency");
30  vtxunit = iPSet.getUntrackedParameter<int>("VtxUnit");
31  label = iPSet.getParameter<std::string>("Label");
32  edm::ParameterSet m_Prov =
33  iPSet.getParameter<edm::ParameterSet>("ProvenanceLookup");
35  m_Prov.getUntrackedParameter<bool>("GetAllProvenances");
37  m_Prov.getUntrackedParameter<bool>("PrintProvenanceInfo");
38 
39  //get Labels to use to extract information
40  PxlBrlLowSrc_ = iPSet.getParameter<edm::InputTag>("PxlBrlLowSrc");
41  PxlBrlHighSrc_ = iPSet.getParameter<edm::InputTag>("PxlBrlHighSrc");
42  PxlFwdLowSrc_ = iPSet.getParameter<edm::InputTag>("PxlFwdLowSrc");
43  PxlFwdHighSrc_ = iPSet.getParameter<edm::InputTag>("PxlFwdHighSrc");
44 
45  SiTIBLowSrc_ = iPSet.getParameter<edm::InputTag>("SiTIBLowSrc");
46  SiTIBHighSrc_ = iPSet.getParameter<edm::InputTag>("SiTIBHighSrc");
47  SiTOBLowSrc_ = iPSet.getParameter<edm::InputTag>("SiTOBLowSrc");
48  SiTOBHighSrc_ = iPSet.getParameter<edm::InputTag>("SiTOBHighSrc");
49  SiTIDLowSrc_ = iPSet.getParameter<edm::InputTag>("SiTIDLowSrc");
50  SiTIDHighSrc_ = iPSet.getParameter<edm::InputTag>("SiTIDHighSrc");
51  SiTECLowSrc_ = iPSet.getParameter<edm::InputTag>("SiTECLowSrc");
52  SiTECHighSrc_ = iPSet.getParameter<edm::InputTag>("SiTECHighSrc");
53 
54  MuonCscSrc_ = iPSet.getParameter<edm::InputTag>("MuonCscSrc");
55  MuonDtSrc_ = iPSet.getParameter<edm::InputTag>("MuonDtSrc");
56  MuonRpcSrc_ = iPSet.getParameter<edm::InputTag>("MuonRpcSrc");
57 
58  ECalEBSrc_ = iPSet.getParameter<edm::InputTag>("ECalEBSrc");
59  ECalEESrc_ = iPSet.getParameter<edm::InputTag>("ECalEESrc");
60  ECalESSrc_ = iPSet.getParameter<edm::InputTag>("ECalESSrc");
61 
62  HCalSrc_ = iPSet.getParameter<edm::InputTag>("HCalSrc");
63 
64  // use value of first digit to determine default output level (inclusive)
65  // 0 is none, 1 is basic, 2 is fill output, 3 is gather output
66  verbosity %= 10;
67 
68  // create persistent object
69  produces<PGlobalSimHit>(label);
70 
71  // print out Parameter Set information being used
72  if (verbosity >= 0) {
73  edm::LogInfo(MsgLoggerCat)
74  << "\n===============================\n"
75  << "Initialized as EDProducer with parameter values:\n"
76  << " Name = " << fName << "\n"
77  << " Verbosity = " << verbosity << "\n"
78  << " Frequency = " << frequency << "\n"
79  << " VtxUnit = " << vtxunit << "\n"
80  << " Label = " << label << "\n"
81  << " GetProv = " << getAllProvenances << "\n"
82  << " PrintProv = " << printProvenanceInfo << "\n"
83  << " PxlBrlLowSrc = " << PxlBrlLowSrc_.label()
84  << ":" << PxlBrlLowSrc_.instance() << "\n"
85  << " PxlBrlHighSrc = " << PxlBrlHighSrc_.label()
86  << ":" << PxlBrlHighSrc_.instance() << "\n"
87  << " PxlFwdLowSrc = " << PxlFwdLowSrc_.label()
88  << ":" << PxlBrlLowSrc_.instance() << "\n"
89  << " PxlFwdHighSrc = " << PxlFwdHighSrc_.label()
90  << ":" << PxlBrlHighSrc_.instance() << "\n"
91  << " SiTIBLowSrc = " << SiTIBLowSrc_.label()
92  << ":" << SiTIBLowSrc_.instance() << "\n"
93  << " SiTIBHighSrc = " << SiTIBHighSrc_.label()
94  << ":" << SiTIBHighSrc_.instance() << "\n"
95  << " SiTOBLowSrc = " << SiTOBLowSrc_.label()
96  << ":" << SiTOBLowSrc_.instance() << "\n"
97  << " SiTOBHighSrc = " << SiTOBHighSrc_.label()
98  << ":" << SiTOBHighSrc_.instance() << "\n"
99  << " SiTIDLowSrc = " << SiTIDLowSrc_.label()
100  << ":" << SiTIDLowSrc_.instance() << "\n"
101  << " SiTIDHighSrc = " << SiTIDHighSrc_.label()
102  << ":" << SiTIDHighSrc_.instance() << "\n"
103  << " SiTECLowSrc = " << SiTECLowSrc_.label()
104  << ":" << SiTECLowSrc_.instance() << "\n"
105  << " SiTECHighSrc = " << SiTECHighSrc_.label()
106  << ":" << SiTECHighSrc_.instance() << "\n"
107  << " MuonCscSrc = " << MuonCscSrc_.label()
108  << ":" << MuonCscSrc_.instance() << "\n"
109  << " MuonDtSrc = " << MuonDtSrc_.label()
110  << ":" << MuonDtSrc_.instance() << "\n"
111  << " MuonRpcSrc = " << MuonRpcSrc_.label()
112  << ":" << MuonRpcSrc_.instance() << "\n"
113  << " ECalEBSrc = " << ECalEBSrc_.label()
114  << ":" << ECalEBSrc_.instance() << "\n"
115  << " ECalEESrc = " << ECalEESrc_.label()
116  << ":" << ECalEESrc_.instance() << "\n"
117  << " ECalESSrc = " << ECalESSrc_.label()
118  << ":" << ECalESSrc_.instance() << "\n"
119  << " HCalSrc = " << HCalSrc_.label()
120  << ":" << HCalSrc_.instance() << "\n"
121  << "===============================\n";
122  }
123 
124  // migrated here from beginJob
125  clear();
126 
127 }
128 
130 {
131 }
132 
134 {
135  return;
136 }
137 
139 {
140  std::string MsgLoggerCat = "GlobalHitsProducer_endJob";
141  if (verbosity >= 0)
142  edm::LogInfo(MsgLoggerCat)
143  << "Terminating having processed " << count << " events.";
144  return;
145 }
146 
148  const edm::EventSetup& iSetup)
149 {
150  std::string MsgLoggerCat = "GlobalHitsProducer_produce";
151 
152  // keep track of number of events processed
153  ++count;
154 
155  // get event id information
156  int nrun = iEvent.id().run();
157  int nevt = iEvent.id().event();
158 
159  if (verbosity > 0) {
160  edm::LogInfo(MsgLoggerCat)
161  << "Processing run " << nrun << ", event " << nevt
162  << " (" << count << " events total)";
163  } else if (verbosity == 0) {
164  if (nevt%frequency == 0 || nevt == 1) {
165  edm::LogInfo(MsgLoggerCat)
166  << "Processing run " << nrun << ", event " << nevt
167  << " (" << count << " events total)";
168  }
169  }
170 
171  // clear event holders
172  clear();
173 
174  // look at information available in the event
175  if (getAllProvenances) {
176 
177  std::vector<const edm::Provenance*> AllProv;
178  iEvent.getAllProvenance(AllProv);
179 
180  if (verbosity >= 0)
181  edm::LogInfo(MsgLoggerCat)
182  << "Number of Provenances = " << AllProv.size();
183 
184  if (printProvenanceInfo && (verbosity >= 0)) {
185  TString eventout("\nProvenance info:\n");
186 
187  for (unsigned int i = 0; i < AllProv.size(); ++i) {
188  eventout += "\n ******************************";
189  eventout += "\n Module : ";
190  eventout += AllProv[i]->moduleLabel();
191  eventout += "\n ProductID : ";
192  eventout += AllProv[i]->productID().id();
193  eventout += "\n ClassName : ";
194  eventout += AllProv[i]->className();
195  eventout += "\n InstanceName : ";
196  eventout += AllProv[i]->productInstanceName();
197  eventout += "\n BranchName : ";
198  eventout += AllProv[i]->branchName();
199  }
200  eventout += "\n ******************************\n";
201  edm::LogInfo(MsgLoggerCat) << eventout << "\n";
202  printProvenanceInfo = false;
203  }
204  getAllProvenances = false;
205  }
206 
207  // call fill functions
208  //gather G4MC information from event
209  fillG4MC(iEvent);
210  // gather Tracker information from event
211  fillTrk(iEvent,iSetup);
212  // gather muon information from event
213  fillMuon(iEvent, iSetup);
214  // gather Ecal information from event
215  fillECal(iEvent, iSetup);
216  // gather Hcal information from event
217  fillHCal(iEvent, iSetup);
218 
219  if (verbosity > 0)
220  edm::LogInfo (MsgLoggerCat)
221  << "Done gathering data from event.";
222 
223  // produce object to put into event
224  std::auto_ptr<PGlobalSimHit> pOut(new PGlobalSimHit);
225 
226  if (verbosity > 2)
227  edm::LogInfo (MsgLoggerCat)
228  << "Saving event contents:";
229 
230  // call store functions
231  // store G4MC information in product
232  storeG4MC(*pOut);
233  // store Tracker information in produce
234  storeTrk(*pOut);
235  // store Muon information in produce
236  storeMuon(*pOut);
237  // store ECal information in produce
238  storeECal(*pOut);
239  // store HCal information in produce
240  storeHCal(*pOut);
241 
242  // store information in event
243  iEvent.put(pOut,label);
244 
245  return;
246 }
247 
248 //==================fill and store functions================================
250 {
251 
252  std::string MsgLoggerCat = "GlobalHitsProducer_fillG4MC";
253 
254  TString eventout;
255  if (verbosity > 0)
256  eventout = "\nGathering info:";
257 
259  // get MC information
262  std::vector<edm::Handle<edm::HepMCProduct> > AllHepMCEvt;
263  iEvent.getManyByType(AllHepMCEvt);
264 
265  // loop through products and extract VtxSmearing if available. Any of them
266  // should have the information needed
267  for (unsigned int i = 0; i < AllHepMCEvt.size(); ++i) {
268  HepMCEvt = AllHepMCEvt[i];
269  if ((HepMCEvt.provenance()->product()).moduleLabel() == "VtxSmeared")
270  break;
271  }
272 
273  if (!HepMCEvt.isValid()) {
274  edm::LogWarning(MsgLoggerCat)
275  << "Unable to find HepMCProduct in event!";
276  return;
277  } else {
278  eventout += "\n Using HepMCProduct: ";
279  eventout += (HepMCEvt.provenance()->product()).moduleLabel();
280  }
281  const HepMC::GenEvent* MCEvt = HepMCEvt->GetEvent();
282  nRawGenPart = MCEvt->particles_size();
283 
284  if (verbosity > 1) {
285  eventout += "\n Number of Raw Particles collected:......... ";
286  eventout += nRawGenPart;
287  }
288 
290  // get G4Vertex information
292  // convert unit stored in SimVertex to mm
293  float unit = 0.;
294  if (vtxunit == 0) unit = 1.; // already in mm
295  if (vtxunit == 1) unit = 10.; // stored in cm, convert to mm
296 
298  iEvent.getByType(G4VtxContainer);
299  if (!G4VtxContainer.isValid()) {
300  edm::LogWarning(MsgLoggerCat)
301  << "Unable to find SimVertex in event!";
302  return;
303  }
304  int i = 0;
305  edm::SimVertexContainer::const_iterator itVtx;
306  for (itVtx = G4VtxContainer->begin(); itVtx != G4VtxContainer->end();
307  ++itVtx) {
308 
309  ++i;
310 
311  const math::XYZTLorentzVector G4Vtx1(itVtx->position().x(),
312  itVtx->position().y(),
313  itVtx->position().z(),
314  itVtx->position().e());
315  double G4Vtx[4];
316  G4Vtx1.GetCoordinates(G4Vtx);
317 
318  G4VtxX.push_back((G4Vtx[0]*unit)/micrometer);
319  G4VtxY.push_back((G4Vtx[1]*unit)/micrometer);
320  G4VtxZ.push_back((G4Vtx[2]*unit)/millimeter);
321  }
322 
323  if (verbosity > 1) {
324  eventout += "\n Number of G4Vertices collected:............ ";
325  eventout += i;
326  }
327 
329  // get G4Track information
332  iEvent.getByType(G4TrkContainer);
333  if (!G4TrkContainer.isValid()) {
334  edm::LogWarning(MsgLoggerCat)
335  << "Unable to find SimTrack in event!";
336  return;
337  }
338  i = 0;
339  edm::SimTrackContainer::const_iterator itTrk;
340  for (itTrk = G4TrkContainer->begin(); itTrk != G4TrkContainer->end();
341  ++itTrk) {
342 
343  ++i;
344 
345  const math::XYZTLorentzVector G4Trk1(itTrk->momentum().x(),
346  itTrk->momentum().y(),
347  itTrk->momentum().z(),
348  itTrk->momentum().e());
349  double G4Trk[4];
350  G4Trk1.GetCoordinates(G4Trk);
351 
352  G4TrkPt.push_back(sqrt(G4Trk[0]*G4Trk[0]+G4Trk[1]*G4Trk[1])); //GeV
353  G4TrkE.push_back(G4Trk[3]); //GeV
354  }
355 
356  if (verbosity > 1) {
357  eventout += "\n Number of G4Tracks collected:.............. ";
358  eventout += i;
359  }
360 
361  if (verbosity > 0)
362  edm::LogInfo(MsgLoggerCat) << eventout << "\n";
363 
364  return;
365 }
366 
368 {
369  std::string MsgLoggerCat = "GlobalHitsProducer_storeG4MC";
370 
371  if (verbosity > 2) {
372  TString eventout("\n nRawGenPart = ");
373  eventout += nRawGenPart;
374  eventout += "\n nG4Vtx = ";
375  eventout += G4VtxX.size();
376  for (unsigned int i = 0; i < G4VtxX.size(); ++i) {
377  eventout += "\n (x,y,z) = (";
378  eventout += G4VtxX[i];
379  eventout += ", ";
380  eventout += G4VtxY[i];
381  eventout += ", ";
382  eventout += G4VtxZ[i];
383  eventout += ")";
384  }
385  eventout += "\n nG4Trk = ";
386  eventout += G4TrkPt.size();
387  for (unsigned int i = 0; i < G4TrkPt.size(); ++i) {
388  eventout += "\n (pt,e) = (";
389  eventout += G4TrkPt[i];
390  eventout += ", ";
391  eventout += G4TrkE[i];
392  eventout += ")";
393  }
394  edm::LogInfo(MsgLoggerCat) << eventout << "\n";
395  } // end verbose output
396 
397  product.putRawGenPart(nRawGenPart);
398  product.putG4Vtx(G4VtxX, G4VtxY, G4VtxZ);
399  product.putG4Trk(G4TrkPt, G4TrkE);
400 
401  return;
402 }
403 
405  const edm::EventSetup& iSetup)
406 {
407  std::string MsgLoggerCat = "GlobalHitsProducer_fillTrk";
408 
409  TString eventout;
410  if (verbosity > 0)
411  eventout = "\nGathering info:";
412 
413  // access the tracker geometry
414  edm::ESHandle<TrackerGeometry> theTrackerGeometry;
415  iSetup.get<TrackerDigiGeometryRecord>().get(theTrackerGeometry);
416  if (!theTrackerGeometry.isValid()) {
417  edm::LogWarning(MsgLoggerCat)
418  << "Unable to find TrackerDigiGeometryRecord in event!";
419  return;
420  }
421  const TrackerGeometry& theTracker(*theTrackerGeometry);
422 
423  // iterator to access containers
424  edm::PSimHitContainer::const_iterator itHit;
425 
427  // get Pixel Barrel information
429  edm::PSimHitContainer thePxlBrlHits;
430  // extract low container
431  edm::Handle<edm::PSimHitContainer> PxlBrlLowContainer;
432  iEvent.getByLabel(PxlBrlLowSrc_,PxlBrlLowContainer);
433  if (!PxlBrlLowContainer.isValid()) {
434  edm::LogWarning(MsgLoggerCat)
435  << "Unable to find TrackerHitsPixelBarrelLowTof in event!";
436  return;
437  }
438  // extract high container
439  edm::Handle<edm::PSimHitContainer> PxlBrlHighContainer;
440  iEvent.getByLabel(PxlBrlHighSrc_,PxlBrlHighContainer);
441  if (!PxlBrlHighContainer.isValid()) {
442  edm::LogWarning(MsgLoggerCat)
443  << "Unable to find TrackerHitsPixelBarrelHighTof in event!";
444  return;
445  }
446  // place both containers into new container
447  thePxlBrlHits.insert(thePxlBrlHits.end(),PxlBrlLowContainer->begin(),
448  PxlBrlLowContainer->end());
449  thePxlBrlHits.insert(thePxlBrlHits.end(),PxlBrlHighContainer->begin(),
450  PxlBrlHighContainer->end());
451 
452  // cycle through new container
453  int i = 0, j = 0;
454  for (itHit = thePxlBrlHits.begin(); itHit != thePxlBrlHits.end(); ++itHit) {
455 
456  ++i;
457 
458  // create a DetId from the detUnitId
459  DetId theDetUnitId(itHit->detUnitId());
460  int detector = theDetUnitId.det();
461  int subdetector = theDetUnitId.subdetId();
462 
463  // check that expected detector is returned
464  if ((detector == dTrk) && (subdetector == sdPxlBrl)) {
465 
466  // get the GeomDetUnit from the geometry using theDetUnitID
467  const GeomDetUnit *theDet = theTracker.idToDetUnit(theDetUnitId);
468 
469  if (!theDet) {
470  edm::LogWarning(MsgLoggerCat)
471  << "Unable to get GeomDetUnit from PxlBrlHits for Hit " << i;
472  continue;
473  }
474 
475  ++j;
476 
477  // get the Surface of the hit (knows how to go from local <-> global)
478  const BoundPlane& bSurface = theDet->surface();
479 
480  // gather necessary information
481  PxlBrlToF.push_back(itHit->tof());
482  PxlBrlR.push_back(bSurface.toGlobal(itHit->localPosition()).perp());
483  PxlBrlPhi.push_back(bSurface.toGlobal(itHit->localPosition()).phi());
484  PxlBrlEta.push_back(bSurface.toGlobal(itHit->localPosition()).eta());
485 
486  } else {
487  edm::LogWarning(MsgLoggerCat)
488  << "PxlBrl PSimHit " << i
489  << " is expected to be (det,subdet) = ("
490  << dTrk << "," << sdPxlBrl
491  << "); value returned is: ("
492  << detector << "," << subdetector << ")";
493  continue;
494  } // end detector type check
495  } // end loop through PxlBrl Hits
496 
497  if (verbosity > 1) {
498  eventout += "\n Number of Pixel Barrel Hits collected:..... ";
499  eventout += j;
500  }
501 
503  // get Pixel Forward information
505  edm::PSimHitContainer thePxlFwdHits;
506  // extract low container
507  edm::Handle<edm::PSimHitContainer> PxlFwdLowContainer;
508  iEvent.getByLabel(PxlFwdLowSrc_,PxlFwdLowContainer);
509  if (!PxlFwdLowContainer.isValid()) {
510  edm::LogWarning(MsgLoggerCat)
511  << "Unable to find TrackerHitsPixelEndcapLowTof in event!";
512  return;
513  }
514  // extract high container
515  edm::Handle<edm::PSimHitContainer> PxlFwdHighContainer;
516  iEvent.getByLabel(PxlFwdHighSrc_,PxlFwdHighContainer);
517  if (!PxlFwdHighContainer.isValid()) {
518  edm::LogWarning("GlobalHitsProducer_fillTrk")
519  << "Unable to find TrackerHitsPixelEndcapHighTof in event!";
520  return;
521  }
522  // place both containers into new container
523  thePxlFwdHits.insert(thePxlFwdHits.end(),PxlFwdLowContainer->begin(),
524  PxlFwdLowContainer->end());
525  thePxlFwdHits.insert(thePxlFwdHits.end(),PxlFwdHighContainer->begin(),
526  PxlFwdHighContainer->end());
527 
528  // cycle through new container
529  i = 0; j = 0;
530  for (itHit = thePxlFwdHits.begin(); itHit != thePxlFwdHits.end(); ++itHit) {
531 
532  ++i;
533 
534  // create a DetId from the detUnitId
535  DetId theDetUnitId(itHit->detUnitId());
536  int detector = theDetUnitId.det();
537  int subdetector = theDetUnitId.subdetId();
538 
539  // check that expected detector is returned
540  if ((detector == dTrk) && (subdetector == sdPxlFwd)) {
541 
542  // get the GeomDetUnit from the geometry using theDetUnitID
543  const GeomDetUnit *theDet = theTracker.idToDetUnit(theDetUnitId);
544 
545  if (!theDet) {
546  edm::LogWarning(MsgLoggerCat)
547  << "Unable to get GeomDetUnit from PxlFwdHits for Hit " << i;;
548  continue;
549  }
550 
551  ++j;
552 
553  // get the Surface of the hit (knows how to go from local <-> global)
554  const BoundPlane& bSurface = theDet->surface();
555 
556  // gather necessary information
557  PxlFwdToF.push_back(itHit->tof());
558  PxlFwdZ.push_back(bSurface.toGlobal(itHit->localPosition()).z());
559  PxlFwdPhi.push_back(bSurface.toGlobal(itHit->localPosition()).phi());
560  PxlFwdEta.push_back(bSurface.toGlobal(itHit->localPosition()).eta());
561  } else {
562  edm::LogWarning(MsgLoggerCat)
563  << "PxlFwd PSimHit " << i
564  << " is expected to be (det,subdet) = ("
565  << dTrk << "," << sdPxlFwd
566  << "); value returned is: ("
567  << detector << "," << subdetector << ")";
568  continue;
569  } // end detector type check
570  } // end loop through PxlFwd Hits
571 
572  if (verbosity > 1) {
573  eventout += "\n Number of Pixel Forward Hits collected:.... ";
574  eventout += j;
575  }
576 
578  // get Silicon Barrel information
580  edm::PSimHitContainer theSiBrlHits;
581  // extract TIB low container
582  edm::Handle<edm::PSimHitContainer> SiTIBLowContainer;
583  iEvent.getByLabel(SiTIBLowSrc_,SiTIBLowContainer);
584  if (!SiTIBLowContainer.isValid()) {
585  edm::LogWarning(MsgLoggerCat)
586  << "Unable to find TrackerHitsTIBLowTof in event!";
587  return;
588  }
589  // extract TIB high container
590  edm::Handle<edm::PSimHitContainer> SiTIBHighContainer;
591  iEvent.getByLabel(SiTIBHighSrc_,SiTIBHighContainer);
592  if (!SiTIBHighContainer.isValid()) {
593  edm::LogWarning(MsgLoggerCat)
594  << "Unable to find TrackerHitsTIBHighTof in event!";
595  return;
596  }
597  // extract TOB low container
598  edm::Handle<edm::PSimHitContainer> SiTOBLowContainer;
599  iEvent.getByLabel(SiTOBLowSrc_,SiTOBLowContainer);
600  if (!SiTOBLowContainer.isValid()) {
601  edm::LogWarning(MsgLoggerCat)
602  << "Unable to find TrackerHitsTOBLowTof in event!";
603  return;
604  }
605  // extract TOB high container
606  edm::Handle<edm::PSimHitContainer> SiTOBHighContainer;
607  iEvent.getByLabel(SiTOBHighSrc_,SiTOBHighContainer);
608  if (!SiTOBHighContainer.isValid()) {
609  edm::LogWarning(MsgLoggerCat)
610  << "Unable to find TrackerHitsTOBHighTof in event!";
611  return;
612  }
613  // place all containers into new container
614  theSiBrlHits.insert(theSiBrlHits.end(),SiTIBLowContainer->begin(),
615  SiTIBLowContainer->end());
616  theSiBrlHits.insert(theSiBrlHits.end(),SiTIBHighContainer->begin(),
617  SiTIBHighContainer->end());
618  theSiBrlHits.insert(theSiBrlHits.end(),SiTOBLowContainer->begin(),
619  SiTOBLowContainer->end());
620  theSiBrlHits.insert(theSiBrlHits.end(),SiTOBHighContainer->begin(),
621  SiTOBHighContainer->end());
622 
623  // cycle through new container
624  i = 0; j = 0;
625  for (itHit = theSiBrlHits.begin(); itHit != theSiBrlHits.end(); ++itHit) {
626 
627  ++i;
628 
629  // create a DetId from the detUnitId
630  DetId theDetUnitId(itHit->detUnitId());
631  int detector = theDetUnitId.det();
632  int subdetector = theDetUnitId.subdetId();
633 
634  // check that expected detector is returned
635  if ((detector == dTrk) &&
636  ((subdetector == sdSiTIB) ||
637  (subdetector == sdSiTOB))) {
638 
639  // get the GeomDetUnit from the geometry using theDetUnitID
640  const GeomDetUnit *theDet = theTracker.idToDetUnit(theDetUnitId);
641 
642  if (!theDet) {
643  edm::LogWarning(MsgLoggerCat)
644  << "Unable to get GeomDetUnit from SiBrlHits for Hit " << i;
645  continue;
646  }
647 
648  ++j;
649 
650  // get the Surface of the hit (knows how to go from local <-> global)
651  const BoundPlane& bSurface = theDet->surface();
652 
653  // gather necessary information
654  SiBrlToF.push_back(itHit->tof());
655  SiBrlR.push_back(bSurface.toGlobal(itHit->localPosition()).perp());
656  SiBrlPhi.push_back(bSurface.toGlobal(itHit->localPosition()).phi());
657  SiBrlEta.push_back(bSurface.toGlobal(itHit->localPosition()).eta());
658  } else {
659  edm::LogWarning(MsgLoggerCat)
660  << "SiBrl PSimHit " << i
661  << " is expected to be (det,subdet) = ("
662  << dTrk << "," << sdSiTIB
663  << " || " << sdSiTOB << "); value returned is: ("
664  << detector << "," << subdetector << ")";
665  continue;
666  } // end detector type check
667  } // end loop through SiBrl Hits
668 
669  if (verbosity > 1) {
670  eventout += "\n Number of Silicon Barrel Hits collected:... ";
671  eventout += j;
672  }
673 
675  // get Silicon Forward information
677  edm::PSimHitContainer theSiFwdHits;
678  // extract TID low container
679  edm::Handle<edm::PSimHitContainer> SiTIDLowContainer;
680  iEvent.getByLabel(SiTIDLowSrc_,SiTIDLowContainer);
681  if (!SiTIDLowContainer.isValid()) {
682  edm::LogWarning(MsgLoggerCat)
683  << "Unable to find TrackerHitsTIDLowTof in event!";
684  return;
685  }
686  // extract TID high container
687  edm::Handle<edm::PSimHitContainer> SiTIDHighContainer;
688  iEvent.getByLabel(SiTIDHighSrc_,SiTIDHighContainer);
689  if (!SiTIDHighContainer.isValid()) {
690  edm::LogWarning("GlobalHitsProducer_fillTrk")
691  << "Unable to find TrackerHitsTIDHighTof in event!";
692  return;
693  }
694  // extract TEC low container
695  edm::Handle<edm::PSimHitContainer> SiTECLowContainer;
696  iEvent.getByLabel(SiTECLowSrc_,SiTECLowContainer);
697  if (!SiTECLowContainer.isValid()) {
698  edm::LogWarning(MsgLoggerCat)
699  << "Unable to find TrackerHitsTECLowTof in event!";
700  return;
701  }
702  // extract TEC high container
703  edm::Handle<edm::PSimHitContainer> SiTECHighContainer;
704  iEvent.getByLabel(SiTECHighSrc_,SiTECHighContainer);
705  if (!SiTECHighContainer.isValid()) {
706  edm::LogWarning(MsgLoggerCat)
707  << "Unable to find TrackerHitsTECHighTof in event!";
708  return;
709  }
710  // place all containers into new container
711  theSiFwdHits.insert(theSiFwdHits.end(),SiTIDLowContainer->begin(),
712  SiTIDLowContainer->end());
713  theSiFwdHits.insert(theSiFwdHits.end(),SiTIDHighContainer->begin(),
714  SiTIDHighContainer->end());
715  theSiFwdHits.insert(theSiFwdHits.end(),SiTECLowContainer->begin(),
716  SiTECLowContainer->end());
717  theSiFwdHits.insert(theSiFwdHits.end(),SiTECHighContainer->begin(),
718  SiTECHighContainer->end());
719 
720  // cycle through container
721  i = 0; j = 0;
722  for (itHit = theSiFwdHits.begin(); itHit != theSiFwdHits.end(); ++itHit) {
723 
724  ++i;
725 
726  // create a DetId from the detUnitId
727  DetId theDetUnitId(itHit->detUnitId());
728  int detector = theDetUnitId.det();
729  int subdetector = theDetUnitId.subdetId();
730 
731  // check that expected detector is returned
732  if ((detector == dTrk) &&
733  ((subdetector == sdSiTID) ||
734  (subdetector == sdSiTEC))) {
735 
736  // get the GeomDetUnit from the geometry using theDetUnitID
737  const GeomDetUnit *theDet = theTracker.idToDetUnit(theDetUnitId);
738 
739  if (!theDet) {
740  edm::LogWarning(MsgLoggerCat)
741  << "Unable to get GeomDetUnit from SiFwdHits Hit " << i;
742  return;
743  }
744 
745  ++j;
746 
747  // get the Surface of the hit (knows how to go from local <-> global)
748  const BoundPlane& bSurface = theDet->surface();
749 
750  // gather necessary information
751  SiFwdToF.push_back(itHit->tof());
752  SiFwdZ.push_back(bSurface.toGlobal(itHit->localPosition()).z());
753  SiFwdPhi.push_back(bSurface.toGlobal(itHit->localPosition()).phi());
754  SiFwdEta.push_back(bSurface.toGlobal(itHit->localPosition()).eta());
755  } else {
756  edm::LogWarning(MsgLoggerCat)
757  << "SiFwd PSimHit " << i
758  << " is expected to be (det,subdet) = ("
759  << dTrk << "," << sdSiTOB
760  << " || " << sdSiTEC << "); value returned is: ("
761  << detector << "," << subdetector << ")";
762  continue;
763  } // end check detector type
764  } // end loop through SiFwd Hits
765 
766  if (verbosity > 1) {
767  eventout += "\n Number of Silicon Forward Hits collected:.. ";
768  eventout += j;
769  }
770 
771  if (verbosity > 0)
772  edm::LogInfo(MsgLoggerCat) << eventout << "\n";
773 
774  return;
775 }
776 
778 {
779  std::string MsgLoggerCat = "GlobalHitsProducer_storeTrk";
780 
781  if (verbosity > 2) {
782  TString eventout("\n nPxlBrlHits = ");
783  eventout += PxlBrlToF.size();
784  for (unsigned int i = 0; i < PxlBrlToF.size(); ++i) {
785  eventout += "\n (tof,r,phi,eta) = (";
786  eventout += PxlBrlToF[i];
787  eventout += ", ";
788  eventout += PxlBrlR[i];
789  eventout += ", ";
790  eventout += PxlBrlPhi[i];
791  eventout += ", ";
792  eventout += PxlBrlEta[i];
793  eventout += ")";
794  } // end PxlBrl output
795  eventout += "\n nPxlFwdHits = ";
796  eventout += PxlFwdToF.size();
797  for (unsigned int i = 0; i < PxlFwdToF.size(); ++i) {
798  eventout += "\n (tof,z,phi,eta) = (";
799  eventout += PxlFwdToF[i];
800  eventout += ", ";
801  eventout += PxlFwdZ[i];
802  eventout += ", ";
803  eventout += PxlFwdPhi[i];
804  eventout += ", ";
805  eventout += PxlFwdEta[i];
806  eventout += ")";
807  } // end PxlFwd output
808  eventout += "\n nSiBrlHits = ";
809  eventout += SiBrlToF.size();
810  for (unsigned int i = 0; i < SiBrlToF.size(); ++i) {
811  eventout += "\n (tof,r,phi,eta) = (";
812  eventout += SiBrlToF[i];
813  eventout += ", ";
814  eventout += SiBrlR[i];
815  eventout += ", ";
816  eventout += SiBrlPhi[i];
817  eventout += ", ";
818  eventout += SiBrlEta[i];
819  eventout += ")";
820  } // end SiBrl output
821  eventout += "\n nSiFwdHits = ";
822  eventout += SiFwdToF.size();
823  for (unsigned int i = 0; i < SiFwdToF.size(); ++i) {
824  eventout += "\n (tof,z,phi,eta) = (";
825  eventout += SiFwdToF[i];
826  eventout += ", ";
827  eventout += SiFwdZ[i];
828  eventout += ", ";
829  eventout += SiFwdPhi[i];
830  eventout += ", ";
831  eventout += SiFwdEta[i];
832  eventout += ")";
833  } // end SiFwd output
834  edm::LogInfo(MsgLoggerCat) << eventout << "\n";
835  } // end verbose output
836 
841 
842  return;
843 }
844 
846  const edm::EventSetup& iSetup)
847 {
848  std::string MsgLoggerCat = "GlobalHitsProducer_fillMuon";
849 
850  TString eventout;
851  if (verbosity > 0)
852  eventout = "\nGathering info:";
853 
854  // iterator to access containers
855  edm::PSimHitContainer::const_iterator itHit;
856 
857  //int i = 0, j = 0;
859  // access the CSC Muon
861  // access the CSC Muon geometry
862  edm::ESHandle<CSCGeometry> theCSCGeometry;
863  iSetup.get<MuonGeometryRecord>().get(theCSCGeometry);
864  if (!theCSCGeometry.isValid()) {
865  edm::LogWarning(MsgLoggerCat)
866  << "Unable to find MuonGeometryRecord for the CSCGeometry in event!";
867  return;
868  }
869  const CSCGeometry& theCSCMuon(*theCSCGeometry);
870 
871  // get Muon CSC information
872  edm::Handle<edm::PSimHitContainer> MuonCSCContainer;
873  iEvent.getByLabel(MuonCscSrc_,MuonCSCContainer);
874  if (!MuonCSCContainer.isValid()) {
875  edm::LogWarning(MsgLoggerCat)
876  << "Unable to find MuonCSCHits in event!";
877  return;
878  }
879 
880  // cycle through container
881  int i = 0, j = 0;
882  for (itHit = MuonCSCContainer->begin(); itHit != MuonCSCContainer->end();
883  ++itHit) {
884 
885  ++i;
886 
887  // create a DetId from the detUnitId
888  DetId theDetUnitId(itHit->detUnitId());
889  int detector = theDetUnitId.det();
890  int subdetector = theDetUnitId.subdetId();
891 
892  // check that expected detector is returned
893  if ((detector == dMuon) &&
894  (subdetector == sdMuonCSC)) {
895 
896  // get the GeomDetUnit from the geometry using theDetUnitID
897  const GeomDetUnit *theDet = theCSCMuon.idToDetUnit(theDetUnitId);
898 
899  if (!theDet) {
900  edm::LogWarning(MsgLoggerCat)
901  << "Unable to get GeomDetUnit from theCSCMuon for hit " << i;
902  continue;
903  }
904 
905  ++j;
906 
907  // get the Surface of the hit (knows how to go from local <-> global)
908  const BoundPlane& bSurface = theDet->surface();
909 
910  // gather necessary information
911  MuonCscToF.push_back(itHit->tof());
912  MuonCscZ.push_back(bSurface.toGlobal(itHit->localPosition()).z());
913  MuonCscPhi.push_back(bSurface.toGlobal(itHit->localPosition()).phi());
914  MuonCscEta.push_back(bSurface.toGlobal(itHit->localPosition()).eta());
915  } else {
916  edm::LogWarning(MsgLoggerCat)
917  << "MuonCsc PSimHit " << i
918  << " is expected to be (det,subdet) = ("
919  << dMuon << "," << sdMuonCSC
920  << "); value returned is: ("
921  << detector << "," << subdetector << ")";
922  continue;
923  } // end detector type check
924  } // end loop through CSC Hits
925 
926  if (verbosity > 1) {
927  eventout += "\n Number of CSC muon Hits collected:......... ";
928  eventout += j;
929  }
930 
931  //i = 0, j = 0;
933  // access the DT Muon
935  // access the DT Muon geometry
936  edm::ESHandle<DTGeometry> theDTGeometry;
937  iSetup.get<MuonGeometryRecord>().get(theDTGeometry);
938  if (!theDTGeometry.isValid()) {
939  edm::LogWarning(MsgLoggerCat)
940  << "Unable to find MuonGeometryRecord for the DTGeometry in event!";
941  return;
942  }
943  const DTGeometry& theDTMuon(*theDTGeometry);
944 
945  // get Muon DT information
946  edm::Handle<edm::PSimHitContainer> MuonDtContainer;
947  iEvent.getByLabel(MuonDtSrc_,MuonDtContainer);
948  if (!MuonDtContainer.isValid()) {
949  edm::LogWarning(MsgLoggerCat)
950  << "Unable to find MuonDTHits in event!";
951  return;
952  }
953 
954  // cycle through container
955  i = 0, j = 0;
956  for (itHit = MuonDtContainer->begin(); itHit != MuonDtContainer->end();
957  ++itHit) {
958 
959  ++i;
960 
961  // create a DetId from the detUnitId
962  DetId theDetUnitId(itHit->detUnitId());
963  int detector = theDetUnitId.det();
964  int subdetector = theDetUnitId.subdetId();
965 
966  // check that expected detector is returned
967  if ((detector == dMuon) &&
968  (subdetector == sdMuonDT)) {
969 
970  // CSC uses wires and layers rather than the full detID
971  // get the wireId
972  DTWireId wireId(itHit->detUnitId());
973 
974  // get the DTLayer from the geometry using the wireID
975  const DTLayer *theDet = theDTMuon.layer(wireId.layerId());
976 
977  if (!theDet) {
978  edm::LogWarning(MsgLoggerCat)
979  << "Unable to get GeomDetUnit from theDtMuon for hit " << i;
980  continue;
981  }
982 
983  ++j;
984 
985  // get the Surface of the hit (knows how to go from local <-> global)
986  const BoundPlane& bSurface = theDet->surface();
987 
988  // gather necessary information
989  MuonDtToF.push_back(itHit->tof());
990  MuonDtR.push_back(bSurface.toGlobal(itHit->localPosition()).perp());
991  MuonDtPhi.push_back(bSurface.toGlobal(itHit->localPosition()).phi());
992  MuonDtEta.push_back(bSurface.toGlobal(itHit->localPosition()).eta());
993  } else {
994  edm::LogWarning(MsgLoggerCat)
995  << "MuonDt PSimHit " << i
996  << " is expected to be (det,subdet) = ("
997  << dMuon << "," << sdMuonDT
998  << "); value returned is: ("
999  << detector << "," << subdetector << ")";
1000  continue;
1001  } // end detector type check
1002  } // end loop through DT Hits
1003 
1004  if (verbosity > 1) {
1005  eventout += "\n Number of DT muon Hits collected:.......... ";
1006  eventout += j;
1007  }
1008 
1009  //i = 0, j = 0;
1010  //int RPCBrl = 0, RPCFwd = 0;
1012  // access the RPC Muon
1014  // access the RPC Muon geometry
1015  edm::ESHandle<RPCGeometry> theRPCGeometry;
1016  iSetup.get<MuonGeometryRecord>().get(theRPCGeometry);
1017  if (!theRPCGeometry.isValid()) {
1018  edm::LogWarning(MsgLoggerCat)
1019  << "Unable to find MuonGeometryRecord for the RPCGeometry in event!";
1020  return;
1021  }
1022  const RPCGeometry& theRPCMuon(*theRPCGeometry);
1023 
1024  // get Muon RPC information
1025  edm::Handle<edm::PSimHitContainer> MuonRPCContainer;
1026  iEvent.getByLabel(MuonRpcSrc_,MuonRPCContainer);
1027  if (!MuonRPCContainer.isValid()) {
1028  edm::LogWarning(MsgLoggerCat)
1029  << "Unable to find MuonRPCHits in event!";
1030  return;
1031  }
1032 
1033  // cycle through container
1034  i = 0, j = 0;
1035  int RPCBrl =0, RPCFwd = 0;
1036  for (itHit = MuonRPCContainer->begin(); itHit != MuonRPCContainer->end();
1037  ++itHit) {
1038 
1039  ++i;
1040 
1041  // create a DetID from the detUnitId
1042  DetId theDetUnitId(itHit->detUnitId());
1043  int detector = theDetUnitId.det();
1044  int subdetector = theDetUnitId.subdetId();
1045 
1046  // check that expected detector is returned
1047  if ((detector == dMuon) &&
1048  (subdetector == sdMuonRPC)) {
1049 
1050  // get an RPCDetID from the detUnitID
1051  RPCDetId RPCId(itHit->detUnitId());
1052 
1053  // find the region of the RPC hit
1054  int region = RPCId.region();
1055 
1056  // get the GeomDetUnit from the geometry using the RPCDetId
1057  const GeomDetUnit *theDet = theRPCMuon.idToDetUnit(theDetUnitId);
1058 
1059  if (!theDet) {
1060  edm::LogWarning(MsgLoggerCat)
1061  << "Unable to get GeomDetUnit from theRPCMuon for hit " << i;
1062  continue;
1063  }
1064 
1065  ++j;
1066 
1067  // get the Surface of the hit (knows how to go from local <-> global)
1068  const BoundPlane& bSurface = theDet->surface();
1069 
1070  // gather necessary information
1071  if ((region == sdMuonRPCRgnFwdp) || (region == sdMuonRPCRgnFwdn)) {
1072  ++RPCFwd;
1073 
1074  MuonRpcFwdToF.push_back(itHit->tof());
1075  MuonRpcFwdZ.push_back(bSurface.toGlobal(itHit->localPosition()).z());
1076  MuonRpcFwdPhi.
1077  push_back(bSurface.toGlobal(itHit->localPosition()).phi());
1078  MuonRpcFwdEta.
1079  push_back(bSurface.toGlobal(itHit->localPosition()).eta());
1080  } else if (region == sdMuonRPCRgnBrl) {
1081  ++RPCBrl;
1082 
1083  MuonRpcBrlToF.push_back(itHit->tof());
1084  MuonRpcBrlR.
1085  push_back(bSurface.toGlobal(itHit->localPosition()).perp());
1086  MuonRpcBrlPhi.
1087  push_back(bSurface.toGlobal(itHit->localPosition()).phi());
1088  MuonRpcBrlEta.
1089  push_back(bSurface.toGlobal(itHit->localPosition()).eta());
1090  } else {
1091  edm::LogWarning(MsgLoggerCat)
1092  << "Invalid region for RPC Muon hit" << i;
1093  continue;
1094  } // end check of region
1095  } else {
1096  edm::LogWarning(MsgLoggerCat)
1097  << "MuonRpc PSimHit " << i
1098  << " is expected to be (det,subdet) = ("
1099  << dMuon << "," << sdMuonRPC
1100  << "); value returned is: ("
1101  << detector << "," << subdetector << ")";
1102  continue;
1103  } // end detector type check
1104  } // end loop through RPC Hits
1105 
1106  if (verbosity > 1) {
1107  eventout += "\n Number of RPC muon Hits collected:......... ";
1108  eventout += j;
1109  eventout += "\n RPC Barrel muon Hits:............ ";
1110  eventout += RPCBrl;
1111  eventout += "\n RPC Forward muon Hits:........... ";
1112  eventout += RPCFwd;
1113  }
1114 
1115  if (verbosity > 0)
1116  edm::LogInfo(MsgLoggerCat) << eventout << "\n";
1117 
1118  return;
1119 }
1120 
1122 {
1123  std::string MsgLoggerCat = "GlobalHitsProducer_storeMuon";
1124 
1125  if (verbosity > 2) {
1126  TString eventout("\n nMuonCSCHits = ");
1127  eventout += MuonCscToF.size();
1128  for (unsigned int i = 0; i < MuonCscToF.size(); ++i) {
1129  eventout += "\n (tof,z,phi,eta) = (";
1130  eventout += MuonCscToF[i];
1131  eventout += ", ";
1132  eventout += MuonCscZ[i];
1133  eventout += ", ";
1134  eventout += MuonCscPhi[i];
1135  eventout += ", ";
1136  eventout += MuonCscEta[i];
1137  eventout += ")";
1138  } // end MuonCsc output
1139  eventout += "\n nMuonDtHits = ";
1140  eventout += MuonDtToF.size();
1141  for (unsigned int i = 0; i < MuonDtToF.size(); ++i) {
1142  eventout += "\n (tof,r,phi,eta) = (";
1143  eventout += MuonDtToF[i];
1144  eventout += ", ";
1145  eventout += MuonDtR[i];
1146  eventout += ", ";
1147  eventout += MuonDtPhi[i];
1148  eventout += ", ";
1149  eventout += MuonDtEta[i];
1150  eventout += ")";
1151  } // end MuonDt output
1152  eventout += "\n nMuonRpcBrlHits = ";
1153  eventout += MuonRpcBrlToF.size();
1154  for (unsigned int i = 0; i < MuonRpcBrlToF.size(); ++i) {
1155  eventout += "\n (tof,r,phi,eta) = (";
1156  eventout += MuonRpcBrlToF[i];
1157  eventout += ", ";
1158  eventout += MuonRpcBrlR[i];
1159  eventout += ", ";
1160  eventout += MuonRpcBrlPhi[i];
1161  eventout += ", ";
1162  eventout += MuonRpcBrlEta[i];
1163  eventout += ")";
1164  } // end MuonRpcBrl output
1165  eventout += "\n nMuonRpcFwdHits = ";
1166  eventout += MuonRpcFwdToF.size();
1167  for (unsigned int i = 0; i < MuonRpcFwdToF.size(); ++i) {
1168  eventout += "\n (tof,z,phi,eta) = (";
1169  eventout += MuonRpcFwdToF[i];
1170  eventout += ", ";
1171  eventout += MuonRpcFwdZ[i];
1172  eventout += ", ";
1173  eventout += MuonRpcFwdPhi[i];
1174  eventout += ", ";
1175  eventout += MuonRpcFwdEta[i];
1176  eventout += ")";
1177  } // end MuonRpcFwd output
1178  edm::LogInfo(MsgLoggerCat) << eventout << "\n";
1179  } // end verbose output
1180 
1184  MuonRpcBrlEta);
1186  MuonRpcFwdEta);
1187 
1188  return;
1189 }
1190 
1192  const edm::EventSetup& iSetup)
1193 {
1194  std::string MsgLoggerCat = "GlobalHitsProducer_fillECal";
1195 
1196  TString eventout;
1197  if (verbosity > 0)
1198  eventout = "\nGathering info:";
1199 
1200  // access the calorimeter geometry
1201  edm::ESHandle<CaloGeometry> theCaloGeometry;
1202  iSetup.get<CaloGeometryRecord>().get(theCaloGeometry);
1203  if (!theCaloGeometry.isValid()) {
1204  edm::LogWarning(MsgLoggerCat)
1205  << "Unable to find CaloGeometryRecord in event!";
1206  return;
1207  }
1208  const CaloGeometry& theCalo(*theCaloGeometry);
1209 
1210  // iterator to access containers
1211  edm::PCaloHitContainer::const_iterator itHit;
1212 
1214  // get ECal information
1216  edm::PCaloHitContainer theECalHits;
1217  // extract EB container
1219  iEvent.getByLabel(ECalEBSrc_,EBContainer);
1220  if (!EBContainer.isValid()) {
1221  edm::LogWarning(MsgLoggerCat)
1222  << "Unable to find EcalHitsEB in event!";
1223  return;
1224  }
1225  // extract EE container
1227  iEvent.getByLabel(ECalEESrc_,EEContainer);
1228  if (!EEContainer.isValid()) {
1229  edm::LogWarning(MsgLoggerCat)
1230  << "Unable to find EcalHitsEE in event!";
1231  return;
1232  }
1233  // place both containers into new container
1234  theECalHits.insert(theECalHits.end(),EBContainer->begin(),
1235  EBContainer->end());
1236  theECalHits.insert(theECalHits.end(),EEContainer->begin(),
1237  EEContainer->end());
1238 
1239  // cycle through new container
1240  int i = 0, j = 0;
1241  for (itHit = theECalHits.begin(); itHit != theECalHits.end(); ++itHit) {
1242 
1243  ++i;
1244 
1245  // create a DetId from the detUnitId
1246  DetId theDetUnitId(itHit->id());
1247  int detector = theDetUnitId.det();
1248  int subdetector = theDetUnitId.subdetId();
1249 
1250  // check that expected detector is returned
1251  if ((detector == dEcal) &&
1252  ((subdetector == sdEcalBrl) ||
1253  (subdetector == sdEcalFwd))) {
1254 
1255  // get the Cell geometry
1256  const CaloCellGeometry *theDet = theCalo.
1257  getSubdetectorGeometry(theDetUnitId)->getGeometry(theDetUnitId);
1258 
1259  if (!theDet) {
1260  edm::LogWarning(MsgLoggerCat)
1261  << "Unable to get CaloCellGeometry from ECalHits for Hit " << i;
1262  continue;
1263  }
1264 
1265  ++j;
1266 
1267  // get the global position of the cell
1268  const GlobalPoint& globalposition = theDet->getPosition();
1269 
1270  // gather necessary information
1271  ECalE.push_back(itHit->energy());
1272  ECalToF.push_back(itHit->time());
1273  ECalPhi.push_back(globalposition.phi());
1274  ECalEta.push_back(globalposition.eta());
1275 
1276  } else {
1277  edm::LogWarning(MsgLoggerCat)
1278  << "ECal PCaloHit " << i
1279  << " is expected to be (det,subdet) = ("
1280  << dEcal << "," << sdEcalBrl
1281  << " || " << sdEcalFwd << "); value returned is: ("
1282  << detector << "," << subdetector << ")";
1283  continue;
1284  } // end detector type check
1285  } // end loop through ECal Hits
1286 
1287  if (verbosity > 1) {
1288  eventout += "\n Number of ECal Hits collected:............. ";
1289  eventout += j;
1290  }
1291 
1293  // Get Preshower information
1295  // extract PreShower container
1296  edm::Handle<edm::PCaloHitContainer> PreShContainer;
1297  iEvent.getByLabel(ECalESSrc_,PreShContainer);
1298  if (!PreShContainer.isValid()) {
1299  edm::LogWarning(MsgLoggerCat)
1300  << "Unable to find EcalHitsES in event!";
1301  return;
1302  }
1303 
1304  // cycle through container
1305  i = 0, j = 0;
1306  for (itHit = PreShContainer->begin();
1307  itHit != PreShContainer->end(); ++itHit) {
1308 
1309  ++i;
1310 
1311  // create a DetId from the detUnitId
1312  DetId theDetUnitId(itHit->id());
1313  int detector = theDetUnitId.det();
1314  int subdetector = theDetUnitId.subdetId();
1315 
1316  // check that expected detector is returned
1317  if ((detector == dEcal) &&
1318  (subdetector == sdEcalPS)) {
1319 
1320  // get the Cell geometry
1321  const CaloCellGeometry *theDet = theCalo.
1322  getSubdetectorGeometry(theDetUnitId)->getGeometry(theDetUnitId);
1323 
1324  if (!theDet) {
1325  edm::LogWarning(MsgLoggerCat)
1326  << "Unable to get CaloCellGeometry from PreShContainer for Hit "
1327  << i;
1328  continue;
1329  }
1330 
1331  ++j;
1332 
1333  // get the global position of the cell
1334  const GlobalPoint& globalposition = theDet->getPosition();
1335 
1336  // gather necessary information
1337  PreShE.push_back(itHit->energy());
1338  PreShToF.push_back(itHit->time());
1339  PreShPhi.push_back(globalposition.phi());
1340  PreShEta.push_back(globalposition.eta());
1341 
1342  } else {
1343  edm::LogWarning(MsgLoggerCat)
1344  << "PreSh PCaloHit " << i
1345  << " is expected to be (det,subdet) = ("
1346  << dEcal << "," << sdEcalPS
1347  << "); value returned is: ("
1348  << detector << "," << subdetector << ")";
1349  continue;
1350  } // end detector type check
1351  } // end loop through PreShower Hits
1352 
1353  if (verbosity > 1) {
1354  eventout += "\n Number of PreSh Hits collected:............ ";
1355  eventout += j;
1356  }
1357 
1358  if (verbosity > 0)
1359  edm::LogInfo(MsgLoggerCat) << eventout << "\n";
1360 
1361  return;
1362 }
1363 
1365 {
1366  std::string MsgLoggerCat = "GlobalHitsProducer_storeECal";
1367 
1368  if (verbosity > 2) {
1369  TString eventout("\n nECalHits = ");
1370  eventout += ECalE.size();
1371  for (unsigned int i = 0; i < ECalE.size(); ++i) {
1372  eventout += "\n (e,tof,phi,eta) = (";
1373  eventout += ECalE[i];
1374  eventout += ", ";
1375  eventout += ECalToF[i];
1376  eventout += ", ";
1377  eventout += ECalPhi[i];
1378  eventout += ", ";
1379  eventout += ECalEta[i];
1380  eventout += ")";
1381  } // end ECal output
1382  eventout += "\n nPreShHits = ";
1383  eventout += PreShE.size();
1384  for (unsigned int i = 0; i < PreShE.size(); ++i) {
1385  eventout += "\n (e,tof,phi,eta) = (";
1386  eventout += PreShE[i];
1387  eventout += ", ";
1388  eventout += PreShToF[i];
1389  eventout += ", ";
1390  eventout += PreShPhi[i];
1391  eventout += ", ";
1392  eventout += PreShEta[i];
1393  eventout += ")";
1394  } // end PreShower output
1395  edm::LogInfo(MsgLoggerCat) << eventout << "\n";
1396  } // end verbose output
1397 
1400 
1401  return;
1402 }
1403 
1405  const edm::EventSetup& iSetup)
1406 {
1407  std::string MsgLoggerCat = "GlobalHitsProducer_fillHCal";
1408 
1409  TString eventout;
1410  if (verbosity > 0)
1411  eventout = "\nGathering info:";
1412 
1413  // access the calorimeter geometry
1414  edm::ESHandle<CaloGeometry> theCaloGeometry;
1415  iSetup.get<CaloGeometryRecord>().get(theCaloGeometry);
1416  if (!theCaloGeometry.isValid()) {
1417  edm::LogWarning(MsgLoggerCat)
1418  << "Unable to find CaloGeometryRecord in event!";
1419  return;
1420  }
1421  const CaloGeometry& theCalo(*theCaloGeometry);
1422 
1423  // iterator to access containers
1424  edm::PCaloHitContainer::const_iterator itHit;
1425 
1427  // get HCal information
1429  // extract HCal container
1431  iEvent.getByLabel(HCalSrc_,HCalContainer);
1432  if (!HCalContainer.isValid()) {
1433  edm::LogWarning(MsgLoggerCat)
1434  << "Unable to find HCalHits in event!";
1435  return;
1436  }
1437 
1438  // cycle through container
1439  int i = 0, j = 0;
1440  for (itHit = HCalContainer->begin();
1441  itHit != HCalContainer->end(); ++itHit) {
1442 
1443  ++i;
1444 
1445  // create a DetId from the detUnitId
1446  DetId theDetUnitId(itHit->id());
1447  int detector = theDetUnitId.det();
1448  int subdetector = theDetUnitId.subdetId();
1449 
1450  // check that expected detector is returned
1451  if ((detector == dHcal) &&
1452  ((subdetector == sdHcalBrl) ||
1453  (subdetector == sdHcalEC) ||
1454  (subdetector == sdHcalOut) ||
1455  (subdetector == sdHcalFwd))) {
1456 
1457  // get the Cell geometry
1458  const CaloCellGeometry *theDet = theCalo.
1459  getSubdetectorGeometry(theDetUnitId)->getGeometry(theDetUnitId);
1460 
1461  if (!theDet) {
1462  edm::LogWarning(MsgLoggerCat)
1463  << "Unable to get CaloCellGeometry from HCalContainer for Hit " << i;
1464  continue;
1465  }
1466 
1467  ++j;
1468 
1469  // get the global position of the cell
1470  const GlobalPoint& globalposition = theDet->getPosition();
1471 
1472  // gather necessary information
1473  HCalE.push_back(itHit->energy());
1474  HCalToF.push_back(itHit->time());
1475  HCalPhi.push_back(globalposition.phi());
1476  HCalEta.push_back(globalposition.eta());
1477 
1478  } else {
1479  edm::LogWarning(MsgLoggerCat)
1480  << "HCal PCaloHit " << i
1481  << " is expected to be (det,subdet) = ("
1482  << dHcal << "," << sdHcalBrl
1483  << " || " << sdHcalEC << " || " << sdHcalOut << " || " << sdHcalFwd
1484  << "); value returned is: ("
1485  << detector << "," << subdetector << ")";
1486  continue;
1487  } // end detector type check
1488  } // end loop through HCal Hits
1489 
1490  if (verbosity > 1) {
1491  eventout += "\n Number of HCal Hits collected:............. ";
1492  eventout += j;
1493  }
1494 
1495  if (verbosity > 0)
1496  edm::LogInfo(MsgLoggerCat) << eventout << "\n";
1497 
1498  return;
1499 }
1500 
1502 {
1503  std::string MsgLoggerCat = "GlobalHitsProducer_storeHCal";
1504 
1505  if (verbosity > 2) {
1506  TString eventout("\n nHCalHits = ");
1507  eventout += HCalE.size();
1508  for (unsigned int i = 0; i < HCalE.size(); ++i) {
1509  eventout += "\n (e,tof,phi,eta) = (";
1510  eventout += HCalE[i];
1511  eventout += ", ";
1512  eventout += HCalToF[i];
1513  eventout += ", ";
1514  eventout += HCalPhi[i];
1515  eventout += ", ";
1516  eventout += HCalEta[i];
1517  eventout += ")";
1518  } // end HCal output
1519  edm::LogInfo(MsgLoggerCat) << eventout << "\n";
1520  } // end verbose output
1521 
1523 
1524  return;
1525 }
1526 
1528 {
1529  std::string MsgLoggerCat = "GlobalHitsProducer_clear";
1530 
1531  if (verbosity > 0)
1532  edm::LogInfo(MsgLoggerCat)
1533  << "Clearing event holders";
1534 
1535  // reset G4MC info
1536  nRawGenPart = 0;
1537  G4VtxX.clear();
1538  G4VtxY.clear();
1539  G4VtxZ.clear();
1540  G4TrkPt.clear();
1541  G4TrkE.clear();
1542 
1543  // reset electromagnetic info
1544  // reset ECal info
1545  ECalE.clear();
1546  ECalToF.clear();
1547  ECalPhi.clear();
1548  ECalEta.clear();
1549  // reset Preshower info
1550  PreShE.clear();
1551  PreShToF.clear();
1552  PreShPhi.clear();
1553  PreShEta.clear();
1554 
1555  // reset hadronic info
1556  // reset HCal info
1557  HCalE.clear();
1558  HCalToF.clear();
1559  HCalPhi.clear();
1560  HCalEta.clear();
1561 
1562  // reset tracker info
1563  // reset Pixel info
1564  PxlBrlToF.clear();
1565  PxlBrlR.clear();
1566  PxlBrlPhi.clear();
1567  PxlBrlEta.clear();
1568  PxlFwdToF.clear();
1569  PxlFwdZ.clear();
1570  PxlFwdPhi.clear();
1571  PxlFwdEta.clear();
1572  // reset strip info
1573  SiBrlToF.clear();
1574  SiBrlR.clear();
1575  SiBrlPhi.clear();
1576  SiBrlEta.clear();
1577  SiFwdToF.clear();
1578  SiFwdZ.clear();
1579  SiFwdPhi.clear();
1580  SiFwdEta.clear();
1581 
1582  // reset muon info
1583  // reset muon DT info
1584  MuonDtToF.clear();
1585  MuonDtR.clear();
1586  MuonDtPhi.clear();
1587  MuonDtEta.clear();
1588  // reset muon CSC info
1589  MuonCscToF.clear();
1590  MuonCscZ.clear();
1591  MuonCscPhi.clear();
1592  MuonCscEta.clear();
1593  // rest muon RPC info
1594  MuonRpcBrlToF.clear();
1595  MuonRpcBrlR.clear();
1596  MuonRpcBrlPhi.clear();
1597  MuonRpcBrlEta.clear();
1598  MuonRpcFwdToF.clear();
1599  MuonRpcFwdZ.clear();
1600  MuonRpcFwdPhi.clear();
1601  MuonRpcFwdEta.clear();
1602 
1603  return;
1604 }
edm::InputTag ECalESSrc_
RunNumber_t run() const
Definition: EventID.h:42
void storeECal(PGlobalSimHit &)
void getManyByType(std::vector< Handle< PROD > > &results) const
Definition: Event.h:407
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:71
int i
Definition: DBlmapReader.cc:9
static const int dEcal
static const int dTrk
std::vector< PCaloHit > PCaloHitContainer
void putG4Vtx(std::vector< float > x, std::vector< float > y, std::vector< float > z)
static const int sdMuonRPCRgnFwdn
const std::string & label
Definition: MVAComputer.cc:186
static const int sdHcalOut
edm::InputTag ECalEESrc_
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
edm::InputTag MuonCscSrc_
void putSiFwdHits(std::vector< float > tof, std::vector< float > z, std::vector< float > phi, std::vector< float > eta)
edm::InputTag MuonDtSrc_
static const int sdSiTID
Geom::Phi< T > phi() const
Definition: PV3DBase.h:63
edm::InputTag SiTOBHighSrc_
edm::InputTag PxlBrlHighSrc_
edm::InputTag PxlBrlLowSrc_
static const int sdEcalPS
bool getByType(Handle< PROD > &result) const
Definition: Event.h:397
void storeMuon(PGlobalSimHit &)
edm::InputTag PxlFwdLowSrc_
static const int sdMuonRPC
void putECalHits(std::vector< float > e, std::vector< float > tof, std::vector< float > phi, std::vector< float > eta)
void storeG4MC(PGlobalSimHit &)
T eta() const
edm::InputTag SiTIDLowSrc_
void storeTrk(PGlobalSimHit &)
double double double z
virtual void produce(edm::Event &, const edm::EventSetup &)
void putMuonDtHits(std::vector< float > tof, std::vector< float > r, std::vector< float > phi, std::vector< float > eta)
const DTLayer * layer(DTLayerId id) const
Return a layer given its id.
Definition: DTGeometry.cc:115
edm::InputTag SiTECHighSrc_
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:30
edm::InputTag ECalEBSrc_
void fillMuon(edm::Event &, const edm::EventSetup &)
void putMuonRpcBrlHits(std::vector< float > tof, std::vector< float > r, std::vector< float > phi, std::vector< float > eta)
int iEvent
Definition: GenABIO.cc:243
GlobalHitsProducer(const edm::ParameterSet &)
static const int sdSiTIB
static const int sdPxlBrl
virtual const GeomDetUnit * idToDetUnit(DetId) const
Return the pointer to the GeomDetUnit corresponding to a given DetId.
Definition: CSCGeometry.cc:87
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
string unit
Definition: csvLumiCalc.py:46
T sqrt(T t)
Definition: SSEVec.h:28
static const int sdMuonCSC
static const int sdEcalFwd
void fillTrk(edm::Event &, const edm::EventSetup &)
void putPxlBrlHits(std::vector< float > tof, std::vector< float > r, std::vector< float > phi, std::vector< float > eta)
int j
Definition: DBlmapReader.cc:9
edm::InputTag SiTIBLowSrc_
edm::InputTag SiTECLowSrc_
static const int sdSiTOB
static const int sdEcalBrl
BranchDescription const & product() const
Definition: Provenance.h:44
static const int sdMuonRPCRgnFwdp
static const int sdMuonRPCRgnBrl
void putMuonCscHits(std::vector< float > tof, std::vector< float > z, std::vector< float > phi, std::vector< float > eta)
bool isValid() const
Definition: HandleBase.h:76
edm::InputTag SiTIDHighSrc_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:355
edm::InputTag PxlFwdHighSrc_
const int verbosity
void putPreShHits(std::vector< float > e, std::vector< float > tof, std::vector< float > phi, std::vector< float > eta)
Definition: DetId.h:20
static const int dHcal
virtual void beginJob(void)
void fillECal(edm::Event &, const edm::EventSetup &)
void fillHCal(edm::Event &, const edm::EventSetup &)
const T & get() const
Definition: EventSetup.h:55
static const int sdHcalFwd
void putPxlFwdHits(std::vector< float > tof, std::vector< float > z, std::vector< float > phi, std::vector< float > eta)
static const int sdHcalBrl
void storeHCal(PGlobalSimHit &)
edm::InputTag SiTOBLowSrc_
std::string const & label() const
Definition: InputTag.h:25
void putHCalHits(std::vector< float > e, std::vector< float > tof, std::vector< float > phi, std::vector< float > eta)
T eta() const
Definition: PV3DBase.h:70
virtual const GeomDetUnit * idToDetUnit(DetId) const
Return the pointer to the GeomDetUnit corresponding to a given DetId.
void putG4Trk(std::vector< float > pt, std::vector< float > e)
edm::EventID id() const
Definition: EventBase.h:56
static const int sdSiTEC
T perp() const
Magnitude of transverse component.
static const int dMuon
const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id.
Definition: CaloGeometry.cc:76
void putRawGenPart(int n)
void fillG4MC(edm::Event &)
std::vector< PSimHit > PSimHitContainer
static const int sdPxlFwd
void putMuonRpcFwdHits(std::vector< float > tof, std::vector< float > z, std::vector< float > phi, std::vector< float > eta)
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
edm::InputTag SiTIBHighSrc_
void putSiBrlHits(std::vector< float > tof, std::vector< float > r, std::vector< float > phi, std::vector< float > eta)
std::string const & instance() const
Definition: InputTag.h:26
edm::InputTag MuonRpcSrc_
static const int sdHcalEC
virtual const BoundPlane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
Provenance const * provenance() const
Definition: HandleBase.h:84
const std::string * moduleLabel() const
Definition: HLTadd.h:40
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
Definition: RPCDetId.h:65
Definition: DDAxes.h:10