ATLAS Offline Software
Public Member Functions | Static Public Attributes | Private Attributes | List of all members
asg::AcceptInfo Class Referencefinal

#include <AcceptInfo.h>

Collaboration diagram for asg::AcceptInfo:

Public Member Functions

 AcceptInfo (const char *name="AcceptInfo")
 Standard constructor. More...
 
const char * getName () const
 Get the name of the class instance. More...
 
unsigned int getNCuts () const
 Get the number of cuts defined. More...
 
const std::bitset< NBITS > & getCutMask () const
 Get a bitmask for all cuts defined. More...
 
int addCut (const std::string &cutName, const std::string &cutDescription)
 Add a cut; returning the cut position. More...
 
unsigned int getCutPosition (const std::string &cutName) const
 Get the bit position of a cut. More...
 
const std::string & getCutName (unsigned int cutPosition) const
 Get the name of a cut, based on the cut position (slow, avoid usage) More...
 
const std::string & getCutDescription (const std::string &cutName) const
 Get the description of a cut, based on the cut name. More...
 
const std::string & getCutDescription (unsigned int cutPosition) const
 Get the description of a cut, based on the cut position. More...
 
void setCutDescription (const std::string &cutName, const std::string &cutDescription)
 Set the result of a cut, based on the cut name (safer) More...
 
void setCutDescription (unsigned int cutPosition, const std::string &cutDescription)
 Get the result of a cut, based on the cut position (faster) More...
 

Static Public Attributes

static const unsigned int NBITS =32
 The number of bits for cuts. More...
 

Private Attributes

std::string m_name
 The name of the class instance. More...
 
std::map< std::string, std::pair< std::string, unsigned int > > m_cutMap
 The map for mapping cut names to their description and position. More...
 
std::bitset< NBITSm_cutMask
 A bitmap that provides a mask that only leaves defined cuts. More...
 

Detailed Description

Definition at line 27 of file AcceptInfo.h.

Constructor & Destructor Documentation

◆ AcceptInfo()

asg::AcceptInfo::AcceptInfo ( const char *  name = "AcceptInfo")
inline

Standard constructor.

Definition at line 35 of file AcceptInfo.h.

36  : m_name(name),
37  m_cutMap()
38  {}

Member Function Documentation

◆ addCut()

int asg::AcceptInfo::addCut ( const std::string &  cutName,
const std::string &  cutDescription 
)
inline

Add a cut; returning the cut position.

Definition at line 53 of file AcceptInfo.h.

54  {
55  // Make sure that this new cuts doesn't exceed the number of bits available
56  if ( m_cutMap.size() >= NBITS )
57  {
58  return -1;
59  }
60 
61  // Add the cut to the map
62  std::pair< std::string, unsigned int > cutPair = std::make_pair( cutDescription, m_cutMap.size() );
63  m_cutMap.insert( std::make_pair( cutName, cutPair ) );
64 
65  // Return the position of the newly added cut in the bitmask
66  int result = (m_cutMap.size() - 1);
67  m_cutMask.set (result);
68  return result;
69  }

◆ getCutDescription() [1/2]

const std::string & AcceptInfo::getCutDescription ( const std::string &  cutName) const

Get the description of a cut, based on the cut name.

Definition at line 119 of file AcceptInfo.cxx.

120 {
121  static const std::string emptyString;
122  auto it = m_cutMap.find(cutName);
123  return (it != m_cutMap.end()) ? (it->second).first : emptyString;
124 }

◆ getCutDescription() [2/2]

const std::string & AcceptInfo::getCutDescription ( unsigned int  cutPosition) const

Get the description of a cut, based on the cut position.

Definition at line 66 of file AcceptInfo.cxx.

67 {
68  static const std::string emptyString;
69 
70  // Make sure that this cut doesn't exceed the number of defined cuts
71  if ( cutPosition >= m_cutMap.size() )
72  {
73  return emptyString;
74  }
75 
76  // iterate over the map and find the right position
77  auto it = m_cutMap.begin();
78  auto itEnd = m_cutMap.end();
79  for ( ; it != itEnd; ++it )
80  {
81  if ( (it->second).second == cutPosition )
82  {
83  return (it->second).first;
84  }
85  }
86 
87  return emptyString;
88 }

◆ getCutMask()

const std::bitset<NBITS>& asg::AcceptInfo::getCutMask ( ) const
inline

Get a bitmask for all cuts defined.

Definition at line 49 of file AcceptInfo.h.

49 { return m_cutMask; };

◆ getCutName()

const std::string & AcceptInfo::getCutName ( unsigned int  cutPosition) const

Get the name of a cut, based on the cut position (slow, avoid usage)

Definition at line 36 of file AcceptInfo.cxx.

37 {
38  static const std::string emptyString;
39 
40  // Make sure that this cut doesn't exceed the number of defined cuts
41  if ( cutPosition >= m_cutMap.size() )
42  {
43  return emptyString;
44  }
45 
46  // iterate over the map and find the right position
47  auto it = m_cutMap.begin();
48  auto itEnd = m_cutMap.end();
49  for ( ; it != itEnd; ++it )
50  {
51  if ( (it->second).second == cutPosition )
52  {
53  return (it->first);
54  }
55  }
56 
57  return emptyString;
58 }

◆ getCutPosition()

unsigned int asg::AcceptInfo::getCutPosition ( const std::string &  cutName) const
inline

Get the bit position of a cut.

Definition at line 73 of file AcceptInfo.h.

74  {
75  auto it = m_cutMap.find(cutName);
76  return (it != m_cutMap.end()) ? (it->second).second : 999999;
77  }

◆ getName()

const char* asg::AcceptInfo::getName ( ) const
inline

Get the name of the class instance.

Definition at line 43 of file AcceptInfo.h.

43 { return m_name.c_str(); };

◆ getNCuts()

unsigned int asg::AcceptInfo::getNCuts ( ) const
inline

Get the number of cuts defined.

Definition at line 46 of file AcceptInfo.h.

46 { return m_cutMap.size(); };

◆ setCutDescription() [1/2]

void asg::AcceptInfo::setCutDescription ( const std::string &  cutName,
const std::string &  cutDescription 
)
inline

Set the result of a cut, based on the cut name (safer)

Definition at line 92 of file AcceptInfo.h.

93  {
94  unsigned int cutPosition = getCutPosition(cutName);
95  return setCutDescription( cutPosition, cutDescription );
96  }

◆ setCutDescription() [2/2]

void AcceptInfo::setCutDescription ( unsigned int  cutPosition,
const std::string &  cutDescription 
)

Get the result of a cut, based on the cut position (faster)

Definition at line 97 of file AcceptInfo.cxx.

98 {
99  // iterate over the map and find the right position
100  auto it = m_cutMap.begin();
101  auto itEnd = m_cutMap.end();
102  for ( ; it != itEnd; ++it )
103  {
104  if ( (it->second).second == cutPosition )
105  {
106  ((it->second).first) = cutDescription;
107  return;
108  }
109  }
110 
111  return;
112 }

Member Data Documentation

◆ m_cutMap

std::map< std::string, std::pair< std::string, unsigned int > > asg::AcceptInfo::m_cutMap
private

The map for mapping cut names to their description and position.

Definition at line 109 of file AcceptInfo.h.

◆ m_cutMask

std::bitset<NBITS> asg::AcceptInfo::m_cutMask
private

A bitmap that provides a mask that only leaves defined cuts.

Definition at line 112 of file AcceptInfo.h.

◆ m_name

std::string asg::AcceptInfo::m_name
private

The name of the class instance.

Definition at line 106 of file AcceptInfo.h.

◆ NBITS

const unsigned int asg::AcceptInfo::NBITS =32
static

The number of bits for cuts.

Definition at line 32 of file AcceptInfo.h.


The documentation for this class was generated from the following files:
python.SystemOfUnits.second
int second
Definition: SystemOfUnits.py:120
get_generator_info.result
result
Definition: get_generator_info.py:21
asg::AcceptInfo::m_name
std::string m_name
The name of the class instance.
Definition: AcceptInfo.h:106
skel.it
it
Definition: skel.GENtoEVGEN.py:396
asg::AcceptInfo::getCutPosition
unsigned int getCutPosition(const std::string &cutName) const
Get the bit position of a cut.
Definition: AcceptInfo.h:73
asg::AcceptInfo::setCutDescription
void setCutDescription(const std::string &cutName, const std::string &cutDescription)
Set the result of a cut, based on the cut name (safer)
Definition: AcceptInfo.h:92
asg::AcceptInfo::NBITS
static const unsigned int NBITS
The number of bits for cuts.
Definition: AcceptInfo.h:32
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
DeMoScan.first
bool first
Definition: DeMoScan.py:536
asg::AcceptInfo::m_cutMap
std::map< std::string, std::pair< std::string, unsigned int > > m_cutMap
The map for mapping cut names to their description and position.
Definition: AcceptInfo.h:109
asg::AcceptInfo::m_cutMask
std::bitset< NBITS > m_cutMask
A bitmap that provides a mask that only leaves defined cuts.
Definition: AcceptInfo.h:112