ATLAS Offline Software
Chain.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /**********************************************************************************
6  * @Project: HLT Steering
7  * @Package: TrigSteering
8  * @Class : Chain
9  *
10  * @brief chain of signatures
11  *
12  * @author Till Eifert <Till.Eifert@cern.ch> - U. of Geneva, Switzerland
13  * @author Nicolas Berger <Nicolas.Berger@cern.ch> - CERN
14  *
15  * File and Version Information:
16  * $Id: Chain.cxx,v 1.59 2009-02-16 15:47:05 tbold Exp $
17  **********************************************************************************/
18 
21 
22 
23 #include <sstream>
24 #include <iostream>
25 
26 using namespace HLT;
27 Chain::Chain( uint32_t serialData )
28  : m_configChain(0) {
29  reset();
30  deserialize(serialData);
32 }
33 
34 Chain::Chain(const TrigConf::HLTChain* configChain)
35  : m_configChain(configChain)
36  , m_chain_counter{0}
37 {
38  if (configChain)
39  m_chain_counter = m_configChain->chain_counter();
40 
41  reset();
42  setStatus(HLT::ConfigOnlyChain);
43 }
44 
45 
46 bool Chain::chainPassed() const {
47  return (chainPassedRaw() && (!isPrescaled()) && (!isResurrected())) || isPassedThrough();
48 }
49 
50 
51 
52 HLT::ErrorCode Chain::serialize( std::vector<uint32_t>& output ) const
53 {
54  // Chain serialized structure: 1 word per Chain
55  // 1 bit: active ? (before prescale and passThrough)
56  // 1 bit: prescaled ?
57  // 1 bit: passedThrough ?
58  // 7 bit: last active step => [0,127]
59  // 16 bit: chainCounter => [0,65535]
60  // 6 bit: ErrorCode => [0,63]
61 
62  // serialize data: first 3 bits for Active, Prescaled, passThrough bits
63  uint32_t chainWord = 0;
64  if (chainPassedRaw()) chainWord |= 0x1;
65  if (isPrescaled()) chainWord |= 0x2;
66  if (isPassedThrough()) chainWord |= 0x4;
67 
68  // next, 6 bits for the last active step (64 steps)
69  chainWord |= ((m_currentStep & 0x0000003f) << 3);
70 
71 
72  if ( isResurrected()) chainWord |= 0x200;
73 
74  // next, 16 bits for the chain counter
75  chainWord |= ((getChainCounter() & 0x0000ffff) << (3+6+1));
76 
77  // next, 6 bits for the errorCode
78  chainWord |= ((m_errorCode & 0x0000003f) << (3+6+1+16));
79 
80  output.push_back(chainWord);
81 
82  return HLT::OK;
83 }
84 
85 HLT::ErrorCode Chain::setDecisions(bool passedraw, bool passedthrough, bool prescaled, bool resurrected)
86 {
87  m_status = ChainOK;
88  m_passedRaw = passedraw;
89  m_passThrough = passedthrough;
90  m_prescaled = prescaled;
91  m_resurrected = resurrected;
92 
93  // can't deduce the following
94  // m_currentStep = 0; // can't deduce
95  // m_chain_counter = ( chainWord >> (3+7)) & 0x0000ffff;
96  // m_errorCode = static_cast<HLT::ErrorCode>(( chainWord >> (3+7+16)) & 0x0000003f);
97  return HLT::OK;
98 }
99 
100 
102 {
103  m_status = ChainOK;
104  m_passedRaw = chainWord & (0x1);
105  m_passThrough = chainWord & (0x4);
106  m_prescaled = chainWord & (0x2);
107  m_resurrected = chainWord & (0x200);
108 
109  m_currentStep = ( chainWord >> 3) & 0x0000003f;
110  m_chain_counter = ( chainWord >> (3+7)) & 0x0000ffff;
111  m_errorCode = static_cast<HLT::ErrorCode>(( chainWord >> (3+7+16)) & 0x0000003f);
112  /*
113  // Put m_currentStep signatures in the vector
114  for (unsigned int i = 0; i < static_cast<unsigned int>(m_currentStep); i++) m_signatures.push_back(0);
115 
116  // if chain didn't pass, add one more signature...
117  if (!(chainWord & (0x1))) m_signatures.push_back(0);
118  */
119 
120  return HLT::OK;
121 }
122 
123 unsigned int HLT::Chain::inquireChainCounter(uint32_t chainWord) {
124  return ( chainWord >> (3+7)) & 0x0000ffff;
125 }
126 
128  m_errorCode = HLT::OK;
129  m_passedRaw = false;
130  m_passThrough = false;
131  m_prescaled = false;
132  m_resurrected = false;
133  m_currentStep = 0;
134  return true;
135 }
136 
137 
139 std::ostream& HLT::operator << (std::ostream& os, const Chain& c)
140 {
141  c.print(os);
142  return os;
143 }
144 MsgStream& HLT::operator << (MsgStream& msg, const Chain& c)
145 {
146  c.print(msg);
147  return msg;
148 }
149 
HLT::Chain::getChainCounter
unsigned int getChainCounter() const
return the unique identifier of this Chain (uint)
Definition: Chain.h:93
HLT::Chain::reset
bool reset()
restes the bits to the basic state
Definition: Chain.cxx:127
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
HLT::Chain::deserialize
ErrorCode deserialize(uint32_t chainWord)
deserialize this Chain from given vector of uint's
Definition: Chain.cxx:101
HLT::ErrorCode
The definition of error codes in HLT. This is a class (note; before was simple enum) to enable safer ...
Definition: Trigger/TrigEvent/TrigSteeringEvent/TrigSteeringEvent/Enums.h:80
HLT::ChainInvalid
@ ChainInvalid
Definition: Chain.h:51
HLT::Chain::m_passedRaw
bool m_passedRaw
Definition: Chain.h:146
HLT::Chain::m_prescaled
bool m_prescaled
Flagged as "prescaled" for this event ?
Definition: Chain.h:148
HLT::Chain::setDecisions
ErrorCode setDecisions(bool passedraw, bool passedthrough, bool prescaled, bool resurrected)
set bool decisions directly
Definition: Chain.cxx:85
HLT::Chain::isPrescaled
bool isPrescaled() const
is chain prescaled ?
Definition: Chain.h:86
HLT::Chain::inquireChainCounter
static unsigned int inquireChainCounter(uint32_t chainWord)
unpack chain counter from the serialized word
Definition: Chain.cxx:123
TrigConf::HLTChain
HLT chain configuration information.
Definition: TrigConfHLTData/TrigConfHLTData/HLTChain.h:35
HLT::Chain::chainPassed
bool chainPassed() const
Definition: Chain.cxx:46
HLT::operator<<
MsgStream & operator<<(MsgStream &m, const Navigation &nav)
Definition: Navigation.cxx:168
HLT::Chain::Chain
Chain(uint32_t serialData)
constructor from serialized data
Definition: Chain.cxx:27
HLT::ChainOK
@ ChainOK
Definition: Chain.h:51
HLT
It used to be useful piece of code for replacing actual SG with other store of similar functionality ...
Definition: HLTResultReader.h:26
HLT::Chain::serialize
ErrorCode serialize(std::vector< uint32_t > &output) const
serialize this Chain into the given vector of uint's
Definition: Chain.cxx:52
HLTSignature.h
HLT::Chain::m_currentStep
int m_currentStep
Current step of this chain.
Definition: Chain.h:150
HLT::Chain::m_chain_counter
unsigned int m_chain_counter
chain counter from configuration (copied here for speed)
Definition: Chain.h:144
HLT::Chain::setStatus
void setStatus(ChainStatus s)
Definition: Chain.h:141
Chain.h
HLT::Chain
Definition: Chain.h:64
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
merge.output
output
Definition: merge.py:17
HLT::Chain::isResurrected
bool isResurrected() const
is chain resurrected ?
Definition: Chain.h:87
HLT::Chain::m_resurrected
bool m_resurrected
flag to mar that chain was originally prescalled but is reexecuted
Definition: Chain.h:149
HLT::Chain::m_passThrough
bool m_passThrough
Flagged as "passedThrough" for this event ?
Definition: Chain.h:147
HLT::Chain::m_errorCode
ErrorCode m_errorCode
most severe error code of execution
Definition: Chain.h:145
CxxUtils::reset
constexpr std::enable_if_t< is_bitmask_v< E >, E & > reset(E &lhs, E rhs)
Convenience function to clear bits in a class enum bitmask.
Definition: bitmask.h:243
HLT::ConfigOnlyChain
@ ConfigOnlyChain
Definition: Chain.h:51
python.compressB64.c
def c
Definition: compressB64.py:93
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
HLT::Chain::chainPassedRaw
bool chainPassedRaw() const
Definition: Chain.h:81
HLT::Chain::m_status
ChainStatus m_status
Chain status, enum {ChainInvalid, ConfigOnlyChain, ChainOK }.
Definition: Chain.h:153
HLT::Chain::isPassedThrough
bool isPassedThrough() const
is chain passed through ?
Definition: Chain.h:85