ATLAS Offline Software
Loading...
Searching...
No Matches
xAOD::TrigPassBits_v1 Class Reference

Type describing which elements in a container passed a trigger chain. More...

#include <TrigPassBits_v1.h>

Inheritance diagram for xAOD::TrigPassBits_v1:
Collaboration diagram for xAOD::TrigPassBits_v1:

Public Member Functions

 TrigPassBits_v1 ()
 Default constructor.
Raw data accessors
uint32_t size () const
 The size of the target container.
void setSize (uint32_t value)
 Set the size of the target container.
const std::vector< uint32_t > & passBits () const
 The internal bitmap created with the hypo decisions.
void setPassBits (const std::vector< uint32_t > &value)
 Set the internal bitmap directly (not recommended).
uint32_t containerKey () const
 Hashed SG key of the target container.
void setContainerKey (uint32_t value)
 Set the hashed SG key of the target container.
uint32_t containerClid () const
 CLID of the target container.
void setContainerClid (uint32_t value)
 Set the CLID of the target container.

Static Public Attributes

static const uint32_t DEFAULT_KEY = 0xffff
 Default hashed container key, in case no explicit value was specified.

Private Attributes

const void * m_container
 Transient pointer to the target container.

Helper functions for easier usage

template<class CONT>
void reset (const CONT *container, uint32_t containerKey=0xffff)
 Function configuring and resetting the object for a new target.
template<class OBJ, class CONT>
void markPassing (const OBJ *obj, const CONT *container, bool passed=true)
 Mark one of the elements of the target container as passing/failing.
void markPassing (size_t index, bool passed=true)
 Mark one of the elements of the target container as passing/failing.
template<class OBJ, class CONT>
bool isPassing (const OBJ *obj, const CONT *container) const
 Check if an element of a container is passing/failing.
template<class OBJ, class CONT>
bool isPassing (const OBJ *obj, const CONT *container, uint32_t containerKey) const
 Check if an element of a container is passing/failing.
template<class OBJ, class CONT>
bool isPassing (const OBJ *obj, const CONT *container, const std::string &containerKey) const
 Check if an element of a container is passing/failing.
bool isPassing (size_t index) const
 Check if an element of a container is passing/failing.
static uint32_t hash (const std::string &key)
 Function calculating a "hash" out of a string.

Detailed Description

Type describing which elements in a container passed a trigger chain.

This type allows us to attach simple pass/fail information to the containers that we reconstructed in Fex algorithms, in Hypo algorithms. In this case we can't just decorate the original objects, as we may want to evaluate a lot of hypotheses on the exact same objects.

Author
Attila Krasznahorkay Attil.nosp@m.a.Kr.nosp@m.aszna.nosp@m.hork.nosp@m.ay@ce.nosp@m.rn.c.nosp@m.h
Tomasz Bold Tomas.nosp@m.z.Bo.nosp@m.ld@ce.nosp@m.rn.c.nosp@m.h
Revision
773869
Date
2016-09-19 17:27:05 +0200 (Mon, 19 Sep 2016)

Definition at line 38 of file TrigPassBits_v1.h.

Constructor & Destructor Documentation

◆ TrigPassBits_v1()

xAOD::TrigPassBits_v1::TrigPassBits_v1 ( )

Default constructor.

Definition at line 17 of file TrigPassBits_v1.cxx.

18 : SG::AuxElement(), m_container( nullptr ) {
19
20 }
const void * m_container
Transient pointer to the target container.
AuxElement(SG::AuxVectorData *container, size_t index)
Base class for elements of a container that can have aux data.

Member Function Documentation

◆ containerClid()

uint32_t xAOD::TrigPassBits_v1::containerClid ( ) const

CLID of the target container.

◆ containerKey()

uint32_t xAOD::TrigPassBits_v1::containerKey ( ) const

Hashed SG key of the target container.

◆ hash()

uint32_t xAOD::TrigPassBits_v1::hash ( const std::string & key)
static

Function calculating a "hash" out of a string.

Helper function used to create a well defined hash of a string key.

Used to create the containerKey value stored in the object.

Parameters
keyThe string key to create a hash out of
Returns
The hashed value for the specified key

Definition at line 100 of file TrigPassBits_v1.cxx.

100 {
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 }
setEventNumber uint32_t

◆ isPassing() [1/4]

template<class OBJ, class CONT>
bool xAOD::TrigPassBits_v1::isPassing ( const OBJ * obj,
const CONT * container ) const

Check if an element of a container is passing/failing.

◆ isPassing() [2/4]

template<class OBJ, class CONT>
bool xAOD::TrigPassBits_v1::isPassing ( const OBJ * obj,
const CONT * container,
const std::string & containerKey ) const

Check if an element of a container is passing/failing.

◆ isPassing() [3/4]

template<class OBJ, class CONT>
bool xAOD::TrigPassBits_v1::isPassing ( const OBJ * obj,
const CONT * container,
uint32_t containerKey ) const

Check if an element of a container is passing/failing.

◆ isPassing() [4/4]

bool xAOD::TrigPassBits_v1::isPassing ( size_t index) const

Check if an element of a container is passing/failing.

Non-template function for checking the state of an object with a given index inside the container.

Parameters
indexThe index of the object to check the state of
Returns
The "passing state" of the object with the specified index

Definition at line 69 of file TrigPassBits_v1.cxx.

69 {
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 }
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.
str index
Definition DeMoScan.py:362
constexpr unsigned int bit(int n)

◆ markPassing() [1/2]

template<class OBJ, class CONT>
void xAOD::TrigPassBits_v1::markPassing ( const OBJ * obj,
const CONT * container,
bool passed = true )

Mark one of the elements of the target container as passing/failing.

◆ markPassing() [2/2]

void xAOD::TrigPassBits_v1::markPassing ( size_t index,
bool passed = true )

Mark one of the elements of the target container as passing/failing.

Non-template function for marking an element with the specified index as passing/non-passing.

Performs fewer checks than the template function, so should be used with care.

Parameters
indexThe index of the object to set the state of
passedThe "passing state" of the object with the specified index

Definition at line 29 of file TrigPassBits_v1.cxx.

29 {
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:
37 static const SG::AuxElement::Accessor< std::vector< uint32_t > >
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 }
bool passed(DecisionID id, const DecisionIDContainer &)
checks if required decision ID is in the set of IDs in the container

◆ passBits()

const std::vector< uint32_t > & xAOD::TrigPassBits_v1::passBits ( ) const

The internal bitmap created with the hypo decisions.

◆ reset()

template<class CONT>
void xAOD::TrigPassBits_v1::reset ( const CONT * container,
uint32_t containerKey = 0xffff )

Function configuring and resetting the object for a new target.

◆ setContainerClid()

void xAOD::TrigPassBits_v1::setContainerClid ( uint32_t value)

Set the CLID of the target container.

◆ setContainerKey()

void xAOD::TrigPassBits_v1::setContainerKey ( uint32_t value)

Set the hashed SG key of the target container.

◆ setPassBits()

void xAOD::TrigPassBits_v1::setPassBits ( const std::vector< uint32_t > & value)

Set the internal bitmap directly (not recommended).

◆ setSize()

void xAOD::TrigPassBits_v1::setSize ( uint32_t value)

Set the size of the target container.

◆ size()

uint32_t xAOD::TrigPassBits_v1::size ( ) const

The size of the target container.

Member Data Documentation

◆ DEFAULT_KEY

const uint32_t xAOD::TrigPassBits_v1::DEFAULT_KEY = 0xffff
static

Default hashed container key, in case no explicit value was specified.

Definition at line 45 of file TrigPassBits_v1.h.

◆ m_container

const void* xAOD::TrigPassBits_v1::m_container
private

Transient pointer to the target container.

Definition at line 107 of file TrigPassBits_v1.h.


The documentation for this class was generated from the following files: