Report problems to ATLAS LXR Team (with time and IP address indicated)

The LXR Cross Referencer

source navigation ]
diff markup ]
identifier search ]
general search ]
 
 
Architecture: linux ]
Version: head ] [ nightly ] [ GaudiDev ]
  Links to LXR source navigation pages for stable releases [ 12.*.* ]   [ 13.*.* ]   [ 14.*.* ]   [ 15.*.* ] 

001 //////////////////////////////////////////////////////////////////////////
002 //                                                                      //
003 // PS   CalSection.                                                     //
004 // 00/09/06                                                             //
005 //                                                                      //
006 // build an array of cells spanning the eta and phi ranges passed in the//
007 // constructor. The granularities used are the closest to the requested //
008 // values, but which divide exactly into the requested ranges.          //
009 //                                                                      //
010 //                                                                      //
011 //                                                                      //
012 //                                                                      //
013 //                                                                      //
014 //////////////////////////////////////////////////////////////////////////
015 
016 
017 #include "AtlfastAlgs/CalSection.h"
018 #include "AtlfastAlgs/ICellSelector.h"
019 #include "AtlfastUtils/DeleteObject.h"
020 
021 #include "AtlfastUtils/ISmearer.h"
022 #include "AtlfastUtils/CellFactory.h"
023 
024 #include "AtlfastEvent/TwoCptCell.h"
025 #include "AtlfastEvent/ITransportedParticle.h"
026 
027 #include "FastShowerUtils/Gridlet.h"
028 
029 #include "CLHEP/Vector/LorentzVector.h"
030 #include "GaudiKernel/MsgStream.h"
031 #include <iostream>
032 #include <assert.h>
033 #include <algorithm>
034 
035 namespace Atlfast {
036   using FastShower::GridletElement;
037 
038 //____________________________________________________________________
039   CalSection::CalSection(
040                          MsgStream& log,
041                          double minEta,
042                          double maxEta,
043                          double granEta,
044                          double granPhi,
045                          std::string detEffectsFileName,
046                          double minPhi,
047                          double maxPhi
048                          ):
049     m_log(log),
050     m_minEta(minEta), m_maxEta(maxEta),
051     m_minPhi(minPhi), m_maxPhi(maxPhi),
052     m_calSectionReject(minEta, maxEta, minPhi, maxPhi){
053 
054     log <<MSG::DEBUG<< "Initialising CellFactory with detector effects file: '"<<detEffectsFileName<<"'"<<endreq;
055     CellFactory cf(detEffectsFileName,log);
056 
057     log <<MSG::DEBUG<< "CalSection: construction. Eta range: "
058         <<minEta<<" - "<<maxEta<<endreq; 
059     log <<MSG::DEBUG<< "                          Phi range: "
060         <<minPhi<<" - "<<maxPhi<<endreq; 
061     log <<MSG::DEBUG<< " starting granularity Eta: "<<granEta
062         << " phi: "<<granPhi
063         <<endreq;
064 
065     log <<MSG::DEBUG<<"CalSectionReject parameters:"<<endreq;
066     log <<MSG::DEBUG<<m_calSectionReject<<endreq;
067 
068     int nEta    = int(((maxEta-minEta)/granEta)+0.5);
069     m_granEta   = (maxEta-minEta)/int(nEta);
070     m_nPhi      = 1+int(((m_maxPhi-m_minPhi)/granPhi)+0.5);
071     m_granPhi   = (m_maxPhi-m_minPhi)/double(m_nPhi); 
072     log <<MSG::DEBUG<< " final granularity Eta: "<<m_granEta
073         << " phi: "<<m_granPhi
074         <<endreq; 
075     log <<MSG::DEBUG<< " final Bins in Eta: "<<nEta
076         << " phi: "<<m_nPhi
077         <<endreq; 
078 
079     for (int ieta=0; ieta<nEta; ieta++){
080       for (int iphi=0; iphi<m_nPhi; iphi++){
081         
082         double eta        = minEta+((double(ieta)+0.5)*double(m_granEta));
083         double phi        = m_minPhi + ((double(iphi)+0.5)*double(m_granPhi));
084         CellDescriptor id = CellDescriptor(eta,phi);
085         ITwoCptCell* cell = cf.makeCell(id);
086         
087         m_cells.push_back(cell);
088       }
089     }
090   }
091   CalSection::~CalSection(){
092     m_log<<MSG::DEBUG<<"CalSection destructor starts "<<endreq;
093     std::for_each(m_cells.begin(), m_cells.end(), DeleteObject());
094     m_log<<MSG::DEBUG<<"CalSection destructor ends "<<endreq;
095   }
096   CalSection::CalSection(const CalSection& c):
097     m_log(c.m_log),
098     m_minEta(c.m_minEta),
099     m_maxEta(c.m_maxEta),
100     m_minPhi(c.m_minPhi),
101     m_maxPhi(c.m_maxPhi),
102     m_granEta(c.m_granEta),
103     m_granPhi(c.m_granPhi),
104     m_nPhi(c.m_nPhi),
105     m_calSectionReject(c.m_calSectionReject){
106     std::vector<ITwoCptCell*>::const_iterator i=c.m_cells.begin();
107     for(;i<c.m_cells.end();++i) m_cells.push_back((*i)->cloneITCC());
108   }
109   //----------------------------------------------------------------
110   /**
111      * Takes the ITransportedParticle (transported through mag field)
112      * and deposits it within the calorimeter section.
113      */
114   void CalSection::deposit(ITransportedParticleCollectionIter& f, 
115                            ITransportedParticleCollectionIter& l){
116     // remove particles not in acceptance
117     ITransportedParticleCollectionIter divider;
118     divider = std::partition(f, l, m_calSectionReject);
119     
120     // fill cells 
121     for(ITransportedParticleCollectionCIter i=divider; i<l; ++i){newHit(*i);}
122 
123     // assume sections do not overlap: do not reprocess.
124     l=divider;
125   }
126   //----------------------------------------------------------------
127   /** a deposit method into Ecal comaprtment (used with FastShower) */
128   void 
129   CalSection::depositEcal(std::vector<const GridletElement*>::iterator& f, 
130                           std::vector<const GridletElement*>::iterator& l
131                           ){
132     //    cerr<<"Calsection depositEcal begin"<<endl;
133   
134     //    cerr<<"  no of elements on entry "<<l-f<<endl;
135     std::vector<const GridletElement*>::iterator divider;
136     divider = std::partition(f, l, m_calSectionReject);
137     //    cerr<<"Calsection depositEcal after partition"<<endl;
138   
139     std::vector<const GridletElement*>::iterator i;
140     for( i=divider; i<l; ++i){newEHit(*i);}
141     //    cerr<<"Calsection depositEcal after newhit call"<<endl;
142   
143 
144     // assume sections do not overlap: do not reprocess.
145     l=divider;
146     //    cerr<<"  no of elements on exit "<<l-f<<endl;
147     //    cerr<<"Calsection depositEcal end"<<endl;
148   }
149   //----------------------------------------------------------------
150   /** a deposit method into Hcal comaprtment (used with FastShower) */
151   void CalSection::depositHcal(std::vector<const GridletElement*>::iterator& f, 
152                                std::vector<const GridletElement*>::iterator& l
153                                ){
154     
155     std::vector<const GridletElement*>::iterator divider;
156     divider = std::partition(f, l, m_calSectionReject);
157   
158     std::vector<const GridletElement*>::iterator i;
159     for( i=divider; i<l; ++i){newHHit(*i);}
160 
161     // assume sections do not overlap: do not reprocess.
162     l=divider;
163   }
164   //----------------------------------------------------------------
165   /** set Generated Energy (used with FastShower) */
166   void CalSection::depositEgen(std::vector<const Gridlet*>::iterator& f, 
167                                std::vector<const Gridlet*>::iterator& l
168                                ){
169     std::vector<const Gridlet*>::iterator divider;
170     divider = std::partition(f, l, m_calSectionReject);
171     
172     
173     std::vector<const Gridlet*>::iterator i;
174     for( i=divider; i<l; ++i){setEgen(*i);}
175     
176     // assume sections do not overlap: do not reprocess.
177     l=divider;
178   }
179   
180   //----------------------------------------------------------------
181 /** Registers a new hit in the calorimeter section. */
182   void CalSection::newHit( const ITransportedParticle* tp){
183     //check cell is reasonable
184     const HepMC::GenParticle* particle = tp->particle();
185     //const double eta = particle->momentum().pseudoRapidity();
186     const double eta = tp->eta();
187     const double phi = tp->phi();
188     int ind = iindex(phi, eta);
189     ITwoCptCell* cell = m_cells[ind];
190     assert(std::abs( eta-(cell->eta()) ) <m_granEta);
191     assert(std::abs( phi-(cell->phi()) ) <m_granPhi);
192     cell->newHit(particle);
193     //use a map to store pointers to hit cells to avoid
194     //duplicate entries if the cell is hit more than once.
195     m_hitCells[ind] = cell;
196     return;
197   }
198   //---------------------------------------------------------------
199  /** Registers a new deposit in the Ecal  in the calorimeter section. */
200   void CalSection::newEHit( const GridletElement* ge){
201     int ind = index(ge);
202     ITwoCptCell* cell = m_cells[ind];
203     //    cerr<<"gridletEl, phi, eta, eT:     "
204     //    <<ge->phi()<<" "<<ge->eta()<<" "<<ge->et()<<endl;
205     //    cerr<<"cell, phi, eta, granularity: "<<cell->phi()<<" "<<cell->eta()
206     //  <<" "<<m_granPhi<<" "<<m_granEta<<endl;
207     assert(std::abs( (ge->eta()-cell->eta()) )<m_granEta);
208     assert(std::abs( (ge->phi()-cell->phi()) )<m_granPhi);
209     cell->depositEcal(ge->et());
210     //use a map to store pointers to hit cells to avoid
211     //duplicate entries if the cell is hit more than once.
212     m_hitCells[ind] = cell;
213 
214     return;
215   }
216   //----------------------------------------------------------------
217  /** Registers a new deposit in the Hcal  in the calorimeter section. */
218   void CalSection::newHHit( const GridletElement* ge){
219     int ind = index(ge);
220     ITwoCptCell* cell = m_cells[ind];
221 
222     assert(std::abs( (ge->eta())-(cell->eta()) )<m_granEta);
223     assert(std::abs( (ge->phi())-(cell->phi()) )<m_granPhi);
224 
225     cell->depositHcal(ge->et());
226     //use a map to store pointers to hit cells to avoid
227     //duplicate entries if the cell is hit more than once.
228     m_hitCells[ind] = cell;
229 
230     return;
231   }
232   //----------------------------------------------------------------
233   /** find the cell index for a variety of input arguments */
234   void CalSection::setEgen( const Gridlet* gr){
235     int ind = index(gr);
236     ITwoCptCell* cell = m_cells[ind];
237     cell->addEgen(gr->eGen());
238     m_hitCells[ind] = cell;
239     return;
240   }
241   //----------------------------------------------------------------
242   /** find the cell index for a variety of input arguments */
243   int  CalSection::index(const Gridlet* gr) const{
244     int ind = this->iindex( gr->phi0(), gr->eta0() );
245     return ind;
246   }
247   //----------------------------------------------------------------
248   int  CalSection::index(const GridletElement* ge) const{
249     int ind = this->iindex( ge->phi(), ge->eta() );
250     return ind;
251   }
252   //----------------------------------------------------------------
253   int  CalSection::index(const ITransportedParticle* tp) const {
254     const HepMC::GenParticle* particle = tp->particle();
255     const double eta = particle->momentum().pseudoRapidity();
256     const double phi = tp->phi();
257     int ind = iindex(phi, eta);
258     return ind;
259   }
260   //----------------------------------------------------------------
261   int CalSection::iindex(double phi, double eta) const{
262     int iphi = int( (phi-m_minPhi)/m_granPhi );
263     int ieta = int( (eta-m_minEta)/m_granEta );
264     
265     return  (m_nPhi*ieta  + iphi);
266   }
267  /**
268      * Returns a list of hit cells within the calorimeter section.
269      */
270   void CalSection::giveHits
271     (const ICellSelector* p_cellselect, ITwoCptCellCollection* cells) const{
272 
273     std::vector<ITwoCptCell*>::const_iterator i;
274     for(i=m_cells.begin(); i!=m_cells.end(); ++i){
275       //test cell before newing and filling vector
276       if( (*p_cellselect) (*i) && (*i)->isActive()){ 
277         ITwoCptCell* cell = (*i)->cloneITCC();
278         //Need to copy cells because Athena deletes container AND POINTERS
279         // AND POINTEES
280         cells->push_back(cell);
281       }
282     }
283     
284   }
285   //===========================================================================
286  /**
287      * Smear the cells resolution
288      */
289   void CalSection::smearCells
290     (ISmearer* p_smearer) {
291     std::map<int, ITwoCptCell*, std::less<int> >::const_iterator i;
292     for(i=m_hitCells.begin(); i!=m_hitCells.end(); ++i){
293       if((*((*i).second)).momentum().e() > 0){
294         HepLorentzVector temp = p_smearer->smear((*((*i).second)).momentum());
295           (*((*i).second)).setPt(temp);
296       }
297     }
298   }
299 
300 
301 
302   void CalSection::reset(){
303     //reset the cells of this CalSection
304 
305     std::vector<ITwoCptCell*>::const_iterator i = m_cells.begin();
306     for(;i!=m_cells.end();++i) {
307       // may want the cell reset even if it's not hit
308       if((*i)->isActive())(*i)->resetCell();
309     }
310     m_hitCells.erase(m_hitCells.begin(), m_hitCells.end());
311   }
312 }
313 
314     
315 
316     
317   
318 
319 
320 
321 
322 
323 
324 
325 

source navigation ] diff markup ] identifier search ] general search ]

Due to the LXR bug, the updates fail sometimes to remove references to deleted files. The Saturday's full rebuilds fix these problems
This page was automatically generated by the LXR engine. Valid HTML 4.01!