ATLAS Offline Software
HLTResultMT.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef TRIGSTEERINGEVENT_HLTResultMT_H
6 #define TRIGSTEERINGEVENT_HLTResultMT_H
7 
8 // Trigger includes
10 
11 // Athena includes
12 #include "AthenaKernel/CLASS_DEF.h"
13 
14 // Gaudi includes
15 #include "GaudiKernel/StatusCode.h"
16 
17 // TDAQ includes
18 #include "eformat/Status.h"
19 #include "eformat/StreamTag.h"
20 
21 // System includes
22 #include <boost/dynamic_bitset.hpp>
23 #include <vector>
24 #include <unordered_map>
25 #include <utility>
26 #include <cstdint>
27 
28 namespace HLT {
29 
38  class HLTResultMT {
39  public:
41  HLTResultMT(std::vector<eformat::helper::StreamTag> streamTags = {},
42  boost::dynamic_bitset<uint32_t> hltPassRawBits = boost::dynamic_bitset<uint32_t>(),
43  boost::dynamic_bitset<uint32_t> hltPrescaledBits = boost::dynamic_bitset<uint32_t>(),
44  std::unordered_map<uint16_t, std::vector<uint32_t> > data = {});
45 
46 
47  // ------------------------- Public typedefs -------------------------------
48 
50  using RODMinorVersion = std::pair<uint8_t,uint8_t>;
51 
52 
53  // ------------------------- Stream tags getters/setters -------------------
54 
56  const std::vector<eformat::helper::StreamTag>& getStreamTags() const;
57 
59  std::vector<eformat::helper::StreamTag>& getStreamTagsNonConst();
60 
66  StatusCode setStreamTags(const std::vector<eformat::helper::StreamTag>& streamTags);
67 
73  StatusCode addStreamTag(const eformat::helper::StreamTag& streamTag);
74 
75 
76  // ------------------------- HLT bits getters/setters ----------------------
77 
79  const boost::dynamic_bitset<uint32_t>& getHltPassRawBits() const;
80 
82  const boost::dynamic_bitset<uint32_t>& getHltPrescaledBits() const;
83 
85  const std::vector<uint32_t>& getHltBitsAsWords() const;
86 
88  void setHltPassRawBits(const boost::dynamic_bitset<uint32_t>& bitset);
89 
91  void setHltPrescaledBits(const boost::dynamic_bitset<uint32_t>& bitset);
92 
94  void setHltBits(const boost::dynamic_bitset<uint32_t>& passRawBitset,
95  const boost::dynamic_bitset<uint32_t>& prescaledBitset);
96 
97 
98  // ------------------------- Serialised data getters/setters ---------------
99 
104  const std::unordered_map<uint16_t, std::vector<uint32_t> >& getSerialisedData() const;
105 
111  StatusCode getSerialisedData(const uint16_t moduleId, const std::vector<uint32_t>*& data) const;
112 
114  void setSerialisedData(std::unordered_map<uint16_t, std::vector<uint32_t> > data);
115 
117  void addSerialisedData(const uint16_t moduleId, const std::vector<uint32_t>& data);
118 
122  StatusCode addSerialisedDataWithCheck(const uint16_t moduleId, std::vector<uint32_t> data);
123 
124 
125  // ------------------------- Error codes getters/setters -------------------
126  // The event processing status is stored as one bit-mask word corresponding to eformat::helper::Status
127  // and n optional error codes. Online HLT framework uses them to store HLT::OnlineErrorCode.
128 
130  const std::vector<uint32_t>& getStatus() const;
131 
133  const std::vector<HLT::OnlineErrorCode> getErrorCodes() const;
134 
136  void setStatus(std::vector<uint32_t> status);
137 
143  void addErrorCode(const HLT::OnlineErrorCode& errorCode,
144  const eformat::helper::Status& firstStatusWord = {
145  eformat::GenericStatus::DATA_CORRUPTION,
146  eformat::FullEventStatus::PSC_PROBLEM
147  });
148 
150  const std::vector<uint32_t>& getRobStatus(uint16_t moduleId) const;
151 
152  // ------------------------- Version getters/setters -----------------------
153  // The format of the HLT ByteStream (ROD payload) and the interpretation of the HLT-specific information
154  // in the full event header are versioned by the ROD minor version of the HLT ROBFragments
155 
157  RODMinorVersion getVersion() const;
158 
161 
162 
163  // ------------------------- Truncation information ------------------------
164 
166  const std::set<uint16_t>& getTruncatedModuleIds() const;
167 
171  void addTruncatedModuleId(const uint16_t moduleId, bool severeTruncation=true);
172 
174  bool severeTruncation() const { return m_severeTruncation; }
175 
176  // ------------------------- Extra helper methods --------------------------
178  bool isAccepted() const {return !m_streamTags.empty();}
179 
180  private:
181  // ------------------------- Private data members --------------------------
182 
184  std::vector<eformat::helper::StreamTag> m_streamTags;
185 
187  boost::dynamic_bitset<uint32_t> m_hltPassRawBits;
188  boost::dynamic_bitset<uint32_t> m_hltPrescaledBits;
189 
195  std::vector<uint32_t> m_hltBitWords;
196 
198  std::unordered_map<uint16_t, std::vector<uint32_t> > m_data;
199 
201  std::vector<uint32_t> m_status;
202 
204  std::unordered_map<uint16_t, std::vector<uint32_t>> m_robStatus;
205 
208 
211  std::set<uint16_t> m_truncatedModuleIds;
212 
214  bool m_severeTruncation{false};
215 
216  // ------------------------- Private helper methods ------------------------
217 
219  void updateHltBitWords();
220  };
221 } // namespace HLT
222 
224 std::ostream& operator<<(std::ostream& str, const HLT::HLTResultMT& hltResult);
225 
226 CLASS_DEF(HLT::HLTResultMT, 172156324, 1)
227 
228 #endif // TRIGSTEERINGEVENT_HLTResultMT_H
HLT::HLTResultMT::m_severeTruncation
bool m_severeTruncation
Should the event be sent to the debug stream due to severe truncation?
Definition: HLTResultMT.h:214
HLT::HLTResultMT::isAccepted
bool isAccepted() const
If there is at least one stream tag set, it means the event is accepted.
Definition: HLTResultMT.h:178
HLT::HLTResultMT::setHltBits
void setHltBits(const boost::dynamic_bitset< uint32_t > &passRawBitset, const boost::dynamic_bitset< uint32_t > &prescaledBitset)
Replace both HLT pass raw and prescaled bits with the given bitsets.
Definition: HLTResultMT.cxx:125
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
HLT::HLTResultMT::getStreamTags
const std::vector< eformat::helper::StreamTag > & getStreamTags() const
Const-getter for stream tags.
Definition: HLTResultMT.cxx:43
HLT::HLTResultMT::m_status
std::vector< uint32_t > m_status
FullEvent status words (first word is eformat::helper::Status, next words are optional error codes)
Definition: HLTResultMT.h:201
HLT::HLTResultMT::addSerialisedDataWithCheck
StatusCode addSerialisedDataWithCheck(const uint16_t moduleId, std::vector< uint32_t > data)
Add serialised data for a given moduleId.
Definition: HLTResultMT.cxx:180
HLT::HLTResultMT::m_hltPrescaledBits
boost::dynamic_bitset< uint32_t > m_hltPrescaledBits
Definition: HLTResultMT.h:188
RODMinorVersion
HLT::HLTResultMT::RODMinorVersion RODMinorVersion
Definition: HLTResultMTByteStreamDecoderTool.cxx:11
HLT::HLTResultMT
A container class for data required to build online output from HLT.
Definition: HLTResultMT.h:38
operator<<
std::ostream & operator<<(std::ostream &str, const HLT::HLTResultMT &hltResult)
operator<< overload for printing to std::ostream
Definition: HLTResultMT.cxx:274
HLT::HLTResultMT::m_streamTags
std::vector< eformat::helper::StreamTag > m_streamTags
Stream tags of the event.
Definition: HLTResultMT.h:184
HLT::HLTResultMT::updateHltBitWords
void updateHltBitWords()
Update m_hltBitWords with the contents of m_hltPassRawBits and m_hltPrescaledBits.
Definition: HLTResultMT.cxx:137
HLT::HLTResultMT::setSerialisedData
void setSerialisedData(std::unordered_map< uint16_t, std::vector< uint32_t > > data)
Replaces serialised data with a copy of the given data.
Definition: HLTResultMT.cxx:167
HLT::HLTResultMT::m_hltBitWords
std::vector< uint32_t > m_hltBitWords
Vector storing m_hltBits converted to 4-byte words.
Definition: HLTResultMT.h:195
HLT::HLTResultMT::addStreamTag
StatusCode addStreamTag(const eformat::helper::StreamTag &streamTag)
Append one stream tag to the stored list.
Definition: HLTResultMT.cxx:62
HLT::HLTResultMT::getRobStatus
const std::vector< uint32_t > & getRobStatus(uint16_t moduleId) const
Status words for ROB with given moduleId.
Definition: HLTResultMT.cxx:226
HLT::HLTResultMT::getErrorCodes
const std::vector< HLT::OnlineErrorCode > getErrorCodes() const
Error codes getter (by value) - strips off the first bit-mask status word.
Definition: HLTResultMT.cxx:201
HLT::HLTResultMT::m_robStatus
std::unordered_map< uint16_t, std::vector< uint32_t > > m_robStatus
ROBFragment status words for each moduleId.
Definition: HLTResultMT.h:204
HLT::HLTResultMT::getTruncatedModuleIds
const std::set< uint16_t > & getTruncatedModuleIds() const
Getter for the truncation information.
Definition: HLTResultMT.cxx:251
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:88
HLT
It used to be useful piece of code for replacing actual SG with other store of similar functionality ...
Definition: HLTResultReader.h:26
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
HLT::HLTResultMT::addTruncatedModuleId
void addTruncatedModuleId(const uint16_t moduleId, bool severeTruncation=true)
Add module ID to the list of truncated results.
Definition: HLTResultMT.cxx:256
HLT::HLTResultMT::addSerialisedData
void addSerialisedData(const uint16_t moduleId, const std::vector< uint32_t > &data)
Append serialised data (copy of input) for a given moduleId, doesn't remove existing data.
Definition: HLTResultMT.cxx:173
HLT::HLTResultMT::m_data
std::unordered_map< uint16_t, std::vector< uint32_t > > m_data
Serialised result (ROBFragment payload) for each moduleId (0 for full result, >0 for data scouting)
Definition: HLTResultMT.h:198
HLT::HLTResultMT::m_version
RODMinorVersion m_version
Stores the ROD minor version of the HLT ROBFragments.
Definition: HLTResultMT.h:207
HLT::HLTResultMT::getVersion
RODMinorVersion getVersion() const
ROD minor version getter.
Definition: HLTResultMT.cxx:239
HLT::HLTResultMT::setStreamTags
StatusCode setStreamTags(const std::vector< eformat::helper::StreamTag > &streamTags)
Replace the stored list of stream tags with the given one.
Definition: HLTResultMT.cxx:53
OnlineErrorCode.h
HLT::HLTResultMT::getSerialisedData
const std::unordered_map< uint16_t, std::vector< uint32_t > > & getSerialisedData() const
Serialised data getter.
Definition: HLTResultMT.cxx:147
HLT::HLTResultMT::getStreamTagsNonConst
std::vector< eformat::helper::StreamTag > & getStreamTagsNonConst()
Non-const-getter for stream tags needed by the result maker to remove disabled ROBs/SubDets.
Definition: HLTResultMT.cxx:48
HLT::HLTResultMT::setHltPrescaledBits
void setHltPrescaledBits(const boost::dynamic_bitset< uint32_t > &bitset)
Replace HLT prescaled bits with the given bitset.
Definition: HLTResultMT.cxx:118
get_generator_info.version
version
Definition: get_generator_info.py:33
HLT::OnlineErrorCode
OnlineErrorCode
Definition: OnlineErrorCode.h:15
HLT::HLTResultMT::RODMinorVersion
std::pair< uint8_t, uint8_t > RODMinorVersion
Type to store decoded ROD minor version (16-bit version split into two 8-bit numbers)
Definition: HLTResultMT.h:50
Athena::Status
Status
Athena specific StatusCode values.
Definition: AthStatusCode.h:22
HLT::HLTResultMT::severeTruncation
bool severeTruncation() const
Truncation in at least one collection that is not allowed to be truncated.
Definition: HLTResultMT.h:174
HLT::HLTResultMT::m_truncatedModuleIds
std::set< uint16_t > m_truncatedModuleIds
List of module IDs with truncation.
Definition: HLTResultMT.h:211
CLASS_DEF
#define CLASS_DEF(NAME, CID, VERSION)
associate a clid and a version to a type eg
Definition: Control/AthenaKernel/AthenaKernel/CLASS_DEF.h:64
HLT::HLTResultMT::setVersion
void setVersion(RODMinorVersion version)
ROD minor version setter.
Definition: HLTResultMT.cxx:244
HLT::HLTResultMT::setHltPassRawBits
void setHltPassRawBits(const boost::dynamic_bitset< uint32_t > &bitset)
Replace HLT pass raw bits with the given bitset.
Definition: HLTResultMT.cxx:111
HLT::HLTResultMT::addErrorCode
void addErrorCode(const HLT::OnlineErrorCode &errorCode, const eformat::helper::Status &firstStatusWord={ eformat::GenericStatus::DATA_CORRUPTION, eformat::FullEventStatus::PSC_PROBLEM })
Append an error code.
Definition: HLTResultMT.cxx:218
HLT::HLTResultMT::getStatus
const std::vector< uint32_t > & getStatus() const
Full event status reference getter (1 bit-mask status word + error code words)
Definition: HLTResultMT.cxx:196
HLT::HLTResultMT::getHltPrescaledBits
const boost::dynamic_bitset< uint32_t > & getHltPrescaledBits() const
Const-getter for HLT prescaled bits.
Definition: HLTResultMT.cxx:95
HLT::HLTResultMT::setStatus
void setStatus(std::vector< uint32_t > status)
Replace the full status words with the given data.
Definition: HLTResultMT.cxx:212
str
Definition: BTagTrackIpAccessor.cxx:11
merge.status
status
Definition: merge.py:17
HLT::HLTResultMT::getHltBitsAsWords
const std::vector< uint32_t > & getHltBitsAsWords() const
Const-getter for HLT bits as uint32_t array. Ordering: PassRaw, Prescaled.
Definition: HLTResultMT.cxx:100
HLT::HLTResultMT::m_hltPassRawBits
boost::dynamic_bitset< uint32_t > m_hltPassRawBits
HLT bits (flagging which chains passed)
Definition: HLTResultMT.h:187
CLASS_DEF.h
macros to associate a CLID to a type
HLT::HLTResultMT::HLTResultMT
HLTResultMT(std::vector< eformat::helper::StreamTag > streamTags={}, boost::dynamic_bitset< uint32_t > hltPassRawBits=boost::dynamic_bitset< uint32_t >(), boost::dynamic_bitset< uint32_t > hltPrescaledBits=boost::dynamic_bitset< uint32_t >(), std::unordered_map< uint16_t, std::vector< uint32_t > > data={})
Standard constructor.
Definition: HLTResultMT.cxx:30
HLT::HLTResultMT::getHltPassRawBits
const boost::dynamic_bitset< uint32_t > & getHltPassRawBits() const
Const-getter for HLT pass raw bits.
Definition: HLTResultMT.cxx:90