Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

C0EmEcalBar1.cxx

Go to the documentation of this file.
00001 // ================================================
00002 // Implementation of C0EmEcalBar1
00003 // ================================================
00004 
00005 #include "FastShowerUtils/Samplers/C0EmEcalBar1.h"
00006 
00007 #include "FastShowerUtils/ParticleParameters.h"
00008 #include "FastShowerUtils/PolyArgs.h"
00009 #include "FastShowerUtils/CoreSamples.h"
00010 #include "FastShowerUtils/IFn.h"
00011 #include "FastShowerUtils/LinearProcessor.h"
00012 #include "FastShowerUtils/UpdatingGaussian.h"
00013 #include "FastShowerUtils/ProcessedNormal.h"
00014 #include "FastShowerUtils/IInTail.h"
00015 #include "FastShowerUtils/SplitDecision.h"
00016 #include "FastShowerUtils/IConfigurer.h"
00017 #include <cmath>
00018 #include <iostream>
00019 
00020 namespace FastShower{
00021 
00022   using std::pair;
00023 
00024   const double C0EmEcalBar1::s_nSigma1(3.0);
00025   const double C0EmEcalBar1::s_nSigma2(5.0);
00026   const double C0EmEcalBar1::s_tailFluctScale(0.025);
00028   C0EmEcalBar1::C0EmEcalBar1(IUpdatingGaussian* g, 
00029                              IProcessedDist* t,
00030                              IInTail* inTail,
00031                              IFn* ts):
00032     ISampler(), ICell0(), DebugBase("C0EmEcalBar1"), 
00033     m_peak(g), m_tail(t), m_inTail(inTail), m_tailLowerBound(ts){}
00035   C0EmEcalBar1::C0EmEcalBar1(const IConfigurer* configurer,
00036                              const std::string&
00037                              ):
00038     DebugBase("C0"), m_peak(0), m_tail(0), m_inTail(0), m_tailLowerBound(0){
00039     m_peak           = configurer->findIUG( text()+"Peak" ) ;
00040     m_tail           = configurer->makeProcessedFlat( text() );
00041     m_inTail         = configurer->makeIInTail( text() );
00042     m_tailLowerBound = configurer->findFn( text()+"TailLowerBound");
00043     cout<<text()<<" finishing construction"<<endl;
00044   }
00046   ISampler* C0EmEcalBar1::clone() const {return new C0EmEcalBar1(*this);}
00048 
00049   void C0EmEcalBar1::sample(const PolyArgs& pa, CoreSamples& cs)const{
00050     
00051     if( m_inTail->operator()(pa) ){
00052       cs.fill(this, evalTail(pa) );
00053     }else{
00054       cs.fill(this, evalPeak(pa) );
00055     }
00056   }
00058   double C0EmEcalBar1::evalTail(const PolyArgs& pa) const {
00059 
00060     pair<double, double>  peakParams = m_peak->parameters(pa);
00061     double peakMean  = peakParams.first;
00062     double peakSigma = peakParams.second;
00063     //calculate ther upper and lower limits of the tails
00064     //
00065     // upper tail
00066     double energy = pa.pp()->energy();
00067     double uLimit2 = (energy<30.) ? 1.0 : peakMean + s_nSigma2*peakSigma;
00068     if(uLimit2>1.){ uLimit2=1.;}
00069     //
00070     double lLimit2 = peakMean + s_nSigma1*peakSigma;
00071     if(lLimit2>uLimit2){lLimit2 = uLimit2-peakSigma;}
00072     //
00073     // lower tail
00074     double uLimit1 = peakMean - s_nSigma1*peakSigma;
00075     //
00076     double lLimit1 = uLimit1 - ( m_tailLowerBound->value(pa) );
00077     //Add a little fluctuation in the lower base length
00078     ProcessedNormal temp;
00079     lLimit1 -= s_tailFluctScale*( abs( temp.sample() ) );
00080     if(lLimit1<0.){lLimit1=0.;}
00081     //
00082     if(uLimit1<0.){ uLimit1=peakMean;}
00083     
00084     double base1 = uLimit1-lLimit1;
00085     double base2 = uLimit2-lLimit2;
00086     double narrowBase;
00087     double narrowBaseStart;
00088     double wideBase;
00089     double wideBaseStart;
00090     
00091     if( base1>base2 ){
00092       wideBase = base1;
00093       wideBaseStart = lLimit1;
00094       narrowBase = base2;
00095       narrowBaseStart = lLimit2;
00096     }else{
00097       wideBase = base2;
00098       wideBaseStart = lLimit2;
00099       narrowBase = base1;
00100       narrowBaseStart = lLimit1;
00101     }   
00102     
00103     SplitDecision sp(narrowBase/wideBase);
00104     if ( sp.lower() ){
00105       LinearProcessor lp(narrowBase,narrowBaseStart);
00106       return m_tail->sample(&lp);
00107     }else{
00108       LinearProcessor lp(wideBase,wideBaseStart);
00109       return m_tail->sample(&lp);
00110     }
00111   }
00113   double C0EmEcalBar1::evalPeak(const PolyArgs& pa)const{
00114     return m_peak->sample(0.0,s_nSigma1,1.0,s_nSigma1,pa);
00115   }
00117   double C0EmEcalBar1::lastValue(const CoreSamples& cs) const {
00118     return cs.give(this);
00119   }
00121   void C0EmEcalBar1::components(IDebug::Cpts& v) const{
00122     v.push_back(m_peak);
00123     v.push_back(m_tail);
00124     v.push_back(m_inTail);
00125     v.push_back(m_tailLowerBound);
00126   }
00127  
00128 }//namespace
00129 
00130 
00131 
00132 
00133 
00134 
00135 

Generated on Tue Mar 18 11:49:55 2003 for FastShowerUtils by doxygen1.3-rc1