ATLAS Offline Software
Loading...
Searching...
No Matches
TrigSerializeConvHelper Class Reference

it is the worker class for templated converters non templated code should be concentrated here to avoid massive recompilation of the templated code More...

#include <TrigSerializeConvHelper.h>

Inheritance diagram for TrigSerializeConvHelper:
Collaboration diagram for TrigSerializeConvHelper:

Public Member Functions

 TrigSerializeConvHelper (const std::string &name, const std::string &type, const IInterface *parent)
virtual ~TrigSerializeConvHelper ()
StatusCode createObj (const std::string &clname, IOpaqueAddress *iAddr, void *&ptr, bool isxAOD=false)
StatusCode createRep (const std::string &clname, void *ptr, std::vector< uint32_t > &out, bool isxAOD=false)
StatusCode initialize ()
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Static Public Member Functions

static const InterfaceID & interfaceID ()

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvc > StoreGateSvc_t

Private Member Functions

Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

ToolHandle< ITrigSerializerToolBase > m_serializerTool
ToolHandle< TrigSerTPTool > m_TPTool
ToolHandle< ITrigSerializeGuidHelper > m_guidTool
bool m_doTP
std::map< std::string, std::string > m_oldEDMmap
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default).
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default).
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

it is the worker class for templated converters non templated code should be concentrated here to avoid massive recompilation of the templated code

Author
Jiri Masik Jiri..nosp@m.Masi.nosp@m.k@cer.nosp@m.n.ch

Definition at line 29 of file TrigSerializeConvHelper.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 376 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ TrigSerializeConvHelper()

TrigSerializeConvHelper::TrigSerializeConvHelper ( const std::string & name,
const std::string & type,
const IInterface * parent )

Definition at line 18 of file TrigSerializeConvHelper.cxx.

18 :
19 AthAlgTool(toolname, type, parent),
20 m_serializerTool("TrigTSerializer/TrigTSerializer"),
21 m_TPTool("TrigSerTPTool/TrigSerTPTool"),
22 m_guidTool("TrigSerializeGuidHelper/TrigSerializeGuidHelper"),
23 m_doTP(true)
24{
25 declareInterface<ITrigSerializeConvHelper>( this );
26 declareProperty("doTP", m_doTP, "allows to serialize/deserialize transient classes");
27}
AthAlgTool()
Default constructor:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
ToolHandle< TrigSerTPTool > m_TPTool
ToolHandle< ITrigSerializeGuidHelper > m_guidTool
ToolHandle< ITrigSerializerToolBase > m_serializerTool

◆ ~TrigSerializeConvHelper()

TrigSerializeConvHelper::~TrigSerializeConvHelper ( )
virtual

Definition at line 29 of file TrigSerializeConvHelper.cxx.

29 {
30}

Member Function Documentation

◆ createObj()

StatusCode TrigSerializeConvHelper::createObj ( const std::string & clname,
IOpaqueAddress * iAddr,
void *& ptr,
bool isxAOD = false )
virtual
Returns
StatusCode

Implements ITrigSerConvHelperBase.

Definition at line 81 of file TrigSerializeConvHelper.cxx.

81 {
82 ptr = 0;
83 ATH_MSG_DEBUG("in TrigSerializeConvHelper::createObj for clname " << clname << " is xAOD? " << (isxAOD?"yes":"no"));
84
85 //could alse get DATA (perhaps as std::any) from the IOA
86 TrigStreamAddress *addr = dynamic_cast<TrigStreamAddress*>(iAddr);
87 if (!addr) {
88 ATH_MSG_WARNING("createObj cast failed");
89 return StatusCode::FAILURE;
90 }
91
92 ITrigSerializerToolBase* serializer = m_serializerTool.operator->();
93 serializer->reset();
94
95 std::vector<uint32_t> v = addr->get();
96
97 //we need to find the name of the ob
98 std::string cl = clname;
99
100 if (m_doTP and !isxAOD)
101 cl = m_TPTool->persClassName(clname);
102
103 uint32_t guid[4];
104
105 bool versionChange = false;
106
107 if (cl!=""){
108 StatusCode scid;
109 scid = serializer->peekCLID(v, guid);
110 if (scid.isFailure()){
111 //BS has no hint on the pers class - use the original table
112 ATH_MSG_DEBUG("BS does not hint on payload object " << cl);
113 if (m_oldEDMmap.find(clname)!=m_oldEDMmap.end()){
114 if (cl!=m_oldEDMmap[clname]){
115 ATH_MSG_DEBUG("Using backward compatibility map with " << m_oldEDMmap[clname]
116 << " instead of " << cl);
117 cl = m_oldEDMmap[clname];
118 }
119 }
120 } else {
121 //get the pers version from the BS
122 std::string nclass = cl;
123 StatusCode ai = m_guidTool->IntsToClassName(guid, nclass);
124 if (ai.isFailure()) {
125 //better do not decode
126 return StatusCode::FAILURE;
127 }
128 if (cl != nclass){
129 cl = nclass;
130 ATH_MSG_DEBUG("Got hint of " << cl << " different persistent class from the BS payload. Name from GUID: " << nclass);
131
132 if(isxAOD){
133 ATH_MSG_DEBUG("This is an xAOD so probably the BS version is an older version of the xAOD type.");
134 }
135 versionChange = true;
136 }
137 }
138
139 // Many variables in this class were changed from double to float.
140 // However, we wrote data in the past which contained values
141 // that were valid doubles but which were out of range for floats.
142 // So we can get FPEs when we read them.
143 // Disable FPEs when we're reading an instance of this class.
144 CxxUtils::FPControl fpcontrol;
145 if (cl == "xAOD::BTaggingTrigAuxContainer_v1") {
146 fpcontrol.holdExceptions();
147 }
148
149 ptr = serializer->deserialize(cl, v);
150
151 ATH_MSG_DEBUG(cl << " deserialized to " << ptr << " version change detected: " << (versionChange ? "yes":"no"));
152 }
153
154 // T/P separation
155 bool isViewVector = cl.substr(0, 11) == "ViewVector<";
156 if (m_doTP and (!isxAOD or versionChange) and !isViewVector){
157 std::string transclass;
158
159 ATH_MSG_DEBUG("converting with pername " << cl);
160
161 void *transObj = m_TPTool->convertPT(cl,ptr, transclass);
162
163 ATH_MSG_DEBUG("was converted to " << transclass << " at " << transObj);
164
165 //persistent object not needed anymore
166 RootType persClObj(cl);
167 persClObj.Destruct(ptr);
168
169 ptr = transObj;
170 }
171
172 return StatusCode::SUCCESS;
173}
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_WARNING(x,...)
TTypeAdapter RootType
Definition RootType.h:211
virtual StatusCode peekCLID(const std::vector< uint32_t > &v, uint32_t *guid) const =0
access clid of the payload (stored in BS)
virtual void reset()=0
clean internal serializer state.
virtual void * deserialize(const std::string &nameOfClass, const std::vector< uint32_t > &v)=0
deserializes an object of a class nameOfClass (and recursively other objects) found in std::vector<ui...
std::map< std::string, std::string > m_oldEDMmap
const std::vector< uint32_t > & get() const
::StatusCode StatusCode
StatusCode definition for legacy code.
void * ptr(T *p)
Definition SGImplSvc.cxx:76
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]
setEventNumber uint32_t

◆ createRep()

StatusCode TrigSerializeConvHelper::createRep ( const std::string & clname,
void * ptr,
std::vector< uint32_t > & out,
bool isxAOD = false )
virtual
Returns
StatusCode

Implements ITrigSerConvHelperBase.

Definition at line 177 of file TrigSerializeConvHelper.cxx.

178 {
179
180 StatusCode sc(StatusCode::SUCCESS);
181
182 ATH_MSG_DEBUG("in TrigSerializeConvHelper::createRep for clname" << clname << " is xAOD? " << (isxAOD?"yes":"no"));
183
184 std::string cl = clname;
185 void *pObj = ptr;
186
187 // T/P separation
188 if (m_doTP and !isxAOD){
189 std::string persclass("");
190 pObj = m_TPTool->convertTP(clname,ptr, persclass);
191 cl = std::move(persclass);
192 }
193
194 ATH_MSG_DEBUG("convertTP: " << pObj << " of " << cl);
195
196 //void *serptr(0);
197 //
198 ITrigSerializerToolBase* serializer = m_serializerTool.operator->();
199 serializer->reset();
200
201 ATH_MSG_VERBOSE("About to get GUID for " << cl);
202
203 //opposite from string to class
204 uint32_t irep[4];
205 StatusCode ai = m_guidTool->ClassNameToInts(cl, irep);
206 if (ai.isFailure()){
207 ATH_MSG_WARNING("Cannot store class identification for " << cl << " to BS");
208 }
209
210 ATH_MSG_VERBOSE("got GUID: " << irep[0] << "-" << irep[1] << "-" << irep[2] << "-" << irep[3]);
211
212 if (cl != "" && pObj){
213 serializer->setCLID(irep);
214 serializer->serialize(cl, pObj, out);
215 } else {
216 ATH_MSG_WARNING("did not serialize " << ptr << " of " << clname);
217 }
218
219 if (m_doTP and !isxAOD){
220 //we don't need the persistent object anymore
221 RootType persClObj(cl);
222 persClObj.Destruct(pObj);
223 }
224
225 ATH_MSG_DEBUG("pObj: " << pObj << " of " << cl << " payload: " << out.size());
226
227 return sc;
228}
#define ATH_MSG_VERBOSE(x,...)
static Double_t sc
virtual void serialize(const std::string &nameOfClass, const void *instance, std::vector< uint32_t > &v)=0
serializes an object of a class nameOfClass pointed to by instance and recursively also other objects...
virtual void setCLID(const uint32_t *guid)=0
access clid of the payload virtual CLID getCLID() const = 0;

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ initialize()

StatusCode TrigSerializeConvHelper::initialize ( )

Definition at line 32 of file TrigSerializeConvHelper.cxx.

32 {
33
34 StatusCode sc = m_serializerTool.retrieve();
35
36 if (!sc.isSuccess()){
37 ATH_MSG_DEBUG("m_serializer not retrieved");
38 return sc;
39 } else {
40 ATH_MSG_DEBUG("m_serializer retrieved");
41 /*
42 if (m_serializerTool->initialize().isSuccess()){
43 ATH_MSG_DEBUG( "serializer initialized" );
44 }
45 */
46 }
47
48 StatusCode sctp = m_TPTool.retrieve();
49 if (!sctp.isSuccess()){
50 ATH_MSG_DEBUG( "m_TPTool not retrieved" );
51 return sctp;
52 } else {
53 ATH_MSG_DEBUG( "m_TPTool retrieved" );
54 /*
55 if (m_TPTool->initialize().isSuccess())
56 ATH_MSG_DEBUG( "m_TPTool initialized" );
57 */
58 }
59
60 StatusCode scg = m_guidTool.retrieve();
61 if (!scg.isSuccess()){
62 ATH_MSG_DEBUG( m_guidTool << " not retrieved" );
63 return scg;
64 } else {
65 ATH_MSG_DEBUG( m_guidTool << "retrieved" );
66 }
67
68 m_oldEDMmap[ "TrigRoiDescriptor" ] = "TrigRoiDescriptorCollection_tlp1";
69 m_oldEDMmap[ "TrigInDetTrackCollection" ] = "TrigInDetTrackCollection_tlp1";
70 m_oldEDMmap[ "TrigVertexCollection" ] = "TrigVertexCollection_tlp1";
71 m_oldEDMmap[ "CaloCellContainer" ] = "CaloCompactCellContainer";
72 m_oldEDMmap[ "CaloClusterContainer" ] = "CaloClusterContainer_p4";
73 m_oldEDMmap[ "CaloShowerContainer" ] = "CaloShowerContainer_p2";
74 m_oldEDMmap[ "TrackCollection" ] = "Trk::TrackCollection_tlp2";
75 m_oldEDMmap[ "Rec::TrackParticleContainer" ] = "Rec::TrackParticleContainer_tlp1";
76 m_oldEDMmap[ "VxContainer" ] = "";
77
78 return StatusCode::SUCCESS;
79}

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ interfaceID()

const InterfaceID & ITrigSerializeConvHelper::interfaceID ( )
inlinestaticinherited

Definition at line 52 of file ITrigSerConvHelper.h.

52{ return IID_ITrigSerConvHelper; }
static const InterfaceID IID_ITrigSerConvHelper("ITrigSerConvHelper", 1, 0)
Declaration of the interface ID ( interface id, major version, minor version).

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 368 of file AthCommonDataStore.h.

369 {
370 h.renounce();
372 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 352 of file AthCommonDataStore.h.

352 {
354 }

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, and AthCheckedComponent<::AthAlgTool >.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 298 of file AthCommonDataStore.h.

298 {
299 for (auto &a : m_vhka) {
301 for (auto k : keys) {
302 k->setOwner(this);
303 }
304 }
305 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default).

Definition at line 381 of file AthCommonDataStore.h.

◆ m_doTP

bool TrigSerializeConvHelper::m_doTP
private

Definition at line 43 of file TrigSerializeConvHelper.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default).

Definition at line 378 of file AthCommonDataStore.h.

◆ m_guidTool

ToolHandle<ITrigSerializeGuidHelper> TrigSerializeConvHelper::m_guidTool
private

Definition at line 42 of file TrigSerializeConvHelper.h.

◆ m_oldEDMmap

std::map<std::string,std::string> TrigSerializeConvHelper::m_oldEDMmap
private

Definition at line 44 of file TrigSerializeConvHelper.h.

◆ m_serializerTool

ToolHandle< ITrigSerializerToolBase > TrigSerializeConvHelper::m_serializerTool
private

Definition at line 40 of file TrigSerializeConvHelper.h.

◆ m_TPTool

ToolHandle<TrigSerTPTool> TrigSerializeConvHelper::m_TPTool
private

Definition at line 41 of file TrigSerializeConvHelper.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 387 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 386 of file AthCommonDataStore.h.


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