CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TrackerHitProducer.cc
Go to the documentation of this file.
2 #include <cmath>
3 
5  fName(""), verbosity(0), label(""), getAllProvenances(false),
6  printProvenanceInfo(false), nRawGenPart(0), config_(iPSet), count(0)
7 {
8  // get information from parameter set
9  fName = iPSet.getUntrackedParameter<std::string>("Name");
10  verbosity = iPSet.getUntrackedParameter<int>("Verbosity");
11  label = iPSet.getParameter<std::string>("Label");
12  edm::ParameterSet m_Prov =
13  iPSet.getParameter<edm::ParameterSet>("ProvenanceLookup");
15  m_Prov.getUntrackedParameter<bool>("GetAllProvenances");
17  m_Prov.getUntrackedParameter<bool>("PrintProvenanceInfo");
18 
19  //get Labels to use to extract information
20  PxlBrlLowSrc_ = iPSet.getParameter<edm::InputTag>("PxlBrlLowSrc");
21  PxlBrlHighSrc_ = iPSet.getParameter<edm::InputTag>("PxlBrlHighSrc");
22  PxlFwdLowSrc_ = iPSet.getParameter<edm::InputTag>("PxlFwdLowSrc");
23  PxlFwdHighSrc_ = iPSet.getParameter<edm::InputTag>("PxlFwdHighSrc");
24 
25  SiTIBLowSrc_ = iPSet.getParameter<edm::InputTag>("SiTIBLowSrc");
26  SiTIBHighSrc_ = iPSet.getParameter<edm::InputTag>("SiTIBHighSrc");
27  SiTOBLowSrc_ = iPSet.getParameter<edm::InputTag>("SiTOBLowSrc");
28  SiTOBHighSrc_ = iPSet.getParameter<edm::InputTag>("SiTOBHighSrc");
29  SiTIDLowSrc_ = iPSet.getParameter<edm::InputTag>("SiTIDLowSrc");
30  SiTIDHighSrc_ = iPSet.getParameter<edm::InputTag>("SiTIDHighSrc");
31  SiTECLowSrc_ = iPSet.getParameter<edm::InputTag>("SiTECLowSrc");
32  SiTECHighSrc_ = iPSet.getParameter<edm::InputTag>("SiTECHighSrc");
33 
34  // use value of first digit to determine default output level (inclusive)
35  // 0 is none, 1 is basic, 2 is fill output, 3 is gather output
36  verbosity %= 10;
37 
38  // create persistent object
39  produces<PTrackerSimHit>(label);
40 
41  // print out Parameter Set information being used
42  if (verbosity > 0) {
43  edm::LogInfo ("TrackerHitProducer::TrackerHitProducer")
44  << "\n===============================\n"
45  << "Initialized as EDProducer with parameter values:\n"
46  << " Name =" << fName << "\n"
47  << " Verbosity =" << verbosity << "\n"
48  << " Label =" << label << "\n"
49  << " GetProv =" << getAllProvenances << "\n"
50  << " PrintProv =" << printProvenanceInfo << "\n"
51  << " PxlBrlLowSrc = " << PxlBrlLowSrc_.label()
52  << ":" << PxlBrlLowSrc_.instance() << "\n"
53  << " PxlBrlHighSrc = " << PxlBrlHighSrc_.label()
54  << ":" << PxlBrlHighSrc_.instance() << "\n"
55  << " PxlFwdLowSrc = " << PxlFwdLowSrc_.label()
56  << ":" << PxlBrlLowSrc_.instance() << "\n"
57  << " PxlFwdHighSrc = " << PxlFwdHighSrc_.label()
58  << ":" << PxlBrlHighSrc_.instance() << "\n"
59  << " SiTIBLowSrc = " << SiTIBLowSrc_.label()
60  << ":" << SiTIBLowSrc_.instance() << "\n"
61  << " SiTIBHighSrc = " << SiTIBHighSrc_.label()
62  << ":" << SiTIBHighSrc_.instance() << "\n"
63  << " SiTOBLowSrc = " << SiTOBLowSrc_.label()
64  << ":" << SiTOBLowSrc_.instance() << "\n"
65  << " SiTOBHighSrc = " << SiTOBHighSrc_.label()
66  << ":" << SiTOBHighSrc_.instance() << "\n"
67  << " SiTIDLowSrc = " << SiTIDLowSrc_.label()
68  << ":" << SiTIDLowSrc_.instance() << "\n"
69  << " SiTIDHighSrc = " << SiTIDHighSrc_.label()
70  << ":" << SiTIDHighSrc_.instance() << "\n"
71  << " SiTECLowSrc = " << SiTECLowSrc_.label()
72  << ":" << SiTECLowSrc_.instance() << "\n"
73  << " SiTECHighSrc = " << SiTECHighSrc_.label()
74  << ":" << SiTECHighSrc_.instance() << "\n"
75  << "===============================\n"; }
76 }
77 
79 {
80 }
81 
83 {
84  if (verbosity > 0)
85  edm::LogInfo ("TrackerHitProducer::beginJob")
86  << "Starting the job...";
87  clear();
88  return;
89 }
90 
92 {
93  if (verbosity > 0)
94  edm::LogInfo ("TrackerHitProducer::endJob")
95  << "Terminating having processed" << count << "events.";
96  return;
97 }
98 
100  const edm::EventSetup& iSetup)
101 {
102  // keep track of number of events processed
103  ++count;
104 
105  // get event id information
106  int nrun = iEvent.id().run();
107  int nevt = iEvent.id().event();
108 
109  // get event setup information
110  //edm::ESHandle<edm::SetupData> pSetup;
111  //iSetup.get<edm::SetupRecord>().get(pSetup);
112 
113  if (verbosity > 0) {
114  edm::LogInfo ("TrackerHitProducer::produce")
115  << "Processing run" << nrun << "," << "event " << nevt;
116  }
117 
118  // clear event holders
119  clear();
120 
121  // look at information available in the event
122  if (getAllProvenances) {
123 
124  std::vector<const edm::Provenance*> AllProv;
125  iEvent.getAllProvenance(AllProv);
126 
127  if (verbosity > 0)
128  edm::LogInfo ("TrackerHitProducer::produce")
129  << "Number of Provenances =" << AllProv.size();
130 
131  if (printProvenanceInfo && (verbosity > 0)) {
132  TString eventout("\nProvenance info:\n");
133 
134  for (unsigned int i = 0; i < AllProv.size(); ++i) {
135  eventout += "\n ******************************";
136  eventout += "\n Module : ";
137  eventout += AllProv[i]->moduleLabel();
138  eventout += "\n ProductID process index: ";
139  eventout += AllProv[i]->productID().processIndex();
140  eventout += "\n ProductID product index: ";
141  eventout += AllProv[i]->productID().productIndex();
142  eventout += "\n ClassName : ";
143  eventout += AllProv[i]->className();
144  eventout += "\n InstanceName : ";
145  eventout += AllProv[i]->productInstanceName();
146  eventout += "\n BranchName : ";
147  eventout += AllProv[i]->branchName();
148  }
149  eventout += " ******************************\n";
150  edm::LogInfo("TrackerHitProducer::produce") << eventout;
151  }
152  }
153 
154  // call fill functions
155  //gather G4MC information from event
156  fillG4MC(iEvent);
157  // gather Tracker information from event
158  fillTrk(iEvent,iSetup);
159 
160  if (verbosity > 0)
161  edm::LogInfo ("TrackerHitProducer::produce")
162  << "Done gathering data from event.";
163 
164  // produce object to put into event
165  std::auto_ptr<PTrackerSimHit> pOut(new PTrackerSimHit);
166 
167  if (verbosity > 2)
168  edm::LogInfo ("TrackerHitProducer::produce")
169  << "Saving event contents:";
170 
171  // call store functions
172  // store G4MC information in product
173  storeG4MC(*pOut);
174  // store Tracker information in produce
175  storeTrk(*pOut);
176 
177  // store information in event
178  iEvent.put(pOut,label);
179 
180  return;
181 }
182 
183 //==================fill and store functions================================
185 {
186 
187  TString eventout;
188  if (verbosity > 0)
189  eventout = "\nGathering info:";
190 
192  // get MC information
195  //iEvent.getByType(HepMCEvt);
196  static std::string HepMClabel = config_.getUntrackedParameter<std::string>("HepMCProductLabel","source");
197  static std::string HepMCinstance = config_.getUntrackedParameter<std::string>("HepMCInputInstance","");
198  iEvent.getByLabel(HepMClabel, HepMCinstance ,HepMCEvt);
199  if (!HepMCEvt.isValid()) {
200  edm::LogError("TrackerHitProducer::fillG4MC")
201  << "Unable to find HepMCProduct in event!";
202  return;
203  }
204  const HepMC::GenEvent* MCEvt = HepMCEvt->GetEvent();
205  nRawGenPart = MCEvt->particles_size();
206 
207  if (verbosity > 1) {
208  eventout += "\n Number of Raw Particles collected: ";
209  eventout += nRawGenPart;
210  }
211 
213  // get G4Vertex information
216  iEvent.getByType(G4VtxContainer);
217  if (!G4VtxContainer.isValid()) {
218  edm::LogError("TrackerHitProducer::fillG4MC")
219  << "Unable to find SimVertex in event!";
220  return;
221  }
222  int i = 0;
223  edm::SimVertexContainer::const_iterator itVtx;
224  for (itVtx = G4VtxContainer->begin(); itVtx != G4VtxContainer->end();
225  ++itVtx) {
226 
227  ++i;
228 
229  const CLHEP::HepLorentzVector& G4Vtx = CLHEP::HepLorentzVector(itVtx->position().x(),
230  itVtx->position().y(),
231  itVtx->position().z(),
232  itVtx->position().e());
233  G4VtxX.push_back(G4Vtx[0]/micrometer); //cm from code -> micrometer *10000
234  G4VtxY.push_back(G4Vtx[1]/micrometer); //cm from code -> micrometer *10000
235  G4VtxZ.push_back(G4Vtx[2]/millimeter); //cm from code -> millimeter *10
236  }
237 
238  if (verbosity > 1) {
239  eventout += "\n Number of G4Vertices collected: ";
240  eventout += i;
241  }
242 
244  // get G4Track information
247  iEvent.getByType(G4TrkContainer);
248  if (!G4TrkContainer.isValid()) {
249  edm::LogError("TrackerHitProducer::fillG4MC")
250  << "Unable to find SimTrack in event!";
251  return;
252  }
253  i = 0;
254  edm::SimTrackContainer::const_iterator itTrk;
255  for (itTrk = G4TrkContainer->begin(); itTrk != G4TrkContainer->end();
256  ++itTrk) {
257 
258  ++i;
259 
260  double etaInit =0, phiInit =0, pInit =0;
261  const CLHEP::HepLorentzVector& G4Trk = CLHEP::HepLorentzVector(itTrk->momentum().x(),
262  itTrk->momentum().y(),
263  itTrk->momentum().z(),
264  itTrk->momentum().e());
265  pInit =sqrt(G4Trk[0]*G4Trk[0]+G4Trk[1]*G4Trk[1]+G4Trk[2]*G4Trk[2]);
266  if ( pInit == 0)
267  edm::LogError("TrackerHitProducer::fillG4MC")
268  << "TrackerTest::INFO: Primary has p = 0 ";
269  else {
270  double costheta = G4Trk[2]/pInit;
271  double theta = acos(TMath::Min(TMath::Max(costheta, -1.),1.));
272  etaInit = -log(tan(theta/2));
273 
274  if ( G4Trk[0] != 0 || G4Trk[1] != 0)
275  phiInit = atan2(G4Trk[1],G4Trk[0]);
276  }
277  G4TrkPt.push_back(sqrt(G4Trk[0]*G4Trk[0]+G4Trk[1]*G4Trk[1])); //GeV
278  G4TrkE.push_back(G4Trk[3]); //GeV
279  G4TrkEta.push_back(etaInit);
280  G4TrkPhi.push_back(phiInit);
281  }
282 
283  if (verbosity > 1) {
284  eventout += "\n Number of G4Tracks collected: ";
285  eventout += i;
286  }
287 
288  if (verbosity > 0)
289  edm::LogInfo("TrackerHitProducer::fillG4MC") << eventout;
290 
291  return;
292 }
293 
295 {
296 
297  if (verbosity > 2) {
298  TString eventout("\nnRawGenPart = ");
299  eventout += nRawGenPart;
300  eventout += "\n nG4Vtx = ";
301  eventout += G4VtxX.size();
302  for (unsigned int i = 0; i < G4VtxX.size(); ++i) {
303  eventout += "\n (x,y,z) = (";
304  eventout += G4VtxX[i];
305  eventout += ", ";
306  eventout += G4VtxY[i];
307  eventout += ", ";
308  eventout += G4VtxZ[i];
309  eventout += ")";
310  }
311  eventout += "\n nG4Trk = ";
312  eventout += G4TrkPt.size();
313  for (unsigned int i = 0; i < G4TrkPt.size(); ++i) {
314  eventout += "\n (pt,e,eta,phi) = (";
315  eventout += G4TrkPt[i];
316  eventout += ", ";
317  eventout += G4TrkE[i];
318  eventout += ")";
319  eventout += G4TrkEta[i];
320  eventout += ")";
321  eventout += G4TrkPhi[i];
322  eventout += ")";
323  }
324  edm::LogInfo("TrackerHitProducer::storeG4MC") << eventout;
325  } // end verbose output
326 
327  product.putRawGenPart(nRawGenPart);
328  product.putG4Vtx(G4VtxX, G4VtxY, G4VtxZ);
330 
331  return;
332 }
333 
335  const edm::EventSetup& iSetup)
336 {
337  TString eventout;
338  int sysID = 0;
339  if (verbosity > 0)
340  eventout = "\nGathering info:";
342  // iterator to access containers
343  edm::PSimHitContainer::const_iterator itHit;
344 // edm::PSimHitContainer theHits;
345 
347  // get Pixel Barrel information
349 
350  // extract low container
351  edm::Handle<edm::PSimHitContainer> PxlBrlLowContainer;
352  iEvent.getByLabel(PxlBrlLowSrc_,PxlBrlLowContainer);
353 // iEvent.getByLabel("g4SimHits","TrackerHitsPixelBarrelLowTof",PxlBrlLowContainer);
354  if (!PxlBrlLowContainer.isValid()) {
355  edm::LogError("TrackerHitProducer::fillTrk")
356  << "Unable to find TrackerHitsPixelBarrelLowTof in event!";
357  return;
358  }
359 
360  // place both containers into new container
361 // theHits.insert(theHits.end(),PxlBrlLowContainer->begin(),
362 // PxlBrlLowContainer->end());
363 
364  sysID = 100; // TrackerHitsPixelBarrelLowTof
365  int j = 0;
366  for (itHit = PxlBrlLowContainer->begin(); itHit != PxlBrlLowContainer->end(); ++itHit) {
367 // for (itHit = theHits.begin(); itHit != theHits.end(); ++itHit) {
368 
369  // gather necessary information
370  ++j;
371  HitsSysID.push_back(sysID);
372  HitsDuID.push_back(itHit->detUnitId());
373  HitsTkID.push_back(itHit->trackId());
374  HitsProT.push_back(itHit->processType());
375  HitsParT.push_back(itHit->particleType());
376  HitsP.push_back(itHit->pabs());
377 
378  HitsLpX.push_back(itHit->localPosition().x());
379  HitsLpY.push_back(itHit->localPosition().y());
380  HitsLpZ.push_back(itHit->localPosition().z());
381 
382  HitsLdX.push_back(itHit->localDirection().x());
383  HitsLdY.push_back(itHit->localDirection().y());
384  HitsLdZ.push_back(itHit->localDirection().z());
385  HitsLdTheta.push_back(itHit->localDirection().theta());
386  HitsLdPhi.push_back(itHit->localDirection().phi());
387 
388  HitsExPx.push_back(itHit->exitPoint().x());
389  HitsExPy.push_back(itHit->exitPoint().y());
390  HitsExPz.push_back(itHit->exitPoint().z());
391 
392  HitsEnPx.push_back(itHit->entryPoint().x());
393  HitsEnPy.push_back(itHit->entryPoint().y());
394  HitsEnPz.push_back(itHit->entryPoint().z());
395 
396  HitsEloss.push_back(itHit->energyLoss());
397  HitsToF.push_back(itHit->tof());
398 
399  } // end loop through PxlBrl Hits
400 
401  if (verbosity > 1) {
402  eventout += "\n Number of Pixel Barrel Low TOF Hits collected: ";
403  eventout += j;
404  }
405 
406 // theHits.clear();
407 
408  // extract high container
409  edm::Handle<edm::PSimHitContainer> PxlBrlHighContainer;
410 // iEvent.getByLabel("g4SimHits","TrackerHitsPixelBarrelHighTof",PxlBrlHighContainer);
411  iEvent.getByLabel(PxlBrlHighSrc_,PxlBrlHighContainer);
412  if (!PxlBrlHighContainer.isValid()) {
413  edm::LogError("TrackerHitProducer::fillTrk")
414  << "Unable to find TrackerHitsPixelBarrelHighTof in event!";
415  return;
416  }
417 
418 
419  sysID = 200; // TrackerHitsPixelBarrelHighTof
420  j = 0;
421  for (itHit = PxlBrlHighContainer->begin(); itHit != PxlBrlHighContainer->end(); ++itHit) {
422 
423  // gather necessary information
424  ++j;
425  HitsSysID.push_back(sysID);
426  HitsDuID.push_back(itHit->detUnitId());
427  HitsTkID.push_back(itHit->trackId());
428  HitsProT.push_back(itHit->processType());
429  HitsParT.push_back(itHit->particleType());
430  HitsP.push_back(itHit->pabs());
431 
432  HitsLpX.push_back(itHit->localPosition().x());
433  HitsLpY.push_back(itHit->localPosition().y());
434  HitsLpZ.push_back(itHit->localPosition().z());
435 
436  HitsLdX.push_back(itHit->localDirection().x());
437  HitsLdY.push_back(itHit->localDirection().y());
438  HitsLdZ.push_back(itHit->localDirection().z());
439  HitsLdTheta.push_back(itHit->localDirection().theta());
440  HitsLdPhi.push_back(itHit->localDirection().phi());
441 
442  HitsExPx.push_back(itHit->exitPoint().x());
443  HitsExPy.push_back(itHit->exitPoint().y());
444  HitsExPz.push_back(itHit->exitPoint().z());
445 
446  HitsEnPx.push_back(itHit->entryPoint().x());
447  HitsEnPy.push_back(itHit->entryPoint().y());
448  HitsEnPz.push_back(itHit->entryPoint().z());
449 
450  HitsEloss.push_back(itHit->energyLoss());
451  HitsToF.push_back(itHit->tof());
452 
453  } // end loop through PxlBrl Hits
454 
455  if (verbosity > 1) {
456  eventout += "\n Number of Pixel Barrel High TOF Hits collected: ";
457  eventout += j;
458  }
459 
460 
462  // get Pixel Forward information
464  // extract low container
465  edm::Handle<edm::PSimHitContainer> PxlFwdLowContainer;
466 // iEvent.getByLabel("g4SimHits","TrackerHitsPixelEndcapLowTof",PxlFwdLowContainer);
467  iEvent.getByLabel(PxlFwdLowSrc_,PxlFwdLowContainer);
468  if (!PxlFwdLowContainer.isValid()) {
469  edm::LogError("TrackerHitProducer::fillTrk")
470  << "Unable to find TrackerHitsPixelEndcapLowTof in event!";
471  return;
472  }
473 
474  sysID = 300; // TrackerHitsPixelEndcapLowTof
475  j = 0;
476  for (itHit = PxlFwdLowContainer->begin(); itHit != PxlFwdLowContainer->end(); ++itHit) {
477 
478  // gather necessary information
479  ++j;
480  HitsSysID.push_back(sysID);
481  HitsDuID.push_back(itHit->detUnitId());
482  HitsTkID.push_back(itHit->trackId());
483  HitsProT.push_back(itHit->processType());
484  HitsParT.push_back(itHit->particleType());
485  HitsP.push_back(itHit->pabs());
486 
487  HitsLpX.push_back(itHit->localPosition().x());
488  HitsLpY.push_back(itHit->localPosition().y());
489  HitsLpZ.push_back(itHit->localPosition().z());
490 
491  HitsLdX.push_back(itHit->localDirection().x());
492  HitsLdY.push_back(itHit->localDirection().y());
493  HitsLdZ.push_back(itHit->localDirection().z());
494  HitsLdTheta.push_back(itHit->localDirection().theta());
495  HitsLdPhi.push_back(itHit->localDirection().phi());
496 
497  HitsExPx.push_back(itHit->exitPoint().x());
498  HitsExPy.push_back(itHit->exitPoint().y());
499  HitsExPz.push_back(itHit->exitPoint().z());
500 
501  HitsEnPx.push_back(itHit->entryPoint().x());
502  HitsEnPy.push_back(itHit->entryPoint().y());
503  HitsEnPz.push_back(itHit->entryPoint().z());
504 
505  HitsEloss.push_back(itHit->energyLoss());
506  HitsToF.push_back(itHit->tof());
507 
508  } // end loop through PxlFwd Hits
509 
510  if (verbosity > 1) {
511  eventout += "\n Number of Pixel Forward Low TOF Hits collected: ";
512  eventout += j;
513  }
514 
515 
516  // extract high container
517  edm::Handle<edm::PSimHitContainer> PxlFwdHighContainer;
518 // iEvent.getByLabel("g4SimHits","TrackerHitsPixelEndcapHighTof",PxlFwdHighContainer);
519  iEvent.getByLabel(PxlFwdHighSrc_,PxlFwdHighContainer);
520  if (!PxlFwdHighContainer.isValid()) {
521  edm::LogError("TrackerHitProducer::fillTrk")
522  << "Unable to find TrackerHitsPixelEndcapHighTof in event!";
523  return;
524  }
525 
526  sysID = 400; // TrackerHitsPixelEndcapHighTof
527  j = 0;
528  for (itHit = PxlFwdHighContainer->begin(); itHit != PxlFwdHighContainer->end(); ++itHit) {
529 
530  // gather necessary information
531  ++j;
532  HitsSysID.push_back(sysID);
533  HitsDuID.push_back(itHit->detUnitId());
534  HitsTkID.push_back(itHit->trackId());
535  HitsProT.push_back(itHit->processType());
536  HitsParT.push_back(itHit->particleType());
537  HitsP.push_back(itHit->pabs());
538 
539  HitsLpX.push_back(itHit->localPosition().x());
540  HitsLpY.push_back(itHit->localPosition().y());
541  HitsLpZ.push_back(itHit->localPosition().z());
542 
543  HitsLdX.push_back(itHit->localDirection().x());
544  HitsLdY.push_back(itHit->localDirection().y());
545  HitsLdZ.push_back(itHit->localDirection().z());
546  HitsLdTheta.push_back(itHit->localDirection().theta());
547  HitsLdPhi.push_back(itHit->localDirection().phi());
548 
549  HitsExPx.push_back(itHit->exitPoint().x());
550  HitsExPy.push_back(itHit->exitPoint().y());
551  HitsExPz.push_back(itHit->exitPoint().z());
552 
553  HitsEnPx.push_back(itHit->entryPoint().x());
554  HitsEnPy.push_back(itHit->entryPoint().y());
555  HitsEnPz.push_back(itHit->entryPoint().z());
556 
557  HitsEloss.push_back(itHit->energyLoss());
558  HitsToF.push_back(itHit->tof());
559 
560  } // end loop through PxlFwd Hits
561 
562  if (verbosity > 1) {
563  eventout += "\n Number of Pixel Forward High TOF Hits collected: ";
564  eventout += j;
565  }
566 
567 
569  // get Silicon TIB information
571  // extract TIB low container
572  edm::Handle<edm::PSimHitContainer> SiTIBLowContainer;
573 // iEvent.getByLabel("g4SimHits","TrackerHitsTIBLowTof",SiTIBLowContainer);
574  iEvent.getByLabel(SiTIBLowSrc_,SiTIBLowContainer);
575  if (!SiTIBLowContainer.isValid()) {
576  edm::LogError("TrackerHitProducer::fillTrk")
577  << "Unable to find TrackerHitsTIBLowTof in event!";
578  return;
579  }
580 
581  sysID = 10; // TrackerHitsTIBLowTof
582  j = 0;
583  for (itHit = SiTIBLowContainer->begin(); itHit != SiTIBLowContainer->end(); ++itHit) {
584 
585  // gather necessary information
586  ++j;
587  HitsSysID.push_back(sysID);
588  HitsDuID.push_back(itHit->detUnitId());
589  HitsTkID.push_back(itHit->trackId());
590  HitsProT.push_back(itHit->processType());
591  HitsParT.push_back(itHit->particleType());
592  HitsP.push_back(itHit->pabs());
593 
594  HitsLpX.push_back(itHit->localPosition().x());
595  HitsLpY.push_back(itHit->localPosition().y());
596  HitsLpZ.push_back(itHit->localPosition().z());
597 
598  HitsLdX.push_back(itHit->localDirection().x());
599  HitsLdY.push_back(itHit->localDirection().y());
600  HitsLdZ.push_back(itHit->localDirection().z());
601  HitsLdTheta.push_back(itHit->localDirection().theta());
602  HitsLdPhi.push_back(itHit->localDirection().phi());
603 
604  HitsExPx.push_back(itHit->exitPoint().x());
605  HitsExPy.push_back(itHit->exitPoint().y());
606  HitsExPz.push_back(itHit->exitPoint().z());
607 
608  HitsEnPx.push_back(itHit->entryPoint().x());
609  HitsEnPy.push_back(itHit->entryPoint().y());
610  HitsEnPz.push_back(itHit->entryPoint().z());
611 
612  HitsEloss.push_back(itHit->energyLoss());
613  HitsToF.push_back(itHit->tof());
614 
615  } // end loop through PxlFwd Hits
616 
617  if (verbosity > 1) {
618  eventout += "\n Number of TIB low TOF Hits collected: ";
619  eventout += j;
620  }
621 
622 
623  // extract TIB high container
624  edm::Handle<edm::PSimHitContainer> SiTIBHighContainer;
625 // iEvent.getByLabel("g4SimHits","TrackerHitsTIBHighTof",SiTIBHighContainer);
626  iEvent.getByLabel(SiTIBHighSrc_,SiTIBHighContainer);
627  if (!SiTIBHighContainer.isValid()) {
628  edm::LogError("TrackerHitProducer::fillTrk")
629  << "Unable to find TrackerHitsTIBHighTof in event!";
630  return;
631  }
632 
633  sysID = 20; // TrackerHitsTIBHighTof
634  j = 0;
635  for (itHit = SiTIBHighContainer->begin(); itHit != SiTIBHighContainer->end(); ++itHit) {
636 
637  // gather necessary information
638  ++j;
639  HitsSysID.push_back(sysID);
640  HitsDuID.push_back(itHit->detUnitId());
641  HitsTkID.push_back(itHit->trackId());
642  HitsProT.push_back(itHit->processType());
643  HitsParT.push_back(itHit->particleType());
644  HitsP.push_back(itHit->pabs());
645 
646  HitsLpX.push_back(itHit->localPosition().x());
647  HitsLpY.push_back(itHit->localPosition().y());
648  HitsLpZ.push_back(itHit->localPosition().z());
649 
650  HitsLdX.push_back(itHit->localDirection().x());
651  HitsLdY.push_back(itHit->localDirection().y());
652  HitsLdZ.push_back(itHit->localDirection().z());
653  HitsLdTheta.push_back(itHit->localDirection().theta());
654  HitsLdPhi.push_back(itHit->localDirection().phi());
655 
656  HitsExPx.push_back(itHit->exitPoint().x());
657  HitsExPy.push_back(itHit->exitPoint().y());
658  HitsExPz.push_back(itHit->exitPoint().z());
659 
660  HitsEnPx.push_back(itHit->entryPoint().x());
661  HitsEnPy.push_back(itHit->entryPoint().y());
662  HitsEnPz.push_back(itHit->entryPoint().z());
663 
664  HitsEloss.push_back(itHit->energyLoss());
665  HitsToF.push_back(itHit->tof());
666 
667  } // end loop through PxlFwd Hits
668 
669  if (verbosity > 1) {
670  eventout += "\n Number of TIB high TOF Hits collected: ";
671  eventout += j;
672  }
673 
675  // get Silicon TOB information
677  // extract TOB low container
678  edm::Handle<edm::PSimHitContainer> SiTOBLowContainer;
679 // iEvent.getByLabel("g4SimHits","TrackerHitsTOBLowTof",SiTOBLowContainer);
680  iEvent.getByLabel(SiTOBLowSrc_,SiTOBLowContainer);
681  if (!SiTOBLowContainer.isValid()) {
682  edm::LogError("TrackerHitProducer::fillTrk")
683  << "Unable to find TrackerHitsTOBLowTof in event!";
684  return;
685  }
686 
687  sysID = 30; // TrackerHitsTOBLowTof
688  j = 0;
689  for (itHit = SiTOBLowContainer->begin(); itHit != SiTOBLowContainer->end(); ++itHit) {
690 
691  // gather necessary information
692  ++j;
693  HitsSysID.push_back(sysID);
694  HitsDuID.push_back(itHit->detUnitId());
695  HitsTkID.push_back(itHit->trackId());
696  HitsProT.push_back(itHit->processType());
697  HitsParT.push_back(itHit->particleType());
698  HitsP.push_back(itHit->pabs());
699 
700  HitsLpX.push_back(itHit->localPosition().x());
701  HitsLpY.push_back(itHit->localPosition().y());
702  HitsLpZ.push_back(itHit->localPosition().z());
703 
704  HitsLdX.push_back(itHit->localDirection().x());
705  HitsLdY.push_back(itHit->localDirection().y());
706  HitsLdZ.push_back(itHit->localDirection().z());
707  HitsLdTheta.push_back(itHit->localDirection().theta());
708  HitsLdPhi.push_back(itHit->localDirection().phi());
709 
710  HitsExPx.push_back(itHit->exitPoint().x());
711  HitsExPy.push_back(itHit->exitPoint().y());
712  HitsExPz.push_back(itHit->exitPoint().z());
713 
714  HitsEnPx.push_back(itHit->entryPoint().x());
715  HitsEnPy.push_back(itHit->entryPoint().y());
716  HitsEnPz.push_back(itHit->entryPoint().z());
717 
718  HitsEloss.push_back(itHit->energyLoss());
719  HitsToF.push_back(itHit->tof());
720 
721  } // end loop through PxlFwd Hits
722 
723  if (verbosity > 1) {
724  eventout += "\n Number of TOB low TOF Hits collected: ";
725  eventout += j;
726  }
727 
728  // extract TOB high container
729  edm::Handle<edm::PSimHitContainer> SiTOBHighContainer;
730 // iEvent.getByLabel("g4SimHits","TrackerHitsTOBHighTof",SiTOBHighContainer);
731  iEvent.getByLabel(SiTOBHighSrc_,SiTOBHighContainer);
732  if (!SiTOBHighContainer.isValid()) {
733  edm::LogError("TrackerHitProducer::fillTrk")
734  << "Unable to find TrackerHitsTOBHighTof in event!";
735  return;
736  }
737 
738  sysID = 40; // TrackerHitsTOBHighTof
739  j = 0;
740  for (itHit = SiTOBHighContainer->begin(); itHit != SiTOBHighContainer->end(); ++itHit) {
741 
742  // gather necessary information
743  ++j;
744  HitsSysID.push_back(sysID);
745  HitsDuID.push_back(itHit->detUnitId());
746  HitsTkID.push_back(itHit->trackId());
747  HitsProT.push_back(itHit->processType());
748  HitsParT.push_back(itHit->particleType());
749  HitsP.push_back(itHit->pabs());
750 
751  HitsLpX.push_back(itHit->localPosition().x());
752  HitsLpY.push_back(itHit->localPosition().y());
753  HitsLpZ.push_back(itHit->localPosition().z());
754 
755  HitsLdX.push_back(itHit->localDirection().x());
756  HitsLdY.push_back(itHit->localDirection().y());
757  HitsLdZ.push_back(itHit->localDirection().z());
758  HitsLdTheta.push_back(itHit->localDirection().theta());
759  HitsLdPhi.push_back(itHit->localDirection().phi());
760 
761  HitsExPx.push_back(itHit->exitPoint().x());
762  HitsExPy.push_back(itHit->exitPoint().y());
763  HitsExPz.push_back(itHit->exitPoint().z());
764 
765  HitsEnPx.push_back(itHit->entryPoint().x());
766  HitsEnPy.push_back(itHit->entryPoint().y());
767  HitsEnPz.push_back(itHit->entryPoint().z());
768 
769  HitsEloss.push_back(itHit->energyLoss());
770  HitsToF.push_back(itHit->tof());
771 
772  } // end loop through SiTOB Hits
773 
774  if (verbosity > 1) {
775  eventout += "\n Number of TOB high TOF Hits collected: ";
776  eventout += j;
777  }
778 
780  // get Silicon TID information
782  // extract TID low container
783  edm::Handle<edm::PSimHitContainer> SiTIDLowContainer;
784 // iEvent.getByLabel("g4SimHits","TrackerHitsTIDLowTof",SiTIDLowContainer);
785  iEvent.getByLabel(SiTIDLowSrc_,SiTIDLowContainer);
786  if (!SiTIDLowContainer.isValid()) {
787  edm::LogError("TrackerHitProducer::fillTrk")
788  << "Unable to find TrackerHitsTIDLowTof in event!";
789  return;
790  }
791 
792  sysID = 50; // TrackerHitsTIDLowTof
793  j = 0;
794  for (itHit = SiTIDLowContainer->begin(); itHit != SiTIDLowContainer->end(); ++itHit) {
795 
796  // gather necessary information
797  ++j;
798  HitsSysID.push_back(sysID);
799  HitsDuID.push_back(itHit->detUnitId());
800  HitsTkID.push_back(itHit->trackId());
801  HitsProT.push_back(itHit->processType());
802  HitsParT.push_back(itHit->particleType());
803  HitsP.push_back(itHit->pabs());
804 
805  HitsLpX.push_back(itHit->localPosition().x());
806  HitsLpY.push_back(itHit->localPosition().y());
807  HitsLpZ.push_back(itHit->localPosition().z());
808 
809  HitsLdX.push_back(itHit->localDirection().x());
810  HitsLdY.push_back(itHit->localDirection().y());
811  HitsLdZ.push_back(itHit->localDirection().z());
812  HitsLdTheta.push_back(itHit->localDirection().theta());
813  HitsLdPhi.push_back(itHit->localDirection().phi());
814 
815  HitsExPx.push_back(itHit->exitPoint().x());
816  HitsExPy.push_back(itHit->exitPoint().y());
817  HitsExPz.push_back(itHit->exitPoint().z());
818 
819  HitsEnPx.push_back(itHit->entryPoint().x());
820  HitsEnPy.push_back(itHit->entryPoint().y());
821  HitsEnPz.push_back(itHit->entryPoint().z());
822 
823  HitsEloss.push_back(itHit->energyLoss());
824  HitsToF.push_back(itHit->tof());
825 
826  } // end loop through SiTID Hits
827 
828  if (verbosity > 1) {
829  eventout += "\n Number of TID low TOF Hits collected: ";
830  eventout += j;
831  }
832 
833  // extract TID high container
834  edm::Handle<edm::PSimHitContainer> SiTIDHighContainer;
835 // iEvent.getByLabel("g4SimHits","TrackerHitsTIDHighTof",SiTIDHighContainer);
836  iEvent.getByLabel(SiTIDHighSrc_,SiTIDHighContainer);
837  if (!SiTIDHighContainer.isValid()) {
838  edm::LogError("TrackerHitProducer::fillTrk")
839  << "Unable to find TrackerHitsTIDHighTof in event!";
840  return;
841  }
842 
843  sysID = 60; // TrackerHitsTIDHighTof
844  j = 0;
845  for (itHit = SiTIDHighContainer->begin(); itHit != SiTIDHighContainer->end(); ++itHit) {
846 
847  // gather necessary information
848  ++j;
849  HitsSysID.push_back(sysID);
850  HitsDuID.push_back(itHit->detUnitId());
851  HitsTkID.push_back(itHit->trackId());
852  HitsProT.push_back(itHit->processType());
853  HitsParT.push_back(itHit->particleType());
854  HitsP.push_back(itHit->pabs());
855 
856  HitsLpX.push_back(itHit->localPosition().x());
857  HitsLpY.push_back(itHit->localPosition().y());
858  HitsLpZ.push_back(itHit->localPosition().z());
859 
860  HitsLdX.push_back(itHit->localDirection().x());
861  HitsLdY.push_back(itHit->localDirection().y());
862  HitsLdZ.push_back(itHit->localDirection().z());
863  HitsLdTheta.push_back(itHit->localDirection().theta());
864  HitsLdPhi.push_back(itHit->localDirection().phi());
865 
866  HitsExPx.push_back(itHit->exitPoint().x());
867  HitsExPy.push_back(itHit->exitPoint().y());
868  HitsExPz.push_back(itHit->exitPoint().z());
869 
870  HitsEnPx.push_back(itHit->entryPoint().x());
871  HitsEnPy.push_back(itHit->entryPoint().y());
872  HitsEnPz.push_back(itHit->entryPoint().z());
873 
874  HitsEloss.push_back(itHit->energyLoss());
875  HitsToF.push_back(itHit->tof());
876 
877  } // end loop through SiTID Hits
878 
879  if (verbosity > 1) {
880  eventout += "\n Number of TID high TOF Hits collected: ";
881  eventout += j;
882  }
883 
885  // get Silicon TEC information
887  // extract TEC low container
888  edm::Handle<edm::PSimHitContainer> SiTECLowContainer;
889 // iEvent.getByLabel("g4SimHits","TrackerHitsTECLowTof",SiTECLowContainer);
890  iEvent.getByLabel(SiTECLowSrc_,SiTECLowContainer);
891  if (!SiTECLowContainer.isValid()) {
892  edm::LogError("TrackerHitProducer::fillTrk")
893  << "Unable to find TrackerHitsTECLowTof in event!";
894  return;
895  }
896 
897  sysID = 70; // TrackerHitsTECLowTof
898  j = 0;
899  for (itHit = SiTECLowContainer->begin(); itHit != SiTECLowContainer->end(); ++itHit) {
900 
901  // gather necessary information
902  ++j;
903  HitsSysID.push_back(sysID);
904  HitsDuID.push_back(itHit->detUnitId());
905  HitsTkID.push_back(itHit->trackId());
906  HitsProT.push_back(itHit->processType());
907  HitsParT.push_back(itHit->particleType());
908  HitsP.push_back(itHit->pabs());
909 
910  HitsLpX.push_back(itHit->localPosition().x());
911  HitsLpY.push_back(itHit->localPosition().y());
912  HitsLpZ.push_back(itHit->localPosition().z());
913 
914  HitsLdX.push_back(itHit->localDirection().x());
915  HitsLdY.push_back(itHit->localDirection().y());
916  HitsLdZ.push_back(itHit->localDirection().z());
917  HitsLdTheta.push_back(itHit->localDirection().theta());
918  HitsLdPhi.push_back(itHit->localDirection().phi());
919 
920  HitsExPx.push_back(itHit->exitPoint().x());
921  HitsExPy.push_back(itHit->exitPoint().y());
922  HitsExPz.push_back(itHit->exitPoint().z());
923 
924  HitsEnPx.push_back(itHit->entryPoint().x());
925  HitsEnPy.push_back(itHit->entryPoint().y());
926  HitsEnPz.push_back(itHit->entryPoint().z());
927 
928  HitsEloss.push_back(itHit->energyLoss());
929  HitsToF.push_back(itHit->tof());
930 
931  } // end loop through SiTEC Hits
932 
933  if (verbosity > 1) {
934  eventout += "\n Number of TEC low TOF Hits collected: ";
935  eventout += j;
936  }
937 
938 
939  // extract TEC high container
940  edm::Handle<edm::PSimHitContainer> SiTECHighContainer;
941 // iEvent.getByLabel("g4SimHits","TrackerHitsTECHighTof",SiTECHighContainer);
942  iEvent.getByLabel(SiTECHighSrc_,SiTECHighContainer);
943  if (!SiTECHighContainer.isValid()) {
944  edm::LogError("TrackerHitProducer::fillTrk")
945  << "Unable to find TrackerHitsTECHighTof in event!";
946  return;
947  }
948  sysID = 80; // TrackerHitsTECHighTof
949  j = 0;
950  for (itHit = SiTECHighContainer->begin(); itHit != SiTECHighContainer->end(); ++itHit) {
951 
952  // gather necessary information
953  ++j;
954  HitsSysID.push_back(sysID);
955  HitsDuID.push_back(itHit->detUnitId());
956  HitsTkID.push_back(itHit->trackId());
957  HitsProT.push_back(itHit->processType());
958  HitsParT.push_back(itHit->particleType());
959  HitsP.push_back(itHit->pabs());
960 
961  HitsLpX.push_back(itHit->localPosition().x());
962  HitsLpY.push_back(itHit->localPosition().y());
963  HitsLpZ.push_back(itHit->localPosition().z());
964 
965  HitsLdX.push_back(itHit->localDirection().x());
966  HitsLdY.push_back(itHit->localDirection().y());
967  HitsLdZ.push_back(itHit->localDirection().z());
968  HitsLdTheta.push_back(itHit->localDirection().theta());
969  HitsLdPhi.push_back(itHit->localDirection().phi());
970 
971  HitsExPx.push_back(itHit->exitPoint().x());
972  HitsExPy.push_back(itHit->exitPoint().y());
973  HitsExPz.push_back(itHit->exitPoint().z());
974 
975  HitsEnPx.push_back(itHit->entryPoint().x());
976  HitsEnPy.push_back(itHit->entryPoint().y());
977  HitsEnPz.push_back(itHit->entryPoint().z());
978 
979  HitsEloss.push_back(itHit->energyLoss());
980  HitsToF.push_back(itHit->tof());
981 
982  } // end loop through SiTEC Hits
983 
984  if (verbosity > 1) {
985  eventout += "\n Number of TEC high TOF Hits collected: ";
986  eventout += j;
987  }
988 
989  if (verbosity > 0)
990  edm::LogInfo("TrackerHitProducer::fillTrk") << eventout;
991 
992  return;
993 }
994 
996 {
997 
998 /*
999  if (verbosity > 2) {
1000  TString eventout("\nnPxlBrlHits = ");
1001  eventout += PxlBrlToF.size();
1002  for (unsigned int i = 0; i < PxlBrlToF.size(); ++i) {
1003  eventout += "\n (tof,r,phi,eta) = (";
1004  eventout += PxlBrlToF[i];
1005  eventout += ", ";
1006  eventout += PxlBrlR[i];
1007  eventout += ", ";
1008  eventout += PxlBrlPhi[i];
1009  eventout += ", ";
1010  eventout += PxlBrlEta[i];
1011  eventout += ")";
1012  } // end PxlBrl output
1013  eventout += "\n nPxlFwdHits = ";
1014  eventout += PxlFwdToF.size();
1015  for (unsigned int i = 0; i < PxlFwdToF.size(); ++i) {
1016  eventout += "\n (tof,z,phi,eta) = (";
1017  eventout += PxlFwdToF[i];
1018  eventout += ", ";
1019  eventout += PxlFwdZ[i];
1020  eventout += ", ";
1021  eventout += PxlFwdPhi[i];
1022  eventout += ", ";
1023  eventout += PxlFwdEta[i];
1024  eventout += ")";
1025  } // end PxlFwd output
1026  eventout += "\n nSiBrlHits = ";
1027  eventout += SiBrlToF.size();
1028  for (unsigned int i = 0; i < SiBrlToF.size(); ++i) {
1029  eventout += "\n (tof,r,phi,eta) = (";
1030  eventout += SiBrlToF[i];
1031  eventout += ", ";
1032  eventout += SiBrlR[i];
1033  eventout += ", ";
1034  eventout += SiBrlPhi[i];
1035  eventout += ", ";
1036  eventout += SiBrlEta[i];
1037  eventout += ")";
1038  } // end SiBrl output
1039  eventout += "\n nSiFwdHits = ";
1040  eventout += SiFwdToF.size();
1041  for (unsigned int i = 0; i < SiFwdToF.size(); ++i) {
1042  eventout += "\n (tof,z,phi,eta) = (";
1043  eventout += SiFwdToF[i];
1044  eventout += ", ";
1045  eventout += SiFwdZ[i];
1046  eventout += ", ";
1047  eventout += SiFwdPhi[i];
1048  eventout += ", ";
1049  eventout += SiFwdEta[i];
1050  eventout += ")";
1051  } // end SiFwd output
1052  edm::LogInfo("TrackerHitProducer::storeTrk") << eventout;
1053  } // end verbose output
1054 */
1056  HitsLpX, HitsLpY, HitsLpZ,
1060  HitsEloss, HitsToF);
1061 
1062  return;
1063 }
1064 
1066 {
1067  if (verbosity > 0)
1068  edm::LogInfo("GlobalValProducer::clear")
1069  << "Clearing event holders";
1070 
1071  // reset G4MC info
1072  nRawGenPart = 0;
1073  G4VtxX.clear();
1074  G4VtxY.clear();
1075  G4VtxZ.clear();
1076  G4TrkPt.clear();
1077  G4TrkE.clear();
1078  G4TrkEta.clear();
1079  G4TrkPhi.clear();
1080  // reset tracker info
1081  HitsSysID.clear();
1082  HitsDuID.clear();
1083  HitsTkID.clear();
1084  HitsProT.clear();
1085  HitsParT.clear();
1086  HitsP.clear();
1087  HitsLpX.clear();
1088  HitsLpY.clear();
1089  HitsLpZ.clear();
1090  HitsLdX.clear();
1091  HitsLdY.clear();
1092  HitsLdZ.clear();
1093  HitsLdTheta.clear();
1094  HitsLdPhi.clear();
1095  HitsExPx.clear();
1096  HitsExPy.clear();
1097  HitsExPz.clear();
1098  HitsEnPx.clear();
1099  HitsEnPy.clear();
1100  HitsEnPz.clear();
1101  HitsEloss.clear();
1102  HitsToF.clear();
1103 
1104  return;
1105 }
1106 
1107 //define this as a plug-in
RunNumber_t run() const
Definition: EventID.h:42
void fillG4MC(edm::Event &)
void storeTrk(PTrackerSimHit &)
T getParameter(std::string const &) const
EventNumber_t event() const
Definition: EventID.h:44
edm::InputTag SiTIBHighSrc_
T getUntrackedParameter(std::string const &, T const &) const
void getAllProvenance(std::vector< Provenance const * > &provenances) const
Definition: Event.cc:70
int i
Definition: DBlmapReader.cc:9
edm::InputTag PxlFwdHighSrc_
void storeG4MC(PTrackerSimHit &)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void putRawGenPart(int n)
Geom::Theta< T > theta() const
void putG4Vtx(std::vector< float > x, std::vector< float > y, std::vector< float > z)
bool getByType(Handle< PROD > &result) const
Definition: Event.h:398
edm::InputTag PxlBrlHighSrc_
virtual void beginJob()
virtual void produce(edm::Event &, const edm::EventSetup &)
edm::InputTag SiTIDHighSrc_
TrackerHitProducer(const edm::ParameterSet &)
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
T sqrt(T t)
Definition: SSEVec.h:46
edm::InputTag PxlFwdLowSrc_
edm::InputTag SiTOBLowSrc_
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
edm::InputTag SiTECHighSrc_
int j
Definition: DBlmapReader.cc:9
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
void putHits(std::vector< int > _sysID, std::vector< float > _detUnitId, std::vector< float >_trackId, std::vector< float >_processType, std::vector< float >_particleType, std::vector< float > _pabs, std::vector< float >_lpx, std::vector< float >_lpy, std::vector< float >_lpz, std::vector< float >_ldx, std::vector< float >_ldy, std::vector< float >_ldz, std::vector< float >_ldtheta, std::vector< float >_ldphi, std::vector< float >_exx, std::vector< float >_exy, std::vector< float >_exz, std::vector< float >_enx, std::vector< float >_eny, std::vector< float >_enz, std::vector< float >_eloss, std::vector< float >_tof)
edm::InputTag PxlBrlLowSrc_
edm::InputTag SiTECLowSrc_
std::string const & label() const
Definition: InputTag.h:25
edm::EventID id() const
Definition: EventBase.h:56
edm::ParameterSet config_
void putG4Trk(std::vector< float > pt, std::vector< float > e, std::vector< float > eta, std::vector< float > phi)
std::string const & instance() const
Definition: InputTag.h:26
edm::InputTag SiTIDLowSrc_
void fillTrk(edm::Event &, const edm::EventSetup &)
edm::InputTag SiTOBHighSrc_
edm::InputTag SiTIBLowSrc_