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 // CellMaker 
004 // ================================================
005 //
006 // THIS TEXT TO BE REPLACED BY ATLAS STANDARD FORMAT
007 //
008 // Namespace Atlfast
009 //
010 
011 #include "AtlfastAlgs/CellMaker.h"
012 #include "AtlfastAlgs/CellsAboveThreshold.h"
013 #include "AtlfastAlgs/Calorimeter.h"
014 #include "AtlfastAlgs/ICellSelector.h"
015 #include "AtlfastAlgs/CellSmearer.h"
016 #include "AtlfastAlgs/GlobalEventData.h"
017 #include "AtlfastAlgs/containerDelete.h"
018 
019 #include "AtlfastUtils/ISmearer.h"
020 #include "AtlfastUtils/TesIO.h"
021 #include "AtlfastUtils/HeaderPrinter.h"
022 
023 #include "AtlfastEvent/ITransportedParticleFactory.h"
024 #include "AtlfastEvent/CollectionDefs.h"
025 
026 #include <cmath>
027 #include <iomanip>
028 #include <vector>
029 // Gaudi includes
030 #include "GaudiKernel/DataSvc.h"
031 #include "GaudiKernel/Chrono.h"
032 #include "GaudiKernel/ISvcLocator.h"
033 #include "GaudiKernel/MsgStream.h"
034 
035 #include "CLHEP/Units/SystemOfUnits.h"
036 #include "NavFourMom/INavigable4MomentumCollection.h"
037 
038 namespace Atlfast {
039   /** @brief Deposits truth particle energies into Atlfast Cells.
040    *
041    * Maker class which reads Monte Carlo information from the TES
042    * and causes a calorimeter simulation of their energy deposits.<BR>
043    * This results in a collection of hit Cell entities to be
044    * written to the TES
045    *
046    * @image html CellMaker.jpg "CellMaker sequence"
047    */
048   CellMaker:: CellMaker(const std::string& name, ISvcLocator* pSvcLocator):
049     Algorithm(name,pSvcLocator),
050     m_calorimeter(0),
051     m_cellSelector(0),
052     m_mcSelector(0),
053     m_smearer(0),
054     m_tesIO(0),
055     m_log( messageService(), name )
056   {
057     
058     //default paths for entities in the TES
059     m_outputLocation      = "/Event/AtlfastCells" ;
060     m_outputLocation_IN4M = "/Event/AtlfastCellsIN4M";
061 
062     // default parameters to build the calorimeter
063     m_etaCoverage        = 5.0;
064     m_minETCell          = 0.0*GeV;
065     m_granBarrelEta      = 0.1;
066     m_granBarrelPhi      = 0.1;
067     m_granForwardEta     = 0.2;
068     m_granForwardPhi     = 0.2;
069     /** This doSmearing is still in experimental phase
070         and should NOT be set to true by any user */
071     m_doSmearing         = false;
072     m_fastShower         = false;
073     m_detEffectsFileName = "";
074 
075     
076     declareProperty("OutputLocation",     m_outputLocation);
077     declareProperty("OutputLocationIN4M", m_outputLocation_IN4M);
078     declareProperty("EtaCoverage",        m_etaCoverage);
079     declareProperty("MinETCell",          m_minETCell);
080     declareProperty("GranBarrelEta",      m_granBarrelEta);
081     declareProperty("GranBarrelPhi",      m_granBarrelPhi);
082     declareProperty("GranForwardEta",     m_granForwardEta);
083     declareProperty("GranForwardPhi",     m_granForwardPhi);
084     /**WARNING!! DoSmearing should not be changed from default of false */
085     declareProperty("DoSmearing",     m_doSmearing);
086     declareProperty("FastShower",     m_fastShower);
087   }
088   
089   //__________________________________________________________________________
090   CellMaker::~CellMaker(){
091 
092     m_log<<MSG::DEBUG<<"CellMaker destructor starts "<<endreq;
093 
094     m_log<<MSG::DEBUG<<"Deleting Calorimeter "<<endreq;
095     if (m_calorimeter) delete m_calorimeter;
096 
097     m_log<<MSG::DEBUG<<"Deleting TesIO "<<endreq;
098     if (m_tesIO) delete m_tesIO;
099 
100     m_log<<MSG::DEBUG<<"Deleting Cell Selector "<<endreq;
101     if (m_cellSelector) delete m_cellSelector;
102 
103     if (m_smearer) delete m_smearer;
104 
105     m_log<<MSG::DEBUG<<"CellMaker destructor ends "<<endreq;
106   }
107   //__________________________________________________________________________
108   StatusCode CellMaker::initialize()
109   {
110     
111 
112     //set up objects used to determine particle charge,
113     // and to select input MC 4-vectors.
114     m_cellSelector  = new CellsAboveThreshold(m_minETCell);
115     
116 
117     //get the Global Event Data using singleton pattern
118     GlobalEventData* ged = GlobalEventData::Instance();
119     m_fieldOn          = ged -> fieldOn();
120     m_mcSelector       = ged -> visibleToCal();
121     m_barrelForwardEta = ged -> barrelForwardEta();
122     m_mcLocation       = ged -> mcLocation();
123     m_monopoleIDs      = ged -> monopoleIDs();
124     m_detEffectsFileName = ged -> detEffectsFileName();
125  
126     //    m_tesIO = new TesIO(eventDataService());
127     m_tesIO = new TesIO(m_mcLocation, ged->justHardScatter());
128 
129 
130     if (fabs(m_etaCoverage) < fabs(m_barrelForwardEta) ) {
131       m_log << MSG::ERROR 
132           << "asked to makecalo with max extent " 
133           << m_etaCoverage 
134           << "but barrel-forward boundary at " 
135           << m_barrelForwardEta << endreq;
136       return StatusCode::FAILURE;
137     }
138     m_calorimeter = new Calorimeter(
139                                     m_log,
140                                     m_fastShower,
141                                     m_etaCoverage, 
142                                     m_barrelForwardEta,
143                                     m_granBarrelEta, 
144                                     m_granBarrelPhi, 
145                                     m_granForwardEta, 
146                                     m_granForwardPhi,
147                                     m_detEffectsFileName
148                                     );
149     /**NOTE!! Smearing should not be switched on */
150     /** if we want to perform cell level smearing, must make a
151      * CellSmearer and a Energy Pileup map */
152     if(m_doSmearing == true){
153       m_smearer = new CellSmearer(ged->randSeed(),m_barrelForwardEta);
154     }else{
155       m_smearer = 0;
156     }
157 
158     HeaderPrinter hp("Atlfast Cell Maker:", m_log);
159     
160     hp.add("Min Cell ET                         ", m_minETCell);  
161     hp.add("Magnetic Field is on?               ", m_fieldOn);
162     hp.add("MC Input Location                   ", m_mcLocation);
163     hp.add("Output Location                     ", m_outputLocation);
164     hp.add("INavigable4Momentum Output Location ", m_outputLocation_IN4M);
165     hp.add("DoSmearing                          ", m_doSmearing);    
166     hp.add("Run FastShower                      ", m_fastShower);    
167     hp.add("Calorimeter Geometry:               ");
168     hp.add("Total Eta Range                     ", m_etaCoverage);
169     hp.add("Barrel Eta Range                    ", m_barrelForwardEta);
170     hp.add("Barrel Eta Granularity              ", m_granBarrelEta);
171     hp.add("Barrel Phi Granularity              ", m_granBarrelPhi);
172     hp.add("Forward Eta Granularity             ", m_granForwardEta);
173     hp.add("Forward Phi Granularity             ", m_granForwardPhi);
174     hp.print();
175 
176 
177       
178     return StatusCode::SUCCESS; 
179   }
180   
181   StatusCode CellMaker::finalize()
182   {
183     
184     m_log<<MSG::INFO<<"Finalizing"<<endreq;
185     return StatusCode::SUCCESS; 
186   }
187   
188   //_________________________________________________________________________
189   StatusCode CellMaker::execute()
190   {
191     //.............................................
192     
193     m_log << MSG::DEBUG << "CellMaker execute()" << endreq;
194 
195     ITransportedParticleCollection particlesAtCal;
196     deflectParticles(particlesAtCal);
197     
198     // give to calorimeter (iseq gives the interval [begin,end)
199     ITransportedParticleCollectionIter fpart = particlesAtCal.begin();
200     ITransportedParticleCollectionIter lpart = particlesAtCal.end();
201     m_calorimeter->deposit(fpart, lpart);
202     
203     //Delete the the container of transported particles and its pointers
204     containerDelete(particlesAtCal.begin(), particlesAtCal.end());
205 
206 
207     // Add in the energy pileup 
208     if(m_doSmearing){
209 
210       //Smear the cells resolution first
211       m_calorimeter->smearCells(m_smearer);
212       m_log << MSG::DEBUG << "Doing Smearing" << endreq;
213     }
214 
215     m_log << MSG::DEBUG << "deposit" << endreq;
216     
217     // Ask for Cells passing selection criteria of m_cellSelector (=Et).
218 
219     // For now, we will make, fill and store two collections here
220     // The first is to be used iternally by Atlfast Algorithms:
221     ITwoCptCellCollection* cells = new ITwoCptCellCollection;
222     // The second will be read in by the full jet reconstruction:
223     INavigable4MomentumCollection *cells_IN4M = 
224       new INavigable4MomentumCollection(SG::VIEW_ELEMENTS);
225     
226 
227     //************************
228     /** pass pointer to smearer as well, if not NULL, then cells pT is smeared 
229      before the ITwoCellCollection is filled */
230     m_calorimeter->giveHitCells(m_cellSelector, cells);
231     m_log << MSG::DEBUG << "hit cells retrieved, " << cells->size() 
232         << " cells were hit this event " << endreq;
233 
234     // Fill the IN4M collection with pointers to the ITwoCptCells
235     ITwoCptCellCollection::const_iterator cellItr = cells->begin();
236     for (;cellItr != cells->end(); ++cellItr){
237       INavigable4Momentum *cell_IN4M = *cellItr;
238       cells_IN4M->push_back(cell_IN4M);
239     }
240     
241     // finished with the calorimeter
242     m_calorimeter->reset();
243     m_log << MSG::DEBUG << "calorimeter reset" << endreq;
244     
245     // then store and return
246     TesIoStat stat = m_tesIO->store(cells, m_outputLocation );  
247     std::string mess = stat ? "Stored cells in TES":"Failed store cells in TES";
248     m_log << MSG::DEBUG << mess << endreq;
249 
250     stat = m_tesIO->store(cells_IN4M, m_outputLocation_IN4M );
251     if (stat) m_log << MSG::DEBUG << "Stored cells in TES as INavigable4MomentumCollection" << endreq;
252     else m_log << MSG::ERROR << "Failed to store cells in TES as INavigable4MomentumCollection" << endreq;
253     
254     return stat;
255 
256   }
257   
258   void CellMaker::deflectParticles(ITransportedParticleCollection &itpc){
259     
260     m_log << MSG::DEBUG << "CellMaker deflectParticles()" << endreq;
261 
262     // read MC particles from TES
263     MCparticleCollection p;
264     TesIoStat stat = m_tesIO->getMC( p, m_mcSelector ) ;
265     std::string mess;
266     mess = stat? "Retrieved MC from TES ":"Failed MC retrieve from TES ";
267     m_log << MSG::DEBUG << mess << p.size()<<endreq;
268     
269     MCparticleCollectionCIter ip= p.begin();
270     for(; ip<p.end(); ++ip){
271       
272       // Factory comes back with the relevant TransportedParticle
273       ITransportedParticle *itp = ITransportedParticleFactory::create(*ip,m_monopoleIDs);
274       itp->deflect();
275       itpc.push_back(itp);
276       
277     }   
278     
279     return;
280     
281   }
282   
283   
284 } // end of namespace bracket
285 
286 
287 
288 
289 
290 
291 

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!