00001
00002
00003
00004
00005 #include "FastShowerUtils/Samplers/S0EmEcalEc1.h"
00006
00007 #include "FastShowerUtils/PolyArgs.h"
00008 #include "FastShowerUtils/IFn.h"
00009 #include "FastShowerUtils/CoreSamples.h"
00010 #include "FastShowerUtils/TriangleProcessor.h"
00011 #include "FastShowerUtils/ProcessedNormal.h"
00012 #include "FastShowerUtils/IInTail.h"
00013 #include "FastShowerUtils/SplitDecision.h"
00014 #include "FastShowerUtils/IConfigurer.h"
00015 #include <cmath>
00016 #include <iostream>
00017
00018 namespace FastShower{
00019
00020 using std::pair;
00021
00022 const double S0EmEcalEc1::s_nSigma(3.0);
00023 const double S0EmEcalEc1::s_tailFluctScale(0.05);
00024
00026 S0EmEcalEc1::S0EmEcalEc1(IUpdatingGaussian* g,
00027 IProcessedDist* t,
00028 IInTail* it,
00029 IFn* tlb):
00030 ISampler(), ISlice0(), DebugBase("S0EmEcalEc1"),
00031 m_peak(g), m_tail(t), m_inTail(it), m_tailLowerBound(tlb){}
00033 S0EmEcalEc1::S0EmEcalEc1(const IConfigurer* configurer,
00034 const std::string&):
00035 DebugBase("S0"), m_peak(0), m_tail(0), m_inTail(0), m_tailLowerBound(0){
00036 m_peak = configurer->findIUG( text()+"Peak" ) ;
00037 m_tail = configurer->makeProcessedFlat( text() );
00038 m_inTail = configurer->makeIInTail( text() );
00039 m_tailLowerBound = configurer->findFn( text()+"TailLowerBound");
00040 cout<<text()<<" finishing construction"<<endl;
00041 }
00043 ISampler* S0EmEcalEc1::clone() const {return new S0EmEcalEc1(*this);}
00045 void
00046 S0EmEcalEc1::sample(const PolyArgs& pa, CoreSamples& cs) const{
00047
00048 if( m_inTail->operator()(pa) ){
00049 cs.fill(this, evalTail(pa) );
00050 }else{
00051 cs.fill(this, evalPeak(pa) );
00052 }
00053 }
00055 double S0EmEcalEc1::evalTail(const PolyArgs& pa) const {
00056
00057 pair<double, double> peakParams = m_peak->parameters(pa);
00058 double peakMean = peakParams.first;
00059 double peakSigma = peakParams.second;
00060
00061
00062 double uLimit = peakMean - s_nSigma*peakSigma;
00063
00064 double lLimit = uLimit - ( m_tailLowerBound->value(pa) );
00065
00066 ProcessedNormal temp;
00067 lLimit -= s_tailFluctScale*( abs( temp.sample() ) );
00068 if(lLimit<0.){lLimit=0.;}
00069
00070
00071 if(uLimit<0.){ uLimit=peakMean;}
00072
00073
00074 TriangleProcessor::EndPoint1 endPoint1 = lLimit;
00075 TriangleProcessor::EndPoint2 endPoint2 = uLimit;
00076
00077 TriangleProcessor tp(endPoint1,endPoint2);
00078 return m_tail->sample(&tp);
00079 }
00081 double S0EmEcalEc1::evalPeak(const PolyArgs& pa)const{
00082 return m_peak->sample(0.0, s_nSigma, 1.0, s_nSigma, pa);
00083 }
00085 double S0EmEcalEc1::lastValue(const CoreSamples& cs) const {
00086 return cs.give(this);
00087 }
00088 void S0EmEcalEc1::components(IDebug::Cpts& v) const{
00089 v.push_back(m_peak);
00090 v.push_back(m_tail);
00091 v.push_back(m_inTail);
00092 v.push_back(m_tailLowerBound);
00093 }
00094
00095 }
00096
00097
00098
00099
00100
00101
00102
00103
00104