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

S0EmEcalBar1.cxx

Go to the documentation of this file.
00001 // ================================================
00002 // Implementation of S0EmEcalBar1
00003 // ================================================
00004 
00005 #include "FastShowerUtils/Samplers/S0EmEcalBar1.h"
00006 
00007 #include "FastShowerUtils/PolyArgs.h"
00008 #include "FastShowerUtils/IFn.h"
00009 #include "FastShowerUtils/CoreSamples.h"
00010 #include "FastShowerUtils/IProcessedDist.h"
00011 #include "FastShowerUtils/TriangleProcessor.h"
00012 #include "FastShowerUtils/ProcessedNormal.h"
00013 #include "FastShowerUtils/IInTail.h"
00014 #include "FastShowerUtils/UpdatingGaussian.h"
00015 #include "FastShowerUtils/IConfigurer.h"
00016 #include <cmath>
00017 #include <iostream>
00018 
00019 namespace FastShower{
00020 
00021   using std::pair;
00022 
00023   const double S0EmEcalBar1::s_nSigma(3.0);
00024   const double S0EmEcalBar1::s_tailFluctScale(0.05);
00025 
00027   S0EmEcalBar1::S0EmEcalBar1(IUpdatingGaussian* g, 
00028                              IProcessedDist* tail,
00029                              IInTail* it,
00030                              IFn* ts):
00031     ISampler(), ISlice0(), DebugBase("S0EmEcalBar1"), 
00032     m_peak(g), m_tail(tail), m_inTail(it), m_tailLowerBound(ts){}
00034   S0EmEcalBar1::S0EmEcalBar1(const IConfigurer* configurer,
00035                              const std::string&
00036                              ):
00037     DebugBase("S0"), m_peak(0), m_tail(0), m_inTail(0), m_tailLowerBound(0){
00038     m_peak           = configurer->findIUG( text()+"Peak" ) ;
00039     m_tail           = configurer->makeProcessedFlat( text() );
00040     m_inTail         = configurer->makeIInTail( text() );
00041     m_tailLowerBound = configurer->findFn( text()+"TailLowerBound");
00042     cout<<text()<<" finishing construction"<<endl;
00043   }
00045   ISampler* S0EmEcalBar1::clone() const {return new S0EmEcalBar1(*this);}
00047   void S0EmEcalBar1::sample(const PolyArgs& pa, CoreSamples& cs)const{
00048 
00049     if( m_inTail->operator()(pa) ){
00050       cs.fill(this, evalTail(pa) );
00051     }else{
00052       cs.fill(this, evalPeak(pa) );
00053     }
00054   }
00056   double S0EmEcalBar1::evalTail(const PolyArgs& pa) const {
00057     
00058     pair<double, double>  peakParams = m_peak->parameters(pa);
00059     double peakMean  = peakParams.first;
00060     double peakSigma = peakParams.second;
00061     
00062     //calculate ther upper and lower limits of the triangular tail
00063     double uLimit = peakMean - s_nSigma*peakSigma;
00064     //
00065     double lLimit = uLimit - ( m_tailLowerBound->value(pa) );
00066     //Add a little fluctuation in triangle base length
00067     ProcessedNormal normal;
00068     lLimit -= s_tailFluctScale*( abs( normal.sample() ) );
00069     if(lLimit<0.){lLimit=0.;}
00070     //
00071     //FIXME - the logic of setting limits to be made clearer
00072     if(uLimit<0.){ uLimit=peakMean;}
00073 
00074     // Sample from a Triangle dist.
00075     TriangleProcessor::EndPoint1  endPoint1 = lLimit;
00076     TriangleProcessor::EndPoint2  endPoint2 = uLimit;
00077     
00078     TriangleProcessor tp(endPoint1,endPoint2);
00079     return m_tail->sample(&tp);
00080   }
00082   double S0EmEcalBar1::evalPeak(const PolyArgs& pa)const{
00083     return m_peak->sample(0.0, s_nSigma, 1.0, s_nSigma, pa);
00084   }
00086   double S0EmEcalBar1::lastValue(const CoreSamples& cs) const {
00087     return cs.give(this);
00088   }
00090   void S0EmEcalBar1::components(IDebug::Cpts& v) const{
00091     v.push_back(m_peak);
00092     v.push_back(m_tail);
00093     v.push_back(m_inTail);
00094     v.push_back(m_tailLowerBound);
00095   }
00096   
00097 }//namespace
00098 
00099 
00100 
00101 
00102 
00103 
00104 

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