ATLAS Offline Software
Loading...
Searching...
No Matches
AcceptData.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 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 <map>
23#include <bitset>
24#include <cassert>
25#include <PATCore/AcceptInfo.h>
26
27
28namespace 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 {
59 m_accept = m_info->getCutMask();
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 const 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
AcceptData & operator|=(const AcceptData &other)
Definition AcceptData.h:146
AcceptData(const AcceptInfo *val_info)
Standard constructor.
Definition AcceptData.h:37
unsigned int getNCuts() const
Get the number of cuts defined.
Definition AcceptData.h:64
std::bitset< NBITS > getCutResultInvertedBitSet() const
Get an inverted bitset of the cut result.
Definition AcceptData.h:119
const AcceptInfo * m_info
the info structure describing us
Definition AcceptData.h:157
const std::bitset< NBITS > & getCutResultBitSet() const
Get the cut result bitset.
Definition AcceptData.h:112
void setCutResult(unsigned int cutPosition, bool cutResult)
Get the result of a cut, based on the cut position (faster)
Definition AcceptData.h:141
std::bitset< NBITS > getCutMask() const
Get a bitmask for all cuts defined.
Definition AcceptData.h:67
bool getCutResult(unsigned int cutPosition) const
Get the result of a cut, based on the cut position (faster)
Definition AcceptData.h:105
void clearPositive()
Set all bits to true.
Definition AcceptData.h:57
const std::string & getCutDescription(const std::string &cutName) const
Get the description of a cut, based on the cut name.
Definition AcceptData.h:85
const std::string & getCutDescription(unsigned int cutPosition) const
Get the description of a cut, based on the cut position.
Definition AcceptData.h:91
void setCutResult(const std::string &cutName, bool cutResult)
Set the result of a cut, based on the cut name (safer)
Definition AcceptData.h:134
static const unsigned int NBITS
The number of bits for cuts.
Definition AcceptData.h:34
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
unsigned int getCutPosition(const std::string &cutName) const
Get the bit position of a cut.
Definition AcceptData.h:71
std::bitset< NBITS > m_accept
The cut bits.
Definition AcceptData.h:160
void clear()
Clear all bits.
Definition AcceptData.h:54
const char * getName() const
Get the name of the class instance.
Definition AcceptData.h:50
bool getCutResult(const std::string &cutName) const
Get the result of a cut, based on the cut name (safer)
Definition AcceptData.h:98
unsigned int getCutResultInverted() const
Get an inverted bitset as an unsigned integer of the cut result.
Definition AcceptData.h:126
static const unsigned int NBITS
The number of bits for cuts.
Definition AcceptInfo.h:32