ATLAS Offline Software
Loading...
Searching...
No Matches
MCEventInfoByteStreamTool.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef BYTESTREAMCNVSVC_MCEVENTINFOBYTESTREAMTOOL_H
6#define BYTESTREAMCNVSVC_MCEVENTINFOBYTESTREAMTOOL_H
7
19
26#include "Gaudi/Property.h"
27
28#include <vector>
29#include <memory>
30#include <cstdint>
31
36class IMCEventInfoByteStreamTool : virtual public IAlgTool {
37public:
39 virtual ~IMCEventInfoByteStreamTool() override = default;
40
42 virtual StatusCode convertToBS(std::vector<OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment*>& vrobf,
43 const EventContext& eventContext) = 0;
44
47 xAOD::EventInfo& evtInfo) const = 0;
48
50 virtual const std::vector<uint32_t>& robIds() const = 0;
51};
52
71class MCEventInfoByteStreamTool : public extends<AthAlgTool, IMCEventInfoByteStreamTool> {
72public:
73 MCEventInfoByteStreamTool(const std::string& type, const std::string& name, const IInterface* parent);
74 virtual ~MCEventInfoByteStreamTool() override = default;
75
76 virtual StatusCode initialize() override;
77
79 virtual StatusCode convertToBS(std::vector<OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment*>& vrobf,
80 const EventContext& eventContext) override;
81
83 virtual StatusCode convertFromBS(const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment* rob,
84 xAOD::EventInfo& evtInfo) const override;
85
87 virtual const std::vector<uint32_t>& robIds() const override { return m_robIds.value(); }
88
90 static constexpr uint32_t MC_EVENTINFO_ROB_ID = 0x00ff0001;
91
93 static constexpr uint32_t FORMAT_VERSION = 0x00010000; // v1.0
94
96 static constexpr uint32_t MIN_DATA_WORDS = 14;
97
98private:
100 void clearCache(const EventContext& eventContext);
101
103 uint32_t* newRodData(const EventContext& eventContext, size_t size);
104
107 const EventContext& eventContext,
108 uint32_t source_id,
109 uint32_t ndata,
110 const uint32_t* data);
111
112 // Properties
113 Gaudi::Property<std::vector<uint32_t>> m_robIds {
114 this, "ROBIDs", {MC_EVENTINFO_ROB_ID}, "List of ROB IDs for MC EventInfo"};
115
117 this, "EventInfoReadKey", "", "Read handle key for EventInfo (encoding mode)"};
118
119 // Cache for ByteStream data representation
120 struct Cache {
121 std::vector<std::unique_ptr<uint32_t[]>> rodData;
122 std::vector<std::unique_ptr<OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment>> robFragments;
123 ~Cache() { clear(); }
124 void clear() {
125 rodData.clear();
126 robFragments.clear();
127 }
128 };
130};
131
132#endif // BYTESTREAMCNVSVC_MCEVENTINFOBYTESTREAMTOOL_H
Maintain a set of objects, one per slot.
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
Property holding a SG store/key/clid from which a ReadHandle is made.
Property holding a SG store/key/clid from which a WriteHandle is made.
size_t size() const
Number of registered mappings.
Interface for MCEventInfoByteStreamTool.
virtual ~IMCEventInfoByteStreamTool() override=default
DeclareInterfaceID(IMCEventInfoByteStreamTool, 1, 0)
virtual StatusCode convertToBS(std::vector< OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment * > &vrobf, const EventContext &eventContext)=0
Convert xAOD::EventInfo MC fields to ByteStream ROB fragment.
virtual const std::vector< uint32_t > & robIds() const =0
Return the ROB IDs used by this tool.
virtual StatusCode convertFromBS(const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment *rob, xAOD::EventInfo &evtInfo) const =0
Decode MC EventInfo from ROB fragment and fill xAOD::EventInfo.
virtual StatusCode convertFromBS(const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment *rob, xAOD::EventInfo &evtInfo) const override
Decode MC EventInfo from ROB fragment and fill xAOD::EventInfo.
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoReadKey
virtual StatusCode convertToBS(std::vector< OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment * > &vrobf, const EventContext &eventContext) override
Convert xAOD::EventInfo MC fields to ByteStream ROB fragment.
virtual ~MCEventInfoByteStreamTool() override=default
static constexpr uint32_t MC_EVENTINFO_ROB_ID
Static ROB ID for MC EventInfo (SubDetector=OTHER=0xFF, ModuleId=0x01).
virtual const std::vector< uint32_t > & robIds() const override
Return the ROB IDs used by this tool.
MCEventInfoByteStreamTool(const std::string &type, const std::string &name, const IInterface *parent)
static constexpr uint32_t FORMAT_VERSION
Version word for the data format.
void clearCache(const EventContext &eventContext)
Helper to clear the ByteStream data cache for a given event slot.
OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment * newRobFragment(const EventContext &eventContext, uint32_t source_id, uint32_t ndata, const uint32_t *data)
Allocate new ROBFragment for output ByteStream data.
virtual StatusCode initialize() override
static constexpr uint32_t MIN_DATA_WORDS
Minimum number of words in the ROB data (excluding weights).
SG::SlotSpecificObj< Cache > m_cache
Gaudi::Property< std::vector< uint32_t > > m_robIds
uint32_t * newRodData(const EventContext &eventContext, size_t size)
Allocate new array of raw ROD words for output ByteStream data.
Property holding a SG store/key/clid from which a ReadHandle is made.
Maintain a set of objects, one per slot.
eformat::write::ROBFragment ROBFragment
Definition RawEvent.h:33
eformat::ROBFragment< PointerType > ROBFragment
Definition RawEvent.h:27
EventInfo_v1 EventInfo
Definition of the latest event info version.
std::vector< std::unique_ptr< uint32_t[]> > rodData
std::vector< std::unique_ptr< OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment > > robFragments