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  LogDebug("HcalSim") << "***************************************************"
102  << "\n"
103  << "* Constructing a HCalSD with name " << name << "\n"
104  << "\n"
105  << "***************************************************";
106 #endif
107  edm::LogInfo("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::LogInfo("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::LogInfo("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::LogInfo("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::LogInfo("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::LogInfo("HcalSim") << "HCalSD::getFromLibrary: HFLumiDarkening at r= "
341  << r << ", z= " << z << " Dose= " << dose_acquired
342  << " weight= " << weight_;
343 #endif
344  }
345 
346  if (useParam) {
347  getFromParam(aStep, kill);
348 #ifdef EDM_ML_DEBUG
349  G4String nameVolume = lv->GetName();
350  LogDebug("HcalSim") << "HCalSD: " << getNumberOfHits()
351  << " hits from parametrization in " << nameVolume
352  << " for Track " << track->GetTrackID()
353  <<" (" << track->GetDefinition()->GetParticleName()
354  <<")";
355 #endif
359 #ifdef EDM_ML_DEBUG
360  auto nameVolume =
361  aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetName();
362  edm::LogInfo("HcalSim") << "HCalSD: Starts shower library from "
363  << nameVolume << " for Track "
364  << track->GetTrackID() << " ("
365  << track->GetDefinition()->GetParticleName() << ")";
366 
367 #endif
368  getFromHFLibrary(aStep, kill);
369  }
370  }
371  }
372 #ifdef EDM_ML_DEBUG
373  edm::LogInfo("HcalSim") << "HCalSD::getFromLibrary ID= "
374  << track->GetTrackID() << " ("
375  << track->GetDefinition()->GetParticleName()
376  << ") kill= " << kill << " weight= " << weight_
377  << " depth= " << depth_ << " isHF: " << isHF;
378 #endif
379  return kill;
380 }
381 
382 double HCalSD::getEnergyDeposit(const G4Step* aStep) {
383  double destep(0.0);
384  auto const lv = aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume();
385  auto const theTrack = aStep->GetTrack();
386 
387  if(isHF) {
388  if (useShowerLibrary && G4TrackToParticleID::isMuon(theTrack) && isItFibre(lv)) {
389 #ifdef EDM_ML_DEBUG
390  edm::LogInfo("HcalSim") << "HCalSD: Hit at Fibre in LV " << lv->GetName()
391  << " for track " << aStep->GetTrack()->GetTrackID() <<" ("
392  << aStep->GetTrack()->GetDefinition()->GetParticleName() << ")";
393 #endif
394  hitForFibre(aStep);
395  }
396  return destep;
397  }
398 
399  if (isItPMT(lv)) {
400  if(usePMTHit && showerPMT) { getHitPMT(aStep); }
401 #ifdef EDM_ML_DEBUG
402  edm::LogInfo("HcalSim") << "HCalSD: Hit from PMT parametrization in LV "
403  << lv->GetName() << " for Track "
404  << aStep->GetTrack()->GetTrackID() << " ("
405  << aStep->GetTrack()->GetDefinition()->GetParticleName() << ")";
406 #endif
407  return destep;
408 
409  } else if (isItStraightBundle(lv)) {
410  if(useFibreBundle && showerBundle) { getHitFibreBundle(aStep, false); }
411 #ifdef EDM_ML_DEBUG
412  edm::LogInfo("HcalSim") << "HCalSD: Hit from straight FibreBundle in LV: "
413  << lv->GetName() << " for track "
414  << aStep->GetTrack()->GetTrackID() << " ("
415  << aStep->GetTrack()->GetDefinition()->GetParticleName() << ")";
416 #endif
417  return destep;
418 
419  } else if(isItConicalBundle(lv)) {
420  if(useFibreBundle && showerBundle) { getHitFibreBundle(aStep, true); }
421 #ifdef EDM_ML_DEBUG
422  edm::LogInfo("HcalSim") << "HCalSD: Hit from conical FibreBundle PV: "
423  << lv->GetName() << " for track "
424  << aStep->GetTrack()->GetTrackID() << " ("
425  << aStep->GetTrack()->GetDefinition()->GetParticleName() << ")";
426 #endif
427  return destep;
428  }
429 
430  // normal hit
431  destep = aStep->GetTotalEnergyDeposit();
432 
433  const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
434  uint32_t detid = setDetUnitId(aStep);
435  int det(0), ieta(0), phi(0), z(0), lay, depth(-1);
436  if (testNumber) {
437  HcalTestNumbering::unpackHcalIndex(detid,det,z,depth,ieta,phi,lay);
438  if (z==0) { z = -1; }
439  } else {
440  HcalDetId hcid(detid);
441  det = hcid.subdetId();
442  ieta = hcid.ietaAbs();
443  phi = hcid.iphi();
444  z = hcid.zside();
445  }
446  lay = (touch->GetReplicaNumber(0)/10)%100 + 1;
447 #ifdef EDM_ML_DEBUG
448  edm::LogInfo("HcalSim") << "HCalSD: det: " << det << " ieta: "<< ieta
449  << " iphi: " << phi << " zside " << z << " lay: "
450  << lay-2;
451 #endif
452  if (depth_==0 && (det==1 || det==2) && ((!testNumber) || neutralDensity))
454  if (useLayerWt) {
455  G4ThreeVector hitPoint = aStep->GetPreStepPoint()->GetPosition();
456  weight_ = layerWeight(det+2, hitPoint, depth_, lay);
457  }
458 
459  if (m_HBDarkening && det == 1) {
460  double dweight = m_HBDarkening->degradation(deliveredLumi,ieta,lay);
461  weight_ *= dweight;
462 #ifdef EDM_ML_DEBUG
463  edm::LogInfo("HcalSim") << "HCalSD: HB Lumi: " << deliveredLumi
464  << " coefficient = " << dweight << " Weight= " << weight_;
465 #endif
466  }
467 
468  if (m_HEDarkening && det == 2) {
469  double dweight = m_HEDarkening->degradation(deliveredLumi,ieta,lay);
470  weight_ *= dweight;
471 #ifdef EDM_ML_DEBUG
472  edm::LogInfo("HcalSim") << "HCalSD: HB Lumi: " << deliveredLumi
473  << " coefficient = " << dweight << " Weight= " << weight_;
474 #endif
475  }
476 
477  if (suppressHeavy) {
478  TrackInformation * trkInfo = (TrackInformation *)(theTrack->GetUserInformation());
479  if (trkInfo) {
480  int pdg = theTrack->GetDefinition()->GetPDGEncoding();
481  if (!(trkInfo->isPrimary())) { // Only secondary particles
482  double ke = theTrack->GetKineticEnergy();
483  if ( pdg/1000000000 == 1 && (pdg/10000)%100 > 0 &&
484  (pdg/10)%100 > 0 && ke <kmaxIon ) weight_ = 0;
485  if ((pdg == 2212) && (ke < kmaxProton)) weight_ = 0;
486  if ((pdg == 2112) && (ke < kmaxNeutron)) weight_ = 0;
487  }
488  }
489  }
490  if (useBirk) {
491  const G4Material* mat = aStep->GetPreStepPoint()->GetMaterial();
492  if (isItScintillator(mat)) weight_ *= getAttenuation(aStep, birk1, birk2, birk3);
493  }
494  double wt1 = getResponseWt(theTrack);
495  double wt2 = theTrack->GetWeight();
496  double edep = weight_*wt1*destep;
497  if (wt2 > 0.0) { edep *= wt2; }
498 #ifdef EDM_ML_DEBUG
499  edm::LogInfo("HcalSim")
500  << "HCalSD: edep= " << edep << " Det: " << det+2 << " depth= " << depth_
501  << " weight= " << weight_ << " wt1= " << wt1 << " wt2= " << wt2;
502 #endif
503  return edep;
504 }
505 
506 uint32_t HCalSD::setDetUnitId(const G4Step * aStep) {
507 
508  auto const prePoint = aStep->GetPreStepPoint();
509  auto const touch = prePoint->GetTouchable();
510  const G4ThreeVector& hitPoint = prePoint->GetPosition();
511 
512  int depth = (touch->GetReplicaNumber(0))%10 + 1;
513  int lay = (touch->GetReplicaNumber(0)/10)%100 + 1;
514  int det = (touch->GetReplicaNumber(1))/1000;
515 
516  return setDetUnitId (det, hitPoint, depth, lay);
517 }
518 
520  if (scheme != nullptr) {
521  edm::LogInfo("HcalSim") << "HCalSD: updates numbering scheme for " << GetName();
522  numberingScheme.reset(scheme);
523  }
524 }
525 
526 void HCalSD::update(const BeginOfJob * job) {
527 
528  const edm::EventSetup* es = (*job)();
530  es->get<HcalSimNumberingRecord>().get(hdc);
531  if (hdc.isValid()) {
532  hcalConstants = (HcalDDDSimConstants*)(&(*hdc));
533  } else {
534  edm::LogError("HcalSim") << "HCalSD : Cannot find HcalDDDSimConstant";
535  throw cms::Exception("Unknown", "HCalSD") << "Cannot find HcalDDDSimConstant" << "\n";
536  }
537 
539 
540  //Special Geometry parameters
542  std::stringstream sss;
543  for (unsigned int ig=0; ig<gpar.size(); ig++) {
544  sss << "\n gpar[" << ig << "] = " << gpar[ig]/cm << " cm";
545  }
546  edm::LogInfo("HcalSim") << "Maximum depth for HF " << hcalConstants->getMaxDepth(2)
547  << gpar.size()<< " gpar (cm)" << sss.str();
548  //Test Hcal Numbering Scheme
549  if (testNS_) m_HcalTestNS.reset(new HcalTestNS(es));
550 
551  if (agingFlagHB) {
553  es->get<HBHEDarkeningRecord>().get("HB",hdark);
554  m_HBDarkening = &*hdark;
555  }
556  if (agingFlagHE) {
558  es->get<HBHEDarkeningRecord>().get("HE",hdark);
559  m_HEDarkening = &*hdark;
560  }
561 }
562 
564  if (showerLibrary.get()) showerLibrary.get()->initRun(nullptr, hcalConstants);
565  if (showerParam.get()) showerParam.get()->initRun(hcalConstants);
566  if (hfshower.get()) hfshower.get()->initRun(hcalConstants);
567  if (showerPMT.get()) showerPMT.get()->initRun(hcalConstants);
568  if (showerBundle.get()) showerBundle.get()->initRun(hcalConstants);
569 }
570 
571 bool HCalSD::filterHit(CaloG4Hit* aHit, double time) {
572  double threshold=0;
573  DetId theId(aHit->getUnitID());
574  switch (theId.subdetId()) {
575  case HcalBarrel:
576  threshold = eminHitHB; break;
577  case HcalEndcap:
578  threshold = eminHitHE; break;
579  case HcalOuter:
580  threshold = eminHitHO; break;
581  case HcalForward:
582  threshold = eminHitHF; break;
583  default:
584  break;
585  }
586  return ((time <= tmaxHit) && (aHit->getEnergyDeposit() > threshold));
587 }
588 
589 uint32_t HCalSD::setDetUnitId (int det, const G4ThreeVector& pos, int depth, int lay=1) {
590  uint32_t id = 0;
591  if (numberingFromDDD.get()) {
592  //get the ID's as eta, phi, depth, ... indices
593  HcalNumberingFromDDD::HcalID tmp = numberingFromDDD.get()->unitID(det, pos, depth, lay);
594  id = setDetUnitId(tmp);
595  }
596  return id;
597 }
598 
600  modifyDepth(tmp);
601  uint32_t id = (numberingScheme.get()) ? numberingScheme.get()->getUnitID(tmp) : 0;
602  if ((!testNumber) && m_HcalTestNS.get()) {
603  bool ok = m_HcalTestNS.get()->compare(tmp,id);
604  if (!ok)
605  edm::LogWarning("HcalSim") << "Det ID from HCalSD " << HcalDetId(id)
606  << " " << std::hex << id << std::dec
607  << " does not match one from relabller for "
608  << tmp.subdet << ":" << tmp.etaR << ":"
609  << tmp.phi << ":" << tmp.phis << ":"
610  << tmp.depth << ":" << tmp.lay << std::endl;
611  }
612  return id;
613 }
614 
615 std::vector<double> HCalSD::getDDDArray(const std::string & str,
616  const DDsvalues_type & sv) {
617 #ifdef EDM_ML_DEBUG
618  LogDebug("HcalSim") << "HCalSD:getDDDArray called for " << str;
619 #endif
620  DDValue value(str);
621  if (DDfetch(&sv,value)) {
622 #ifdef EDM_ML_DEBUG
623  LogDebug("HcalSim") << value;
624 #endif
625  const std::vector<double> & fvec = value.doubles();
626  int nval = fvec.size();
627  if (nval < 1) {
628  edm::LogError("HcalSim") << "HCalSD : # of " << str << " bins " << nval
629  << " < 2 ==> illegal";
630  throw cms::Exception("Unknown", "HCalSD") << "nval < 2 for array " << str << "\n";
631  }
632 
633  return fvec;
634  } else {
635  edm::LogError("HcalSim") << "HCalSD : cannot get array " << str;
636  throw cms::Exception("Unknown", "HCalSD") << "cannot get array " << str << "\n";
637  }
638 }
639 
640 std::vector<G4String> HCalSD::getNames(DDFilteredView& fv) {
641 
642  std::vector<G4String> tmp;
643  bool dodet = fv.firstChild();
644  while (dodet) {
645  const DDLogicalPart & log = fv.logicalPart();
646  bool ok = true;
647 
648  for (unsigned int i=0; i<tmp.size(); ++i) {
649  if (!strcmp(tmp[i].c_str(), log.name().name().c_str())) {
650  ok = false;
651  break;
652  }
653  }
654  if (ok) tmp.push_back(log.name().name());
655  dodet = fv.next();
656  }
657  return tmp;
658 }
659 
660 bool HCalSD::isItHF(const G4Step * aStep) {
661  const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
662  int levels = (touch->GetHistoryDepth()) + 1;
663  for (unsigned int it=0; it < hfNames.size(); ++it) {
664  if (levels >= hfLevels[it]) {
665  const G4LogicalVolume* lv = touch->GetVolume(levels-hfLevels[it])->GetLogicalVolume();
666  if (lv == hfLV[it]) return true;
667  }
668  }
669  return false;
670 }
671 
672 bool HCalSD::isItHF (const G4String& name) {
673  for (auto nam : hfNames) if (name == nam) { return true; }
674  return false;
675 }
676 
677 bool HCalSD::isItFibre (const G4LogicalVolume* lv) {
678  for (auto lvol : fibreLV) if (lv == lvol) { return true; }
679  return false;
680 }
681 
682 bool HCalSD::isItFibre (const G4String& name) {
683  for (auto nam : fibreNames) if (name == nam) { return true; }
684  return false;
685 }
686 
687 bool HCalSD::isItPMT (const G4LogicalVolume* lv) {
688  for (auto lvol : pmtLV) if (lv == lvol) { return true; }
689  return false;
690 }
691 
692 bool HCalSD::isItStraightBundle (const G4LogicalVolume* lv) {
693  for (auto lvol : fibre1LV) if (lv == lvol) { return true; }
694  return false;
695 }
696 
697 bool HCalSD::isItConicalBundle (const G4LogicalVolume* lv) {
698  for (auto lvol : fibre2LV) if (lv == lvol) { return true; }
699  return false;
700 }
701 
702 bool HCalSD::isItScintillator (const G4Material* mat) {
703  for (auto amat : materials) if (amat == mat) { return true; }
704  return false;
705 }
706 
707 bool HCalSD::isItinFidVolume (const G4ThreeVector& hitPoint) {
708  bool flag = true;
709  if (applyFidCut) {
710  int npmt = HFFibreFiducial::PMTNumber(hitPoint);
711 #ifdef EDM_ML_DEBUG
712  edm::LogInfo("HcalSim") << "HCalSD::isItinFidVolume:#PMT= " << npmt
713  << " for hit point " << hitPoint;
714 #endif
715  if (npmt <= 0) flag = false;
716  }
717 #ifdef EDM_ML_DEBUG
718  edm::LogInfo("HcalSim") << "HCalSD::isItinFidVolume: point " << hitPoint
719  << " return flag " << flag;
720 #endif
721  return flag;
722 }
723 
724 void HCalSD::getFromHFLibrary (const G4Step* aStep, bool& isKilled) {
725 
726  std::vector<HFShowerLibrary::Hit> hits = showerLibrary.get()->getHits(aStep, isKilled, weight_, false);
727  if(!isKilled || hits.empty()) { return; }
728 
729  int primaryID = setTrackID(aStep);
730 
731  // Reset entry point for new primary
732  resetForNewPrimary(aStep);
733 
734  auto const theTrack = aStep->GetTrack();
735  int det = 5;
736 
738  edepositEM = 1.*GeV;
739  edepositHAD = 0.;
740  } else {
741  edepositEM = 0.;
742  edepositHAD = 1.*GeV;
743  }
744 #ifdef EDM_ML_DEBUG
745  edm::LogInfo("HcalSim") << "HCalSD::getFromLibrary " <<hits.size()
746  << " hits for " << GetName() << " of " << primaryID
747  << " with " << theTrack->GetDefinition()->GetParticleName()
748  << " of " << aStep->GetPreStepPoint()->GetKineticEnergy()/GeV << " GeV";
749 #endif
750  for (unsigned int i=0; i<hits.size(); ++i) {
751  G4ThreeVector hitPoint = hits[i].position;
752  if (isItinFidVolume (hitPoint)) {
753  int depth = hits[i].depth;
754  double time = hits[i].time;
755  unsigned int unitID = setDetUnitId(det, hitPoint, depth);
756  currentID.setID(unitID, time, primaryID, 0);
757 #ifdef plotDebug
758  plotProfile(aStep, hitPoint, 1.0*GeV, time, depth);
759  bool emType = G4TrackToParticleID::isGammaElectronPositron(parCode);
760  plotHF(hitPoint,emType);
761 #endif
762  processHit(aStep);
763  }
764  }
765 }
766 
767 void HCalSD::hitForFibre (const G4Step* aStep) { // if not ParamShower
768 
769  std::vector<HFShower::Hit> hits = hfshower.get()->getHits(aStep, weight_);
770  if(hits.empty()) { return; }
771 
772  auto const theTrack = aStep->GetTrack();
773  int primaryID = setTrackID(aStep);
774  int det = 5;
775 
777  edepositEM = 1.*GeV;
778  edepositHAD = 0.;
779  } else {
780  edepositEM = 0.;
781  edepositHAD = 1.*GeV;
782  }
783 
784 #ifdef EDM_ML_DEBUG
785  edm::LogInfo("HcalSim") << "HCalSD::hitForFibre " << hits.size()
786  << " hits for " << GetName() << " of " << primaryID
787  << " with " << theTrack->GetDefinition()->GetParticleName()
788  << " of " << preStepPoint->GetKineticEnergy()/GeV
789  << " GeV in detector type " << det;
790 #endif
791 
792  for (unsigned int i=0; i<hits.size(); ++i) {
793  G4ThreeVector hitPoint = hits[i].position;
794  if (isItinFidVolume (hitPoint)) {
795  int depth = hits[i].depth;
796  double time = hits[i].time;
797  unsigned int unitID = setDetUnitId(det, hitPoint, depth);
798  currentID.setID(unitID, time, primaryID, 0);
799 #ifdef plotDebug
800  plotProfile(aStep, hitPoint, edepositEM, time, depth);
801  bool emType = (edepositEM > 0.) ? true : false;
802  plotHF(hitPoint,emType);
803 #endif
804  processHit(aStep);
805  }
806  }
807 }
808 
809 void HCalSD::getFromParam (const G4Step* aStep, bool& isKilled) {
810 
811  std::vector<HFShowerParam::Hit> hits = showerParam.get()->getHits(aStep, weight_, isKilled);
812  if(!isKilled || hits.empty()) { return; }
813 
814  int primaryID = setTrackID(aStep);
815  int det = 5;
816 
817 #ifdef EDM_ML_DEBUG
818  edm::LogInfo("HcalSim") << "HCalSD::getFromParam " << hits.size() << " hits for "
819  << GetName() << " of " << primaryID << " with "
820  << aStep->GetTrack()->GetDefinition()->GetParticleName()
821  << " of " << preStepPoint->GetKineticEnergy()/GeV
822  << " GeV in detector type " << det;
823 #endif
824  for (unsigned int i=0; i<hits.size(); ++i) {
825  G4ThreeVector hitPoint = hits[i].position;
826  int depth = hits[i].depth;
827  double time = hits[i].time;
828  unsigned int unitID = setDetUnitId(det, hitPoint, depth);
829  currentID.setID(unitID, time, primaryID, 0);
830  edepositEM = hits[i].edep*GeV;
831  edepositHAD = 0.;
832 #ifdef plotDebug
833  plotProfile(aStep, hitPoint, edepositEM, time, depth);
834 #endif
835  processHit(aStep);
836  }
837 }
838 
839 void HCalSD::getHitPMT (const G4Step * aStep) {
840 
841  auto const preStepPoint = aStep->GetPreStepPoint();
842  auto const theTrack = aStep->GetTrack();
843  double edep = showerPMT->getHits(aStep);
844 
845  if (edep >= 0.) {
846  edep *= GeV;
847  double etrack = preStepPoint->GetKineticEnergy();
848  int primaryID = 0;
849  if (etrack >= energyCut) {
850  primaryID = theTrack->GetTrackID();
851  } else {
852  primaryID = theTrack->GetParentID();
853  if (primaryID == 0) primaryID = theTrack->GetTrackID();
854  }
855  // Reset entry point for new primary
856  resetForNewPrimary(aStep);
857  //
858  int det = static_cast<int>(HcalForward);
859  const G4ThreeVector& hitPoint = preStepPoint->GetPosition();
860  double rr = (hitPoint.x()*hitPoint.x() + hitPoint.y()*hitPoint.y());
861  double phi = (rr == 0. ? 0. :atan2(hitPoint.y(),hitPoint.x()));
862  double etaR = showerPMT->getRadius();
863  int depth = 1;
864  if (etaR < 0) {
865  depth = 2;
866  etaR =-etaR;
867  }
868  if (hitPoint.z() < 0) etaR =-etaR;
869 #ifdef EDM_ML_DEBUG
870  edm::LogInfo("HcalSim") << "HCalSD::Hit for Detector " << det << " etaR "
871  << etaR << " phi " << phi/deg << " depth " <<depth;
872 #endif
873  double time = (aStep->GetPostStepPoint()->GetGlobalTime());
874  uint32_t unitID = 0;
875  if (numberingFromDDD) {
876  HcalNumberingFromDDD::HcalID tmp = numberingFromDDD.get()->unitID(det,etaR,phi,
877  depth,1);
878  unitID = setDetUnitId(tmp);
879  }
880  currentID.setID(unitID, time, primaryID, 1);
881 
882  edepositHAD = aStep->GetTotalEnergyDeposit();
883  edepositEM =-edepositHAD + edep;
884 #ifdef plotDebug
885  plotProfile(aStep, hitPoint, edep, time, depth);
886 #endif
887 #ifdef EDM_ML_DEBUG
888  double beta = preStepPoint->GetBeta();
889  LogDebug("HcalSim") << "HCalSD::getHitPMT 1 hit for " << GetName()
890  << " of " << primaryID << " with "
891  << theTrack->GetDefinition()->GetParticleName()
892  << " of " << preStepPoint->GetKineticEnergy()/GeV
893  << " GeV with velocity " << beta << " UnitID "
894  << std::hex << unitID << std::dec;
895 #endif
896  processHit(aStep);
897  }
898 }
899 
900 void HCalSD::getHitFibreBundle (const G4Step* aStep, bool type) {
901  auto const preStepPoint = aStep->GetPreStepPoint();
902  auto const theTrack = aStep->GetTrack();
903  double edep = showerBundle.get()->getHits(aStep, type);
904 
905  if (edep >= 0.0) {
906  edep *= GeV;
907  double etrack = preStepPoint->GetKineticEnergy();
908  int primaryID = 0;
909  if (etrack >= energyCut) {
910  primaryID = theTrack->GetTrackID();
911  } else {
912  primaryID = theTrack->GetParentID();
913  if (primaryID == 0) primaryID = theTrack->GetTrackID();
914  }
915  // Reset entry point for new primary
916  resetForNewPrimary(aStep);
917  //
918  int det = static_cast<int>(HcalForward);
919  const G4ThreeVector& hitPoint = preStepPoint->GetPosition();
920  double rr = hitPoint.x()*hitPoint.x() + hitPoint.y()*hitPoint.y();
921  double phi = rr == 0. ? 0. :atan2(hitPoint.y(),hitPoint.x());
922  double etaR = showerBundle->getRadius();
923  int depth = 1;
924  if (etaR < 0.) {
925  depth = 2;
926  etaR =-etaR;
927  }
928  if (hitPoint.z() < 0.) etaR =-etaR;
929 #ifdef EDM_ML_DEBUG
930  LogDebug("HcalSim") << "HCalSD::Hit for Detector " << det << " etaR "
931  << etaR << " phi " << phi/deg << " depth " <<depth;
932 #endif
933  double time = (aStep->GetPostStepPoint()->GetGlobalTime());
934  uint32_t unitID = 0;
935  if (numberingFromDDD) {
936  HcalNumberingFromDDD::HcalID tmp = numberingFromDDD.get()->unitID(det,etaR,phi,depth,1);
937  unitID = setDetUnitId(tmp);
938  }
939  if (type) currentID.setID(unitID, time, primaryID, 3);
940  else currentID.setID(unitID, time, primaryID, 2);
941 
942  edepositHAD = aStep->GetTotalEnergyDeposit();
943  edepositEM =-edepositHAD + edep;
944 #ifdef plotDebug
945  plotProfile(aStep, hitPoint, edep, time, depth);
946 #endif
947 #ifdef EDM_ML_DEBUG
948  double beta = preStepPoint->GetBeta();
949  LogDebug("HcalSim") << "HCalSD::getHitFibreBundle 1 hit for " << GetName()
950  << " of " << primaryID << " with "
951  << theTrack->GetDefinition()->GetParticleName()
952  << " of " << preStepPoint->GetKineticEnergy()/GeV
953  << " GeV with velocity " << beta << " UnitID "
954  << std::hex << unitID << std::dec;
955 #endif
956  processHit(aStep);
957  } // non-zero energy deposit
958 }
959 
961 
962  std::ifstream infile;
963  int entry=0;
964  infile.open(fName.c_str(), std::ios::in);
965  if (infile) {
966  int det, zside, etaR, phi, lay;
967  double wt;
968  while (infile >> det >> zside >> etaR >> phi >> lay >> wt) {
969  uint32_t id = HcalTestNumbering::packHcalIndex(det,zside,1,etaR,phi,lay);
970  layerWeights.insert(std::pair<uint32_t,double>(id,wt));
971  ++entry;
972 #ifdef EDM_ML_DEBUG
973  edm::LogInfo("HcalSim") << "HCalSD::readWeightFromFile:Entry " << entry
974  << " ID " << std::hex << id << std::dec << " ("
975  << det << "/" << zside << "/1/" << etaR << "/"
976  << phi << "/" << lay << ") Weight " << wt;
977 #endif
978  }
979  infile.close();
980  }
981  edm::LogInfo("HcalSim") << "HCalSD::readWeightFromFile: reads " << entry
982  << " weights from " << fName;
983  if (entry <= 0) useLayerWt = false;
984 }
985 
986 double HCalSD::layerWeight(int det, const G4ThreeVector& pos, int depth, int lay) {
987 
988  double wt = 1.;
989  if (numberingFromDDD) {
990  //get the ID's as eta, phi, depth, ... indices
991  HcalNumberingFromDDD::HcalID tmp = numberingFromDDD.get()->unitID(det, pos,
992  depth, lay);
993  modifyDepth(tmp);
994  uint32_t id = HcalTestNumbering::packHcalIndex(tmp.subdet, tmp.zside, 1,
995  tmp.etaR, tmp.phis,tmp.lay);
996  std::map<uint32_t,double>::const_iterator ite = layerWeights.find(id);
997  if (ite != layerWeights.end()) wt = ite->second;
998 #ifdef EDM_ML_DEBUG
999  edm::LogInfo("HcalSim") << "HCalSD::layerWeight: ID " << std::hex << id
1000  << std::dec << " (" << tmp.subdet << "/"
1001  << tmp.zside << "/1/" << tmp.etaR << "/"
1002  << tmp.phis << "/" << tmp.lay << ") Weight " <<wt;
1003 #endif
1004  }
1005  return wt;
1006 }
1007 
1008 void HCalSD::plotProfile(const G4Step* aStep,const G4ThreeVector& global, double edep,
1009  double time, int id) {
1010 
1011  const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
1012  static const G4String modName[8] = {"HEModule", "HVQF" , "HBModule", "MBAT",
1013  "MBBT" , "MBBTC", "MBBT_R1P", "MBBT_R1M"};
1014  G4ThreeVector local;
1015  bool found=false;
1016  double depth=-2000;
1017  int idx = 4;
1018  for (int n=0; n<touch->GetHistoryDepth(); ++n) {
1019  G4String name = touch->GetVolume(n)->GetName();
1020 #ifdef EDM_ML_DEBUG
1021  LogDebug("HcalSim") << "plotProfile Depth " << n << " Name " << name;
1022 #endif
1023  for (unsigned int ii=0; ii<8; ++ii) {
1024  if (name == modName[ii]) {
1025  found = true;
1026  int dn = touch->GetHistoryDepth() - n;
1027  local = touch->GetHistory()->GetTransform(dn).TransformPoint(global);
1028  if (ii == 0) {depth = local.z() - 4006.5; idx = 1;}
1029  else if (ii == 1) {depth = local.z() + 825.0; idx = 3;}
1030  else if (ii == 2) {depth = local.x() - 1775.; idx = 0;}
1031  else {depth = local.y() + 15.; idx = 2;}
1032  break;
1033  }
1034  }
1035  if (found) break;
1036  }
1037  if (!found) depth = std::abs(global.z()) - 11500;
1038 #ifdef EDM_ML_DEBUG
1039  LogDebug("HcalSim") << "plotProfile Found " << found << " Global " << global
1040  << " Local " << local << " depth " << depth << " ID "
1041  << id << " EDEP " << edep << " Time " << time;
1042 #endif
1043  if (hit_[idx] != nullptr) hit_[idx]->Fill(edep);
1044  if (time_[idx] != nullptr) time_[idx]->Fill(time,edep);
1045  if (dist_[idx] != nullptr) dist_[idx]->Fill(depth,edep);
1046  int jd = 2*idx + id - 7;
1047  if (jd >= 0 && jd < 4) {
1048  jd += 5;
1049  if (hit_[jd] != nullptr) hit_[jd]->Fill(edep);
1050  if (time_[jd] != nullptr) time_[jd]->Fill(time,edep);
1051  if (dist_[jd] != nullptr) dist_[jd]->Fill(depth,edep);
1052  }
1053 }
1054 
1055 void HCalSD::plotHF(const G4ThreeVector& hitPoint, bool emType) {
1056  double zv = std::abs(hitPoint.z()) - gpar[4];
1057  if (emType) {
1058  if (hzvem != nullptr) hzvem->Fill(zv);
1059  } else {
1060  if (hzvhad != nullptr) hzvhad->Fill(zv);
1061  }
1062 }
1063 
1065  if (id.subdet == 4) {
1066  int ieta = (id.zside == 0) ? -id.etaR : id.etaR;
1067  if (hcalConstants->maxHFDepth(ieta,id.phis) > 2) {
1068  if (id.depth <= 2) {
1069  if (G4UniformRand() > 0.5) id.depth += 2;
1070  }
1071  }
1072  } else if ((id.subdet == 1 || id.subdet ==2) && testNumber) {
1073  id.depth = (depth_ == 0) ? 1 : 2;
1074  }
1075 }
#define LogDebug(id)
float edepositEM
Definition: CaloSD.h:128
double energyCut
Definition: CaloSD.h:132
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:960
std::vector< const G4LogicalVolume * > hfLV
Definition: HCalSD.h:116
bool useParam
Definition: HCalSD.h:107
double eminHitHE
Definition: HCalSD.h:108
TH1F * time_[9]
Definition: HCalSD.h:118
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:137
void hitForFibre(const G4Step *step)
Definition: HCalSD.cc:767
const N & name() const
Definition: DDBase.h:78
static bool isMuon(int pdgCode)
bool useLayerWt
Definition: HCalSD.h:104
Definition: CaloSD.h:37
std::unique_ptr< HFShowerParam > showerParam
Definition: HCalSD.h:92
double weight_
Definition: HCalSD.h:110
std::vector< double > gpar
Definition: HCalSD.h:112
bool useFibreBundle
Definition: HCalSD.h:104
int zside() const
get the z-side of the cell (1/-1)
Definition: HcalDetId.h:145
double betaThr
Definition: HCalSD.h:106
double deliveredLumi
Definition: HCalSD.h:109
double eminHitHB
Definition: HCalSD.h:108
bool useShowerLibrary
Definition: HCalSD.h:107
std::vector< double > getDDDArray(const std::string &, const DDsvalues_type &)
Definition: HCalSD.cc:615
void plotProfile(const G4Step *step, const G4ThreeVector &pos, double edep, double time, int id)
Definition: HCalSD.cc:1008
double birk2
Definition: HCalSD.h:106
bool usePMTHit
Definition: HCalSD.h:104
std::vector< const G4LogicalVolume * > fibre2LV
Definition: HCalSD.h:116
int zside(DetId const &)
static const unsigned int numberOfZLayers
Definition: HFDarkening.h:26
void modifyDepth(HcalNumberingFromDDD::HcalID &id)
Definition: HCalSD.cc:1064
void update(const BeginOfJob *) override
This routine will be called when the appropriate signal arrives.
Definition: HCalSD.cc:526
#define nullptr
void setNumberingScheme(HcalNumberingScheme *)
Definition: HCalSD.cc:519
void processHit(const G4Step *step)
Definition: CaloSD.h:100
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:83
bool agingFlagHE
Definition: HCalSD.h:103
double birk1
Definition: HCalSD.h:106
double kmaxProton
Definition: CaloSD.h:137
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:93
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
static int PMTNumber(const G4ThreeVector &pe_effect)
TH1F * hzvhad
Definition: HCalSD.h:118
bool isItConicalBundle(const G4LogicalVolume *)
Definition: HCalSD.cc:697
double eminHitHF
Definition: HCalSD.h:108
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:88
TH1F * hit_[9]
Definition: HCalSD.h:118
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:103
bool testNumber
Definition: HCalSD.h:105
double kmaxIon
Definition: CaloSD.h:137
bool suppressHeavy
Definition: CaloSD.h:136
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:104
float edepositHAD
Definition: CaloSD.h:128
std::unique_ptr< HFDarkening > m_HFDarkening
Definition: HCalSD.h:99
double birk3
Definition: HCalSD.h:106
void resetForNewPrimary(const G4Step *)
Definition: CaloSD.cc:447
const HBHEDarkening * m_HEDarkening
Definition: HCalSD.h:98
std::vector< std::pair< unsigned int, DDValue > > DDsvalues_type
std::maps an index to a DDValue. The index corresponds to the index assigned to the name of the std::...
Definition: DDsvalues.h:20
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:107
TH1F * dist_[9]
Definition: HCalSD.h:118
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void plotHF(const G4ThreeVector &pos, bool emType)
Definition: HCalSD.cc:1055
std::unique_ptr< HcalTestNS > m_HcalTestNS
Definition: HCalSD.h:100
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:92
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:113
void getFromParam(const G4Step *step, bool &isKilled)
Definition: HCalSD.cc:809
void getFromHFLibrary(const G4Step *step, bool &isKilled)
Definition: HCalSD.cc:724
uint32_t setDetUnitId(const G4Step *step) override
Definition: HCalSD.cc:506
double getLayer0Wt(const int &det, const int &phi, const int &zside) const
bool isItStraightBundle(const G4LogicalVolume *)
Definition: HCalSD.cc:692
bool testNS_
Definition: HCalSD.h:105
ii
Definition: cuy.py:589
bool getFromLibrary(const G4Step *) override
Definition: HCalSD.cc:316
double eminHitHO
Definition: HCalSD.h:108
double tmaxHit
Definition: CaloSD.h:132
static bool isStableHadronIon(const G4Track *)
int ietaAbs() const
get the absolute value of the cell ieta
Definition: HcalDetId.h:150
void setID(uint32_t unitID, double timeSlice, int trackID, uint16_t depth=0)
Definition: CaloHitID.cc:44
TH1F * hzvem
Definition: HCalSD.h:118
int iphi() const
get the cell iphi
Definition: HcalDetId.h:157
const std::vector< double > & getGparHF() const
std::vector< const G4LogicalVolume * > pmtLV
Definition: HCalSD.h:116
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:571
CaloHitID currentID
Definition: CaloSD.h:130
static const unsigned int upperZLimit
Definition: HFDarkening.h:30
bool neutralDensity
Definition: HCalSD.h:105
bool isHF
Definition: HCalSD.h:102
void getHitFibreBundle(const G4Step *step, bool type)
Definition: HCalSD.cc:900
double getEnergyDeposit(const G4Step *) override
Definition: HCalSD.cc:382
int ke
bool isPrimary() const
std::unique_ptr< HFShowerFibreBundle > showerBundle
Definition: HCalSD.h:94
bool isItPMT(const G4LogicalVolume *)
Definition: HCalSD.cc:687
DDsvalues_type mergedSpecifics() const
bool isItinFidVolume(const G4ThreeVector &)
Definition: HCalSD.cc:707
bool isHF(int etabin, int depth)
void getHitPMT(const G4Step *step)
Definition: HCalSD.cc:839
double getAttenuation(const G4Step *aStep, double birk1, double birk2, double birk3) const
Definition: CaloSD.cc:462
std::unique_ptr< HFShowerLibrary > showerLibrary
Definition: HCalSD.h:90
double layerWeight(int, const G4ThreeVector &, int, int)
Definition: HCalSD.cc:986
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
int depth_
Definition: HCalSD.h:111
HLT enums.
virtual int setTrackID(const G4Step *)
Definition: CaloSD.cc:615
bool isItHF(const G4Step *)
Definition: HCalSD.cc:660
std::vector< G4String > fibreNames
Definition: HCalSD.h:114
static bool isGammaElectronPositron(int pdgCode)
T get() const
Definition: EventSetup.h:63
bool firstChild()
set the current node to the first child ...
bool isItScintillator(const G4Material *)
Definition: HCalSD.cc:702
#define EDM_ML_DEBUG
std::unique_ptr< HcalNumberingScheme > numberingScheme
Definition: HCalSD.h:89
std::vector< G4String > hfNames
Definition: HCalSD.h:114
std::unique_ptr< HFShower > hfshower
Definition: HCalSD.h:91
std::vector< const G4LogicalVolume * > fibreLV
Definition: HCalSD.h:116
std::map< uint32_t, double > layerWeights
Definition: HCalSD.h:117
uint32_t getUnitID() const
Definition: CaloG4Hit.h:69
double getResponseWt(const G4Track *)
Definition: CaloSD.cc:646
std::vector< const G4LogicalVolume * > fibre1LV
Definition: HCalSD.h:116
#define str(s)
int maxHFDepth(const int &ieta, const int &iphi) const
std::vector< const G4Material * > materials
Definition: HCalSD.h:115
void initRun() override
Definition: HCalSD.cc:563
const HBHEDarkening * m_HBDarkening
Definition: HCalSD.h:97
const std::string & name() const
Returns the name.
Definition: DDName.cc:88
const DDMaterial & material(void) const
Returns a reference object of the material this LogicalPart is made of.
std::vector< G4String > matNames
Definition: HCalSD.h:114
float degradation(float intlumi, int ieta, int lay) const
double getEnergyDeposit() const
Definition: CaloG4Hit.h:81
bool useHF
Definition: HCalSD.h:107
bool isItFibre(const G4LogicalVolume *)
Definition: HCalSD.cc:677
void setParameterized(bool val)
Definition: CaloSD.h:97
HcalDDDSimConstants * hcalConstants
Definition: HCalSD.h:96
void fillLogVolumeVector(const std::string &, const std::string &, const DDCompactView &, std::vector< const G4LogicalVolume * > &, std::vector< G4String > &)
Definition: HCalSD.cc:285