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

CoreDepositor.cxx

Go to the documentation of this file.
00001 #include "FastShowerUtils/CoreDepositor.h"
00002 #include "FastShowerUtils/ISampler.h"
00003 #include "FastShowerUtils/Deposits.h"
00004 #include "FastShowerUtils/ParticleParameters.h"
00005 #include "FastShowerUtils/PolyArgs.h"
00006 
00007 #include "FastShowerUtils/Normalisations.h"
00008 
00009 #include <boost/array.hpp>
00010 #include <algorithm>
00011 
00012 #include <pair.h>
00013 
00014 
00015 #include <iostream>
00016 #include <iomanip>
00017 #include <numeric>
00018 #include <assert.h>
00019 
00020 namespace FastShower{
00021   using boost::array;
00022   using std::pair;
00023   //
00025   //                                               //
00026   //Function objects used by STL algorithms        //
00027   //                                               //
00029   class ProxToGeom{
00031     public:
00032 
00033     ProxToGeom(CoreDepositor::ProxDepIter pdIter, IDeposits& deposits):
00034       m_proxIter(pdIter), m_deposits(deposits){}
00035     
00036     void operator()(std::pair<double, double> geom){
00037       m_deposits.accept(geom.first, geom.second, *m_proxIter++);
00038     }
00039     
00040   private:
00041     CoreDepositor::ProxDepIter m_proxIter;
00042     IDeposits& m_deposits;
00043   };
00044   
00046   
00047   class ApplyNorm{
00048   public:
00049     ApplyNorm(double norm):m_norm(norm){}
00050     void operator()(double& proxDep){ 
00051       proxDep *= m_norm;
00052     }
00053   private:
00054     double m_norm;
00055   };
00057   //                                               //
00058   //   Function objects used by STL algorithms     //
00059   //                                               //
00061 
00062 
00063   CoreDepositor::CoreDepositor(ISampler* s0,ISampler* c0,
00064                                ISampler* csn,ISampler* can):
00065     IDepositor(), DebugBase("CoreDepositor"){
00066     unsigned int it = 0;
00067     unsigned int end = m_samplers.size();
00068 
00069     m_samplers[it++]=s0;
00070     m_samplers[it++]=c0;
00071     m_samplers[it++]=csn;
00072     m_samplers[it++]=can;
00073     assert(it=end);
00074     
00075     m_proximityDeps.assign(0.); //eta and phi offsets wrt to cell 0 center
00076     array<pair<int, int>, 6> q0, q1, q2, q3;
00077     // 
00078     q0[sf]=pair<int, int>(  0, -1);
00079     q0[sc]=pair<int, int>(  0,  0);
00080     q0[sn]=pair<int, int>(  0,  1);
00081     q0[af]=pair<int, int>(  1, -1);
00082     q0[ac]=pair<int, int>(  1,  0);
00083     q0[an]=pair<int, int>(  1,  1);
00084     m_mappers[0]=q0;
00085     //
00086     q1[sf]=pair<int, int>(  0, -1);
00087     q1[sc]=pair<int, int>(  0,  0 );
00088     q1[sn]=pair<int, int>(  0,  1);
00089     q1[af]=pair<int, int>( -1, -1);
00090     q1[ac]=pair<int, int>( -1,  0 );
00091     q1[an]=pair<int, int>( -1,  1);
00092     m_mappers[1]=q1;
00093     //
00094     q2[sf]=pair<int, int>(  0,  1);
00095     q2[sc]=pair<int, int>(  0,  0 );
00096     q2[sn]=pair<int, int>(  0, -1);
00097     q2[af]=pair<int, int>( -1,  1);
00098     q2[ac]=pair<int, int>( -1,  0);
00099     q2[an]=pair<int, int>( -1, -1);
00100     m_mappers[2]=q2;
00101     //
00102     q3[sf]=pair<int, int>(  0,  1);
00103     q3[sc]=pair<int, int>(  0,  0);
00104     q3[sn]=pair<int, int>(  0, -1);
00105     q3[af]=pair<int, int>(  1,  1);
00106     q3[ac]=pair<int, int>(  1,  0);
00107     q3[an]=pair<int, int>(  1, -1);
00108     m_mappers[3]=q3;
00109 
00110   }
00111 
00112   //
00113   void CoreDepositor::deposit(const ParticleParameters& pp,
00114                               const Normalisations& ns,
00115                               IDeposits& geomDeposits){
00116     unsigned int ind = 0;
00117     unsigned int end = m_samplers.size();
00118     PolyArgs pa(pp, m_cs);
00119     
00120     // fill core samples
00121     for(; ind!=end; ++ind){
00122       m_samplers[ind]->sample(pa, m_cs);
00123     }
00124 
00125     // fill proximity map
00126     this->fillProximityDeps();
00127 
00128     //normalise core deposits
00129     std::for_each(m_proximityDeps.begin(),
00130           m_proximityDeps.end(),
00131           ApplyNorm(ns.core())
00132           );
00133 
00134     // proximity to geometry map
00135     std::for_each(
00136                   m_mappers[pp.quadrant()].begin(),
00137                   m_mappers[pp.quadrant()].end(),
00138                   ProxToGeom( m_proximityDeps.begin(), geomDeposits )
00139                   );
00140 
00141   }
00142 
00143   //
00144   void CoreDepositor::fillProximityDeps(){
00145     double sfF, acF, afF;
00146     sfF = 1.0 - m_cs.cell0() - m_cs.cellSN();
00147     assert(sfF>=0.0 && sfF<=1.0);
00148     if (sfF<=0.0) {
00149       afF = 0.0;
00150     } else {
00151       afF = (1.0 - m_cs.cellAN())/(1.0 + m_cs.cell0()/sfF);
00152     }
00153     assert(afF>=0.0 && afF<=1.0);
00154     if (m_cs.cell0()<=0.0) {
00155       acF = 0.0;
00156     } else {
00157       acF = (1.0 - m_cs.cellAN())/(1.0 + sfF/m_cs.cell0());
00158     }
00159     assert(acF>=0.0 && acF<=1.0);
00160 
00161     m_proximityDeps[sc] = m_cs.cell0()*m_cs.slice0();
00162     m_proximityDeps[sn] = m_cs.cellSN()*m_cs.slice0();
00163     m_proximityDeps[sf] = sfF*m_cs.slice0();
00164     m_proximityDeps[an] = m_cs.cellAN()*(1.0-m_cs.slice0());
00165     m_proximityDeps[af] = afF*(1.0-m_cs.slice0());
00166     m_proximityDeps[ac] = acF*(1.0-m_cs.slice0());
00167   }
00168 
00169   //
00170   IDepositor* CoreDepositor::clone() const {
00171     IDepositor* d = new CoreDepositor(*this);
00172     return d;
00173   }
00174 
00175   //
00176   void CoreDepositor::components(std::vector<const IDebug*>& v) const{
00177     v.clear();
00178     std::copy(m_samplers.begin(), m_samplers.end(), back_inserter(v));
00179   }
00180   
00181 }//namespace
00182 
00183 
00184 
00185 
00186 
00187 

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