24 #define infinity 10000
38 theHcalHitMaker(myHcalHitMaker),
87 if(
e < emin) effective = emin;
93 if(effective > 0.5 * emax) {
95 if(effective > emax) {
106 LogDebug(
"FastCalorimetry") <<
" HDShower : " << std::endl
107 <<
" Energy " <<
e << std::endl
108 <<
" lossesOpt " <<
lossesOpt << std::endl
110 <<
" nTRsteps " <<
nTRsteps << std::endl
112 <<
" eSpotSize " <<
eSpotSize << std::endl
115 <<
" balanceEH " <<
balanceEH << std::endl
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;
158 alpEM = alpEM1 + alpEM2 * aedep;
160 betEM = betEM1 - betEM2 * aedep;
161 alpHD = alpHD1 + alpHD2 * aedep;
163 betHD = betHD1 - betHD2 * aedep;
164 part = part1 - part2 * aedep;
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;
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;
213 double depthECAL = 0.;
214 double depthGAP = 0.;
215 double depthGAPx0 = 0.;
223 double depthToHCAL = depthECAL + depthGAP;
229 double maxDepth = depthToHCAL + depthHCAL - 1.1 *
depthStep;
234 LogDebug(
"FastCalorimetry") <<
" FamosHDShower : e <emin -> depthStart = 0" << std::endl;
238 if(depthStart > maxDepth) {
239 if(
debug)
LogDebug(
"FastCalorimetry") <<
" FamosHDShower : depthStart too big ... = "
240 << depthStart << std::endl;
243 if( depthStart < 0.) depthStart = 0.;
244 if(
debug)
LogDebug(
"FastCalorimetry") <<
" FamosHDShower : depthStart re-calculated = "
245 << depthStart << std::endl;
248 if( onECAL &&
e < emid ) {
249 if(depthECAL >
depthStep && (depthECAL - depthStart)/depthECAL > 0.2) {
253 LogDebug(
"FastCalorimetry") <<
" FamosHDShower : small energy, "
254 <<
" depthStart reduced to = " << depthStart << std::endl;
260 if(
debug)
LogDebug(
"FastCalorimetry") <<
" FamosHDShower : depthHCAL too small ... = "
261 << depthHCAL <<
" depthStart -> forced to 0 !!!"
268 LogInfo(
"FastCalorimetry") <<
" FamosHDShower : too small ECAL and HCAL depths - "
269 <<
" particle is lost !!! " << std::endl;
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;
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"
297 lamstep.push_back(depthECAL-depthStart);
303 if(
debug)
LogDebug(
"FastCalorimetry") <<
" FamosHDShower : " <<
" in ECAL sum1, sum2 "
304 << sum1 <<
" " << sum2 << std::endl;
315 if(
debug)
LogDebug(
"FastCalorimetry") <<
" FamosHDShower : goto HCAL" << std::endl;
317 depthStart = depthToHCAL;
323 if(depthStart >= depthECAL && depthStart < depthToHCAL ) {
324 depthStart = depthToHCAL;
328 if(
debug)
LogDebug(
"FastCalorimetry") <<
" FamosHDShower : goto HCAL" << std::endl;
332 if(
debug)
LogDebug(
"FastCalorimetry") <<
" FamosHDShower : forward" << std::endl;
337 for (
int i = 0;
i < nmoresteps ;
i++) {
339 if (sum1 > (depthECAL + depthGAP + depthHCAL))
break;
363 std::vector<double>
temp;
367 LogDebug(
"FastCalorimetry") <<
" FamosHDShower::makeSteps - "
368 <<
" nsteps required : " << nsteps << std::endl;
371 for (
int i = 0;
i < nsteps;
i++) {
376 double y =
betHD * deplam;
379 LogDebug(
"FastCalorimetry") <<
" FamosHDShower::makeSteps "
381 <<
" depx0, x = " << depx0 <<
", " << x
382 <<
" deplam, y = " << deplam <<
", "
391 LogDebug(
"FastCalorimetry") <<
"*** FamosHDShower::makeSteps " <<
" - negative step energy !!!"
399 int nPest = (int) (est *
e / sum /
eSpotSize) ;
402 LogDebug(
"FastCalorimetry") <<
" FamosHDShower::makeSteps - nPoints estimate = "
403 << nPest << std::endl;
405 if(nPest <= 1 && count !=0 )
break;
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++)
426 LogDebug(
"FastCalorimetry") <<
"*** FamosHDShower::makeSteps " <<
" ECAL fraction : old/new - "
427 << oldECALenergy/sumes <<
"/" << newECALenergy/sumes << std::endl;
429 temp[0] = newECALenergy;
430 double newHCALenergy = sumes - newECALenergy;
431 double newHCALreweight = newHCALenergy / oldHCALenergy;
434 temp[
i] *= newHCALreweight;
442 eStep.push_back(temp[
i] *
e / sumes );
449 <<
" xO and lamdepth at the end of step = "
465 LogDebug(
"FastCalorimetry") <<
" FamosHDShower::makeSteps - " <<
"ECAL energy = " <<
eStep[0]
466 <<
" out of total = " <<
e << std::endl;
476 int numLongit =
eStep.size();
478 LogDebug(
"FastCalorimetry") <<
" FamosHDShower::compute - "
479 <<
" N_long.steps required : " << numLongit << std::endl;
485 std::vector<double> Fhist;
486 std::vector<double> rhist;
491 LogDebug(
"FastCalorimetry") <<
"indexFinder - i, Fhist[i] = " << j <<
" " << Fhist[
j] << std::endl;
495 for (
int i = 0;
i < numLongit ;
i++) {
501 LogDebug(
"FastCalorimetry") <<
" FamosHDShower::compute - detector = "
503 <<
" currentDepthL0 = "
504 << currentDepthL0 << std::endl;
507 double rbinsize = maxTRsize /
nTRsteps;
510 if(espot > 2. || espot < 0. )
511 LogDebug(
"FastCalorimetry") <<
" FamosHDShower::compute - unphysical espot = "
512 << espot << std::endl;
519 LogDebug(
"FastCalorimetry") <<
" FamosHDShower::compute - status of "
520 <<
" theHcalHitMaker->setDepth(currentDepthL0) is "
521 << setHDdepth << std::endl;
528 if(!setHDdepth)
continue;
537 LogDebug(
"FastCalorimetry") <<
" FamosHDShower::compute - status of Grid = "
538 << status << std::endl;
540 if(!status)
continue;
545 espot *= 0.1 * (double)ntry /
double(
nspots[
i]);
565 std::cout <<
" FamosHDShower::compute - at long.step " <<
i
566 <<
" too many spots required : " <<
nspots[
i] <<
" !!! "
570 for (
int j = 0;
j <
inf;
j++) {
581 LogDebug(
"FastCalorimetry") << std::endl <<
" FamosHDShower::compute " <<
" r = " << radius
582 <<
" phi = " << phi << std::endl;
589 LogDebug(
"FastCalorimetry") <<
" FamosHDShower::compute - "
590 <<
" theGrid->addHit result = "
591 << result << std::endl;
597 LogDebug(
"FastCalorimetry") <<
" FamosHDShower::compute - "
598 <<
" theHcalHitMaker->addHit result = "
599 << result << std::endl;
607 <<
" FamosHDShower::compute " <<
" maximum number of"
608 <<
" transverse points " << count <<
" is used !!!" << std::endl;
613 <<
" FamosHDShower::compute " <<
" long.step No." <<
i
614 <<
" Ntry, Nok = " << count
615 <<
" " << nok << std::endl;
626 int size = Fhist.size();
634 for (iter = 0; iter <
size ; iter++) {
636 if( curr >= size || curr < 1 )
637 LogWarning(
"FastCalorimetry") <<
" FamosHDShower::indexFinder - wrong current index = "
638 << curr <<
" !!!" << std::endl;
640 if ((x <= Fhist[curr]) && (x > Fhist[curr-1]))
break;
642 if(x > Fhist[curr]) {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;}}
650 LogDebug(
"FastCalorimetry") <<
" indexFinder - end of iter." << iter
651 <<
" curr, F[curr-1], F[curr] = "
652 << curr <<
" " << Fhist[curr-1] <<
" " << Fhist[curr] << std::endl;
657 LogDebug(
"FastCalorimetry") <<
" indexFinder x = " << x <<
" found index = " << curr-1
void setSpotEnergy(double e)
Set the spot energy.
bool addHit(double r, double phi, unsigned layer=0)
void setSpotEnergy(double e)
double radLenIncm() const
Radiation length in cm.
const ECALProperties * theECALproperties
int getHDnTRsteps() const
double getHDeSpotSize() const
std::vector< double > lamstep
bool compute()
Compute the shower longitudinal and lateral development.
std::vector< double > x0curr
double getHDhcalDepthFactor() const
double interactionLength() const
Interaction length in cm.
std::vector< double > lamdepth
int getHDlossesOpt() const
std::vector< double > lamcurr
const HSParameters * hsParameters() const
int getHDnDepthSteps() const
double gam(double x, double a) const
double transProb(double factor, double R, double r)
std::vector< double > x0depth
HDShowerParametrization * theParam
double getHDdepthStep() const
double radLenIncm() const
Radiation length in cm.
double getHDbalanceEH() const
HDShower(const RandomEngine *engine, HDShowerParametrization *myParam, EcalHitMaker *myGrid, HcalHitMaker *myHcalHitMaker, int onECAL, double epart)
Log< T >::type log(const T &t)
double ecalHcalGapTotalX0() const
ECAL-HCAL transition.
std::vector< int > nspots
HcalHitMaker * theHcalHitMaker
std::vector< int > detector
double flatShoot(double xmin=0.0, double xmax=1.0) const
std::vector< double > lamtotal
bool getPads(double depth, bool inCm=false)
const RandomEngine * random
const HCALProperties * hcalProperties() const
double getHDcriticalEnergy() const
const ECALProperties * ecalProperties() const
double getHDmaxTRfactor() const
double getHDtransParam() const
const HCALProperties * theHCALproperties
std::vector< double > eStep
int indexFinder(double x, const std::vector< double > &Fhist)
std::vector< double > rlamStep
double ecalTotalL0() const
in the ECAL
bool addHit(double r, double phi, unsigned layer=0)
add the hit in the HCAL in local coordinates
void makeSteps(int nsteps)
tuple size
Write out results.
bool setDepth(double, bool inCm=false)
set the depth in X0 or Lambda0 units depending on showerType
double ecalHcalGapTotalL0() const
ECAL-HCAL transition.
double interactionLength() const
Interaction length in cm.
double hcalTotalL0() const
in the HCAL