ATLAS Offline Software
TrigPassBits_v1.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
6 // System include(s):
7 #include <functional>
8 
9 // xAOD include(s):
11 
12 // Local include(s):
14 
15 namespace xAOD {
16 
18  : SG::AuxElement(), m_container( nullptr ) {
19 
20  }
21 
29  void TrigPassBits_v1::markPassing( size_t index, bool passed ) {
30 
31  // A sanity check:
32  if( index >= size() ) {
33  throw std::runtime_error( "Index out of range" );
34  }
35 
36  // Access the serialised bits:
38  accBits( "passBits" );
39  std::vector< uint32_t >& bits = accBits( *this );
40 
41  // Calculate which bit to modify:
42  const size_t vec_element = index / 32;
43  const size_t vec_index = index % 32;
44 
45  // Another sanity check:
46  if( vec_element >= bits.size() ) {
47  throw std::runtime_error( "The object is in an inconsistent state" );
48  }
49 
50  // Set the bit:
51  const uint32_t bit = ( 0x1 << vec_index );
52  uint32_t mask = bits[ vec_element ];
53  if( passed ) {
54  mask |= bit;
55  } else {
56  mask &= ~bit;
57  }
58  bits[ vec_element ] = mask;
59 
60  return;
61  }
62 
69  bool TrigPassBits_v1::isPassing( size_t index ) const {
70 
71  // A sanity check:
72  if( index >= size() ) {
73  throw std::runtime_error( "Index out of range" );
74  }
75 
76  // Access the serialised bits:
77  const std::vector< uint32_t >& bits = passBits();
78 
79  // Calculate the bit to extract:
80  const size_t vec_element = index / 32;
81  const size_t vec_index = index % 32;
82 
83  // Another sanity check:
84  if( vec_element >= bits.size() ) {
85  throw std::runtime_error( "The object is in an inconsistent state" );
86  }
87 
88  // Extract the bit:
89  const uint32_t bit = ( 0x1 << vec_index );
90  const uint32_t mask = bits[ vec_element ];
91  return ( mask & bit );
92  }
93 
100  uint32_t TrigPassBits_v1::hash( const std::string& key ) {
101 
102  // The helper object:
103  static const std::hash< std::string > helper;
104 
105  // The mask comes from how StoreGate creates hashes from keys. Could use
106  // some other value here as well though.
107  return ( static_cast< uint32_t >( helper( key ) ) & 0x3fffffff );
108  }
109 
110  // Implementation of the raw accessor functions:
111 
113  size, setSize )
114  AUXSTORE_OBJECT_SETTER_AND_GETTER( TrigPassBits_v1, std::vector< uint32_t >,
115  passBits, setPassBits )
117  containerKey, setContainerKey )
119  containerClid, setContainerClid )
120 
121 } // namespace xAOD
xAOD::AUXSTORE_PRIMITIVE_SETTER_AND_GETTER
AUXSTORE_PRIMITIVE_SETTER_AND_GETTER(BTagging_v1, float, IP2D_pb, setIP2D_pb) AUXSTORE_PRIMITIVE_SETTER_AND_GETTER(BTagging_v1
xAOD::TrigPassBits_v1::isPassing
bool isPassing(const OBJ *obj, const CONT *container) const
Check if an element of a container is passing/failing.
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
TrigCompositeUtils::passed
bool passed(DecisionID id, const DecisionIDContainer &idSet)
checks if required decision ID is in the set of IDs in the container
Definition: TrigCompositeUtilsRoot.cxx:117
SG::Accessor
Helper class to provide type-safe access to aux data.
Definition: Control/AthContainers/AthContainers/Accessor.h:68
AuxStoreAccessorMacros.h
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
xAOD::TrigPassBits_v1::hash
static uint32_t hash(const std::string &key)
Function calculating a "hash" out of a string.
Definition: TrigPassBits_v1.cxx:100
index
Definition: index.py:1
xAOD::passBits
passBits
Definition: TrigPassBits_v1.cxx:115
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
python.utils.AtlRunQueryLookup.mask
string mask
Definition: AtlRunQueryLookup.py:460
runBeamSpotCalibration.helper
helper
Definition: runBeamSpotCalibration.py:112
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
xAOD::TrigPassBits_v1::size
uint32_t size() const
The size of the target container.
xAOD::TrigPassBits_v1
Type describing which elements in a container passed a trigger chain.
Definition: TrigPassBits_v1.h:38
xAOD::TrigPassBits_v1::TrigPassBits_v1
TrigPassBits_v1()
Default constructor.
Definition: TrigPassBits_v1.cxx:17
xAOD::TrigPassBits_v1::passBits
const std::vector< uint32_t > & passBits() const
The internal bitmap created with the hypo decisions.
xAOD::TrigPassBits_v1::markPassing
void markPassing(const OBJ *obj, const CONT *container, bool passed=true)
Mark one of the elements of the target container as passing/failing.
TrigPassBits_v1.h
xAOD::containerClid
setPassBits containerClid
Definition: TrigPassBits_v1.cxx:119
xAOD::AUXSTORE_OBJECT_SETTER_AND_GETTER
AUXSTORE_OBJECT_SETTER_AND_GETTER(CaloRings_v1, RingSetLinks, ringSetLinks, setRingSetLinks) unsigned CaloRings_v1
Definition: CaloRings_v1.cxx:27
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37