Calorimeter.cxx

Go to the documentation of this file.
00001 
00002 //                                                                      //
00003 // RMS  calorimeter class implementation.                               //
00004 //                                                                      //
00005 // HTP  put into namespace & a little tidying up                        //
00006 //                                                                      //
00007 // PS   radically changed.                                              //
00009 
00010 
00011 #include "AtlfastAlgs/Calorimeter.h"
00012 #include "AtlfastAlgs/ICellSelector.h"
00013 #include "AtlfastAlgs/CalSection.h"
00014 #include "AtlfastEvent/IKinematic.h"
00015 #include "AtlfastEvent/EPileupDeposit.h"
00016 #include "AtlfastAlgs/ISmearer.h"
00017 #include "AtlfastUtils/DeleteObject.h"
00018 #include "AtlfastUtils/CheckNull.h"
00019 #include "FastShowerUtils/GridletForger.h"
00020 #include "FastShowerUtils/Gridlet.h"
00021 #include "GaudiKernel/MsgStream.h"
00022 #include <cmath> 
00023 #include <vector>
00024 #include <iostream>
00025 
00026 
00027 namespace Atlfast {
00028   using std::abs;
00029   using FastShower::GridletForger;
00030   using FastShower::Gridlet;
00031   using FastShower::GridletElement;
00032 
00033   //____________________________________________________________________
00034   // create calorimeter as a number of CalSections
00035   Calorimeter::Calorimeter(
00036                            MsgStream& log,
00037                            bool  fastShower,
00038                            const double MaxEta,
00039                            const double barrelMaxEta, 
00040                            const double granBarrelEta,
00041                            const double granBarrelPhi,
00042                            const double granForwardEta,
00043                            const double granForwardPhi
00044                            ):m_log(log){ 
00045     
00046     m_section[0] =  new CalSection(log,
00047                                    abs(barrelMaxEta),  abs(MaxEta), 
00048                                    granForwardEta, granForwardPhi);
00049     
00050     m_section[1] =  new CalSection(log,
00051                                    -abs(barrelMaxEta), abs(barrelMaxEta), 
00052                                    granBarrelEta,  granBarrelPhi);
00053 
00054     m_section[2] =  new CalSection(log,
00055                                    -abs(MaxEta),       -abs(barrelMaxEta), 
00056                                    granForwardEta, granForwardPhi);
00057 
00058     if(fastShower) {
00059       m_gridletForger   = new GridletForger;
00060     }else{
00061       m_gridletForger   = 0;
00062     }
00063 
00064   }
00065   Calorimeter::~Calorimeter(){
00066     m_log<<MSG::DEBUG<<"Calorimeter destructor starts "<<endreq;
00067     delete m_section[0];
00068     delete m_section[1];
00069     delete m_section[2];
00070     delete m_gridletForger;
00071     m_log<<MSG::DEBUG<<"Calorimeter destructor ends "<<endreq;
00072   }
00073   Calorimeter::Calorimeter(const Calorimeter& c):m_log(c.m_log){
00074     //make m_sections point to different instances
00075     // of the CalSections, with the same value as those
00076     //owned by c.
00077     m_section[0]   = new CalSection(*(c.m_section[0]));
00078     m_section[1]   = new CalSection(*(c.m_section[1]));
00079     m_section[2]   = new CalSection(*(c.m_section[2]));
00080     m_gridletForger= new GridletForger(*(c.m_gridletForger));
00081   }
00082   //_____________________________________________________________________
00083   class Elements{
00084   public:
00085     typedef vector<const GridletElement*>    Vector;
00086     typedef Vector::iterator                   Iter;
00087     //    Elements():m_eElements(5000),m_hElements(5000){
00088     //    }
00089     ~Elements(){
00090       // do NOT delete the element vector pointees - they are used by the
00091       // clients!
00092     }
00093     void operator()(const Gridlet* g){
00094       std::vector<const GridletElement*> eEl = g->eElements();
00095       std::vector<const GridletElement*> hEl = g->hElements();
00096 
00097       m_eElements.insert(m_eElements.end(), eEl.begin(), eEl.end());
00098       m_hElements.insert(m_hElements.end(), hEl.begin(), hEl.end());
00099       //std::copy(eEl.begin(), eEl.end(), back_inserter(m_eElements));
00100       //std::copy(hEl.begin(), hEl.end(), back_inserter(m_hElements));
00101 
00102     }
00103     std::pair<Iter, Iter>  eIters(){
00104       return std::pair<Iter,Iter>(m_eElements.begin(),m_eElements.end());
00105     }
00106     std::pair<Iter, Iter> hIters(){
00107       return std::pair<Iter,Iter>(m_hElements.begin(), m_hElements.end());
00108     }
00109   private:
00110     Vector m_eElements;
00111     Vector m_hElements;
00112   };
00113   //_____________________________________________________________________
00114   void Calorimeter::addGridlet(Gridlet* g){m_gridlets.push_back(g);} 
00115   //_____________________________________________________________________
00116   void Calorimeter::deposit(ITransportedParticleCollectionIter& f, 
00117                             ITransportedParticleCollectionIter& l){
00118     
00119     ITransportedParticleCollectionIter divider = 
00120       std::partition(f, l, TryToShower(this));
00121 
00122     //    std::for_each(m_gridlets.begin(), m_gridlets.end(), CheckNull());
00123 
00124     // put all the elements from all gridlets into a containers    
00125     Elements els;
00126     els = std::for_each(m_gridlets.begin(), m_gridlets.end(), els);
00127     std::pair<Elements::Iter, Elements::Iter> ei = els.eIters();
00128     std::pair<Elements::Iter, Elements::Iter> hi = els.hIters();
00129     std::for_each(ei.first, ei.second, CheckNull());
00130     std::for_each(hi.first, hi.second, CheckNull());
00131 
00132     //    cerr<<"Calorimeter: no  of e elements "<<ei.second - ei.first<<endl;
00133     //    cerr<<"Calorimeter: no  of h elements "<<hi.second - hi.first<<endl;
00134 
00135     //Deposit Elements, generated particle energies for showered particles
00136     //(needed for calibration) and unshowered particles.
00137     for(int ind =0 ;ind<=2; ++ind){ 
00138       //      cerr<<"Calsection "<<ind<<endl;
00139       //      cerr<<" E deposits "<<endl;
00140       //      cerr<<" E deposits "<<endl;
00141       m_section[ind]->depositEcal(ei.first, ei.second);
00142       //      cerr<<" H deposits "<<endl;
00143       m_section[ind]->depositHcal(hi.first, hi.second);
00144 
00145       //need to make the iterators because the call is to references,
00146       //and so we need an object to reference. The following commented
00147       //out line does not work because there is nothing to reference!
00148       std::vector<const Gridlet*>::iterator b = m_gridlets.begin();
00149       std::vector<const Gridlet*>::iterator e = m_gridlets.end();
00150       //      cerr<<" Egen deposits "<<endl;
00151       m_section[ind]->depositEgen(b, e);
00152 
00153       //m_section[ind]->depositEgen(m_gridlets.begin(), m_gridlets.end());
00154       //      cerr<<" Particle deposits "<<endl;
00155       m_section[ind]->deposit(divider, l);
00156     }
00157     // the iterators have been messed around with , so get a fresh set before
00158     // deleting the elements
00159     ei = els.eIters();
00160     hi = els.hIters();
00161     std::for_each(ei.first, ei.second, DeleteObject());
00162     std::for_each(hi.first, hi.second, DeleteObject());
00163   }
00164   //_____________________________________________________________________
00165     // deposit energy pileup
00166   void 
00167   Calorimeter::deposit(std::vector<Atlfast::EPileupDeposit*>::iterator& f, 
00168                        std::vector<Atlfast::EPileupDeposit*>::iterator& l)
00169     const{
00170     //send energy pileup to calorimeter sections
00171     for(int ind =0 ;ind<=2; ++ind){
00172       m_section[ind]->deposit(f, l);
00173     }
00174 
00175     }
00176   //__________________________________________________________________
00177   const GridletForger*  Calorimeter::gridletForger() const {
00178     return m_gridletForger;
00179   }
00180   //__________________________________________________________________
00181   MsgStream&  Calorimeter::msgStream() const {return m_log;}
00182   //__________________________________________________________________
00183   void Calorimeter::giveHitCells(const ICellSelector* p_cellSelector, 
00184                                  ITwoCptCellCollection* cells)  {
00185     
00186     // return cells in calorimeter passed by cellSelector
00187     // could make type change from Calorimeter cells to TES cells here 
00188     
00189     for(int ind=0; ind<=2; ++ind) {
00190       m_section[ind]->giveHits(p_cellSelector, cells);
00191     }
00192   }
00193     
00194   //_______________________________________________________________________
00195   void Calorimeter::reset(){
00196 
00197     for(int ind=0; ind<=2; ++ind) {m_section[ind]->reset();}
00198 
00199     std::for_each(m_gridlets.begin(), m_gridlets.end(), DeleteObject());
00200     m_gridlets.clear();
00201 
00202   }
00203   //_______________________________________________________________________
00204   void Calorimeter::smearCells(ISmearer* p_smearer)
00205   {
00206     for(int ind=0; ind<=2; ++ind) {
00207       m_section[ind]->smearCells(p_smearer);
00208     }
00209   }
00210 } // end of namespace bracket
00211 
00212 
00213 
00214 
00215 
00216 
00217 
00218 
00219 
00220 
00221 
00222 
00223 
00224 
00225 
00226 

Generated on Mon Sep 24 14:19:11 2007 for AtlfastAlgs by  doxygen 1.5.1