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