12#include "CLHEP/Random/RandFlat.h"
16 const std::string& inputFile,
17 const std::vector<std::string>& generatorSettings):
35 std::cout <<
"Error: Could not open ascii input file " <<
m_inputFile << std::endl;
39 std::cout <<
"Info: Reading ascii input file " <<
m_inputFile << std::endl;
48 CLHEP::HepRandomEngine* engine) {
49 std::vector<BeamHaloParticle> beamHaloEvent;
53 if((ret_val =
readEvent(&beamHaloEvent, engine)) != 0)
return ret_val;
88 std::cout <<
"Warning: FlukaHaloGenerator::readParticle is not yet available: "<< beamHaloParticle << std::endl;
95 CLHEP::HepRandomEngine* engine) {
99 beamHaloEvent->clear();
109 std::cout <<
"Error: Conversion from FlukaParticle to BeamHaloParticle failed." << std::endl;
113 beamHaloEvent->push_back(beamHaloParticle);
123 std::vector<std::string> row;
124 bool endOfFile =
false;
128 if(row.size() == 0) {
162 std::cout <<
"Error: Conversion from FlukaParticle to BeamHaloParticle failed." << std::endl;
167 beamHaloEvent->push_back(beamHaloParticle);
175 if(beamHaloEvent->size() == 0) {
176 std::cout <<
"Error: No particles read from " <<
m_inputFile << std::endl;
184 std::vector<BeamHaloParticle>::iterator itr = beamHaloEvent->begin();
185 std::vector<BeamHaloParticle>::iterator itr_end = beamHaloEvent->end();
187 for(;itr!=itr_end;++itr) {
188 beamHaloParticle = *itr;
194 if(
m_debug) std::cout <<
"Debug: Particle fails generator settings cuts." << std::endl;
208 if((ret_val =
readEvent(beamHaloEvent, engine)) != 0)
return ret_val;
long m_eventNumber
A data member to count the event number.
double m_wsums[NUM_COUNTERS]
Sum of weights of particles or events of dimension enumCounters.
int convertEvent(std::vector< BeamHaloParticle > *beamHaloEvent, HepMC::GenEvent *evt, CLHEP::HepRandomEngine *engine)
A member function to convert a vector of beam halo particles into a GenEvent.
std::unique_ptr< AsciiInput > m_asciiInput
A pointer to an AsciiInput object, used to read data from the Ascii input file.
std::string m_inputFile
Input file name.
virtual int genInitialize()
A function to initialise the generator.
BeamHaloGenerator(const std::string &inputFile, const std::vector< std::string > &generatorSettings)
long m_counters[NUM_COUNTERS]
Particle or event counters of dimension enumCounters.
virtual int genFinalize()
A function to finalise the generator.
bool m_debug
A flat to turn on or off debug print out.
std::unique_ptr< BeamHaloGeneratorSettings > m_beamHaloGeneratorSettings
A pointer to a BeamHaloGeneratorSettings object used to filter particles.
A class to describe a generic beam halo particle.
int fill(MarsParticle *marsParticle)
A function to fill the data members from an input MarsParticle object.
FlukaParticle m_lastFlukaParticle
virtual int readParticle(BeamHaloParticle *beamHaloParticle)
A function to read one particle from the input ASCII file.
FlukaHaloGenerator(int type, const std::string &inputFile, const std::vector< std::string > &generatorSettings)
virtual int genInitialize()
A function to initialise the generator.
virtual int fillEvt(HepMC::GenEvent *evt, CLHEP::HepRandomEngine *engine)
A function to create one event in HepMC format.
virtual int genFinalize()
A function to finalise the generator.
virtual int readEvent(std::vector< BeamHaloParticle > *beamHaloEvent, CLHEP::HepRandomEngine *engine)
A function to read one event in a simplified format.
FlukaParticle m_flukaParticle
void set_signal_process_id(GenEvent *e, const int i=0)
HepMC3::GenEvent GenEvent