#include <ReconstructedParticleHistogramMaker.h>
Collaboration diagram for Atlfast::ReconstructedParticleHistogramMaker:
Public Member Functions | |
ReconstructedParticleHistogramMaker (const std::string &name, ISvcLocator *pSvcLocator) | |
~ReconstructedParticleHistogramMaker () | |
StatusCode | initialize () |
StatusCode | execute () |
StatusCode | finalize () |
Private Member Functions | |
void | book (std::vector< IHistogram1D * > &start, const std::string title, const int nbins, const double xmin, const double xmax, const double xminDiff, const double xmaxDiff) |
void | fill (std::vector< IHistogram1D * > &start, const double rec, const double tru) |
Private Attributes | |
TesIO * | m_tesIO |
std::string | m_mcLocation |
std::string | m_inputLocation |
std::string | m_mcTruthLocation |
std::vector< IHistogram1D * > | m_h_multiplicity |
std::vector< IHistogram1D * > | m_h_energy |
std::vector< IHistogram1D * > | m_h_pt |
std::vector< IHistogram1D * > | m_h_eta |
std::vector< IHistogram1D * > | m_h_phi |
std::vector< IHistogram1D * > | m_h_theta |
int | m_histStart |
int | m_nHist |
int | m_particleType |
std::string | m_histTitle |
HepMC_helper::IMCselector * | m_ncutter |
Definition at line 55 of file ReconstructedParticleHistogramMaker.h.
Atlfast::ReconstructedParticleHistogramMaker::ReconstructedParticleHistogramMaker | ( | const std::string & | name, | |
ISvcLocator * | pSvcLocator | |||
) |
Definition at line 50 of file ReconstructedParticleHistogramMaker.cxx.
00051 : Algorithm( name, pSvcLocator ){ 00052 00053 00054 00055 00056 // Default paths for entities in the TES 00057 m_inputLocation = "/Event/Electrons"; 00058 m_mcTruthLocation = "/Event/McEventCollection"; 00059 00060 00061 m_histStart = 0; // ID of first histogram 00062 m_particleType = 11; // Default particle type to examine 00063 m_histTitle = "Electron "; // Default prefixfor histogram titles 00064 00065 declareProperty( "InputLocation", m_inputLocation ) ; 00066 declareProperty( "McTruthLocation", m_mcTruthLocation ); 00067 declareProperty( "HistogramStart", m_histStart ); 00068 declareProperty( "ParticleType", m_particleType ); 00069 declareProperty( "HistogramTitle", m_histTitle ); 00070 00071 }
Atlfast::ReconstructedParticleHistogramMaker::~ReconstructedParticleHistogramMaker | ( | ) |
Definition at line 74 of file ReconstructedParticleHistogramMaker.cxx.
00074 { 00075 MsgStream log(messageService(), name()); 00076 log << MSG::INFO << "destructor" << endreq; 00077 00078 }
StatusCode Atlfast::ReconstructedParticleHistogramMaker::initialize | ( | ) |
Definition at line 85 of file ReconstructedParticleHistogramMaker.cxx.
00086 { 00087 // .. put any initialisation in here... 00088 MsgStream log(messageService(), name()); 00089 log << MSG::DEBUG << "in initialize()" << endreq; 00090 00091 m_nHist = m_histStart; 00092 00093 book(m_h_multiplicity, string("Multiplicity"),20,0.0,20.0,-5.0, 5.0); 00094 log << MSG::DEBUG << "Made multiplicity histos" << endreq; 00095 00096 book(m_h_energy, string("Energy"),100,0.0,500.0,-10.0, 10.0); 00097 log << MSG::DEBUG << "Made energy histos" << endreq; 00098 00099 book(m_h_pt, string("Pt"), 100,0.0,500.0,-10.0,10.0); 00100 log << MSG::DEBUG << "Made pt histos" << endreq; 00101 00102 book(m_h_eta, string("Eta"), 100,-3.0,3.0,-0.2,0.2); 00103 log << MSG::DEBUG << "Made eta histos" << endreq; 00104 00105 book(m_h_phi, string("Phi"),20,-M_PI,M_PI,-0.1,0.1); 00106 log << MSG::DEBUG << "Made phi histos" << endreq; 00107 00108 book(m_h_theta, string("Theta"),20,0.0,M_PI,-0.1,0.1); 00109 log << MSG::DEBUG << "Made thetahistos" << endreq; 00110 00111 00112 log << MSG::DEBUG << "Booked histograms OK" << endreq; 00113 00114 GlobalEventData* ged = GlobalEventData::Instance(); 00115 // load the location of the MC in StoreGate 00116 m_mcLocation = ged -> mcLocation(); 00117 00118 00119 // m_tesIO = new TesIO(eventDataService()); 00120 m_tesIO = new TesIO(m_mcLocation, ged->justHardScatter()); 00121 00122 // Set up NCutter to select the required HepMC::GenParticles 00123 typedef HepMC_helper::IMCselector Selector; 00124 00125 Selector* typeSelector = new HepMC_helper::SelectType( m_particleType); 00126 Selector* kineSelector = new HepMC_helper::MCCuts(m_mcPtMin, m_mcEtaMax); 00127 Selector* fstaSelector = new HepMC_helper::IsFinalState(); 00128 Selector* fhscSelector = new HepMC_helper::IsFromHardScatter(); 00129 00130 vector<HepMC_helper::IMCselector*> selectors; 00131 selectors.push_back(fhscSelector); 00132 selectors.push_back(fstaSelector); 00133 selectors.push_back(typeSelector); 00134 selectors.push_back(kineSelector); 00135 00136 m_ncutter = new HepMC_helper::NCutter(selectors); 00137 00138 delete typeSelector; 00139 delete kineSelector; 00140 delete fstaSelector; 00141 delete fhscSelector; 00142 //======================================================= 00143 00144 return StatusCode::SUCCESS ; 00145 }
StatusCode Atlfast::ReconstructedParticleHistogramMaker::execute | ( | ) |
Definition at line 169 of file ReconstructedParticleHistogramMaker.cxx.
00170 { 00171 00172 //................................ 00173 // make a message logging stream 00174 00175 MsgStream log( messageService(), name() ) ; 00176 log << MSG::DEBUG << "Executing " << endreq; 00177 00178 // Access the reconstructed particles in the TES 00179 std::vector<ReconstructedParticle*> myParticles; 00180 // Access the collection of "McEvent" records in the TES 00181 std::vector<McEvent*> mcEvents; 00182 00183 00184 //Get the MC truth list 00185 MCparticleCollection myMC_particles ; 00186 MCparticleCollectionCIter src ; 00187 00188 TesIoStat stat = m_tesIO->getMC( myMC_particles, m_ncutter ) ; 00189 mess = stat? "Retrieved MC from TES ":"Failed MC retrieve from TES"; 00190 log << MSG::DEBUG << mess << endreq; 00191 00192 00193 //check to see whether any reconstructed particles are found at the requested location 00194 if(!m_tesIO->copy(myParticles, m_inputLocation)){ 00195 log << MSG::DEBUG << "no particles found in the TES. This is probably normal" << endreq; 00196 // fill any histograms that have meaning in the absence of rec particles 00197 fill(m_h_multiplicity,0.0,float(myMC_particles.size()) ); 00198 //log << MSG::DEBUG 00199 //<< "filled multiplicity 0.0 and " 00200 //<< float(myMC_particles.size()) 00201 //<< endreq; 00202 } else { 00203 // fill all histograms 00204 //log << MSG::DEBUG << "Fill multiplicity" << endreq; 00205 fill(m_h_multiplicity, 00206 double(myParticles.size()), 00207 double(myMC_particles.size()) ); 00208 00209 //iterate over the electrons 00210 00211 std::vector<ReconstructedParticle*>::const_iterator iter = myParticles.begin(); 00212 for (; iter != myParticles.end(); ++iter) { 00213 const HepMC::GenParticle* truth = (*iter)->truth(); 00214 HepLorentzVector momentum = (*iter)->momentum(); 00215 HepLorentzVector trueMomentum = truth->momentum(); 00216 00217 //log << MSG::DEBUG << "Fill per-electron histos" << endreq; 00218 fill(m_h_pt, (*iter)->pT(), trueMomentum.perp()); 00219 fill(m_h_eta, (*iter)->eta(), trueMomentum.pseudoRapidity()); 00220 fill(m_h_energy,((*iter)->momentum()).e(), trueMomentum.e()); 00221 fill(m_h_phi, (*iter)->phi(), trueMomentum.phi()); 00222 fill(m_h_theta, ((*iter)->momentum()).theta(),trueMomentum.theta()); 00223 } 00224 } 00225 log << MSG::DEBUG << "Done the filling OK" << endreq; 00226 return StatusCode::SUCCESS ; 00227 }
StatusCode Atlfast::ReconstructedParticleHistogramMaker::finalize | ( | ) |
Definition at line 153 of file ReconstructedParticleHistogramMaker.cxx.
00154 { 00155 // .. put any finalisation in here... 00156 MsgStream log(messageService(), name()); 00157 log << MSG::INFO << "finalizing" << endreq; 00158 00159 return StatusCode::SUCCESS ; 00160 }
void Atlfast::ReconstructedParticleHistogramMaker::book | ( | std::vector< IHistogram1D * > & | start, | |
const std::string | title, | |||
const int | nbins, | |||
const double | xmin, | |||
const double | xmax, | |||
const double | xminDiff, | |||
const double | xmaxDiff | |||
) | [private] |
Definition at line 234 of file ReconstructedParticleHistogramMaker.cxx.
00243 { 00244 00245 // book the histograms in turn, incrementing the counter before using it 00246 start.push_back(histoSvc()->book( 00247 "/stat/simple1d/", 00248 ++m_nHist, 00249 m_histTitle+" Rec "+title, 00250 nbins, 00251 xmin, 00252 xmax 00253 ) 00254 ); 00255 00256 start.push_back(histoSvc()->book( 00257 "/stat/simple1d/", 00258 ++m_nHist, 00259 m_histTitle+" Tru "+title, 00260 nbins, 00261 xmin, 00262 xmax 00263 ) 00264 ); 00265 00266 start.push_back(histoSvc()->book( 00267 "/stat/simple1d/", 00268 ++m_nHist, 00269 m_histTitle+" Dif "+title, 00270 nbins*2, 00271 xminDiff, 00272 xmaxDiff 00273 ) 00274 ); 00275 start.push_back(histoSvc()->book( 00276 "/stat/simple1d/", 00277 ++m_nHist, 00278 m_histTitle+" Res "+title, 00279 nbins*2, 00280 -2.0, 00281 2.0 00282 ) 00283 ); 00284 00285 return; 00286 }
void Atlfast::ReconstructedParticleHistogramMaker::fill | ( | std::vector< IHistogram1D * > & | start, | |
const double | rec, | |||
const double | tru | |||
) | [private] |
Definition at line 291 of file ReconstructedParticleHistogramMaker.cxx.
00291 { 00292 00293 MsgStream log( messageService(), name() ) ; 00294 00295 if (!start[0] || !start[1] || !start[2] || !start[3]) { 00296 log << MSG::WARNING << "trying to fill to a null histogram pointer" << endreq; 00297 return; 00298 } 00299 start[0]->fill(rec,1.0); 00300 start[1]->fill(tru,1.0); 00301 start[2]->fill(tru-rec,1.0); 00302 if (tru != 0.0) { 00303 start[3]->fill((tru-rec)/tru,1.0); 00304 } 00305 return; 00306 }
Definition at line 81 of file ReconstructedParticleHistogramMaker.h.
std::string Atlfast::ReconstructedParticleHistogramMaker::m_mcLocation [private] |
Definition at line 83 of file ReconstructedParticleHistogramMaker.h.
std::string Atlfast::ReconstructedParticleHistogramMaker::m_inputLocation [private] |
Definition at line 108 of file ReconstructedParticleHistogramMaker.h.
std::string Atlfast::ReconstructedParticleHistogramMaker::m_mcTruthLocation [private] |
Definition at line 109 of file ReconstructedParticleHistogramMaker.h.
std::vector<IHistogram1D*> Atlfast::ReconstructedParticleHistogramMaker::m_h_multiplicity [private] |
Definition at line 125 of file ReconstructedParticleHistogramMaker.h.
std::vector<IHistogram1D*> Atlfast::ReconstructedParticleHistogramMaker::m_h_energy [private] |
Definition at line 127 of file ReconstructedParticleHistogramMaker.h.
std::vector<IHistogram1D*> Atlfast::ReconstructedParticleHistogramMaker::m_h_pt [private] |
Definition at line 129 of file ReconstructedParticleHistogramMaker.h.
std::vector<IHistogram1D*> Atlfast::ReconstructedParticleHistogramMaker::m_h_eta [private] |
Definition at line 131 of file ReconstructedParticleHistogramMaker.h.
std::vector<IHistogram1D*> Atlfast::ReconstructedParticleHistogramMaker::m_h_phi [private] |
Definition at line 133 of file ReconstructedParticleHistogramMaker.h.
std::vector<IHistogram1D*> Atlfast::ReconstructedParticleHistogramMaker::m_h_theta [private] |
Definition at line 135 of file ReconstructedParticleHistogramMaker.h.
Definition at line 140 of file ReconstructedParticleHistogramMaker.h.
int Atlfast::ReconstructedParticleHistogramMaker::m_nHist [private] |
Definition at line 142 of file ReconstructedParticleHistogramMaker.h.
Definition at line 145 of file ReconstructedParticleHistogramMaker.h.
std::string Atlfast::ReconstructedParticleHistogramMaker::m_histTitle [private] |
Definition at line 148 of file ReconstructedParticleHistogramMaker.h.
Definition at line 154 of file ReconstructedParticleHistogramMaker.h.