ATLAS Offline Software
Loading...
Searching...
No Matches
AcceptInfo.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_INFO_H
8#define PATCORE_ACCEPT_INFO_H
9
20
21#include <string>
22#include <map>
23#include <bitset>
24
25
26namespace asg {
27 class AcceptInfo final
28 {
29
30 public:
32 static const unsigned int NBITS=32;
33
35 AcceptInfo(const char* name="AcceptInfo")
36 : m_name(name),
37 m_cutMap()
38 {}
39
40 public:
41
43 inline const char* getName() const { return m_name.c_str(); };
44
46 inline unsigned int getNCuts() const { return m_cutMap.size(); };
47
49 inline const std::bitset<NBITS>& getCutMask() const { return m_cutMask; };
50
51
53 int addCut( const std::string& cutName, const std::string& cutDescription )
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 }
70
71
73 inline unsigned int getCutPosition( const std::string& cutName ) const
74 {
75 auto it = m_cutMap.find(cutName);
76 return (it != m_cutMap.end()) ? (it->second).second : 999999;
77 }
78
79
81 const std::string& getCutName( unsigned int cutPosition ) const;
82
83
85 const std::string& getCutDescription( const std::string& cutName ) const;
86
88 const std::string& getCutDescription( unsigned int cutPosition ) const;
89
90
92 inline void setCutDescription( const std::string& cutName, const std::string& cutDescription )
93 {
94 unsigned int cutPosition = getCutPosition(cutName);
95 return setCutDescription( cutPosition, cutDescription );
96 }
97
99 void setCutDescription( unsigned int cutPosition, const std::string& cutDescription );
100
101
102 // Private members
103 private:
104
106 std::string m_name;
107
109 std::map< std::string, std::pair< std::string, unsigned int > > m_cutMap;
110
112 std::bitset<NBITS> m_cutMask;
113
114
115 }; // End: class definition
116
117} // End: namespace asg
118
119
120#endif
std::string m_name
The name of the class instance.
Definition AcceptInfo.h:106
unsigned int getCutPosition(const std::string &cutName) const
Get the bit position of a cut.
Definition AcceptInfo.h:73
const char * getName() const
Get the name of the class instance.
Definition AcceptInfo.h:43
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
const std::bitset< NBITS > & getCutMask() const
Get a bitmask for all cuts defined.
Definition AcceptInfo.h:49
unsigned int getNCuts() const
Get the number of cuts defined.
Definition AcceptInfo.h:46
const std::string & getCutName(unsigned int cutPosition) const
Get the name of a cut, based on the cut position (slow, avoid usage)
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
int addCut(const std::string &cutName, const std::string &cutDescription)
Add a cut; returning the cut position.
Definition AcceptInfo.h:53
static const unsigned int NBITS
The number of bits for cuts.
Definition AcceptInfo.h:32
std::bitset< NBITS > m_cutMask
A bitmap that provides a mask that only leaves defined cuts.
Definition AcceptInfo.h:112
const std::string & getCutDescription(const std::string &cutName) const
Get the description of a cut, based on the cut name.
AcceptInfo(const char *name="AcceptInfo")
Standard constructor.
Definition AcceptInfo.h:35