CMS 3D CMS Logo

HCalSD.cc
Go to the documentation of this file.
1 // File: HCalSD.cc
3 // Description: Sensitive Detector class for calorimeters
5 
17 
26 
27 #include "G4LogicalVolumeStore.hh"
28 #include "G4LogicalVolume.hh"
29 #include "G4Step.hh"
30 #include "G4Track.hh"
31 
32 #include "G4SystemOfUnits.hh"
33 #include "G4PhysicalConstants.hh"
34 #include "Randomize.hh"
35 
36 #include <iostream>
37 #include <fstream>
38 #include <iomanip>
39 #include <sstream>
40 
41 //#define EDM_ML_DEBUG
42 //#define plotDebug
43 
44 #ifdef plotDebug
45 #include <TH1F.h>
46 #endif
47 
49  const DDCompactView& cpv,
50  const SensitiveDetectorCatalog& clg,
51  edm::ParameterSet const& p,
52  const SimTrackManager* manager)
53  : CaloSD(name,
54  cpv,
55  clg,
56  p,
57  manager,
58  (float)(p.getParameter<edm::ParameterSet>("HCalSD").getParameter<double>("TimeSliceUnit")),
59  p.getParameter<edm::ParameterSet>("HCalSD").getParameter<bool>("IgnoreTrackID")),
60  hcalConstants(nullptr),
61  m_HBDarkening(nullptr),
62  m_HEDarkening(nullptr),
63  isHF(false),
64  weight_(1.0),
65  depth_(1) {
66  numberingFromDDD.reset(nullptr);
67  numberingScheme.reset(nullptr);
68  showerLibrary.reset(nullptr);
69  hfshower.reset(nullptr);
70  showerParam.reset(nullptr);
71  showerPMT.reset(nullptr);
72  showerBundle.reset(nullptr);
73  m_HFDarkening.reset(nullptr);
74  m_HcalTestNS.reset(nullptr);
75 
76  //static SimpleConfigurable<double> bk1(0.013, "HCalSD:BirkC1");
77  //static SimpleConfigurable<double> bk2(0.0568,"HCalSD:BirkC2");
78  //static SimpleConfigurable<double> bk3(1.75, "HCalSD:BirkC3");
79  // Values from NIM 80 (1970) 239-244: as implemented in Geant3
80 
82  useBirk = m_HC.getParameter<bool>("UseBirkLaw");
83  birk1 = m_HC.getParameter<double>("BirkC1") * (g / (MeV * cm2));
84  birk2 = m_HC.getParameter<double>("BirkC2");
85  birk3 = m_HC.getParameter<double>("BirkC3");
86  useShowerLibrary = m_HC.getParameter<bool>("UseShowerLibrary");
87  useParam = m_HC.getParameter<bool>("UseParametrize");
88  testNumber = m_HC.getParameter<bool>("TestNumberingScheme");
89  neutralDensity = m_HC.getParameter<bool>("doNeutralDensityFilter");
90  usePMTHit = m_HC.getParameter<bool>("UsePMTHits");
91  betaThr = m_HC.getParameter<double>("BetaThreshold");
92  eminHitHB = m_HC.getParameter<double>("EminHitHB") * MeV;
93  eminHitHE = m_HC.getParameter<double>("EminHitHE") * MeV;
94  eminHitHO = m_HC.getParameter<double>("EminHitHO") * MeV;
95  eminHitHF = m_HC.getParameter<double>("EminHitHF") * MeV;
96  useFibreBundle = m_HC.getParameter<bool>("UseFibreBundleHits");
97  deliveredLumi = m_HC.getParameter<double>("DelivLuminosity");
98  agingFlagHB = m_HC.getParameter<bool>("HBDarkening");
99  agingFlagHE = m_HC.getParameter<bool>("HEDarkening");
100  bool agingFlagHF = m_HC.getParameter<bool>("HFDarkening");
101  useHF = m_HC.getUntrackedParameter<bool>("UseHF", true);
102  bool forTBH2 = m_HC.getUntrackedParameter<bool>("ForTBH2", false);
103  useLayerWt = m_HC.getUntrackedParameter<bool>("UseLayerWt", false);
104  std::string file = m_HC.getUntrackedParameter<std::string>("WtFile", "None");
105  testNS_ = m_HC.getUntrackedParameter<bool>("TestNS", false);
106  edm::ParameterSet m_HF = p.getParameter<edm::ParameterSet>("HFShower");
107  applyFidCut = m_HF.getParameter<bool>("ApplyFiducialCut");
108 
109 #ifdef EDM_ML_DEBUG
110  edm::LogVerbatim("HcalSim") << "***************************************************"
111  << "\n"
112  << "* Constructing a HCalSD with name " << name << "\n"
113  << "\n"
114  << "***************************************************";
115 #endif
116  edm::LogVerbatim("HcalSim") << "HCalSD:: Use of HF code is set to " << useHF
117  << "\nUse of shower parametrization set to " << useParam
118  << "\nUse of shower library is set to " << useShowerLibrary << "\nUse PMT Hit is set to "
119  << usePMTHit << " with beta Threshold " << betaThr << "\nUSe of FibreBundle Hit set to "
120  << useFibreBundle << "\n Use of Birks law is set to " << useBirk
121  << " with three constants kB = " << birk1 << ", C1 = " << birk2 << ", C2 = " << birk3;
122  edm::LogVerbatim("HcalSim") << "HCalSD:: Suppression Flag " << suppressHeavy << " protons below " << kmaxProton
123  << " MeV,"
124  << " neutrons below " << kmaxNeutron << " MeV and"
125  << " ions below " << kmaxIon << " MeV\n"
126  << " Threshold for storing hits in HB: " << eminHitHB << " HE: " << eminHitHE
127  << " HO: " << eminHitHO << " HF: " << eminHitHF << "\n"
128  << "Delivered luminosity for Darkening " << deliveredLumi << " Flag (HE) " << agingFlagHE
129  << " Flag (HB) " << agingFlagHB << " Flag (HF) " << agingFlagHF << "\n"
130  << "Application of Fiducial Cut " << applyFidCut
131  << "Flag for test number|neutral density filter " << testNumber << " " << neutralDensity;
132 
133  HcalNumberingScheme* scheme;
134  if (testNumber || forTBH2) {
135  scheme = dynamic_cast<HcalNumberingScheme*>(new HcalTestNumberingScheme(forTBH2));
136  } else {
137  scheme = new HcalNumberingScheme();
138  }
139  setNumberingScheme(scheme);
140 
141  // always call getFromLibrary() method to identify HF region
142  setParameterized(true);
143 
144  const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance();
145  // std::vector<G4LogicalVolume *>::const_iterator lvcite;
146  const G4LogicalVolume* lv;
147  std::string attribute, value;
148 
149  if (useHF) {
150  if (useParam) {
151  showerParam.reset(new HFShowerParam(name, cpv, p));
152  } else {
153  if (useShowerLibrary) {
154  showerLibrary.reset(new HFShowerLibrary(name, cpv, p));
155  }
156  hfshower.reset(new HFShower(name, cpv, p, 0));
157  }
158 
159  // HF volume names
160  attribute = "Volume";
161  value = "HF";
162  DDSpecificsMatchesValueFilter filter0{DDValue(attribute, value, 0)};
163  DDFilteredView fv0(cpv, filter0);
164  hfNames = getNames(fv0);
165  fv0.firstChild();
166  DDsvalues_type sv0(fv0.mergedSpecifics());
167  std::vector<double> temp = getDDDArray("Levels", sv0);
168 
169  unsigned int nhf = hfNames.size();
170  std::stringstream ss;
171  ss << "HCalSD: Names to be tested for " << attribute << " = " << value << " has " << nhf << " elements";
172  for (unsigned int i = 0; i < nhf; ++i) {
173  G4String namv = hfNames[i];
174  lv = nullptr;
175  for (auto lvol : *lvs) {
176  if (lvol->GetName() == namv) {
177  lv = lvol;
178  break;
179  }
180  }
181  hfLV.push_back(lv);
182  int level = static_cast<int>(temp[i]);
183  hfLevels.push_back(level);
184  ss << "\n HF[" << i << "] = " << namv << " LV " << hfLV[i] << " at level " << hfLevels[i];
185  }
186  edm::LogVerbatim("HcalSim") << ss.str();
187 
188  // HF Fibre volume names
189  fillLogVolumeVector(attribute, "HFFibre", cpv, fibreLV, fibreNames);
190  std::vector<G4String> tempNames;
191  fillLogVolumeVector(attribute, "HFPMT", cpv, pmtLV, tempNames);
192  fillLogVolumeVector(attribute, "HFFibreBundleStraight", cpv, fibre1LV, tempNames);
193  fillLogVolumeVector(attribute, "HFFibreBundleConical", cpv, fibre2LV, tempNames);
194  }
195 
196  //Material list for HB/HE/HO sensitive detectors
197  const G4MaterialTable* matTab = G4Material::GetMaterialTable();
198  std::vector<G4Material*>::const_iterator matite;
199  attribute = "OnlyForHcalSimNumbering";
200  DDSpecificsHasNamedValueFilter filter2{attribute};
201  DDFilteredView fv2(cpv, filter2);
202  bool dodet = fv2.firstChild();
204 
205  while (dodet) {
206  const DDLogicalPart& log = fv2.logicalPart();
207  G4String namx = log.name().name();
208  if (!isItHF(namx) && !isItFibre(namx)) {
209  bool notIn = true;
210  for (unsigned int i = 0; i < matNames.size(); ++i) {
211  if (!strcmp(matNames[i].c_str(), log.material().name().name().c_str())) {
212  notIn = false;
213  break;
214  }
215  }
216  if (notIn) {
217  namx = log.material().name().name();
218  matNames.push_back(namx);
219  const G4Material* mat = nullptr;
220  for (matite = matTab->begin(); matite != matTab->end(); ++matite) {
221  if ((*matite)->GetName() == namx) {
222  mat = (*matite);
223  break;
224  }
225  }
226  materials.push_back(mat);
227  }
228  }
229  dodet = fv2.next();
230  }
231 
232  std::stringstream sss;
233  for (unsigned int i = 0; i < matNames.size(); ++i) {
234  if (i / 10 * 10 == i) {
235  sss << "\n";
236  }
237  sss << " " << matNames[i];
238  }
239  edm::LogVerbatim("HcalSim") << "HCalSD: Material names for " << attribute << " = " << name << ":" << sss.str();
240 
241  if (useLayerWt) {
242  readWeightFromFile(file);
243  }
244 
245  for (int i = 0; i < 9; ++i) {
246  hit_[i] = time_[i] = dist_[i] = nullptr;
247  }
248  hzvem = hzvhad = nullptr;
249 
250  if (agingFlagHF) {
251  m_HFDarkening.reset(new HFDarkening(m_HC.getParameter<edm::ParameterSet>("HFDarkeningParameterBlock")));
252  }
253 #ifdef plotDebug
255 
256  if (tfile.isAvailable()) {
257  static const char* const labels[] = {"HB",
258  "HE",
259  "HO",
260  "HF Absorber",
261  "HF PMT",
262  "HF Absorber Long",
263  "HF Absorber Short",
264  "HF PMT Long",
265  "HF PMT Short"};
266  TFileDirectory hcDir = tfile->mkdir("ProfileFromHCalSD");
267  char name[20], title[60];
268  for (int i = 0; i < 9; ++i) {
269  sprintf(title, "Hit energy in %s", labels[i]);
270  sprintf(name, "HCalSDHit%d", i);
271  hit_[i] = hcDir.make<TH1F>(name, title, 2000, 0., 2000.);
272  sprintf(title, "Energy (MeV)");
273  hit_[i]->GetXaxis()->SetTitle(title);
274  hit_[i]->GetYaxis()->SetTitle("Hits");
275  sprintf(title, "Time of the hit in %s", labels[i]);
276  sprintf(name, "HCalSDTime%d", i);
277  time_[i] = hcDir.make<TH1F>(name, title, 2000, 0., 2000.);
278  sprintf(title, "Time (ns)");
279  time_[i]->GetXaxis()->SetTitle(title);
280  time_[i]->GetYaxis()->SetTitle("Hits");
281  sprintf(title, "Longitudinal profile in %s", labels[i]);
282  sprintf(name, "HCalSDDist%d", i);
283  dist_[i] = hcDir.make<TH1F>(name, title, 2000, 0., 2000.);
284  sprintf(title, "Distance (mm)");
285  dist_[i]->GetXaxis()->SetTitle(title);
286  dist_[i]->GetYaxis()->SetTitle("Hits");
287  }
288  if (useHF && (!useParam)) {
289  hzvem = hcDir.make<TH1F>("hzvem", "Longitudinal Profile (EM Part)", 330, 0.0, 1650.0);
290  hzvem->GetXaxis()->SetTitle("Longitudinal Profile (EM Part)");
291  hzvhad = hcDir.make<TH1F>("hzvhad", "Longitudinal Profile (Had Part)", 330, 0.0, 1650.0);
292  hzvhad->GetXaxis()->SetTitle("Longitudinal Profile (Hadronic Part)");
293  }
294  }
295 #endif
296 }
297 
299  const std::string& value,
300  const DDCompactView& cpv,
301  std::vector<const G4LogicalVolume*>& lvvec,
302  std::vector<G4String>& lvnames) {
303  const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance();
304  const G4LogicalVolume* lv;
305 
306  DDSpecificsMatchesValueFilter filter{DDValue(attribute, value, 0)};
307  DDFilteredView fv(cpv, filter);
308  lvnames = getNames(fv);
309 
310  unsigned int nvol = lvnames.size();
311  std::stringstream ss;
312  ss << "HCalSD: " << nvol << " names to be tested for " << attribute << " <" << value << ">:";
313  for (unsigned int i = 0; i < nvol; ++i) {
314  G4String namv = lvnames[i];
315  lv = nullptr;
316  for (auto lvol : *lvs) {
317  if (lvol->GetName() == namv) {
318  lv = lvol;
319  break;
320  }
321  }
322  lvvec.push_back(lv);
323  if (i / 10 * 10 == i) {
324  ss << "\n";
325  }
326  ss << " " << namv;
327  }
328  edm::LogVerbatim("HcalSim") << ss.str();
329 }
330 
331 bool HCalSD::getFromLibrary(const G4Step* aStep) {
332  auto const track = aStep->GetTrack();
333  depth_ = (aStep->GetPreStepPoint()->GetTouchable()->GetReplicaNumber(0)) % 10;
334  weight_ = 1.0;
335  bool kill(false);
336  isHF = isItHF(aStep);
337  if (isHF) {
338  if (m_HFDarkening) {
339  G4ThreeVector hitPoint = aStep->GetPreStepPoint()->GetPosition();
340  const double invcm = 1. / CLHEP::cm;
341  double r = hitPoint.perp() * invcm;
342  double z = std::abs(hitPoint.z()) * invcm;
343  double dose_acquired = 0.;
345  unsigned int hfZLayer = (unsigned int)((z - HFDarkening::lowZLimit) / 5);
346  if (hfZLayer >= HFDarkening::upperZLimit)
347  hfZLayer = (HFDarkening::upperZLimit - 1);
348  float normalized_lumi = m_HFDarkening->int_lumi(deliveredLumi);
349  for (int i = hfZLayer; i != HFDarkening::numberOfZLayers; ++i) {
350  dose_acquired = m_HFDarkening->dose(i, r);
351  weight_ *= m_HFDarkening->degradation(normalized_lumi * dose_acquired);
352  }
353  }
354 #ifdef EDM_ML_DEBUG
355  edm::LogVerbatim("HcalSim") << "HCalSD::getFromLibrary: HFLumiDarkening at "
356  << "r= " << r << ", z= " << z << " Dose= " << dose_acquired << " weight= " << weight_;
357 #endif
358  }
359 
360  if (useParam) {
361  getFromParam(aStep, kill);
362 #ifdef EDM_ML_DEBUG
363  G4String nameVolume = lv->GetName();
364  edm::LogVerbatim("HcalSim") << "HCalSD: " << getNumberOfHits() << " hits from parametrization in " << nameVolume
365  << " for Track " << track->GetTrackID() << " ("
366  << track->GetDefinition()->GetParticleName() << ")";
367 #endif
370 #ifdef EDM_ML_DEBUG
371  auto nameVolume = aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetName();
372  edm::LogVerbatim("HcalSim") << "HCalSD: Starts shower library from " << nameVolume << " for Track "
373  << track->GetTrackID() << " (" << track->GetDefinition()->GetParticleName() << ")";
374 
375 #endif
376  getFromHFLibrary(aStep, kill);
377  }
378  }
379  }
380 #ifdef EDM_ML_DEBUG
381  edm::LogVerbatim("HcalSim") << "HCalSD::getFromLibrary ID= " << track->GetTrackID() << " ("
382  << track->GetDefinition()->GetParticleName() << ") kill= " << kill
383  << " weight= " << weight_ << " depth= " << depth_ << " isHF: " << isHF;
384 #endif
385  return kill;
386 }
387 
388 double HCalSD::getEnergyDeposit(const G4Step* aStep) {
389  double destep(0.0);
390  auto const lv = aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume();
391  auto const theTrack = aStep->GetTrack();
392 
393  if (isHF) {
394  if (useShowerLibrary && G4TrackToParticleID::isMuon(theTrack) && isItFibre(lv)) {
395 #ifdef EDM_ML_DEBUG
396  edm::LogVerbatim("HcalSim") << "HCalSD: Hit at Fibre in LV " << lv->GetName() << " for track "
397  << aStep->GetTrack()->GetTrackID() << " ("
398  << aStep->GetTrack()->GetDefinition()->GetParticleName() << ")";
399 #endif
400  hitForFibre(aStep);
401  }
402  return destep;
403  }
404 
405  if (isItPMT(lv)) {
406  if (usePMTHit && showerPMT) {
407  getHitPMT(aStep);
408  }
409 #ifdef EDM_ML_DEBUG
410  edm::LogVerbatim("HcalSim") << "HCalSD: Hit from PMT parametrization in LV " << lv->GetName() << " for Track "
411  << aStep->GetTrack()->GetTrackID() << " ("
412  << aStep->GetTrack()->GetDefinition()->GetParticleName() << ")";
413 #endif
414  return destep;
415 
416  } else if (isItStraightBundle(lv)) {
417  if (useFibreBundle && showerBundle) {
418  getHitFibreBundle(aStep, false);
419  }
420 #ifdef EDM_ML_DEBUG
421  edm::LogVerbatim("HcalSim") << "HCalSD: Hit from straight FibreBundle in LV: " << lv->GetName() << " for track "
422  << aStep->GetTrack()->GetTrackID() << " ("
423  << aStep->GetTrack()->GetDefinition()->GetParticleName() << ")";
424 #endif
425  return destep;
426 
427  } else if (isItConicalBundle(lv)) {
428  if (useFibreBundle && showerBundle) {
429  getHitFibreBundle(aStep, true);
430  }
431 #ifdef EDM_ML_DEBUG
432  edm::LogVerbatim("HcalSim") << "HCalSD: Hit from conical FibreBundle PV: " << lv->GetName() << " for track "
433  << aStep->GetTrack()->GetTrackID() << " ("
434  << aStep->GetTrack()->GetDefinition()->GetParticleName() << ")";
435 #endif
436  return destep;
437  }
438 
439  // normal hit
440  destep = aStep->GetTotalEnergyDeposit();
441 
442  const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
443  uint32_t detid = setDetUnitId(aStep);
444  int det(0), ieta(0), phi(0), z(0), lay, depth(-1);
445  if (testNumber) {
446  HcalTestNumbering::unpackHcalIndex(detid, det, z, depth, ieta, phi, lay);
447  if (z == 0) {
448  z = -1;
449  }
450  } else {
451  HcalDetId hcid(detid);
452  det = hcid.subdetId();
453  ieta = hcid.ietaAbs();
454  phi = hcid.iphi();
455  z = hcid.zside();
456  }
457  lay = (touch->GetReplicaNumber(0) / 10) % 100 + 1;
458 #ifdef EDM_ML_DEBUG
459  edm::LogVerbatim("HcalSim") << "HCalSD: det: " << det << " ieta: " << ieta << " iphi: " << phi << " zside " << z
460  << " lay: " << lay - 2;
461 #endif
462  if (depth_ == 0 && (det == 1 || det == 2) && ((!testNumber) || neutralDensity))
464  if (useLayerWt) {
465  G4ThreeVector hitPoint = aStep->GetPreStepPoint()->GetPosition();
466  weight_ = layerWeight(det + 2, hitPoint, depth_, lay);
467  }
468 
469  if (m_HBDarkening && det == 1) {
470  double dweight = m_HBDarkening->degradation(deliveredLumi, ieta, lay);
471  weight_ *= dweight;
472 #ifdef EDM_ML_DEBUG
473  edm::LogVerbatim("HcalSim") << "HCalSD: HB Lumi: " << deliveredLumi << " coefficient = " << dweight
474  << " Weight= " << weight_;
475 #endif
476  }
477 
478  if (m_HEDarkening && det == 2) {
479  double dweight = m_HEDarkening->degradation(deliveredLumi, ieta, lay);
480  weight_ *= dweight;
481 #ifdef EDM_ML_DEBUG
482  edm::LogVerbatim("HcalSim") << "HCalSD: HB Lumi: " << deliveredLumi << " coefficient = " << dweight
483  << " Weight= " << weight_;
484 #endif
485  }
486 
487  if (suppressHeavy) {
488  TrackInformation* trkInfo = (TrackInformation*)(theTrack->GetUserInformation());
489  if (trkInfo) {
490  int pdg = theTrack->GetDefinition()->GetPDGEncoding();
491  if (!(trkInfo->isPrimary())) { // Only secondary particles
492  double ke = theTrack->GetKineticEnergy();
493  if (pdg / 1000000000 == 1 && (pdg / 10000) % 100 > 0 && (pdg / 10) % 100 > 0 && ke < kmaxIon)
494  weight_ = 0;
495  if ((pdg == 2212) && (ke < kmaxProton))
496  weight_ = 0;
497  if ((pdg == 2112) && (ke < kmaxNeutron))
498  weight_ = 0;
499  }
500  }
501  }
502  if (useBirk) {
503  const G4Material* mat = aStep->GetPreStepPoint()->GetMaterial();
504  if (isItScintillator(mat))
505  weight_ *= getAttenuation(aStep, birk1, birk2, birk3);
506  }
507  double wt1 = getResponseWt(theTrack);
508  double wt2 = theTrack->GetWeight();
509  double edep = weight_ * wt1 * destep;
510  if (wt2 > 0.0) {
511  edep *= wt2;
512  }
513 #ifdef EDM_ML_DEBUG
514  edm::LogVerbatim("HcalSim") << "HCalSD: edep= " << edep << " Det: " << det + 2 << " depth= " << depth_
515  << " weight= " << weight_ << " wt1= " << wt1 << " wt2= " << wt2;
516 #endif
517  return edep;
518 }
519 
520 uint32_t HCalSD::setDetUnitId(const G4Step* aStep) {
521  auto const prePoint = aStep->GetPreStepPoint();
522  auto const touch = prePoint->GetTouchable();
523  const G4ThreeVector& hitPoint = prePoint->GetPosition();
524 
525  int depth = (touch->GetReplicaNumber(0)) % 10 + 1;
526  int lay = (touch->GetReplicaNumber(0) / 10) % 100 + 1;
527  int det = (touch->GetReplicaNumber(1)) / 1000;
528 
529  return setDetUnitId(det, hitPoint, depth, lay);
530 }
531 
533  if (scheme != nullptr) {
534  edm::LogVerbatim("HcalSim") << "HCalSD: updates numbering scheme for " << GetName();
535  numberingScheme.reset(scheme);
536  }
537 }
538 
539 void HCalSD::update(const BeginOfJob* job) {
540  const edm::EventSetup* es = (*job)();
542  es->get<HcalSimNumberingRecord>().get(hdc);
543  if (hdc.isValid()) {
544  hcalConstants = hdc.product();
545  } else {
546  edm::LogError("HcalSim") << "HCalSD : Cannot find HcalDDDSimConstant";
547  throw cms::Exception("Unknown", "HCalSD") << "Cannot find HcalDDDSimConstant"
548  << "\n";
549  }
550 
552 
553  //Special Geometry parameters
555  std::stringstream sss;
556  for (unsigned int ig = 0; ig < gpar.size(); ig++) {
557  sss << "\n gpar[" << ig << "] = " << gpar[ig] / cm << " cm";
558  }
559  edm::LogVerbatim("HcalSim") << "Maximum depth for HF " << hcalConstants->getMaxDepth(2) << gpar.size() << " gpar (cm)"
560  << sss.str();
561  //Test Hcal Numbering Scheme
562  if (testNS_)
563  m_HcalTestNS.reset(new HcalTestNS(es));
564 
565  if (agingFlagHB) {
567  es->get<HBHEDarkeningRecord>().get("HB", hdark);
568  m_HBDarkening = &*hdark;
569  }
570  if (agingFlagHE) {
572  es->get<HBHEDarkeningRecord>().get("HE", hdark);
573  m_HEDarkening = &*hdark;
574  }
575 }
576 
578  if (showerLibrary.get())
579  showerLibrary.get()->initRun(nullptr, hcalConstants);
580  if (showerParam.get())
581  showerParam.get()->initRun(hcalConstants);
582  if (hfshower.get())
583  hfshower.get()->initRun(hcalConstants);
584  if (showerPMT.get())
585  showerPMT.get()->initRun(hcalConstants);
586  if (showerBundle.get())
587  showerBundle.get()->initRun(hcalConstants);
588 }
589 
590 bool HCalSD::filterHit(CaloG4Hit* aHit, double time) {
591  double threshold = 0;
592  DetId theId(aHit->getUnitID());
593  switch (theId.subdetId()) {
594  case HcalBarrel:
595  threshold = eminHitHB;
596  break;
597  case HcalEndcap:
598  threshold = eminHitHE;
599  break;
600  case HcalOuter:
601  threshold = eminHitHO;
602  break;
603  case HcalForward:
604  threshold = eminHitHF;
605  break;
606  default:
607  break;
608  }
609  return ((time <= tmaxHit) && (aHit->getEnergyDeposit() > threshold));
610 }
611 
612 uint32_t HCalSD::setDetUnitId(int det, const G4ThreeVector& pos, int depth, int lay = 1) {
613  uint32_t id = 0;
614  if (numberingFromDDD.get()) {
615  //get the ID's as eta, phi, depth, ... indices
617  numberingFromDDD.get()->unitID(det, math::XYZVectorD(pos.x(), pos.y(), pos.z()), depth, lay);
618  id = setDetUnitId(tmp);
619  }
620  return id;
621 }
622 
624  modifyDepth(tmp);
625  uint32_t id = (numberingScheme.get()) ? numberingScheme.get()->getUnitID(tmp) : 0;
626  if ((!testNumber) && m_HcalTestNS.get()) {
627  bool ok = m_HcalTestNS.get()->compare(tmp, id);
628  if (!ok)
629  edm::LogWarning("HcalSim") << "Det ID from HCalSD " << HcalDetId(id) << " " << std::hex << id << std::dec
630  << " does not match one from relabller for " << tmp.subdet << ":" << tmp.etaR << ":"
631  << tmp.phi << ":" << tmp.phis << ":" << tmp.depth << ":" << tmp.lay << std::endl;
632  }
633  return id;
634 }
635 
636 std::vector<double> HCalSD::getDDDArray(const std::string& str, const DDsvalues_type& sv) {
637 #ifdef EDM_ML_DEBUG
638  edm::LogVerbatim("HcalSim") << "HCalSD:getDDDArray called for " << str;
639 #endif
640  DDValue value(str);
641  if (DDfetch(&sv, value)) {
642 #ifdef EDM_ML_DEBUG
643  edm::LogVerbatim("HcalSim") << value;
644 #endif
645  const std::vector<double>& fvec = value.doubles();
646  int nval = fvec.size();
647  if (nval < 1) {
648  edm::LogError("HcalSim") << "HCalSD : # of " << str << " bins " << nval << " < 2 ==> illegal";
649  throw cms::Exception("Unknown", "HCalSD") << "nval < 2 for array " << str << "\n";
650  }
651 
652  return fvec;
653  } else {
654  edm::LogError("HcalSim") << "HCalSD : cannot get array " << str;
655  throw cms::Exception("Unknown", "HCalSD") << "cannot get array " << str << "\n";
656  }
657 }
658 
659 std::vector<G4String> HCalSD::getNames(DDFilteredView& fv) {
660  std::vector<G4String> tmp;
661  bool dodet = fv.firstChild();
662  while (dodet) {
663  const DDLogicalPart& log = fv.logicalPart();
664  bool ok = true;
665 
666  for (unsigned int i = 0; i < tmp.size(); ++i) {
667  if (!strcmp(tmp[i].c_str(), log.name().name().c_str())) {
668  ok = false;
669  break;
670  }
671  }
672  if (ok)
673  tmp.push_back(log.name().name());
674  dodet = fv.next();
675  }
676  return tmp;
677 }
678 
679 bool HCalSD::isItHF(const G4Step* aStep) {
680  const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
681  int levels = (touch->GetHistoryDepth()) + 1;
682  for (unsigned int it = 0; it < hfNames.size(); ++it) {
683  if (levels >= hfLevels[it]) {
684  const G4LogicalVolume* lv = touch->GetVolume(levels - hfLevels[it])->GetLogicalVolume();
685  if (lv == hfLV[it])
686  return true;
687  }
688  }
689  return false;
690 }
691 
692 bool HCalSD::isItHF(const G4String& name) {
693  for (auto nam : hfNames)
694  if (name == nam) {
695  return true;
696  }
697  return false;
698 }
699 
700 bool HCalSD::isItFibre(const G4LogicalVolume* lv) {
701  for (auto lvol : fibreLV)
702  if (lv == lvol) {
703  return true;
704  }
705  return false;
706 }
707 
708 bool HCalSD::isItFibre(const G4String& name) {
709  for (auto nam : fibreNames)
710  if (name == nam) {
711  return true;
712  }
713  return false;
714 }
715 
716 bool HCalSD::isItPMT(const G4LogicalVolume* lv) {
717  for (auto lvol : pmtLV)
718  if (lv == lvol) {
719  return true;
720  }
721  return false;
722 }
723 
724 bool HCalSD::isItStraightBundle(const G4LogicalVolume* lv) {
725  for (auto lvol : fibre1LV)
726  if (lv == lvol) {
727  return true;
728  }
729  return false;
730 }
731 
732 bool HCalSD::isItConicalBundle(const G4LogicalVolume* lv) {
733  for (auto lvol : fibre2LV)
734  if (lv == lvol) {
735  return true;
736  }
737  return false;
738 }
739 
740 bool HCalSD::isItScintillator(const G4Material* mat) {
741  for (auto amat : materials)
742  if (amat == mat) {
743  return true;
744  }
745  return false;
746 }
747 
748 bool HCalSD::isItinFidVolume(const G4ThreeVector& hitPoint) {
749  bool flag = true;
750  if (applyFidCut) {
751  int npmt = HFFibreFiducial::PMTNumber(hitPoint);
752 #ifdef EDM_ML_DEBUG
753  edm::LogVerbatim("HcalSim") << "HCalSD::isItinFidVolume:#PMT= " << npmt << " for hit point " << hitPoint;
754 #endif
755  if (npmt <= 0)
756  flag = false;
757  }
758 #ifdef EDM_ML_DEBUG
759  edm::LogVerbatim("HcalSim") << "HCalSD::isItinFidVolume: point " << hitPoint << " return flag " << flag;
760 #endif
761  return flag;
762 }
763 
764 void HCalSD::getFromHFLibrary(const G4Step* aStep, bool& isKilled) {
765  std::vector<HFShowerLibrary::Hit> hits = showerLibrary.get()->getHits(aStep, isKilled, weight_, false);
766  if (!isKilled || hits.empty()) {
767  return;
768  }
769 
770  int primaryID = setTrackID(aStep);
771 
772  // Reset entry point for new primary
773  resetForNewPrimary(aStep);
774 
775  auto const theTrack = aStep->GetTrack();
776  int det = 5;
777 
779  edepositEM = 1. * GeV;
780  edepositHAD = 0.;
781  } else {
782  edepositEM = 0.;
783  edepositHAD = 1. * GeV;
784  }
785 #ifdef EDM_ML_DEBUG
786  edm::LogVerbatim("HcalSim") << "HCalSD::getFromLibrary " << hits.size() << " hits for " << GetName() << " of "
787  << primaryID << " with " << theTrack->GetDefinition()->GetParticleName() << " of "
788  << aStep->GetPreStepPoint()->GetKineticEnergy() / GeV << " GeV";
789 #endif
790  for (unsigned int i = 0; i < hits.size(); ++i) {
791  G4ThreeVector hitPoint = hits[i].position;
792  if (isItinFidVolume(hitPoint)) {
793  int depth = hits[i].depth;
794  double time = hits[i].time;
795  unsigned int unitID = setDetUnitId(det, hitPoint, depth);
796  currentID.setID(unitID, time, primaryID, 0);
797 #ifdef plotDebug
798  plotProfile(aStep, hitPoint, 1.0 * GeV, time, depth);
799  bool emType = G4TrackToParticleID::isGammaElectronPositron(parCode);
800  plotHF(hitPoint, emType);
801 #endif
802  processHit(aStep);
803  }
804  }
805 }
806 
807 void HCalSD::hitForFibre(const G4Step* aStep) { // if not ParamShower
808 
809  std::vector<HFShower::Hit> hits = hfshower.get()->getHits(aStep, weight_);
810  if (hits.empty()) {
811  return;
812  }
813 
814  auto const theTrack = aStep->GetTrack();
815  int primaryID = setTrackID(aStep);
816  int det = 5;
817 
819  edepositEM = 1. * GeV;
820  edepositHAD = 0.;
821  } else {
822  edepositEM = 0.;
823  edepositHAD = 1. * GeV;
824  }
825 
826 #ifdef EDM_ML_DEBUG
827  edm::LogVerbatim("HcalSim") << "HCalSD::hitForFibre " << hits.size() << " hits for " << GetName() << " of "
828  << primaryID << " with " << theTrack->GetDefinition()->GetParticleName() << " of "
829  << preStepPoint->GetKineticEnergy() / GeV << " GeV in detector type " << det;
830 #endif
831 
832  for (unsigned int i = 0; i < hits.size(); ++i) {
833  G4ThreeVector hitPoint = hits[i].position;
834  if (isItinFidVolume(hitPoint)) {
835  int depth = hits[i].depth;
836  double time = hits[i].time;
837  unsigned int unitID = setDetUnitId(det, hitPoint, depth);
838  currentID.setID(unitID, time, primaryID, 0);
839 #ifdef plotDebug
840  plotProfile(aStep, hitPoint, edepositEM, time, depth);
841  bool emType = (edepositEM > 0.) ? true : false;
842  plotHF(hitPoint, emType);
843 #endif
844  processHit(aStep);
845  }
846  }
847 }
848 
849 void HCalSD::getFromParam(const G4Step* aStep, bool& isKilled) {
850  std::vector<HFShowerParam::Hit> hits = showerParam.get()->getHits(aStep, weight_, isKilled);
851  if (!isKilled || hits.empty()) {
852  return;
853  }
854 
855  int primaryID = setTrackID(aStep);
856  int det = 5;
857 
858 #ifdef EDM_ML_DEBUG
859  edm::LogVerbatim("HcalSim") << "HCalSD::getFromParam " << hits.size() << " hits for " << GetName() << " of "
860  << primaryID << " with " << aStep->GetTrack()->GetDefinition()->GetParticleName()
861  << " of " << preStepPoint->GetKineticEnergy() / GeV << " GeV in detector type " << det;
862 #endif
863  for (unsigned int i = 0; i < hits.size(); ++i) {
864  G4ThreeVector hitPoint = hits[i].position;
865  int depth = hits[i].depth;
866  double time = hits[i].time;
867  unsigned int unitID = setDetUnitId(det, hitPoint, depth);
868  currentID.setID(unitID, time, primaryID, 0);
869  edepositEM = hits[i].edep * GeV;
870  edepositHAD = 0.;
871 #ifdef plotDebug
872  plotProfile(aStep, hitPoint, edepositEM, time, depth);
873 #endif
874  processHit(aStep);
875  }
876 }
877 
878 void HCalSD::getHitPMT(const G4Step* aStep) {
879  auto const preStepPoint = aStep->GetPreStepPoint();
880  auto const theTrack = aStep->GetTrack();
881  double edep = showerPMT->getHits(aStep);
882 
883  if (edep >= 0.) {
884  edep *= GeV;
885  double etrack = preStepPoint->GetKineticEnergy();
886  int primaryID = 0;
887  if (etrack >= energyCut) {
888  primaryID = theTrack->GetTrackID();
889  } else {
890  primaryID = theTrack->GetParentID();
891  if (primaryID == 0)
892  primaryID = theTrack->GetTrackID();
893  }
894  // Reset entry point for new primary
895  resetForNewPrimary(aStep);
896  //
897  int det = static_cast<int>(HcalForward);
898  const G4ThreeVector& hitPoint = preStepPoint->GetPosition();
899  double rr = (hitPoint.x() * hitPoint.x() + hitPoint.y() * hitPoint.y());
900  double phi = (rr == 0. ? 0. : atan2(hitPoint.y(), hitPoint.x()));
901  double etaR = showerPMT->getRadius();
902  int depth = 1;
903  if (etaR < 0) {
904  depth = 2;
905  etaR = -etaR;
906  }
907  if (hitPoint.z() < 0)
908  etaR = -etaR;
909 #ifdef EDM_ML_DEBUG
910  edm::LogVerbatim("HcalSim") << "HCalSD::Hit for Detector " << det << " etaR " << etaR << " phi " << phi / deg
911  << " depth " << depth;
912 #endif
913  double time = (aStep->GetPostStepPoint()->GetGlobalTime());
914  uint32_t unitID = 0;
915  if (numberingFromDDD) {
916  HcalNumberingFromDDD::HcalID tmp = numberingFromDDD.get()->unitID(det, etaR, phi, depth, 1);
917  unitID = setDetUnitId(tmp);
918  }
919  currentID.setID(unitID, time, primaryID, 1);
920 
921  edepositHAD = aStep->GetTotalEnergyDeposit();
922  edepositEM = -edepositHAD + edep;
923 #ifdef plotDebug
924  plotProfile(aStep, hitPoint, edep, time, depth);
925 #endif
926 #ifdef EDM_ML_DEBUG
927  double beta = preStepPoint->GetBeta();
928  edm::LogVerbatim("HcalSim") << "HCalSD::getHitPMT 1 hit for " << GetName() << " of " << primaryID << " with "
929  << theTrack->GetDefinition()->GetParticleName() << " of "
930  << preStepPoint->GetKineticEnergy() / GeV << " GeV with velocity " << beta << " UnitID "
931  << std::hex << unitID << std::dec;
932 #endif
933  processHit(aStep);
934  }
935 }
936 
937 void HCalSD::getHitFibreBundle(const G4Step* aStep, bool type) {
938  auto const preStepPoint = aStep->GetPreStepPoint();
939  auto const theTrack = aStep->GetTrack();
940  double edep = showerBundle.get()->getHits(aStep, type);
941 
942  if (edep >= 0.0) {
943  edep *= GeV;
944  double etrack = preStepPoint->GetKineticEnergy();
945  int primaryID = 0;
946  if (etrack >= energyCut) {
947  primaryID = theTrack->GetTrackID();
948  } else {
949  primaryID = theTrack->GetParentID();
950  if (primaryID == 0)
951  primaryID = theTrack->GetTrackID();
952  }
953  // Reset entry point for new primary
954  resetForNewPrimary(aStep);
955  //
956  int det = static_cast<int>(HcalForward);
957  const G4ThreeVector& hitPoint = preStepPoint->GetPosition();
958  double rr = hitPoint.x() * hitPoint.x() + hitPoint.y() * hitPoint.y();
959  double phi = rr == 0. ? 0. : atan2(hitPoint.y(), hitPoint.x());
960  double etaR = showerBundle->getRadius();
961  int depth = 1;
962  if (etaR < 0.) {
963  depth = 2;
964  etaR = -etaR;
965  }
966  if (hitPoint.z() < 0.)
967  etaR = -etaR;
968 #ifdef EDM_ML_DEBUG
969  edm::LogVerbatim("HcalSim") << "HCalSD::Hit for Detector " << det << " etaR " << etaR << " phi " << phi / deg
970  << " depth " << depth;
971 #endif
972  double time = (aStep->GetPostStepPoint()->GetGlobalTime());
973  uint32_t unitID = 0;
974  if (numberingFromDDD) {
975  HcalNumberingFromDDD::HcalID tmp = numberingFromDDD.get()->unitID(det, etaR, phi, depth, 1);
976  unitID = setDetUnitId(tmp);
977  }
978  if (type)
979  currentID.setID(unitID, time, primaryID, 3);
980  else
981  currentID.setID(unitID, time, primaryID, 2);
982 
983  edepositHAD = aStep->GetTotalEnergyDeposit();
984  edepositEM = -edepositHAD + edep;
985 #ifdef plotDebug
986  plotProfile(aStep, hitPoint, edep, time, depth);
987 #endif
988 #ifdef EDM_ML_DEBUG
989  double beta = preStepPoint->GetBeta();
990  edm::LogVerbatim("HcalSim") << "HCalSD::getHitFibreBundle 1 hit for " << GetName() << " of " << primaryID
991  << " with " << theTrack->GetDefinition()->GetParticleName() << " of "
992  << preStepPoint->GetKineticEnergy() / GeV << " GeV with velocity " << beta << " UnitID "
993  << std::hex << unitID << std::dec;
994 #endif
995  processHit(aStep);
996  } // non-zero energy deposit
997 }
998 
1000  std::ifstream infile;
1001  int entry = 0;
1002  infile.open(fName.c_str(), std::ios::in);
1003  if (infile) {
1004  int det, zside, etaR, phi, lay;
1005  double wt;
1006  while (infile >> det >> zside >> etaR >> phi >> lay >> wt) {
1007  uint32_t id = HcalTestNumbering::packHcalIndex(det, zside, 1, etaR, phi, lay);
1008  layerWeights.insert(std::pair<uint32_t, double>(id, wt));
1009  ++entry;
1010 #ifdef EDM_ML_DEBUG
1011  edm::LogVerbatim("HcalSim") << "HCalSD::readWeightFromFile:Entry " << entry << " ID " << std::hex << id
1012  << std::dec << " (" << det << "/" << zside << "/1/" << etaR << "/" << phi << "/"
1013  << lay << ") Weight " << wt;
1014 #endif
1015  }
1016  infile.close();
1017  }
1018  edm::LogVerbatim("HcalSim") << "HCalSD::readWeightFromFile: reads " << entry << " weights from " << fName;
1019  if (entry <= 0)
1020  useLayerWt = false;
1021 }
1022 
1023 double HCalSD::layerWeight(int det, const G4ThreeVector& pos, int depth, int lay) {
1024  double wt = 1.;
1025  if (numberingFromDDD) {
1026  //get the ID's as eta, phi, depth, ... indices
1028  numberingFromDDD.get()->unitID(det, math::XYZVectorD(pos.x(), pos.y(), pos.z()), depth, lay);
1029  modifyDepth(tmp);
1030  uint32_t id = HcalTestNumbering::packHcalIndex(tmp.subdet, tmp.zside, 1, tmp.etaR, tmp.phis, tmp.lay);
1031  std::map<uint32_t, double>::const_iterator ite = layerWeights.find(id);
1032  if (ite != layerWeights.end())
1033  wt = ite->second;
1034 #ifdef EDM_ML_DEBUG
1035  edm::LogVerbatim("HcalSim") << "HCalSD::layerWeight: ID " << std::hex << id << std::dec << " (" << tmp.subdet << "/"
1036  << tmp.zside << "/1/" << tmp.etaR << "/" << tmp.phis << "/" << tmp.lay << ") Weight "
1037  << wt;
1038 #endif
1039  }
1040  return wt;
1041 }
1042 
1043 void HCalSD::plotProfile(const G4Step* aStep, const G4ThreeVector& global, double edep, double time, int id) {
1044  const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
1045  static const G4String modName[8] = {"HEModule", "HVQF", "HBModule", "MBAT", "MBBT", "MBBTC", "MBBT_R1P", "MBBT_R1M"};
1046  G4ThreeVector local;
1047  bool found = false;
1048  double depth = -2000;
1049  int idx = 4;
1050  for (int n = 0; n < touch->GetHistoryDepth(); ++n) {
1051  G4String name = touch->GetVolume(n)->GetName();
1052 #ifdef EDM_ML_DEBUG
1053  edm::LogVerbatim("HcalSim") << "plotProfile Depth " << n << " Name " << name;
1054 #endif
1055  for (unsigned int ii = 0; ii < 8; ++ii) {
1056  if (name == modName[ii]) {
1057  found = true;
1058  int dn = touch->GetHistoryDepth() - n;
1059  local = touch->GetHistory()->GetTransform(dn).TransformPoint(global);
1060  if (ii == 0) {
1061  depth = local.z() - 4006.5;
1062  idx = 1;
1063  } else if (ii == 1) {
1064  depth = local.z() + 825.0;
1065  idx = 3;
1066  } else if (ii == 2) {
1067  depth = local.x() - 1775.;
1068  idx = 0;
1069  } else {
1070  depth = local.y() + 15.;
1071  idx = 2;
1072  }
1073  break;
1074  }
1075  }
1076  if (found)
1077  break;
1078  }
1079  if (!found)
1080  depth = std::abs(global.z()) - 11500;
1081 #ifdef EDM_ML_DEBUG
1082  edm::LogVerbatim("HcalSim") << "plotProfile Found " << found << " Global " << global << " Local " << local
1083  << " depth " << depth << " ID " << id << " EDEP " << edep << " Time " << time;
1084 #endif
1085  if (hit_[idx] != nullptr)
1086  hit_[idx]->Fill(edep);
1087  if (time_[idx] != nullptr)
1088  time_[idx]->Fill(time, edep);
1089  if (dist_[idx] != nullptr)
1090  dist_[idx]->Fill(depth, edep);
1091  int jd = 2 * idx + id - 7;
1092  if (jd >= 0 && jd < 4) {
1093  jd += 5;
1094  if (hit_[jd] != nullptr)
1095  hit_[jd]->Fill(edep);
1096  if (time_[jd] != nullptr)
1097  time_[jd]->Fill(time, edep);
1098  if (dist_[jd] != nullptr)
1099  dist_[jd]->Fill(depth, edep);
1100  }
1101 }
1102 
1103 void HCalSD::plotHF(const G4ThreeVector& hitPoint, bool emType) {
1104  double zv = std::abs(hitPoint.z()) - gpar[4];
1105  if (emType) {
1106  if (hzvem != nullptr)
1107  hzvem->Fill(zv);
1108  } else {
1109  if (hzvhad != nullptr)
1110  hzvhad->Fill(zv);
1111  }
1112 }
1113 
1115  if (id.subdet == 4) {
1116  int ieta = (id.zside == 0) ? -id.etaR : id.etaR;
1117  if (hcalConstants->maxHFDepth(ieta, id.phis) > 2) {
1118  if (id.depth <= 2) {
1119  if (G4UniformRand() > 0.5)
1120  id.depth += 2;
1121  }
1122  }
1123  } else if ((id.subdet == 1 || id.subdet == 2) && testNumber) {
1124  id.depth = (depth_ == 0) ? 1 : 2;
1125  }
1126 }
float edepositEM
Definition: CaloSD.h:129
double energyCut
Definition: CaloSD.h:133
type
Definition: HCALResponse.h:21
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
void readWeightFromFile(const std::string &)
Definition: HCalSD.cc:999
std::vector< const G4LogicalVolume * > hfLV
Definition: HCalSD.h:115
bool useParam
Definition: HCalSD.h:106
double eminHitHE
Definition: HCalSD.h:107
TH1F * time_[9]
Definition: HCalSD.h:117
const DDLogicalPart & logicalPart() const
The logical-part of the current node in the filtered-view.
const std::vector< double > & doubles() const
a reference to the double-valued values stored in the given instance of DDValue
Definition: DDValue.cc:140
const double GeV
Definition: MathUtil.h:16
double kmaxNeutron
Definition: CaloSD.h:138
void hitForFibre(const G4Step *step)
Definition: HCalSD.cc:807
const N & name() const
Definition: DDBase.h:74
static bool isMuon(int pdgCode)
bool useLayerWt
Definition: HCalSD.h:103
Definition: CaloSD.h:38
const HcalDDDSimConstants * hcalConstants
Definition: HCalSD.h:95
std::unique_ptr< HFShowerParam > showerParam
Definition: HCalSD.h:91
double weight_
Definition: HCalSD.h:109
std::vector< double > gpar
Definition: HCalSD.h:111
bool useFibreBundle
Definition: HCalSD.h:103
int zside() const
get the z-side of the cell (1/-1)
Definition: HcalDetId.h:149
double betaThr
Definition: HCalSD.h:105
double deliveredLumi
Definition: HCalSD.h:108
#define nullptr
double eminHitHB
Definition: HCalSD.h:107
bool useShowerLibrary
Definition: HCalSD.h:106
std::vector< double > getDDDArray(const std::string &, const DDsvalues_type &)
Definition: HCalSD.cc:636
void plotProfile(const G4Step *step, const G4ThreeVector &pos, double edep, double time, int id)
Definition: HCalSD.cc:1043
double birk2
Definition: HCalSD.h:105
bool usePMTHit
Definition: HCalSD.h:103
std::vector< const G4LogicalVolume * > fibre2LV
Definition: HCalSD.h:115
int zside(DetId const &)
static const unsigned int numberOfZLayers
Definition: HFDarkening.h:24
void modifyDepth(HcalNumberingFromDDD::HcalID &id)
Definition: HCalSD.cc:1114
void update(const BeginOfJob *) override
This routine will be called when the appropriate signal arrives.
Definition: HCalSD.cc:539
void setNumberingScheme(HcalNumberingScheme *)
Definition: HCalSD.cc:532
void processHit(const G4Step *step)
Definition: CaloSD.h:103
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:80
bool agingFlagHE
Definition: HCalSD.h:102
double birk1
Definition: HCalSD.h:105
double kmaxProton
Definition: CaloSD.h:138
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:81
std::unique_ptr< HFShowerPMT > showerPMT
Definition: HCalSD.h:92
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
TH1F * hzvhad
Definition: HCalSD.h:117
bool isItConicalBundle(const G4LogicalVolume *)
Definition: HCalSD.cc:732
double eminHitHF
Definition: HCalSD.h:107
const double MeV
static uint32_t packHcalIndex(int det, int z, int depth, int eta, int phi, int lay)
std::unique_ptr< HcalNumberingFromDDD > numberingFromDDD
Definition: HCalSD.h:87
TH1F * hit_[9]
Definition: HCalSD.h:117
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > XYZVectorD
spatial vector with cartesian internal representation
Definition: Vector3D.h:8
int getMaxDepth(const int &type) const
HCalSD(const std::string &, const DDCompactView &, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *)
Definition: HCalSD.cc:48
bool agingFlagHB
Definition: HCalSD.h:102
bool testNumber
Definition: HCalSD.h:104
double kmaxIon
Definition: CaloSD.h:138
bool suppressHeavy
Definition: CaloSD.h:137
bool next()
set current node to the next node in the filtered tree
const std::vector< std::string > & getNames() const
bool useBirk
Definition: HCalSD.h:103
float edepositHAD
Definition: CaloSD.h:129
std::unique_ptr< HFDarkening > m_HFDarkening
Definition: HCalSD.h:98
double birk3
Definition: HCalSD.h:105
void resetForNewPrimary(const G4Step *)
Definition: CaloSD.cc:425
const HBHEDarkening * m_HEDarkening
Definition: HCalSD.h:97
bool isAvailable() const
Definition: Service.h:40
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:41
bool applyFidCut
Definition: HCalSD.h:106
TH1F * dist_[9]
Definition: HCalSD.h:117
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void plotHF(const G4ThreeVector &pos, bool emType)
Definition: HCalSD.cc:1103
std::unique_ptr< HcalTestNS > m_HcalTestNS
Definition: HCalSD.h:99
static void unpackHcalIndex(const uint32_t &idx, int &det, int &z, int &depth, int &eta, int &phi, int &lay)
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:93
T * make(const Args &...args) const
make new ROOT object
int getNumberOfHits()
Definition: CaloSD.cc:345
Definition: value.py:1
std::vector< int > hfLevels
Definition: HCalSD.h:112
void getFromParam(const G4Step *step, bool &isKilled)
Definition: HCalSD.cc:849
void getFromHFLibrary(const G4Step *step, bool &isKilled)
Definition: HCalSD.cc:764
uint32_t setDetUnitId(const G4Step *step) override
Definition: HCalSD.cc:520
double getLayer0Wt(const int &det, const int &phi, const int &zside) const
bool isItStraightBundle(const G4LogicalVolume *)
Definition: HCalSD.cc:724
bool testNS_
Definition: HCalSD.h:104
ii
Definition: cuy.py:590
bool getFromLibrary(const G4Step *) override
Definition: HCalSD.cc:331
double eminHitHO
Definition: HCalSD.h:107
double tmaxHit
Definition: CaloSD.h:133
static bool isStableHadronIon(const G4Track *)
int ietaAbs() const
get the absolute value of the cell ieta
Definition: HcalDetId.h:154
void setID(uint32_t unitID, double timeSlice, int trackID, uint16_t depth=0)
Definition: CaloHitID.cc:40
TH1F * hzvem
Definition: HCalSD.h:117
int iphi() const
get the cell iphi
Definition: HcalDetId.h:161
const std::vector< double > & getGparHF() const
std::vector< const G4LogicalVolume * > pmtLV
Definition: HCalSD.h:115
int PMTNumber(const G4ThreeVector &pe_effect)
Definition: DetId.h:18
static const unsigned int lowZLimit
Definition: HFDarkening.h:27
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
Definition: TFileService.h:69
bool filterHit(CaloG4Hit *, double) override
Definition: HCalSD.cc:590
CaloHitID currentID
Definition: CaloSD.h:131
static const unsigned int upperZLimit
Definition: HFDarkening.h:28
bool neutralDensity
Definition: HCalSD.h:104
bool isHF
Definition: HCalSD.h:101
void getHitFibreBundle(const G4Step *step, bool type)
Definition: HCalSD.cc:937
double getEnergyDeposit(const G4Step *) override
Definition: HCalSD.cc:388
int ke
bool isPrimary() const
std::unique_ptr< HFShowerFibreBundle > showerBundle
Definition: HCalSD.h:93
bool isItPMT(const G4LogicalVolume *)
Definition: HCalSD.cc:716
DDsvalues_type mergedSpecifics() const
bool isItinFidVolume(const G4ThreeVector &)
Definition: HCalSD.cc:748
bool isHF(int etabin, int depth)
void getHitPMT(const G4Step *step)
Definition: HCalSD.cc:878
double getAttenuation(const G4Step *aStep, double birk1, double birk2, double birk3) const
Definition: CaloSD.cc:438
std::unique_ptr< HFShowerLibrary > showerLibrary
Definition: HCalSD.h:89
double layerWeight(int, const G4ThreeVector &, int, int)
Definition: HCalSD.cc:1023
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
int depth_
Definition: HCalSD.h:110
HLT enums.
virtual int setTrackID(const G4Step *)
Definition: CaloSD.cc:592
std::map< uint32_t, double > layerWeights
Definition: HCalSD.h:116
bool isItHF(const G4Step *)
Definition: HCalSD.cc:679
std::vector< G4String > fibreNames
Definition: HCalSD.h:113
static bool isGammaElectronPositron(int pdgCode)
T get() const
Definition: EventSetup.h:71
std::vector< std::pair< unsigned int, DDValue > > DDsvalues_type
Definition: DDsvalues.h:12
bool firstChild()
set the current node to the first child ...
bool isItScintillator(const G4Material *)
Definition: HCalSD.cc:740
#define EDM_ML_DEBUG
std::unique_ptr< HcalNumberingScheme > numberingScheme
Definition: HCalSD.h:88
std::vector< G4String > hfNames
Definition: HCalSD.h:113
std::unique_ptr< HFShower > hfshower
Definition: HCalSD.h:90
std::vector< const G4LogicalVolume * > fibreLV
Definition: HCalSD.h:115
uint32_t getUnitID() const
Definition: CaloG4Hit.h:65
double getResponseWt(const G4Track *)
Definition: CaloSD.cc:623
std::vector< const G4LogicalVolume * > fibre1LV
Definition: HCalSD.h:115
#define str(s)
int maxHFDepth(const int &ieta, const int &iphi) const
std::vector< const G4Material * > materials
Definition: HCalSD.h:114
void initRun() override
Definition: HCalSD.cc:577
const HBHEDarkening * m_HBDarkening
Definition: HCalSD.h:96
const std::string & name() const
Returns the name.
Definition: DDName.cc:53
const DDMaterial & material(void) const
Returns a reference object of the material this LogicalPart is made of.
std::vector< G4String > matNames
Definition: HCalSD.h:113
float degradation(float intlumi, int ieta, int lay) const
double getEnergyDeposit() const
Definition: CaloG4Hit.h:77
bool useHF
Definition: HCalSD.h:106
bool isItFibre(const G4LogicalVolume *)
Definition: HCalSD.cc:700
void setParameterized(bool val)
Definition: CaloSD.h:100
void fillLogVolumeVector(const std::string &, const std::string &, const DDCompactView &, std::vector< const G4LogicalVolume * > &, std::vector< G4String > &)
Definition: HCalSD.cc:298