CMS 3D CMS Logo

HcalTestAnalysis.cc
Go to the documentation of this file.
5 
6 // to retreive hits
13 
18 
19 #include "G4SDManager.hh"
20 #include "G4Step.hh"
21 #include "G4Track.hh"
22 #include "G4VProcess.hh"
23 #include "G4HCofThisEvent.hh"
24 #include "CLHEP/Units/GlobalSystemOfUnits.h"
25 #include "CLHEP/Units/GlobalPhysicalConstants.h"
26 #include "Randomize.hh"
27 
28 #include <cmath>
29 #include <iostream>
30 #include <iomanip>
31 
33  addTower(3),tuples(nullptr),numberingFromDDD(nullptr),hcons(nullptr),org(nullptr) {
34 
35  edm::ParameterSet m_Anal = p.getParameter<edm::ParameterSet>("HcalTestAnalysis");
36  eta0 = m_Anal.getParameter<double>("Eta0");
37  phi0 = m_Anal.getParameter<double>("Phi0");
38  int laygroup = m_Anal.getParameter<int>("LayerGrouping");
39  centralTower = m_Anal.getParameter<int>("CentralTower");
40  names = m_Anal.getParameter<std::vector<std::string> >("Names");
41  fileName = m_Anal.getParameter<std::string>("FileName");
42 
43  tuplesManager.reset(nullptr);
44  edm::LogInfo("HcalSim") << "HcalTestAnalysis:: Initialised as observer of "
45  << "begin/end events and of G4step";
46 
47  count = 0;
48  group_ = layerGrouping(laygroup);
49  nGroup = 0;
50  for (unsigned int i=0; i<group_.size(); i++)
51  if (group_[i]>nGroup) nGroup = group_[i];
52  tower_ = towersToAdd(centralTower, addTower);
53  nTower = tower_.size()/2;
54 
55  edm::LogInfo("HcalSim") << "HcalTestAnalysis:: initialised for " << nGroup
56  << " Longitudinal groups and " << nTower
57  << " towers";
58 
59  // qie
60  myqie = new HcalQie(p);
61 }
62 
64  edm::LogInfo("HcalSim") << "HcalTestAnalysis: --------> Total number of "
65  << "selected entries : " << count;
66  edm::LogInfo("HcalSim") << "HcalTestAnalysis: Pointers:: HcalQie " << myqie
67  << ", HistoClass " << tuples << ", Numbering Scheme "
68  << org << " and FromDDD " << numberingFromDDD;
69  if (myqie) {
70  edm::LogInfo("HcalSim") << "HcalTestAnalysis: Delete HcalQie";
71  delete myqie;
72  }
73  if (numberingFromDDD) {
74  edm::LogInfo("HcalSim") << "HcalTestAnalysis: Delete HcalNumberingFromDDD";
75  delete numberingFromDDD;
76  }
77 }
78 
79 std::vector<int> HcalTestAnalysis::layerGrouping(int group) {
80 
81  std::vector<int> temp(19);
82  if (group <= 1) {
83  int grp[19] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2};
84  for (int i=0; i<19; i++)
85  temp[i] = grp[i];
86  } else if (group == 2) {
87  int grp[19] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19};
88  for (int i=0; i<19; i++)
89  temp[i] = grp[i];
90  } else if (group == 3) {
91  int grp[19] = {1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7};
92  for (int i=0; i<19; i++)
93  temp[i] = grp[i];
94  } else if (group == 4) {
95  int grp[19] = {1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7};
96  for (int i=0; i<19; i++)
97  temp[i] = grp[i];
98  } else {
99  int grp[19] = {1, 1, 2, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7};
100  for (int i=0; i<19; i++)
101  temp[i] = grp[i];
102  }
103 
104  edm::LogInfo("HcalSim") << "HcalTestAnalysis:: Layer Grouping ";
105  for (int i=0; i<19; i++)
106  edm::LogInfo("HcalSim") << "HcalTestAnalysis: Group[" << i << "] = "
107  << temp[i];
108  return temp;
109 }
110 
111 std::vector<int> HcalTestAnalysis::towersToAdd(int centre, int nadd) {
112 
113  int etac = (centre/100)%100;
114  int phic = (centre%100);
115  int etamin, etamax, phimin, phimax;
116  if (etac>0) {
117  etamin = etac-nadd;
118  etamax = etac+nadd;
119  } else {
120  etamin = etac;
121  etamax = etac;
122  }
123  if (phic>0) {
124  phimin = phic-nadd;
125  phimax = phic+nadd;
126  } else {
127  phimin = phic;
128  phimax = phic;
129  }
130 
131  int nbuf, kount=0;
132  nbuf = (etamax-etamin+1)*(phimax-phimin+1);
133  std::vector<int> temp(2*nbuf);
134  for (int eta=etamin; eta<=etamax; eta++) {
135  for (int phi=phimin; phi<=phimax; phi++) {
136  temp[kount] = (eta*100 + phi);
137  temp[kount+nbuf] = std::max(abs(eta-etac),abs(phi-phic));
138  kount++;
139  }
140  }
141 
142  edm::LogInfo("HcalSim") << "HcalTestAnalysis:: Towers to be considered for"
143  << " Central " << centre << " and " << nadd
144  << " on either side";
145  for (int i=0; i<nbuf; i++)
146  edm::LogInfo("HcalSim") << "HcalTestAnalysis: Tower[" << std::setw(3) << i
147  << "] " << temp[i] << " " << temp[nbuf+i];
148  return temp;
149 }
150 
151 //==================================================================== per JOB
152 
154 
155  // Numbering From DDD
157  (*job)()->get<HcalSimNumberingRecord>().get(hdc);
158  if(!hcons) { hcons = (HcalDDDSimConstants*)(&(*hdc)); }
159  //if(!hcons) { hcons = &(*hdc); }
160  edm::LogInfo("HcalSim") << "HcalTestAnalysis:: Initialise "
161  << "HcalNumberingFromDDD for " << names[0];
163 
164  // Ntuples
166 
167  // Numbering scheme
168  org = new HcalTestNumberingScheme(false);
169 
170 }
171 
172 //==================================================================== per RUN
174 
175  int irun = (*run)()->GetRunID();
176  edm::LogInfo("HcalSim") << "HcalTestAnalysis:: Begin of Run = " << irun;
177 
178  bool loop = true, eta = true, phi = true;
179  int etac = (centralTower/100)%100;
180  if (etac == 0) {
181  etac = 1;
182  eta = false;
183  }
184  int phic = (centralTower%100);
185  if (phic == 0) {
186  phic = 1;
187  phi = false;
188  }
189  int idet = static_cast<int>(HcalBarrel);
190  while (loop) {
191  HcalCellType::HcalCell tmp = hcons->cell(idet,1,1,etac,phic);
192  if (tmp.ok) {
193  if (eta) eta0 = tmp.eta;
194  if (phi) phi0 = tmp.phi;
195  loop = false;
196  } else if (idet == static_cast<int>(HcalBarrel)) {
197  idet = static_cast<int>(HcalEndcap);
198  } else if (idet == static_cast<int>(HcalEndcap)) {
199  idet = static_cast<int>(HcalForward);
200  } else {
201  loop = false;
202  }
203  }
204 
205  edm::LogInfo("HcalSim") << "HcalTestAnalysis:: Central Tower "
206  << centralTower << " corresponds to eta0 = " << eta0
207  << " phi0 = " << phi0;
208 
209  std::string sdname = names[0];
210  G4SDManager* sd = G4SDManager::GetSDMpointerIfExist();
211  if (sd != nullptr) {
212  G4VSensitiveDetector* aSD = sd->FindSensitiveDetector(sdname);
213  if (aSD==nullptr) {
214  edm::LogWarning("HcalSim") << "HcalTestAnalysis::beginOfRun: No SD with "
215  << "name " << sdname << " in this Setup";
216  } else {
217  HCalSD* theCaloSD = dynamic_cast<HCalSD*>(aSD);
218  edm::LogInfo("HcalSim") << "HcalTestAnalysis::beginOfRun: Finds SD with "
219  << "name " << theCaloSD->GetName()
220  << " in this Setup";
221  if (org) {
222  theCaloSD->setNumberingScheme(org);
223  edm::LogInfo("HcalSim") << "HcalTestAnalysis::beginOfRun: set a new "
224  << "numbering scheme";
225  }
226  }
227  } else {
228  edm::LogWarning("HcalSim") << "HcalTestAnalysis::beginOfRun: Could not get"
229  << " SD Manager!";
230  }
231 
232 }
233 
234 //=================================================================== per EVENT
236 
237  // create tuple object
238  tuples = new HcalTestHistoClass();
239  // Reset counters
240  tuples->setCounters();
241 
242  int i = 0;
243  edepEB = edepEE = edepHB = edepHE = edepHO = 0.;
244  for (i = 0; i < 20; i++) edepl[i] = 0.;
245  for (i = 0; i < 20; i++) mudist[i] = -1.;
246 
247  int iev = (*evt)()->GetEventID();
248  LogDebug("HcalSim") <<"HcalTestAnalysis: Begin of event = " << iev;
249 }
250 
251 //=================================================================== each STEP
252 void HcalTestAnalysis::update(const G4Step * aStep) {
253 
254  if (aStep != nullptr) {
255  G4VPhysicalVolume* curPV = aStep->GetPreStepPoint()->GetPhysicalVolume();
256  G4String name = curPV->GetName();
257  name.assign(name,0,3);
258  double edeposit = aStep->GetTotalEnergyDeposit();
259  int layer=-1;
260  if (name == "EBR") {
261  edepEB += edeposit;
262  } else if (name == "EFR") {
263  edepEE += edeposit;
264  } else if (name == "HBS") {
265  layer = (curPV->GetCopyNo()/10)%100;
266  if (layer >= 0 && layer < 17) {
267  edepHB += edeposit;
268  } else {
269  edm::LogWarning("HcalSim") << "HcalTestAnalysis::Error in HB "
270  << curPV->GetName() << curPV->GetCopyNo();
271  layer = -1;
272  }
273  } else if (name == "HES") {
274  layer = (curPV->GetCopyNo()/10)%100;
275  if (layer >= 0 && layer < 19) {
276  edepHE += edeposit;
277  } else {
278  edm::LogWarning("HcalSim") << "HcalTestAnalysis::Error in HE "
279  << curPV->GetName() << curPV->GetCopyNo();
280  layer = -1;
281  }
282  } else if (name == "HTS") {
283  layer = (curPV->GetCopyNo()/10)%100;
284  if (layer >= 17 && layer < 20) {
285  edepHO += edeposit;
286  } else {
287  edm::LogWarning("HcalSim") << "HcalTestAnalysis::Error in HO "
288  << curPV->GetName() << curPV->GetCopyNo();
289  layer = -1;
290  }
291  }
292  if (layer >= 0 && layer < 20) {
293  edepl[layer] += edeposit;
294 
295  // Calculate the distance if it is a muon
296  G4String part = aStep->GetTrack()->GetDefinition()->GetParticleName();
297  if ((part == "mu-" || part == "mu+") && mudist[layer] < 0) {
298  math::XYZPoint pos(aStep->GetPreStepPoint()->GetPosition().x(),
299  aStep->GetPreStepPoint()->GetPosition().y(),
300  aStep->GetPreStepPoint()->GetPosition().z());
301  double theta = pos.theta();
302  double eta = -log(tan(theta * 0.5));
303  double phi = pos.phi();
304  double dist = sqrt ((eta-eta0)*(eta-eta0) + (phi-phi0)*(phi-phi0));
305  mudist[layer] = dist*std::sqrt(pos.perp2());
306  }
307  }
308 
309  if (layer >= 0 && layer < 20) {
310  LogDebug("HcalSim") << "HcalTestAnalysis:: G4Step: " << name << " Layer "
311  << std::setw(3) << layer << " Edep " << std::setw(6)
312  << edeposit/MeV << " MeV";
313  }
314  } else {
315  edm::LogInfo("HcalSim") << "HcalTestAnalysis:: G4Step: Null Step";
316  }
317 }
318 
319 //================================================================ End of EVENT
321 
322  count++;
323  // Fill event input
324  fill(evt);
325  LogDebug("HcalSim") << "HcalTestAnalysis:: --- after Fill";
326 
327  // Qie analysis
328  CLHEP::HepRandomEngine* engine = G4Random::getTheEngine();
329  qieAnalysis(engine);
330  LogDebug("HcalSim") << "HcalTestAnalysis:: --- after QieAnalysis";
331 
332  // Layers tuples filling
333  layerAnalysis();
334  LogDebug("HcalSim") << "HcalTestAnalysis:: --- after LayerAnalysis";
335 
336  // Writing the data to the Tree
337  tuplesManager.get()->fillTree(tuples); // (no need to delete it...)
338  tuples = nullptr; // but avoid to reuse it...
339  LogDebug("HcalSim") << "HcalTestAnalysis:: --- after fillTree";
340 
341 }
342 
343 //---------------------------------------------------
345 
346  LogDebug("HcalSim") << "HcalTestAnalysis: Fill event "
347  << (*evt)()->GetEventID();
348 
349  // access to the G4 hit collections
350  G4HCofThisEvent* allHC = (*evt)()->GetHCofThisEvent();
351 
352  int nhc = 0, neb = 0, nef = 0, j = 0;
353  caloHitCache.erase (caloHitCache.begin(), caloHitCache.end());
354 
355  // Hcal
356  int HCHCid = G4SDManager::GetSDMpointer()->GetCollectionID(names[0]);
357  CaloG4HitCollection* theHCHC = (CaloG4HitCollection*) allHC->GetHC(HCHCid);
358  LogDebug("HcalSim") << "HcalTestAnalysis :: Hit Collection for " << names[0]
359  << " of ID " << HCHCid << " is obtained at " << theHCHC;
360  if (HCHCid >= 0 && theHCHC != nullptr) {
361  for (j = 0; j < theHCHC->entries(); j++) {
362 
363  CaloG4Hit* aHit = (*theHCHC)[j];
364 
365  double e = aHit->getEnergyDeposit()/GeV;
366  double time = aHit->getTimeSlice();
367 
368  math::XYZPoint pos = aHit->getPosition();
369  double theta = pos.theta();
370  double eta = -log(tan(theta * 0.5));
371  double phi = pos.phi();
372 
373  uint32_t unitID = aHit->getUnitID();
374  int subdet, zside, layer, etaIndex, phiIndex, lay;
375  org->unpackHcalIndex(unitID,subdet,zside,layer,etaIndex,phiIndex,lay);
376  double jitter = time-timeOfFlight(subdet,lay,eta);
377  if (jitter<0) jitter = 0;
378  CaloHit hit(subdet,lay,e,eta,phi,jitter,unitID);
379  caloHitCache.push_back(hit);
380  nhc++;
381 
382  std::string det = "HB";
383  if (subdet == static_cast<int>(HcalForward)) {
384  det = "HF";
385  } else if (subdet == static_cast<int>(HcalEndcap)) {
386  if (etaIndex <= 20) {
387  det = "HES";
388  } else {
389  det = "HED";
390  }
391  }
392 
393  LogDebug("HcalSim") << "HcalTest: " << det << " layer " << std::setw(2)
394  << layer << " time " << std::setw(6) << time
395  << " theta " << std::setw(8) << theta << " eta "
396  << std::setw(8) << eta << " phi " << std::setw(8)
397  << phi << " e " << std::setw(8) << e;
398  }
399  }
400  LogDebug("HcalSim") << "HcalTestAnalysis::HCAL hits : " << nhc << "\n";
401 
402  // EB
403  int EBHCid = G4SDManager::GetSDMpointer()->GetCollectionID(names[1]);
404  CaloG4HitCollection* theEBHC = (CaloG4HitCollection*) allHC->GetHC(EBHCid);
405  LogDebug("HcalSim") << "HcalTestAnalysis :: Hit Collection for " << names[1]
406  << " of ID " << EBHCid << " is obtained at " << theEBHC;
407  if (EBHCid >= 0 && theEBHC != nullptr) {
408  for (j = 0; j < theEBHC->entries(); j++) {
409 
410  CaloG4Hit* aHit = (*theEBHC)[j];
411 
412  double e = aHit->getEnergyDeposit()/GeV;
413  double time = aHit->getTimeSlice();
414  std::string det = "EB";
415 
416  math::XYZPoint pos = aHit->getPosition();
417  double theta = pos.theta();
418  double eta = -log(tan(theta/2.));
419  double phi = pos.phi();
420 
422  uint32_t unitID = org->getUnitID(id);
423  int subdet, zside, layer, ieta, iphi, lay;
424  org->unpackHcalIndex(unitID,subdet,zside,layer,ieta,iphi,lay);
425  subdet = 10;
426  layer = 0;
427  unitID = org->packHcalIndex(subdet,zside,layer,ieta,iphi,lay);
428  CaloHit hit(subdet,lay,e,eta,phi,time,unitID);
429  caloHitCache.push_back(hit);
430  neb++;
431  LogDebug("HcalSim") << "HcalTest: " << det << " layer " << std::setw(2)
432  << layer << " time " << std::setw(6) << time
433  << " theta " << std::setw(8) << theta << " eta "
434  << std::setw(8) << eta << " phi " << std::setw(8)
435  << phi << " e " << std::setw(8) << e;
436  }
437  }
438  LogDebug("HcalSim") << "HcalTestAnalysis::EB hits : " << neb << "\n";
439 
440  // EE
441  int EEHCid = G4SDManager::GetSDMpointer()->GetCollectionID(names[2]);
442  CaloG4HitCollection* theEEHC = (CaloG4HitCollection*) allHC->GetHC(EEHCid);
443  LogDebug("HcalSim") << "HcalTestAnalysis :: Hit Collection for " << names[2]
444  << " of ID " << EEHCid << " is obtained at " << theEEHC;
445  if (EEHCid >= 0 && theEEHC != nullptr) {
446  for (j = 0; j < theEEHC->entries(); j++) {
447 
448  CaloG4Hit* aHit = (*theEEHC)[j];
449 
450  double e = aHit->getEnergyDeposit()/GeV;
451  double time = aHit->getTimeSlice();
452  std::string det = "EE";
453 
454  math::XYZPoint pos = aHit->getPosition();
455  double theta = pos.theta();
456  double eta = -log(tan(theta/2.));
457  double phi = pos.phi();
458 
460  uint32_t unitID = org->getUnitID(id);
461  int subdet, zside, layer, ieta, iphi, lay;
462  org->unpackHcalIndex(unitID,subdet,zside,layer,ieta,iphi,lay);
463  subdet = 11;
464  layer = 0;
465  unitID = org->packHcalIndex(subdet,zside,layer,ieta,iphi,lay);
466  CaloHit hit(subdet,lay,e,eta,phi,time,unitID);
467  caloHitCache.push_back(hit);
468  nef++;
469  LogDebug("HcalSim") << "HcalTest: " << det << " layer " << std::setw(2)
470  << layer << " time " << std::setw(6) << time
471  << " theta " << std::setw(8) << theta << " eta "
472  << std::setw(8) << eta << " phi " << std::setw(8)
473  << phi << " e " << std::setw(8) << e;
474  }
475  }
476  LogDebug("HcalSim") << "HcalTestAnalysis::EE hits : " << nef << "\n";
477 }
478 
479 //-----------------------------------------------------------------------------
480 void HcalTestAnalysis::qieAnalysis(CLHEP::HepRandomEngine* engine) {
481 
482  //Fill tuple with hit information
483  int hittot = caloHitCache.size();
485 
486  //Get the index of the central tower
488  uint32_t unitID = org->getUnitID(id);
489  int subdet, zside, layer, ieta, iphi, lay;
490  org->unpackHcalIndex(unitID,subdet,zside,layer,ieta,iphi,lay);
491  int laymax = 0;
492  std::string det = "Unknown";
493  if (subdet == static_cast<int>(HcalBarrel)) {
494  laymax = 4; det = "HB";
495  } else if (subdet == static_cast<int>(HcalEndcap)) {
496  laymax = 2; det = "HES";
497  }
498  LogDebug("HcalSim") << "HcalTestAnalysis::Qie: " << det << " Eta " << ieta
499  << " Phi " << iphi << " Laymax " << laymax << " Hits "
500  << hittot;
501 
502  if (laymax>0 && hittot>0) {
503  std::vector<CaloHit> hits(hittot);
504  std::vector<double> eqielay(80,0.0), esimlay(80,0.0), esimtot(4,0.0);
505  std::vector<double> eqietow(200,0.0), esimtow(200,0.0), eqietot(4,0.0);
506  int etac = (centralTower/100)%100;
507  int phic = (centralTower%100);
508 
509  for (int layr=0; layr<nGroup; layr++) {
510  /*
511  int layx, layy=20;
512  for (int i=0; i<20; i++)
513  if (group_[i] == layr+1 && i < layy) layy = i+1;
514  if (subdet == static_cast<int>(HcalBarrel)) {
515  if (layy < 2) layx = 0;
516  else if (layy < 17) layx = 1;
517  else if (layy == 17) layx = 2;
518  else layx = 3;
519  } else {
520  if (layy < 2) layx = 0;
521  else layx = 1;
522  }
523  */
524  for (int it=0; it<nTower; it++) {
525  int nhit = 0;
526  double esim = 0;
527  for (int k1 = 0; k1 < hittot; k1++) {
528  CaloHit hit = caloHitCache[k1];
529  int subdetc = hit.det();
530  int layer = hit.layer();
531  int group = 0;
532  if (layer > 0 && layer < 20) group = group_[layer];
533  if (subdetc == subdet && group == layr+1) {
534  int zsidec, ietac, iphic, idx;
535  unitID = hit.id();
536  org->unpackHcalIndex(unitID,subdetc,zsidec,layer,ietac,iphic,lay);
537  if (etac > 0 && phic > 0) {
538  idx = ietac*100 + iphic;
539  } else if (etac > 0) {
540  idx = ietac*100;
541  } else if (phic > 0) {
542  idx = iphic;
543  } else {
544  idx = 0;
545  }
546  if (zsidec==zside && idx==tower_[it]) {
547  hits[nhit] = hit;
548  LogDebug("HcalSim") << "HcalTest: Hit " << nhit << " " << hit;
549  nhit++;
550  esim += hit.e();
551  }
552  }
553  }
554 
555  std::vector<int> cd = myqie->getCode(nhit, hits, engine);
556  double eqie = myqie->getEnergy(cd);
557 
558  LogDebug("HcalSim") << "HcalTestAnalysis::Qie: Energy in layer "
559  << layr << " Sim " << esim << " After QIE " <<eqie;
560  for (int i=0; i<4; i++) {
561  if (tower_[nTower+it] <= i) {
562  esimtot[i] += esim;
563  eqietot[i] += eqie;
564  esimlay[20*i+layr] += esim;
565  eqielay[20*i+layr] += eqie;
566  esimtow[50*i+it] += esim;
567  eqietow[50*i+it] += eqie;
568  }
569  }
570  }
571  }
572  LogDebug("HcalSim") << "HcalTestAnalysis::Qie: Total energy " << esimtot[3]
573  << " (SimHit) " << eqietot[3] << " (After QIE)";
574 
575  std::vector<double> latphi(10);
576  int nt = 2*addTower + 1;
577  for (int it=0; it<nt; it++)
578  latphi[it] = it-addTower;
579  for (int i=0; i<4; i++) {
580  double scals=1, scalq=1;
581  std::vector<double> latfs(10,0.), latfq(10,0.), longs(20), longq(20);
582  if (esimtot[i]>0) scals = 1./esimtot[i];
583  if (eqietot[i]>0) scalq = 1./eqietot[i];
584  for (int it=0; it<nTower; it++) {
585  int phib = it%nt;
586  latfs[phib] += scals*esimtow[50*i+it];
587  latfq[phib] += scalq*eqietow[50*i+it];
588  }
589  for (int layr=0; layr<=nGroup; layr++) {
590  longs[layr] = scals*esimlay[20*i+layr];
591  longq[layr] = scalq*eqielay[20*i+layr];
592  }
593  tuples->fillQie(i,esimtot[i],eqietot[i],nGroup,longs,longq,
594  nt,latphi,latfs,latfq);
595  }
596  }
597 }
598 
599 //---------------------------------------------------
601 
602  int i = 0;
603  LogDebug("HcalSim") << "\n ===>>> HcalTestAnalysis: Energy deposit in MeV "
604  << "\n at EB : " << std::setw(6) << edepEB/MeV
605  << "\n at EE : " << std::setw(6) << edepEE/MeV
606  << "\n at HB : " << std::setw(6) << edepHB/MeV
607  << "\n at HE : " << std::setw(6) << edepHE/MeV
608  << "\n at HO : " << std::setw(6) << edepHO/MeV
609  << "\n ---- HcalTestAnalysis: Energy deposit in Layers";
610  for (i = 0; i < 20; i++)
611  LogDebug("HcalSim") << " Layer " << std::setw(2) << i << " E "
612  << std::setw(8) << edepl[i]/MeV << " MeV";
613 
615 }
616 
617 
618 //---------------------------------------------------
619 double HcalTestAnalysis::timeOfFlight(int det, int layer, double eta) {
620 
621  double theta = 2.0*atan(exp(-eta));
622  double dist = 0.;
623  if (det == static_cast<int>(HcalBarrel)) {
624  const double rLay[19] = {
625  1836.0, 1902.0, 1962.0, 2022.0, 2082.0, 2142.0, 2202.0, 2262.0, 2322.0,
626  2382.0, 2448.0, 2514.0, 2580.0, 2646.0, 2712.0, 2776.0, 2862.5, 3847.0,
627  4052.0};
628  if (layer>0 && layer<20) dist += rLay[layer-1]*mm/sin(theta);
629  } else {
630  const double zLay[19] = {
631  4034.0, 4032.0, 4123.0, 4210.0, 4297.0, 4384.0, 4471.0, 4558.0, 4645.0,
632  4732.0, 4819.0, 4906.0, 4993.0, 5080.0, 5167.0, 5254.0, 5341.0, 5428.0,
633  5515.0};
634  if (layer>0 && layer<20) dist += zLay[layer-1]*mm/cos(theta);
635  }
636  double tmp = dist/c_light/ns;
637  LogDebug("HcalSim") << "HcalTestAnalysis::timeOfFlight " << tmp
638  << " for det/lay " << det << " " << layer
639  << " eta/theta " << eta << " " << theta/deg << " dist "
640  << dist;
641  return tmp;
642 }
#define LogDebug(id)
void fillQie(int id, double esimtot, double eqietot, int nGroup, const std::vector< double > &longs, const std::vector< double > &longq, int nTower, const std::vector< double > &latphi, const std::vector< double > &latfs, const std::vector< double > &latfq)
T getParameter(std::string const &) const
math::XYZPoint getPosition() const
Definition: CaloG4Hit.h:56
const double GeV
Definition: MathUtil.h:16
HcalNumberingFromDDD * numberingFromDDD
int det() const
Definition: CaloHit.h:22
void fillLayers(double el[], double ho, double hbhe, double muxy[])
std::vector< int > layerGrouping(int)
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
unsigned int count
Geom::Theta< T > theta() const
void fillHits(std::vector< CaloHit > &)
void update(const BeginOfJob *run) override
This routine will be called when the appropriate signal arrives.
HcalDDDSimConstants * hcons
std::vector< std::string > names
HcalTestNumberingScheme * org
#define nullptr
HcalCellType::HcalCell cell(const int &det, const int &zside, const int &depth, const int &etaR, const int &iphi) const
void setNumberingScheme(HcalNumberingScheme *)
Definition: HCalSD.cc:563
std::vector< int > towersToAdd(int centre, int nadd)
const double MeV
double timeOfFlight(int det, int layer, double eta)
Definition: HCalSD.h:36
uint32_t id() const
Definition: CaloHit.h:28
void fill(const EndOfEvent *ev)
static uint32_t packHcalIndex(int det, int z, int depth, int eta, int phi, int lay)
std::vector< int > tower_
HcalTestAnalysis(const edm::ParameterSet &p)
double getEnergy(const std::vector< int > &)
Definition: HcalQie.cc:390
T sqrt(T t)
Definition: SSEVec.h:18
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
~HcalTestAnalysis() override
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
int layer() const
Definition: CaloHit.h:23
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
HcalTestHistoClass * tuples
std::unique_ptr< HcalTestHistoManager > tuplesManager
int nt
Definition: AMPTWrapper.h:32
std::string fileName
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
double sd
part
Definition: HCALResponse.h:20
double e() const
Definition: CaloHit.h:24
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
std::vector< int > getCode(int, const std::vector< CaloHit > &, CLHEP::HepRandomEngine *)
Definition: HcalQie.cc:296
G4THitsCollection< CaloG4Hit > CaloG4HitCollection
std::vector< CaloHit > caloHitCache
static void unpackHcalIndex(const uint32_t &idx, int &det, int &z, int &depth, int &eta, int &phi, int &lay)
double getTimeSlice() const
Definition: CaloG4Hit.h:70
void qieAnalysis(CLHEP::HepRandomEngine *)
uint32_t getUnitID() const
Definition: CaloG4Hit.h:69
HcalID unitID(int det, const CLHEP::Hep3Vector &pos, int depth, int lay=-1) const
std::vector< int > group_
double getEnergyDeposit() const
Definition: CaloG4Hit.h:81
uint32_t getUnitID(const HcalNumberingFromDDD::HcalID &id) override