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