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

SNEmEcalBar2.cxx

Go to the documentation of this file.
00001 // ================================================
00002 // Implementation of SNEmEcalBar2
00003 // ================================================
00004 
00005 #include "FastShowerUtils/Samplers/SNEmEcalBar2.h"
00006 
00007 #include "FastShowerUtils/PolyArgs.h"
00008 #include "FastShowerUtils/IFn.h"
00009 #include "FastShowerUtils/CoreSamples.h"
00010 #include "FastShowerUtils/LinearProcessor.h"
00011 #include "FastShowerUtils/IProcessedDist.h"
00012 #include "FastShowerUtils/ProcessedNormal.h"
00013 #include "FastShowerUtils/IInTail.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 SNEmEcalBar2::s_nSigma(3.0);
00024   SNEmEcalBar2::SNEmEcalBar2(IUpdatingGaussian* g,
00025                              IProcessedDist* f,
00026                              IInTail* it,
00027                              IFn* tlb):
00028     ISampler(), ICellSN(), DebugBase("SNEmEcalBar2"), 
00029     m_peak(g), m_tail(f), m_inTail(it), m_tailLowerBound(tlb){}
00031   SNEmEcalBar2::SNEmEcalBar2(const IConfigurer* configurer,
00032                              const std::string&
00033                              ):
00034     DebugBase("SN2"), m_peak(0), m_tail(0), m_inTail(0), m_tailLowerBound(0){
00035     m_peak           = configurer->findIUG( text()+"Peak" ) ;
00036     m_tail           = configurer->makeProcessedFlat( text() );
00037     m_inTail         = configurer->makeIInTail( text() );
00038     m_tailLowerBound = configurer->findFn( text()+"TailLowerBound");
00039     cout<<text()<<" finishing construction"<<endl;
00040   }
00042   ISampler* SNEmEcalBar2::clone() const {return new SNEmEcalBar2(*this);}
00044 
00045   void SNEmEcalBar2::sample(const PolyArgs& pa, CoreSamples& cs) const{
00046     
00047     if( m_inTail->operator()(pa) ){
00048       cs.fill(this, evalTail(pa) );
00049     }else{
00050       cs.fill(this, evalPeak(pa) );
00051     }
00052   }
00054   double SNEmEcalBar2::evalTail(const PolyArgs& pa ) const{
00055 
00056     pair<double, double>  peakParams = m_peak->parameters(pa);
00057     double peakMean  = peakParams.first;
00058     double peakSigma = peakParams.second;
00059 
00060     //calculate the upper and lower limits of the tail
00061     double uLimit = peakMean - s_nSigma*peakSigma;
00062     //
00063     double lLimit = m_tailLowerBound->value(pa);
00064     //
00065     if(lLimit<0.){lLimit=0.;}
00066     //IMPROVEME - the logic of setting limits to be made clearer
00067     if(uLimit<0.){ uLimit=peakMean;}
00068     if(uLimit<=lLimit){ uLimit=peakMean;}
00069     //
00070     LinearProcessor lp( (uLimit- lLimit), lLimit );
00071     return m_tail->sample(&lp);
00072   }
00074   double SNEmEcalBar2::evalPeak(const PolyArgs& pa) const{
00075     pair<double, double>  peakParams = m_peak->parameters(pa);
00076     double peakMean  = peakParams.first;
00077     if (peakMean<=0.0) return 0.0;
00078     return m_peak->sample(0.0, s_nSigma, peakMean, s_nSigma, pa);
00079   }
00081   double SNEmEcalBar2::lastValue(const CoreSamples& cs) const {
00082     return cs.give(this);
00083   }
00085   void SNEmEcalBar2::components(IDebug::Cpts& v) const{
00086     v.push_back(m_peak);
00087     v.push_back(m_tail);
00088     v.push_back(m_inTail);
00089     v.push_back(m_tailLowerBound);
00090   }
00091 }//namespace

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