CMS 3D CMS Logo

GlobalHitsProducer.cc
Go to the documentation of this file.
1 
11 
13  : fName(""),
14  verbosity(0),
15  frequency(0),
16  vtxunit(0),
17  label(""),
18  getAllProvenances(false),
19  printProvenanceInfo(false),
20  nRawGenPart(0),
21  G4VtxSrc_Token_(consumes<edm::SimVertexContainer>((iPSet.getParameter<edm::InputTag>("G4VtxSrc")))),
22  G4TrkSrc_Token_(consumes<edm::SimTrackContainer>(iPSet.getParameter<edm::InputTag>("G4TrkSrc"))),
23  // ECalEBSrc_(""), ECalEESrc_(""), ECalESSrc_(""), HCalSrc_(""),
24  // PxlBrlLowSrc_(""), PxlBrlHighSrc_(""), PxlFwdLowSrc_(""),
25  // PxlFwdHighSrc_(""), SiTIBLowSrc_(""), SiTIBHighSrc_(""),
26  // SiTOBLowSrc_(""), SiTOBHighSrc_(""), SiTIDLowSrc_(""),
27  // SiTIDHighSrc_(""), SiTECLowSrc_(""), SiTECHighSrc_(""),
28  // MuonDtSrc_(""), MuonCscSrc_(""), MuonRpcSrc_(""),
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  iEvent.getManyByType(AllHepMCEvt);
253 
254  // loop through products and extract VtxSmearing if available. Any of them
255  // should have the information needed
256  for (unsigned int i = 0; i < AllHepMCEvt.size(); ++i) {
257  HepMCEvt = AllHepMCEvt[i];
258  if ((HepMCEvt.provenance()->branchDescription()).moduleLabel() == "generatorSmeared")
259  break;
260  }
261 
262  if (!HepMCEvt.isValid()) {
263  edm::LogWarning(MsgLoggerCat) << "Unable to find HepMCProduct in event!";
264  return;
265  } else {
266  eventout += "\n Using HepMCProduct: ";
267  eventout += (HepMCEvt.provenance()->branchDescription()).moduleLabel();
268  }
269  const HepMC::GenEvent *MCEvt = HepMCEvt->GetEvent();
270  nRawGenPart = MCEvt->particles_size();
271 
272  if (verbosity > 1) {
273  eventout += "\n Number of Raw Particles collected:......... ";
274  eventout += nRawGenPart;
275  }
276 
278  // get G4Vertex information
280  // convert unit stored in SimVertex to mm
281  float unit = 0.;
282  if (vtxunit == 0)
283  unit = 1.; // already in mm
284  if (vtxunit == 1)
285  unit = 10.; // stored in cm, convert to mm
286 
288  iEvent.getByToken(G4VtxSrc_Token_, G4VtxContainer);
289  if (!G4VtxContainer.isValid()) {
290  edm::LogWarning(MsgLoggerCat) << "Unable to find SimVertex in event!";
291  return;
292  }
293  int i = 0;
294  edm::SimVertexContainer::const_iterator itVtx;
295  for (itVtx = G4VtxContainer->begin(); itVtx != G4VtxContainer->end(); ++itVtx) {
296  ++i;
297 
298  const math::XYZTLorentzVector G4Vtx1(
299  itVtx->position().x(), itVtx->position().y(), itVtx->position().z(), itVtx->position().e());
300  double G4Vtx[4];
301  G4Vtx1.GetCoordinates(G4Vtx);
302 
303  G4VtxX.push_back((G4Vtx[0] * unit) / micrometer);
304  G4VtxY.push_back((G4Vtx[1] * unit) / micrometer);
305  G4VtxZ.push_back((G4Vtx[2] * unit) / millimeter);
306  }
307 
308  if (verbosity > 1) {
309  eventout += "\n Number of G4Vertices collected:............ ";
310  eventout += i;
311  }
312 
314  // get G4Track information
317  iEvent.getByToken(G4TrkSrc_Token_, G4TrkContainer);
318 
319  if (!G4TrkContainer.isValid()) {
320  edm::LogWarning(MsgLoggerCat) << "Unable to find SimTrack in event!";
321  return;
322  }
323  i = 0;
324  edm::SimTrackContainer::const_iterator itTrk;
325  for (itTrk = G4TrkContainer->begin(); itTrk != G4TrkContainer->end(); ++itTrk) {
326  ++i;
327 
328  const math::XYZTLorentzVector G4Trk1(
329  itTrk->momentum().x(), itTrk->momentum().y(), itTrk->momentum().z(), itTrk->momentum().e());
330  double G4Trk[4];
331  G4Trk1.GetCoordinates(G4Trk);
332 
333  G4TrkPt.push_back(sqrt(G4Trk[0] * G4Trk[0] + G4Trk[1] * G4Trk[1])); // GeV
334  G4TrkE.push_back(G4Trk[3]); // GeV
335  }
336 
337  if (verbosity > 1) {
338  eventout += "\n Number of G4Tracks collected:.............. ";
339  eventout += i;
340  }
341 
342  if (verbosity > 0)
343  edm::LogInfo(MsgLoggerCat) << eventout << "\n";
344 
345  return;
346 }
347 
349  std::string MsgLoggerCat = "GlobalHitsProducer_storeG4MC";
350 
351  if (verbosity > 2) {
352  TString eventout("\n nRawGenPart = ");
353  eventout += nRawGenPart;
354  eventout += "\n nG4Vtx = ";
355  eventout += G4VtxX.size();
356  for (unsigned int i = 0; i < G4VtxX.size(); ++i) {
357  eventout += "\n (x,y,z) = (";
358  eventout += G4VtxX[i];
359  eventout += ", ";
360  eventout += G4VtxY[i];
361  eventout += ", ";
362  eventout += G4VtxZ[i];
363  eventout += ")";
364  }
365  eventout += "\n nG4Trk = ";
366  eventout += G4TrkPt.size();
367  for (unsigned int i = 0; i < G4TrkPt.size(); ++i) {
368  eventout += "\n (pt,e) = (";
369  eventout += G4TrkPt[i];
370  eventout += ", ";
371  eventout += G4TrkE[i];
372  eventout += ")";
373  }
374  edm::LogInfo(MsgLoggerCat) << eventout << "\n";
375  } // end verbose output
376 
377  product.putRawGenPart(nRawGenPart);
378  product.putG4Vtx(G4VtxX, G4VtxY, G4VtxZ);
379  product.putG4Trk(G4TrkPt, G4TrkE);
380 
381  return;
382 }
383 
385  std::string MsgLoggerCat = "GlobalHitsProducer_fillTrk";
386 
387  TString eventout;
388  if (verbosity > 0)
389  eventout = "\nGathering info:";
390 
391  // access the tracker geometry
392  edm::ESHandle<TrackerGeometry> theTrackerGeometry;
393  iSetup.get<TrackerDigiGeometryRecord>().get(theTrackerGeometry);
394  if (!theTrackerGeometry.isValid()) {
395  edm::LogWarning(MsgLoggerCat) << "Unable to find TrackerDigiGeometryRecord in event!";
396  return;
397  }
398  const TrackerGeometry &theTracker(*theTrackerGeometry);
399 
400  // iterator to access containers
401  edm::PSimHitContainer::const_iterator itHit;
402 
404  // get Pixel Barrel information
406  edm::PSimHitContainer thePxlBrlHits;
407  // extract low container
408  edm::Handle<edm::PSimHitContainer> PxlBrlLowContainer;
409  iEvent.getByToken(PxlBrlLowSrc_Token_, PxlBrlLowContainer);
410  if (!PxlBrlLowContainer.isValid()) {
411  edm::LogWarning(MsgLoggerCat) << "Unable to find TrackerHitsPixelBarrelLowTof in event!";
412  return;
413  }
414  // extract high container
415  edm::Handle<edm::PSimHitContainer> PxlBrlHighContainer;
416  iEvent.getByToken(PxlBrlHighSrc_Token_, PxlBrlHighContainer);
417  if (!PxlBrlHighContainer.isValid()) {
418  edm::LogWarning(MsgLoggerCat) << "Unable to find TrackerHitsPixelBarrelHighTof in event!";
419  return;
420  }
421  // place both containers into new container
422  thePxlBrlHits.insert(thePxlBrlHits.end(), PxlBrlLowContainer->begin(), PxlBrlLowContainer->end());
423  thePxlBrlHits.insert(thePxlBrlHits.end(), PxlBrlHighContainer->begin(), PxlBrlHighContainer->end());
424 
425  // cycle through new container
426  int i = 0, j = 0;
427  for (itHit = thePxlBrlHits.begin(); itHit != thePxlBrlHits.end(); ++itHit) {
428  ++i;
429 
430  // create a DetId from the detUnitId
431  DetId theDetUnitId(itHit->detUnitId());
432  int detector = theDetUnitId.det();
433  int subdetector = theDetUnitId.subdetId();
434 
435  // check that expected detector is returned
436  if ((detector == dTrk) && (subdetector == sdPxlBrl)) {
437  // get the GeomDetUnit from the geometry using theDetUnitID
438  const GeomDetUnit *theDet = theTracker.idToDetUnit(theDetUnitId);
439 
440  if (!theDet) {
441  edm::LogWarning(MsgLoggerCat) << "Unable to get GeomDetUnit from PxlBrlHits for Hit " << i;
442  continue;
443  }
444 
445  ++j;
446 
447  // get the Surface of the hit (knows how to go from local <-> global)
448  const BoundPlane &bSurface = theDet->surface();
449 
450  // gather necessary information
451  PxlBrlToF.push_back(itHit->tof());
452  PxlBrlR.push_back(bSurface.toGlobal(itHit->localPosition()).perp());
453  PxlBrlPhi.push_back(bSurface.toGlobal(itHit->localPosition()).phi());
454  PxlBrlEta.push_back(bSurface.toGlobal(itHit->localPosition()).eta());
455 
456  } else {
457  edm::LogWarning(MsgLoggerCat) << "PxlBrl PSimHit " << i << " is expected to be (det,subdet) = (" << dTrk << ","
458  << sdPxlBrl << "); value returned is: (" << detector << "," << subdetector << ")";
459  continue;
460  } // end detector type check
461  } // end loop through PxlBrl Hits
462 
463  if (verbosity > 1) {
464  eventout += "\n Number of Pixel Barrel Hits collected:..... ";
465  eventout += j;
466  }
467 
469  // get Pixel Forward information
471  edm::PSimHitContainer thePxlFwdHits;
472  // extract low container
473  edm::Handle<edm::PSimHitContainer> PxlFwdLowContainer;
474  iEvent.getByToken(PxlFwdLowSrc_Token_, PxlFwdLowContainer);
475  if (!PxlFwdLowContainer.isValid()) {
476  edm::LogWarning(MsgLoggerCat) << "Unable to find TrackerHitsPixelEndcapLowTof in event!";
477  return;
478  }
479  // extract high container
480  edm::Handle<edm::PSimHitContainer> PxlFwdHighContainer;
481  iEvent.getByToken(PxlFwdHighSrc_Token_, PxlFwdHighContainer);
482  if (!PxlFwdHighContainer.isValid()) {
483  edm::LogWarning("GlobalHitsProducer_fillTrk") << "Unable to find TrackerHitsPixelEndcapHighTof in event!";
484  return;
485  }
486  // place both containers into new container
487  thePxlFwdHits.insert(thePxlFwdHits.end(), PxlFwdLowContainer->begin(), PxlFwdLowContainer->end());
488  thePxlFwdHits.insert(thePxlFwdHits.end(), PxlFwdHighContainer->begin(), PxlFwdHighContainer->end());
489 
490  // cycle through new container
491  i = 0;
492  j = 0;
493  for (itHit = thePxlFwdHits.begin(); itHit != thePxlFwdHits.end(); ++itHit) {
494  ++i;
495 
496  // create a DetId from the detUnitId
497  DetId theDetUnitId(itHit->detUnitId());
498  int detector = theDetUnitId.det();
499  int subdetector = theDetUnitId.subdetId();
500 
501  // check that expected detector is returned
502  if ((detector == dTrk) && (subdetector == sdPxlFwd)) {
503  // get the GeomDetUnit from the geometry using theDetUnitID
504  const GeomDetUnit *theDet = theTracker.idToDetUnit(theDetUnitId);
505 
506  if (!theDet) {
507  edm::LogWarning(MsgLoggerCat) << "Unable to get GeomDetUnit from PxlFwdHits for Hit " << i;
508  ;
509  continue;
510  }
511 
512  ++j;
513 
514  // get the Surface of the hit (knows how to go from local <-> global)
515  const BoundPlane &bSurface = theDet->surface();
516 
517  // gather necessary information
518  PxlFwdToF.push_back(itHit->tof());
519  PxlFwdZ.push_back(bSurface.toGlobal(itHit->localPosition()).z());
520  PxlFwdPhi.push_back(bSurface.toGlobal(itHit->localPosition()).phi());
521  PxlFwdEta.push_back(bSurface.toGlobal(itHit->localPosition()).eta());
522  } else {
523  edm::LogWarning(MsgLoggerCat) << "PxlFwd PSimHit " << i << " is expected to be (det,subdet) = (" << dTrk << ","
524  << sdPxlFwd << "); value returned is: (" << detector << "," << subdetector << ")";
525  continue;
526  } // end detector type check
527  } // end loop through PxlFwd Hits
528 
529  if (verbosity > 1) {
530  eventout += "\n Number of Pixel Forward Hits collected:.... ";
531  eventout += j;
532  }
533 
535  // get Silicon Barrel information
537  edm::PSimHitContainer theSiBrlHits;
538  // extract TIB low container
539  edm::Handle<edm::PSimHitContainer> SiTIBLowContainer;
540  iEvent.getByToken(SiTIBLowSrc_Token_, SiTIBLowContainer);
541  if (!SiTIBLowContainer.isValid()) {
542  edm::LogWarning(MsgLoggerCat) << "Unable to find TrackerHitsTIBLowTof in event!";
543  return;
544  }
545  // extract TIB high container
546  edm::Handle<edm::PSimHitContainer> SiTIBHighContainer;
547  iEvent.getByToken(SiTIBHighSrc_Token_, SiTIBHighContainer);
548  if (!SiTIBHighContainer.isValid()) {
549  edm::LogWarning(MsgLoggerCat) << "Unable to find TrackerHitsTIBHighTof in event!";
550  return;
551  }
552  // extract TOB low container
553  edm::Handle<edm::PSimHitContainer> SiTOBLowContainer;
554  iEvent.getByToken(SiTOBLowSrc_Token_, SiTOBLowContainer);
555  if (!SiTOBLowContainer.isValid()) {
556  edm::LogWarning(MsgLoggerCat) << "Unable to find TrackerHitsTOBLowTof in event!";
557  return;
558  }
559  // extract TOB high container
560  edm::Handle<edm::PSimHitContainer> SiTOBHighContainer;
561  iEvent.getByToken(SiTOBHighSrc_Token_, SiTOBHighContainer);
562  if (!SiTOBHighContainer.isValid()) {
563  edm::LogWarning(MsgLoggerCat) << "Unable to find TrackerHitsTOBHighTof in event!";
564  return;
565  }
566  // place all containers into new container
567  theSiBrlHits.insert(theSiBrlHits.end(), SiTIBLowContainer->begin(), SiTIBLowContainer->end());
568  theSiBrlHits.insert(theSiBrlHits.end(), SiTIBHighContainer->begin(), SiTIBHighContainer->end());
569  theSiBrlHits.insert(theSiBrlHits.end(), SiTOBLowContainer->begin(), SiTOBLowContainer->end());
570  theSiBrlHits.insert(theSiBrlHits.end(), SiTOBHighContainer->begin(), SiTOBHighContainer->end());
571 
572  // cycle through new container
573  i = 0;
574  j = 0;
575  for (itHit = theSiBrlHits.begin(); itHit != theSiBrlHits.end(); ++itHit) {
576  ++i;
577 
578  // create a DetId from the detUnitId
579  DetId theDetUnitId(itHit->detUnitId());
580  int detector = theDetUnitId.det();
581  int subdetector = theDetUnitId.subdetId();
582 
583  // check that expected detector is returned
584  if ((detector == dTrk) && ((subdetector == sdSiTIB) || (subdetector == sdSiTOB))) {
585  // get the GeomDetUnit from the geometry using theDetUnitID
586  const GeomDetUnit *theDet = theTracker.idToDetUnit(theDetUnitId);
587 
588  if (!theDet) {
589  edm::LogWarning(MsgLoggerCat) << "Unable to get GeomDetUnit from SiBrlHits for Hit " << i;
590  continue;
591  }
592 
593  ++j;
594 
595  // get the Surface of the hit (knows how to go from local <-> global)
596  const BoundPlane &bSurface = theDet->surface();
597 
598  // gather necessary information
599  SiBrlToF.push_back(itHit->tof());
600  SiBrlR.push_back(bSurface.toGlobal(itHit->localPosition()).perp());
601  SiBrlPhi.push_back(bSurface.toGlobal(itHit->localPosition()).phi());
602  SiBrlEta.push_back(bSurface.toGlobal(itHit->localPosition()).eta());
603  } else {
604  edm::LogWarning(MsgLoggerCat) << "SiBrl PSimHit " << i << " is expected to be (det,subdet) = (" << dTrk << ","
605  << sdSiTIB << " || " << sdSiTOB << "); value returned is: (" << detector << ","
606  << subdetector << ")";
607  continue;
608  } // end detector type check
609  } // end loop through SiBrl Hits
610 
611  if (verbosity > 1) {
612  eventout += "\n Number of Silicon Barrel Hits collected:... ";
613  eventout += j;
614  }
615 
617  // get Silicon Forward information
619  edm::PSimHitContainer theSiFwdHits;
620  // extract TID low container
621  edm::Handle<edm::PSimHitContainer> SiTIDLowContainer;
622  iEvent.getByToken(SiTIDLowSrc_Token_, SiTIDLowContainer);
623  if (!SiTIDLowContainer.isValid()) {
624  edm::LogWarning(MsgLoggerCat) << "Unable to find TrackerHitsTIDLowTof in event!";
625  return;
626  }
627  // extract TID high container
628  edm::Handle<edm::PSimHitContainer> SiTIDHighContainer;
629  iEvent.getByToken(SiTIDHighSrc_Token_, SiTIDHighContainer);
630  if (!SiTIDHighContainer.isValid()) {
631  edm::LogWarning("GlobalHitsProducer_fillTrk") << "Unable to find TrackerHitsTIDHighTof in event!";
632  return;
633  }
634  // extract TEC low container
635  edm::Handle<edm::PSimHitContainer> SiTECLowContainer;
636  iEvent.getByToken(SiTECLowSrc_Token_, SiTECLowContainer);
637  if (!SiTECLowContainer.isValid()) {
638  edm::LogWarning(MsgLoggerCat) << "Unable to find TrackerHitsTECLowTof in event!";
639  return;
640  }
641  // extract TEC high container
642  edm::Handle<edm::PSimHitContainer> SiTECHighContainer;
643  iEvent.getByToken(SiTECHighSrc_Token_, SiTECHighContainer);
644  if (!SiTECHighContainer.isValid()) {
645  edm::LogWarning(MsgLoggerCat) << "Unable to find TrackerHitsTECHighTof in event!";
646  return;
647  }
648  // place all containers into new container
649  theSiFwdHits.insert(theSiFwdHits.end(), SiTIDLowContainer->begin(), SiTIDLowContainer->end());
650  theSiFwdHits.insert(theSiFwdHits.end(), SiTIDHighContainer->begin(), SiTIDHighContainer->end());
651  theSiFwdHits.insert(theSiFwdHits.end(), SiTECLowContainer->begin(), SiTECLowContainer->end());
652  theSiFwdHits.insert(theSiFwdHits.end(), SiTECHighContainer->begin(), SiTECHighContainer->end());
653 
654  // cycle through container
655  i = 0;
656  j = 0;
657  for (itHit = theSiFwdHits.begin(); itHit != theSiFwdHits.end(); ++itHit) {
658  ++i;
659 
660  // create a DetId from the detUnitId
661  DetId theDetUnitId(itHit->detUnitId());
662  int detector = theDetUnitId.det();
663  int subdetector = theDetUnitId.subdetId();
664 
665  // check that expected detector is returned
666  if ((detector == dTrk) && ((subdetector == sdSiTID) || (subdetector == sdSiTEC))) {
667  // get the GeomDetUnit from the geometry using theDetUnitID
668  const GeomDetUnit *theDet = theTracker.idToDetUnit(theDetUnitId);
669 
670  if (!theDet) {
671  edm::LogWarning(MsgLoggerCat) << "Unable to get GeomDetUnit from SiFwdHits Hit " << i;
672  return;
673  }
674 
675  ++j;
676 
677  // get the Surface of the hit (knows how to go from local <-> global)
678  const BoundPlane &bSurface = theDet->surface();
679 
680  // gather necessary information
681  SiFwdToF.push_back(itHit->tof());
682  SiFwdZ.push_back(bSurface.toGlobal(itHit->localPosition()).z());
683  SiFwdPhi.push_back(bSurface.toGlobal(itHit->localPosition()).phi());
684  SiFwdEta.push_back(bSurface.toGlobal(itHit->localPosition()).eta());
685  } else {
686  edm::LogWarning(MsgLoggerCat) << "SiFwd PSimHit " << i << " is expected to be (det,subdet) = (" << dTrk << ","
687  << sdSiTOB << " || " << sdSiTEC << "); value returned is: (" << detector << ","
688  << subdetector << ")";
689  continue;
690  } // end check detector type
691  } // end loop through SiFwd Hits
692 
693  if (verbosity > 1) {
694  eventout += "\n Number of Silicon Forward Hits collected:.. ";
695  eventout += j;
696  }
697 
698  if (verbosity > 0)
699  edm::LogInfo(MsgLoggerCat) << eventout << "\n";
700 
701  return;
702 }
703 
705  std::string MsgLoggerCat = "GlobalHitsProducer_storeTrk";
706 
707  if (verbosity > 2) {
708  TString eventout("\n nPxlBrlHits = ");
709  eventout += PxlBrlToF.size();
710  for (unsigned int i = 0; i < PxlBrlToF.size(); ++i) {
711  eventout += "\n (tof,r,phi,eta) = (";
712  eventout += PxlBrlToF[i];
713  eventout += ", ";
714  eventout += PxlBrlR[i];
715  eventout += ", ";
716  eventout += PxlBrlPhi[i];
717  eventout += ", ";
718  eventout += PxlBrlEta[i];
719  eventout += ")";
720  } // end PxlBrl output
721  eventout += "\n nPxlFwdHits = ";
722  eventout += PxlFwdToF.size();
723  for (unsigned int i = 0; i < PxlFwdToF.size(); ++i) {
724  eventout += "\n (tof,z,phi,eta) = (";
725  eventout += PxlFwdToF[i];
726  eventout += ", ";
727  eventout += PxlFwdZ[i];
728  eventout += ", ";
729  eventout += PxlFwdPhi[i];
730  eventout += ", ";
731  eventout += PxlFwdEta[i];
732  eventout += ")";
733  } // end PxlFwd output
734  eventout += "\n nSiBrlHits = ";
735  eventout += SiBrlToF.size();
736  for (unsigned int i = 0; i < SiBrlToF.size(); ++i) {
737  eventout += "\n (tof,r,phi,eta) = (";
738  eventout += SiBrlToF[i];
739  eventout += ", ";
740  eventout += SiBrlR[i];
741  eventout += ", ";
742  eventout += SiBrlPhi[i];
743  eventout += ", ";
744  eventout += SiBrlEta[i];
745  eventout += ")";
746  } // end SiBrl output
747  eventout += "\n nSiFwdHits = ";
748  eventout += SiFwdToF.size();
749  for (unsigned int i = 0; i < SiFwdToF.size(); ++i) {
750  eventout += "\n (tof,z,phi,eta) = (";
751  eventout += SiFwdToF[i];
752  eventout += ", ";
753  eventout += SiFwdZ[i];
754  eventout += ", ";
755  eventout += SiFwdPhi[i];
756  eventout += ", ";
757  eventout += SiFwdEta[i];
758  eventout += ")";
759  } // end SiFwd output
760  edm::LogInfo(MsgLoggerCat) << eventout << "\n";
761  } // end verbose output
762 
767 
768  return;
769 }
770 
772  std::string MsgLoggerCat = "GlobalHitsProducer_fillMuon";
773 
774  TString eventout;
775  if (verbosity > 0)
776  eventout = "\nGathering info:";
777 
778  // iterator to access containers
779  edm::PSimHitContainer::const_iterator itHit;
780 
781  // int i = 0, j = 0;
783  // access the CSC Muon
785  // access the CSC Muon geometry
786  edm::ESHandle<CSCGeometry> theCSCGeometry;
787  iSetup.get<MuonGeometryRecord>().get(theCSCGeometry);
788  if (!theCSCGeometry.isValid()) {
789  edm::LogWarning(MsgLoggerCat) << "Unable to find MuonGeometryRecord for the CSCGeometry in event!";
790  return;
791  }
792  const CSCGeometry &theCSCMuon(*theCSCGeometry);
793 
794  // get Muon CSC information
795  edm::Handle<edm::PSimHitContainer> MuonCSCContainer;
796  iEvent.getByToken(MuonCscSrc_Token_, MuonCSCContainer);
797  if (!MuonCSCContainer.isValid()) {
798  edm::LogWarning(MsgLoggerCat) << "Unable to find MuonCSCHits in event!";
799  return;
800  }
801 
802  // cycle through container
803  int i = 0, j = 0;
804  for (itHit = MuonCSCContainer->begin(); itHit != MuonCSCContainer->end(); ++itHit) {
805  ++i;
806 
807  // create a DetId from the detUnitId
808  DetId theDetUnitId(itHit->detUnitId());
809  int detector = theDetUnitId.det();
810  int subdetector = theDetUnitId.subdetId();
811 
812  // check that expected detector is returned
813  if ((detector == dMuon) && (subdetector == sdMuonCSC)) {
814  // get the GeomDetUnit from the geometry using theDetUnitID
815  const GeomDetUnit *theDet = theCSCMuon.idToDetUnit(theDetUnitId);
816 
817  if (!theDet) {
818  edm::LogWarning(MsgLoggerCat) << "Unable to get GeomDetUnit from theCSCMuon for hit " << i;
819  continue;
820  }
821 
822  ++j;
823 
824  // get the Surface of the hit (knows how to go from local <-> global)
825  const BoundPlane &bSurface = theDet->surface();
826 
827  // gather necessary information
828  MuonCscToF.push_back(itHit->tof());
829  MuonCscZ.push_back(bSurface.toGlobal(itHit->localPosition()).z());
830  MuonCscPhi.push_back(bSurface.toGlobal(itHit->localPosition()).phi());
831  MuonCscEta.push_back(bSurface.toGlobal(itHit->localPosition()).eta());
832  } else {
833  edm::LogWarning(MsgLoggerCat) << "MuonCsc PSimHit " << i << " is expected to be (det,subdet) = (" << dMuon << ","
834  << sdMuonCSC << "); value returned is: (" << detector << "," << subdetector << ")";
835  continue;
836  } // end detector type check
837  } // end loop through CSC Hits
838 
839  if (verbosity > 1) {
840  eventout += "\n Number of CSC muon Hits collected:......... ";
841  eventout += j;
842  }
843 
844  // i = 0, j = 0;
846  // access the DT Muon
848  // access the DT Muon geometry
849  edm::ESHandle<DTGeometry> theDTGeometry;
850  iSetup.get<MuonGeometryRecord>().get(theDTGeometry);
851  if (!theDTGeometry.isValid()) {
852  edm::LogWarning(MsgLoggerCat) << "Unable to find MuonGeometryRecord for the DTGeometry in event!";
853  return;
854  }
855  const DTGeometry &theDTMuon(*theDTGeometry);
856 
857  // get Muon DT information
858  edm::Handle<edm::PSimHitContainer> MuonDtContainer;
859  iEvent.getByToken(MuonDtSrc_Token_, MuonDtContainer);
860  if (!MuonDtContainer.isValid()) {
861  edm::LogWarning(MsgLoggerCat) << "Unable to find MuonDTHits in event!";
862  return;
863  }
864 
865  // cycle through container
866  i = 0, j = 0;
867  for (itHit = MuonDtContainer->begin(); itHit != MuonDtContainer->end(); ++itHit) {
868  ++i;
869 
870  // create a DetId from the detUnitId
871  DetId theDetUnitId(itHit->detUnitId());
872  int detector = theDetUnitId.det();
873  int subdetector = theDetUnitId.subdetId();
874 
875  // check that expected detector is returned
876  if ((detector == dMuon) && (subdetector == sdMuonDT)) {
877  // CSC uses wires and layers rather than the full detID
878  // get the wireId
879  DTWireId wireId(itHit->detUnitId());
880 
881  // get the DTLayer from the geometry using the wireID
882  const DTLayer *theDet = theDTMuon.layer(wireId.layerId());
883 
884  if (!theDet) {
885  edm::LogWarning(MsgLoggerCat) << "Unable to get GeomDetUnit from theDtMuon for hit " << i;
886  continue;
887  }
888 
889  ++j;
890 
891  // get the Surface of the hit (knows how to go from local <-> global)
892  const BoundPlane &bSurface = theDet->surface();
893 
894  // gather necessary information
895  MuonDtToF.push_back(itHit->tof());
896  MuonDtR.push_back(bSurface.toGlobal(itHit->localPosition()).perp());
897  MuonDtPhi.push_back(bSurface.toGlobal(itHit->localPosition()).phi());
898  MuonDtEta.push_back(bSurface.toGlobal(itHit->localPosition()).eta());
899  } else {
900  edm::LogWarning(MsgLoggerCat) << "MuonDt PSimHit " << i << " is expected to be (det,subdet) = (" << dMuon << ","
901  << sdMuonDT << "); value returned is: (" << detector << "," << subdetector << ")";
902  continue;
903  } // end detector type check
904  } // end loop through DT Hits
905 
906  if (verbosity > 1) {
907  eventout += "\n Number of DT muon Hits collected:.......... ";
908  eventout += j;
909  }
910 
911  // i = 0, j = 0;
912  // int RPCBrl = 0, RPCFwd = 0;
914  // access the RPC Muon
916  // access the RPC Muon geometry
917  edm::ESHandle<RPCGeometry> theRPCGeometry;
918  iSetup.get<MuonGeometryRecord>().get(theRPCGeometry);
919  if (!theRPCGeometry.isValid()) {
920  edm::LogWarning(MsgLoggerCat) << "Unable to find MuonGeometryRecord for the RPCGeometry in event!";
921  return;
922  }
923  const RPCGeometry &theRPCMuon(*theRPCGeometry);
924 
925  // get Muon RPC information
926  edm::Handle<edm::PSimHitContainer> MuonRPCContainer;
927  iEvent.getByToken(MuonRpcSrc_Token_, MuonRPCContainer);
928  if (!MuonRPCContainer.isValid()) {
929  edm::LogWarning(MsgLoggerCat) << "Unable to find MuonRPCHits in event!";
930  return;
931  }
932 
933  // cycle through container
934  i = 0, j = 0;
935  int RPCBrl = 0, RPCFwd = 0;
936  for (itHit = MuonRPCContainer->begin(); itHit != MuonRPCContainer->end(); ++itHit) {
937  ++i;
938 
939  // create a DetID from the detUnitId
940  DetId theDetUnitId(itHit->detUnitId());
941  int detector = theDetUnitId.det();
942  int subdetector = theDetUnitId.subdetId();
943 
944  // check that expected detector is returned
945  if ((detector == dMuon) && (subdetector == sdMuonRPC)) {
946  // get an RPCDetID from the detUnitID
947  RPCDetId RPCId(itHit->detUnitId());
948 
949  // find the region of the RPC hit
950  int region = RPCId.region();
951 
952  // get the GeomDetUnit from the geometry using the RPCDetId
953  const GeomDetUnit *theDet = theRPCMuon.idToDetUnit(theDetUnitId);
954 
955  if (!theDet) {
956  edm::LogWarning(MsgLoggerCat) << "Unable to get GeomDetUnit from theRPCMuon for hit " << i;
957  continue;
958  }
959 
960  ++j;
961 
962  // get the Surface of the hit (knows how to go from local <-> global)
963  const BoundPlane &bSurface = theDet->surface();
964 
965  // gather necessary information
966  if ((region == sdMuonRPCRgnFwdp) || (region == sdMuonRPCRgnFwdn)) {
967  ++RPCFwd;
968 
969  MuonRpcFwdToF.push_back(itHit->tof());
970  MuonRpcFwdZ.push_back(bSurface.toGlobal(itHit->localPosition()).z());
971  MuonRpcFwdPhi.push_back(bSurface.toGlobal(itHit->localPosition()).phi());
972  MuonRpcFwdEta.push_back(bSurface.toGlobal(itHit->localPosition()).eta());
973  } else if (region == sdMuonRPCRgnBrl) {
974  ++RPCBrl;
975 
976  MuonRpcBrlToF.push_back(itHit->tof());
977  MuonRpcBrlR.push_back(bSurface.toGlobal(itHit->localPosition()).perp());
978  MuonRpcBrlPhi.push_back(bSurface.toGlobal(itHit->localPosition()).phi());
979  MuonRpcBrlEta.push_back(bSurface.toGlobal(itHit->localPosition()).eta());
980  } else {
981  edm::LogWarning(MsgLoggerCat) << "Invalid region for RPC Muon hit" << i;
982  continue;
983  } // end check of region
984  } else {
985  edm::LogWarning(MsgLoggerCat) << "MuonRpc PSimHit " << i << " is expected to be (det,subdet) = (" << dMuon << ","
986  << sdMuonRPC << "); value returned is: (" << detector << "," << subdetector << ")";
987  continue;
988  } // end detector type check
989  } // end loop through RPC Hits
990 
991  if (verbosity > 1) {
992  eventout += "\n Number of RPC muon Hits collected:......... ";
993  eventout += j;
994  eventout += "\n RPC Barrel muon Hits:............ ";
995  eventout += RPCBrl;
996  eventout += "\n RPC Forward muon Hits:........... ";
997  eventout += RPCFwd;
998  }
999 
1000  if (verbosity > 0)
1001  edm::LogInfo(MsgLoggerCat) << eventout << "\n";
1002 
1003  return;
1004 }
1005 
1007  std::string MsgLoggerCat = "GlobalHitsProducer_storeMuon";
1008 
1009  if (verbosity > 2) {
1010  TString eventout("\n nMuonCSCHits = ");
1011  eventout += MuonCscToF.size();
1012  for (unsigned int i = 0; i < MuonCscToF.size(); ++i) {
1013  eventout += "\n (tof,z,phi,eta) = (";
1014  eventout += MuonCscToF[i];
1015  eventout += ", ";
1016  eventout += MuonCscZ[i];
1017  eventout += ", ";
1018  eventout += MuonCscPhi[i];
1019  eventout += ", ";
1020  eventout += MuonCscEta[i];
1021  eventout += ")";
1022  } // end MuonCsc output
1023  eventout += "\n nMuonDtHits = ";
1024  eventout += MuonDtToF.size();
1025  for (unsigned int i = 0; i < MuonDtToF.size(); ++i) {
1026  eventout += "\n (tof,r,phi,eta) = (";
1027  eventout += MuonDtToF[i];
1028  eventout += ", ";
1029  eventout += MuonDtR[i];
1030  eventout += ", ";
1031  eventout += MuonDtPhi[i];
1032  eventout += ", ";
1033  eventout += MuonDtEta[i];
1034  eventout += ")";
1035  } // end MuonDt output
1036  eventout += "\n nMuonRpcBrlHits = ";
1037  eventout += MuonRpcBrlToF.size();
1038  for (unsigned int i = 0; i < MuonRpcBrlToF.size(); ++i) {
1039  eventout += "\n (tof,r,phi,eta) = (";
1040  eventout += MuonRpcBrlToF[i];
1041  eventout += ", ";
1042  eventout += MuonRpcBrlR[i];
1043  eventout += ", ";
1044  eventout += MuonRpcBrlPhi[i];
1045  eventout += ", ";
1046  eventout += MuonRpcBrlEta[i];
1047  eventout += ")";
1048  } // end MuonRpcBrl output
1049  eventout += "\n nMuonRpcFwdHits = ";
1050  eventout += MuonRpcFwdToF.size();
1051  for (unsigned int i = 0; i < MuonRpcFwdToF.size(); ++i) {
1052  eventout += "\n (tof,z,phi,eta) = (";
1053  eventout += MuonRpcFwdToF[i];
1054  eventout += ", ";
1055  eventout += MuonRpcFwdZ[i];
1056  eventout += ", ";
1057  eventout += MuonRpcFwdPhi[i];
1058  eventout += ", ";
1059  eventout += MuonRpcFwdEta[i];
1060  eventout += ")";
1061  } // end MuonRpcFwd output
1062  edm::LogInfo(MsgLoggerCat) << eventout << "\n";
1063  } // end verbose output
1064 
1069 
1070  return;
1071 }
1072 
1074  std::string MsgLoggerCat = "GlobalHitsProducer_fillECal";
1075 
1076  TString eventout;
1077  if (verbosity > 0)
1078  eventout = "\nGathering info:";
1079 
1080  // access the calorimeter geometry
1081  edm::ESHandle<CaloGeometry> theCaloGeometry;
1082  iSetup.get<CaloGeometryRecord>().get(theCaloGeometry);
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  edm::ESHandle<CaloGeometry> theCaloGeometry;
1266  iSetup.get<CaloGeometryRecord>().get(theCaloGeometry);
1267  if (!theCaloGeometry.isValid()) {
1268  edm::LogWarning(MsgLoggerCat) << "Unable to find CaloGeometryRecord in event!";
1269  return;
1270  }
1271  const CaloGeometry &theCalo(*theCaloGeometry);
1272 
1273  // iterator to access containers
1274  edm::PCaloHitContainer::const_iterator itHit;
1275 
1277  // get HCal information
1279  // extract HCal container
1281  iEvent.getByToken(HCalSrc_Token_, HCalContainer);
1282  if (!HCalContainer.isValid()) {
1283  edm::LogWarning(MsgLoggerCat) << "Unable to find HCalHits in event!";
1284  return;
1285  }
1286 
1287  // cycle through container
1288  int i = 0, j = 0;
1289  for (itHit = HCalContainer->begin(); itHit != HCalContainer->end(); ++itHit) {
1290  ++i;
1291 
1292  // create a DetId from the detUnitId
1293  DetId theDetUnitId(itHit->id());
1294  int detector = theDetUnitId.det();
1295  int subdetector = theDetUnitId.subdetId();
1296 
1297  // check that expected detector is returned
1298  if ((detector == dHcal) && ((subdetector == sdHcalBrl) || (subdetector == sdHcalEC) || (subdetector == sdHcalOut) ||
1299  (subdetector == sdHcalFwd))) {
1300  // get the Cell geometry
1301  const HcalGeometry *theDet = dynamic_cast<const HcalGeometry *>(theCalo.getSubdetectorGeometry(theDetUnitId));
1302 
1303  if (!theDet) {
1304  edm::LogWarning(MsgLoggerCat) << "Unable to get CaloCellGeometry from HCalContainer for Hit " << i;
1305  continue;
1306  }
1307 
1308  ++j;
1309 
1310  // get the global position of the cell
1311  const GlobalPoint &globalposition = theDet->getPosition(theDetUnitId);
1312 
1313  // gather necessary information
1314  HCalE.push_back(itHit->energy());
1315  HCalToF.push_back(itHit->time());
1316  HCalPhi.push_back(globalposition.phi());
1317  HCalEta.push_back(globalposition.eta());
1318 
1319  } else {
1320  edm::LogWarning(MsgLoggerCat) << "HCal PCaloHit " << i << " is expected to be (det,subdet) = (" << dHcal << ","
1321  << sdHcalBrl << " || " << sdHcalEC << " || " << sdHcalOut << " || " << sdHcalFwd
1322  << "); value returned is: (" << detector << "," << subdetector << ")";
1323  continue;
1324  } // end detector type check
1325  } // end loop through HCal Hits
1326 
1327  if (verbosity > 1) {
1328  eventout += "\n Number of HCal Hits collected:............. ";
1329  eventout += j;
1330  }
1331 
1332  if (verbosity > 0)
1333  edm::LogInfo(MsgLoggerCat) << eventout << "\n";
1334 
1335  return;
1336 }
1337 
1339  std::string MsgLoggerCat = "GlobalHitsProducer_storeHCal";
1340 
1341  if (verbosity > 2) {
1342  TString eventout("\n nHCalHits = ");
1343  eventout += HCalE.size();
1344  for (unsigned int i = 0; i < HCalE.size(); ++i) {
1345  eventout += "\n (e,tof,phi,eta) = (";
1346  eventout += HCalE[i];
1347  eventout += ", ";
1348  eventout += HCalToF[i];
1349  eventout += ", ";
1350  eventout += HCalPhi[i];
1351  eventout += ", ";
1352  eventout += HCalEta[i];
1353  eventout += ")";
1354  } // end HCal output
1355  edm::LogInfo(MsgLoggerCat) << eventout << "\n";
1356  } // end verbose output
1357 
1358  product.putHCalHits(HCalE, HCalToF, HCalPhi, HCalEta);
1359 
1360  return;
1361 }
1362 
1364  std::string MsgLoggerCat = "GlobalHitsProducer_clear";
1365 
1366  if (verbosity > 0)
1367  edm::LogInfo(MsgLoggerCat) << "Clearing event holders";
1368 
1369  // reset G4MC info
1370  nRawGenPart = 0;
1371  G4VtxX.clear();
1372  G4VtxY.clear();
1373  G4VtxZ.clear();
1374  G4TrkPt.clear();
1375  G4TrkE.clear();
1376 
1377  // reset electromagnetic info
1378  // reset ECal info
1379  ECalE.clear();
1380  ECalToF.clear();
1381  ECalPhi.clear();
1382  ECalEta.clear();
1383  // reset Preshower info
1384  PreShE.clear();
1385  PreShToF.clear();
1386  PreShPhi.clear();
1387  PreShEta.clear();
1388 
1389  // reset hadronic info
1390  // reset HCal info
1391  HCalE.clear();
1392  HCalToF.clear();
1393  HCalPhi.clear();
1394  HCalEta.clear();
1395 
1396  // reset tracker info
1397  // reset Pixel info
1398  PxlBrlToF.clear();
1399  PxlBrlR.clear();
1400  PxlBrlPhi.clear();
1401  PxlBrlEta.clear();
1402  PxlFwdToF.clear();
1403  PxlFwdZ.clear();
1404  PxlFwdPhi.clear();
1405  PxlFwdEta.clear();
1406  // reset strip info
1407  SiBrlToF.clear();
1408  SiBrlR.clear();
1409  SiBrlPhi.clear();
1410  SiBrlEta.clear();
1411  SiFwdToF.clear();
1412  SiFwdZ.clear();
1413  SiFwdPhi.clear();
1414  SiFwdEta.clear();
1415 
1416  // reset muon info
1417  // reset muon DT info
1418  MuonDtToF.clear();
1419  MuonDtR.clear();
1420  MuonDtPhi.clear();
1421  MuonDtEta.clear();
1422  // reset muon CSC info
1423  MuonCscToF.clear();
1424  MuonCscZ.clear();
1425  MuonCscPhi.clear();
1426  MuonCscEta.clear();
1427  // rest muon RPC info
1428  MuonRpcBrlToF.clear();
1429  MuonRpcBrlR.clear();
1430  MuonRpcBrlPhi.clear();
1431  MuonRpcBrlEta.clear();
1432  MuonRpcFwdToF.clear();
1433  MuonRpcFwdZ.clear();
1434  MuonRpcFwdPhi.clear();
1435  MuonRpcFwdEta.clear();
1436 
1437  return;
1438 }
edm::InputTag ECalESSrc_
RunNumber_t run() const
Definition: EventID.h:39
void storeECal(PGlobalSimHit &)
edm::EDGetTokenT< edm::PSimHitContainer > SiTIBHighSrc_Token_
T getParameter(std::string const &) const
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:49
EventNumber_t event() const
Definition: EventID.h:41
T getUntrackedParameter(std::string const &, T const &) const
static const int dEcal
static const int dTrk
edm::EDGetTokenT< edm::PSimHitContainer > SiTECHighSrc_Token_
std::vector< PCaloHit > PCaloHitContainer
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
const GeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
Definition: RPCGeometry.cc:48
static const int sdMuonRPCRgnFwdn
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
edm::EDGetTokenT< edm::PSimHitContainer > MuonRpcSrc_Token_
edm::InputTag MuonCscSrc_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
void putMuonRpcFwdHits(const std::vector< float > &tof, const std::vector< float > &z, const std::vector< float > &phi, const std::vector< float > &eta)
TString subdetector
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_
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 &)
void getManyByType(std::vector< Handle< PROD >> &results) const
Definition: Event.h:508
edm::InputTag PxlFwdLowSrc_
static const int sdMuonRPC
void storeG4MC(PGlobalSimHit &)
edm::EDGetTokenT< edm::PSimHitContainer > PxlBrlHighSrc_Token_
CaloGeometry const * getGeometry()
edm::InputTag SiTIDLowSrc_
void storeTrk(PGlobalSimHit &)
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:42
void beginJob(void) override
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_
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
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:18
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_
static const int sdSiTOB
static const int sdEcalBrl
static const int sdMuonRPCRgnFwdp
static const int sdMuonRPCRgnBrl
bool isValid() const
Definition: HandleBase.h:74
edm::InputTag SiTIDHighSrc_
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)
edm::EDGetTokenT< edm::SimTrackContainer > G4TrkSrc_Token_
edm::InputTag PxlFwdHighSrc_
GlobalPoint getPosition(const DetId &id) const
edm::EDGetTokenT< edm::PCaloHitContainer > ECalESSrc_Token_
Definition: DetId.h:18
static const int dHcal
edm::EDGetTokenT< edm::PSimHitContainer > SiTOBHighSrc_Token_
void putPreShHits(const std::vector< float > &e, const std::vector< float > &tof, const std::vector< float > &phi, const std::vector< float > &eta)
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:38
BranchDescription const & branchDescription() const
Definition: Provenance.h:45
void fillECal(edm::Event &, const edm::EventSetup &)
void fillHCal(edm::Event &, const edm::EventSetup &)
std::vector< SimVertex > SimVertexContainer
edm::EDGetTokenT< edm::PSimHitContainer > SiTIDHighSrc_Token_
static const int sdHcalFwd
static const int sdHcalBrl
void storeHCal(PGlobalSimHit &)
edm::InputTag SiTOBLowSrc_
edm::EDGetTokenT< edm::PSimHitContainer > PxlFwdLowSrc_Token_
std::string const & label() const
Definition: InputTag.h:36
T eta() const
Definition: PV3DBase.h:76
edm::EDGetTokenT< edm::PSimHitContainer > MuonDtSrc_Token_
const GeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
Definition: CSCGeometry.cc:108
edm::EDGetTokenT< edm::PSimHitContainer > PxlBrlLowSrc_Token_
edm::EventID id() const
Definition: EventBase.h:59
edm::EDGetTokenT< edm::SimVertexContainer > G4VtxSrc_Token_
static const int sdSiTEC
T perp() const
Magnitude of transverse component.
static const int dMuon
edm::EDGetTokenT< edm::PCaloHitContainer > ECalEBSrc_Token_
edm::EDGetTokenT< edm::PCaloHitContainer > ECalEESrc_Token_
HLT enums.
void putPxlBrlHits(const std::vector< float > &tof, const std::vector< float > &r, const std::vector< float > &phi, const std::vector< float > &eta)
T get() const
Definition: EventSetup.h:71
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
const DTLayer * layer(const DTLayerId &id) const
Return a layer given its id.
Definition: DTGeometry.cc:127
bool isValid() const
Definition: ESHandle.h:44
edm::InputTag SiTIBHighSrc_
std::vector< SimTrack > SimTrackContainer
std::string const & instance() const
Definition: InputTag.h:37
edm::InputTag MuonRpcSrc_
static const int sdHcalEC
def move(src, dest)
Definition: eostools.py:511
Provenance const * provenance() const
Definition: HandleBase.h:83
void getAllStableProvenance(std::vector< StableProvenance const * > &provenances) const
Definition: Event.cc:117
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
Definition: RPCDetId.h:63