ATLAS Offline Software
AcceptData.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // Dear emacs, this is -*-c++-*-
6 
7 #ifndef PATCORE_ACCEPT_DATA_H
8 #define PATCORE_ACCEPT_DATA_H
9 
21 #include <string>
22 #include <map>
23 #include <bitset>
24 #include <cassert>
25 #include <PATCore/AcceptInfo.h>
26 
27 
28 namespace asg {
29  class AcceptData final
30  {
31 
32  public:
34  static const unsigned int NBITS=AcceptInfo::NBITS;
35 
37  inline explicit AcceptData(const AcceptInfo* val_info)
38  : m_info (val_info)
39  {}
40 
41  public:
43  explicit inline operator bool() const
44  {
45  return m_accept == m_info->getCutMask();
46  };
47 
48 
50  inline const char* getName() const { return m_info->getName(); };
51 
52 
54  inline void clear() { m_accept.reset(); }
55 
57  inline void clearPositive()
58  {
60  }
61 
62 
64  inline unsigned int getNCuts() const { return m_info->getNCuts(); };
65 
67  inline std::bitset<NBITS> getCutMask() const { return m_info->getCutMask(); };
68 
69 
71  inline unsigned int getCutPosition( const std::string& cutName ) const
72  {
73  return m_info->getCutPosition(cutName);
74  }
75 
76 
78  const std::string& getCutName( unsigned int cutPosition ) const
79  {
80  return m_info->getCutName (cutPosition);
81  };
82 
83 
85  inline const std::string& getCutDescription( const std::string& cutName ) const
86  {
87  return m_info->getCutDescription (cutName);
88  }
89 
91  const std::string& getCutDescription( unsigned int cutPosition ) const
92  {
93  return m_info->getCutDescription (cutPosition);
94  }
95 
96 
98  inline bool getCutResult( const std::string& cutName ) const
99  {
100  unsigned int cutPosition = getCutPosition(cutName);
101  return getCutResult(cutPosition);
102  }
103 
105  inline bool getCutResult( unsigned int cutPosition ) const
106  {
107  return m_accept[cutPosition];
108  }
109 
110 
112  inline std::bitset<NBITS> getCutResultBitSet() const
113  {
114  return m_accept;
115  }
116 
119  inline std::bitset<NBITS> getCutResultInvertedBitSet() const
120  {
121  return m_accept ^ m_info->getCutMask();
122  }
123 
126  inline unsigned int getCutResultInverted() const
127  {
128  return getCutResultInvertedBitSet().to_ulong();
129  }
130 
131 
132 
134  inline void setCutResult( const std::string& cutName, bool cutResult )
135  {
136  unsigned int cutPosition = getCutPosition(cutName);
137  return setCutResult( cutPosition, cutResult );
138  }
139 
141  inline void setCutResult( unsigned int cutPosition, bool cutResult )
142  {
143  m_accept[cutPosition] = cutResult;
144  }
145 
147  {
148  assert (m_info == other.m_info);
149  m_accept |= other.m_accept;
150  return *this;
151  }
152 
153 
154  // Private members
155  private:
157  const AcceptInfo *m_info = nullptr;
158 
160  std::bitset<NBITS> m_accept;
161 
162  }; // End: class definition
163 
164 } // End: namespace asg
165 
166 
167 #endif
asg::AcceptData::getCutResultInvertedBitSet
std::bitset< NBITS > getCutResultInvertedBitSet() const
Get an inverted bitset of the cut result.
Definition: AcceptData.h:119
asg::AcceptData::getNCuts
unsigned int getNCuts() const
Get the number of cuts defined.
Definition: AcceptData.h:64
asg::AcceptData::getCutDescription
const std::string & getCutDescription(const std::string &cutName) const
Get the description of a cut, based on the cut name.
Definition: AcceptData.h:85
asg
Definition: DataHandleTestTool.h:28
asg::AcceptData::getCutResultInverted
unsigned int getCutResultInverted() const
Get an inverted bitset as an unsigned integer of the cut result.
Definition: AcceptData.h:126
asg::AcceptData::m_accept
std::bitset< NBITS > m_accept
The cut bits.
Definition: AcceptData.h:160
asg::AcceptInfo::getCutPosition
unsigned int getCutPosition(const std::string &cutName) const
Get the bit position of a cut.
Definition: AcceptInfo.h:73
asg::AcceptData::getName
const char * getName() const
Get the name of the class instance.
Definition: AcceptData.h:50
asg::AcceptData::getCutPosition
unsigned int getCutPosition(const std::string &cutName) const
Get the bit position of a cut.
Definition: AcceptData.h:71
asg::AcceptInfo::getCutName
const std::string & getCutName(unsigned int cutPosition) const
Get the name of a cut, based on the cut position (slow, avoid usage)
Definition: AcceptInfo.cxx:36
asg::AcceptData::getCutDescription
const std::string & getCutDescription(unsigned int cutPosition) const
Get the description of a cut, based on the cut position.
Definition: AcceptData.h:91
asg::AcceptData::NBITS
static const unsigned int NBITS
The number of bits for cuts.
Definition: AcceptData.h:34
asg::AcceptData::getCutMask
std::bitset< NBITS > getCutMask() const
Get a bitmask for all cuts defined.
Definition: AcceptData.h:67
asg::AcceptInfo
Definition: AcceptInfo.h:28
asg::AcceptData::getCutResult
bool getCutResult(unsigned int cutPosition) const
Get the result of a cut, based on the cut position (faster)
Definition: AcceptData.h:105
asg::AcceptInfo::getNCuts
unsigned int getNCuts() const
Get the number of cuts defined.
Definition: AcceptInfo.h:46
asg::AcceptData::clearPositive
void clearPositive()
Set all bits to true.
Definition: AcceptData.h:57
asg::AcceptData::setCutResult
void setCutResult(unsigned int cutPosition, bool cutResult)
Get the result of a cut, based on the cut position (faster)
Definition: AcceptData.h:141
asg::AcceptInfo::NBITS
static const unsigned int NBITS
The number of bits for cuts.
Definition: AcceptInfo.h:32
asg::AcceptData::getCutName
const std::string & getCutName(unsigned int cutPosition) const
Get the name of a cut, based on the cut position (slow, avoid usage)
Definition: AcceptData.h:78
asg::AcceptInfo::getCutMask
std::bitset< NBITS > getCutMask() const
Get a bitmask for all cuts defined.
Definition: AcceptInfo.h:49
asg::AcceptData::getCutResultBitSet
std::bitset< NBITS > getCutResultBitSet() const
Get the cut result bitset.
Definition: AcceptData.h:112
asg::AcceptData::operator|=
AcceptData & operator|=(const AcceptData &other)
Definition: AcceptData.h:146
asg::AcceptData::AcceptData
AcceptData(const AcceptInfo *val_info)
Standard constructor.
Definition: AcceptData.h:37
AcceptInfo.h
asg::AcceptData::m_info
const AcceptInfo * m_info
the info structure describing us
Definition: AcceptData.h:157
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
asg::AcceptData::setCutResult
void setCutResult(const std::string &cutName, bool cutResult)
Set the result of a cut, based on the cut name (safer)
Definition: AcceptData.h:134
asg::AcceptData::clear
void clear()
Clear all bits.
Definition: AcceptData.h:54
asg::AcceptData::getCutResult
bool getCutResult(const std::string &cutName) const
Get the result of a cut, based on the cut name (safer)
Definition: AcceptData.h:98
asg::AcceptInfo::getName
const char * getName() const
Get the name of the class instance.
Definition: AcceptInfo.h:43
asg::AcceptData
Definition: AcceptData.h:30
xAOD::bool
setBGCode setTAP setLVL2ErrorBits bool
Definition: TrigDecision_v1.cxx:60
asg::AcceptInfo::getCutDescription
const std::string & getCutDescription(const std::string &cutName) const
Get the description of a cut, based on the cut name.
Definition: AcceptInfo.cxx:119