00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "AtlfastAlgs/CellMaker.h"
00012 #include "AtlfastAlgs/CellsAboveThreshold.h"
00013 #include "AtlfastAlgs/TransportedParticle.h"
00014 #include "AtlfastAlgs/TransportedParticleCollection.h"
00015 #include "AtlfastAlgs/Calorimeter.h"
00016 #include "AtlfastAlgs/MagField.h"
00017 #include "AtlfastAlgs/ICellSelector.h"
00018 #include "AtlfastAlgs/ISmearer.h"
00019 #include "AtlfastAlgs/CellSmearer.h"
00020 #include "AtlfastAlgs/GlobalEventData.h"
00021 #include "AtlfastAlgs/EPileupMap.h"
00022
00023 #include "AtlfastEvent/CollectionDefs.h"
00024
00025 #include "AtlfastUtils/TesIO.h"
00026 #include "AtlfastUtils/HeaderPrinter.h"
00027
00028 #include <cmath>
00029 #include <iomanip>
00030 #include <vector>
00031
00032 #include "GaudiKernel/DataSvc.h"
00033 #include "GaudiKernel/Chrono.h"
00034 #include "StoreGate/DataHandle.h"
00035 #include "GaudiKernel/ISvcLocator.h"
00036 #include "GaudiKernel/MsgStream.h"
00037
00038
00039
00040 namespace Atlfast {
00041 CellMaker:: CellMaker(const std::string& name, ISvcLocator* pSvcLocator):
00042 Algorithm(name,pSvcLocator){
00043
00044
00045 m_inputLocation = "/Event/McEventCollection";
00046 m_outputLocation = "/Event/AtlfastCells" ;
00047
00048
00049 m_etaCoverage = 5.0;
00050 m_minETCell = 0.0;
00051 m_granBarrelEta = 0.1;
00052 m_granBarrelPhi = 0.1;
00053 m_granForwardEta = 0.2;
00054 m_granForwardPhi = 0.2;
00057 m_doSmearing = false;
00058 m_fastShower = false;
00059
00060 declareProperty("InputLocation", m_inputLocation);
00061 declareProperty("OutputLocation", m_outputLocation);
00062 declareProperty("EtaCoverage", m_etaCoverage);
00063 declareProperty("MinETCell", m_minETCell);
00064 declareProperty("GranBarrelEta", m_granBarrelEta);
00065 declareProperty("GranBarrelPhi", m_granBarrelPhi);
00066 declareProperty("GranForwardEta", m_granForwardEta);
00067 declareProperty("GranForwardPhi", m_granForwardPhi);
00069 declareProperty("DoSmearing", m_doSmearing);
00070 declareProperty("FastShower", m_fastShower);
00071
00072 }
00073
00074
00075 CellMaker::~CellMaker(){
00076
00077 MsgStream log( messageService(), name() );
00078 log<<MSG::DEBUG<<"CellMaker destructor starts "<<endreq;
00079
00080 if (m_calorimeter) {
00081 delete m_calorimeter;
00082 }
00083 if (m_tesIO) {
00084 delete m_tesIO;
00085 }
00086 if (m_cellSelector) {
00087 delete m_cellSelector;
00088 }
00089 if (m_magField) {
00090 delete m_magField;
00091 }
00092 log<<MSG::DEBUG<<"CellMaker destructor ends "<<endreq;
00093 }
00094
00095 StatusCode CellMaker::initialize()
00096 {
00097
00098 MsgStream log( messageService(), name() );
00099
00100
00101
00102 m_cellSelector = new CellsAboveThreshold(m_minETCell);
00103
00104
00105 m_tesIO = new TesIO();
00106
00107
00108 GlobalEventData* ged = GlobalEventData::Instance();
00109 m_fieldOn = ged->fieldOn();
00110 m_mcSelector = ged -> visibleToCal();
00111 m_barrelForwardEta = ged -> barrelForwardEta();
00112 m_magField = new MagField(m_fieldOn);
00113 if (fabs(m_etaCoverage) < fabs(m_barrelForwardEta) ) {
00114 log << MSG::ERROR
00115 << "asked to makecalo with max extent "
00116 << m_etaCoverage
00117 << "but barrel-forward boundary at "
00118 << m_barrelForwardEta << endreq;
00119 return StatusCode::FAILURE;
00120 }
00121 m_calorimeter = new Calorimeter(
00122 log,
00123 m_fastShower,
00124 m_etaCoverage,
00125 m_barrelForwardEta,
00126 m_granBarrelEta,
00127 m_granBarrelPhi,
00128 m_granForwardEta,
00129 m_granForwardPhi
00130 );
00134 if(m_doSmearing == true){
00135 m_epileupMap = new EPileupMap(ged->lumi());
00136 m_smearer = new CellSmearer(ged->randSeed(),m_barrelForwardEta);
00137 }else{
00138 m_epileupMap = NULL;
00139 m_smearer = NULL;
00140 }
00141
00142 HeaderPrinter hp("Atlfast Cell Maker:", log);
00143
00144 hp.add("min Cell ET ", m_minETCell);
00145 hp.add("Magnetic Field is on? ", m_fieldOn);
00146 hp.add("Input Location ", m_inputLocation);
00147 hp.add("Output Location ", m_outputLocation);
00148 hp.add(" DoSmearing ", m_doSmearing);
00149 hp.add(" Run FastShower ", m_fastShower);
00150 hp.add("Calorimeter Geometry: ");
00151 hp.add(" Total Eta Range ", m_etaCoverage);
00152 hp.add(" Barrel Eta Range ", m_barrelForwardEta);
00153 hp.add(" Barrel Eta Granularity ", m_granBarrelEta);
00154 hp.add(" Barrel Phi Granularity ", m_granBarrelPhi);
00155 hp.add(" Forward Eta Granularity", m_granForwardEta);
00156 hp.add(" Forward Phi Granularity", m_granForwardPhi);
00157 hp.print();
00158
00159
00160
00161 return StatusCode::SUCCESS;
00162 }
00163
00164 StatusCode CellMaker::finalize()
00165 {
00166
00167 MsgStream log( messageService(), name() );
00168 log<<MSG::INFO<<"Finalizing"<<endreq;
00169 return StatusCode::SUCCESS;
00170 }
00171
00172
00173 StatusCode CellMaker::execute()
00174 {
00175
00176
00177 MsgStream log( messageService(), name() );
00178 log << MSG::DEBUG << "CellMaker execute()" << endreq;
00179
00180 std::string mess;
00181
00182
00183
00184 MCparticleCollection mcParticles ;
00185 TesIoStat stat = m_tesIO->getMC( mcParticles, m_mcSelector ) ;
00186 mess = stat? "Retrieved MC from TES ":"Failed MC retrieve from TES";
00187 log << MSG::DEBUG << mess << endreq;
00188
00189
00190 TransportedParticleCollection particlesAtCal;
00191 (*m_magField)(mcParticles, particlesAtCal);
00192 log << MSG::DEBUG << "bend" << endreq;
00193
00194
00195
00196 TransportedParticleCollectionIter fpart = particlesAtCal.begin();
00197 TransportedParticleCollectionIter lpart = particlesAtCal.end();
00198 m_calorimeter->deposit(fpart, lpart);
00199
00200
00201
00202 if(m_doSmearing){
00203
00204 m_calorimeter->smearCells(m_smearer);
00205 log << MSG::DEBUG << "Doing Smearing" << endreq;
00207 m_epileupMap->fillMap();
00208 log << MSG::DEBUG
00209 << "Size of EM EPileup vector: "
00210 << m_epileupMap->getEMMap()->size()
00211 << endreq;
00212 std::vector<Atlfast::EPileupDeposit*>::iterator fdep =
00213 m_epileupMap->getEMMap()->begin();
00214 std::vector<Atlfast::EPileupDeposit*>::iterator ldep =
00215 m_epileupMap->getEMMap()->end();
00217 m_calorimeter->deposit(fdep, ldep);
00218 log << MSG::DEBUG << "ECAL pileup deposited" << endreq;
00219 log << MSG::DEBUG << "Size of HAD EPileup vector: "
00220 << m_epileupMap->getHadMap()->size()
00221 << endreq;
00222 fdep = m_epileupMap->getHadMap()->begin();
00223 ldep = m_epileupMap->getHadMap()->end();
00225 m_calorimeter->deposit(fdep, ldep);
00226 log << MSG::DEBUG << "HCAL pileup deposited" << endreq;
00227 }
00228
00229 log << MSG::DEBUG << "deposit" << endreq;
00230
00231
00232
00233
00234 ITwoCptCellCollection* cells = new ITwoCptCellCollection;
00235
00238 m_calorimeter->giveHitCells(m_cellSelector, cells);
00239 log << MSG::DEBUG << "hit cells retrieved, " << cells->size()
00240 << " cells were hit this event " << endreq;
00241
00242
00243
00244
00245 m_calorimeter->reset();
00246 log << MSG::DEBUG << "calorimeter reset" << endreq;
00247
00248
00249
00250
00251 stat = m_tesIO->store(cells, m_outputLocation );
00252 mess = stat? " Stored cells to TES":" Failed store cells to TES";
00253 log << MSG::DEBUG << mess << endreq;
00254
00255 return stat;
00256 }
00257
00258 }
00259
00260
00261
00262
00263
00264
00265