ATLAS Offline Software
Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
BeamHaloGeneratorSettings Class Reference

A class to read a vector of strings defining particle filtering settings and provide a method for filtering particles based on type and kinematics. More...

#include <BeamHaloGeneratorSettings.h>

Collaboration diagram for BeamHaloGeneratorSettings:

Public Member Functions

 BeamHaloGeneratorSettings (const std::vector< std::string > &settings)
 Construct a class with a vector of string settings to filter particles. More...
 
int parseSettings (void)
 A function to parse the settings using the vector of strings given to the constructor of this class. More...
 
bool checkParticle (BeamHaloParticle *beamHaloParticle)
 Check if the supplied beam halo particle passes the generator settings. More...
 
void printSettings (void)
 Print a summary of the current settings. More...
 

Private Types

enum  enumShapeRequirements { NONE, CYLINDER }
 An enum mapped to different shape requirements. More...
 
enum  enumLimits {
  PX_LIMIT, PY_LIMIT, PZ_LIMIT, E_LIMIT,
  X_LIMIT, Y_LIMIT, Z_LIMIT, PT_LIMIT,
  PHI_LIMIT, ETA_LIMIT, R_LIMIT, W_LIMIT,
  ENUM_LIMITS_SIZE
}
 

Private Member Functions

int parseLimitSetting (std::vector< std::string > *commandVector)
 A function to read the limit settings from the supplied vector of strings. More...
 
bool checkCylinder (BeamHaloParticle *beamHaloParticle)
 A function to check if a particle is within a cylinder. More...
 
bool checkSetting (int index, double value)
 A function to check if a particle is within a range. More...
 

Private Attributes

std::vector< std::string > m_generatorSettings
 A vector of strings to configure the generator settings. More...
 
std::vector< long > m_allowedPdgIds
 An allowed set of PDG ids where any empty vector implies all PDG ids are allowed. More...
 
std::vector< std::pair< float, float > > m_limits
 Minimum and maximum limits. More...
 
std::vector< std::pair< bool, bool > > m_limitsEnabled
 A vector of flags to signal if a limit should be used or not. More...
 
int m_shapeRequirement
 A variable to store the volume shape requirement. More...
 
bool m_settingsParsed
 A flag to check if the settings have been parsed or not. More...
 

Static Private Attributes

static const std::string m_limitNames [ENUM_LIMITS_SIZE]
 The name of the limits. More...
 

Detailed Description

A class to read a vector of strings defining particle filtering settings and provide a method for filtering particles based on type and kinematics.

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

Definition at line 25 of file BeamHaloGeneratorSettings.h.

Member Enumeration Documentation

◆ enumLimits

Enumerator
PX_LIMIT 
PY_LIMIT 
PZ_LIMIT 
E_LIMIT 
X_LIMIT 
Y_LIMIT 
Z_LIMIT 
PT_LIMIT 
PHI_LIMIT 
ETA_LIMIT 
R_LIMIT 
W_LIMIT 
ENUM_LIMITS_SIZE 

Definition at line 51 of file BeamHaloGeneratorSettings.h.

51  {
52  PX_LIMIT,
53  PY_LIMIT,
54  PZ_LIMIT,
55  E_LIMIT,
56  X_LIMIT,
57  Y_LIMIT,
58  Z_LIMIT,
59  PT_LIMIT,
60  PHI_LIMIT,
61  ETA_LIMIT,
62  R_LIMIT,
63  W_LIMIT,

◆ enumShapeRequirements

An enum mapped to different shape requirements.

Enumerator
NONE 
CYLINDER 

Definition at line 47 of file BeamHaloGeneratorSettings.h.

47  {
48  NONE,
49  CYLINDER};

Constructor & Destructor Documentation

◆ BeamHaloGeneratorSettings()

BeamHaloGeneratorSettings::BeamHaloGeneratorSettings ( const std::vector< std::string > &  settings)

Construct a class with a vector of string settings to filter particles.

Definition at line 26 of file BeamHaloGeneratorSettings.cxx.

26  :
27  m_generatorSettings(settings),
29  m_limits(),
32  m_settingsParsed(false) {
33 
34  // Initialise the lower and upper limits as zero, and disabled.
35  for(int i=0;i<ENUM_LIMITS_SIZE;i++) {
36  m_limits.push_back(std::make_pair(0.,0.));
37  m_limitsEnabled.push_back(std::make_pair(false,false));
38  }
39 }

Member Function Documentation

◆ checkCylinder()

bool BeamHaloGeneratorSettings::checkCylinder ( BeamHaloParticle beamHaloParticle)
private

A function to check if a particle is within a cylinder.

Definition at line 187 of file BeamHaloGeneratorSettings.cxx.

187  {
188  double rmin = m_limits[R_LIMIT].first;
189  double rmax = m_limits[R_LIMIT].second;
190  double zmin = m_limits[Z_LIMIT].first;
191  double zmax = m_limits[Z_LIMIT].second;
192 
193  // Check if the particle radius at the scoring place is outside the
194  // outer radius of the cylinder and the particle trajectory is away
195  // from the cylinder reject the particle.
196  if(beamHaloParticle->positionAtScoringPlane().perp() > rmax &&
197  beamHaloParticle->fourVector().theta() > 0.) return false;
198 
199  // If the particle has no pT then check if it is inside the radius
200  // of the cylinder.
201  if(beamHaloParticle->fourVector().perp() == 0.) {
202  if(beamHaloParticle->positionAtScoringPlane().perp() < rmin ||
203  beamHaloParticle->positionAtScoringPlane().perp() > rmin) {
204  return false;
205  }
206  else {
207  return true;
208  }
209  }
210 
211  // r = sqrt(x^2 + y^2)
212  //
213  // tan(theta) = pT/pz
214  // tan(theta) = r/z
215  //
216  // z = (r*pz)/pT
217 
218  // The z position where the particle crosses the inner radius.
219  double innerZ = (rmin*beamHaloParticle->fourVector().z())/beamHaloParticle->fourVector().perp();
220 
221  // The z position where the particle crosses the outer radius.
222  double outerZ = (rmax*beamHaloParticle->fourVector().z())/beamHaloParticle->fourVector().perp();
223 
224  // If the trajectory of the particle crosses either the inner or
225  // outer surface within the length of the cylinder keep it.
226  if((innerZ >= zmin && innerZ <= zmax) ||
227  (outerZ >= zmin && outerZ <= zmax)) {
228  return true;
229  }
230 
231  return false;
232 }

◆ checkParticle()

bool BeamHaloGeneratorSettings::checkParticle ( BeamHaloParticle beamHaloParticle)

Check if the supplied beam halo particle passes the generator settings.

Definition at line 139 of file BeamHaloGeneratorSettings.cxx.

139  {
140  if(!m_settingsParsed) {
141  if(parseSettings() != 0) return false;
142  }
143 
144  // Search the allowed PDG id list if it has been defined.
145  if(m_allowedPdgIds.size() != 0) {
148  while(itr!=itr_end) {
149  if(beamHaloParticle->pdgId() == (*itr)) break;
150  ++itr;
151  }
152  if(itr==itr_end) {
153  return false;
154  }
155  }
156 
157  // First implement the cuts which are not related to the particle
158  // trajectory.
159  if(!checkSetting(W_LIMIT, std::abs(beamHaloParticle->weight()))) return false;
160  if(!checkSetting(PX_LIMIT, std::abs(beamHaloParticle->fourVector().px()))) return false;
161  if(!checkSetting(PY_LIMIT, std::abs(beamHaloParticle->fourVector().py()))) return false;
162  if(!checkSetting(PZ_LIMIT, std::abs(beamHaloParticle->fourVector().pz()))) return false;
163  if(!checkSetting(E_LIMIT, std::abs(beamHaloParticle->fourVector().e()))) return false;
164  if(!checkSetting(PT_LIMIT, beamHaloParticle->fourVector().perp())) return false;
165  if(!checkSetting(ETA_LIMIT, std::abs(beamHaloParticle->fourVector().pseudoRapidity()))) return false;
166  if(!checkSetting(PHI_LIMIT, std::abs(beamHaloParticle->fourVector().phi()))) return false;
167 
168 
169  // Require the selection at the scoring plane.
170  if(m_shapeRequirement == NONE) {
171  if(!checkSetting(X_LIMIT, std::abs(beamHaloParticle->positionAtScoringPlane().x()))) return false;
172  if(!checkSetting(Y_LIMIT, std::abs(beamHaloParticle->positionAtScoringPlane().y()))) return false;
173  if(!checkSetting(R_LIMIT, beamHaloParticle->positionAtScoringPlane().perp())) return false;
174  }
175  else if(m_shapeRequirement == CYLINDER) {
176  if(!checkCylinder(beamHaloParticle)) return false;
177  }
178  else {
179  std::cerr << "Warning: m_shapeRequirement = " << m_shapeRequirement << " is an unknown requirement." << std::endl;
180  }
181 
182  return true;
183 }

◆ checkSetting()

bool BeamHaloGeneratorSettings::checkSetting ( int  index,
double  value 
)
private

A function to check if a particle is within a range.

Definition at line 236 of file BeamHaloGeneratorSettings.cxx.

236  {
237  if(index >= ENUM_LIMITS_SIZE) {
238  std::cerr << "Error: the index " << index << " is out of range." << std::endl;
239  return false;
240  }
241 
242  if(m_limitsEnabled[index].first && value < m_limits[index].first) return false;
243  if(m_limitsEnabled[index].second && value >= m_limits[index].second) return false;
244 
245  return true;
246 }

◆ parseLimitSetting()

int BeamHaloGeneratorSettings::parseLimitSetting ( std::vector< std::string > *  commandVector)
private

A function to read the limit settings from the supplied vector of strings.

Definition at line 98 of file BeamHaloGeneratorSettings.cxx.

98  {
99  std::vector<std::string>::iterator itr = commandVector->begin();
100  std::vector<std::string>::iterator itr_end = commandVector->end();
101 
102  int i = 0;
103  while(i<ENUM_LIMITS_SIZE) {
104  if((*itr) == m_limitNames[i]) break;
105  i++;
106  }
107 
108  if(i == ENUM_LIMITS_SIZE) {
109  std::cerr << "Error: " << (*itr) << " is an un-known generator setting." << std::endl;
110  return 1;
111  }
112 
113  // Look for the lower limit
114  ++itr;
115  if(itr==itr_end) {
116  std::cerr << "Warning: " << m_limitNames[i] << " was not followed by a lower or upper limit." << std::endl;
117  return 0;
118  }
119 
120  // Enable the lower limit.
121  m_limits[i] = std::make_pair(AsciiInput::strToDouble(*itr),0.);
122  m_limitsEnabled[i] = std::make_pair(true,false);
123 
124  // Look for the upper limit
125  ++itr;
126  if(itr==itr_end) { // no upper limit.
127  return 0;
128  }
129 
130  // Enable the upper limit.
131  m_limits[i].second = AsciiInput::strToDouble(*itr);
132  m_limitsEnabled[i].second = true;
133 
134  return 0;
135 }

◆ parseSettings()

int BeamHaloGeneratorSettings::parseSettings ( void  )

A function to parse the settings using the vector of strings given to the constructor of this class.

Returns
0 if successful and a status code otherwise

Definition at line 43 of file BeamHaloGeneratorSettings.cxx.

43  {
44  std::vector<std::string> strVector;
49 // double upperLimit, lowerLimit;
50 
51  // Loop over all settings.
52  row_itr = m_generatorSettings.begin();
53  row_itr_end = m_generatorSettings.end();
54  for(;row_itr!=row_itr_end;++row_itr) {
55  strVector.clear();
56  strVector = AsciiInput::strToStrVec(*row_itr);
57 
58  if(strVector.size() == 0) continue;
59  if(strVector.size() == 1) {
60  std::cerr << "A generator setting must be followed by a value" << std::endl;
61  continue;
62  }
63 
64 // lowerLimit = -1.; upperLimit = -1.1; // Disable limits by default;
65 
66  col_itr = strVector.begin();
67  col_itr_end = strVector.end();
68 
69  if((*col_itr) == "allowedPdgId") {
70  ++col_itr;
71  for(;col_itr!=col_itr_end;++col_itr) {
72  m_allowedPdgIds.push_back(AsciiInput::strToLong(*col_itr));
73  }
74  }
75  else if((*col_itr) == "shape") {
76  ++col_itr;
77  if((*col_itr) == "cylinder") {
79  }
80  else {
81  std::cerr << "Warning: unknown shape requirement \"" << (*col_itr) << "\" ignored." << std::endl;
82  }
83  }
84  else {
85  parseLimitSetting(&strVector);
86  }
87  }
88 
89  printSettings();
90 
91  m_settingsParsed = true;
92 
93  return 0;
94 }

◆ printSettings()

void BeamHaloGeneratorSettings::printSettings ( void  )

Print a summary of the current settings.

Definition at line 250 of file BeamHaloGeneratorSettings.cxx.

250  {
251  std::cout << "============== BeamHaloGeneratorSettings ==============" << std::endl;
252  std::cout << " allowedPdfIds: ";
253  if(m_allowedPdgIds.size() != 0) {
254  std::vector<long>::iterator pdgId_itr = m_allowedPdgIds.begin();
255  std::vector<long>::iterator pdgId_itr_end = m_allowedPdgIds.end();
256  for(;pdgId_itr != pdgId_itr_end; ++pdgId_itr) {
257  std::cout << (*pdgId_itr) << " ";
258  }
259  std::cout << std::endl;
260  }
261  else {
262  std::cout << "All PDG IDs are allowed." << std::endl;
263  }
264 
265  std::cout << " shapeRequirement: ";
266  switch (m_shapeRequirement) {
267  case(NONE) : std::cout << "NONE"; break;
268  case(CYLINDER) : std::cout << "CYLINDER"; break;
269  default : std::cout << "UNKNOWN"; break;
270  }
271  std::cout << std::endl;
272 
273  for(int i=0;i<ENUM_LIMITS_SIZE;i++) {
274  std::cout << " " << m_limitNames[i] << ": {";
275  if(!m_limitsEnabled[i].first) std::cout << "disabled, ";
276  else std::cout << m_limits[i].first << ", ";
277  if(!m_limitsEnabled[i].second) std::cout << "disabled}";
278  else std::cout << m_limits[i].second << "}";
279  std::cout << std::endl;
280  }
281  std::cout << "=======================================================" << std::endl;
282 }

Member Data Documentation

◆ m_allowedPdgIds

std::vector<long> BeamHaloGeneratorSettings::m_allowedPdgIds
private

An allowed set of PDG ids where any empty vector implies all PDG ids are allowed.

Definition at line 84 of file BeamHaloGeneratorSettings.h.

◆ m_generatorSettings

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

A vector of strings to configure the generator settings.

Definition at line 80 of file BeamHaloGeneratorSettings.h.

◆ m_limitNames

const std::string BeamHaloGeneratorSettings::m_limitNames
staticprivate
Initial value:
= {"pxLimits",
"pyLimits",
"pzLimits",
"energyLimits",
"xLimits",
"yLimits",
"zLimits",
"ptLimits",
"phiLimits",
"etaLimits",
"rLimits",
"weightLimits"}

The name of the limits.

Definition at line 77 of file BeamHaloGeneratorSettings.h.

◆ m_limits

std::vector<std::pair<float, float> > BeamHaloGeneratorSettings::m_limits
private

Minimum and maximum limits.

Definition at line 87 of file BeamHaloGeneratorSettings.h.

◆ m_limitsEnabled

std::vector<std::pair<bool, bool> > BeamHaloGeneratorSettings::m_limitsEnabled
private

A vector of flags to signal if a limit should be used or not.

Definition at line 90 of file BeamHaloGeneratorSettings.h.

◆ m_settingsParsed

bool BeamHaloGeneratorSettings::m_settingsParsed
private

A flag to check if the settings have been parsed or not.

Definition at line 96 of file BeamHaloGeneratorSettings.h.

◆ m_shapeRequirement

int BeamHaloGeneratorSettings::m_shapeRequirement
private

A variable to store the volume shape requirement.

Definition at line 93 of file BeamHaloGeneratorSettings.h.


The documentation for this class was generated from the following files:
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
python.SystemOfUnits.second
int second
Definition: SystemOfUnits.py:120
BeamHaloGeneratorSettings::ENUM_LIMITS_SIZE
@ ENUM_LIMITS_SIZE
Definition: BeamHaloGeneratorSettings.h:64
BeamHaloGeneratorSettings::PY_LIMIT
@ PY_LIMIT
Definition: BeamHaloGeneratorSettings.h:53
BeamHaloGeneratorSettings::CYLINDER
@ CYLINDER
Definition: BeamHaloGeneratorSettings.h:49
BeamHaloGeneratorSettings::m_settingsParsed
bool m_settingsParsed
A flag to check if the settings have been parsed or not.
Definition: BeamHaloGeneratorSettings.h:96
BeamHaloGeneratorSettings::E_LIMIT
@ E_LIMIT
Definition: BeamHaloGeneratorSettings.h:55
BeamHaloGeneratorSettings::parseSettings
int parseSettings(void)
A function to parse the settings using the vector of strings given to the constructor of this class.
Definition: BeamHaloGeneratorSettings.cxx:43
PixelAthClusterMonAlgCfg.zmin
zmin
Definition: PixelAthClusterMonAlgCfg.py:176
index
Definition: index.py:1
athena.value
value
Definition: athena.py:122
BeamHaloGeneratorSettings::m_limitNames
static const std::string m_limitNames[ENUM_LIMITS_SIZE]
The name of the limits.
Definition: BeamHaloGeneratorSettings.h:77
BeamHaloGeneratorSettings::m_limitsEnabled
std::vector< std::pair< bool, bool > > m_limitsEnabled
A vector of flags to signal if a limit should be used or not.
Definition: BeamHaloGeneratorSettings.h:90
BeamHaloGeneratorSettings::checkSetting
bool checkSetting(int index, double value)
A function to check if a particle is within a range.
Definition: BeamHaloGeneratorSettings.cxx:236
BeamHaloGeneratorSettings::printSettings
void printSettings(void)
Print a summary of the current settings.
Definition: BeamHaloGeneratorSettings.cxx:250
BeamHaloGeneratorSettings::m_limits
std::vector< std::pair< float, float > > m_limits
Minimum and maximum limits.
Definition: BeamHaloGeneratorSettings.h:87
BeamHaloGeneratorSettings::NONE
@ NONE
Definition: BeamHaloGeneratorSettings.h:48
BeamHaloGeneratorSettings::R_LIMIT
@ R_LIMIT
Definition: BeamHaloGeneratorSettings.h:62
lumiFormat.i
int i
Definition: lumiFormat.py:92
BeamHaloGeneratorSettings::Y_LIMIT
@ Y_LIMIT
Definition: BeamHaloGeneratorSettings.h:57
BeamHaloParticle::pdgId
long pdgId() const
A function to return the PDG id of this particle.
Definition: BeamHaloParticle.h:58
BeamHaloGeneratorSettings::W_LIMIT
@ W_LIMIT
Definition: BeamHaloGeneratorSettings.h:63
AsciiInput::strToLong
static long strToLong(const std::string &inputString)
A helper function to convert a string to a long value.
Definition: AsciiInput.cxx:113
BeamHaloGeneratorSettings::m_generatorSettings
std::vector< std::string > m_generatorSettings
A vector of strings to configure the generator settings.
Definition: BeamHaloGeneratorSettings.h:80
PixelAthClusterMonAlgCfg.zmax
zmax
Definition: PixelAthClusterMonAlgCfg.py:176
BeamHaloGeneratorSettings::parseLimitSetting
int parseLimitSetting(std::vector< std::string > *commandVector)
A function to read the limit settings from the supplied vector of strings.
Definition: BeamHaloGeneratorSettings.cxx:98
BeamHaloGeneratorSettings::m_allowedPdgIds
std::vector< long > m_allowedPdgIds
An allowed set of PDG ids where any empty vector implies all PDG ids are allowed.
Definition: BeamHaloGeneratorSettings.h:84
BeamHaloGeneratorSettings::PHI_LIMIT
@ PHI_LIMIT
Definition: BeamHaloGeneratorSettings.h:60
BeamHaloParticle::fourVector
HepMC::FourVector fourVector() const
A function to return the momentum fourvector of this particle.
Definition: BeamHaloParticle.h:62
BeamHaloGeneratorSettings::checkCylinder
bool checkCylinder(BeamHaloParticle *beamHaloParticle)
A function to check if a particle is within a cylinder.
Definition: BeamHaloGeneratorSettings.cxx:187
BeamHaloGeneratorSettings::m_shapeRequirement
int m_shapeRequirement
A variable to store the volume shape requirement.
Definition: BeamHaloGeneratorSettings.h:93
BeamHaloGeneratorSettings::Z_LIMIT
@ Z_LIMIT
Definition: BeamHaloGeneratorSettings.h:58
BeamHaloParticle::weight
double weight() const
A function to return the weight of this particle within the input beam background simulation file.
Definition: BeamHaloParticle.h:70
DeMoScan.first
bool first
Definition: DeMoScan.py:534
BeamHaloGeneratorSettings::ETA_LIMIT
@ ETA_LIMIT
Definition: BeamHaloGeneratorSettings.h:61
AsciiInput::strToStrVec
static std::vector< std::string > strToStrVec(const std::string &inputString)
A helper function to convert a string into a string vector, by using any number of space or tab chara...
Definition: AsciiInput.cxx:67
BeamHaloParticle::positionAtScoringPlane
HepMC::FourVector positionAtScoringPlane() const
A function to return the position fourvector of this particle with respect to the scoring plane.
Definition: BeamHaloParticle.h:66
BeamHaloGeneratorSettings::PZ_LIMIT
@ PZ_LIMIT
Definition: BeamHaloGeneratorSettings.h:54
python.CaloScaleNoiseConfig.default
default
Definition: CaloScaleNoiseConfig.py:79
BeamHaloGeneratorSettings::PT_LIMIT
@ PT_LIMIT
Definition: BeamHaloGeneratorSettings.h:59
AsciiInput::strToDouble
static double strToDouble(const std::string &inputString)
A helper function to convert a string to a double value.
Definition: AsciiInput.cxx:122
BeamHaloGeneratorSettings::X_LIMIT
@ X_LIMIT
Definition: BeamHaloGeneratorSettings.h:56
BeamHaloGeneratorSettings::PX_LIMIT
@ PX_LIMIT
Definition: BeamHaloGeneratorSettings.h:52