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

SNEmEcalEc1.cxx

Go to the documentation of this file.
00001 // ================================================
00002 // Implementation of SNEmEcalEc1
00003 // ================================================
00004 
00005 #include "FastShowerUtils/Samplers/SNEmEcalEc1.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/SplitDecision.h"
00015 #include "FastShowerUtils/IConfigurer.h"
00016 #include "CLHEP/Random/RandFlat.h"
00017 #include <cmath>
00018 #include <algorithm>
00019 #include <iostream>
00020 
00021 namespace FastShower{
00022 
00023   using std::pair;
00024   
00025   const double SNEmEcalEc1::s_nSigma(3.0);
00027   SNEmEcalEc1::SNEmEcalEc1(IUpdatingGaussian* g,
00028                            IProcessedDist* f,
00029                            IInTail* it):
00030     ISampler(), ICellSN(), DebugBase("SNEmEcalEc1"), 
00031     m_peak(g), m_tail(f), m_inTail(it){}
00033   SNEmEcalEc1::SNEmEcalEc1(const IConfigurer* configurer,
00034                            const std::string&):
00035     DebugBase("SN1"), m_peak(0), m_tail(0), m_inTail(0){
00036     m_peak           = configurer->findIUG( text()+"Peak" ) ;
00037     m_tail           = configurer->makeProcessedFlat( text() );
00038     m_inTail         = configurer->makeIInTail( text() );
00039     cout<<text()<<" finishing construction"<<endl;
00040   }
00042   ISampler* SNEmEcalEc1::clone() const {return new SNEmEcalEc1(*this);}
00044 
00045   void SNEmEcalEc1::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 SNEmEcalEc1::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 tails
00061     double uLimit = peakMean - s_nSigma*peakSigma;
00062     double lLimit = 0.0;
00063 
00064     double energy = pa.pp()->energy();
00065     double cell0  = pa.cs()->cell0();
00066 
00067     //find a better name for "limit" (see TailFracSNEmEcalEc1.cxx)
00068     double limit = 0.0; 
00069     if (energy<15.0) {limit = 0.45;}
00070     else if (energy<25.0) {limit = 0.40;}
00071 
00072     if (cell0 < limit) {
00073       double fracBin1 = 0.0;
00074       fracBin1 = (energy<10.0)?  0.35/(0.35+0.25) :  0.0;
00075       fracBin1 = (energy>=10.0 && energy<25.0)?  1.09 - 0.0507*energy :  0.0;
00076       fracBin1 = max(fracBin1, 0.0);
00077       fracBin1 = min(fracBin1, 1.0);
00078       SplitDecision inBin1(fracBin1);
00079       if (inBin1.lower()) {
00080         lLimit = 0.0;
00081         uLimit = 0.05;
00082       } else {
00083         lLimit = 0.05;
00084       }
00085     } else {
00086       if (energy<15.0) {
00087         lLimit = 0.50*peakMean;
00088       } else if (energy<30.0) {
00089         lLimit = 0.75*peakMean;
00090       } else {
00091         lLimit = 0.95*peakMean;
00092       }
00093     }
00094     //
00095     if(lLimit<0.){lLimit=0.;}
00096     //IMPROVEME - the logic of setting limits to be made clearer
00097     if(uLimit<0.){ uLimit=peakMean;}
00098     if(uLimit<=lLimit){ uLimit=peakMean;}
00099     //
00100     LinearProcessor lp( (uLimit-lLimit), lLimit );
00101     return m_tail->sample(&lp);
00102   }
00104   double SNEmEcalEc1::evalPeak(const PolyArgs& pa) const{
00105     pair<double, double>  peakParams = m_peak->parameters(pa);
00106     double peakMean  = peakParams.first;
00107     if (peakMean<=0.0) return 0.0;
00108     return m_peak->sample(0.0, s_nSigma, peakMean, s_nSigma, pa);
00109   }
00111   double SNEmEcalEc1::lastValue(const CoreSamples& cs) const {
00112     return cs.give(this);
00113   }
00115   void SNEmEcalEc1::components(IDebug::Cpts& v) const{
00116     v.push_back(m_peak);
00117     v.push_back(m_tail);
00118     v.push_back(m_inTail);
00119   }
00120 }//namespace

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