CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
HDShower Class Reference

#include <HDShower.h>

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...
 
int getmip ()
 
 HDShower (const RandomEngineAndDistribution *engine, HDShowerParametrization *myParam, EcalHitMaker *myGrid, HcalHitMaker *myHcalHitMaker, int onECAL, double epart, double pmip)
 
virtual ~HDShower ()
 

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
 
double balanceEH
 
double betEM
 
double betHD
 
double criticalEnergy
 
double depthECAL
 
double depthGAP
 
double depthGAPx0
 
double depthHCAL
 
double depthStart
 
double depthStep
 
double depthToHCAL
 
std::vector< int > detector
 
double e
 
double eSpotSize
 
std::vector< double > eStep
 
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 mip
 
int nDepthSteps
 
std::vector< int > nspots
 
int nTRsteps
 
int onEcal
 
double part
 
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 HDShower.h.

Member Typedef Documentation

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

Definition at line 29 of file HDShower.h.

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

Definition at line 30 of file HDShower.h.

typedef Steps::const_iterator HDShower::step_iterator

Definition at line 32 of file HDShower.h.

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

Definition at line 31 of file HDShower.h.

Definition at line 27 of file HDShower.h.

Constructor & Destructor Documentation

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

Definition at line 21 of file HDShower.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, depthECAL, depthGAP, depthGAPx0, depthHCAL, depthStart, depthStep, depthToHCAL, 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(), i, ECALProperties::interactionLength(), HCALProperties::interactionLength(), lambdaEM, lambdaHD, lamcurr, lamdepth, lamstep, lamtotal, cmsBatch::log, lossesOpt, makeSteps(), HLT_25ns14e33_v1_cff::maxDepth, maxTRfactor, mip, 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.

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

Definition at line 44 of file HDShower.h.

44 {;}

Member Function Documentation

bool HDShower::compute ( )

Compute the shower longitudinal and lateral development.

Definition at line 447 of file HDShower.cc.

References HcalHitMaker::addHit(), EcalHitMaker::addHit(), prof2calltree::count, gather_cfg::cout, debug, detector, patCandidatesForDimuonsSequences_cff::ecal, eStep, RandomEngineAndDistribution::flatShoot(), EcalHitMaker::getPads(), hcalDepthFactor, i, cmsHarvester::index, indexFinder(), EcalCondDB::inf, infinity, j, lamstep, lamtotal, lossesOpt, M_PI, maxTRfactor, nspots, nTRsteps, phi, CosmicsPD_Skims::radius, random, query::result, rlamStep, HcalHitMaker::setDepth(), HcalHitMaker::setSpotEnergy(), EcalHitMaker::setSpotEnergy(), ntuplemaker::status, theGrid, theHcalHitMaker, and transProb().

Referenced by CalorimetryManager::HDShowerSimulation().

447  {
448 
449  // TimeMe theT("FamosHDShower::compute");
450 
451  bool status = false;
452  int numLongit = eStep.size();
453  if(debug)
454  LogInfo("FastCalorimetry") << " FamosHDShower::compute - "
455  << " N_long.steps required : " << numLongit << std::endl;
456 
457  if(numLongit > 0) {
458 
459  status = true;
460  // Prepare the trsanverse probability function
461  std::vector<double> Fhist;
462  std::vector<double> rhist;
463  for (int j = 0; j < nTRsteps + 1; j++) {
464  rhist.push_back(maxTRfactor * j / nTRsteps );
465  Fhist.push_back(transProb(maxTRfactor,1.,rhist[j]));
466  if(debug == 3) LogInfo("FastCalorimetry") << "indexFinder - i, Fhist[i] = " << j << " " << Fhist[j] << std::endl;
467  }
468 
469  // Longitudinal steps
470  for (int i = 0; i < numLongit ; i++) {
471 
472  double currentDepthL0 = lamtotal[i] - 0.5 * lamstep[i];
473  // vary the longitudinal profile if needed
474  if(detector[i] != 1) currentDepthL0 *= hcalDepthFactor;
475  if(debug) LogInfo("FastCalorimetry") << " FamosHDShower::compute - detector = " << detector[i] << " currentDepthL0 = " << currentDepthL0 << std::endl;
476 
477  double maxTRsize = maxTRfactor * rlamStep[i]; // in lambda units
478  double rbinsize = maxTRsize / nTRsteps;
479  double espot = eStep[i] / (double)nspots[i]; // re-adjust espot
480 
481  if(espot > 2. || espot < 0. ) LogInfo("FastCalorimetry") << " FamosHDShower::compute - unphysical espot = " << espot << std::endl;
482 
483  int ecal = 0;
484  if(detector[i] != 1) {
485  bool setHDdepth = theHcalHitMaker->setDepth(currentDepthL0);
486 
487  if(debug) LogInfo("FastCalorimetry") << " FamosHDShower::compute - status of " << " theHcalHitMaker->setDepth(currentDepthL0) is "
488  << setHDdepth << std::endl;
489 
490  if(!setHDdepth) {
491  currentDepthL0 -= lamstep[i];
492  setHDdepth = theHcalHitMaker->setDepth(currentDepthL0);
493  }
494 
495  if(!setHDdepth) continue;
496 
498 
499  //fill hcal longitudinal distribution histogram
500  }
501  else {
502  ecal = 1;
503  bool status = theGrid->getPads(currentDepthL0);
504 
505  if(debug) LogInfo("FastCalorimetry") << " FamosHDShower::compute - status of Grid = " << status << std::endl;
506 
507  if(!status) continue;
508 
509  int ntry = nspots[i] * 10;
510  if( ntry >= infinity ) { // use max allowed in case of too many spots
511  nspots[i] = 0.5 * infinity;
512  espot *= 0.1 * (double)ntry / double(nspots[i]);
513  }
514  else {
515  espot *= 0.1; // fine-grain energy spots in ECAL
516  // to avoid false ECAL clustering
517  nspots[i] = ntry;
518  }
519 
520  theGrid->setSpotEnergy(espot);
521 
522  //fill ecal longitudinal distribution histogram
523  }
524 
525  // Transverse distribition
526  int nok = 0; // counter of OK
527  int count = 0;
528  int inf = infinity;
529  if(lossesOpt) inf = nspots[i]; // if losses are enabled, otherwise
530  // only OK points are counted ...
531  if(nspots[i] > inf ) std::cout << " FamosHDShower::compute - at long.step " << i << " too many spots required : " << nspots[i] << " !!! " << std::endl;
532 
533  for (int j = 0; j < inf; j++) {
534  if(nok == nspots[i]) break;
535  count ++;
536 
537  double prob = random->flatShoot();
538  int index = indexFinder(prob,Fhist);
539  double radius = rlamStep[i] * rhist[index] + random->flatShoot() * rbinsize; // in-bin
540  double phi = 2.*M_PI*random->flatShoot();
541 
542  if(debug == 2) LogInfo("FastCalorimetry") << std::endl << " FamosHDShower::compute " << " r = " << radius
543  << " phi = " << phi << std::endl;
544 
545  bool result;
546  if(ecal) {
547  result = theGrid->addHit(radius,phi,0);
548 
549  if(debug == 2) LogInfo("FastCalorimetry") << " FamosHDShower::compute - " << " theGrid->addHit result = " << result << std::endl;
550 
551  //fill ecal transverse distribution histogram
552  }
553  else {
554  result = theHcalHitMaker->addHit(radius,phi,0);
555 
556  if(debug == 2) LogInfo("FastCalorimetry") << " FamosHDShower::compute - " << " theHcalHitMaker->addHit result = " << result << std::endl;
557 
558  //fill hcal transverse distribution histogram
559  }
560 
561  if(result) nok ++;
562 
563 
564 
565  } // end of tranverse simulation
566 
567 
568  if(count == infinity) {
569  if(debug) LogInfo("FastCalorimetry") << " FamosHDShower::compute " << " maximum number of"
570  << " transverse points " << count << " is used !!!" << std::endl;
571  }
572 
573  if(debug) LogInfo("FastCalorimetry") << " FamosHDShower::compute " << " long.step No."
574  << i << " Ntry, Nok = " << count << " " << nok << std::endl;
575  } // end of longitudinal steps
576  } // end of no steps
577 
578  return status;
579 
580 }
void setSpotEnergy(double e)
Set the spot energy.
Definition: HcalHitMaker.h:28
int i
Definition: DBlmapReader.cc:9
EcalHitMaker * theGrid
Definition: HDShower.h:90
bool addHit(double r, double phi, unsigned layer=0)
void setSpotEnergy(double e)
Definition: EcalHitMaker.h:117
double flatShoot(double xmin=0.0, double xmax=1.0) const
double maxTRfactor
Definition: HDShower.h:121
std::vector< double > lamstep
Definition: HDShower.h:85
int nTRsteps
Definition: HDShower.h:109
double hcalDepthFactor
Definition: HDShower.h:125
tuple result
Definition: query.py:137
string inf
Definition: EcalCondDB.py:94
double transProb(double factor, double R, double r)
Definition: HDShower.h:57
int j
Definition: DBlmapReader.cc:9
int infinity
Definition: HDShower.h:87
#define M_PI
#define debug
Definition: HDRShower.cc:19
std::vector< int > nspots
Definition: HDShower.h:82
HcalHitMaker * theHcalHitMaker
Definition: HDShower.h:93
std::vector< int > detector
Definition: HDShower.h:82
std::vector< double > lamtotal
Definition: HDShower.h:85
bool getPads(double depth, bool inCm=false)
int lossesOpt
Definition: HDShower.h:105
const RandomEngineAndDistribution * random
Definition: HDShower.h:128
tuple cout
Definition: gather_cfg.py:121
std::vector< double > eStep
Definition: HDShower.h:83
int indexFinder(double x, const std::vector< double > &Fhist)
Definition: HDShower.cc:582
tuple status
Definition: ntuplemaker.py:245
std::vector< double > rlamStep
Definition: HDShower.h:83
bool addHit(double r, double phi, unsigned layer=0)
add the hit in the HCAL in local coordinates
Definition: HcalHitMaker.cc:28
bool setDepth(double, bool inCm=false)
set the depth in X0 or Lambda0 units depending on showerType
double HDShower::gam ( double  x,
double  a 
) const
inlineprivate

Definition at line 52 of file HDShower.h.

References create_public_lumi_plots::exp, and funct::pow().

Referenced by makeSteps().

52 { 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:40
int HDShower::getmip ( )
inline

Definition at line 42 of file HDShower.h.

References mip.

Referenced by CalorimetryManager::HDShowerSimulation().

42 {return mip;}
int mip
Definition: HDShower.h:99
int HDShower::indexFinder ( double  x,
const std::vector< double > &  Fhist 
)
private

Definition at line 582 of file HDShower.cc.

References debug, findQualityFiles::size, and relval_parameters_module::step.

Referenced by compute().

582  {
583  // binary search in the vector of doubles
584  int size = Fhist.size();
585 
586  int curr = size / 2;
587  int step = size / 4;
588  int iter;
589  int prevdir = 0;
590  int actudir = 0;
591 
592  for (iter = 0; iter < size ; iter++) {
593 
594  if( curr >= size || curr < 1 )
595  LogWarning("FastCalorimetry") << " FamosHDShower::indexFinder - wrong current index = "
596  << curr << " !!!" << std::endl;
597 
598  if ((x <= Fhist[curr]) && (x > Fhist[curr-1])) break;
599  prevdir = actudir;
600  if(x > Fhist[curr]) {actudir = 1;}
601  else {actudir = -1;}
602  if(prevdir * actudir < 0) { if(step > 1) step /= 2;}
603  curr += actudir * step;
604  if(curr > size) curr = size;
605  else { if(curr < 1) {curr = 1;}}
606 
607  if(debug == 3)
608  LogInfo("FastCalorimetry") << " indexFinder - end of iter." << iter
609  << " curr, F[curr-1], F[curr] = "
610  << curr << " " << Fhist[curr-1] << " " << Fhist[curr] << std::endl;
611 
612  }
613 
614  if(debug == 3)
615  LogInfo("FastCalorimetry") << " indexFinder x = " << x << " found index = " << curr-1
616  << std::endl;
617 
618 
619  return curr-1;
620 }
#define debug
Definition: HDRShower.cc:19
tuple size
Write out results.
void HDShower::makeSteps ( int  nsteps)
private

Definition at line 339 of file HDShower.cc.

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

Referenced by HDShower().

339  {
340 
341  double sumes = 0.;
342  double sum = 0.;
343  std::vector<double> temp;
344 
345  if(debug)
346  LogInfo("FastCalorimetry") << " FamosHDShower::makeSteps - "
347  << " nsteps required : " << nsteps << std::endl;
348 
349  int count = 0;
350  for (int i = 0; i < nsteps; i++) {
351 
352  double deplam = lamdepth[i] - 0.5 * lamstep[i];
353  double depx0 = x0depth[i] - 0.5 * lamstep[i] / x0curr[i];
354  double x = betEM * depx0;
355  double y = betHD * deplam;
356 
357  if(debug == 2)
358  LogInfo("FastCalorimetry") << " FamosHDShower::makeSteps "
359  << " - step " << i
360  << " depx0, x = " << depx0 << ", " << x
361  << " deplam, y = " << deplam << ", "
362  << y << std::endl;
363 
364  double est = (part * betEM * gam(x,alpEM) * lamcurr[i] /
365  (x0curr[i] * tgamEM) +
366  (1.-part) * betHD * gam(y,alpHD) / tgamHD) * lamstep[i];
367 
368  // protection ...
369  if(est < 0.) {
370  LogInfo("FastCalorimetry") << "*** FamosHDShower::makeSteps " << " - negative step energy !!!"
371  << std::endl;
372  est = 0.;
373  break ;
374  }
375 
376  // for estimates only
377  sum += est;
378  int nPest = (int) (est * e / sum / eSpotSize) ;
379 
380  if(debug == 2)
381  LogInfo("FastCalorimetry") << " FamosHDShower::makeSteps - nPoints estimate = "
382  << nPest << std::endl;
383 
384  if(nPest <= 1 && count !=0 ) break;
385 
386  // good step - to proceed
387 
388  temp.push_back(est);
389  sumes += est;
390 
391  rlamStep.push_back(transParam * (theR1 + (theR2 - theR3 * aloge))
392  * deplam * transFactor);
393  count ++;
394  }
395 
396  // fluctuations in ECAL and re-distribution of remaining energy in HCAL
397  if(detector[0] == 1 && count > 1) {
398  double oldECALenergy = temp[0];
399  double oldHCALenergy = sumes - oldECALenergy ;
400  double newECALenergy = 2. * sumes;
401  for (int i = 0; newECALenergy > sumes && i < infinity; i++)
402  newECALenergy = 2.* balanceEH * random->flatShoot() * oldECALenergy;
403 
404  if(debug == 2)
405  LogInfo("FastCalorimetry") << "*** FamosHDShower::makeSteps " << " ECAL fraction : old/new - "
406  << oldECALenergy/sumes << "/" << newECALenergy/sumes << std::endl;
407 
408  temp[0] = newECALenergy;
409  double newHCALenergy = sumes - newECALenergy;
410  double newHCALreweight = newHCALenergy / oldHCALenergy;
411 
412  for (int i = 1; i < count; i++) {
413  temp[i] *= newHCALreweight;
414  }
415 
416  }
417 
418  // final re-normalization of the energy fractions
419  for (int i = 0; i < count ; i++) {
420  eStep.push_back(temp[i] * e / sumes );
421  nspots.push_back((int)(eStep[i]/eSpotSize)+1);
422 
423  if(debug)
424  LogInfo("FastCalorimetry")
425  << " step " << i
426  << " det: " << detector[i]
427  << " xO and lamdepth at the end of step = "
428  << x0depth[i] << " "
429  << lamdepth[i] << " Estep func = " << eStep[i]
430  << " Rstep = " << rlamStep[i] << " Nspots = " << nspots[i]
431  << " espot = " << eStep[i] / (double)nspots[i]
432  << std::endl;
433 
434  }
435 
436  // The only step is in ECAL - let's make the size bigger ...
437  if(count == 1 and detector[0] == 1) rlamStep[0] *= 2.;
438 
439  if(debug) {
440  if(eStep[0] > 0.95 * e && detector[0] == 1)
441  LogInfo("FastCalorimetry") << " FamosHDShower::makeSteps - " << "ECAL energy = " << eStep[0]
442  << " out of total = " << e << std::endl;
443  }
444 
445 }
int i
Definition: DBlmapReader.cc:9
double balanceEH
Definition: HDShower.h:123
double eSpotSize
Definition: HDShower.h:115
double flatShoot(double xmin=0.0, double xmax=1.0) const
double betEM
Definition: HDShower.h:75
std::vector< double > lamstep
Definition: HDShower.h:85
double theR3
Definition: HDShower.h:74
std::vector< double > x0curr
Definition: HDShower.h:84
double betHD
Definition: HDShower.h:75
double theR1
Definition: HDShower.h:74
double theR2
Definition: HDShower.h:74
std::vector< double > lamdepth
Definition: HDShower.h:85
std::vector< double > lamcurr
Definition: HDShower.h:85
double gam(double x, double a) const
Definition: HDShower.h:52
std::vector< double > x0depth
Definition: HDShower.h:84
int infinity
Definition: HDShower.h:87
double aloge
Definition: HDShower.h:80
double tgamHD
Definition: HDShower.h:75
double alpEM
Definition: HDShower.h:75
#define debug
Definition: HDRShower.cc:19
double transParam
Definition: HDShower.h:111
std::vector< int > nspots
Definition: HDShower.h:82
part
Definition: HCALResponse.h:20
double alpHD
Definition: HDShower.h:75
std::vector< int > detector
Definition: HDShower.h:82
double transFactor
Definition: HDShower.h:113
double e
Definition: HDShower.h:102
const RandomEngineAndDistribution * random
Definition: HDShower.h:128
std::vector< double > eStep
Definition: HDShower.h:83
std::vector< double > rlamStep
Definition: HDShower.h:83
double tgamEM
Definition: HDShower.h:75
double HDShower::transProb ( double  factor,
double  R,
double  r 
)
inlineprivate

Definition at line 57 of file HDShower.h.

References dttmaxenums::R.

Referenced by compute().

57  {
58  double fsq = factor * factor;
59  return ((fsq + 1.)/fsq) * r * r / (r*r + R*R) ;
60  }

Member Data Documentation

double HDShower::aloge
private

Definition at line 80 of file HDShower.h.

Referenced by HDShower(), and makeSteps().

double HDShower::alpEM
private

Definition at line 75 of file HDShower.h.

Referenced by HDShower(), and makeSteps().

double HDShower::alpHD
private

Definition at line 75 of file HDShower.h.

Referenced by HDShower(), and makeSteps().

double HDShower::balanceEH
private

Definition at line 123 of file HDShower.h.

Referenced by HDShower(), and makeSteps().

double HDShower::betEM
private

Definition at line 75 of file HDShower.h.

Referenced by HDShower(), and makeSteps().

double HDShower::betHD
private

Definition at line 75 of file HDShower.h.

Referenced by HDShower(), and makeSteps().

double HDShower::criticalEnergy
private

Definition at line 119 of file HDShower.h.

Referenced by HDShower().

double HDShower::depthECAL
private

Definition at line 131 of file HDShower.h.

Referenced by HDShower().

double HDShower::depthGAP
private

Definition at line 131 of file HDShower.h.

Referenced by HDShower().

double HDShower::depthGAPx0
private

Definition at line 131 of file HDShower.h.

Referenced by HDShower().

double HDShower::depthHCAL
private

Definition at line 131 of file HDShower.h.

Referenced by HDShower().

double HDShower::depthStart
private

Definition at line 79 of file HDShower.h.

Referenced by HDShower().

double HDShower::depthStep
private

Definition at line 117 of file HDShower.h.

Referenced by HDShower().

double HDShower::depthToHCAL
private

Definition at line 131 of file HDShower.h.

Referenced by HDShower().

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

Definition at line 82 of file HDShower.h.

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

double HDShower::e
private

Definition at line 102 of file HDShower.h.

Referenced by HDShower(), and makeSteps().

double HDShower::eSpotSize
private

Definition at line 115 of file HDShower.h.

Referenced by HDShower(), and makeSteps().

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

Definition at line 83 of file HDShower.h.

Referenced by compute(), and makeSteps().

double HDShower::hcalDepthFactor
private

Definition at line 125 of file HDShower.h.

Referenced by compute(), and HDShower().

int HDShower::infinity
private

Definition at line 87 of file HDShower.h.

Referenced by compute(), and makeSteps().

double HDShower::lambdaEM
private

Definition at line 78 of file HDShower.h.

Referenced by HDShower().

double HDShower::lambdaHD
private

Definition at line 78 of file HDShower.h.

Referenced by HDShower().

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

Definition at line 85 of file HDShower.h.

Referenced by HDShower(), and makeSteps().

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

Definition at line 85 of file HDShower.h.

Referenced by HDShower(), and makeSteps().

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

Definition at line 85 of file HDShower.h.

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

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

Definition at line 85 of file HDShower.h.

Referenced by compute(), and HDShower().

int HDShower::lossesOpt
private

Definition at line 105 of file HDShower.h.

Referenced by compute(), and HDShower().

double HDShower::maxTRfactor
private

Definition at line 121 of file HDShower.h.

Referenced by compute(), and HDShower().

int HDShower::mip
private

Definition at line 99 of file HDShower.h.

Referenced by getmip(), and HDShower().

int HDShower::nDepthSteps
private

Definition at line 107 of file HDShower.h.

Referenced by HDShower().

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

Definition at line 82 of file HDShower.h.

Referenced by compute(), and makeSteps().

int HDShower::nTRsteps
private

Definition at line 109 of file HDShower.h.

Referenced by compute(), and HDShower().

int HDShower::onEcal
private

Definition at line 96 of file HDShower.h.

Referenced by HDShower().

double HDShower::part
private

Definition at line 75 of file HDShower.h.

const RandomEngineAndDistribution* HDShower::random
private

Definition at line 128 of file HDShower.h.

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

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

Definition at line 83 of file HDShower.h.

Referenced by compute(), and makeSteps().

double HDShower::tgamEM
private

Definition at line 75 of file HDShower.h.

Referenced by HDShower(), and makeSteps().

double HDShower::tgamHD
private

Definition at line 75 of file HDShower.h.

Referenced by HDShower(), and makeSteps().

const ECALProperties* HDShower::theECALproperties
private

Definition at line 70 of file HDShower.h.

Referenced by HDShower().

EcalHitMaker* HDShower::theGrid
private

Definition at line 90 of file HDShower.h.

Referenced by compute(), and HDShower().

HcalHitMaker* HDShower::theHcalHitMaker
private

Definition at line 93 of file HDShower.h.

Referenced by compute().

const HCALProperties* HDShower::theHCALproperties
private

Definition at line 71 of file HDShower.h.

Referenced by HDShower().

HDShowerParametrization* HDShower::theParam
private

Definition at line 67 of file HDShower.h.

Referenced by HDShower().

double HDShower::theR1
private

Definition at line 74 of file HDShower.h.

Referenced by HDShower(), and makeSteps().

double HDShower::theR2
private

Definition at line 74 of file HDShower.h.

Referenced by HDShower(), and makeSteps().

double HDShower::theR3
private

Definition at line 74 of file HDShower.h.

Referenced by HDShower(), and makeSteps().

double HDShower::transFactor
private

Definition at line 113 of file HDShower.h.

Referenced by HDShower(), and makeSteps().

double HDShower::transParam
private

Definition at line 111 of file HDShower.h.

Referenced by HDShower(), and makeSteps().

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

Definition at line 84 of file HDShower.h.

Referenced by HDShower(), and makeSteps().

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

Definition at line 84 of file HDShower.h.

Referenced by HDShower(), and makeSteps().

double HDShower::x0EM
private

Definition at line 78 of file HDShower.h.

Referenced by HDShower().

double HDShower::x0HD
private

Definition at line 78 of file HDShower.h.

Referenced by HDShower().