ATLAS Offline Software
Loading...
Searching...
No Matches
AcceptData.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 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
20
21#include <string>
22#include <string_view>
23#include <map>
24#include <bitset>
25#include <cassert>
26#include <PATCore/AcceptInfo.h>
27
28
29namespace asg {
30 class AcceptData final
31 {
32
33 public:
35 static const unsigned int NBITS=AcceptInfo::NBITS;
36
38 inline explicit AcceptData(const AcceptInfo* val_info)
39 : m_info (val_info)
40 {}
41
42 public:
44 explicit inline operator bool() const
45 {
46 return m_accept == m_info->getCutMask();
47 };
48
49
51 inline const char* getName() const { return m_info->getName(); };
52
53
55 inline void clear() { m_accept.reset(); }
56
58 inline void clearPositive()
59 {
60 m_accept = m_info->getCutMask();
61 }
62
63
65 inline unsigned int getNCuts() const { return m_info->getNCuts(); };
66
68 inline std::bitset<NBITS> getCutMask() const { return m_info->getCutMask(); };
69
70
72 inline unsigned int getCutPosition( std::string_view cutName ) const
73 {
74 return m_info->getCutPosition(cutName);
75 }
76
77
79 const std::string& getCutName( unsigned int cutPosition ) const
80 {
81 return m_info->getCutName (cutPosition);
82 };
83
84
86 inline const std::string& getCutDescription( const std::string& cutName ) const
87 {
88 return m_info->getCutDescription (cutName);
89 }
90
92 const std::string& getCutDescription( unsigned int cutPosition ) const
93 {
94 return m_info->getCutDescription (cutPosition);
95 }
96
97
99 inline bool getCutResult( std::string_view cutName ) const
100 {
101 unsigned int cutPosition = getCutPosition(cutName);
102 return getCutResult(cutPosition);
103 }
104
106 inline bool getCutResult( unsigned int cutPosition ) const
107 {
108 return m_accept[cutPosition];
109 }
110
111
113 inline const std::bitset<NBITS>& getCutResultBitSet() const
114 {
115 return m_accept;
116 }
117
120 inline std::bitset<NBITS> getCutResultInvertedBitSet() const
121 {
122 return m_accept ^ m_info->getCutMask();
123 }
124
127 inline unsigned int getCutResultInverted() const
128 {
129 return getCutResultInvertedBitSet().to_ulong();
130 }
131
132
133
135 inline void setCutResult( const std::string& cutName, bool cutResult )
136 {
137 unsigned int cutPosition = getCutPosition(cutName);
138 return setCutResult( cutPosition, cutResult );
139 }
140
142 inline void setCutResult( unsigned int cutPosition, bool cutResult )
143 {
144 m_accept[cutPosition] = cutResult;
145 }
146
148 {
149 assert (m_info == other.m_info);
150 m_accept |= other.m_accept;
151 return *this;
152 }
153
154
155 // Private members
156 private:
158 const AcceptInfo *m_info = nullptr;
159
161 std::bitset<NBITS> m_accept;
162
163 }; // End: class definition
164
165} // End: namespace asg
166
167
168#endif
AcceptData & operator|=(const AcceptData &other)
Definition AcceptData.h:147
AcceptData(const AcceptInfo *val_info)
Standard constructor.
Definition AcceptData.h:38
unsigned int getNCuts() const
Get the number of cuts defined.
Definition AcceptData.h:65
std::bitset< NBITS > getCutResultInvertedBitSet() const
Get an inverted bitset of the cut result.
Definition AcceptData.h:120
const AcceptInfo * m_info
the info structure describing us
Definition AcceptData.h:158
const std::bitset< NBITS > & getCutResultBitSet() const
Get the cut result bitset.
Definition AcceptData.h:113
void setCutResult(unsigned int cutPosition, bool cutResult)
Get the result of a cut, based on the cut position (faster).
Definition AcceptData.h:142
std::bitset< NBITS > getCutMask() const
Get a bitmask for all cuts defined.
Definition AcceptData.h:68
bool getCutResult(unsigned int cutPosition) const
Get the result of a cut, based on the cut position (faster).
Definition AcceptData.h:106
void clearPositive()
Set all bits to true.
Definition AcceptData.h:58
const std::string & getCutDescription(const std::string &cutName) const
Get the description of a cut, based on the cut name.
Definition AcceptData.h:86
const std::string & getCutDescription(unsigned int cutPosition) const
Get the description of a cut, based on the cut position.
Definition AcceptData.h:92
void setCutResult(const std::string &cutName, bool cutResult)
Set the result of a cut, based on the cut name (safer).
Definition AcceptData.h:135
unsigned int getCutPosition(std::string_view cutName) const
Get the bit position of a cut.
Definition AcceptData.h:72
static const unsigned int NBITS
The number of bits for cuts.
Definition AcceptData.h:35
bool getCutResult(std::string_view cutName) const
Get the result of a cut, based on the cut name (safer).
Definition AcceptData.h:99
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:79
std::bitset< NBITS > m_accept
The cut bits.
Definition AcceptData.h:161
void clear()
Clear all bits.
Definition AcceptData.h:55
const char * getName() const
Get the name of the class instance.
Definition AcceptData.h:51
unsigned int getCutResultInverted() const
Get an inverted bitset as an unsigned integer of the cut result.
Definition AcceptData.h:127
static const unsigned int NBITS
The number of bits for cuts.
Definition AcceptInfo.h:32