CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes
HFShower Class Reference

#include <HFShower.h>

Classes

struct  Hit
 

Public Types

typedef std::pair< XYZPoint, double > Spot
 
typedef std::pair< unsigned int, double > Step
 
typedef Steps::const_iterator step_iterator
 
typedef std::vector< StepSteps
 
typedef math::XYZVector XYZPoint
 

Public Member Functions

bool compute ()
 Compute the shower longitudinal and lateral development. More...
 
std::vector< HitgetHits (const G4Step *aStep, double weight)
 
std::vector< HitgetHits (const G4Step *aStep, bool forLibrary)
 
std::vector< HitgetHits (const G4Step *aStep, bool forLibraryProducer, double zoffset)
 
 HFShower (const std::string &name, const HcalDDDSimConstants *hcons, const HcalSimulationParameters *hps, edm::ParameterSet const &p, int chk=0)
 
 HFShower (const RandomEngineAndDistribution *engine, HDShowerParametrization *myParam, EcalHitMaker *myGrid, HcalHitMaker *myHcalHitMaker, int onECAL, double epart)
 
virtual ~HFShower ()
 

Private Member Functions

double gam (double x, double a) const
 
int indexFinder (double x, const std::vector< double > &Fhist)
 
void makeSteps (int nsteps)
 
double transProb (double factor, double R, double r)
 

Private Attributes

double aloge
 
double alpEM
 
double alpHD
 
bool applyFidCut_
 
double balanceEH
 
double betEM
 
double betHD
 
HFCherenkov cherenkov_
 
int chkFibre_
 
double criticalEnergy
 
double depthStart
 
double depthStep
 
std::vector< int > detector
 
double e
 
bool equalizeTimeShift_
 
double eSpotSize
 
std::vector< double > eStep
 
HFFibre fibre_
 
std::vector< double > gpar_
 
double hcalDepthFactor
 
int infinity
 
double lambdaEM
 
double lambdaHD
 
std::vector< double > lamcurr
 
std::vector< double > lamdepth
 
std::vector< double > lamstep
 
std::vector< double > lamtotal
 
int lossesOpt
 
double maxTRfactor
 
int nDepthSteps
 
std::vector< int > nspots
 
int nTRsteps
 
int onEcal
 
double part
 
double probMax_
 
const RandomEngineAndDistributionrandom
 
std::vector< double > rlamStep
 
double tgamEM
 
double tgamHD
 
const ECALPropertiestheECALproperties
 
EcalHitMakertheGrid
 
HcalHitMakertheHcalHitMaker
 
const HCALPropertiestheHCALproperties
 
HDShowerParametrizationtheParam
 
double theR1
 
double theR2
 
double theR3
 
double transFactor
 
double transParam
 
std::vector< double > x0curr
 
std::vector< double > x0depth
 
double x0EM
 
double x0HD
 

Detailed Description

Definition at line 22 of file HFShower.h.

Member Typedef Documentation

◆ Spot

typedef std::pair<XYZPoint, double> HFShower::Spot

Definition at line 26 of file HFShower.h.

◆ Step

typedef std::pair<unsigned int, double> HFShower::Step

Definition at line 27 of file HFShower.h.

◆ step_iterator

typedef Steps::const_iterator HFShower::step_iterator

Definition at line 29 of file HFShower.h.

◆ Steps

typedef std::vector<Step> HFShower::Steps

Definition at line 28 of file HFShower.h.

◆ XYZPoint

Definition at line 24 of file HFShower.h.

Constructor & Destructor Documentation

◆ HFShower() [1/2]

HFShower::HFShower ( const RandomEngineAndDistribution engine,
HDShowerParametrization myParam,
EcalHitMaker myGrid,
HcalHitMaker myHcalHitMaker,
int  onECAL,
double  epart 
)

Definition at line 29 of file HFShower.cc.

References aloge, HDShowerParametrization::alpe1(), HDShowerParametrization::alpe2(), alpEM, HDShowerParametrization::alph1(), HDShowerParametrization::alph2(), alpHD, balanceEH, HDShowerParametrization::bete1(), HDShowerParametrization::bete2(), betEM, HDShowerParametrization::beth1(), HDShowerParametrization::beth2(), betHD, criticalEnergy, debug, depthStart, depthStep, detector, e, HDShowerParametrization::e1(), HDShowerParametrization::e2(), EcalHitMaker::ecalHcalGapTotalL0(), EcalHitMaker::ecalHcalGapTotalX0(), HDShowerParametrization::ecalProperties(), EcalHitMaker::ecalTotalL0(), HDShowerParametrization::emax(), HDShowerParametrization::emid(), HDShowerParametrization::emin(), eSpotSize, RandomEngineAndDistribution::flatShoot(), HSParameters::getHDbalanceEH(), HSParameters::getHDcriticalEnergy(), HSParameters::getHDdepthStep(), HSParameters::getHDeSpotSize(), HSParameters::getHDhcalDepthFactor(), HSParameters::getHDlossesOpt(), HSParameters::getHDmaxTRfactor(), HSParameters::getHDnDepthSteps(), HSParameters::getHDnTRsteps(), HSParameters::getHDtransParam(), hcalDepthFactor, HDShowerParametrization::hcalProperties(), EcalHitMaker::hcalTotalL0(), HDShowerParametrization::hsParameters(), mps_fire::i, ECALProperties::interactionLength(), HCALProperties::interactionLength(), lambdaEM, lambdaHD, lamcurr, lamdepth, lamstep, lamtotal, dqm-mbProfile::log, LogDebug, lossesOpt, makeSteps(), HLT_2024v13_cff::maxDepth, maxTRfactor, nDepthSteps, nTRsteps, onEcal, HDShowerParametrization::part1(), HDShowerParametrization::part2(), HDShowerParametrization::r1(), HDShowerParametrization::r2(), HDShowerParametrization::r3(), ECALProperties::radLenIncm(), HCALProperties::radLenIncm(), random, HDShowerParametrization::setCase(), tgamEM, tgamHD, theECALproperties, theGrid, theHCALproperties, theParam, theR1, theR2, theR3, transFactor, transParam, x0curr, x0depth, x0EM, and x0HD.

35  : theParam(myParam), theGrid(myGrid), theHcalHitMaker(myHcalHitMaker), onEcal(onECAL), e(epart), random(engine) {
36  // To get an access to constants read in FASTCalorimeter
37  // FASTCalorimeter * myCalorimeter= FASTCalorimeter::instance();
38 
39  // Values taken from FamosGeneric/FamosCalorimeter/src/FASTCalorimeter.cc
40  lossesOpt = myParam->hsParameters()->getHDlossesOpt();
42  nTRsteps = myParam->hsParameters()->getHDnTRsteps();
43  transParam = myParam->hsParameters()->getHDtransParam();
44  eSpotSize = myParam->hsParameters()->getHDeSpotSize();
45  depthStep = myParam->hsParameters()->getHDdepthStep();
48  balanceEH = myParam->hsParameters()->getHDbalanceEH();
50 
51  // Special tr.size fluctuations
52  transParam *= (1. + random->flatShoot());
53 
54  // Special ad hoc long. extension + some fluctuations
55  double depthExt;
56  if (e < 50.)
57  depthExt = 0.8 * (50. - e) / 50. + 0.3;
58  else {
59  if (e < 500.)
60  depthExt = (500. - e) / 500. * 0.4 - 0.1;
61  else
62  depthExt = -0.1;
63  }
64  hcalDepthFactor += depthExt + 0.05 * (2. * random->flatShoot() - 1.);
65 
66  // normally 1, in HF - might be smaller to take into account
67  // a narrowness of the HF shower (Cherenkov light)
68  if (e < 50.)
69  transFactor = 0.5 - (50. - e) / 50. * 0.2;
70  else
71  transFactor = 0.7 - (1000. - e) / 1000. * 0.2;
72 
73  // simple protection ...
74  if (e < 0)
75  e = 0.;
76 
77  // Get the Famos Histos pointer
78  // myHistos = FamosHistos::instance();
79  // std::cout << " Hello FamosShower " << std::endl;
80 
83 
84  double emax = theParam->emax();
85  double emid = theParam->emid();
86  double emin = theParam->emin();
87  double effective = e;
88 
89  if (e < emid) {
90  theParam->setCase(1);
91  // avoid "underflow" below Emin (for parameters calculation only)
92  if (e < emin)
93  effective = emin;
94  } else
95  theParam->setCase(2);
96 
97  // A bit coarse espot size for HF...
98  eSpotSize *= 2.5;
99  if (effective > 0.5 * emax) {
100  eSpotSize *= 2.;
101  if (effective > emax) {
102  effective = emax;
103  eSpotSize *= 3.;
104  depthStep *= 2.;
105  }
106  }
107 
108  if (debug == 2)
109  LogDebug("FastCalorimetry") << " HFShower : " << std::endl
110  << " Energy " << e << std::endl
111  << " lossesOpt " << lossesOpt << std::endl
112  << " nDepthSteps " << nDepthSteps << std::endl
113  << " nTRsteps " << nTRsteps << std::endl
114  << " transParam " << transParam << std::endl
115  << " eSpotSize " << eSpotSize << std::endl
116  << " criticalEnergy " << criticalEnergy << std::endl
117  << " maxTRfactor " << maxTRfactor << std::endl
118  << " balanceEH " << balanceEH << std::endl
119  << "hcalDepthFactor " << hcalDepthFactor << std::endl;
120 
121  double alpEM1 = theParam->alpe1();
122  double alpEM2 = theParam->alpe2();
123 
124  double betEM1 = theParam->bete1();
125  double betEM2 = theParam->bete2();
126 
127  double alpHD1 = theParam->alph1();
128  double alpHD2 = theParam->alph2();
129 
130  double betHD1 = theParam->beth1();
131  double betHD2 = theParam->beth2();
132 
133  double part1 = theParam->part1();
134  double part2 = theParam->part2();
135 
136  aloge = std::log(effective);
137 
138  double edpar = (theParam->e1() + aloge * theParam->e2()) * effective;
139  double aedep = std::log(edpar);
140 
141  if (debug == 2)
142  LogDebug("FastCalorimetry") << " HFShower : " << std::endl
143  << " edpar " << edpar << " aedep " << aedep << std::endl
144  << " alpEM1 " << alpEM1 << std::endl
145  << " alpEM2 " << alpEM2 << std::endl
146  << " betEM1 " << betEM1 << std::endl
147  << " betEM2 " << betEM2 << std::endl
148  << " alpHD1 " << alpHD1 << std::endl
149  << " alpHD2 " << alpHD2 << std::endl
150  << " betHD1 " << betHD1 << std::endl
151  << " betHD2 " << betHD2 << std::endl
152  << " part1 " << part1 << std::endl
153  << " part2 " << part2 << std::endl;
154 
155  // private members to set
156  theR1 = theParam->r1();
157  theR2 = theParam->r2();
158  theR3 = theParam->r3();
159 
160  alpEM = alpEM1 + alpEM2 * aedep;
161  tgamEM = tgamma(alpEM);
162  betEM = betEM1 - betEM2 * aedep;
163  alpHD = alpHD1 + alpHD2 * aedep;
164  tgamHD = tgamma(alpHD);
165  betHD = betHD1 - betHD2 * aedep;
166  part = part1 - part2 * aedep;
167  if (part > 1.)
168  part = 1.; // protection - just in case of
169 
170  if (debug == 2)
171  LogDebug("FastCalorimetry") << " HFShower : " << std::endl
172  << " alpEM " << alpEM << std::endl
173  << " tgamEM " << tgamEM << std::endl
174  << " betEM " << betEM << std::endl
175  << " alpHD " << alpHD << std::endl
176  << " tgamHD " << tgamHD << std::endl
177  << " betHD " << betHD << std::endl
178  << " part " << part << std::endl;
179 
180  if (onECAL) {
183  } else {
184  lambdaEM = 0.;
185  x0EM = 0.;
186  }
189 
190  if (debug == 2)
191  LogDebug("FastCalorimetry") << " HFShower e " << e << std::endl
192  << " x0EM = " << x0EM << std::endl
193  << " x0HD = " << x0HD << std::endl
194  << " lamEM = " << lambdaEM << std::endl
195  << " lamHD = " << lambdaHD << std::endl;
196 
197  // Starting point of the shower
198  // try first with ECAL lambda
199 
200  double sum1 = 0.; // lambda path from the ECAL/HF entrance;
201  double sum2 = 0.; // lambda path from the interaction point;
202  double sum3 = 0.; // x0 path from the interaction point;
203  int nsteps = 0; // full number of longitudinal steps (counter);
204 
205  int nmoresteps; // how many longitudinal steps in addition to
206  // one (if interaction happens there) in ECAL
207 
208  if (e < criticalEnergy)
209  nmoresteps = 1;
210  else
211  nmoresteps = nDepthSteps;
212 
213  double depthECAL = 0.;
214  double depthGAP = 0.;
215  double depthGAPx0 = 0.;
216  if (onECAL) {
217  depthECAL = theGrid->ecalTotalL0(); // ECAL depth segment
218  depthGAP = theGrid->ecalHcalGapTotalL0(); // GAP depth segment
219  depthGAPx0 = theGrid->ecalHcalGapTotalX0(); // GAP depth x0
220  }
221 
222  double depthHCAL = theGrid->hcalTotalL0(); // HCAL depth segment
223  double depthToHCAL = depthECAL + depthGAP;
224 
225  //---------------------------------------------------------------------------
226  // Depth simulation & various protections, among them
227  // if too deep - get flat random in the allowed region
228  // if no HCAL material behind - force to deposit in ECAL
229  double maxDepth = depthToHCAL + depthHCAL - 1.1 * depthStep;
230 
231  double depthStart = std::log(1. / random->flatShoot()); // starting point lambda unts
232 
233  if (e < emin) {
234  if (debug)
235  LogDebug("FastCalorimetry") << " FamosHFShower : e <emin -> depthStart = 0" << std::endl;
236  depthStart = 0.;
237  }
238 
239  if (depthStart > maxDepth) {
240  if (debug)
241  LogDebug("FastCalorimetry") << " FamosHFShower : depthStart too big ... = " << depthStart << std::endl;
242 
244  if (depthStart < 0.)
245  depthStart = 0.;
246  if (debug)
247  LogDebug("FastCalorimetry") << " FamosHFShower : depthStart re-calculated = " << depthStart << std::endl;
248  }
249 
250  if (onECAL && e < emid) {
251  if ((depthECAL - depthStart) / depthECAL > 0.2 && depthECAL > depthStep) {
252  depthStart = 0.5 * depthECAL * random->flatShoot();
253  if (debug)
254  LogDebug("FastCalorimetry") << " FamosHFShower : small energy, "
255  << " depthStart reduced to = " << depthStart << std::endl;
256  }
257  }
258 
259  if (depthHCAL < depthStep) {
260  if (debug)
261  LogDebug("FastCalorimetry") << " FamosHFShower : depthHCAL too small ... = " << depthHCAL
262  << " depthStart -> forced to 0 !!!" << std::endl;
263  depthStart = 0.;
264  nmoresteps = 0;
265 
266  if (depthECAL < depthStep) {
267  nsteps = -1;
268  LogInfo("FastCalorimetry") << " FamosHFShower : too small ECAL and HCAL depths - "
269  << " particle is lost !!! " << std::endl;
270  }
271  }
272 
273  if (debug)
274  LogDebug("FastCalorimetry") << " FamosHFShower depths(lam) - " << std::endl
275  << " ECAL = " << depthECAL << std::endl
276  << " GAP = " << depthGAP << std::endl
277  << " HCAL = " << depthHCAL << std::endl
278  << " starting point = " << depthStart << std::endl;
279 
280  if (onEcal) {
281  if (debug)
282  LogDebug("FastCalorimetry") << " FamosHFShower : onECAL" << std::endl;
283  if (depthStart < depthECAL) {
284  if (debug)
285  LogDebug("FastCalorimetry") << " FamosHFShower : depthStart < depthECAL" << std::endl;
286  if ((depthECAL - depthStart) / depthECAL > 0.25 && depthECAL > depthStep) {
287  if (debug)
288  LogDebug("FastCalorimetry") << " FamosHFShower : enough space to make ECAL step" << std::endl;
289  // ECAL - one step
290  nsteps++;
291  sum1 += depthECAL; // at the end of step
292  sum2 += depthECAL - depthStart;
293  sum3 += sum2 * lambdaEM / x0EM;
294  lamtotal.push_back(sum1);
295  lamdepth.push_back(sum2);
296  lamcurr.push_back(lambdaEM);
297  lamstep.push_back(depthECAL - depthStart);
298  x0depth.push_back(sum3);
299  x0curr.push_back(x0EM);
300  detector.push_back(1);
301 
302  if (debug)
303  LogDebug("FastCalorimetry") << " FamosHFShower : "
304  << " in ECAL sum1, sum2 " << sum1 << " " << sum2 << std::endl;
305 
306  // // Gap - no additional step after ECAL
307  // // just move further to HCAL over the gap
308  sum1 += depthGAP;
309  sum2 += depthGAP;
310  sum3 += depthGAPx0;
311  }
312  // Just shift starting point to HCAL
313  else {
314  // cout << " FamosHFShower : not enough space to make ECAL step" << std::endl;
315  if (debug)
316  LogDebug("FastCalorimetry") << " FamosHFShower : goto HCAL" << std::endl;
317 
318  depthStart = depthToHCAL;
319  sum1 += depthStart;
320  }
321  } else { // GAP or HCAL
322 
323  if (depthStart >= depthECAL && depthStart < depthToHCAL) {
324  depthStart = depthToHCAL; // just a shift to HCAL for simplicity
325  }
326  sum1 += depthStart;
327 
328  if (debug)
329  LogDebug("FastCalorimetry") << " FamosHFShower : goto HCAL" << std::endl;
330  }
331  } else { // Forward
332  if (debug)
333  LogDebug("FastCalorimetry") << " FamosHFShower : forward" << std::endl;
334  sum1 += depthStart;
335  }
336 
337  for (int i = 0; i < nmoresteps; i++) {
338  sum1 += depthStep;
339  if (sum1 > (depthECAL + depthGAP + depthHCAL))
340  break;
341  sum2 += depthStep;
342  sum3 += sum2 * lambdaHD / x0HD;
343  lamtotal.push_back(sum1);
344  lamdepth.push_back(sum2);
345  lamcurr.push_back(lambdaHD);
346  lamstep.push_back(depthStep);
347  x0depth.push_back(sum3);
348  x0curr.push_back(x0HD);
349  detector.push_back(3);
350  nsteps++;
351  }
352 
353  // Make fractions of energy and transverse radii at each step
354 
355  // PV
356  // std::cout << "HFShower::HFShower() : Nsteps = " << nsteps << std::endl;
357 
358  if (nsteps > 0) {
359  makeSteps(nsteps);
360  }
361 }
std::vector< double > lamdepth
Definition: HFShower.h:78
double ecalHcalGapTotalL0() const
ECAL-HCAL transition.
Definition: EcalHitMaker.h:91
double balanceEH
Definition: HFShower.h:113
const RandomEngineAndDistribution * random
Definition: HFShower.h:118
double alpHD
Definition: HFShower.h:68
double radLenIncm() const override
Radiation length in cm.
double theR2
Definition: HFShower.h:67
double radLenIncm() const override
Radiation length in cm.
double transParam
Definition: HFShower.h:101
double betHD
Definition: HFShower.h:68
double getHDtransParam() const
Definition: HSParameters.h:22
double ecalTotalL0() const
in the ECAL
Definition: EcalHitMaker.h:85
std::vector< double > lamstep
Definition: HFShower.h:78
double theR1
Definition: HFShower.h:67
int nDepthSteps
Definition: HFShower.h:97
double getHDmaxTRfactor() const
Definition: HSParameters.h:26
double eSpotSize
Definition: HFShower.h:105
double transFactor
Definition: HFShower.h:103
double interactionLength() const override
Interaction length in cm.
double getHDcriticalEnergy() const
Definition: HSParameters.h:25
double getHDbalanceEH() const
Definition: HSParameters.h:27
int getHDnDepthSteps() const
Definition: HSParameters.h:20
std::vector< int > detector
Definition: HFShower.h:75
double tgamEM
Definition: HFShower.h:68
double lambdaHD
Definition: HFShower.h:71
double aloge
Definition: HFShower.h:73
const ECALProperties * theECALproperties
Definition: HFShower.h:63
double theR3
Definition: HFShower.h:67
double x0HD
Definition: HFShower.h:71
double x0EM
Definition: HFShower.h:71
HcalHitMaker * theHcalHitMaker
Definition: HFShower.h:86
double criticalEnergy
Definition: HFShower.h:109
int getHDlossesOpt() const
Definition: HSParameters.h:19
std::vector< double > x0curr
Definition: HFShower.h:77
double maxTRfactor
Definition: HFShower.h:111
double e
Definition: HFShower.h:92
double hcalDepthFactor
Definition: HFShower.h:115
const HSParameters * hsParameters() const
double getHDdepthStep() const
Definition: HSParameters.h:24
double lambdaEM
Definition: HFShower.h:71
EcalHitMaker * theGrid
Definition: HFShower.h:83
std::vector< double > lamcurr
Definition: HFShower.h:78
double ecalHcalGapTotalX0() const
ECAL-HCAL transition.
Definition: EcalHitMaker.h:70
#define debug
Definition: HFShower.cc:25
const HCALProperties * theHCALproperties
Definition: HFShower.h:64
Log< level::Info, false > LogInfo
double depthStep
Definition: HFShower.h:107
int onEcal
Definition: HFShower.h:89
int lossesOpt
Definition: HFShower.h:95
part
Definition: HCALResponse.h:20
const HCALProperties * hcalProperties() const
void makeSteps(int nsteps)
Definition: HFShower.cc:363
std::vector< double > lamtotal
Definition: HFShower.h:78
double depthStart
Definition: HFShower.h:72
double hcalTotalL0() const
in the HCAL
Definition: EcalHitMaker.h:88
double getHDeSpotSize() const
Definition: HSParameters.h:23
double getHDhcalDepthFactor() const
Definition: HSParameters.h:28
const ECALProperties * ecalProperties() const
int nTRsteps
Definition: HFShower.h:99
double flatShoot(double xmin=0.0, double xmax=1.0) const
double tgamHD
Definition: HFShower.h:68
double interactionLength() const override
Interaction length in cm: 18.5 for Standard ECAL.
HDShowerParametrization * theParam
Definition: HFShower.h:60
int getHDnTRsteps() const
Definition: HSParameters.h:21
double betEM
Definition: HFShower.h:68
double alpEM
Definition: HFShower.h:68
#define LogDebug(id)
std::vector< double > x0depth
Definition: HFShower.h:77

◆ ~HFShower()

virtual HFShower::~HFShower ( )
inlinevirtual

Definition at line 38 of file HFShower.h.

38 { ; }

◆ HFShower() [2/2]

HFShower::HFShower ( const std::string &  name,
const HcalDDDSimConstants hcons,
const HcalSimulationParameters hps,
edm::ParameterSet const &  p,
int  chk = 0 
)

Definition at line 21 of file HFShower.cc.

References applyFidCut_, chkFibre_, equalizeTimeShift_, HcalDDDSimConstants::getGparHF(), edm::ParameterSet::getParameter(), gpar_, AlCaHLTBitMon_ParallelJobs::p, and probMax_.

26  : cherenkov_(p.getParameter<edm::ParameterSet>("HFShower")), fibre_(hcons, hps, p), chkFibre_(chk) {
27  edm::ParameterSet m_HF = p.getParameter<edm::ParameterSet>("HFShower");
28  applyFidCut_ = m_HF.getParameter<bool>("ApplyFiducialCut");
29  edm::ParameterSet m_HF2 = m_HF.getParameter<edm::ParameterSet>("HFShowerBlock");
30  equalizeTimeShift_ = m_HF2.getParameter<bool>("EqualizeTimeShift");
31  probMax_ = m_HF2.getParameter<double>("ProbMax");
32 
33  edm::LogVerbatim("HFShower") << "HFShower:: Maximum probability cut off " << probMax_ << " Check flag " << chkFibre_
34  << " EqualizeTimeShift " << equalizeTimeShift_;
35 
36  //Special Geometry parameters
37  gpar_ = hcons->getGparHF();
38 }
Log< level::Info, true > LogVerbatim
std::vector< double > gpar_
Definition: HFShower.h:52
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
HFFibre fibre_
Definition: HFShower.h:46
HFCherenkov cherenkov_
Definition: HFShower.h:45
const std::vector< double > & getGparHF() const
double probMax_
Definition: HFShower.h:51
bool equalizeTimeShift_
Definition: HFShower.h:50
bool applyFidCut_
Definition: HFShower.h:49
int chkFibre_
Definition: HFShower.h:48

Member Function Documentation

◆ compute()

bool HFShower::compute ( )

Compute the shower longitudinal and lateral development.

Definition at line 459 of file HFShower.cc.

References HcalHitMaker::addHit(), EcalHitMaker::addHit(), submitPVResolutionJobs::count, debug, detector, eStep, RandomEngineAndDistribution::flatShoot(), EcalHitMaker::getPads(), hcalDepthFactor, mps_fire::i, indexFinder(), dqmiodatasetharvest::inf, infinity, dqmiolumiharvest::j, lamstep, lamtotal, nano_mu_digi_cff::layer, LogDebug, lossesOpt, M_PI, maxTRfactor, nspots, nTRsteps, phi, TtFullHadEvtBuilder_cfi::prob, CosmicsPD_Skims::radius, random, mps_fire::result, rlamStep, HcalHitMaker::setDepth(), HcalHitMaker::setSpotEnergy(), EcalHitMaker::setSpotEnergy(), mps_update::status, theGrid, theHcalHitMaker, and transProb().

Referenced by CalorimetryManager::HDShowerSimulation().

459  {
460  // TimeMe theT("FamosHFShower::compute");
461 
462  bool status = false;
463  int numLongit = eStep.size();
464  if (debug)
465  LogDebug("FastCalorimetry") << " FamosHFShower::compute - "
466  << " N_long.steps required : " << numLongit << std::endl;
467 
468  if (numLongit > 0) {
469  status = true;
470  // Prepare the trsanverse probability function
471  std::vector<double> Fhist;
472  std::vector<double> rhist;
473  for (int j = 0; j < nTRsteps + 1; j++) {
474  rhist.push_back(maxTRfactor * j / nTRsteps);
475  Fhist.push_back(transProb(maxTRfactor, 1., rhist[j]));
476  if (debug == 3)
477  LogDebug("FastCalorimetry") << "indexFinder - i, Fhist[i] = " << j << " " << Fhist[j] << std::endl;
478  }
479 
480  //================================================================
481  // Longitudinal steps
482  //================================================================
483  for (int i = 0; i < numLongit; i++) {
484  double currentDepthL0 = lamtotal[i] - 0.5 * lamstep[i];
485  // vary the longitudinal profile if needed
486  if (detector[i] != 1)
487  currentDepthL0 *= hcalDepthFactor;
488  if (debug)
489  LogDebug("FastCalorimetry") << " FamosHFShower::compute - detector = " << detector[i]
490  << " currentDepthL0 = " << currentDepthL0 << std::endl;
491 
492  double maxTRsize = maxTRfactor * rlamStep[i]; // in lambda units
493  double rbinsize = maxTRsize / nTRsteps;
494  double espot = eStep[i] / (double)nspots[i]; // re-adjust espot
495 
496  if (espot > 4. || espot < 0.)
497  LogDebug("FastCalorimetry") << " FamosHFShower::compute - unphysical espot = " << espot << std::endl;
498 
499  int ecal = 0;
500  if (detector[i] != 1) {
501  bool setHDdepth = theHcalHitMaker->setDepth(currentDepthL0);
502 
503  if (debug)
504  LogDebug("FastCalorimetry") << " FamosHFShower::compute - status of "
505  << " theHcalHitMaker->setDepth(currentDepthL0) is " << setHDdepth << std::endl;
506 
507  if (!setHDdepth) {
508  currentDepthL0 -= lamstep[i];
509  setHDdepth = theHcalHitMaker->setDepth(currentDepthL0);
510  }
511  if (!setHDdepth)
512  continue;
513 
515  } else {
516  ecal = 1;
517  bool status = theGrid->getPads(currentDepthL0);
518 
519  if (debug)
520  LogDebug("FastCalorimetry") << " FamosHFShower::compute - status of Grid = " << status << std::endl;
521 
522  if (!status)
523  continue;
524 
525  theGrid->setSpotEnergy(espot);
526  }
527 
528  //------------------------------------------------------------
529  // Transverse distribution
530  //------------------------------------------------------------
531  int nok = 0; // counter of OK
532  int count = 0;
533  int inf = infinity;
534  if (lossesOpt)
535  inf = nspots[i]; // losses are enabled, otherwise
536  // only OK points are counted ...
537 
538  // Total energy in this layer
539  double eremaining = eStep[i];
540  bool converged = false;
541 
542  while (eremaining > 0. && !converged && count < inf) {
543  ++count;
544 
545  // energy spot (HFL)
546  double newespot = espot;
547 
548  // We need to know a priori if this energy spot if for
549  // a long (1) or short (2) fiber
550 
551  unsigned layer = 1;
552  if (currentDepthL0 < 1.3) // first 22 cm = 1.3 lambda - only HFL
553  layer = 1;
554  else
555  layer = random->flatShoot() < 0.5 ? 1 : 2;
556 
557  if (layer == 2)
558  newespot = 2. * espot;
559 
560  if (eremaining - newespot < 0.)
561  newespot = eremaining;
562 
563  // process transverse distribution
564 
565  double prob = random->flatShoot();
566  int index = indexFinder(prob, Fhist);
567  double radius = rlamStep[i] * rhist[index] + random->flatShoot() * rbinsize; // in-bin
568  double phi = 2. * M_PI * random->flatShoot();
569 
570  if (debug == 2)
571  LogDebug("FastCalorimetry") << std::endl
572  << " FamosHFShower::compute "
573  << " r = " << radius << " phi = " << phi << std::endl;
574 
575  // add hit
576 
577  theHcalHitMaker->setSpotEnergy(newespot);
578  theGrid->setSpotEnergy(newespot);
579 
580  bool result;
581  if (ecal) {
582  result = theGrid->addHit(radius, phi, 0); // shouldn't get here !
583 
584  if (debug == 2)
585  LogDebug("FastCalorimetry") << " FamosHFShower::compute - "
586  << " theGrid->addHit result = " << result << std::endl;
587 
588  } else {
589  // PV assign espot to long/short fibers
591 
592  if (debug == 2)
593  LogDebug("FastCalorimetry") << " FamosHFShower::compute - "
594  << " theHcalHitMaker->addHit result = " << result << std::endl;
595  }
596 
597  if (result) {
598  ++nok;
599  eremaining -= newespot;
600  if (eremaining <= 0.)
601  converged = true;
602  // std::cout << "Transverse : " << nok << " "
603  // << " , E= " << newespot
604  // << " , Erem = " << eremaining
605  // << std::endl;
606  } else {
607  // std::cout << "WARNING : hit not added" << std::endl;
608  }
609  }
610 
611  // end of tranverse simulation
612  //-----------------------------------------------------
613 
614  if (count == infinity) {
615  status = false;
616  if (debug)
617  LogDebug("FastCalorimetry") << "*** FamosHFShower::compute "
618  << " maximum number of"
619  << " transverse points " << count << " is used !!!" << std::endl;
620  break;
621  }
622 
623  if (debug)
624  LogDebug("FastCalorimetry") << " FamosHFShower::compute "
625  << " long.step No." << i << " Ntry, Nok = " << count << " " << nok << std::endl;
626 
627  } // end of longitudinal steps
628  } // end of no steps
629  return status;
630 }
std::vector< double > eStep
Definition: HFShower.h:76
const RandomEngineAndDistribution * random
Definition: HFShower.h:118
std::vector< double > rlamStep
Definition: HFShower.h:76
bool addHit(double r, double phi, unsigned layer=0) override
std::vector< int > nspots
Definition: HFShower.h:75
int infinity
Definition: HFShower.h:80
std::vector< double > lamstep
Definition: HFShower.h:78
int indexFinder(double x, const std::vector< double > &Fhist)
Definition: HFShower.cc:632
std::vector< int > detector
Definition: HFShower.h:75
bool addHit(double r, double phi, unsigned layer=0) override
add the hit in the HCAL in local coordinates
Definition: HcalHitMaker.cc:30
HcalHitMaker * theHcalHitMaker
Definition: HFShower.h:86
double transProb(double factor, double R, double r)
Definition: HFShower.h:50
double maxTRfactor
Definition: HFShower.h:111
void setSpotEnergy(double e) override
Set the spot energy.
Definition: HcalHitMaker.h:26
double hcalDepthFactor
Definition: HFShower.h:115
EcalHitMaker * theGrid
Definition: HFShower.h:83
#define M_PI
#define debug
Definition: HFShower.cc:25
int lossesOpt
Definition: HFShower.h:95
std::vector< double > lamtotal
Definition: HFShower.h:78
bool getPads(double depth, bool inCm=false)
int nTRsteps
Definition: HFShower.h:99
double flatShoot(double xmin=0.0, double xmax=1.0) const
bool setDepth(double, bool inCm=false)
set the depth in X0 or Lambda0 units depending on showerType
void setSpotEnergy(double e) override
Definition: EcalHitMaker.h:112
#define LogDebug(id)

◆ gam()

double HFShower::gam ( double  x,
double  a 
) const
inlineprivate

Definition at line 45 of file HFShower.h.

References a, JetChargeProducer_cfi::exp, funct::pow(), and x.

Referenced by makeSteps().

45 { return pow(x, a - 1.) * exp(-x); }
double a
Definition: hdecay.h:121
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29

◆ getHits() [1/3]

std::vector< HFShower::Hit > HFShower::getHits ( const G4Step *  aStep,
double  weight 
)

Definition at line 40 of file HFShower.cc.

References funct::abs(), applyFidCut_, HFFibre::attLength(), cherenkov_, chkFibre_, HFCherenkov::computeNPE(), hcalRecHitTable_cff::depth, hcalRecHitTable_cff::energy, equalizeTimeShift_, JetChargeProducer_cfi::exp, fibre_, HFCherenkov::getMom(), HFCherenkov::getWL(), gpar_, hfClusterShapes_cfi::hits, mps_fire::i, Skims_PA_cff::name, convertSQLiteXML::ok, AlCaHLTBitMon_ParallelJobs::p, HFFibreFiducial::PMTNumber(), probMax_, diffTwoXMLs::r1, diffTwoXMLs::r2, hcalRecHitTable_cff::time, HFFibre::tShift(), findQualityFiles::v, w(), and ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::zv.

Referenced by FiberSD::ProcessHits().

40  {
41  std::vector<HFShower::Hit> hits;
42 
43  double edep = weight * (aStep->GetTotalEnergyDeposit());
44 #ifdef EDM_ML_DEBUG
45  int nHit = 0;
46  edm::LogVerbatim("HFShower") << "HFShower::getHits: energy " << aStep->GetTotalEnergyDeposit() << " weight " << weight
47  << " edep " << edep;
48 #endif
49  double stepl = 0.;
50 
51  if (aStep->GetTrack()->GetDefinition()->GetPDGCharge() != 0.)
52  stepl = aStep->GetStepLength();
53  if ((edep == 0.) || (stepl == 0.)) {
54 #ifdef EDM_ML_DEBUG
55  edm::LogVerbatim("HFShower") << "HFShower::getHits: Number of Hits " << nHit;
56 #endif
57  return hits;
58  }
59  const G4Track *aTrack = aStep->GetTrack();
60  const G4DynamicParticle *aParticle = aTrack->GetDynamicParticle();
61 
63  double energy = aParticle->GetTotalEnergy();
64  double momentum = aParticle->GetTotalMomentum();
65  double pBeta = momentum / energy;
66  double dose = 0.;
67  int npeDose = 0;
68 
69  const G4ThreeVector &momentumDir = aParticle->GetMomentumDirection();
70  const G4ParticleDefinition *particleDef = aTrack->GetDefinition();
71 
72  const G4StepPoint *preStepPoint = aStep->GetPreStepPoint();
73  const G4ThreeVector &globalPos = preStepPoint->GetPosition();
74  G4String name = preStepPoint->GetTouchable()->GetSolid(0)->GetName();
75  //double zv = std::abs(globalPos.z()) - gpar_[4] - 0.5*gpar_[1];
76  double zv = std::abs(globalPos.z()) - gpar_[4];
77  G4ThreeVector localPos = G4ThreeVector(globalPos.x(), globalPos.y(), zv);
78  G4ThreeVector localMom = preStepPoint->GetTouchable()->GetHistory()->GetTopTransform().TransformAxis(momentumDir);
79  // @@ Here the depth should be changed (Fibers all long in Geometry!)
80  int depth = 1;
81  int npmt = 0;
82  bool ok = true;
83  if (zv < 0. || zv > gpar_[1]) {
84  ok = false; // beyond the fiber in Z
85  }
86  if (ok && applyFidCut_) {
87  npmt = HFFibreFiducial::PMTNumber(globalPos);
88  if (npmt <= 0) {
89  ok = false;
90  } else if (npmt > 24) { // a short fibre
91  if (zv > gpar_[0]) {
92  depth = 2;
93  } else {
94  ok = false;
95  }
96  }
97 #ifdef EDM_ML_DEBUG
98  edm::LogVerbatim("HFShower") << "HFShower: npmt " << npmt << " zv " << std::abs(globalPos.z()) << ":" << gpar_[4]
99  << ":" << zv << ":" << gpar_[0] << " ok " << ok << " depth " << depth;
100 #endif
101  } else {
102  depth = (preStepPoint->GetTouchable()->GetReplicaNumber(0)) % 10; // All LONG!
103  }
104  G4ThreeVector translation = preStepPoint->GetTouchable()->GetVolume(1)->GetObjectTranslation();
105 
106  double u = localMom.x();
107  double v = localMom.y();
108  double w = localMom.z();
109  double zCoor = localPos.z();
110  double zFibre = (0.5 * gpar_[1] - zCoor - translation.z());
111  double tSlice = (aStep->GetPostStepPoint()->GetGlobalTime());
112  double time =
113  (equalizeTimeShift_) ? (fibre_.tShift(localPos, depth, -1)) : (fibre_.tShift(localPos, depth, chkFibre_));
114 
115 #ifdef EDM_ML_DEBUG
116  edm::LogVerbatim("HFShower") << "HFShower::getHits: in " << name << " Z " << zCoor << "(" << globalPos.z() << ") "
117  << zFibre << " Trans " << translation << " Time " << tSlice << " " << time
118  << "\n Direction " << momentumDir << " Local " << localMom;
119 #endif
120  // Here npe should be 0 if there is no fiber (@@ M.K.)
121  int npe = 1;
122  std::vector<double> wavelength;
123  std::vector<double> momz;
124  if (!applyFidCut_) { // _____ Tmp close of the cherenkov function
125  if (ok)
126  npe = cherenkov_.computeNPE(aStep, particleDef, pBeta, u, v, w, stepl, zFibre, dose, npeDose);
127  wavelength = cherenkov_.getWL();
128  momz = cherenkov_.getMom();
129  } // ^^^^^ End of Tmp close of the cherenkov function
130  if (ok && npe > 0) {
131  for (int i = 0; i < npe; ++i) {
132  double p = 1.;
133  if (!applyFidCut_)
134  p = fibre_.attLength(wavelength[i]);
135  double r1 = G4UniformRand();
136  double r2 = G4UniformRand();
137 #ifdef EDM_ML_DEBUG
138  edm::LogVerbatim("HFShower") << "HFShower::getHits: " << i << " attenuation " << r1 << ":" << exp(-p * zFibre)
139  << " r2 " << r2 << ":" << probMax_
140  << " Survive: " << (r1 <= exp(-p * zFibre) && r2 <= probMax_);
141 #endif
142  if (applyFidCut_ || chkFibre_ < 0 || (r1 <= exp(-p * zFibre) && r2 <= probMax_)) {
143  hit.depth = depth;
144  hit.time = tSlice + time;
145  // Temporary fix
146  if (!applyFidCut_) {
147  hit.wavelength = wavelength[i];
148  hit.momentum = momz[i];
149  } else {
150  hit.wavelength = 300.;
151  hit.momentum = 1.;
152  }
153  hit.position = globalPos;
154  hits.push_back(hit);
155 #ifdef EDM_ML_DEBUG
156  nHit++;
157 #endif
158  }
159  }
160  }
161 
162 #ifdef EDM_ML_DEBUG
163  edm::LogVerbatim("HFShower") << "HFShower::getHits: Number of Hits " << nHit;
164  for (int i = 0; i < nHit; ++i)
165  edm::LogVerbatim("HFShower") << "HFShower::Hit " << i << " WaveLength " << hits[i].wavelength << " Time "
166  << hits[i].time << " Momentum " << hits[i].momentum << " Position "
167  << hits[i].position;
168 #endif
169  return hits;
170 }
Log< level::Info, true > LogVerbatim
std::vector< double > gpar_
Definition: HFShower.h:52
HFFibre fibre_
Definition: HFShower.h:46
HFCherenkov cherenkov_
Definition: HFShower.h:45
T w() const
Definition: weight.py:1
std::vector< double > getWL()
Definition: HFCherenkov.cc:301
double probMax_
Definition: HFShower.h:51
bool equalizeTimeShift_
Definition: HFShower.h:50
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double tShift(const G4ThreeVector &point, int depth, int fromEndAbs=0) const
Definition: HFFibre.cc:114
std::vector< double > getMom()
Definition: HFCherenkov.cc:306
bool applyFidCut_
Definition: HFShower.h:49
int PMTNumber(const G4ThreeVector &pe_effect)
int chkFibre_
Definition: HFShower.h:48
int computeNPE(const G4Step *step, const G4ParticleDefinition *pDef, double pBeta, double u, double v, double w, double step_length, double zFiber, double Dose, int Npe_Dose)
Definition: HFCherenkov.cc:43
double attLength(double lambda) const
Definition: HFFibre.cc:98

◆ getHits() [2/3]

std::vector< HFShower::Hit > HFShower::getHits ( const G4Step *  aStep,
bool  forLibrary 
)

Definition at line 261 of file HFShower.cc.

References funct::abs(), applyFidCut_, cherenkov_, chkFibre_, HFCherenkov::computeNPE(), hcalRecHitTable_cff::depth, hcalRecHitTable_cff::energy, equalizeTimeShift_, fibre_, HFCherenkov::getMom(), HFCherenkov::getWL(), gpar_, hfClusterShapes_cfi::hits, mps_fire::i, Skims_PA_cff::name, convertSQLiteXML::ok, HFFibreFiducial::PMTNumber(), hcalRecHitTable_cff::time, HFFibre::tShift(), findQualityFiles::v, w(), and ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::zv.

261  {
262  std::vector<HFShower::Hit> hits;
263 #ifdef EDM_ML_DEBUG
264  int nHit = 0;
265 #endif
266  double edep = aStep->GetTotalEnergyDeposit();
267  double stepl = 0.;
268 
269  if (aStep->GetTrack()->GetDefinition()->GetPDGCharge() != 0.)
270  stepl = aStep->GetStepLength();
271  if ((edep == 0.) || (stepl == 0.)) {
272 #ifdef EDM_ML_DEBUG
273  edm::LogVerbatim("HFShower") << "HFShower::getHits: Number of Hits " << nHit;
274 #endif
275  return hits;
276  }
277 
278  const G4Track *aTrack = aStep->GetTrack();
279  const G4DynamicParticle *aParticle = aTrack->GetDynamicParticle();
280 
282  double energy = aParticle->GetTotalEnergy();
283  double momentum = aParticle->GetTotalMomentum();
284  double pBeta = momentum / energy;
285  double dose = 0.;
286  int npeDose = 0;
287 
288  const G4ThreeVector &momentumDir = aParticle->GetMomentumDirection();
289  G4ParticleDefinition *particleDef = aTrack->GetDefinition();
290 
291  const G4StepPoint *preStepPoint = aStep->GetPreStepPoint();
292  const G4ThreeVector &globalPos = preStepPoint->GetPosition();
293  G4String name = preStepPoint->GetTouchable()->GetSolid(0)->GetName();
294  double zv = std::abs(globalPos.z()) - gpar_[4] - 0.5 * gpar_[1];
295  G4ThreeVector localPos = G4ThreeVector(globalPos.x(), globalPos.y(), zv);
296  G4ThreeVector localMom = preStepPoint->GetTouchable()->GetHistory()->GetTopTransform().TransformAxis(momentumDir);
297  // @@ Here the depth should be changed (Fibers are all long in Geometry!)
298  int depth = 1;
299  int npmt = 0;
300  bool ok = true;
301  if (zv < 0 || zv > gpar_[1]) {
302  ok = false; // beyond the fiber in Z
303  }
304  if (ok && applyFidCut_) {
305  npmt = HFFibreFiducial::PMTNumber(globalPos);
306  if (npmt <= 0) {
307  ok = false;
308  } else if (npmt > 24) { // a short fibre
309  if (zv > gpar_[0]) {
310  depth = 2;
311  } else {
312  ok = false;
313  }
314  }
315 #ifdef EDM_ML_DEBUG
316  edm::LogVerbatim("HFShower") << "HFShower:getHits(SL): npmt " << npmt << " zv " << std::abs(globalPos.z()) << ":"
317  << gpar_[4] << ":" << zv << ":" << gpar_[0] << " ok " << ok << " depth " << depth;
318 #endif
319  } else {
320  depth = (preStepPoint->GetTouchable()->GetReplicaNumber(0)) % 10; // All LONG!
321  }
322  G4ThreeVector translation = preStepPoint->GetTouchable()->GetVolume(1)->GetObjectTranslation();
323 
324  double u = localMom.x();
325  double v = localMom.y();
326  double w = localMom.z();
327  double zCoor = localPos.z();
328  double zFibre = (0.5 * gpar_[1] - zCoor - translation.z());
329  double tSlice = (aStep->GetPostStepPoint()->GetGlobalTime());
330  double time = (equalizeTimeShift_) ? 0 : fibre_.tShift(localPos, depth, chkFibre_);
331 
332 #ifdef EDM_ML_DEBUG
333  edm::LogVerbatim("HFShower") << "HFShower::getHits(SL): in " << name << " Z " << zCoor << "(" << globalPos.z() << ") "
334  << zFibre << " Trans " << translation << " Time " << tSlice << " " << time
335  << "\n Direction " << momentumDir << " Local " << localMom;
336 #endif
337  // npe should be 0
338  int npe = 0;
339  if (ok)
340  npe = cherenkov_.computeNPE(aStep, particleDef, pBeta, u, v, w, stepl, zFibre, dose, npeDose);
341  std::vector<double> wavelength = cherenkov_.getWL();
342  std::vector<double> momz = cherenkov_.getMom();
343 
344  for (int i = 0; i < npe; ++i) {
345  hit.depth = depth;
346  hit.time = tSlice + time;
347  hit.wavelength = wavelength[i];
348  hit.momentum = momz[i];
349  hit.position = globalPos;
350  hits.push_back(hit);
351 #ifdef EDM_ML_DEBUG
352  nHit++;
353 #endif
354  }
355 
356  return hits;
357 }
Log< level::Info, true > LogVerbatim
std::vector< double > gpar_
Definition: HFShower.h:52
HFFibre fibre_
Definition: HFShower.h:46
HFCherenkov cherenkov_
Definition: HFShower.h:45
T w() const
std::vector< double > getWL()
Definition: HFCherenkov.cc:301
bool equalizeTimeShift_
Definition: HFShower.h:50
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double tShift(const G4ThreeVector &point, int depth, int fromEndAbs=0) const
Definition: HFFibre.cc:114
std::vector< double > getMom()
Definition: HFCherenkov.cc:306
bool applyFidCut_
Definition: HFShower.h:49
int PMTNumber(const G4ThreeVector &pe_effect)
int chkFibre_
Definition: HFShower.h:48
int computeNPE(const G4Step *step, const G4ParticleDefinition *pDef, double pBeta, double u, double v, double w, double step_length, double zFiber, double Dose, int Npe_Dose)
Definition: HFCherenkov.cc:43

◆ getHits() [3/3]

std::vector< HFShower::Hit > HFShower::getHits ( const G4Step *  aStep,
bool  forLibraryProducer,
double  zoffset 
)

Definition at line 172 of file HFShower.cc.

References funct::abs(), cherenkov_, chkFibre_, HFCherenkov::computeNPE(), hcalRecHitTable_cff::depth, hcalRecHitTable_cff::energy, equalizeTimeShift_, fibre_, HFCherenkov::getMom(), HFCherenkov::getWL(), gpar_, hfClusterShapes_cfi::hits, mps_fire::i, Skims_PA_cff::name, convertSQLiteXML::ok, hcalRecHitTable_cff::time, HFFibre::tShift(), findQualityFiles::v, w(), and ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::zv.

172  {
173  std::vector<HFShower::Hit> hits;
174 #ifdef EDM_ML_DEBUG
175  int nHit = 0;
176 #endif
177  double edep = aStep->GetTotalEnergyDeposit();
178  double stepl = 0.;
179 
180  if (aStep->GetTrack()->GetDefinition()->GetPDGCharge() != 0.)
181  stepl = aStep->GetStepLength();
182  if ((edep == 0.) || (stepl == 0.)) {
183 #ifdef EDM_ML_DEBUG
184  edm::LogVerbatim("HFShower") << "HFShower::getHits: Number of Hits " << nHit;
185 #endif
186  return hits;
187  }
188  const G4Track *aTrack = aStep->GetTrack();
189  const G4DynamicParticle *aParticle = aTrack->GetDynamicParticle();
190 
192  double energy = aParticle->GetTotalEnergy();
193  double momentum = aParticle->GetTotalMomentum();
194  double pBeta = momentum / energy;
195  double dose = 0.;
196  int npeDose = 0;
197 
198  const G4ThreeVector &momentumDir = aParticle->GetMomentumDirection();
199  G4ParticleDefinition *particleDef = aTrack->GetDefinition();
200 
201  G4StepPoint *preStepPoint = aStep->GetPreStepPoint();
202  const G4ThreeVector &globalPos = preStepPoint->GetPosition();
203  G4String name = preStepPoint->GetTouchable()->GetSolid(0)->GetName();
204  double zb = std::abs(globalPos.z() - zoffset); // from beginning of HF
205  double zv = zb - .5 * gpar_[1]; // from center of HF
206  G4ThreeVector localPos = G4ThreeVector(globalPos.x(), globalPos.y(), zv);
207  G4ThreeVector localMom = preStepPoint->GetTouchable()->GetHistory()->GetTopTransform().TransformAxis(momentumDir);
208  bool ok = true;
209  if (zb < 0. || zb > gpar_[1]) {
210  ok = false; // beyond the fiber in Z
211  }
212  int depth = (preStepPoint->GetTouchable()->GetReplicaNumber(0)) % 10; // All LONG!
213  G4ThreeVector translation = preStepPoint->GetTouchable()->GetVolume(1)->GetObjectTranslation();
214 
215  double u = localMom.x();
216  double v = localMom.y();
217  double w = localMom.z();
218  double zCoor = localPos.z();
219  double zFibre = (0.5 * gpar_[1] - zCoor - translation.z());
220  double tSlice = (aStep->GetPostStepPoint()->GetGlobalTime());
221 
222 #ifdef EDM_ML_DEBUG
223  double time = (equalizeTimeShift_) ? 0 : fibre_.tShift(localPos, depth, chkFibre_);
224  edm::LogVerbatim("HFShower") << "HFShower::getHits: in " << name << " Z " << zCoor << "(" << globalPos.z() << ") "
225  << zFibre << " Trans " << translation << " Time " << tSlice << " " << time
226  << "\n Direction " << momentumDir << " Local " << localMom;
227 #endif
228 
229  int npe = 0;
230  std::vector<double> wavelength;
231  std::vector<double> momz;
232  if (ok)
233  npe = cherenkov_.computeNPE(aStep, particleDef, pBeta, u, v, w, stepl, zFibre, dose, npeDose);
234  wavelength = cherenkov_.getWL();
235  momz = cherenkov_.getMom();
236  if (ok && npe > 0) {
237  for (int i = 0; i < npe; ++i) {
238  hit.depth = depth;
239  // hit.time = tSlice + time;
240  hit.time = tSlice; // only shower time, fiber propagation time to be set on reading library
241  hit.wavelength = wavelength[i];
242  hit.momentum = momz[i];
243  hit.position = globalPos;
244  hits.push_back(hit);
245 #ifdef EDM_ML_DEBUG
246  nHit++;
247 #endif
248  }
249  }
250 
251 #ifdef EDM_ML_DEBUG
252  edm::LogVerbatim("HFShower") << "HFShower::getHits: Number of Hits " << nHit;
253  for (int i = 0; i < nHit; ++i)
254  edm::LogVerbatim("HFShower") << "HFShower::Hit " << i << " WaveLength " << hits[i].wavelength << " Time "
255  << hits[i].time << " Momentum " << hits[i].momentum << " Position "
256  << hits[i].position;
257 #endif
258  return hits;
259 }
Log< level::Info, true > LogVerbatim
std::vector< double > gpar_
Definition: HFShower.h:52
HFFibre fibre_
Definition: HFShower.h:46
HFCherenkov cherenkov_
Definition: HFShower.h:45
T w() const
std::vector< double > getWL()
Definition: HFCherenkov.cc:301
bool equalizeTimeShift_
Definition: HFShower.h:50
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double tShift(const G4ThreeVector &point, int depth, int fromEndAbs=0) const
Definition: HFFibre.cc:114
std::vector< double > getMom()
Definition: HFCherenkov.cc:306
int chkFibre_
Definition: HFShower.h:48
int computeNPE(const G4Step *step, const G4ParticleDefinition *pDef, double pBeta, double u, double v, double w, double step_length, double zFiber, double Dose, int Npe_Dose)
Definition: HFCherenkov.cc:43

◆ indexFinder()

int HFShower::indexFinder ( double  x,
const std::vector< double > &  Fhist 
)
private

Definition at line 632 of file HFShower.cc.

References debug, LogDebug, findQualityFiles::size, and x.

Referenced by compute().

632  {
633  // binary search in the vector of doubles
634  int size = Fhist.size();
635 
636  int curr = size / 2;
637  int step = size / 4;
638  int iter;
639  int prevdir = 0;
640  int actudir = 0;
641 
642  for (iter = 0; iter < size; iter++) {
643  if (curr >= size || curr < 1)
644  LogWarning("FastCalorimetry") << " FamosHFShower::indexFinder - wrong current index = " << curr << " !!!"
645  << std::endl;
646 
647  if ((x <= Fhist[curr]) && (x > Fhist[curr - 1]))
648  break;
649  prevdir = actudir;
650  if (x > Fhist[curr]) {
651  actudir = 1;
652  } else {
653  actudir = -1;
654  }
655  if (prevdir * actudir < 0) {
656  if (step > 1)
657  step /= 2;
658  }
659  curr += actudir * step;
660  if (curr > size)
661  curr = size;
662  else {
663  if (curr < 1) {
664  curr = 1;
665  }
666  }
667 
668  if (debug == 3)
669  LogDebug("FastCalorimetry") << " indexFinder - end of iter." << iter << " curr, F[curr-1], F[curr] = " << curr
670  << " " << Fhist[curr - 1] << " " << Fhist[curr] << std::endl;
671  }
672 
673  if (debug == 3)
674  LogDebug("FastCalorimetry") << " indexFinder x = " << x << " found index = " << curr - 1 << std::endl;
675 
676  return curr - 1;
677 }
size
Write out results.
#define debug
Definition: HFShower.cc:25
step
Definition: StallMonitor.cc:83
Log< level::Warning, false > LogWarning
#define LogDebug(id)

◆ makeSteps()

void HFShower::makeSteps ( int  nsteps)
private

Definition at line 363 of file HFShower.cc.

References aloge, alpEM, alpHD, balanceEH, betEM, betHD, submitPVResolutionJobs::count, debug, detector, e, eSpotSize, eStep, RandomEngineAndDistribution::flatShoot(), gam(), mps_fire::i, infinity, createfilelist::int, lamcurr, lamdepth, lamstep, LogDebug, nspots, random, rlamStep, groupFilesInBlocks::temp, tgamEM, tgamHD, theR1, theR2, theR3, transFactor, transParam, x, x0curr, x0depth, and y.

Referenced by HFShower().

363  {
364  double sumes = 0.;
365  double sum = 0.;
366  std::vector<double> temp;
367 
368  if (debug)
369  LogDebug("FastCalorimetry") << " FamosHFShower::makeSteps - "
370  << " nsteps required : " << nsteps << std::endl;
371 
372  int count = 0;
373  for (int i = 0; i < nsteps; i++) {
374  double deplam = lamdepth[i] - 0.5 * lamstep[i];
375  double depx0 = x0depth[i] - 0.5 * lamstep[i] / x0curr[i];
376  double x = betEM * depx0;
377  double y = betHD * deplam;
378 
379  if (debug == 2)
380  LogDebug("FastCalorimetry") << " FamosHFShower::makeSteps "
381  << " - step " << i << " depx0, x = " << depx0 << ", " << x
382  << " deplam, y = " << deplam << ", " << y << std::endl;
383 
384  double est = (part * betEM * gam(x, alpEM) * lamcurr[i] / (x0curr[i] * tgamEM) +
385  (1. - part) * betHD * gam(y, alpHD) / tgamHD) *
386  lamstep[i];
387 
388  // protection ...
389  if (est < 0.) {
390  LogDebug("FastCalorimetry") << "*** FamosHFShower::makeSteps "
391  << " - negative step energy !!!" << std::endl;
392  est = 0.;
393  break;
394  }
395 
396  // for estimates only
397  sum += est;
398  int nPest = (int)(est * e / sum / eSpotSize);
399 
400  if (debug == 2)
401  LogDebug("FastCalorimetry") << " FamosHFShower::makeSteps - nPoints estimate = " << nPest << std::endl;
402 
403  if (nPest <= 1 && count != 0)
404  break;
405 
406  // good step - to proceed
407 
408  temp.push_back(est);
409  sumes += est;
410 
411  rlamStep.push_back(transParam * (theR1 + (theR2 - theR3 * aloge)) * deplam * transFactor);
412  count++;
413  }
414 
415  // fluctuations in ECAL and re-distribution of remaining energy in HCAL
416  if (detector[0] == 1 && count > 1) {
417  double oldECALenergy = temp[0];
418  double oldHCALenergy = sumes - oldECALenergy;
419  double newECALenergy = 2. * sumes;
420  for (int i = 0; newECALenergy > sumes && i < infinity; i++)
421  newECALenergy = 2. * balanceEH * random->flatShoot() * oldECALenergy;
422 
423  if (debug == 2)
424  LogDebug("FastCalorimetry") << "*** FamosHFShower::makeSteps "
425  << " ECAL fraction : old/new - " << oldECALenergy / sumes << "/"
426  << newECALenergy / sumes << std::endl;
427 
428  temp[0] = newECALenergy;
429  double newHCALenergy = sumes - newECALenergy;
430  double newHCALreweight = newHCALenergy / oldHCALenergy;
431 
432  for (int i = 1; i < count; i++) {
433  temp[i] *= newHCALreweight;
434  }
435  }
436 
437  // final re-normalization of the energy fractions
438  for (int i = 0; i < count; i++) {
439  eStep.push_back(temp[i] * e / sumes);
440  nspots.push_back((int)(eStep[i] / eSpotSize) + 1);
441 
442  if (debug)
443  LogDebug("FastCalorimetry") << i << " xO and lamdepth at the end of step = " << x0depth[i] << " " << lamdepth[i]
444  << " Estep func = " << eStep[i] << " Rstep = " << rlamStep[i]
445  << " Nspots = " << nspots[i] << std::endl;
446  }
447 
448  // The only step is in ECAL - let's make the size bigger ...
449  if (count == 1 and detector[0] == 1)
450  rlamStep[0] *= 2.;
451 
452  if (debug) {
453  if (eStep[0] > 0.95 * e && detector[0] == 1)
454  LogDebug("FastCalorimetry") << " FamosHFShower::makeSteps - "
455  << "ECAL energy = " << eStep[0] << " out of total = " << e << std::endl;
456  }
457 }
std::vector< double > lamdepth
Definition: HFShower.h:78
std::vector< double > eStep
Definition: HFShower.h:76
double balanceEH
Definition: HFShower.h:113
const RandomEngineAndDistribution * random
Definition: HFShower.h:118
double alpHD
Definition: HFShower.h:68
std::vector< double > rlamStep
Definition: HFShower.h:76
std::vector< int > nspots
Definition: HFShower.h:75
double theR2
Definition: HFShower.h:67
double transParam
Definition: HFShower.h:101
int infinity
Definition: HFShower.h:80
double betHD
Definition: HFShower.h:68
std::vector< double > lamstep
Definition: HFShower.h:78
double theR1
Definition: HFShower.h:67
double eSpotSize
Definition: HFShower.h:105
double transFactor
Definition: HFShower.h:103
std::vector< int > detector
Definition: HFShower.h:75
double tgamEM
Definition: HFShower.h:68
double aloge
Definition: HFShower.h:73
double theR3
Definition: HFShower.h:67
std::vector< double > x0curr
Definition: HFShower.h:77
double e
Definition: HFShower.h:92
std::vector< double > lamcurr
Definition: HFShower.h:78
#define debug
Definition: HFShower.cc:25
double gam(double x, double a) const
Definition: HFShower.h:45
part
Definition: HCALResponse.h:20
double flatShoot(double xmin=0.0, double xmax=1.0) const
double tgamHD
Definition: HFShower.h:68
double betEM
Definition: HFShower.h:68
double alpEM
Definition: HFShower.h:68
#define LogDebug(id)
std::vector< double > x0depth
Definition: HFShower.h:77

◆ transProb()

double HFShower::transProb ( double  factor,
double  R,
double  r 
)
inlineprivate

Definition at line 50 of file HFShower.h.

References dttmaxenums::R, and alignCSCRings::r.

Referenced by compute().

50  {
51  double fsq = factor * factor;
52  return ((fsq + 1.) / fsq) * r * r / (r * r + R * R);
53  }

Member Data Documentation

◆ aloge

double HFShower::aloge
private

Definition at line 73 of file HFShower.h.

Referenced by HFShower(), and makeSteps().

◆ alpEM

double HFShower::alpEM
private

Definition at line 68 of file HFShower.h.

Referenced by HFShower(), and makeSteps().

◆ alpHD

double HFShower::alpHD
private

Definition at line 68 of file HFShower.h.

Referenced by HFShower(), and makeSteps().

◆ applyFidCut_

bool HFShower::applyFidCut_
private

Definition at line 49 of file HFShower.h.

Referenced by getHits(), and HFShower().

◆ balanceEH

double HFShower::balanceEH
private

Definition at line 113 of file HFShower.h.

Referenced by HFShower(), and makeSteps().

◆ betEM

double HFShower::betEM
private

Definition at line 68 of file HFShower.h.

Referenced by HFShower(), and makeSteps().

◆ betHD

double HFShower::betHD
private

Definition at line 68 of file HFShower.h.

Referenced by HFShower(), and makeSteps().

◆ cherenkov_

HFCherenkov HFShower::cherenkov_
private

Definition at line 45 of file HFShower.h.

Referenced by getHits().

◆ chkFibre_

int HFShower::chkFibre_
private

Definition at line 48 of file HFShower.h.

Referenced by getHits(), and HFShower().

◆ criticalEnergy

double HFShower::criticalEnergy
private

Definition at line 109 of file HFShower.h.

Referenced by HFShower().

◆ depthStart

double HFShower::depthStart
private

Definition at line 72 of file HFShower.h.

Referenced by HFShower().

◆ depthStep

double HFShower::depthStep
private

Definition at line 107 of file HFShower.h.

Referenced by HFShower().

◆ detector

std::vector<int> HFShower::detector
private

Definition at line 75 of file HFShower.h.

Referenced by compute(), HFShower(), and makeSteps().

◆ e

double HFShower::e
private

Definition at line 92 of file HFShower.h.

Referenced by HFShower(), and makeSteps().

◆ equalizeTimeShift_

bool HFShower::equalizeTimeShift_
private

Definition at line 50 of file HFShower.h.

Referenced by getHits(), and HFShower().

◆ eSpotSize

double HFShower::eSpotSize
private

Definition at line 105 of file HFShower.h.

Referenced by HFShower(), and makeSteps().

◆ eStep

std::vector<double> HFShower::eStep
private

Definition at line 76 of file HFShower.h.

Referenced by compute(), and makeSteps().

◆ fibre_

HFFibre HFShower::fibre_
private

Definition at line 46 of file HFShower.h.

Referenced by getHits().

◆ gpar_

std::vector<double> HFShower::gpar_
private

Definition at line 52 of file HFShower.h.

Referenced by getHits(), and HFShower().

◆ hcalDepthFactor

double HFShower::hcalDepthFactor
private

Definition at line 115 of file HFShower.h.

Referenced by compute(), and HFShower().

◆ infinity

int HFShower::infinity
private

Definition at line 80 of file HFShower.h.

Referenced by compute(), and makeSteps().

◆ lambdaEM

double HFShower::lambdaEM
private

Definition at line 71 of file HFShower.h.

Referenced by HFShower().

◆ lambdaHD

double HFShower::lambdaHD
private

Definition at line 71 of file HFShower.h.

Referenced by HFShower().

◆ lamcurr

std::vector<double> HFShower::lamcurr
private

Definition at line 78 of file HFShower.h.

Referenced by HFShower(), and makeSteps().

◆ lamdepth

std::vector<double> HFShower::lamdepth
private

Definition at line 78 of file HFShower.h.

Referenced by HFShower(), and makeSteps().

◆ lamstep

std::vector<double> HFShower::lamstep
private

Definition at line 78 of file HFShower.h.

Referenced by compute(), HFShower(), and makeSteps().

◆ lamtotal

std::vector<double> HFShower::lamtotal
private

Definition at line 78 of file HFShower.h.

Referenced by compute(), and HFShower().

◆ lossesOpt

int HFShower::lossesOpt
private

Definition at line 95 of file HFShower.h.

Referenced by compute(), and HFShower().

◆ maxTRfactor

double HFShower::maxTRfactor
private

Definition at line 111 of file HFShower.h.

Referenced by compute(), and HFShower().

◆ nDepthSteps

int HFShower::nDepthSteps
private

Definition at line 97 of file HFShower.h.

Referenced by HFShower().

◆ nspots

std::vector<int> HFShower::nspots
private

Definition at line 75 of file HFShower.h.

Referenced by compute(), and makeSteps().

◆ nTRsteps

int HFShower::nTRsteps
private

Definition at line 99 of file HFShower.h.

Referenced by compute(), and HFShower().

◆ onEcal

int HFShower::onEcal
private

Definition at line 89 of file HFShower.h.

Referenced by HFShower().

◆ part

double HFShower::part
private

Definition at line 68 of file HFShower.h.

◆ probMax_

double HFShower::probMax_
private

Definition at line 51 of file HFShower.h.

Referenced by getHits(), and HFShower().

◆ random

const RandomEngineAndDistribution* HFShower::random
private

Definition at line 118 of file HFShower.h.

Referenced by compute(), HFShower(), and makeSteps().

◆ rlamStep

std::vector<double> HFShower::rlamStep
private

Definition at line 76 of file HFShower.h.

Referenced by compute(), and makeSteps().

◆ tgamEM

double HFShower::tgamEM
private

Definition at line 68 of file HFShower.h.

Referenced by HFShower(), and makeSteps().

◆ tgamHD

double HFShower::tgamHD
private

Definition at line 68 of file HFShower.h.

Referenced by HFShower(), and makeSteps().

◆ theECALproperties

const ECALProperties* HFShower::theECALproperties
private

Definition at line 63 of file HFShower.h.

Referenced by HFShower().

◆ theGrid

EcalHitMaker* HFShower::theGrid
private

Definition at line 83 of file HFShower.h.

Referenced by compute(), and HFShower().

◆ theHcalHitMaker

HcalHitMaker* HFShower::theHcalHitMaker
private

Definition at line 86 of file HFShower.h.

Referenced by compute().

◆ theHCALproperties

const HCALProperties* HFShower::theHCALproperties
private

Definition at line 64 of file HFShower.h.

Referenced by HFShower().

◆ theParam

HDShowerParametrization* HFShower::theParam
private

Definition at line 60 of file HFShower.h.

Referenced by HFShower().

◆ theR1

double HFShower::theR1
private

Definition at line 67 of file HFShower.h.

Referenced by HFShower(), and makeSteps().

◆ theR2

double HFShower::theR2
private

Definition at line 67 of file HFShower.h.

Referenced by HFShower(), and makeSteps().

◆ theR3

double HFShower::theR3
private

Definition at line 67 of file HFShower.h.

Referenced by HFShower(), and makeSteps().

◆ transFactor

double HFShower::transFactor
private

Definition at line 103 of file HFShower.h.

Referenced by HFShower(), and makeSteps().

◆ transParam

double HFShower::transParam
private

Definition at line 101 of file HFShower.h.

Referenced by HFShower(), and makeSteps().

◆ x0curr

std::vector<double> HFShower::x0curr
private

Definition at line 77 of file HFShower.h.

Referenced by HFShower(), and makeSteps().

◆ x0depth

std::vector<double> HFShower::x0depth
private

Definition at line 77 of file HFShower.h.

Referenced by HFShower(), and makeSteps().

◆ x0EM

double HFShower::x0EM
private

Definition at line 71 of file HFShower.h.

Referenced by HFShower().

◆ x0HD

double HFShower::x0HD
private

Definition at line 71 of file HFShower.h.

Referenced by HFShower().