ATLAS Offline Software
TriggerEDMSerialiserTool.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 #ifndef TRIGOUTPUTHANDLING_TRIGGEREDMSERIALISERTOOL_H
5 #define TRIGOUTPUTHANDLING_TRIGGEREDMSERIALISERTOOL_H
6 
7 #include <string>
9 #include "GaudiKernel/IClassIDSvc.h"
10 #include "GaudiKernel/ServiceHandle.h"
11 #include "xAODCore/AuxSelection.h"
19 #include "Gaudi/Parsers/Factory.h" // Needed to declare less common Property types
20 
21 // Forward declarations
22 class DataObject;
23 
37 class TriggerEDMSerialiserTool: public extends<AthAlgTool, HLTResultMTMakerTool>
38 {
39 
40  public:
41 
42  TriggerEDMSerialiserTool( const std::string& type,
43  const std::string& name,
44  const IInterface* parent );
45 
46  virtual ~TriggerEDMSerialiserTool() override = default;
47  virtual StatusCode fill( HLT::HLTResultMT& resultToFill, const EventContext& ctx ) const override;
48 
49  virtual StatusCode initialize() override;
50 
51  private:
53  Gaudi::Property< std::vector< std::string > > m_collectionsToSerialize {
54  this, "CollectionsToSerialize", {},
55  "EDM streaming configuration \'collectionKeyType;module1,module2,...[;allowTruncation]\' where collectionKeyType is a string "
56  "formatted like for AthenaOutputStream, e.g. TYPE#SG.aux1.aux2..etc. For xAOD classes the typedef type should be "
57  "used and the _vN version number is automatically detected. For old T/P classes the persistent version has to be "
58  "given. Module IDs following the semicolon are the HLT result ROB module IDs to which the collection should be "
59  "written. ID=0 is the main result, other IDs are used for data scouting. The optional allowTruncation "
60  "indicates if the collection can be truncated without raising an ERROR.",
61  "OrderedSet<std::string>"
62  };
63  Gaudi::Property<bool> m_saveDynamic {
64  this, "SaveDynamic", true, "If false skips serialising of dynamic variables. Use for test purpose only."
65  };
66  Gaudi::Property<std::map<uint16_t,uint32_t>> m_truncationThresholds {
67  this, "TruncationThresholds", {}, "HLT result truncation thresholds. Key is module ID, value is max size in bytes"
68  };
69  Gaudi::Property<int> m_eventSizeHardLimitMB {
70  this, "EventSizeHardLimitMB", -1,
71  "Hard limit for output event size in megabytes. Set automatically in initialize from run parameters. "
72  "In partition, it corresponds to DCM sbaBlockSize_MiB. Value <0 means no limit."
73  };
74  Gaudi::Property<float> m_fullResultTruncationFrac {
75  this, "FullResultTruncationFrac", 0.8,
76  "Fraction of EventSizeHardLimitMB which defines the limit on the total size of HLT output (sum of all modules)"
77  };
80  this, "DebugInfoWHKey", "TruncationDebugInfo"
81  };
84  this, "NavigationSummaryRHKey", "HLTNav_Summary"
85  };
86 
91  struct Address {
93  enum class Truncation { Error, Allowed };
94  std::string transType;
95  std::string persType; // actual versioned type
97  std::string key;
98  std::vector<uint16_t> moduleIdVec{};
102 
103  std::string transTypeName() const {return transType+"#"+key;}
104  std::string persTypeName() const {return persType+"#"+key;}
105  };
106 
111  struct TruncationInfo {
112  const Address* addrPtr{nullptr};
113  size_t size{0};
114  bool recorded{false};
115  };
116 
118  using TruncationInfoMap = std::unordered_map<uint16_t, std::vector<TruncationInfo>>;
119 
120  std::vector< Address > m_toSerialise; // postprocessed configuration info
121 
122  ServiceHandle<IClassIDSvc> m_clidSvc{ this, "ClassIDSvc", "ClassIDSvc",
123  "Service to translate class name to CLID" };
124  ServiceHandle<IAthenaSerializeSvc> m_serializerSvc{ this, "Serializer", "AthenaRootSerializeSvc",
125  "Service to translate transient to persistent representation" };
126 
127  ToolHandle<TrigSerTPTool> m_tpTool{ this, "TPTool", "TrigSerTPTool/TrigSerTPTool",
128  "Tool to do Transient/Persistent conversion (Old EDM)"};
129 
130  ToolHandle<GenericMonitoringTool> m_monTool{ this, "MonTool", "", "Monitoring tool" };
131 
135  StatusCode addCollectionToSerialise(const std::string& typeKeyAuxIDs, std::vector<Address>& addressVec) const;
136 
140  static StatusCode makeHeader( const TriggerEDMSerialiserTool::Address& address, std::vector<uint32_t>& buffer );
141 
147  StatusCode fillPayload( const void* data, size_t sz, std::vector<uint32_t>& buffer ) const;
148 
149 
154  StatusCode serialiseContainer( void* data, const Address& address, std::vector<uint32_t>& buffer ) const;
159  StatusCode serialisexAODAuxContainer( void* data, const Address& address, std::vector<uint32_t>& buffer, SGImplSvc* evtStore ) const;
160 
165  StatusCode serialiseTPContainer( void* data, const Address& address, std::vector<uint32_t>& buffer ) const;
166 
170  StatusCode serialiseDynAux( DataObject* dObject, const Address& address, std::vector<uint32_t>& buffer, size_t& nDynWritten ) const;
171 
176  StatusCode serialise( const Address& address, std::vector<uint32_t>& buffer, SGImplSvc* evtStore ) const;
177 
183  StatusCode tryAddData(HLT::HLTResultMT& hltResult, const uint16_t id, const std::vector<uint32_t>& data, Address::Truncation truncationMode, const std::unordered_map<uint16_t, std::vector<uint32_t>>& deferredInterfaceBuffer) const;
184 
188  StatusCode fillDebugInfo(const TruncationInfoMap& truncationInfoMap, xAOD::TrigCompositeContainer& debugInfoCont, HLT::HLTResultMT& resultToFill, SGImplSvc* evtStore) const;
189 
193  static std::string version( const std::string& name );
194 
198  static std::set<uint16_t> activeModuleIDs(const HLT::HLTResultMT& result);
199 
200 };
201 
202 
203 #endif //> !TRIGOUTPUTHANDLING_TRIGGEREDMSERIALISERTOOL_H
TriggerEDMSerialiserTool::Address::Category::None
@ None
TriggerEDMSerialiserTool::Address::moduleIdVec
std::vector< uint16_t > moduleIdVec
Definition: TriggerEDMSerialiserTool.h:98
TrigSerTPTool.h
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
TriggerEDMSerialiserTool::initialize
virtual StatusCode initialize() override
Definition: TriggerEDMSerialiserTool.cxx:37
TriggerEDMSerialiserTool::fill
virtual StatusCode fill(HLT::HLTResultMT &resultToFill, const EventContext &ctx) const override
Definition: TriggerEDMSerialiserTool.cxx:402
TriggerEDMSerialiserTool::tester
friend StatusCode tester(TriggerEDMSerialiserTool *)
fitman.sz
sz
Definition: fitman.py:527
TriggerEDMSerialiserTool::Address::clid
CLID clid
Definition: TriggerEDMSerialiserTool.h:96
get_generator_info.result
result
Definition: get_generator_info.py:21
TriggerEDMSerialiserTool::addCollectionToSerialise
StatusCode addCollectionToSerialise(const std::string &typeKeyAuxIDs, std::vector< Address > &addressVec) const
Parse entry from m_collectionsToSerialize and add it to m_toSerialise.
Definition: TriggerEDMSerialiserTool.cxx:89
TriggerEDMSerialiserTool::m_eventSizeHardLimitMB
Gaudi::Property< int > m_eventSizeHardLimitMB
Definition: TriggerEDMSerialiserTool.h:69
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:575
TrigCompositeUtils.h
TriggerEDMSerialiserTool::m_truncationThresholds
Gaudi::Property< std::map< uint16_t, uint32_t > > m_truncationThresholds
Definition: TriggerEDMSerialiserTool.h:66
TriggerEDMSerialiserTool
Tool responsible for filling an HLT result object with serialised EDM collections.
Definition: TriggerEDMSerialiserTool.h:38
TriggerEDMSerialiserTool::m_clidSvc
ServiceHandle< IClassIDSvc > m_clidSvc
Definition: TriggerEDMSerialiserTool.h:122
TriggerEDMSerialiserTool::Address
Definition: TriggerEDMSerialiserTool.h:91
TriggerEDMSerialiserTool::TruncationInfo::recorded
bool recorded
Definition: TriggerEDMSerialiserTool.h:114
TriggerEDMSerialiserTool::Address::truncationMode
Truncation truncationMode
Definition: TriggerEDMSerialiserTool.h:100
TriggerEDMSerialiserTool::TruncationInfoMap
std::unordered_map< uint16_t, std::vector< TruncationInfo > > TruncationInfoMap
Typedef for collection of TruncationInfo objects for full event.
Definition: TriggerEDMSerialiserTool.h:118
TriggerEDMSerialiserTool::m_collectionsToSerialize
Gaudi::Property< std::vector< std::string > > m_collectionsToSerialize
Definition: TriggerEDMSerialiserTool.h:53
TriggerEDMSerialiserTool::m_debugNavigationSummaryRHKey
SG::ReadHandleKey< TrigCompositeUtils::DecisionContainer > m_debugNavigationSummaryRHKey
StoreGate key for the navigation summary object - with this we can print which chains accepted the ev...
Definition: TriggerEDMSerialiserTool.h:83
TriggerEDMSerialiserTool::tryAddData
StatusCode tryAddData(HLT::HLTResultMT &hltResult, const uint16_t id, const std::vector< uint32_t > &data, Address::Truncation truncationMode, const std::unordered_map< uint16_t, std::vector< uint32_t >> &deferredInterfaceBuffer) const
Try appending serialised data to HLT result.
Definition: TriggerEDMSerialiserTool.cxx:494
TriggerEDMSerialiserTool::serialiseTPContainer
StatusCode serialiseTPContainer(void *data, const Address &address, std::vector< uint32_t > &buffer) const
Place inside the buffer the serialised old type of container involves T/P conversion.
Definition: TriggerEDMSerialiserTool.cxx:360
HLT::HLTResultMT
A container class for data required to build online output from HLT.
Definition: HLTResultMT.h:38
TriggerEDMSerialiserTool::makeHeader
static StatusCode makeHeader(const TriggerEDMSerialiserTool::Address &address, std::vector< uint32_t > &buffer)
Given the ID of the collection (in address arg) insert basic streaming info into the buffer.
Definition: TriggerEDMSerialiserTool.cxx:185
SG::ReadHandleKey
Property holding a SG store/key/clid from which a ReadHandle is made.
Definition: StoreGate/StoreGate/ReadHandleKey.h:39
TriggerEDMSerialiserTool::fillPayload
StatusCode fillPayload(const void *data, size_t sz, std::vector< uint32_t > &buffer) const
Copy bytes from the memory into the buffer converting from char[] to uint32_t[] This function is cand...
Definition: TriggerEDMSerialiserTool.cxx:198
TriggerEDMSerialiserTool::Address::Category::xAODAux
@ xAODAux
TriggerEDMSerialiserTool::m_debugInfoWHKey
SG::WriteHandleKey< xAOD::TrigCompositeContainer > m_debugInfoWHKey
StoreGate key for the truncation debug info object.
Definition: TriggerEDMSerialiserTool.h:79
TriggerEDMSerialiserTool::Address::key
std::string key
Definition: TriggerEDMSerialiserTool.h:97
TriggerEDMSerialiserTool::m_monTool
ToolHandle< GenericMonitoringTool > m_monTool
Definition: TriggerEDMSerialiserTool.h:130
TriggerEDMSerialiserTool::Address::category
Category category
Definition: TriggerEDMSerialiserTool.h:99
TriggerEDMSerialiserTool::TruncationInfo::size
size_t size
Definition: TriggerEDMSerialiserTool.h:113
createCoolChannelIdFile.buffer
buffer
Definition: createCoolChannelIdFile.py:12
TriggerEDMSerialiserTool::activeModuleIDs
static std::set< uint16_t > activeModuleIDs(const HLT::HLTResultMT &result)
Build a list of module IDs to serialise based on the stream tags.
Definition: TriggerEDMSerialiserTool.cxx:655
SG::WriteHandleKey
Property holding a SG store/key/clid from which a WriteHandle is made.
Definition: StoreGate/StoreGate/WriteHandleKey.h:40
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:88
TriggerEDMSerialiserTool::serialise
StatusCode serialise(const Address &address, std::vector< uint32_t > &buffer, SGImplSvc *evtStore) const
Retrieve data from event store, serialise and fill the buffer using one of the specific serialise met...
Definition: TriggerEDMSerialiserTool.cxx:375
TriggerEDMSerialiserTool::TruncationInfo::addrPtr
const Address * addrPtr
Definition: TriggerEDMSerialiserTool.h:112
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
sel
sel
Definition: SUSYToolsTester.cxx:92
AthAlgTool.h
TriggerEDMSerialiserTool::version
static std::string version(const std::string &name)
Obtain version from the actual type name.
Definition: TriggerEDMSerialiserTool.cxx:644
TriggerEDMSerialiserTool::m_serializerSvc
ServiceHandle< IAthenaSerializeSvc > m_serializerSvc
Definition: TriggerEDMSerialiserTool.h:124
test_pyathena.parent
parent
Definition: test_pyathena.py:15
HLTResultMTMakerTool.h
IAthenaSerializeSvc.h
TriggerEDMSerialiserTool::m_tpTool
ToolHandle< TrigSerTPTool > m_tpTool
Definition: TriggerEDMSerialiserTool.h:127
SGImplSvc
The Athena Transient Store API.
Definition: SGImplSvc.h:116
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
TriggerEDMSerialiserTool::Address::Category
Category
Definition: TriggerEDMSerialiserTool.h:92
Monitored.h
Header file to be included by clients of the Monitored infrastructure.
TriggerEDMSerialiserTool::Address::persTypeName
std::string persTypeName() const
Definition: TriggerEDMSerialiserTool.h:104
TrigCompositeContainer.h
TriggerEDMSerialiserTool::serialisexAODAuxContainer
StatusCode serialisexAODAuxContainer(void *data, const Address &address, std::vector< uint32_t > &buffer, SGImplSvc *evtStore) const
Place inside the buffer serialised the xAOD Aux container involves selection and recording of dynamic...
Definition: TriggerEDMSerialiserTool.cxx:314
TriggerEDMSerialiserTool::Address::Category::xAODDecoration
@ xAODDecoration
xAOD::AuxSelection
Class helping in dealing with dynamic branch selection.
Definition: AuxSelection.h:31
TriggerEDMSerialiserTool::m_toSerialise
std::vector< Address > m_toSerialise
Definition: TriggerEDMSerialiserTool.h:120
TriggerEDMSerialiserTool::Address::Category::xAODInterface
@ xAODInterface
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
TriggerEDMSerialiserTool::Address::transType
std::string transType
Definition: TriggerEDMSerialiserTool.h:94
TriggerEDMSerialiserTool::m_saveDynamic
Gaudi::Property< bool > m_saveDynamic
Definition: TriggerEDMSerialiserTool.h:63
RTTAlgmain.address
address
Definition: RTTAlgmain.py:55
TriggerEDMSerialiserTool::Address::Truncation::Error
@ Error
TriggerEDMSerialiserTool::Address::Truncation
Truncation
Definition: TriggerEDMSerialiserTool.h:93
TriggerEDMSerialiserTool::m_fullResultTruncationFrac
Gaudi::Property< float > m_fullResultTruncationFrac
Definition: TriggerEDMSerialiserTool.h:74
AuxSelection.h
TriggerEDMSerialiserTool::~TriggerEDMSerialiserTool
virtual ~TriggerEDMSerialiserTool() override=default
TriggerEDMSerialiserTool::TruncationInfo
Definition: TriggerEDMSerialiserTool.h:111
IDictLoaderSvc.h
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
TriggerEDMSerialiserTool::Address::Truncation::Allowed
@ Allowed
TriggerEDMSerialiserTool::fillDebugInfo
StatusCode fillDebugInfo(const TruncationInfoMap &truncationInfoMap, xAOD::TrigCompositeContainer &debugInfoCont, HLT::HLTResultMT &resultToFill, SGImplSvc *evtStore) const
Parse the truncation debug information, fill monitoring histograms, fill and record the debug info co...
Definition: TriggerEDMSerialiserTool.cxx:538
TriggerEDMSerialiserTool::Address::persType
std::string persType
Definition: TriggerEDMSerialiserTool.h:95
TriggerEDMSerialiserTool::serialiseDynAux
StatusCode serialiseDynAux(DataObject *dObject, const Address &address, std::vector< uint32_t > &buffer, size_t &nDynWritten) const
Add dynamic variables to the payload.
Definition: TriggerEDMSerialiserTool.cxx:212
TriggerEDMSerialiserTool::Address::transTypeName
std::string transTypeName() const
Definition: TriggerEDMSerialiserTool.h:103
TriggerEDMSerialiserTool::Address::Category::OldTP
@ OldTP
TriggerEDMSerialiserTool::serialiseContainer
StatusCode serialiseContainer(void *data, const Address &address, std::vector< uint32_t > &buffer) const
Place inside the buffer the serialised container (can be either TP, xAOD) involves simple invocation ...
Definition: TriggerEDMSerialiserTool.cxx:287
TriggerEDMSerialiserTool::TriggerEDMSerialiserTool
TriggerEDMSerialiserTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: TriggerEDMSerialiserTool.cxx:32
ServiceHandle< IClassIDSvc >