CMS 3D CMS Logo

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