CMS 3D CMS Logo

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