1#include "EventNavigator/NavigationTestAlg.h"
3#include "EventNavigator/EventNavigator.h"
6#include "GaudiKernel/MsgStream.h"
7#include "GaudiKernel/SmartDataPtr.h"
11#include "McTruth/McParticle.h"
12#include "McTruth/MdcMcHit.h"
15#include "MdcRecEvent/RecMdcTrack.h"
16#include "MdcRecEvent/RecMdcHit.h"
19#include "EmcRecEventModel/RecEmcShower.h"
30 declareProperty(
"OutputFileName", m_fout=
"histo.root");
36 MsgStream log(
msgSvc(), name());
38 log << MSG::INFO <<
" Creating histograms" << endreq;
41 m_histo.push_back(
new TH1F(
"deltap",
"#delta p, true momentum - rec momentum, MeV/c",600,-100,500));
43 m_histo.push_back(
new TH1F(
"n_parents",
"Number of parents for reconstructed track",20,0,20));
44 m_histo.push_back(
new TH1F(
"n_tracks",
"Number of tracks for one MC particle",20,0,20));
46 m_histo.push_back(
new TH1F(
"hit_parent",
"Number of parent MC hits for reconstructed hit",20,-10,10));
47 m_histo.push_back(
new TH1F(
"hit_track",
"Number of reconstructed hits for MC hit",20,-10,10));
49 m_histo.push_back(
new TH1F(
"true_p",
"true momentum, MeV/c",1500,0,1500));
50 m_histo.push_back(
new TH1F(
"rec_p",
"reconstructed momentum, MeV/c",1500,0,1500));
52 m_histo.push_back(
new TH1F(
"n_emcparents",
"# of parents for reconstructed shower",20,0,20));
53 m_histo.push_back(
new TH1F(
"n_showers",
"# of showers for one true particle",20,0,20));
55 m_histo.push_back(
new TH1F(
"pdg_miss",
"Pdg of particles with # trk==0 and #showers > 0",6000,-3000,3000));
57 m_histo.push_back(
new TH1F(
"dE_true",
"True energy - shower energy",40,-2000,2000));
58 m_histo.push_back(
new TH1F(
"dE_rec",
"shower energy - sqrt(Prec**2+m_true**2)",40,-2000,2000));
60 m_histo.push_back(
new TH1F(
"E_true",
"True energy, MeV",100,0,1000));
61 m_histo.push_back(
new TH1F(
"E_rec",
"Rec energy, MeV",100,0,1000));
63 m_histo2.push_back(
new TH2F(
"deltap_p",
"#delta p/p vs. p, MeV",100,0,1000,20,0,2));
65 return StatusCode::SUCCESS;
71 MsgStream log(
msgSvc(), name());
74 SmartDataPtr<EventNavigator> navigator (eventSvc(),
"/Event/Navigator");
77 log << MSG::ERROR <<
" Unable to retrieve EventNavigator" << endreq;
78 return StatusCode::FAILURE;
81 log << MSG::INFO <<
"EventNavigator object" << endreq;
86 log << MSG::INFO <<
"=======================================================================" << endreq;
87 log << MSG::INFO <<
"MC Particles ===============================================================" << endreq;
90 SmartDataPtr<McParticleCol> mcParticles(eventSvc(),
"/Event/MC/McParticleCol");
93 log << MSG::ERROR <<
" Unable to retrieve McParticleCol" << endreq;
94 return StatusCode::FAILURE;
98 for( McParticleCol::iterator it = mcParticles->begin(); it != mcParticles->end(); it++ )
101 int pdg_code = (*it)->particleProperty();
104 double true_mom = (*it)->initialFourMomentum().vect().mag();
107 m_histo[5]->Fill(true_mom);
109 log<<MSG::INFO<<
"Retrieved McParticle # "<<(*it)->trackIndex()
110 <<
" PDG " << pdg_code <<
" of true momentum "
111 << true_mom <<
" GeV/c " <<endreq;
118 m_histo[2]->Fill(tracks.size());
120 log << MSG::INFO <<
" Found " << tracks.size() <<
" tracks and " << ktracks.size() <<
" Kalman tracks" << endreq;
123 for(
unsigned int i=0; i<ktracks.size(); i++)
128 log << MSG::INFO <<
"\t Track # " << i
129 <<
" id = " << ktracks[i]->trackId()
130 <<
" Pid " << ktracks[i]->getPidType()
131 <<
" Ptot " <<
momentum <<
" GeV/c" << endreq;
134 m_histo[0]->Fill(true_mom-
momentum);
137 m_histo2[0]->Fill(true_mom, fabs(true_mom-
momentum)/true_mom);
143 m_histo[8]->Fill(showers.size());
145 log << MSG::INFO <<
" Found " << showers.size() <<
" showers" << endreq;
147 for(
unsigned int i=0; i<showers.size(); i++)
149 double true_energy = (*it)->initialFourMomentum().e();
150 double rec_energy = showers[i]->energy()*1000;
152 log << MSG::INFO <<
"\t Shower # " << i
153 <<
" Id = " << showers[i]->getShowerId().get_value()
154 <<
" E = " << showers[i]->energy()*1000 <<
" MeV " << endreq;
156 m_histo[12]->Fill(true_energy);
157 m_histo[13]->Fill(rec_energy);
161 log << MSG::INFO <<
"MDC Tracks ==============================================================" << endreq;
164 SmartDataPtr<RecMdcKalTrackCol> mdcKalTracks(eventSvc(),
"/Event/Recon/RecMdcKalTrackCol");
167 log << MSG::ERROR <<
" Unable to retrieve MdcKalTrackCol" << endreq;
168 return StatusCode::SUCCESS;
171 for( RecMdcKalTrackCol::iterator it = mdcKalTracks->begin(); it != mdcKalTracks->end(); it++ )
175 log << MSG::INFO <<
"Retrieved " << particles.size() <<
" McParticles for for MdcKalTrack # "
176 << (*it)->trackId() <<
" of reconstructed momentum " << (*it)->p() <<
" GeV/c (PID="
177 << (*it)->getPidType() <<
")" << endreq;
180 m_histo[6]->Fill((*it)->p());
183 m_histo[1]->Fill(particles.size());
186 for(
unsigned int i=0; i<particles.size(); i++)
188 int pdg_code = particles[i]->particleProperty();
191 double true_mom = particles[i]->initialFourMomentum().vect().mag();
194 int relevance = navigator->getMcParticleRelevance(*it, particles[i]);
197 log << MSG::INFO <<
"\t" << pdg_code <<
" momentum "
198 << true_mom <<
" relevance " << relevance << endreq;
203 log << MSG::INFO <<
"EMC Showers ==============================================================" << endreq;
204 SmartDataPtr<RecEmcShowerCol> emcShowers(eventSvc(),
"/Event/Recon/RecEmcShowerCol");
207 log << MSG::ERROR <<
" Unable to retrieve EmcRecShowerCol" << endreq;
208 return StatusCode::SUCCESS;
212 for( RecEmcShowerCol::iterator it = emcShowers->begin(); it != emcShowers->end(); it++ )
215 log << MSG::INFO <<
"Retrieved McParticles for EmcShower # " << ij++
216 <<
" Id " << (*it)->getShowerId().get_value()
217 <<
" Energy = " << (*it)->energy() << endreq;
219 for(
unsigned int i=0; i<particles.size(); i++)
221 int pdg_code = particles[i]->particleProperty();
224 double true_e = particles[i]->initialFourMomentum().e();
227 int relevance = navigator->getMcParticleRelevance(*it, particles[i]);
229 log <<
"\t Particle " << i <<
" PDG " << pdg_code <<
" E=" << true_e
230 <<
" Relevance " << relevance << endreq;
234 m_histo[7]->Fill(particles.size());
237 log << MSG::INFO <<
"=======================================================================" << endreq;
239 return StatusCode::SUCCESS;
247 TFile of(m_fout.c_str(),
"RECREATE");
249 for(vector<TH1F*>::iterator it=m_histo.begin(); it!=m_histo.end(); it++)
251 for(vector<TH2F*>::iterator it=m_histo2.begin(); it!=m_histo2.end(); it++)
255 return StatusCode::SUCCESS;
**********INTEGER nmxhep !maximum number of particles DOUBLE PRECISION vhep INTEGER jdahep COMMON hepevt $ !serial number $ !number of particles $ !status code $ !particle ident KF $ !parent particles $ !childreen particles $ !four momentum
std::vector< const RecMdcTrack * > RecMdcTrackVector
std::vector< const Event::McParticle * > McParticleVector
std::vector< const RecMdcKalTrack * > RecMdcKalTrackVector
std::vector< const RecEmcShower * > RecEmcShowerVector
NavigationTestAlg(const std::string &name, ISvcLocator *pSvcLocator)