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 ()
 
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
 
std::unique_ptr< HFCherenkovcherenkov_
 
int chkFibre_
 
double criticalEnergy
 
double depthStart
 
double depthStep
 
std::vector< int > detector
 
double e
 
bool equalizeTimeShift_
 
double eSpotSize
 
std::vector< double > eStep
 
std::unique_ptr< HFFibrefibre_
 
std::vector< double > gpar_
 
const HcalDDDSimConstantshcalConstant_
 
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_2022v12_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() [1/2]

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_, cherenkov_, chkFibre_, equalizeTimeShift_, fibre_, HcalDDDSimConstants::getGparHF(), edm::ParameterSet::getParameter(), gpar_, hcalConstant_, Skims_PA_cff::name, AlCaHLTBitMon_ParallelJobs::p, and probMax_.

26  : hcalConstant_(hcons), 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  cherenkov_ = std::make_unique<HFCherenkov>(m_HF);
37  fibre_ = std::make_unique<HFFibre>(name, hcalConstant_, hps, p);
38 
39  //Special Geometry parameters
41 }
Log< level::Info, true > LogVerbatim
std::vector< double > gpar_
Definition: HFShower.h:55
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const HcalDDDSimConstants * hcalConstant_
Definition: HFShower.h:46
const std::vector< double > & getGparHF() const
std::unique_ptr< HFCherenkov > cherenkov_
Definition: HFShower.h:48
double probMax_
Definition: HFShower.h:54
std::unique_ptr< HFFibre > fibre_
Definition: HFShower.h:49
bool equalizeTimeShift_
Definition: HFShower.h:53
bool applyFidCut_
Definition: HFShower.h:52
int chkFibre_
Definition: HFShower.h:51

◆ ~HFShower() [2/2]

virtual HFShower::~HFShower ( )
virtual

Member Function Documentation

◆ compute()

bool HFShower::compute ( )

Compute the shower longitudinal and lateral development.

Definition at line 461 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, phase1PixelTopology::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().

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

References funct::abs(), applyFidCut_, cherenkov_, chkFibre_, LEDCalibrationChannels::depth, HCALHighEnergyHPDFilter_cfi::energy, equalizeTimeShift_, JetChargeProducer_cfi::exp, fibre_, gpar_, hfClusterShapes_cfi::hits, mps_fire::i, Skims_PA_cff::name, convertSQLiteXML::ok, AlCaHLTBitMon_ParallelJobs::p, HFFibreFiducial::PMTNumber(), probMax_, diffTwoXMLs::r1, diffTwoXMLs::r2, protons_cff::time, findQualityFiles::v, w(), and gpuVertexFinder::zv.

Referenced by FiberSD::ProcessHits().

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

◆ 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_, LEDCalibrationChannels::depth, HCALHighEnergyHPDFilter_cfi::energy, equalizeTimeShift_, fibre_, gpar_, hfClusterShapes_cfi::hits, mps_fire::i, Skims_PA_cff::name, convertSQLiteXML::ok, HFFibreFiducial::PMTNumber(), protons_cff::time, findQualityFiles::v, w(), and gpuVertexFinder::zv.

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

◆ getHits() [3/3]

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

Definition at line 175 of file HFShower.cc.

References funct::abs(), cherenkov_, chkFibre_, LEDCalibrationChannels::depth, HCALHighEnergyHPDFilter_cfi::energy, equalizeTimeShift_, fibre_, gpar_, hfClusterShapes_cfi::hits, mps_fire::i, Skims_PA_cff::name, convertSQLiteXML::ok, protons_cff::time, findQualityFiles::v, w(), and gpuVertexFinder::zv.

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

◆ indexFinder()

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

Definition at line 634 of file HFShower.cc.

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

Referenced by compute().

634  {
635  // binary search in the vector of doubles
636  int size = Fhist.size();
637 
638  int curr = size / 2;
639  int step = size / 4;
640  int iter;
641  int prevdir = 0;
642  int actudir = 0;
643 
644  for (iter = 0; iter < size; iter++) {
645  if (curr >= size || curr < 1)
646  LogWarning("FastCalorimetry") << " FamosHFShower::indexFinder - wrong current index = " << curr << " !!!"
647  << std::endl;
648 
649  if ((x <= Fhist[curr]) && (x > Fhist[curr - 1]))
650  break;
651  prevdir = actudir;
652  if (x > Fhist[curr]) {
653  actudir = 1;
654  } else {
655  actudir = -1;
656  }
657  if (prevdir * actudir < 0) {
658  if (step > 1)
659  step /= 2;
660  }
661  curr += actudir * step;
662  if (curr > size)
663  curr = size;
664  else {
665  if (curr < 1) {
666  curr = 1;
667  }
668  }
669 
670  if (debug == 3)
671  LogDebug("FastCalorimetry") << " indexFinder - end of iter." << iter << " curr, F[curr-1], F[curr] = " << curr
672  << " " << Fhist[curr - 1] << " " << Fhist[curr] << std::endl;
673  }
674 
675  if (debug == 3)
676  LogDebug("FastCalorimetry") << " indexFinder x = " << x << " found index = " << curr - 1 << std::endl;
677 
678  return curr - 1;
679 }
size
Write out results.
#define debug
Definition: HFShower.cc:25
step
Definition: StallMonitor.cc:98
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  double etot = 0.;
439  for (int i = 0; i < count; i++) {
440  eStep.push_back(temp[i] * e / sumes);
441  nspots.push_back((int)(eStep[i] / eSpotSize) + 1);
442  etot += eStep[i];
443 
444  if (debug)
445  LogDebug("FastCalorimetry") << i << " xO and lamdepth at the end of step = " << x0depth[i] << " " << lamdepth[i]
446  << " Estep func = " << eStep[i] << " Rstep = " << rlamStep[i]
447  << " Nspots = " << nspots[i] << std::endl;
448  }
449 
450  // The only step is in ECAL - let's make the size bigger ...
451  if (count == 1 and detector[0] == 1)
452  rlamStep[0] *= 2.;
453 
454  if (debug) {
455  if (eStep[0] > 0.95 * e && detector[0] == 1)
456  LogDebug("FastCalorimetry") << " FamosHFShower::makeSteps - "
457  << "ECAL energy = " << eStep[0] << " out of total = " << e << std::endl;
458  }
459 }
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 DQMScaleToClient_cfi::factor, 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 52 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_

std::unique_ptr<HFCherenkov> HFShower::cherenkov_
private

Definition at line 48 of file HFShower.h.

Referenced by getHits(), and HFShower().

◆ chkFibre_

int HFShower::chkFibre_
private

Definition at line 51 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 53 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_

std::unique_ptr<HFFibre> HFShower::fibre_
private

Definition at line 49 of file HFShower.h.

Referenced by getHits(), and HFShower().

◆ gpar_

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

Definition at line 55 of file HFShower.h.

Referenced by getHits(), and HFShower().

◆ hcalConstant_

const HcalDDDSimConstants* HFShower::hcalConstant_
private

Definition at line 46 of file HFShower.h.

Referenced by 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 54 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().