00001
00002
00003
00004
00005 #include "FastShowerUtils/Samplers/SNEmEcalEc2.h"
00006
00007 #include "FastShowerUtils/ParticleParameters.h"
00008 #include "FastShowerUtils/PolyArgs.h"
00009 #include "FastShowerUtils/IFn.h"
00010 #include "FastShowerUtils/CoreSamples.h"
00011 #include "FastShowerUtils/LinearProcessor.h"
00012 #include "FastShowerUtils/IProcessedDist.h"
00013 #include "FastShowerUtils/IConfigurer.h"
00014 #include "FastShowerUtils/ProcessedNormal.h"
00015 #include "FastShowerUtils/IInTail.h"
00016 #include <cmath>
00017 #include <iostream>
00018
00019 namespace FastShower{
00020
00021 using std::pair;
00022
00023 const double SNEmEcalEc2::s_nSigma(3.0);
00025 SNEmEcalEc2::SNEmEcalEc2(IUpdatingGaussian* g,
00026 IProcessedDist* f,
00027 IInTail* it):
00028 ISampler(), ICellSN(), DebugBase("SNEmEcalEc2"),
00029 m_peak(g), m_tail(f), m_inTail(it){}
00031 SNEmEcalEc2::SNEmEcalEc2(const IConfigurer* configurer,
00032 const std::string&):
00033 DebugBase("SN2"), m_peak(0), m_tail(0), m_inTail(0){
00034 m_peak = configurer->findIUG( text()+"Peak" ) ;
00035 m_tail = configurer->makeProcessedFlat( text() );
00036 m_inTail = configurer->makeIInTail( text() );
00037 cout<<text()<<" finishing construction"<<endl;
00038 }
00040 ISampler* SNEmEcalEc2::clone() const {return new SNEmEcalEc2(*this);}
00042
00043 void SNEmEcalEc2::sample(const PolyArgs& pa, CoreSamples& cs) const{
00044
00045 if( m_inTail->operator()(pa) ){
00046 cs.fill(this, evalTail(pa) );
00047 }else{
00048 cs.fill(this, evalPeak(pa) );
00049 }
00050 }
00052 double SNEmEcalEc2::evalTail(const PolyArgs& pa) const{
00053
00054 pair<double, double> peakParams = m_peak->parameters(pa);
00055 double peakMean = peakParams.first;
00056 double peakSigma = peakParams.second;
00057
00058
00059 double uLimit = peakMean - s_nSigma*peakSigma;
00060
00061 double energy = pa.pp()->energy();
00062
00063 double lLimit = 0.0;
00064 if (energy<30.0){
00065 lLimit = 0.10*peakMean;
00066 }else if (energy<70.0){
00067 lLimit = 0.70*peakMean;
00068 }else{
00069 lLimit = 0.0;
00070 }
00071
00072 if(lLimit<0.){lLimit=0.;}
00073
00074 if(uLimit<0.){ uLimit=peakMean;}
00075 if(uLimit<=lLimit){ uLimit=peakMean;}
00076
00077 LinearProcessor lp( (uLimit-lLimit), lLimit );
00078 return m_tail->sample(&lp);
00079 }
00081 double SNEmEcalEc2::evalPeak(const PolyArgs& pa) const{
00082 pair<double, double> peakParams = m_peak->parameters(pa);
00083 double peakMean = peakParams.first;
00084 if (peakMean<=0.0) return 0.0;
00085 return m_peak->sample(0.0, s_nSigma, peakMean, s_nSigma, pa);
00086 }
00088 double SNEmEcalEc2::lastValue(const CoreSamples& cs) const {
00089 return cs.give(this);
00090 }
00092 void SNEmEcalEc2::components(IDebug::Cpts& v) const{
00093 v.push_back(m_peak);
00094 v.push_back(m_tail);
00095 v.push_back(m_inTail);
00096 }
00097 }