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