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 RandomEngine *engine, HDShowerParametrization *myParam, EcalHitMaker *myGrid, HcalHitMaker *myHcalHitMaker, int onECAL, double epart)
 
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 depthStart
 
double depthStep
 
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 RandomEnginerandom
 
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 RandomEngine engine,
HDShowerParametrization myParam,
EcalHitMaker myGrid,
HcalHitMaker myHcalHitMaker,
int  onECAL,
double  epart 
)

Definition at line 30 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, depthStart, depthStep, detector, e, HDShowerParametrization::e1(), HDShowerParametrization::e2(), EcalHitMaker::ecalHcalGapTotalL0(), EcalHitMaker::ecalHcalGapTotalX0(), HDShowerParametrization::ecalProperties(), EcalHitMaker::ecalTotalL0(), HDShowerParametrization::emax(), HDShowerParametrization::emid(), HDShowerParametrization::emin(), eSpotSize, RandomEngine::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, create_public_lumi_plots::log, LogDebug, lossesOpt, makeSteps(), 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.

36  : theParam(myParam),
37  theGrid(myGrid),
38  theHcalHitMaker(myHcalHitMaker),
39  onEcal(onECAL),
40  e(epart),
41  random(engine)
42 {
43  // To get an access to constants read in FASTCalorimeter
44  // FASTCalorimeter * myCalorimeter= FASTCalorimeter::instance();
45 
46  // Values taken from FamosGeneric/FamosCalorimeter/src/FASTCalorimeter.cc
47  lossesOpt = myParam->hsParameters()->getHDlossesOpt();
49  nTRsteps = myParam->hsParameters()->getHDnTRsteps();
50  transParam = myParam->hsParameters()->getHDtransParam();
51  eSpotSize = myParam->hsParameters()->getHDeSpotSize();
52  depthStep = myParam->hsParameters()->getHDdepthStep();
55  balanceEH = myParam->hsParameters()->getHDbalanceEH();
57 
58  // Special tr.size fluctuations
59  transParam *= (1. + random->flatShoot());
60 
61  // Special long. fluctuations
62  hcalDepthFactor += 0.05 * (2.* random->flatShoot() - 1.);
63 
64  transFactor = 1.; // normally 1, in HF - might be smaller
65  // to take into account
66  // a narrowness of the HF shower (Cherenkov light)
67 
68  // simple protection ...
69  if(e < 0) e = 0.;
70 
71  // Get the Famos Histos pointer
72  // myHistos = FamosHistos::instance();
73  // std::cout << " Hello FamosShower " << std::endl;
74 
77 
78  double emax = theParam->emax();
79  double emid = theParam->emid();
80  double emin = theParam->emin();
81  double effective = e;
82 
83 
84  if( e < emid ) {
85  theParam->setCase(1);
86  // avoid "underflow" below Emin (for parameters calculation only)
87  if(e < emin) effective = emin;
88  }
89  else
90  theParam->setCase(2);
91 
92  // Avoid "overflow" beyond Emax (for parameters)
93  if(effective > 0.5 * emax) {
94  eSpotSize *= 2.5;
95  if(effective > emax) {
96  effective = emax;
97  eSpotSize *= 4.;
98  depthStep *= 2.;
99  if(effective > 1000.)
100  eSpotSize *= 2.;
101  }
102  }
103 
104 
105  if(debug == 2 )
106  LogDebug("FastCalorimetry") << " HDShower : " << std::endl
107  << " Energy " << e << std::endl
108  << " lossesOpt " << lossesOpt << std::endl
109  << " nDepthSteps " << nDepthSteps << std::endl
110  << " nTRsteps " << nTRsteps << std::endl
111  << " transParam " << transParam << std::endl
112  << " eSpotSize " << eSpotSize << std::endl
113  << " criticalEnergy " << criticalEnergy << std::endl
114  << " maxTRfactor " << maxTRfactor << std::endl
115  << " balanceEH " << balanceEH << std::endl
116  << "hcalDepthFactor " << hcalDepthFactor << std::endl;
117 
118 
119  double alpEM1 = theParam->alpe1();
120  double alpEM2 = theParam->alpe2();
121 
122  double betEM1 = theParam->bete1();
123  double betEM2 = theParam->bete2();
124 
125  double alpHD1 = theParam->alph1();
126  double alpHD2 = theParam->alph2();
127 
128  double betHD1 = theParam->beth1();
129  double betHD2 = theParam->beth2();
130 
131  double part1 = theParam->part1();
132  double part2 = theParam->part2();
133 
134  aloge = std::log(effective);
135 
136  double edpar = (theParam->e1() + aloge * theParam->e2()) * effective;
137  double aedep = std::log(edpar);
138 
139  if(debug == 2)
140  LogDebug("FastCalorimetry") << " HDShower : " << std::endl
141  << " edpar " << edpar << " aedep " << aedep << std::endl
142  << " alpEM1 " << alpEM1 << std::endl
143  << " alpEM2 " << alpEM2 << std::endl
144  << " betEM1 " << betEM1 << std::endl
145  << " betEM2 " << betEM2 << std::endl
146  << " alpHD1 " << alpHD1 << std::endl
147  << " alpHD2 " << alpHD2 << std::endl
148  << " betHD1 " << betHD1 << std::endl
149  << " betHD2 " << betHD2 << std::endl
150  << " part1 " << part1 << std::endl
151  << " part2 " << part2 << std::endl;
152 
153  // private members to set
154  theR1 = theParam->r1();
155  theR2 = theParam->r2();
156  theR3 = theParam->r3();
157 
158  alpEM = alpEM1 + alpEM2 * aedep;
159  tgamEM = tgamma(alpEM);
160  betEM = betEM1 - betEM2 * aedep;
161  alpHD = alpHD1 + alpHD2 * aedep;
162  tgamHD = tgamma(alpHD);
163  betHD = betHD1 - betHD2 * aedep;
164  part = part1 - part2 * aedep;
165  if(part > 1.) part = 1.; // protection - just in case of
166 
167  if(debug == 2 )
168  LogDebug("FastCalorimetry") << " HDShower : " << std::endl
169  << " alpEM " << alpEM << std::endl
170  << " tgamEM " << tgamEM << std::endl
171  << " betEM " << betEM << std::endl
172  << " alpHD " << alpHD << std::endl
173  << " tgamHD " << tgamHD << std::endl
174  << " betHD " << betHD << std::endl
175  << " part " << part << std::endl;
176 
177 
178  if(onECAL){
181  }
182  else {
183  lambdaEM = 0.;
184  x0EM = 0.;
185  }
188 
189  if(debug == 2)
190  LogDebug("FastCalorimetry") << " HDShower e " << e << std::endl
191  << " x0EM = " << x0EM << std::endl
192  << " x0HD = " << x0HD << std::endl
193  << " lamEM = " << lambdaEM << std::endl
194  << " lamHD = " << lambdaHD << std::endl;
195 
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  mip = 1; // just to initiate particle as MIP in ECAL
209 
210  if(e < criticalEnergy ) nmoresteps = 1;
211  else 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  double depthStart = std::log(1./random->flatShoot()); // starting point lambda unts
231 
232  if(e < emin) {
233  if(debug)
234  LogDebug("FastCalorimetry") << " FamosHDShower : e <emin -> depthStart = 0" << std::endl;
235  depthStart = 0.;
236  }
237 
238  if(depthStart > maxDepth) {
239  if(debug) LogDebug("FastCalorimetry") << " FamosHDShower : depthStart too big ... = "
240  << depthStart << std::endl;
241 
242  depthStart = maxDepth * random->flatShoot();
243  if( depthStart < 0.) depthStart = 0.;
244  if(debug) LogDebug("FastCalorimetry") << " FamosHDShower : depthStart re-calculated = "
245  << depthStart << std::endl;
246  }
247 
248  if( onECAL && e < emid ) {
249  if(depthECAL > depthStep && (depthECAL - depthStart)/depthECAL > 0.2) {
250 
251  depthStart = 0.5 * depthECAL * random->flatShoot();
252  if(debug)
253  LogDebug("FastCalorimetry") << " FamosHDShower : small energy, "
254  << " depthStart reduced to = " << depthStart << std::endl;
255 
256  }
257  }
258 
259  if( depthHCAL < depthStep) {
260  if(debug) LogDebug("FastCalorimetry") << " FamosHDShower : depthHCAL too small ... = "
261  << depthHCAL << " depthStart -> forced to 0 !!!"
262  << std::endl;
263  depthStart = 0.;
264  nmoresteps = 0;
265 
266  if(depthECAL < depthStep) {
267  nsteps = -1;
268  LogInfo("FastCalorimetry") << " FamosHDShower : too small ECAL and HCAL depths - "
269  << " particle is lost !!! " << std::endl;
270  }
271  }
272 
273 
274 
275  if(debug)
276  LogDebug("FastCalorimetry") << " FamosHDShower depths(lam) - " << std::endl
277  << " ECAL = " << depthECAL << std::endl
278  << " GAP = " << depthGAP << std::endl
279  << " HCAL = " << depthHCAL << std::endl
280  << " starting point = " << depthStart << std::endl;
281 
282  if( onEcal ) {
283  if(debug) LogDebug("FastCalorimetry") << " FamosHDShower : onECAL" << std::endl;
284  if(depthStart < depthECAL) {
285  if(debug) LogDebug("FastCalorimetry") << " FamosHDShower : depthStart < depthECAL" << std::endl;
286  if(depthECAL > depthStep && (depthECAL - depthStart)/depthECAL > 0.1) {
287  if(debug) LogDebug("FastCalorimetry") << " FamosHDShower : enough space to make ECAL step"
288  << 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  mip = 0;
302 
303  if(debug) LogDebug("FastCalorimetry") << " FamosHDShower : " << " in ECAL sum1, sum2 "
304  << 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 << " FamosHDShower : not enough space to make ECAL step" << std::endl;
315  if(debug) LogDebug("FastCalorimetry") << " FamosHDShower : goto HCAL" << std::endl;
316 
317  depthStart = depthToHCAL;
318  sum1 += depthStart;
319  }
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) LogDebug("FastCalorimetry") << " FamosHDShower : goto HCAL" << std::endl;
329  }
330  }
331  else { // Forward
332  if(debug) LogDebug("FastCalorimetry") << " FamosHDShower : forward" << std::endl;
333  sum1 += depthStart;
334  transFactor = 0.5; // makes narower tresverse size of shower
335  }
336 
337  for (int i = 0; i < nmoresteps ; i++) {
338  sum1 += depthStep;
339  if (sum1 > (depthECAL + depthGAP + depthHCAL)) break;
340  sum2 += depthStep;
341  sum3 += sum2 * lambdaHD / x0HD;
342  lamtotal.push_back(sum1);
343  lamdepth.push_back(sum2);
344  lamcurr.push_back(lambdaHD);
345  lamstep.push_back(depthStep);
346  x0depth.push_back(sum3);
347  x0curr.push_back(x0HD);
348  detector.push_back(3);
349  nsteps++;
350  }
351 
352 
353  // Make fractions of energy and transverse radii at each step
354 
355  if(nsteps > 0) { makeSteps(nsteps); }
356 
357 }
#define LogDebug(id)
double depthStart
Definition: HDShower.h:78
int i
Definition: DBlmapReader.cc:9
EcalHitMaker * theGrid
Definition: HDShower.h:89
double balanceEH
Definition: HDShower.h:122
double eSpotSize
Definition: HDShower.h:114
double betEM
Definition: HDShower.h:74
double radLenIncm() const
Radiation length in cm.
double maxTRfactor
Definition: HDShower.h:120
double criticalEnergy
Definition: HDShower.h:118
const ECALProperties * theECALproperties
Definition: HDShower.h:69
int getHDnTRsteps() const
Definition: HSParameters.h:22
double getHDeSpotSize() const
Definition: HSParameters.h:24
std::vector< double > lamstep
Definition: HDShower.h:84
int nTRsteps
Definition: HDShower.h:108
double x0EM
Definition: HDShower.h:77
double theR3
Definition: HDShower.h:73
std::vector< double > x0curr
Definition: HDShower.h:83
double getHDhcalDepthFactor() const
Definition: HSParameters.h:29
double betHD
Definition: HDShower.h:74
double interactionLength() const
Interaction length in cm.
double theR1
Definition: HDShower.h:73
double theR2
Definition: HDShower.h:73
std::vector< double > lamdepth
Definition: HDShower.h:84
int getHDlossesOpt() const
Definition: HSParameters.h:20
std::vector< double > lamcurr
Definition: HDShower.h:84
double hcalDepthFactor
Definition: HDShower.h:124
const HSParameters * hsParameters() const
int getHDnDepthSteps() const
Definition: HSParameters.h:21
double lambdaHD
Definition: HDShower.h:77
int onEcal
Definition: HDShower.h:95
std::vector< double > x0depth
Definition: HDShower.h:83
HDShowerParametrization * theParam
Definition: HDShower.h:66
int mip
Definition: HDShower.h:98
int nDepthSteps
Definition: HDShower.h:106
double aloge
Definition: HDShower.h:79
double getHDdepthStep() const
Definition: HSParameters.h:25
double tgamHD
Definition: HDShower.h:74
double alpEM
Definition: HDShower.h:74
double radLenIncm() const
Radiation length in cm.
double getHDbalanceEH() const
Definition: HSParameters.h:28
double transParam
Definition: HDShower.h:110
double ecalHcalGapTotalX0() const
ECAL-HCAL transition.
Definition: EcalHitMaker.h:74
part
Definition: HCALResponse.h:21
double alpHD
Definition: HDShower.h:74
double depthStep
Definition: HDShower.h:116
HcalHitMaker * theHcalHitMaker
Definition: HDShower.h:92
std::vector< int > detector
Definition: HDShower.h:81
double transFactor
Definition: HDShower.h:112
double flatShoot(double xmin=0.0, double xmax=1.0) const
Definition: RandomEngine.h:30
std::vector< double > lamtotal
Definition: HDShower.h:84
const RandomEngine * random
Definition: HDShower.h:127
int lossesOpt
Definition: HDShower.h:104
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:101
double getHDtransParam() const
Definition: HSParameters.h:23
const HCALProperties * theHCALproperties
Definition: HDShower.h:70
double lambdaEM
Definition: HDShower.h:77
#define debug
Definition: MEtoEDMFormat.h:34
double ecalTotalL0() const
in the ECAL
Definition: EcalHitMaker.h:89
void makeSteps(int nsteps)
Definition: HDShower.cc:359
double tgamEM
Definition: HDShower.h:74
double ecalHcalGapTotalL0() const
ECAL-HCAL transition.
Definition: EcalHitMaker.h:95
double x0HD
Definition: HDShower.h:77
double interactionLength() const
Interaction length in cm: 18.5 for Standard ECAL.
double hcalTotalL0() const
in the HCAL
Definition: EcalHitMaker.h:92
virtual HDShower::~HDShower ( )
inlinevirtual

Definition at line 43 of file HDShower.h.

43 {;}

Member Function Documentation

bool HDShower::compute ( )

Compute the shower longitudinal and lateral development.

Definition at line 471 of file HDShower.cc.

References HcalHitMaker::addHit(), EcalHitMaker::addHit(), prof2calltree::count, gather_cfg::cout, debug, detector, patCandidatesForDimuonsSequences_cff::ecal, eStep, RandomEngine::flatShoot(), EcalHitMaker::getPads(), hcalDepthFactor, i, getHLTprescales::index, indexFinder(), EcalCondDB::inf, infinity, j, lamstep, lamtotal, LogDebug, 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().

471  {
472 
473  // TimeMe theT("FamosHDShower::compute");
474 
475  bool status = false;
476  int numLongit = eStep.size();
477  if(debug)
478  LogDebug("FastCalorimetry") << " FamosHDShower::compute - "
479  << " N_long.steps required : " << numLongit << std::endl;
480 
481  if(numLongit > 0) {
482 
483  status = true;
484  // Prepare the trsanverse probability function
485  std::vector<double> Fhist;
486  std::vector<double> rhist;
487  for (int j = 0; j < nTRsteps + 1; j++) {
488  rhist.push_back(maxTRfactor * j / nTRsteps );
489  Fhist.push_back(transProb(maxTRfactor,1.,rhist[j]));
490  if(debug == 3)
491  LogDebug("FastCalorimetry") << "indexFinder - i, Fhist[i] = " << j << " " << Fhist[j] << std::endl;
492  }
493 
494  // Longitudinal steps
495  for (int i = 0; i < numLongit ; i++) {
496 
497  double currentDepthL0 = lamtotal[i] - 0.5 * lamstep[i];
498  // vary the longitudinal profile if needed
499  if(detector[i] != 1) currentDepthL0 *= hcalDepthFactor;
500  if(debug)
501  LogDebug("FastCalorimetry") << " FamosHDShower::compute - detector = "
502  << detector[i]
503  << " currentDepthL0 = "
504  << currentDepthL0 << std::endl;
505 
506  double maxTRsize = maxTRfactor * rlamStep[i]; // in lambda units
507  double rbinsize = maxTRsize / nTRsteps;
508  double espot = eStep[i] / (double)nspots[i]; // re-adjust espot
509 
510  if(espot > 2. || espot < 0. )
511  LogDebug("FastCalorimetry") << " FamosHDShower::compute - unphysical espot = "
512  << espot << std::endl;
513 
514  int ecal = 0;
515  if(detector[i] != 1) {
516  bool setHDdepth = theHcalHitMaker->setDepth(currentDepthL0);
517 
518  if(debug)
519  LogDebug("FastCalorimetry") << " FamosHDShower::compute - status of "
520  << " theHcalHitMaker->setDepth(currentDepthL0) is "
521  << setHDdepth << std::endl;
522 
523  if(!setHDdepth)
524  {
525  currentDepthL0 -= lamstep[i];
526  setHDdepth = theHcalHitMaker->setDepth(currentDepthL0);
527  }
528  if(!setHDdepth) continue;
529 
531  }
532  else {
533  ecal = 1;
534  bool status = theGrid->getPads(currentDepthL0);
535 
536  if(debug)
537  LogDebug("FastCalorimetry") << " FamosHDShower::compute - status of Grid = "
538  << status << std::endl;
539 
540  if(!status) continue;
541 
542  int ntry = nspots[i] * 10;
543  if( ntry >= infinity ) { // use max allowed in case of too many spots
544  nspots[i] = 0.5 * infinity;
545  espot *= 0.1 * (double)ntry / double(nspots[i]);
546  }
547  else {
548  espot *= 0.1; // fine-grain energy spots in ECAL
549  // to avoid false ECAL clustering
550  nspots[i] = ntry;
551  }
552 
553 
554  theGrid->setSpotEnergy(espot);
555  }
556 
557 
558  // Transverse distribition
559  int nok = 0; // counter of OK
560  int count = 0;
561  int inf = infinity;
562  if(lossesOpt) inf = nspots[i]; // if losses are enabled, otherwise
563  // only OK points are counted ...
564  if(nspots[i] > inf ){
565  std::cout << " FamosHDShower::compute - at long.step " << i
566  << " too many spots required : " << nspots[i] << " !!! "
567  << std::endl;
568  }
569 
570  for (int j = 0; j < inf; j++) {
571  if(nok == nspots[i]) break;
572  count ++;
573 
574  double prob = random->flatShoot();
575  int index = indexFinder(prob,Fhist);
576  double radius = rlamStep[i] * rhist[index] +
577  random->flatShoot() * rbinsize; // in-bin
578  double phi = 2.*M_PI*random->flatShoot();
579 
580  if(debug == 2)
581  LogDebug("FastCalorimetry") << std::endl << " FamosHDShower::compute " << " r = " << radius
582  << " phi = " << phi << std::endl;
583 
584  bool result;
585  if(ecal) {
586  result = theGrid->addHit(radius,phi,0);
587 
588  if(debug == 2)
589  LogDebug("FastCalorimetry") << " FamosHDShower::compute - "
590  << " theGrid->addHit result = "
591  << result << std::endl;
592  }
593  else {
594  result = theHcalHitMaker->addHit(radius,phi,0);
595 
596  if(debug == 2)
597  LogDebug("FastCalorimetry") << " FamosHDShower::compute - "
598  << " theHcalHitMaker->addHit result = "
599  << result << std::endl;
600  }
601  if(result) nok ++;
602 
603  } // end of tranverse simulation
604  if(count == infinity) {
605  if(debug)
606  LogDebug("FastCalorimetry")
607  << " FamosHDShower::compute " << " maximum number of"
608  << " transverse points " << count << " is used !!!" << std::endl;
609  }
610 
611  if(debug)
612  LogDebug("FastCalorimetry")
613  << " FamosHDShower::compute " << " long.step No." << i
614  << " Ntry, Nok = " << count
615  << " " << nok << std::endl;
616 
617  } // end of longitudinal steps
618  } // end of no steps
619 
620  return status;
621 
622 }
#define LogDebug(id)
void setSpotEnergy(double e)
Set the spot energy.
Definition: HcalHitMaker.h:28
int i
Definition: DBlmapReader.cc:9
EcalHitMaker * theGrid
Definition: HDShower.h:89
bool addHit(double r, double phi, unsigned layer=0)
void setSpotEnergy(double e)
Definition: EcalHitMaker.h:117
double maxTRfactor
Definition: HDShower.h:120
std::vector< double > lamstep
Definition: HDShower.h:84
int nTRsteps
Definition: HDShower.h:108
double hcalDepthFactor
Definition: HDShower.h:124
tuple result
Definition: query.py:137
string inf
Definition: EcalCondDB.py:94
double transProb(double factor, double R, double r)
Definition: HDShower.h:56
int j
Definition: DBlmapReader.cc:9
int infinity
Definition: HDShower.h:86
#define M_PI
Definition: BFit3D.cc:3
std::vector< int > nspots
Definition: HDShower.h:81
HcalHitMaker * theHcalHitMaker
Definition: HDShower.h:92
std::vector< int > detector
Definition: HDShower.h:81
double flatShoot(double xmin=0.0, double xmax=1.0) const
Definition: RandomEngine.h:30
std::vector< double > lamtotal
Definition: HDShower.h:84
bool getPads(double depth, bool inCm=false)
const RandomEngine * random
Definition: HDShower.h:127
int lossesOpt
Definition: HDShower.h:104
tuple cout
Definition: gather_cfg.py:121
std::vector< double > eStep
Definition: HDShower.h:82
int indexFinder(double x, const std::vector< double > &Fhist)
Definition: HDShower.cc:624
tuple status
Definition: ntuplemaker.py:245
std::vector< double > rlamStep
Definition: HDShower.h:82
#define debug
Definition: MEtoEDMFormat.h:34
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
Definition: DDAxes.h:10
double HDShower::gam ( double  x,
double  a 
) const
inlineprivate

Definition at line 51 of file HDShower.h.

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

Referenced by makeSteps().

51 { return pow(x,a-1.)*exp(-x); }
double a
Definition: hdecay.h:121
Definition: DDAxes.h:10
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
int HDShower::getmip ( )
inline

Definition at line 41 of file HDShower.h.

References mip.

Referenced by CalorimetryManager::HDShowerSimulation().

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

Definition at line 624 of file HDShower.cc.

References debug, LogDebug, findQualityFiles::size, and launcher::step.

Referenced by compute().

624  {
625  // binary search in the vector of doubles
626  int size = Fhist.size();
627 
628  int curr = size / 2;
629  int step = size / 4;
630  int iter;
631  int prevdir = 0;
632  int actudir = 0;
633 
634  for (iter = 0; iter < size ; iter++) {
635 
636  if( curr >= size || curr < 1 )
637  LogWarning("FastCalorimetry") << " FamosHDShower::indexFinder - wrong current index = "
638  << curr << " !!!" << std::endl;
639 
640  if ((x <= Fhist[curr]) && (x > Fhist[curr-1])) break;
641  prevdir = actudir;
642  if(x > Fhist[curr]) {actudir = 1;}
643  else {actudir = -1;}
644  if(prevdir * actudir < 0) { if(step > 1) step /= 2;}
645  curr += actudir * step;
646  if(curr > size) curr = size;
647  else { if(curr < 1) {curr = 1;}}
648 
649  if(debug == 3)
650  LogDebug("FastCalorimetry") << " indexFinder - end of iter." << iter
651  << " curr, F[curr-1], F[curr] = "
652  << curr << " " << Fhist[curr-1] << " " << Fhist[curr] << std::endl;
653 
654  }
655 
656  if(debug == 3)
657  LogDebug("FastCalorimetry") << " indexFinder x = " << x << " found index = " << curr-1
658  << std::endl;
659 
660 
661  return curr-1;
662 }
#define LogDebug(id)
list step
Definition: launcher.py:15
Definition: DDAxes.h:10
#define debug
Definition: MEtoEDMFormat.h:34
tuple size
Write out results.
void HDShower::makeSteps ( int  nsteps)
private

Definition at line 359 of file HDShower.cc.

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

Referenced by HDShower().

359  {
360 
361  double sumes = 0.;
362  double sum = 0.;
363  std::vector<double> temp;
364 
365 
366  if(debug)
367  LogDebug("FastCalorimetry") << " FamosHDShower::makeSteps - "
368  << " nsteps required : " << nsteps << std::endl;
369 
370  int count = 0;
371  for (int i = 0; i < nsteps; i++) {
372 
373  double deplam = lamdepth[i] - 0.5 * lamstep[i];
374  double depx0 = x0depth[i] - 0.5 * lamstep[i] / x0curr[i];
375  double x = betEM * depx0;
376  double y = betHD * deplam;
377 
378  if(debug == 2)
379  LogDebug("FastCalorimetry") << " FamosHDShower::makeSteps "
380  << " - step " << i
381  << " depx0, x = " << depx0 << ", " << x
382  << " deplam, y = " << deplam << ", "
383  << y << std::endl;
384 
385  double est = (part * betEM * gam(x,alpEM) * lamcurr[i] /
386  (x0curr[i] * tgamEM) +
387  (1.-part) * betHD * gam(y,alpHD) / tgamHD) * lamstep[i];
388 
389  // protection ...
390  if(est < 0.) {
391  LogDebug("FastCalorimetry") << "*** FamosHDShower::makeSteps " << " - negative step energy !!!"
392  << std::endl;
393  est = 0.;
394  break ;
395  }
396 
397  // for estimates only
398  sum += est;
399  int nPest = (int) (est * e / sum / eSpotSize) ;
400 
401  if(debug == 2)
402  LogDebug("FastCalorimetry") << " FamosHDShower::makeSteps - nPoints estimate = "
403  << nPest << std::endl;
404 
405  if(nPest <= 1 && count !=0 ) break;
406 
407  // good step - to proceed
408 
409  temp.push_back(est);
410  sumes += est;
411 
412  rlamStep.push_back(transParam * (theR1 + (theR2 - theR3 * aloge))
413  * deplam * transFactor);
414  count ++;
415  }
416 
417  // fluctuations in ECAL and re-distribution of remaining energy in HCAL
418  if(detector[0] == 1 && count > 1) {
419  double oldECALenergy = temp[0];
420  double oldHCALenergy = sumes - oldECALenergy ;
421  double newECALenergy = 2. * sumes;
422  for (int i = 0; newECALenergy > sumes && i < infinity; i++)
423  newECALenergy = 2.* balanceEH * random->flatShoot() * oldECALenergy;
424 
425  if(debug == 2)
426  LogDebug("FastCalorimetry") << "*** FamosHDShower::makeSteps " << " ECAL fraction : old/new - "
427  << oldECALenergy/sumes << "/" << newECALenergy/sumes << std::endl;
428 
429  temp[0] = newECALenergy;
430  double newHCALenergy = sumes - newECALenergy;
431  double newHCALreweight = newHCALenergy / oldHCALenergy;
432 
433  for (int i = 1; i < count; i++) {
434  temp[i] *= newHCALreweight;
435  }
436 
437  }
438 
439 
440  // final re-normalization of the energy fractions
441  for (int i = 0; i < count ; i++) {
442  eStep.push_back(temp[i] * e / sumes );
443  nspots.push_back((int)(eStep[i]/eSpotSize)+1);
444 
445  if(debug)
446  LogDebug("FastCalorimetry")
447  << " step " << i
448  << " det: " << detector[i]
449  << " xO and lamdepth at the end of step = "
450  << x0depth[i] << " "
451  << lamdepth[i] << " Estep func = " << eStep[i]
452  << " Rstep = " << rlamStep[i] << " Nspots = " << nspots[i]
453  << " espot = " << eStep[i] / (double)nspots[i]
454  << std::endl;
455 
456  }
457 
458 
459  // The only step is in ECAL - let's make the size bigger ...
460  if(count == 1 and detector[0] == 1) rlamStep[0] *= 2.;
461 
462 
463  if(debug) {
464  if(eStep[0] > 0.95 * e && detector[0] == 1)
465  LogDebug("FastCalorimetry") << " FamosHDShower::makeSteps - " << "ECAL energy = " << eStep[0]
466  << " out of total = " << e << std::endl;
467  }
468 
469 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
double balanceEH
Definition: HDShower.h:122
double eSpotSize
Definition: HDShower.h:114
double betEM
Definition: HDShower.h:74
std::vector< double > lamstep
Definition: HDShower.h:84
double theR3
Definition: HDShower.h:73
std::vector< double > x0curr
Definition: HDShower.h:83
double betHD
Definition: HDShower.h:74
double theR1
Definition: HDShower.h:73
double theR2
Definition: HDShower.h:73
std::vector< double > lamdepth
Definition: HDShower.h:84
std::vector< double > lamcurr
Definition: HDShower.h:84
double gam(double x, double a) const
Definition: HDShower.h:51
std::vector< double > x0depth
Definition: HDShower.h:83
int infinity
Definition: HDShower.h:86
double aloge
Definition: HDShower.h:79
double tgamHD
Definition: HDShower.h:74
double alpEM
Definition: HDShower.h:74
double transParam
Definition: HDShower.h:110
std::vector< int > nspots
Definition: HDShower.h:81
part
Definition: HCALResponse.h:21
double alpHD
Definition: HDShower.h:74
std::vector< int > detector
Definition: HDShower.h:81
double transFactor
Definition: HDShower.h:112
double flatShoot(double xmin=0.0, double xmax=1.0) const
Definition: RandomEngine.h:30
const RandomEngine * random
Definition: HDShower.h:127
double e
Definition: HDShower.h:101
std::vector< double > eStep
Definition: HDShower.h:82
Definition: DDAxes.h:10
std::vector< double > rlamStep
Definition: HDShower.h:82
#define debug
Definition: MEtoEDMFormat.h:34
double tgamEM
Definition: HDShower.h:74
double HDShower::transProb ( double  factor,
double  R,
double  r 
)
inlineprivate

Definition at line 56 of file HDShower.h.

References dttmaxenums::R.

Referenced by compute().

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

Member Data Documentation

double HDShower::aloge
private

Definition at line 79 of file HDShower.h.

Referenced by HDShower(), and makeSteps().

double HDShower::alpEM
private

Definition at line 74 of file HDShower.h.

Referenced by HDShower(), and makeSteps().

double HDShower::alpHD
private

Definition at line 74 of file HDShower.h.

Referenced by HDShower(), and makeSteps().

double HDShower::balanceEH
private

Definition at line 122 of file HDShower.h.

Referenced by HDShower(), and makeSteps().

double HDShower::betEM
private

Definition at line 74 of file HDShower.h.

Referenced by HDShower(), and makeSteps().

double HDShower::betHD
private

Definition at line 74 of file HDShower.h.

Referenced by HDShower(), and makeSteps().

double HDShower::criticalEnergy
private

Definition at line 118 of file HDShower.h.

Referenced by HDShower().

double HDShower::depthStart
private

Definition at line 78 of file HDShower.h.

Referenced by HDShower().

double HDShower::depthStep
private

Definition at line 116 of file HDShower.h.

Referenced by HDShower().

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

Definition at line 81 of file HDShower.h.

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

double HDShower::e
private

Definition at line 101 of file HDShower.h.

Referenced by HDShower(), and makeSteps().

double HDShower::eSpotSize
private

Definition at line 114 of file HDShower.h.

Referenced by HDShower(), and makeSteps().

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

Definition at line 82 of file HDShower.h.

Referenced by compute(), and makeSteps().

double HDShower::hcalDepthFactor
private

Definition at line 124 of file HDShower.h.

Referenced by compute(), and HDShower().

int HDShower::infinity
private

Definition at line 86 of file HDShower.h.

Referenced by compute(), and makeSteps().

double HDShower::lambdaEM
private

Definition at line 77 of file HDShower.h.

Referenced by HDShower().

double HDShower::lambdaHD
private

Definition at line 77 of file HDShower.h.

Referenced by HDShower().

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

Definition at line 84 of file HDShower.h.

Referenced by HDShower(), and makeSteps().

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

Definition at line 84 of file HDShower.h.

Referenced by HDShower(), and makeSteps().

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

Definition at line 84 of file HDShower.h.

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

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

Definition at line 84 of file HDShower.h.

Referenced by compute(), and HDShower().

int HDShower::lossesOpt
private

Definition at line 104 of file HDShower.h.

Referenced by compute(), and HDShower().

double HDShower::maxTRfactor
private

Definition at line 120 of file HDShower.h.

Referenced by compute(), and HDShower().

int HDShower::mip
private

Definition at line 98 of file HDShower.h.

Referenced by getmip(), and HDShower().

int HDShower::nDepthSteps
private

Definition at line 106 of file HDShower.h.

Referenced by HDShower().

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

Definition at line 81 of file HDShower.h.

Referenced by compute(), and makeSteps().

int HDShower::nTRsteps
private

Definition at line 108 of file HDShower.h.

Referenced by compute(), and HDShower().

int HDShower::onEcal
private

Definition at line 95 of file HDShower.h.

Referenced by HDShower().

double HDShower::part
private

Definition at line 74 of file HDShower.h.

const RandomEngine* HDShower::random
private

Definition at line 127 of file HDShower.h.

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

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

Definition at line 82 of file HDShower.h.

Referenced by compute(), and makeSteps().

double HDShower::tgamEM
private

Definition at line 74 of file HDShower.h.

Referenced by HDShower(), and makeSteps().

double HDShower::tgamHD
private

Definition at line 74 of file HDShower.h.

Referenced by HDShower(), and makeSteps().

const ECALProperties* HDShower::theECALproperties
private

Definition at line 69 of file HDShower.h.

Referenced by HDShower().

EcalHitMaker* HDShower::theGrid
private

Definition at line 89 of file HDShower.h.

Referenced by compute(), and HDShower().

HcalHitMaker* HDShower::theHcalHitMaker
private

Definition at line 92 of file HDShower.h.

Referenced by compute().

const HCALProperties* HDShower::theHCALproperties
private

Definition at line 70 of file HDShower.h.

Referenced by HDShower().

HDShowerParametrization* HDShower::theParam
private

Definition at line 66 of file HDShower.h.

Referenced by HDShower().

double HDShower::theR1
private

Definition at line 73 of file HDShower.h.

Referenced by HDShower(), and makeSteps().

double HDShower::theR2
private

Definition at line 73 of file HDShower.h.

Referenced by HDShower(), and makeSteps().

double HDShower::theR3
private

Definition at line 73 of file HDShower.h.

Referenced by HDShower(), and makeSteps().

double HDShower::transFactor
private

Definition at line 112 of file HDShower.h.

Referenced by HDShower(), and makeSteps().

double HDShower::transParam
private

Definition at line 110 of file HDShower.h.

Referenced by HDShower(), and makeSteps().

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

Definition at line 83 of file HDShower.h.

Referenced by HDShower(), and makeSteps().

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

Definition at line 83 of file HDShower.h.

Referenced by HDShower(), and makeSteps().

double HDShower::x0EM
private

Definition at line 77 of file HDShower.h.

Referenced by HDShower().

double HDShower::x0HD
private

Definition at line 77 of file HDShower.h.

Referenced by HDShower().