AtlfastPoolTest.cxx

Go to the documentation of this file.
00001 
00002 // ================================================
00003 // AtlfastPoolTest
00004 // ================================================
00005 //
00006 // THIS TEXT TO BE REPLACED BY ATLAS STANDARD FORMAT
00007 //
00008 // Namespace Atlfast
00009 //
00010 
00011 #include "AtlfastAlgs/AtlfastPoolTest.h"
00012 #include "AtlfastAlgs/CellsAboveThreshold.h"
00013 #include "AtlfastEvent/ITransportedParticleFactory.h"
00014 #include "AtlfastAlgs/Calorimeter.h"
00015 #include "AtlfastAlgs/ICellSelector.h"
00016 #include "AtlfastAlgs/ISmearer.h"
00017 #include "AtlfastAlgs/CellSmearer.h"
00018 #include "AtlfastAlgs/GlobalEventData.h"
00019 #include "AtlfastAlgs/EPileupMap.h"
00020 #include "AtlfastAlgs/containerDelete.h"
00021 #include "AtlfastEvent/CollectionDefs.h"
00022 
00023 #include "AtlfastUtils/TesIO.h"
00024 #include "AtlfastUtils/HeaderPrinter.h"
00025 
00026 #include <cmath>
00027 #include <iomanip>
00028 #include <vector>
00029 // Gaudi includes
00030 #include "GaudiKernel/DataSvc.h"
00031 #include "GaudiKernel/Chrono.h"
00032 #include "GaudiKernel/ISvcLocator.h"
00033 #include "GaudiKernel/MsgStream.h"
00034 
00035 namespace Atlfast {
00036   AtlfastPoolTest:: AtlfastPoolTest(const std::string& name, ISvcLocator* pSvcLocator):
00037     Algorithm(name,pSvcLocator), 
00038     m_calorimeter(0),
00039     m_cellSelector(0),
00040     m_mcSelector(0),
00041     m_epileupMap(0),
00042     m_smearer(0),
00043     m_tesIO(0),
00044     m_log( messageService(), name )
00045   {
00046     
00047     //default paths for entities in the TES
00048     m_inputLocation       = "/Event/McEventCollection";
00049     m_outputLocation      = "/Event/AtlfastCells" ;
00050     
00051     // default parameters to build the calorimeter
00052     m_etaCoverage        = 5.0;
00053     m_minETCell          = 0.0;
00054     m_granBarrelEta      = 0.1;
00055     m_granBarrelPhi      = 0.1;
00056     m_granForwardEta     = 0.2;
00057     m_granForwardPhi     = 0.2;
00060     m_doSmearing         = false;
00061     m_fastShower         = false;
00062     
00063     declareProperty("InputLocation",      m_inputLocation);
00064     declareProperty("OutputLocation",     m_outputLocation);
00065     declareProperty("EtaCoverage",        m_etaCoverage);
00066     declareProperty("MinETCell",          m_minETCell);
00067     declareProperty("GranBarrelEta",      m_granBarrelEta);
00068     declareProperty("GranBarrelPhi",      m_granBarrelPhi);
00069     declareProperty("GranForwardEta",     m_granForwardEta);
00070     declareProperty("GranForwardPhi",     m_granForwardPhi);
00072     declareProperty("DoSmearing",     m_doSmearing);
00073     declareProperty("FastShower",     m_fastShower);
00074     
00075   }
00076   
00077   //__________________________________________________________________________
00078   AtlfastPoolTest::~AtlfastPoolTest(){
00079 
00080     m_log << MSG::DEBUG << "AtlfastPoolTest destructor starts " << endreq;
00081 
00082     if ( m_calorimeter ) delete m_calorimeter;
00083     if ( m_cellSelector ) delete m_cellSelector;
00084     if ( m_epileupMap ) delete m_epileupMap;
00085     if ( m_tesIO ) delete m_tesIO;
00086     if ( m_smearer ) delete m_smearer;
00087     
00088     m_log << MSG::DEBUG << "AtlfastPoolTest destructor ends " << endreq;
00089   }
00090   //__________________________________________________________________________
00091   StatusCode AtlfastPoolTest::initialize()
00092   {
00093     
00094 
00095     //set up objects used to determine particle charge,
00096     // and to select input MC 4-vectors.
00097     m_cellSelector  = new CellsAboveThreshold(m_minETCell);
00098     
00099 
00100     //get the Global Event Data using singleton pattern
00101     GlobalEventData* ged = GlobalEventData::Instance();
00102     m_fieldOn          = ged->fieldOn();
00103     m_mcSelector       = ged -> visibleToCal();
00104     m_barrelForwardEta = ged -> barrelForwardEta();
00105     m_mcLocation       = ged -> mcLocation();
00106     m_monopoleIDs      = ged -> monopoleIDs();
00107 
00108     if (fabs(m_etaCoverage) < fabs(m_barrelForwardEta) ) {
00109       m_log << MSG::ERROR 
00110           << "asked to makecalo with max extent " 
00111           << m_etaCoverage 
00112           << "but barrel-forward boundary at " 
00113           << m_barrelForwardEta << endreq;
00114       return StatusCode::FAILURE;
00115 
00116     //    m_tesIO = new TesIO(eventDataService());
00117     m_tesIO = new TesIO(m_mcLocation, ged->justHardScatter());
00118 
00119     }
00120     m_calorimeter = new Calorimeter(
00121                                     m_log,
00122                                     m_fastShower,
00123                                     m_etaCoverage, 
00124                                     m_barrelForwardEta,
00125                                     m_granBarrelEta, 
00126                                     m_granBarrelPhi, 
00127                                     m_granForwardEta, 
00128                                     m_granForwardPhi
00129                                     );
00133     if(m_doSmearing == true){
00134       m_epileupMap = new EPileupMap(ged->lumi());
00135       m_smearer = new CellSmearer(ged->randSeed(),m_barrelForwardEta);
00136     }else{
00137       m_epileupMap = NULL;
00138       m_smearer = NULL;
00139     }
00140 
00141     HeaderPrinter hp("Atlfast Cell Maker:", m_log);
00142     
00143     hp.add("min Cell ET             ", m_minETCell);  
00144     hp.add("Magnetic Field is on?   ", m_fieldOn);
00145     hp.add("Input Location          ", m_inputLocation);    
00146     hp.add("Output Location         ", m_outputLocation);
00147     hp.add(" DoSmearing             ", m_doSmearing);    
00148     hp.add(" Run FastShower         ", m_fastShower);    
00149     hp.add("Calorimeter Geometry:   ");
00150     hp.add(" Total Eta Range        ", m_etaCoverage);
00151     hp.add(" Barrel Eta Range       ", m_barrelForwardEta);
00152     hp.add(" Barrel Eta Granularity ", m_granBarrelEta);
00153     hp.add(" Barrel Phi Granularity ", m_granBarrelPhi);
00154     hp.add(" Forward Eta Granularity", m_granForwardEta);
00155     hp.add(" Forward Phi Granularity", m_granForwardPhi);
00156     hp.print();
00157 
00158 
00159       
00160     return StatusCode::SUCCESS; 
00161   }
00162   
00163   StatusCode AtlfastPoolTest::finalize()
00164   {
00165     
00166     m_log<<MSG::INFO<<"Finalizing"<<endreq;
00167     return StatusCode::SUCCESS; 
00168   }
00169   
00170   //_________________________________________________________________________
00171   StatusCode AtlfastPoolTest::execute()
00172   {
00173     //.............................................
00174     
00175     m_log << MSG::DEBUG << "AtlfastPoolTest execute()" << endreq;
00176     
00177     
00178     // read MC particles from TES
00179     MCparticleCollection p;
00180     TesIoStat stat = m_tesIO->getMC( p, m_mcSelector ) ;
00181     std::string mess;
00182     mess = stat? "Retrieved MC from TES ":"Failed MC retrieve from TES ";
00183     m_log << MSG::DEBUG << mess << p.size()<<endreq;
00184     
00185     ITransportedParticleCollection particlesAtCal;
00186     
00187     MCparticleCollectionCIter ip= p.begin();
00188     for(; ip<p.end(); ++ip){
00189       
00190       // Factory comes back with the relevant TransportedParticle
00191       ITransportedParticle *itp = ITransportedParticleFactory::create(*ip,m_monopoleIDs);
00192       itp->deflect();
00193       particlesAtCal.push_back(itp);
00194       
00195     }   
00196     
00197     
00198     //    return stat;
00199     // give to calorimeter (iseq gives the interval [begin,end)
00200     ITransportedParticleCollectionIter fpart = particlesAtCal.begin();
00201     ITransportedParticleCollectionIter lpart = particlesAtCal.end();
00202     m_calorimeter->deposit(fpart, lpart);
00203     
00204     //Delete the the container of transported particles and its pointers
00205 
00206     containerDelete(particlesAtCal.begin(), particlesAtCal.end());
00207 
00208 
00209     // Add in the energy pileup 
00210     if(m_doSmearing){
00211       //Smear the cells resolution first
00212       m_calorimeter->smearCells(m_smearer);
00213       m_log << MSG::DEBUG << "Doing Smearing" << endreq;
00215       m_epileupMap->fillMap();
00216       m_log << MSG::DEBUG 
00217           << "Size of EM EPileup vector: " 
00218           << m_epileupMap->getEMMap()->size() 
00219           << endreq;
00220       std::vector<Atlfast::EPileupDeposit*>::iterator fdep = 
00221         m_epileupMap->getEMMap()->begin();
00222       std::vector<Atlfast::EPileupDeposit*>::iterator ldep = 
00223         m_epileupMap->getEMMap()->end();
00225       m_calorimeter->deposit(fdep, ldep);
00226       m_log << MSG::DEBUG << "ECAL pileup deposited" << endreq;
00227       m_log << MSG::DEBUG << "Size of HAD EPileup vector: " 
00228           << m_epileupMap->getHadMap()->size() 
00229           << endreq;
00230       fdep = m_epileupMap->getHadMap()->begin();
00231       ldep = m_epileupMap->getHadMap()->end();
00233       m_calorimeter->deposit(fdep, ldep);
00234       m_log << MSG::DEBUG << "HCAL pileup deposited" << endreq;
00235     }
00236 
00237     m_log << MSG::DEBUG << "deposit" << endreq;
00238     
00239     // ask for Cells passing selection criteria of m_cellSelector (=Et).
00240     //************************
00241     //this worked 23/12 PS
00242     ITwoCptCellCollection* cells = new ITwoCptCellCollection;
00243     //************************
00246     m_calorimeter->giveHitCells(m_cellSelector, cells);
00247     m_log << MSG::DEBUG << "hit cells retrieved, " << cells->size() 
00248         << " cells were hit this event " << endreq;
00249 
00250     //    return stat;
00251 
00252     // finished with the calorimeter
00253     m_calorimeter->reset();
00254     m_log << MSG::DEBUG << "calorimeter reset" << endreq;
00255     //    return stat;
00256     //    return stat;
00257     
00258     // then store and return
00259     stat = m_tesIO->store(cells, m_outputLocation );  
00260     mess = stat? " Stored cells to TES":" Failed store cells to TES";
00261     m_log << MSG::DEBUG << mess << endreq;
00262 
00263     return stat;
00264   }
00265 
00266 } // end of namespace bracket
00267 
00268 
00269 
00270 
00271 
00272 
00273 

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