00001 #include "FastShowerUtils/Normalisers/HadLateHcalCoreFracEc.h"
00002
00003 #include "FastShowerUtils/ParticleParameters.h"
00004
00005 #include "CLHEP/Random/RandFlat.h"
00006
00007 #include <float.h>
00008 #include <algorithm>
00009 #include <cmath>
00010
00011 namespace FastShower{
00012
00013 double HadLateHcalCoreFracEc::value(const ParticleParameters& pp) const{
00014
00015 double energy = pp.energy();
00016
00017 double p1 = 469.7*std::exp(-0.9373*energy) + 0.8919;
00018 double p2 = 0.1815*std::exp(-0.1159*energy) + 0.03937;
00019 double p3 = 3.256*std::exp(-0.1970*energy) + 1.085;
00020 double p4 = -0.00003843*std::exp(0.1076*energy) + 0.003032;
00021
00022 double rndm = RandFlat::shoot();
00023
00024 double denominator = ( (rndm - p4) > FLT_EPSILON )? (rndm - p4) : FLT_EPSILON;
00025 double result = p1 - p2*std::log(p3/denominator - 1.0);
00026
00027 result = max(result, 0.01*energy);
00028
00029 return min(result, 1.0);
00030 }
00031
00032 IFnOfParticleParameters* HadLateHcalCoreFracEc::clone() const {
00033 return new HadLateHcalCoreFracEc(*this);
00034 }
00035 }