ATLAS Offline Software
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
BeamHaloGenerator Class Referenceabstract

An abstract base class to provide generic beam halo generator functionality. More...

#include <BeamHaloGenerator.h>

Inheritance diagram for BeamHaloGenerator:
Collaboration diagram for BeamHaloGenerator:

Public Member Functions

 BeamHaloGenerator (const HepPDT::ParticleDataTable *particleTable, const std::string &inputFile, const std::vector< std::string > &generatorSettings)
 
virtual ~BeamHaloGenerator ()
 
virtual int genInitialize ()
 A function to initialise the generator. More...
 
virtual int genFinalize ()
 A function to finalise the generator. More...
 
virtual int fillEvt (HepMC::GenEvent *evt, CLHEP::HepRandomEngine *engine)=0
 A function to create one event in HepMC format. More...
 
void setInterfacePlane (double interfacePlane)
 Set the position of the interface plane in mm. More...
 
void setEnableFlip (bool enableFlip)
 Turn on or off the event flipping code. More...
 
void setFlipProbability (float flipProbability)
 Set probability of flipping an event about Z=0. More...
 
void setEnableSampling (bool enableSampling)
 Turn on or off sampling from the input ASCII file. More...
 
void setBufferFileName (const std::string &bufferFileName)
 Set the name of the binary buffer file, needed for sampling from a converted file. More...
 
void setDebugEnable (bool debug)
 A function to turn on or off debug print out. More...
 

Protected Types

enum  enumGeneratorProcessIds {
  MARS_READ, MARS_SINGLE, MARS_SHOWER, FLUKA_READ,
  FLUKA_SINGLE, FLUKA_SHOWER
}
 An enum of generator process identifiers. More...
 
enum  enumCounters { TOT_READ, TOT_AFTER, TOT_GEN, NUM_COUNTERS }
 An enum of particle counter indices. More...
 

Protected Member Functions

virtual int readEvent (std::vector< BeamHaloParticle > *beamHaloEvent, CLHEP::HepRandomEngine *engine)=0
 A function to read one event in a simplified format. More...
 
virtual int readParticle (BeamHaloParticle *beamHaloParticle)=0
 A function to read one particle from the input ASCII file. More...
 
bool flipEvent (CLHEP::HepRandomEngine *engine)
 A member function to check if the event should be flipped. More...
 
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. More...
 

Protected Attributes

const HepPDT::ParticleDataTable * m_particleTable
 A pointer to the particle data table. More...
 
std::string m_inputFile
 Input file name. More...
 
double m_interfacePlane
 The position of the interface plane in mm. More...
 
bool m_enableFlip
 Flag for flipping event. More...
 
float m_flipProbability
 Flip probability. More...
 
bool m_enableSampling
 Flag to enable or disable sampling. More...
 
std::string m_bufferFileName
 The name of the binary buffer file, needed for sampling from a converted file. More...
 
BeamHaloParticleBufferm_beamHaloParticleBuffer
 Binary particle buffer for caching converted events. More...
 
AsciiInputm_asciiInput
 A pointer to an AsciiInput object, used to read data from the Ascii input file. More...
 
BeamHaloGeneratorSettingsm_beamHaloGeneratorSettings
 A pointer to a BeamHaloGeneratorSettings object used to filter particles. More...
 
long m_eventNumber
 A data member to count the event number. More...
 
long m_counters [NUM_COUNTERS]
 Particle or event counters of dimension enumCounters. More...
 
double m_wsums [NUM_COUNTERS]
 Sum of weights of particles or events of dimension enumCounters. More...
 
bool m_debug
 A flat to turn on or off debug print out. More...
 

Private Attributes

std::vector< std::string > m_generatorSettings
 A vector of generator settings in string command form. More...
 

Detailed Description

An abstract base class to provide generic beam halo generator functionality.

Author
W. H. Bell W.Bel.nosp@m.l@ce.nosp@m.rn.ch

Definition at line 31 of file BeamHaloGenerator.h.

Member Enumeration Documentation

◆ enumCounters

An enum of particle counter indices.

Enumerator
TOT_READ 
TOT_AFTER 
TOT_GEN 
NUM_COUNTERS 

Definition at line 141 of file BeamHaloGenerator.h.

141  {
142  TOT_READ,
143  TOT_AFTER,
144  TOT_GEN,
145  NUM_COUNTERS};

◆ enumGeneratorProcessIds

An enum of generator process identifiers.

_READ corresponds to no sampling and therefore simple conversion from input file to HepMC record.

Enumerator
MARS_READ 
MARS_SINGLE 
MARS_SHOWER 
FLUKA_READ 
FLUKA_SINGLE 
FLUKA_SHOWER 

Definition at line 86 of file BeamHaloGenerator.h.

86  {
87  MARS_READ,
90  FLUKA_READ,
92  FLUKA_SHOWER };

Constructor & Destructor Documentation

◆ BeamHaloGenerator()

BeamHaloGenerator::BeamHaloGenerator ( const HepPDT::ParticleDataTable *  particleTable,
const std::string &  inputFile,
const std::vector< std::string > &  generatorSettings 
)

Definition at line 16 of file BeamHaloGenerator.cxx.

18  :
19  m_particleTable(particleTable),
21  m_interfacePlane(0.),
22  m_enableFlip(false),
24  m_enableSampling(false),
25  m_bufferFileName("buffer.bin"),
27  m_asciiInput(0),
29  m_eventNumber(0),
30  m_debug(false),
32  for(int i=0;i<NUM_COUNTERS;i++) {
33  m_counters[i] = 0;
34  m_wsums[i] = 0.;
35  }
36 }

◆ ~BeamHaloGenerator()

BeamHaloGenerator::~BeamHaloGenerator ( )
virtual

Definition at line 40 of file BeamHaloGenerator.cxx.

Member Function Documentation

◆ convertEvent()

int BeamHaloGenerator::convertEvent ( std::vector< BeamHaloParticle > *  beamHaloEvent,
HepMC::GenEvent *  evt,
CLHEP::HepRandomEngine *  engine 
)
protected

A member function to convert a vector of beam halo particles into a GenEvent.

Definition at line 94 of file BeamHaloGenerator.cxx.

96  {
97  double pz;
98  bool flipFlag = flipEvent(engine);
99  HepMC::GenParticlePtr genParticle;
100  HepMC::GenVertexPtr genVertex;
101  const double c = 2.99792458E+11; // speed of light in mm/s
102 
103  std::vector<BeamHaloParticle>::iterator itr = beamHaloEvent->begin();
104  std::vector<BeamHaloParticle>::iterator itr_end = beamHaloEvent->end();
105 
106  if(itr != itr_end) {
107  // Take the primary information from the first particle in the event. If the event is more than one
108  // particle, the particles come from the same primary proton.
109  evt->weights().push_back((*itr).weight()); // event weight
110  HepMC::FourVector primaryPosition = (*itr).positionAtPrimary();
111  evt->weights().push_back(primaryPosition.x()); // Starting position of primary particle: x position (cm)
112  evt->weights().push_back(primaryPosition.y()); // Starting position of primary particle: y position (cm)
113  evt->weights().push_back(primaryPosition.z()); // Starting position of primary particle: z position (cm)
114  evt->weights().push_back(primaryPosition.t()); // Starting position of primary particle: t (s)
115  }
116 
117  // Append each particle to the GenEvent
118  for(;itr!=itr_end;++itr) {
119  HepMC::FourVector position = (*itr).positionAtScoringPlane();
120  HepMC::FourVector fourVector = (*itr).fourVector();
121 
122  if(!flipFlag) {
123  genParticle = HepMC::newGenParticlePtr(fourVector,
124  (*itr).pdgId(),
125  1);
126 
127  genVertex = HepMC::newGenVertexPtr(HepMC::FourVector(position.x(),
128  position.y(),
129  (position.z() + m_interfacePlane),
130  c*position.t() -1.0*std::fabs(m_interfacePlane)),
131  1);
132  }
133  else {
134  pz = fourVector.pz();
135  fourVector.setPz(-pz);
136 
137  genParticle = HepMC::newGenParticlePtr(fourVector,
138  (*itr).pdgId(),
139  1);
140 
141  genVertex = HepMC::newGenVertexPtr(HepMC::FourVector(position.x(),
142  position.y(),
143  -1.0*(position.z() + m_interfacePlane),
144  c*position.t() -1.0*std::fabs(m_interfacePlane)),
145  1);
146  }
147 
148  genVertex->add_particle_out(genParticle);
149  evt->add_vertex(genVertex);
150  }
151 
152  return 0;
153 }

◆ fillEvt()

virtual int BeamHaloGenerator::fillEvt ( HepMC::GenEvent *  evt,
CLHEP::HepRandomEngine *  engine 
)
pure virtual

A function to create one event in HepMC format.

Implemented in FlukaHaloGenerator, and MarsHaloGenerator.

◆ flipEvent()

bool BeamHaloGenerator::flipEvent ( CLHEP::HepRandomEngine *  engine)
protected

A member function to check if the event should be flipped.

Definition at line 80 of file BeamHaloGenerator.cxx.

80  {
81  if(!m_enableFlip) return false;
82 
83  // Check to see if the event should be flipped or not
84  if(CLHEP::RandFlat::shoot(engine) <= m_flipProbability) {
85  if(m_debug) std::cout << "Debug: Flipping event" << std::endl;
86  return true;
87  }
88 
89  return false;
90 }

◆ genFinalize()

int BeamHaloGenerator::genFinalize ( )
virtual

A function to finalise the generator.

Reimplemented in FlukaHaloGenerator, and MarsHaloGenerator.

Definition at line 57 of file BeamHaloGenerator.cxx.

57  {
58 
59  std::cout << "=================================================================" << std::endl;
60  std::cout << "| | Total Number | Total Weight |" << std::endl;
61  std::cout << "|---------------------------------------------------------------|" << std::endl;
62  std::cout << "| Particles read from input file | ";
63  std::cout << std::setw(12) << m_counters[TOT_READ] << " | ";
64  std::cout << std::setw(12) << std::setprecision(8) << m_wsums[TOT_READ] << " |" << std::endl;
65  std::cout << "| Particles after cuts | ";
66  std::cout << std::setw(12) << m_counters[TOT_AFTER] << " | ";
67  std::cout << std::setw(12) << std::setprecision(8) << m_wsums[TOT_AFTER] << " |" << std::endl;
68  std::cout << "| Particles generated | ";
69  std::cout << std::setw(12) << m_counters[TOT_GEN] << " | ";
70  std::cout << std::setw(12) << std::setprecision(8) << m_wsums[TOT_GEN] << " |" << std::endl;
71  std::cout << "=================================================================" << std::endl;
72 
73  std::cout << std::setprecision(6);
74 
75  return 0;
76 }

◆ genInitialize()

int BeamHaloGenerator::genInitialize ( )
virtual

A function to initialise the generator.

Reimplemented in FlukaHaloGenerator, and MarsHaloGenerator.

Definition at line 48 of file BeamHaloGenerator.cxx.

◆ readEvent()

virtual int BeamHaloGenerator::readEvent ( std::vector< BeamHaloParticle > *  beamHaloEvent,
CLHEP::HepRandomEngine *  engine 
)
protectedpure virtual

A function to read one event in a simplified format.

Implemented in FlukaHaloGenerator, and MarsHaloGenerator.

◆ readParticle()

virtual int BeamHaloGenerator::readParticle ( BeamHaloParticle beamHaloParticle)
protectedpure virtual

A function to read one particle from the input ASCII file.

Implemented in FlukaHaloGenerator, and MarsHaloGenerator.

◆ setBufferFileName()

void BeamHaloGenerator::setBufferFileName ( const std::string &  bufferFileName)
inline

Set the name of the binary buffer file, needed for sampling from a converted file.

Definition at line 76 of file BeamHaloGenerator.h.

76 { m_bufferFileName = bufferFileName; }

◆ setDebugEnable()

void BeamHaloGenerator::setDebugEnable ( bool  debug)
inline

A function to turn on or off debug print out.

Definition at line 79 of file BeamHaloGenerator.h.

79 { m_debug = debug; }

◆ setEnableFlip()

void BeamHaloGenerator::setEnableFlip ( bool  enableFlip)
inline

Turn on or off the event flipping code.

Definition at line 66 of file BeamHaloGenerator.h.

66 { m_enableFlip = enableFlip; }

◆ setEnableSampling()

void BeamHaloGenerator::setEnableSampling ( bool  enableSampling)
inline

Turn on or off sampling from the input ASCII file.

Definition at line 72 of file BeamHaloGenerator.h.

72 { m_enableSampling = enableSampling; }

◆ setFlipProbability()

void BeamHaloGenerator::setFlipProbability ( float  flipProbability)
inline

Set probability of flipping an event about Z=0.

Definition at line 69 of file BeamHaloGenerator.h.

◆ setInterfacePlane()

void BeamHaloGenerator::setInterfacePlane ( double  interfacePlane)
inline

Set the position of the interface plane in mm.

Definition at line 63 of file BeamHaloGenerator.h.

Member Data Documentation

◆ m_asciiInput

AsciiInput* BeamHaloGenerator::m_asciiInput
protected

A pointer to an AsciiInput object, used to read data from the Ascii input file.

Definition at line 131 of file BeamHaloGenerator.h.

◆ m_beamHaloGeneratorSettings

BeamHaloGeneratorSettings* BeamHaloGenerator::m_beamHaloGeneratorSettings
protected

A pointer to a BeamHaloGeneratorSettings object used to filter particles.

Definition at line 135 of file BeamHaloGenerator.h.

◆ m_beamHaloParticleBuffer

BeamHaloParticleBuffer* BeamHaloGenerator::m_beamHaloParticleBuffer
protected

Binary particle buffer for caching converted events.

Definition at line 127 of file BeamHaloGenerator.h.

◆ m_bufferFileName

std::string BeamHaloGenerator::m_bufferFileName
protected

The name of the binary buffer file, needed for sampling from a converted file.

Definition at line 124 of file BeamHaloGenerator.h.

◆ m_counters

long BeamHaloGenerator::m_counters[NUM_COUNTERS]
protected

Particle or event counters of dimension enumCounters.

Definition at line 148 of file BeamHaloGenerator.h.

◆ m_debug

bool BeamHaloGenerator::m_debug
protected

A flat to turn on or off debug print out.

Definition at line 154 of file BeamHaloGenerator.h.

◆ m_enableFlip

bool BeamHaloGenerator::m_enableFlip
protected

Flag for flipping event.

Definition at line 114 of file BeamHaloGenerator.h.

◆ m_enableSampling

bool BeamHaloGenerator::m_enableSampling
protected

Flag to enable or disable sampling.

Definition at line 120 of file BeamHaloGenerator.h.

◆ m_eventNumber

long BeamHaloGenerator::m_eventNumber
protected

A data member to count the event number.

Definition at line 138 of file BeamHaloGenerator.h.

◆ m_flipProbability

float BeamHaloGenerator::m_flipProbability
protected

Flip probability.

Definition at line 117 of file BeamHaloGenerator.h.

◆ m_generatorSettings

std::vector<std::string> BeamHaloGenerator::m_generatorSettings
private

A vector of generator settings in string command form.

Definition at line 159 of file BeamHaloGenerator.h.

◆ m_inputFile

std::string BeamHaloGenerator::m_inputFile
protected

Input file name.

Definition at line 108 of file BeamHaloGenerator.h.

◆ m_interfacePlane

double BeamHaloGenerator::m_interfacePlane
protected

The position of the interface plane in mm.

Definition at line 111 of file BeamHaloGenerator.h.

◆ m_particleTable

const HepPDT::ParticleDataTable* BeamHaloGenerator::m_particleTable
protected

A pointer to the particle data table.

Definition at line 105 of file BeamHaloGenerator.h.

◆ m_wsums

double BeamHaloGenerator::m_wsums[NUM_COUNTERS]
protected

Sum of weights of particles or events of dimension enumCounters.

Definition at line 151 of file BeamHaloGenerator.h.


The documentation for this class was generated from the following files:
HepMC::GenVertexPtr
HepMC::GenVertex * GenVertexPtr
Definition: GenVertex.h:59
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
BeamHaloGenerator::m_enableFlip
bool m_enableFlip
Flag for flipping event.
Definition: BeamHaloGenerator.h:114
BeamHaloGeneratorSettings
A class to read a vector of strings defining particle filtering settings and provide a method for fil...
Definition: BeamHaloGeneratorSettings.h:25
BeamHaloGenerator::m_wsums
double m_wsums[NUM_COUNTERS]
Sum of weights of particles or events of dimension enumCounters.
Definition: BeamHaloGenerator.h:151
BeamHaloGenerator::m_interfacePlane
double m_interfacePlane
The position of the interface plane in mm.
Definition: BeamHaloGenerator.h:111
BeamHaloGenerator::m_enableSampling
bool m_enableSampling
Flag to enable or disable sampling.
Definition: BeamHaloGenerator.h:120
BeamHaloGenerator::MARS_SHOWER
@ MARS_SHOWER
Definition: BeamHaloGenerator.h:89
BeamHaloGenerator::m_bufferFileName
std::string m_bufferFileName
The name of the binary buffer file, needed for sampling from a converted file.
Definition: BeamHaloGenerator.h:124
HepMC::GenParticlePtr
GenParticle * GenParticlePtr
Definition: GenParticle.h:37
BeamHaloGenerator::m_counters
long m_counters[NUM_COUNTERS]
Particle or event counters of dimension enumCounters.
Definition: BeamHaloGenerator.h:148
BeamHaloGenerator::TOT_AFTER
@ TOT_AFTER
Definition: BeamHaloGenerator.h:143
LArG4FSStartPointFilter.evt
evt
Definition: LArG4FSStartPointFilter.py:42
BeamHaloGenerator::FLUKA_READ
@ FLUKA_READ
Definition: BeamHaloGenerator.h:90
BeamHaloGenerator::TOT_GEN
@ TOT_GEN
Definition: BeamHaloGenerator.h:144
BeamHaloGenerator::FLUKA_SHOWER
@ FLUKA_SHOWER
Definition: BeamHaloGenerator.h:92
BeamHaloGenerator::MARS_READ
@ MARS_READ
Definition: BeamHaloGenerator.h:87
BeamHaloGenerator::m_asciiInput
AsciiInput * m_asciiInput
A pointer to an AsciiInput object, used to read data from the Ascii input file.
Definition: BeamHaloGenerator.h:131
jobOptions_CavernBackground.generatorSettings
generatorSettings
Definition: jobOptions_CavernBackground.py:35
BeamHaloGenerator::m_particleTable
const HepPDT::ParticleDataTable * m_particleTable
A pointer to the particle data table.
Definition: BeamHaloGenerator.h:105
CaloCondBlobAlgs_fillNoiseFromASCII.inputFile
string inputFile
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:17
HepMC::newGenVertexPtr
GenVertexPtr newGenVertexPtr(const HepMC::FourVector &pos=HepMC::FourVector(0.0, 0.0, 0.0, 0.0), const int i=0)
Definition: GenVertex.h:64
lumiFormat.i
int i
Definition: lumiFormat.py:85
BeamHaloGenerator::MARS_SINGLE
@ MARS_SINGLE
Definition: BeamHaloGenerator.h:88
BeamHaloGenerator::m_debug
bool m_debug
A flat to turn on or off debug print out.
Definition: BeamHaloGenerator.h:154
BeamHaloGenerator::m_generatorSettings
std::vector< std::string > m_generatorSettings
A vector of generator settings in string command form.
Definition: BeamHaloGenerator.h:159
BeamHaloGenerator::m_beamHaloGeneratorSettings
BeamHaloGeneratorSettings * m_beamHaloGeneratorSettings
A pointer to a BeamHaloGeneratorSettings object used to filter particles.
Definition: BeamHaloGenerator.h:135
Amg::pz
@ pz
Definition: GeoPrimitives.h:40
BeamHaloGenerator::m_flipProbability
float m_flipProbability
Flip probability.
Definition: BeamHaloGenerator.h:117
BeamHaloGenerator::m_eventNumber
long m_eventNumber
A data member to count the event number.
Definition: BeamHaloGenerator.h:138
debug
const bool debug
Definition: MakeUncertaintyPlots.cxx:53
jobOptions_CavernBackground.interfacePlane
interfacePlane
Definition: jobOptions_CavernBackground.py:23
AsciiInput
A class to provide read access to an ASCII input file.
Definition: AsciiInput.h:18
BeamHaloGenerator::NUM_COUNTERS
@ NUM_COUNTERS
Definition: BeamHaloGenerator.h:145
HepMC::newGenParticlePtr
GenParticlePtr newGenParticlePtr(const HepMC::FourVector &mom=HepMC::FourVector(0.0, 0.0, 0.0, 0.0), int pid=0, int status=0)
Definition: GenParticle.h:39
BeamHaloGenerator::FLUKA_SINGLE
@ FLUKA_SINGLE
Definition: BeamHaloGenerator.h:91
jobOptions_CavernBackground.flipProbability
flipProbability
Definition: jobOptions_CavernBackground.py:24
BeamHaloGenerator::m_inputFile
std::string m_inputFile
Input file name.
Definition: BeamHaloGenerator.h:108
BeamHaloGenerator::m_beamHaloParticleBuffer
BeamHaloParticleBuffer * m_beamHaloParticleBuffer
Binary particle buffer for caching converted events.
Definition: BeamHaloGenerator.h:127
python.compressB64.c
def c
Definition: compressB64.py:93
BeamHaloGenerator::flipEvent
bool flipEvent(CLHEP::HepRandomEngine *engine)
A member function to check if the event should be flipped.
Definition: BeamHaloGenerator.cxx:80
BeamHaloGenerator::TOT_READ
@ TOT_READ
Definition: BeamHaloGenerator.h:142