64 std::vector<Particle*>& particles)
override ;
76 #include <CLHEP/Units/SystemOfUnits.h>
77 #include <CLHEP/Units/PhysicalConstants.h>
93 m_input.open(nam.c_str(), std::ifstream::in);
94 if ( !m_input.good() ) {
95 std::string err =
"+++ Geant4EventReaderGuineaPig: Failed to open input stream:"+nam+
96 " Error:"+std::string(strerror(errno));
97 throw std::runtime_error(err);
102 Geant4EventReaderGuineaPig::~Geant4EventReaderGuineaPig() {
113 printout(INFO,
"EventReader",
"--- Will read all particles in pairs file into one event " );
115 printout(INFO,
"EventReader",
"--- Will read %d particles per event from pairs file ",
m_part_num );
123 printout(DEBUG,
"EventReader",
" move to event_number: %d , m_currEvent %d",
130 printout(ERROR,
"EventReader",
"--- Cannot skip to event %d in GuineaPig file without parameter 'ParticlesPerEvent' being set ! ", event_number );
137 unsigned nSkipParticles =
m_part_num * event_number ;
139 printout(INFO,
"EventReader",
"--- Will skip first %d events, i.e. %d particles ", event_number , nSkipParticles );
146 for (
unsigned i = 0; i<nSkipParticles; ++i){
147 if (
m_input.ignore(std::numeric_limits<std::streamsize>::max(),
m_input.widen(
'\n'))){
164 std::vector<Particle*>& particles) {
169 m_part_num = std::numeric_limits<int>::max() ;
188 for(
int counter = 0; counter <
m_part_num ; ++counter ){
191 std::string lineStr ;
192 std::getline(
m_input, lineStr ) ;
203 std::transform(lineStr.begin(), lineStr.end(), lineStr.begin(), ::tolower);
204 if( lineStr.find(
"nan") != std::string::npos){
206 printout(WARNING,
"EventReader",
"### Read line with 'nan' entries - particle will be ignored ! " ) ;
209 std::stringstream m_input_str( lineStr ) ;
211 m_input_str >> Energy
212 >> betaX >> betaY >> betaZ
213 >> posX >> posY >> posZ ;
233 p->pex = p->psx = betaX*TMath::Abs(Energy)*CLHEP::GeV;
234 p->pey = p->psy = betaY*TMath::Abs(Energy)*CLHEP::GeV;
235 p->pez = p->psz = betaZ*TMath::Abs(Energy)*CLHEP::GeV;
238 p->mass = 0.0005109989461*CLHEP::GeV;
249 p->vsx = posX*CLHEP::nm;
250 p->vsy = posY*CLHEP::nm;
251 p->vsz = posZ*CLHEP::nm;
257 vtx->time = p->time ;
259 vtx->out.insert( p->id );
269 particles.emplace_back(p);
272 vertices.emplace_back(vtx);