11#include "CLHEP/Random/RandFlat.h"
12#include "CLHEP/Units/PhysicalConstants.h"
17 const std::string& inputFile,
18 const std::vector<std::string>& generatorSettings):
53 std::cout <<
"=================================================================" << std::endl;
54 std::cout <<
"| | Total Number | Total Weight |" << std::endl;
55 std::cout <<
"|---------------------------------------------------------------|" << std::endl;
56 std::cout <<
"| Particles read from input file | ";
58 std::cout << std::setw(12) << std::setprecision(8) <<
m_wsums[
TOT_READ] <<
" |" << std::endl;
59 std::cout <<
"| Particles after cuts | ";
61 std::cout << std::setw(12) << std::setprecision(8) <<
m_wsums[
TOT_AFTER] <<
" |" << std::endl;
62 std::cout <<
"| Particles generated | ";
64 std::cout << std::setw(12) << std::setprecision(8) <<
m_wsums[
TOT_GEN] <<
" |" << std::endl;
65 std::cout <<
"=================================================================" << std::endl;
67 std::cout << std::setprecision(6);
79 if(
m_debug) std::cout <<
"Debug: Flipping event" << std::endl;
90 CLHEP::HepRandomEngine* engine) {
95 const double c = 2.99792458E+11;
97 std::vector<BeamHaloParticle>::iterator itr = beamHaloEvent->begin();
98 std::vector<BeamHaloParticle>::iterator itr_end = beamHaloEvent->end();
103 evt->weights().push_back((*itr).weight());
104 HepMC::FourVector primaryPosition = (*itr).positionAtPrimary();
105 evt->weights().push_back(primaryPosition.x());
106 evt->weights().push_back(primaryPosition.y());
107 evt->weights().push_back(primaryPosition.z());
108 evt->weights().push_back(primaryPosition.t());
112 for(;itr!=itr_end;++itr) {
113 HepMC::FourVector position = (*itr).positionAtScoringPlane();
114 HepMC::FourVector fourVector = (*itr).fourVector();
128 pz = fourVector.pz();
129 fourVector.setPz(-pz);
142 genVertex->add_particle_out(genParticle);
143 evt->add_vertex(genVertex);
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.
float m_flipProbability
Flip probability.
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.
bool m_enableFlip
Flag for flipping event.
virtual int genInitialize()
A function to initialise the generator.
BeamHaloGenerator(const HepPDT::ParticleDataTable *particleTable, const std::string &inputFile, const std::vector< std::string > &generatorSettings)
long m_counters[NUM_COUNTERS]
Particle or event counters of dimension enumCounters.
std::vector< std::string > m_generatorSettings
A vector of generator settings in string command form.
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.
bool m_enableSampling
Flag to enable or disable sampling.
const HepPDT::ParticleDataTable * m_particleTable
A pointer to the particle data table.
double m_interfacePlane
The position of the interface plane in mm.
virtual ~BeamHaloGenerator()
bool flipEvent(CLHEP::HepRandomEngine *engine)
A member function to check if the event should be flipped.
std::string m_bufferFileName
The name of the binary buffer file, needed for sampling from a converted file.
HepMC::GenVertex * GenVertexPtr
GenVertexPtr newGenVertexPtr(const HepMC::FourVector &pos=HepMC::FourVector(0.0, 0.0, 0.0, 0.0), const int i=0)
GenParticlePtr newGenParticlePtr(const HepMC::FourVector &mom=HepMC::FourVector(0.0, 0.0, 0.0, 0.0), int pid=0, int status=0)
GenParticle * GenParticlePtr