ATLAS Offline Software
Loading...
Searching...
No Matches
Holder.h
Go to the documentation of this file.
1// Emacs -*- c++ -*-
2
3/*
4 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
5*/
6
7#ifndef TRIGNAVIGATION_HOLDER_H
8#define TRIGNAVIGATION_HOLDER_H
9#include <string>
10#include <vector>
11#include <type_traits>
12#include <memory>
13
14#include "GaudiKernel/ClassID.h"
15
21#include "AthLinks/ElementLinkVector.h"
23
27
31
33#include "GaudiKernel/ToolHandle.h"
34
35class MsgStream;
36
37namespace SG {
38 class IAuxStoreIO;
39 class AuxStoreInternal;
40}
41
42namespace HLTNavDetails {
43
47 //note: needs to be up here to get template compiled.
48 std::string formatSGkey(const std::string& prefix, const std::string& containername, const std::string& label);
49
50
58
59 class IHolder : public HLT::BaseHolder {
60 public:
61 IHolder();
62 IHolder(const std::string& prefix, const std::string& label, uint16_t idx );
63 virtual ~IHolder();
64
65
66 virtual IHolder* clone(const std::string& prefix, const std::string& label, uint16_t idx) const = 0; // actual constructor
67
71
72 virtual void prepare(const asg::AsgMessaging& logger, HLT::AccessProxy* sg, IConversionSvc* objSerializer, bool readonly);
73
75
79 virtual CLID typeClid() const = 0;
80 virtual CLID containerClid() const = 0;
81 virtual CLID auxClidOrZero() const = 0;
82
86 inline const std::string& label() const { return m_label; }
87
91 virtual const std::string& prefix() const { return m_prefix; }
92
96 virtual const std::string& key() const = 0;
97
101 virtual const std::string& typeName() const = 0;
102
106 virtual const std::string& collectionName() const = 0;
107
112 inline uint16_t subTypeIndex() const { return m_subTypeIndex; }
113
114 std::string generateAliasKey(CLID c, uint16_t sti, const std::string& label, unsigned size);
115
119 virtual bool serialize(std::vector<uint32_t>& output) const;
120
125 std::vector<uint32_t>& output,
126 size_t& payloadsize);
127
128
132 bool serializePayload(std::vector<uint32_t>& dataBlob,
133 const xAOD::AuxSelection& sel);
134
135
136
137 virtual void print(MsgStream& m) const;
138
142 bool deserializePayload(const std::vector<uint32_t>& dataBlob, int version);
143
144 // serialization helpers
145 virtual DataObject* getDataObject() = 0;
146 virtual DataObject* getAuxDataObject() = 0;
147
148 virtual bool setDataObject(DataObject* dobj) = 0;
149 virtual bool setAuxDataObject(DataObject* dobjaux) = 0;
150
154 virtual const ITypeProxy& containerTypeProxy() const = 0;
155
157 virtual std::string getUniqueKey() = 0; // this is backward compatibility for TrigCaloRec and TrigTauRec, whould be removed
158 virtual std::string getNextKey() = 0; // this is backward compatibility for TrigCaloRec and TrigTauRec, whould be removed
159
160 protected:
161 // serialization helpers
163 IConversionSvc* m_objectserializerSvc{0};
165
166 bool m_readonly{false};
167 std::unique_ptr<ITypeProxy> m_aux;
168
169 // Adapters so we can use ATH_MSG macros
170 MsgStream& msg() const { return m_logger->msg(); }
171 MsgStream& msg(const MSG::Level lvl) const { return msg() << lvl; }
172 bool msgLvl(const MSG::Level lvl) const { return msg().level() <= lvl; }
173
174 private:
192 bool serializeDynVars (const SG::IAuxStoreIO& iio,
193 const xAOD::AuxSelection& sel,
194 std::vector<uint32_t>& dataBlob);
195
196
211 bool deserializeDynVars (const std::vector<uint32_t>& dataBlob,
212 size_t offs,
213 SG::IAuxStore& store);
214
215
226 std::unique_ptr<SG::IAuxStore>
227 deserializeDynVars (const std::vector<uint32_t>& dataBlob,
228 size_t offs);
229
230
238 const std::type_info* getElementType (const std::string& tname,
239 std::string& elementTypeName) const;
240
241
242 std::string m_prefix;
243 std::string m_label;
244 uint16_t m_subTypeIndex{0};
246
248 ToolHandle<ITrigSerializerToolBase> m_serializer;
249 };
250
251
253
258
259 template<class STORED, class CONTAINER, bool is_same> struct set_link;
260
261 template<class STORED, class CONTAINER>
262 struct set_link<STORED,CONTAINER,true>{
264 static type do_it(const STORED* el, const CONTAINER* src, HLT::TriggerElement::ObjectIndex idx){
265 (void)src;(void)idx; //not used here
266 type t(el);
267 return t;
268 }
269 };
270
271 template<class STORED, class CONTAINER>
272 struct set_link<STORED,CONTAINER,false>{
274 static type do_it(const STORED* el,const CONTAINER* src, HLT::TriggerElement::ObjectIndex idx){
275 (void)el;//not used here
276 type t(*src,idx.objectsBegin());
277 return t;
278 }
279 };
280
282 template<class T, class C> class HolderImp;
289 template<class STORED>
290 class Holder : public IHolder {
291 public:
293 Holder(const std::string& prefix, const std::string& label, uint16_t idx);
294 virtual ~Holder();
295
296 virtual HLT::TriggerElement::ObjectIndex add ATLAS_NOT_THREAD_SAFE ( const STORED* f, bool inSG, const std::string& = "" ) = 0;
297 virtual bool get(const STORED*& dest, HLT::TriggerElement::ObjectIndex idx) = 0;
298
299 template<class CONTAINER2>
301
302 template<class CONTAINER2>
304
305 template<class CONTAINER2>
306 bool getWithLink(typename set_link<STORED,CONTAINER2,std::is_same<STORED,CONTAINER2>::value>::type& link,
308
309 bool result = static_cast<HolderImp<STORED,CONTAINER2>*>(this)->getWithLink(link,idx);
310 return result;
311 }
312
313 virtual bool contains(const STORED* obj, HLT::TriggerElement::ObjectIndex& idx) = 0;
314 };
315
317
328 template<class STORED, class CONTAINER>
329 class HolderImp: public Holder<STORED> {
330 public:
332 typedef STORED stored_type;
333 typedef CONTAINER container_type;
336
338 HolderImp(const std::string& prefix, const std::string& label, uint16_t idx);
339 virtual ~HolderImp();
340
341 virtual IHolder* clone(const std::string& prefix, const std::string& label, uint16_t idx ) const;
342
346 virtual HLT::TriggerElement::ObjectIndex add( const STORED* f, bool inSG = false, const std::string& = "" );
347
351 virtual bool get(const STORED*& dest, HLT::TriggerElement::ObjectIndex idx);
352
356 virtual bool contains(const STORED* obj, HLT::TriggerElement::ObjectIndex& idx);
357
360
361 bool getWithLink(typename set_link<STORED,CONTAINER,std::is_same<STORED,CONTAINER>::value>::type& link,
363
364 virtual std::string getUniqueKey(); // this is backward compatibility for TrigCaloRec and TrigTauRec, whould be removed
365 virtual std::string getNextKey(); // this is backward compatibility for TrigCaloRec and TrigTauRec, whould be removed
366
367 virtual void prepare(const asg::AsgMessaging& logger, HLT::AccessProxy* sg, IConversionSvc* objSerializer, bool readonly = false);
370
371 virtual bool serialize(std::vector<uint32_t>& output) const;
372
373 virtual const std::string& key() const { return m_key; }
374 virtual void print(MsgStream& m) const;
375
376 virtual DataObject* getDataObject();
377 virtual DataObject* getAuxDataObject();
378 virtual bool setDataObject(DataObject* dobj);
379 virtual bool setAuxDataObject(DataObject* dobjaux);
380
381 virtual CLID typeClid() const { return ClassID_traits<STORED>::ID(); }
382 virtual const std::string& typeName() const { return ClassID_traits<STORED>::typeName(); }
384 virtual const std::string& collectionName() const { return ClassID_traits<CONTAINER>::typeName(); }
385 virtual CLID auxClidOrZero() const;
386
387 virtual const ITypeProxy& containerTypeProxy() const { return m_containerProxy; }
388
389 // for memory management
390 struct MemoryMgr {
392 MemoryMgr(const FeatureProxy& st, bool inSG);
393 void clear();
395 bool inSG;
396 };
397
399
400 typedef std::multimap<HLT::TriggerElement::ObjectIndex, MemoryMgr> MemoryMgrMap;
402
403 private:
404 std::string m_key; //<! StoreGate key
405 };
406
407 MsgStream& operator<< ( MsgStream& m, const HLTNavDetails::IHolder& nav ); //<! printing helper
408 template<class T>
409 MsgStream& operator<< ( MsgStream& m, const HLTNavDetails::Holder<T>& nav ); //<! printing helper
410 template<class T, class C>
411 MsgStream& operator<< ( MsgStream& m, const HLTNavDetails::HolderImp<T, C>& nav ); //<! printing helper
412} // end of namespace
413#endif
An STL vector of pointers that by default owns its pointed-to elements.
uint32_t CLID
The Class ID type.
convert to and from a SG storable
size_t size() const
Number of registered mappings.
Define macros for attributes used to control the static checker.
ElementLinkVector implementation for standalone ROOT.
This is an implementation class for all Holders It is templated with 2 arguments STORED which is type...
Definition Holder.h:329
virtual bool setDataObject(DataObject *dobj)
virtual bool get(const STORED *&dest, HLT::TriggerElement::ObjectIndex idx)
gets object(s) holded
virtual std::string getNextKey()
bool getElementLinks(ElementLinkVector< CONTAINER > &cont)
virtual bool checkAndSetOwnership(SG::OwnershipPolicy policy)
virtual CLID typeClid() const
returns the CLID of objects stores by this holder
Definition Holder.h:381
virtual std::string getUniqueKey()
bool getWithLink(typename set_link< STORED, CONTAINER, std::is_same< STORED, CONTAINER >::value >::type &link, HLT::TriggerElement::ObjectIndex &idx)
Holder< STORED > base_type
Definition Holder.h:331
bool getElementLinks(ElementLinkVector< CONTAINER > &cont, HLT::TriggerElement::ObjectIndex idx)
HLTNavDetails::TypeProxy< CONTAINER > ContainerProxy
Definition Holder.h:335
std::multimap< HLT::TriggerElement::ObjectIndex, MemoryMgr > MemoryMgrMap
Definition Holder.h:400
virtual DataObject * getDataObject()
virtual const std::string & collectionName() const
returns the collection's name stored by this holder
Definition Holder.h:384
HLTNavDetails::TypeProxy< STORED > FeatureProxy
Definition Holder.h:334
virtual CLID auxClidOrZero() const
virtual bool contains(const STORED *obj, HLT::TriggerElement::ObjectIndex &idx)
check if object(s) in dest are held by this holder
ContainerProxy m_containerProxy
Definition Holder.h:398
MemoryMgrMap m_memMgr
Definition Holder.h:401
virtual bool setAuxDataObject(DataObject *dobjaux)
HolderImp(const std::string &prefix, const std::string &label, uint16_t idx)
virtual IHolder * clone(const std::string &prefix, const std::string &label, uint16_t idx) const
CONTAINER container_type
Definition Holder.h:333
virtual bool serialize(std::vector< uint32_t > &output) const
serializes this Holder
virtual const std::string & typeName() const
returns the object's name stored by this holder
Definition Holder.h:382
virtual const std::string & key() const
returns the containers StoreGate key
Definition Holder.h:373
virtual CLID containerClid() const
Definition Holder.h:383
virtual DataObject * getAuxDataObject()
virtual HLT::TriggerElement::ObjectIndex add(const STORED *f, bool inSG=false, const std::string &="")
adds object(s) to be holded
virtual void prepare(const asg::AsgMessaging &logger, HLT::AccessProxy *sg, IConversionSvc *objSerializer, bool readonly=false)
prepares this holder by setting messaging, StoreGate access and providing serializer
virtual const ITypeProxy & containerTypeProxy() const
Get the proxy for the container.
Definition Holder.h:387
virtual bool syncWithSG(SG::OwnershipPolicy policy=SG::OWN_ELEMENTS)
virtual void print(MsgStream &m) const
virtual HLT::TriggerElement::ObjectIndex add ATLAS_NOT_THREAD_SAFE(const STORED *f, bool inSG, const std::string &="")=0
saved object in this holder
bool get(ElementLinkVector< CONTAINER2 > &cont, HLT::TriggerElement::ObjectIndex idx)
bool getWithLink(typename set_link< STORED, CONTAINER2, std::is_same< STORED, CONTAINER2 >::value >::type &link, HLT::TriggerElement::ObjectIndex &idx)
Definition Holder.h:306
Holder(const std::string &prefix, const std::string &label, uint16_t idx)
bool get(ElementLinkVector< CONTAINER2 > &cont)
virtual bool get(const STORED *&dest, HLT::TriggerElement::ObjectIndex idx)=0
virtual bool contains(const STORED *obj, HLT::TriggerElement::ObjectIndex &idx)=0
MsgStream & msg(const MSG::Level lvl) const
Definition Holder.h:171
std::string generateAliasKey(CLID c, uint16_t sti, const std::string &label, unsigned size)
Definition Holder.cxx:97
virtual const std::string & key() const =0
returns the containers StoreGate key
std::unique_ptr< ITypeProxy > m_aux
Definition Holder.h:167
bool serializeWithPayload(const xAOD::AuxSelection &sel, std::vector< uint32_t > &output, size_t &payloadsize)
serializes this Holder including payload
Definition Holder.cxx:78
virtual CLID containerClid() const =0
ToolHandle< ITrigSerializerToolBase > m_serializer
Serializer tool; used for dynamic variables.
Definition Holder.h:248
virtual DataObject * getAuxDataObject()=0
virtual IHolder * clone(const std::string &prefix, const std::string &label, uint16_t idx) const =0
std::string m_label
label given to the objects in this holder (labels given at attachFeature)
Definition Holder.h:243
virtual bool syncWithSG(SG::OwnershipPolicy policy=SG::OWN_ELEMENTS)=0
const std::string & label() const
returns the label of objects stores by this holder
Definition Holder.h:86
virtual bool setDataObject(DataObject *dobj)=0
virtual bool serialize(std::vector< uint32_t > &output) const
serializes this Holder
Definition Holder.cxx:61
bool serializeDynVars(const SG::IAuxStoreIO &iio, const xAOD::AuxSelection &sel, std::vector< uint32_t > &dataBlob)
Serialize all selected dynamic variables for an xAOD object.
Definition Holder.cxx:344
HLT::AccessProxy * m_storeGate
pointer to SG
Definition Holder.h:164
const asg::AsgMessaging * m_logger
Definition Holder.h:162
virtual void print(MsgStream &m) const
Definition Holder.cxx:106
uint16_t m_subTypeIndex
index to notify how many objects of given type we have (we need to record it in case of slimming will...
Definition Holder.h:244
bool serializePayload(std::vector< uint32_t > &dataBlob, const xAOD::AuxSelection &sel)
serializes the payload of this Holder
Definition Holder.cxx:253
const std::type_info * getElementType(const std::string &tname, std::string &elementTypeName) const
Find the type of an element of a vector.
Definition Holder.cxx:543
std::string m_prefix
prefix for key given to the objects
Definition Holder.h:242
virtual std::string getUniqueKey()=0
MsgStream & msg() const
Definition Holder.h:170
bool deserializePayload(const std::vector< uint32_t > &dataBlob, int version)
deserialization of holder payload
Definition Holder.cxx:147
virtual std::string getNextKey()=0
virtual CLID auxClidOrZero() const =0
IConversionSvc * m_objectserializerSvc
pointer to object serializer
Definition Holder.h:163
virtual CLID typeClid() const =0
returns the CLID of objects stores by this holder
virtual DataObject * getDataObject()=0
virtual const ITypeProxy & containerTypeProxy() const =0
Get the proxy for the container.
virtual const std::string & prefix() const
returns the containers StoreGate prefix
Definition Holder.h:91
bool deserializeDynVars(const std::vector< uint32_t > &dataBlob, size_t offs, SG::IAuxStore &store)
Read dynamic auxiliary variables from a serialized buffer.
Definition Holder.cxx:404
virtual const std::string & typeName() const =0
returns the object's name stored by this holder
virtual bool checkAndSetOwnership(SG::OwnershipPolicy policy)=0
virtual const std::string & collectionName() const =0
returns the collection's name stored by this holder
uint16_t subTypeIndex() const
returns the index (short number used when linking object to the TE) of objects stores by this holder
Definition Holder.h:112
virtual void prepare(const asg::AsgMessaging &logger, HLT::AccessProxy *sg, IConversionSvc *objSerializer, bool readonly)
prepares this holder by setting messaging, StoreGate access and providing serializer
Definition Holder.cxx:54
virtual bool setAuxDataObject(DataObject *dobjaux)=0
bool msgLvl(const MSG::Level lvl) const
Definition Holder.h:172
Interface to the TypeProxy<...> objects created at runtime.
Definition TypeProxy.h:39
Type specific implementation of ITypeProxy.
Definition TypeProxy.h:170
Helper class for conversion from/to int stored in TE and pair of ints used in Navigation Object point...
This is an implementation class for all Holders It is templated with 2 arguments STORED which is type...
Definition Holder.h:329
Interface providing I/O for a generic auxiliary store.
Definition IAuxStoreIO.h:44
Interface for non-const operations on an auxiliary store.
Definition IAuxStore.h:48
Class mimicking the AthMessaging class from the offline software.
Class helping in dealing with dynamic branch selection.
bool add(const std::string &hname, TKey *tobj)
Definition fastadd.cxx:55
static Root::TMsgLogger logger("iLumiCalc")
std::string label(const std::string &format, int i)
Definition label.h:19
std::string formatSGkey(const std::string &prefix, const std::string &containername, const std::string &label)
declaration of formatting function.
Definition Holder.cxx:121
MsgStream & operator<<(MsgStream &m, const HLTNavDetails::IHolder &nav)
Definition Holder.cxx:111
StoreGateSvc AccessProxy
Definition AccessProxy.h:17
Forward declaration.
OwnershipPolicy
@ OWN_ELEMENTS
this data object owns its elements
AuxStoreInternal(bool standalone=false)
An auxiliary data store that holds data internally.
MemoryMgr(const FeatureProxy &st, bool inSG)