CMS 3D CMS Logo

HcalTB04Analysis.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: HcalTestBeam
4 // Class : HcalTB04Analysis
5 //
6 // Implementation:
7 // Main analysis class for Hcal Test Beam 2004 Analysis
8 //
9 // Usage: A Simwatcher class and can be activated from Oscarproducer module
10 //
11 // Original Author:
12 // Created: Tue May 16 10:14:34 CEST 2006
13 //
14 
15 // system include files
16 #include <cmath>
17 #include <iomanip>
18 #include <iostream>
19 #include <memory>
20 #include <vector>
21 #include <string>
22 
23 // user include files
30 
31 // to retreive hits
42 
48 
52 
53 #include "G4SDManager.hh"
54 #include "G4Step.hh"
55 #include "G4Track.hh"
56 #include "G4ThreeVector.hh"
57 #include "G4VProcess.hh"
58 #include "G4HCofThisEvent.hh"
59 
60 #include <CLHEP/Random/RandGaussQ.h>
61 #include <CLHEP/Random/Randomize.h>
62 #include <CLHEP/Units/GlobalSystemOfUnits.h>
63 #include <CLHEP/Units/GlobalPhysicalConstants.h>
64 
65 #include <cstdint>
66 
67 //#define EDM_ML_DEBUG
68 
69 namespace CLHEP {
70  class HepRandomEngine;
71 }
72 
74  public Observer<const BeginOfRun*>,
75  public Observer<const BeginOfEvent*>,
76  public Observer<const EndOfEvent*>,
77  public Observer<const G4Step*> {
78 public:
80  HcalTB04Analysis(const HcalTB04Analysis&) = delete; // stop default
81  const HcalTB04Analysis& operator=(const HcalTB04Analysis&) = delete;
82  ~HcalTB04Analysis() override;
83 
84  void produce(edm::Event&, const edm::EventSetup&) override;
85 
86 private:
87  void init();
88 
89  // observer methods
90  void update(const BeginOfRun* run) override;
91  void update(const BeginOfEvent* evt) override;
92  void update(const G4Step* step) override;
93  void update(const EndOfEvent* evt) override;
94 
95  //User methods
96  void fillBuffer(const EndOfEvent* evt);
97  void qieAnalysis(CLHEP::HepRandomEngine*);
98  void xtalAnalysis(CLHEP::HepRandomEngine*);
99  void finalAnalysis();
100  void fillEvent(PHcalTB04Info&);
101 
102  void clear();
103  int unitID(uint32_t id);
104  double scale(int det, int layer);
105  double timeOfFlight(int det, int layer, double eta);
106 
107 private:
108  // to read from parameter set
110  const bool hcalOnly;
111  const int mode, type;
112  const double ecalNoise, beamOffset;
114  const std::vector<std::string> names;
115 
118 
119  int iceta, icphi;
120  G4RotationMatrix* beamline_RM;
121 
122  // Constants for the run
123  int count;
125  std::vector<int> idHcal, idXtal;
126  std::vector<uint32_t> idTower, idEcal;
127 
128  // Constants for the event
131  std::vector<CaloHit> ecalHitCache;
132  std::vector<CaloHit> hcalHitCache, hcalHitLayer;
133  std::vector<double> esimh, eqie, esime, enois;
134  std::vector<double> eseta, eqeta, esphi, eqphi, eslay, eqlay;
136 
137  bool pvFound;
138  int evNum, pvType;
139  G4ThreeVector pvPosition, pvMomentum, pvUVW;
140  std::vector<int> secTrackID, secPartID;
141  std::vector<G4ThreeVector> secMomentum;
142  std::vector<double> secEkin;
143  std::vector<int> shortLivedSecondaries;
144 };
145 
146 //
147 // constructors and destructor
148 //
149 
151  : m_Anal(p.getParameter<edm::ParameterSet>("HcalTB04Analysis")),
152  hcalOnly(m_Anal.getParameter<bool>("HcalOnly")),
153  mode(m_Anal.getParameter<int>("Mode")),
154  type(m_Anal.getParameter<int>("Type")),
155  ecalNoise(m_Anal.getParameter<double>("EcalNoise")),
156  beamOffset(-m_Anal.getParameter<double>("BeamPosition") * CLHEP::cm),
157  scaleHB0(m_Anal.getParameter<double>("ScaleHB0")),
158  scaleHB16(m_Anal.getParameter<double>("ScaleHB16")),
159  scaleHO(m_Anal.getParameter<double>("ScaleHO")),
160  scaleHE0(m_Anal.getParameter<double>("ScaleHE0")),
161  names(m_Anal.getParameter<std::vector<std::string> >("Names")),
162  myQie(nullptr),
163  histo(nullptr) {
164  double fMinEta = m_Anal.getParameter<double>("MinEta");
165  double fMaxEta = m_Anal.getParameter<double>("MaxEta");
166  double fMinPhi = m_Anal.getParameter<double>("MinPhi");
167  double fMaxPhi = m_Anal.getParameter<double>("MaxPhi");
168  double beamEta = (fMaxEta + fMinEta) / 2.;
169  double beamPhi = (fMaxPhi + fMinPhi) / 2.;
170  double beamThet = 2 * atan(exp(-beamEta));
171  if (beamPhi < 0)
172  beamPhi += twopi;
173  iceta = static_cast<int>(beamEta / 0.087) + 1;
174  icphi = static_cast<int>(std::fabs(beamPhi) / 0.087) + 5;
175  if (icphi > 72)
176  icphi -= 73;
177 
178  produces<PHcalTB04Info>();
179 
180  beamline_RM = new G4RotationMatrix;
181  beamline_RM->rotateZ(-beamPhi);
182  beamline_RM->rotateY(-beamThet);
183 
184  edm::LogVerbatim("HcalTBSim")
185  << "HcalTB04:: Initialised as observer of BeginOf Job/BeginOfRun/BeginOfEvent/G4Step/EndOfEvent with Parameter "
186  "values:\n \thcalOnly = "
187  << hcalOnly << "\tecalNoise = " << ecalNoise << "\n\tMode = " << mode << " (0: HB2 Standard; 1:HB2 Segmented)"
188  << "\tType = " << type << " (0: HB; 1 HE; 2 HB+HE)\n\tbeamOffset = " << beamOffset << "\ticeta = " << iceta
189  << "\ticphi = " << icphi << "\n\tbeamline_RM = " << *beamline_RM;
190 
191  init();
192 
193  myQie = new HcalQie(p);
194  histo = new HcalTB04Histo(m_Anal);
195 }
196 
198 #ifdef EDM_ML_DEBUG
199  edm::LogVerbatim("HcalTBSim") << "\n --------> Total number of selected entries : " << count << "\nPointers:: QIE "
200  << myQie << " Histo " << histo;
201 #endif
202  if (myQie) {
203  delete myQie;
204  myQie = nullptr;
205  }
206  if (histo) {
207  delete histo;
208  histo = nullptr;
209  }
210 }
211 
212 //
213 // member functions
214 //
215 
217  std::unique_ptr<PHcalTB04Info> product(new PHcalTB04Info);
218  fillEvent(*product);
219  e.put(std::move(product));
220 }
221 
224  nTower = idTower.size();
225 #ifdef EDM_ML_DEBUG
226  edm::LogVerbatim("HcalTBSim") << "HcalTB04Analysis:: Save information from " << nTower << " HCal towers";
227 #endif
228  idHcal.reserve(nTower);
229  for (int i = 0; i < nTower; i++) {
230  int id = unitID(idTower[i]);
231  idHcal.push_back(id);
232 #ifdef EDM_ML_DEBUG
233  edm::LogVerbatim("HcalTBSim") << "\tTower[" << i << "] Original " << std::hex << idTower[i] << " Stored "
234  << idHcal[i] << std::dec;
235 #endif
236  }
237 
238  if (!hcalOnly) {
239  int det = 10;
240  uint32_t id1;
241  nCrystal = 0;
242  for (int lay = 1; lay < 8; lay++) {
243  for (int icr = 1; icr < 8; icr++) {
244  id1 = HcalTestNumbering::packHcalIndex(det, 0, 1, icr, lay, 1);
245  int id = unitID(id1);
246  idEcal.push_back(id1);
247  idXtal.push_back(id);
248  nCrystal++;
249  }
250  }
251  edm::LogVerbatim("HcalTBSim") << "HcalTB04Analysis:: Save information from " << nCrystal << " ECal Crystals";
252 #ifdef EDM_ML_DEBUG
253  for (int i = 0; i < nCrystal; i++) {
254  edm::LogVerbatim("HcalTBSim") << "\tCrystal[" << i << "] Original " << std::hex << idEcal[i] << " Stored "
255  << idXtal[i] << std::dec;
256  }
257 #endif
258  }
259  // Profile vectors
260  eseta.reserve(5);
261  eqeta.reserve(5);
262  esphi.reserve(3);
263  eqphi.reserve(3);
264  eslay.reserve(20);
265  eqlay.reserve(20);
266  for (int i = 0; i < 5; i++) {
267  eseta.push_back(0.);
268  eqeta.push_back(0.);
269  }
270  for (int i = 0; i < 3; i++) {
271  esphi.push_back(0.);
272  eqphi.push_back(0.);
273  }
274  for (int i = 0; i < 20; i++) {
275  eslay.push_back(0.);
276  eqlay.push_back(0.);
277  }
278 
279  // counter
280  count = 0;
281  evNum = 0;
282  clear();
283 }
284 
286  int irun = (*run)()->GetRunID();
287  edm::LogVerbatim("HcalTBSim") << " =====> Begin of Run = " << irun;
288 
289  G4SDManager* sd = G4SDManager::GetSDMpointerIfExist();
290  if (sd != nullptr) {
291  std::string sdname = names[0];
292  G4VSensitiveDetector* aSD = sd->FindSensitiveDetector(sdname);
293  if (aSD == nullptr) {
294  edm::LogWarning("HcalTBSim") << "HcalTB04Analysis::beginOfRun: No SD"
295  << " with name " << sdname << " in this "
296  << "Setup";
297  } else {
298  HCalSD* theCaloSD = dynamic_cast<HCalSD*>(aSD);
299  edm::LogVerbatim("HcalTBSim") << "HcalTB04Analysis::beginOfRun: Finds SD with name " << theCaloSD->GetName()
300  << " in this Setup";
302  theCaloSD->setNumberingScheme(org);
303  edm::LogVerbatim("HcalTBSim") << "HcalTB04Analysis::beginOfRun: set a new numbering scheme";
304  }
305  if (!hcalOnly) {
306  sdname = names[1];
307  aSD = sd->FindSensitiveDetector(sdname);
308  if (aSD == nullptr) {
309  edm::LogWarning("HcalTBSim") << "HcalTB04Analysis::beginOfRun: No SD"
310  << " with name " << sdname << " in this "
311  << "Setup";
312  } else {
313  ECalSD* theCaloSD = dynamic_cast<ECalSD*>(aSD);
314  edm::LogVerbatim("HcalTBSim") << "HcalTB04Analysis::beginOfRun: Finds SD with name " << theCaloSD->GetName()
315  << " in this Setup";
317  theCaloSD->setNumberingScheme(org);
318  edm::LogVerbatim("HcalTBSim") << "HcalTB04Analysis::beginOfRun: set a new numbering scheme";
319  }
320  }
321  } else {
322  edm::LogWarning("HcalTBSim") << "HcalTB04Analysis::beginOfRun: Could "
323  << "not get SD Manager!";
324  }
325 }
326 
328  clear();
329 #ifdef EDM_ML_DEBUG
330  evNum = (*evt)()->GetEventID();
331  edm::LogVerbatim("HcalTBSim") << "HcalTB04Analysis: =====> Begin of event = " << evNum;
332 #endif
333 }
334 
335 void HcalTB04Analysis::update(const G4Step* aStep) {
336  if (aStep != nullptr) {
337  //Get Step properties
338  G4ThreeVector thePreStepPoint = aStep->GetPreStepPoint()->GetPosition();
339  G4ThreeVector thePostStepPoint;
340 
341  // Get Tracks properties
342  G4Track* aTrack = aStep->GetTrack();
343  int trackID = aTrack->GetTrackID();
344  int parentID = aTrack->GetParentID();
345  const G4ThreeVector& position = aTrack->GetPosition();
346  G4ThreeVector momentum = aTrack->GetMomentum();
347  G4String partType = aTrack->GetDefinition()->GetParticleType();
348  G4String partSubType = aTrack->GetDefinition()->GetParticleSubType();
349  int partPDGEncoding = aTrack->GetDefinition()->GetPDGEncoding();
350 #ifdef EDM_ML_DEBUG
351  bool isPDGStable = aTrack->GetDefinition()->GetPDGStable();
352 #endif
353  double pDGlifetime = aTrack->GetDefinition()->GetPDGLifeTime();
354  double gammaFactor = aStep->GetPreStepPoint()->GetGamma();
355 
356  if (!pvFound) { //search for v1
357  double stepDeltaEnergy = aStep->GetDeltaEnergy();
358  double kinEnergy = aTrack->GetKineticEnergy();
359 
360  // look for DeltaE > 10% kinEnergy of particle, or particle death - Ek=0
361  if (trackID == 1 && parentID == 0 && ((kinEnergy == 0.) || (std::fabs(stepDeltaEnergy / kinEnergy) > 0.1))) {
362  pvType = -1;
363  if (kinEnergy == 0.) {
364  pvType = 0;
365  } else {
366  if (std::fabs(stepDeltaEnergy / kinEnergy) > 0.1)
367  pvType = 1;
368  }
369  pvFound = true;
371  pvMomentum = momentum;
372  // Rotated coord.system:
373  pvUVW = (*beamline_RM) * (pvPosition);
374 
375  //Volume name requires some checks:
376  G4String thePostPVname = "NoName";
377  G4StepPoint* thePostPoint = aStep->GetPostStepPoint();
378  if (thePostPoint) {
379  thePostStepPoint = thePostPoint->GetPosition();
380  G4VPhysicalVolume* thePostPV = thePostPoint->GetPhysicalVolume();
381  if (thePostPV)
382  thePostPVname = thePostPV->GetName();
383  }
384 #ifdef EDM_ML_DEBUG
385  edm::LogVerbatim("HcalTBSim") << "HcalTB04Analysis:: V1 found at: " << thePostStepPoint
386  << " G4VPhysicalVolume: " << thePostPVname;
387  edm::LogVerbatim("HcalTBSim") << "HcalTB04Analysis::fill_v1Pos: Primary Track momentum: " << pvMomentum
388  << " psoition " << pvPosition << " u/v/w " << pvUVW;
389 #endif
390  }
391  } else {
392  // watch for secondaries originating @v1, including the surviving primary
393  if ((trackID != 1 && parentID == 1 && (aTrack->GetCurrentStepNumber() == 1) && (thePreStepPoint == pvPosition)) ||
394  (trackID == 1 && thePreStepPoint == pvPosition)) {
395 #ifdef EDM_ML_DEBUG
396  edm::LogVerbatim("HcalTBSim") << "HcalTB04Analysis::A secondary... PDG:" << partPDGEncoding
397  << " TrackID:" << trackID << " ParentID:" << parentID
398  << " stable: " << isPDGStable << " Tau: " << pDGlifetime
399  << " cTauGamma=" << c_light * pDGlifetime * gammaFactor * 1000.
400  << "um GammaFactor: " << gammaFactor;
401 #endif
402  secTrackID.push_back(trackID);
403  secPartID.push_back(partPDGEncoding);
404  secMomentum.push_back(momentum);
405  secEkin.push_back(aTrack->GetKineticEnergy());
406 
407  // Check for short-lived secondaries: cTauGamma<100um
408  double ctaugamma_um = CLHEP::c_light * pDGlifetime * gammaFactor * 1000.;
409  if ((ctaugamma_um > 0.) && (ctaugamma_um < 100.)) { //short-lived secondary
410  shortLivedSecondaries.push_back(trackID);
411  } else { //normal secondary - enter into the V1-calorimetric tree
412  // histos->fill_v1cSec (aTrack);
413  }
414  }
415  // Also watch for tertiary particles coming from
416  // short-lived secondaries from V1
417  if (aTrack->GetCurrentStepNumber() == 1) {
418  if (!shortLivedSecondaries.empty()) {
419  int pid = parentID;
420  std::vector<int>::iterator pos1 = shortLivedSecondaries.begin();
421  std::vector<int>::iterator pos2 = shortLivedSecondaries.end();
422  std::vector<int>::iterator pos;
423  for (pos = pos1; pos != pos2; pos++) {
424  if (*pos == pid) { //ParentID is on the list of short-lived
425  // secondary
426 #ifdef EDM_ML_DEBUG
427  edm::LogVerbatim("HcalTBSim")
428  << "HcalTB04Analysis:: A tertiary... PDG:" << partPDGEncoding << " TrackID:" << trackID
429  << " ParentID:" << parentID << " stable: " << isPDGStable << " Tau: " << pDGlifetime
430  << " cTauGamma=" << c_light * pDGlifetime * gammaFactor * 1000. << "um GammaFactor: " << gammaFactor;
431 #endif
432  }
433  }
434  }
435  }
436  }
437  }
438 }
439 
441  count++;
442 
443  //fill the buffer
444 #ifdef EDM_ML_DEBUG
445  edm::LogVerbatim("HcalTBSim") << "HcalTB04Analysis::Fill event " << (*evt)()->GetEventID();
446 #endif
447  fillBuffer(evt);
448 
449  //QIE analysis
450 #ifdef EDM_ML_DEBUG
451  edm::LogVerbatim("HcalTBSim") << "HcalTB04Analysis::Do QIE analysis with " << hcalHitCache.size() << " hits";
452 #endif
453  CLHEP::HepRandomEngine* engine = G4Random::getTheEngine();
454  qieAnalysis(engine);
455 
456  //Energy in Crystal Matrix
457  if (!hcalOnly) {
458 #ifdef EDM_ML_DEBUG
459  edm::LogVerbatim("HcalTBSim") << "HcalTB04Analysis::Do Xtal analysis with " << ecalHitCache.size() << " hits";
460 #endif
461  xtalAnalysis(engine);
462  }
463 
464  //Final Analysis
465 #ifdef EDM_ML_DEBUG
466  edm::LogVerbatim("HcalTBSim") << "HcalTB04Analysis::Final analysis";
467 #endif
468  finalAnalysis();
469 
470  int iEvt = (*evt)()->GetEventID();
471  if (iEvt < 10)
472  edm::LogVerbatim("HcalTBSim") << "HcalTB04Analysis:: Event " << iEvt;
473  else if ((iEvt < 100) && (iEvt % 10 == 0))
474  edm::LogVerbatim("HcalTBSim") << "HcalTB04Analysis:: Event " << iEvt;
475  else if ((iEvt < 1000) && (iEvt % 100 == 0))
476  edm::LogVerbatim("HcalTBSim") << "HcalTB04Analysis:: Event " << iEvt;
477  else if ((iEvt < 10000) && (iEvt % 1000 == 0))
478  edm::LogVerbatim("HcalTBSim") << "HcalTB04Analysis:: Event " << iEvt;
479 }
480 
482  std::vector<CaloHit> hhits, hhitl;
483  int idHC, j;
484  CaloG4HitCollection* theHC;
485  std::map<int, float, std::less<int> > primaries;
486 #ifdef EDM_ML_DEBUG
487  double etot1 = 0, etot2 = 0;
488 #endif
489 
490  // Look for the Hit Collection of HCal
491  G4HCofThisEvent* allHC = (*evt)()->GetHCofThisEvent();
492  std::string sdName = names[0];
493  idHC = G4SDManager::GetSDMpointer()->GetCollectionID(sdName);
494  theHC = (CaloG4HitCollection*)allHC->GetHC(idHC);
495 #ifdef EDM_ML_DEBUG
496  edm::LogVerbatim("HcalTBSim") << "HcalTB04Analysis:: Hit Collection for " << sdName << " of ID " << idHC
497  << " is obtained at " << theHC << " with " << theHC->entries() << " entries";
498 #endif
499  int thehc_entries = theHC->entries();
500  if (idHC >= 0 && theHC != nullptr) {
501  hhits.reserve(theHC->entries());
502  hhitl.reserve(theHC->entries());
503  for (j = 0; j < thehc_entries; j++) {
504  CaloG4Hit* aHit = (*theHC)[j];
505  double e = aHit->getEnergyDeposit() / CLHEP::GeV;
506  double time = aHit->getTimeSlice();
507  math::XYZPoint pos = aHit->getEntry();
508  unsigned int id = aHit->getUnitID();
509  double theta = pos.theta();
510  double eta = -std::log(std::tan(theta * 0.5));
511  double phi = pos.phi();
512  int det, z, group, ieta, iphi, layer;
514  double jitter = time - timeOfFlight(det, layer, eta);
515  if (jitter < 0)
516  jitter = 0;
517  if (e < 0 || e > 1.)
518  e = 0;
519  double escl = e * scale(det, layer);
520  unsigned int idx = HcalTBNumberingScheme::getUnitID(id, mode);
521  CaloHit hit(det, layer, escl, eta, phi, jitter, idx);
522  hhits.push_back(hit);
523  CaloHit hitl(det, layer, escl, eta, phi, jitter, id);
524  hhitl.push_back(hitl);
525  primaries[aHit->getTrackID()] += e;
526 #ifdef EDM_ML_DEBUG
527  etot1 += escl;
528  edm::LogVerbatim("HcalTBSim") << "HcalTB04Analysis:: Hcal Hit i/p " << j << " ID 0x" << std::hex << id << " 0x"
529  << idx << std::dec << " time " << std::setw(6) << time << " " << std::setw(6)
530  << jitter << " theta " << std::setw(8) << theta << " eta " << std::setw(8) << eta
531  << " phi " << std::setw(8) << phi << " e " << std::setw(8) << e << " "
532  << std::setw(8) << escl;
533 #endif
534  }
535  }
536 
537  // Add hits in the same channel within same time slice
538  std::vector<CaloHit>::iterator itr;
539  int nHit = hhits.size();
540  std::vector<CaloHit*> hits(nHit);
541  for (j = 0, itr = hhits.begin(); itr != hhits.end(); j++, itr++) {
542  hits[j] = &hhits[j];
543  }
544  sort(hits.begin(), hits.end(), CaloHitIdMore());
545  std::vector<CaloHit*>::iterator k1, k2;
546 #ifdef EDM_ML_DEBUG
547  int nhit = 0;
548 #endif
549  for (k1 = hits.begin(); k1 != hits.end(); k1++) {
550  int det = (**k1).det();
551  int layer = (**k1).layer();
552  double ehit = (**k1).e();
553  double eta = (**k1).eta();
554  double phi = (**k1).phi();
555  double jitter = (**k1).t();
556  uint32_t unitID = (**k1).id();
557  int jump = 0;
558  for (k2 = k1 + 1; k2 != hits.end() && std::fabs(jitter - (**k2).t()) < 1 && unitID == (**k2).id(); k2++) {
559  ehit += (**k2).e();
560  jump++;
561  }
562  CaloHit hit(det, layer, ehit, eta, phi, jitter, unitID);
563  hcalHitCache.push_back(hit);
564  k1 += jump;
565 #ifdef EDM_ML_DEBUG
566  nhit++;
567  etot2 += ehit;
568  edm::LogVerbatim("HcalTBSim") << "HcalTB04Analysis:: Hcal Hit store " << nhit << " ID 0x" << std::hex << unitID
569  << std::dec << " time " << std::setw(6) << jitter << " eta " << std::setw(8) << eta
570  << " phi " << std::setw(8) << phi << " e " << std::setw(8) << ehit;
571 #endif
572  }
573 #ifdef EDM_ML_DEBUG
574  edm::LogVerbatim("HcalTBSim") << "HcalTB04Analysis:: Stores " << nhit << " HCal hits from " << nHit
575  << " input hits E(Hcal) " << etot1 << " " << etot2;
576 #endif
577  //Repeat for Hit in each layer (hhits and hhitl sizes are the same)
578  for (j = 0, itr = hhitl.begin(); itr != hhitl.end(); j++, itr++) {
579  hits[j] = &hhitl[j];
580  }
581  sort(hits.begin(), hits.end(), CaloHitIdMore());
582 #ifdef EDM_ML_DEBUG
583  int nhitl = 0;
584  double etotl = 0;
585 #endif
586  for (k1 = hits.begin(); k1 != hits.end(); k1++) {
587  int det = (**k1).det();
588  int layer = (**k1).layer();
589  double ehit = (**k1).e();
590  double eta = (**k1).eta();
591  double phi = (**k1).phi();
592  double jitter = (**k1).t();
593  uint32_t unitID = (**k1).id();
594  int jump = 0;
595  for (k2 = k1 + 1; k2 != hits.end() && std::fabs(jitter - (**k2).t()) < 1 && unitID == (**k2).id(); k2++) {
596  ehit += (**k2).e();
597  jump++;
598  }
599  CaloHit hit(det, layer, ehit, eta, phi, jitter, unitID);
600  hcalHitLayer.push_back(hit);
601  k1 += jump;
602 #ifdef EDM_ML_DEBUG
603  nhitl++;
604  etotl += ehit;
605  edm::LogVerbatim("HcalTBSim") << "HcalTB04Analysis:: Hcal Hit store " << nhitl << " ID 0x" << std::hex << unitID
606  << std::dec << " time " << std::setw(6) << jitter << " eta " << std::setw(8) << eta
607  << " phi " << std::setw(8) << phi << " e " << std::setw(8) << ehit;
608 #endif
609  }
610 #ifdef EDM_ML_DEBUG
611  edm::LogVerbatim("HcalTBSim") << "HcalTB04Analysis:: Stores " << nhitl << " HCal hits from " << nHit
612  << " input hits E(Hcal) " << etot1 << " " << etotl;
613 #endif
614  // Look for the Hit Collection of ECal
615  std::vector<CaloHit> ehits;
616  sdName = names[1];
617  idHC = G4SDManager::GetSDMpointer()->GetCollectionID(sdName);
618  theHC = (CaloG4HitCollection*)allHC->GetHC(idHC);
619 #ifdef EDM_ML_DEBUG
620  etot1 = etot2 = 0;
621  edm::LogVerbatim("HcalTBSim") << "HcalTB04Analysis:: Hit Collection for " << sdName << " of ID " << idHC
622  << " is obtained at " << theHC << " with " << theHC->entries() << " entries";
623 #endif
624  if (idHC >= 0 && theHC != nullptr) {
625  thehc_entries = theHC->entries();
626  ehits.reserve(theHC->entries());
627  for (j = 0; j < thehc_entries; j++) {
628  CaloG4Hit* aHit = (*theHC)[j];
629  double e = aHit->getEnergyDeposit() / CLHEP::GeV;
630  double time = aHit->getTimeSlice();
631  if (e < 0 || e > 100000.)
632  e = 0;
633  if (e > 0) {
634  math::XYZPoint pos = aHit->getEntry();
635  unsigned int id = aHit->getUnitID();
636  double theta = pos.theta();
637  double eta = -std::log(std::tan(theta * 0.5));
638  double phi = pos.phi();
639  int det, z, group, ieta, iphi, layer;
641  CaloHit hit(det, 0, e, eta, phi, time, id);
642  ehits.push_back(hit);
643  primaries[aHit->getTrackID()] += e;
644 #ifdef EDM_ML_DEBUG
645  etot1 += e;
646  edm::LogVerbatim("HcalTBSim") << "HcalTB04Analysis:: Ecal Hit i/p " << j << " ID 0x" << std::hex << id
647  << std::dec << " time " << std::setw(6) << time << " theta " << std::setw(8)
648  << theta << " eta " << std::setw(8) << eta << " phi " << std::setw(8) << phi
649  << " e " << std::setw(8) << e;
650 #endif
651  }
652  }
653  }
654 
655  // Add hits in the same channel within same time slice
656  nHit = ehits.size();
657  std::vector<CaloHit*> hite(nHit);
658  for (j = 0, itr = ehits.begin(); itr != ehits.end(); j++, itr++) {
659  hite[j] = &ehits[j];
660  }
661  sort(hite.begin(), hite.end(), CaloHitIdMore());
662 #ifdef EDM_ML_DEBUG
663  nhit = 0;
664 #endif
665  for (k1 = hite.begin(); k1 != hite.end(); k1++) {
666  int det = (**k1).det();
667  int layer = (**k1).layer();
668  double ehit = (**k1).e();
669  double eta = (**k1).eta();
670  double phi = (**k1).phi();
671  double jitter = (**k1).t();
672  uint32_t unitID = (**k1).id();
673  int jump = 0;
674  for (k2 = k1 + 1; k2 != hite.end() && std::fabs(jitter - (**k2).t()) < 1 && unitID == (**k2).id(); k2++) {
675  ehit += (**k2).e();
676  jump++;
677  }
678  CaloHit hit(det, layer, ehit, eta, phi, jitter, unitID);
679  ecalHitCache.push_back(hit);
680  k1 += jump;
681 #ifdef EDM_ML_DEBUG
682  nhit++;
683  etot2 += ehit;
684  edm::LogVerbatim("HcalTBSim") << "HcalTB04Analysis:: Ecal Hit store " << nhit << " ID 0x" << std::hex << unitID
685  << std::dec << " time " << std::setw(6) << jitter << " eta " << std::setw(8) << eta
686  << " phi " << std::setw(8) << phi << " e " << std::setw(8) << ehit;
687 #endif
688  }
689 #ifdef EDM_ML_DEBUG
690  edm::LogVerbatim("HcalTBSim") << "HcalTB04Analysis:: Stores " << nhit << " ECal hits from " << nHit
691  << " input hits E(Ecal) " << etot1 << " " << etot2;
692 #endif
693  // Find Primary info:
694  nPrimary = static_cast<int>(primaries.size());
695  int trackID = 0;
696  G4PrimaryParticle* thePrim = nullptr;
697  int nvertex = (*evt)()->GetNumberOfPrimaryVertex();
698 #ifdef EDM_ML_DEBUG
699  edm::LogVerbatim("HcalTBSim") << "HcalTB04Analysis:: Event has " << nvertex << " verteices";
700 #endif
701  if (nvertex <= 0)
702  edm::LogWarning("HcalTBSim") << "HcalTB04Analysis::EndOfEvent ERROR: no vertex found for event " << evNum;
703  for (int i = 0; i < nvertex; i++) {
704  G4PrimaryVertex* avertex = (*evt)()->GetPrimaryVertex(i);
705  if (avertex == nullptr) {
706  edm::LogWarning("HcalTBSim") << "HcalTB04Analysis::EndOfEvent ERR: pointer to vertex = 0 for event " << evNum;
707  } else {
708  edm::LogVerbatim("HcalTBSim") << "HcalTB04Analysis::Vertex number :" << i << " " << avertex->GetPosition();
709  int npart = avertex->GetNumberOfParticle();
710  if (npart == 0)
711  edm::LogWarning("HcalTBSim") << "HcalTB04Analysis::End Of Event ERR: no primary!";
712  if (thePrim == nullptr)
713  thePrim = avertex->GetPrimary(trackID);
714  }
715  }
716 
717  if (thePrim != nullptr) {
718  double px = thePrim->GetPx();
719  double py = thePrim->GetPy();
720  double pz = thePrim->GetPz();
721  double p = std::sqrt(pow(px, 2.) + pow(py, 2.) + pow(pz, 2.));
722  pInit = p / CLHEP::GeV;
723  if (p == 0)
724  edm::LogWarning("HcalTBSim") << "HcalTB04Analysis:: EndOfEvent ERR: primary has p=0 ";
725  else {
726  double costheta = pz / p;
727  double theta = acos(std::min(std::max(costheta, -1.), 1.));
728  etaInit = -std::log(std::tan(theta / 2));
729  if (px != 0 || py != 0)
730  phiInit = std::atan2(py, px);
731  }
732  particleType = thePrim->GetPDGcode();
733  } else
734  edm::LogWarning("HcalTBSim") << "HcalTB04Analysis::EndOfEvent ERR: could not find primary";
735 }
736 
737 void HcalTB04Analysis::qieAnalysis(CLHEP::HepRandomEngine* engine) {
738  int hittot = hcalHitCache.size();
739  if (hittot <= 0)
740  hittot = 1;
741  std::vector<CaloHit> hits(hittot);
742  std::vector<int> todo(nTower, 0);
743 
744 #ifdef EDM_ML_DEBUG
745  edm::LogVerbatim("HcalTBSim") << "HcalTB04Analysis::qieAnalysis: Size " << hits.size() << " " << todo.size() << " "
746  << idTower.size() << " " << esimh.size() << " " << eqie.size();
747 #endif
748  // Loop over all HCal hits
749  for (unsigned int k1 = 0; k1 < hcalHitCache.size(); k1++) {
750  CaloHit hit = hcalHitCache[k1];
751  uint32_t id = hit.id();
752  int nhit = 0;
753  double esim = hit.e();
754  hits[nhit] = hit;
755  for (unsigned int k2 = k1 + 1; k2 < hcalHitCache.size(); k2++) {
756  hit = hcalHitCache[k2];
757  if (hit.id() == id) {
758  nhit++;
759  hits[nhit] = hit;
760  esim += hit.e();
761  }
762  }
763  k1 += nhit;
764  nhit++;
765  std::vector<int> cd = myQie->getCode(nhit, hits, engine);
766  double eq = myQie->getEnergy(cd);
767 #ifdef EDM_ML_DEBUG
768  edm::LogVerbatim("HcalTBSim") << "HcalTB04Analysis:: ID 0x" << std::hex << id << std::dec << " registers " << esim
769  << " energy from " << nhit << " hits starting with hit # " << k1
770  << " energy with noise " << eq;
771 #endif
772  for (int k2 = 0; k2 < nTower; k2++) {
773  if (id == idTower[k2]) {
774  todo[k2] = 1;
775  esimh[k2] = esim;
776  eqie[k2] = eq;
777  }
778  }
779  }
780 
781  // Towers with no hit
782  for (int k2 = 0; k2 < nTower; k2++) {
783  if (todo[k2] == 0) {
784  std::vector<int> cd = myQie->getCode(0, hits, engine);
785  double eq = myQie->getEnergy(cd);
786  esimh[k2] = 0;
787  eqie[k2] = eq;
788 #ifdef EDM_ML_DEBUG
789  edm::LogVerbatim("HcalTBSim") << "HcalTB04Analysis:: ID 0x" << std::hex << idTower[k2] << std::dec
790  << " registers " << esimh[k2] << " energy from hits and energy after QIE analysis "
791  << eqie[k2];
792 #endif
793  }
794  }
795 }
796 
797 void HcalTB04Analysis::xtalAnalysis(CLHEP::HepRandomEngine* engine) {
798  CLHEP::RandGaussQ randGauss(*engine);
799 
800  // Crystal Data
801  std::vector<int> iok(nCrystal, 0);
802 #ifdef EDM_ML_DEBUG
803  edm::LogVerbatim("HcalTBSim") << "HcalTB04Analysis::xtalAnalysis: Size " << iok.size() << " " << idEcal.size() << " "
804  << esime.size() << " " << enois.size();
805 #endif
806  for (unsigned int k1 = 0; k1 < ecalHitCache.size(); k1++) {
807  uint32_t id = ecalHitCache[k1].id();
808  int nhit = 0;
809  double esim = ecalHitCache[k1].e();
810  for (unsigned int k2 = k1 + 1; k2 < ecalHitCache.size(); k2++) {
811  if (ecalHitCache[k2].id() == id) {
812  nhit++;
813  esim += ecalHitCache[k2].e();
814  }
815  }
816  k1 += nhit;
817  nhit++;
818  double eq = esim + randGauss.fire(0., ecalNoise);
819 #ifdef EDM_ML_DEBUG
820  edm::LogVerbatim("HcalTBSim") << "HcalTB04Analysis:: ID 0x" << std::hex << id << std::dec << " registers " << esim
821  << " energy from " << nhit << " hits starting with hit # " << k1
822  << " energy with noise " << eq;
823 #endif
824  for (int k2 = 0; k2 < nCrystal; k2++) {
825  if (id == idEcal[k2]) {
826  iok[k2] = 1;
827  esime[k2] = esim;
828  enois[k2] = eq;
829  }
830  }
831  }
832 
833  // Crystals with no hit
834  for (int k2 = 0; k2 < nCrystal; k2++) {
835  if (iok[k2] == 0) {
836  esime[k2] = 0;
837  enois[k2] = randGauss.fire(0., ecalNoise);
838 #ifdef EDM_ML_DEBUG
839  edm::LogVerbatim("HcalTBSim") << "HcalTB04Analysis:: ID 0x" << std::hex << idEcal[k2] << std::dec
840  << " registers " << esime[k2] << " energy from hits and energy from noise "
841  << enois[k2];
842 #endif
843  }
844  }
845 }
846 
848  //Beam Information
850 
851  // Total Energy
852  eecals = ehcals = eecalq = ehcalq = 0.;
853  for (int i = 0; i < nTower; i++) {
854  ehcals += esimh[i];
855  ehcalq += eqie[i];
856  }
857  for (int i = 0; i < nCrystal; i++) {
858  eecals += esime[i];
859  eecalq += enois[i];
860  }
861  etots = eecals + ehcals;
862  etotq = eecalq + ehcalq;
863 #ifdef EDM_ML_DEBUG
864  edm::LogVerbatim("HcalTBSim") << "HcalTB04Analysis:: Energy deposit at Sim Level (Total) " << etots << " (ECal) "
865  << eecals << " (HCal) " << ehcals
866  << "\nHcalTB04Analysis:: Energy deposit at Qie Level (Total) " << etotq << " (ECal) "
867  << eecalq << " (HCal) " << ehcalq;
868 #endif
870 
871  // Lateral Profile
872  for (int i = 0; i < 5; i++) {
873  eseta[i] = 0.;
874  eqeta[i] = 0.;
875  }
876  for (int i = 0; i < 3; i++) {
877  esphi[i] = 0.;
878  eqphi[i] = 0.;
879  }
880  double e1 = 0, e2 = 0;
881  unsigned int id;
882  for (int i = 0; i < nTower; i++) {
883  int det, z, group, ieta, iphi, layer;
884  id = idTower[i];
886  iphi -= (icphi - 1);
887  if (icphi > 4) {
888  if (ieta == 0)
889  ieta = 2;
890  else
891  ieta = -1;
892  } else {
893  ieta = ieta - iceta + 2;
894  }
895  if (iphi >= 0 && iphi < 3 && ieta >= 0 && ieta < 5) {
896  eseta[ieta] += esimh[i];
897  esphi[iphi] += esimh[i];
898  e1 += esimh[i];
899  eqeta[ieta] += eqie[i];
900  eqphi[iphi] += eqie[i];
901  e2 += eqie[i];
902  }
903  }
904  for (int i = 0; i < 3; i++) {
905  if (e1 > 0)
906  esphi[i] /= e1;
907  if (e2 > 0)
908  eqphi[i] /= e2;
909  }
910  for (int i = 0; i < 5; i++) {
911  if (e1 > 0)
912  eseta[i] /= e1;
913  if (e2 > 0)
914  eqeta[i] /= e2;
915  }
916 #ifdef EDM_ML_DEBUG
917  edm::LogVerbatim("HcalTBSim") << "HcalTB04Analysis:: Energy fraction along Eta and Phi (Sim/Qie)";
918  for (int i = 0; i < 5; i++)
919  edm::LogVerbatim("HcalTBSim") << "HcalTB04Analysis:: [" << i << "] Eta Sim = " << eseta[i] << " Qie = " << eqeta[i]
920  << " Phi Sim = " << esphi[i] << " Qie = " << eqphi[i];
921 #endif
923 
924  // Longitudianl profile
925  for (int i = 0; i < 20; i++) {
926  eslay[i] = 0.;
927  eqlay[i] = 0.;
928  }
929  e1 = 0;
930  e2 = 0;
931  for (int i = 0; i < nTower; i++) {
932  int det, z, group, ieta, iphi, layer;
933  id = idTower[i];
935  iphi -= (icphi - 1);
936  layer -= 1;
937  if (iphi >= 0 && iphi < 3 && layer >= 0 && layer < 20) {
938  eslay[layer] += esimh[i];
939  e1 += esimh[i];
940  eqlay[layer] += eqie[i];
941  e2 += eqie[i];
942  }
943  }
944  for (int i = 0; i < 20; i++) {
945  if (e1 > 0)
946  eslay[i] /= e1;
947  if (e2 > 0)
948  eqlay[i] /= e2;
949  }
950 #ifdef EDM_ML_DEBUG
951  edm::LogVerbatim("HcalTBSim") << "HcalTB04Analysis:: Energy fraction along Layer";
952  for (int i = 0; i < 20; i++)
953  edm::LogVerbatim("HcalTBSim") << "HcalTB04Analysis:: [" << i << "] Sim = " << eslay[i] << " Qie = " << eqlay[i];
954 #endif
956 }
957 
959  //Setup the ID's
960  product.setIDs(idHcal, idXtal);
961 
962  //Beam Information
964 
965  //Energy deposits in the crystals and towers
966  product.setEdepHcal(esimh, eqie);
967  product.setEdepHcal(esime, enois);
968 
969  // Total Energy
970  product.setEdep(etots, eecals, ehcals, etotq, eecalq, ehcalq);
971 
972  // Lateral Profile
973  product.setTrnsProf(eseta, eqeta, esphi, eqphi);
974 
975  // Longitudianl profile
976  product.setLongProf(eslay, eqlay);
977 
978  //Save Hits
979  int nhit = 0;
980  std::vector<CaloHit>::iterator itr;
981  for (itr = ecalHitCache.begin(); itr != ecalHitCache.end(); itr++) {
982  uint32_t id = itr->id();
983  int det, z, group, ieta, iphi, lay;
985  product.saveHit(det, lay, ieta, iphi, itr->e(), itr->t());
986  nhit++;
987 #ifdef EDM_ML_DEBUG
988  edm::LogVerbatim("HcalTBSim") << "HcalTB04Analysis:: Save Hit " << std::setw(3) << nhit << " ID 0x" << std::hex
989  << group << std::dec << " " << std::setw(2) << det << " " << std::setw(2) << lay
990  << " " << std::setw(1) << z << " " << std::setw(3) << ieta << " " << std::setw(3)
991  << iphi << " T " << std::setw(6) << itr->t() << " E " << std::setw(6) << itr->e();
992 #endif
993  }
994  edm::LogVerbatim("HcalTBSim") << "HcalTB04Analysis:: Saves " << nhit << " hits from Crystals";
995 #ifdef EDM_ML_DEBUG
996  int nhit0 = nhit;
997 #endif
998  nhit = 0;
999  for (itr = hcalHitCache.begin(); itr != hcalHitCache.end(); itr++) {
1000  uint32_t id = itr->id();
1001  int det, z, group, ieta, iphi, lay;
1003  product.saveHit(det, lay, ieta, iphi, itr->e(), itr->t());
1004  nhit++;
1005 #ifdef EDM_ML_DEBUG
1006  edm::LogVerbatim("HcalTBSim") << "HcalTB04Analysis:: Save Hit " << std::setw(3) << nhit + nhit0 << " ID 0x"
1007  << std::hex << group << std::dec << " " << std::setw(2) << det << " " << std::setw(2)
1008  << lay << " " << std::setw(1) << z << " " << std::setw(3) << ieta << " "
1009  << std::setw(3) << iphi << " T " << std::setw(6) << itr->t() << " E " << std::setw(6)
1010  << itr->e();
1011 #endif
1012  }
1013  edm::LogVerbatim("HcalTBSim") << "HcalTB04Analysis:: Saves " << nhit << " hits from HCal";
1014 
1015  //Vertex associated quantities
1016  product.setVtxPrim(evNum,
1017  pvType,
1018  pvPosition.x(),
1019  pvPosition.y(),
1020  pvPosition.z(),
1021  pvUVW.x(),
1022  pvUVW.y(),
1023  pvUVW.z(),
1024  pvMomentum.x(),
1025  pvMomentum.y(),
1026  pvMomentum.z());
1027  for (unsigned int i = 0; i < secTrackID.size(); i++) {
1028  product.setVtxSec(
1030  }
1031 }
1032 
1034  pvFound = false;
1035  pvType = -2;
1036  pvPosition = G4ThreeVector();
1037  pvMomentum = G4ThreeVector();
1038  pvUVW = G4ThreeVector();
1039  secTrackID.clear();
1040  secPartID.clear();
1041  secMomentum.clear();
1042  secEkin.clear();
1043  shortLivedSecondaries.clear();
1044 
1045  ecalHitCache.erase(ecalHitCache.begin(), ecalHitCache.end());
1046  hcalHitCache.erase(hcalHitCache.begin(), hcalHitCache.end());
1047  hcalHitLayer.erase(hcalHitLayer.begin(), hcalHitLayer.end());
1048  nPrimary = particleType = 0;
1049  pInit = etaInit = phiInit = 0;
1050 
1051  esimh.clear();
1052  eqie.clear();
1053  esimh.reserve(nTower);
1054  eqie.reserve(nTower);
1055  for (int i = 0; i < nTower; i++) {
1056  esimh.push_back(0.);
1057  eqie.push_back(0.);
1058  }
1059  esime.clear();
1060  enois.clear();
1061  esime.reserve(nCrystal);
1062  enois.reserve(nCrystal);
1063  for (int i = 0; i < nCrystal; i++) {
1064  esime.push_back(0.);
1065  enois.push_back(0.);
1066  }
1067 }
1068 
1069 int HcalTB04Analysis::unitID(uint32_t id) {
1070  int det, z, group, ieta, iphi, lay;
1072  group = (det & 15) << 20;
1073  group += ((lay - 1) & 31) << 15;
1074  group += (z & 1) << 14;
1075  group += (ieta & 127) << 7;
1076  group += (iphi & 127);
1077  return group;
1078 }
1079 
1080 double HcalTB04Analysis::scale(int det, int layer) {
1081  double tmp = 1.;
1082  if (det == static_cast<int>(HcalBarrel)) {
1083  if (layer == 1)
1084  tmp = scaleHB0;
1085  else if (layer == 17)
1086  tmp = scaleHB16;
1087  else if (layer > 17)
1088  tmp = scaleHO;
1089  } else {
1090  if (layer <= 2)
1091  tmp = scaleHE0;
1092  }
1093  return tmp;
1094 }
1095 
1096 double HcalTB04Analysis::timeOfFlight(int det, int layer, double eta) {
1097  double theta = 2.0 * std::atan(std::exp(-eta));
1098  double dist = beamOffset;
1099  if (det == static_cast<int>(HcalBarrel)) {
1100  const double rLay[19] = {1836.0,
1101  1902.0,
1102  1962.0,
1103  2022.0,
1104  2082.0,
1105  2142.0,
1106  2202.0,
1107  2262.0,
1108  2322.0,
1109  2382.0,
1110  2448.0,
1111  2514.0,
1112  2580.0,
1113  2646.0,
1114  2712.0,
1115  2776.0,
1116  2862.5,
1117  3847.0,
1118  4052.0};
1119  if (layer > 0 && layer <= 19)
1120  dist += rLay[layer - 1] * mm / sin(theta);
1121  } else {
1122  const double zLay[19] = {4034.0,
1123  4032.0,
1124  4123.0,
1125  4210.0,
1126  4297.0,
1127  4384.0,
1128  4471.0,
1129  4558.0,
1130  4645.0,
1131  4732.0,
1132  4819.0,
1133  4906.0,
1134  4993.0,
1135  5080.0,
1136  5167.0,
1137  5254.0,
1138  5341.0,
1139  5428.0,
1140  5515.0};
1141  if (layer > 0 && layer <= 19)
1142  dist += zLay[layer - 1] * mm / cos(theta);
1143  }
1144 
1145  double tmp = dist / c_light / ns;
1146 #ifdef EDM_ML_DEBUG
1147  edm::LogVerbatim("HcalTBSim") << "HcalTB04Analysis::timeOfFlight " << tmp << " for det/lay " << det << " " << layer
1148  << " eta/theta " << eta << " " << theta / deg << " dist " << dist;
1149 #endif
1150  return tmp;
1151 }
1152 
Log< level::Info, true > LogVerbatim
int getTrackID() const
Definition: CaloG4Hit.h:64
#define DEFINE_SIMWATCHER(type)
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const double beamOffset
std::vector< double > secEkin
void setLongProf(const std::vector< double > &es, const std::vector< double > &eq)
const double scaleHB16
std::vector< int > idHcal
void fillPrimary(double energy, double eta, double phi)
std::vector< CaloHit > hcalHitLayer
std::vector< double > eqeta
std::vector< double > eqie
void fillTrnsProf(const std::vector< double > &es1, const std::vector< double > &eq1, const std::vector< double > &es2, const std::vector< double > &eq2)
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
void fillBuffer(const EndOfEvent *evt)
std::vector< int > shortLivedSecondaries
std::vector< int > secTrackID
constexpr int pow(int x)
Definition: conifer.h:24
double npart
Definition: HydjetWrapper.h:48
std::vector< double > eqphi
void setPrimary(int primary, int id, double energy, double eta, double phi)
const edm::ParameterSet m_Anal
void setNumberingScheme(HcalNumberingScheme *)
Definition: HCalSD.cc:566
const double scaleHE0
void update(const BeginOfRun *run) override
This routine will be called when the appropriate signal arrives.
const std::string names[nVars_]
void setEdep(double simtot, double sime, double simh, double digtot, double dige, double digh)
void setTrnsProf(const std::vector< double > &es1, const std::vector< double > &eq1, const std::vector< double > &es2, const std::vector< double > &eq2)
void saveHit(int det, int lay, int eta, int phi, double e, double t)
std::vector< int > secPartID
const double scaleHB0
Definition: HCalSD.h:38
static uint32_t packHcalIndex(int det, int z, int depth, int eta, int phi, int lay)
std::vector< uint32_t > idEcal
std::vector< double > eseta
math::XYZPoint getEntry() const
Definition: CaloG4Hit.h:46
void setIDs(const std::vector< int > &, const std::vector< int > &)
void setVtxSec(int id, int pdg, double px, double py, double pz, double ek)
G4ThreeVector pvUVW
void setEdepHcal(const std::vector< double > &esim, const std::vector< double > &edig)
double getEnergy(const std::vector< int > &)
Definition: HcalQie.cc:356
T sqrt(T t)
Definition: SSEVec.h:19
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
static void unpackHcalIndex(const uint32_t &idx, int &det, int &z, int &depth, int &eta, int &phi, int &lay)
G4RotationMatrix * beamline_RM
std::vector< double > esime
static std::vector< uint32_t > getUnitIDs(const int type, const int mode)
double scale(int det, int layer)
std::vector< double > esphi
double timeOfFlight(int det, int layer, double eta)
const std::vector< std::string > names
unsigned int id
Definition: ECalSD.h:31
std::vector< CaloHit > hcalHitCache
void xtalAnalysis(CLHEP::HepRandomEngine *)
static uint32_t getUnitID(const uint32_t id, const int mode)
HcalTB04Analysis(const edm::ParameterSet &p)
~HcalTB04Analysis() override
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
std::vector< int > idXtal
std::vector< CaloHit > ecalHitCache
double getEnergyDeposit() const
Definition: CaloG4Hit.h:79
uint32_t getUnitID() const
Definition: CaloG4Hit.h:66
std::vector< double > enois
void setVtxPrim(int evNum, int type, double x, double y, double z, double u, double v, double w, double px, double py, double pz)
std::vector< G4ThreeVector > secMomentum
int unitID(uint32_t id)
HcalTB04Histo * histo
std::vector< int > getCode(int, const std::vector< CaloHit > &, CLHEP::HepRandomEngine *)
Definition: HcalQie.cc:268
HLT enums.
const double scaleHO
G4THitsCollection< CaloG4Hit > CaloG4HitCollection
static int position[264][3]
Definition: ReadPGInfo.cc:289
double getTimeSlice() const
Definition: CaloG4Hit.h:67
G4ThreeVector pvMomentum
std::vector< uint32_t > idTower
void qieAnalysis(CLHEP::HepRandomEngine *)
std::vector< double > eslay
std::vector< double > eqlay
step
Definition: StallMonitor.cc:98
Log< level::Warning, false > LogWarning
G4ThreeVector pvPosition
void setNumberingScheme(EcalNumberingScheme *)
Definition: ECalSD.cc:329
tmp
align.sh
Definition: createJobs.py:716
Geom::Theta< T > theta() const
def move(src, dest)
Definition: eostools.py:511
void fillEdep(double etots, double eecals, double ehcals, double etotq, double eecalq, double ehcalq)
void fillEvent(PHcalTB04Info &)
const HcalTB04Analysis & operator=(const HcalTB04Analysis &)=delete
const double ecalNoise
std::vector< double > esimh
void fillLongProf(const std::vector< double > &es, const std::vector< double > &eq)
void produce(edm::Event &, const edm::EventSetup &) override