#include <AthenaHepMCtoG4EventAction.h>
Public Member Functions | |
AthenaHepMCtoG4EventAction () | |
AthenaHepMCtoG4EventAction (int) | |
~AthenaHepMCtoG4EventAction () | |
void | GeneratePrimaries (G4Event *anEvent) |
void | SetHepMCEvent (McEventCol::iterator) |
Private Attributes | |
const HepMC::GenEvent * | p_evt |
McEventCol::iterator | p_evtCollItr |
int | m_logLevel |
Definition at line 28 of file AthenaHepMCtoG4EventAction.h.
AthenaHepMCtoG4EventAction::AthenaHepMCtoG4EventAction | ( | ) |
Definition at line 37 of file AthenaHepMCtoG4EventAction.cpp.
00037 : 00038 m_logLevel( int(MSG::INFO) ) { 00039 }
AthenaHepMCtoG4EventAction::AthenaHepMCtoG4EventAction | ( | int | ) |
Definition at line 33 of file AthenaHepMCtoG4EventAction.cpp.
00033 : 00034 m_logLevel(level) { 00035 }
AthenaHepMCtoG4EventAction::~AthenaHepMCtoG4EventAction | ( | ) |
void AthenaHepMCtoG4EventAction::GeneratePrimaries | ( | G4Event * | anEvent | ) |
Definition at line 152 of file AthenaHepMCtoG4EventAction.cpp.
References Bes_Common::DEBUG, m_logLevel, p_evt, p_evtCollItr, v, and Bes_Common::WARNING.
00153 { 00154 if ( m_logLevel <= int(MSG::DEBUG) ) { 00155 std::cout << "AthenaHepMCtoG4EventAction: - Generating Primaries" 00156 << std::endl; 00157 } 00158 00159 00160 p_evt = (const HepMC::GenEvent *)(*p_evtCollItr); 00161 00162 00163 if (p_evt == 0) { 00164 00165 if ( m_logLevel <= int(MSG::WARNING) ) { 00166 std::cout << "AthenaHepMCtoG4EventAction: - HepMC ptr == null" 00167 << std::endl; 00168 } 00169 00170 return; 00171 00172 } 00173 00174 G4PrimaryVertex* vertex = new G4PrimaryVertex(0.,0.,0.,0.); 00175 00176 int n=0; 00177 for ( HepMC::GenEvent::vertex_const_iterator v = p_evt->vertices_begin(); 00178 v != p_evt->vertices_end(); ++v ) { 00179 bool IsGood=false; 00180 for (HepMC::GenVertex::particle_iterator it= 00181 (*v)->particles_begin(HepMC::children); 00182 it!=(*v)->particles_end(HepMC::children); 00183 it++) { 00184 00185 if (!(*it)->end_vertex() && (*it)->status()==1 ) { 00186 IsGood=true; 00187 break; 00188 } 00189 } 00190 00191 if (IsGood) { 00192 // std::cout << "found a good vertex, barcode: " << (*v)->barcode() 00193 // << std::endl; 00194 00195 for (HepMC::GenVertex::particle_iterator it= 00196 (*v)->particles_begin(HepMC::children); 00197 it!=(*v)->particles_end(HepMC::children); 00198 it++) { 00199 00200 if ( (*it)->status() != 1) continue; 00201 00202 int pdgcode=(*it)->pdg_id(); 00203 // GenVertex *dcy = (*it)->end_vertex(); 00204 // std::cout << "found a good particle, barcode: " << (*it)->barcode() 00205 // << " pdg: " << pdgcode << " status: " << (*it)->status() 00206 // << " end: "; 00207 // if (dcy != 0) { 00208 // std::cout << dcy->barcode(); 00209 // } else { 00210 // std::cout << "nil"; 00211 // } 00212 // std::cout << std::endl; 00213 00214 const G4ThreeVector& p=(*it)->momentum(); 00215 G4PrimaryParticle *part; 00216 if (pdgcode!=999) { 00217 part=new G4PrimaryParticle (pdgcode,p.x()*GeV,p.y()*GeV,p.z()*GeV); 00218 } else { 00219 G4ParticleDefinition *pdef = G4Geantino::GeantinoDefinition(); 00220 part=new G4PrimaryParticle (pdef,p.x()*GeV,p.y()*GeV,p.z()*GeV); 00221 } 00222 00223 vertex->SetPosition((*v)->position().x(), 00224 (*v)->position().y(), 00225 (*v)->position().z()); 00226 vertex->SetT0((*v)->position().t()); 00227 00228 vertex->SetPrimary(part); 00229 00230 n++; 00231 } 00232 } 00233 } 00234 anEvent->AddPrimaryVertex(vertex); 00235 00236 if ( m_logLevel <= int(MSG::DEBUG) ) { 00237 std::cout << "AthenaHepMCtoG4EventAction: - done. G4Event has " 00238 << n << " particles. " 00239 << std::endl; 00240 } 00241 00242 p_evtCollItr++; 00243 00244 }
void AthenaHepMCtoG4EventAction::SetHepMCEvent | ( | McEventCol::iterator | ) |
Definition at line 48 of file AthenaHepMCtoG4EventAction.cpp.
References Bes_Common::DEBUG, m_logLevel, and p_evtCollItr.
00048 { 00049 00050 if ( m_logLevel <= int(MSG::DEBUG) ) { 00051 std::cout << "AthenaHepMCtoG4EventAction: - Setting HepMC Event ptr" 00052 << std::endl; 00053 } 00054 00055 // p_evt = p; 00056 p_evtCollItr = p; 00057 00058 }
int AthenaHepMCtoG4EventAction::m_logLevel [private] |
Definition at line 43 of file AthenaHepMCtoG4EventAction.h.
Referenced by GeneratePrimaries(), and SetHepMCEvent().
const HepMC::GenEvent* AthenaHepMCtoG4EventAction::p_evt [private] |
McEventCol::iterator AthenaHepMCtoG4EventAction::p_evtCollItr [private] |
Definition at line 42 of file AthenaHepMCtoG4EventAction.h.
Referenced by GeneratePrimaries(), and SetHepMCEvent().