00001 #include "FastShowerUtils/Normalisers/HadLateHcalCoreFracBar.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 HadLateHcalCoreFracBar::value(const ParticleParameters& pp) const{
00014
00015 double energy = pp.energy();
00016
00017 double p1 = -429.5318909*std::exp(-0.8211844*energy) + 1.1221508;
00018 double p2 = 0.0280945*std::exp(-0.0511857*energy) + 0.0376265;
00019 double p3 = -70.7056808*std::exp(-0.0866987*energy) + 31.9345112;
00020 double p4 = 0.0018101 + 0.0000344*energy;
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 return min(result, 1.0);
00028 }
00029
00030 IFnOfParticleParameters* HadLateHcalCoreFracBar::clone() const {
00031 return new HadLateHcalCoreFracBar(*this);
00032 }
00033 }