ATLAS Offline Software
Loading...
Searching...
No Matches
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
15namespace xAOD {
16
21
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
#define AUXSTORE_PRIMITIVE_SETTER_AND_GETTER(CL, TYPE, NAME, SETTER)
Macro creating the accessors of primitive auxiliary properties.
#define AUXSTORE_OBJECT_SETTER_AND_GETTER(CL, TYPE, NAME, SETTER)
Macro creating the accessors of complex auxiliary properties.
bool passed(DecisionID id, const DecisionIDContainer &)
checks if required decision ID is in the set of IDs in the container
SG::Accessor< T, ALLOC > Accessor
Definition AuxElement.h:572
AuxElement()
Default constructor.
Type describing which elements in a container passed a trigger chain.
uint32_t size() const
The size of the target container.
const std::vector< uint32_t > & passBits() const
The internal bitmap created with the hypo decisions.
static uint32_t hash(const std::string &key)
Function calculating a "hash" out of a string.
bool isPassing(const OBJ *obj, const CONT *container) const
Check if an element of a container is passing/failing.
void markPassing(const OBJ *obj, const CONT *container, bool passed=true)
Mark one of the elements of the target container as passing/failing.
const void * m_container
Transient pointer to the target container.
TrigPassBits_v1()
Default constructor.
Forward declaration.
Definition index.py:1
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
AUXSTORE_PRIMITIVE_SETTER_AND_GETTER(BTagging_v1, float, IP2D_pb, setIP2D_pb) AUXSTORE_PRIMITIVE_SETTER_AND_GETTER(BTagging_v1
setPassBits containerClid
setEventNumber uint32_t