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-2023 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
13#include "GaudiKernel/ClassID.h"
14
20#include "AthLinks/ElementLinkVector.h"
22
26
30
32#include "GaudiKernel/ToolHandle.h"
33
34class MsgStream;
35
36namespace SG {
37 class IAuxStoreIO;
38 class AuxStoreInternal;
39}
40
41namespace HLTNavDetails {
42
46 //note: needs to be up here to get template compiled.
47 std::string formatSGkey(const std::string& prefix, const std::string& containername, const std::string& label);
48
49
57
58 class IHolder : public HLT::BaseHolder {
59 public:
60 IHolder();
61 IHolder(const std::string& prefix, const std::string& label, uint16_t idx );
62 virtual ~IHolder();
63
64
65 virtual IHolder* clone(const std::string& prefix, const std::string& label, uint16_t idx) const = 0; // actual constructor
66
70
71 virtual void prepare(const asg::AsgMessaging& logger, HLT::AccessProxy* sg, IConversionSvc* objSerializer, bool readonly);
72
74
78 virtual CLID typeClid() const = 0;
79 virtual CLID containerClid() const = 0;
80 virtual CLID auxClidOrZero() const = 0;
81
85 inline const std::string& label() const { return m_label; }
86
90 virtual const std::string& prefix() const { return m_prefix; }
91
95 virtual const std::string& key() const = 0;
96
100 virtual const std::string& typeName() const = 0;
101
105 virtual const std::string& collectionName() const = 0;
106
111 inline uint16_t subTypeIndex() const { return m_subTypeIndex; }
112
113 std::string generateAliasKey(CLID c, uint16_t sti, const std::string& label, unsigned size);
114
118 virtual bool serialize(std::vector<uint32_t>& output) const;
119
124 std::vector<uint32_t>& output,
125 size_t& payloadsize);
126
127
131 bool serializePayload(std::vector<uint32_t>& dataBlob,
132 const xAOD::AuxSelection& sel);
133
134
135
136 virtual void print(MsgStream& m) const;
137
141 bool deserializePayload(const std::vector<uint32_t>& dataBlob, int version);
142
143 // serialization helpers
144 virtual DataObject* getDataObject() = 0;
145 virtual DataObject* getAuxDataObject() = 0;
146
147 virtual bool setDataObject(DataObject* dobj) = 0;
148 virtual bool setAuxDataObject(DataObject* dobjaux) = 0;
149
153 virtual const ITypeProxy& containerTypeProxy() const = 0;
154
156 virtual std::string getUniqueKey() = 0; // this is backward compatibility for TrigCaloRec and TrigTauRec, whould be removed
157 virtual std::string getNextKey() = 0; // this is backward compatibility for TrigCaloRec and TrigTauRec, whould be removed
158
159 protected:
160 // serialization helpers
162 IConversionSvc* m_objectserializerSvc{0};
164
165 bool m_readonly{false};
167
168 // Adapters so we can use ATH_MSG macros
169 MsgStream& msg() const { return m_logger->msg(); }
170 MsgStream& msg(const MSG::Level lvl) const { return msg() << lvl; }
171 bool msgLvl(const MSG::Level lvl) const { return msg().level() <= lvl; }
172
173 private:
191 bool serializeDynVars (const SG::IAuxStoreIO& iio,
192 const xAOD::AuxSelection& sel,
193 std::vector<uint32_t>& dataBlob);
194
195
210 bool deserializeDynVars (const std::vector<uint32_t>& dataBlob,
211 size_t offs,
212 SG::IAuxStore& store);
213
214
225 std::unique_ptr<SG::IAuxStore>
226 deserializeDynVars (const std::vector<uint32_t>& dataBlob,
227 size_t offs);
228
229
237 const std::type_info* getElementType (const std::string& tname,
238 std::string& elementTypeName) const;
239
240
241 std::string m_prefix;
242 std::string m_label;
243 uint16_t m_subTypeIndex{0};
245
247 ToolHandle<ITrigSerializerToolBase> m_serializer;
248 };
249
250
252
257
258 template<class STORED, class CONTAINER, bool is_same> struct set_link;
259
260 template<class STORED, class CONTAINER>
261 struct set_link<STORED,CONTAINER,true>{
263 static type do_it(const STORED* el, const CONTAINER* src, HLT::TriggerElement::ObjectIndex idx){
264 (void)src;(void)idx; //not used here
265 type t(el);
266 return t;
267 }
268 };
269
270 template<class STORED, class CONTAINER>
271 struct set_link<STORED,CONTAINER,false>{
273 static type do_it(const STORED* el,const CONTAINER* src, HLT::TriggerElement::ObjectIndex idx){
274 (void)el;//not used here
275 type t(*src,idx.objectsBegin());
276 return t;
277 }
278 };
279
281 template<class T, class C> class HolderImp;
288 template<class STORED>
289 class Holder : public IHolder {
290 public:
292 Holder(const std::string& prefix, const std::string& label, uint16_t idx);
293 virtual ~Holder();
294
295 virtual HLT::TriggerElement::ObjectIndex add ATLAS_NOT_THREAD_SAFE ( const STORED* f, bool inSG, const std::string& = "" ) = 0;
296 virtual bool get(const STORED*& dest, HLT::TriggerElement::ObjectIndex idx) = 0;
297
298 template<class CONTAINER2>
300
301 template<class CONTAINER2>
303
304 template<class CONTAINER2>
305 bool getWithLink(typename set_link<STORED,CONTAINER2,std::is_same<STORED,CONTAINER2>::value>::type& link,
307
308 bool result = static_cast<HolderImp<STORED,CONTAINER2>*>(this)->getWithLink(link,idx);
309 return result;
310 }
311
312 virtual bool contains(const STORED* obj, HLT::TriggerElement::ObjectIndex& idx) = 0;
313 };
314
316
327 template<class STORED, class CONTAINER>
328 class HolderImp: public Holder<STORED> {
329 public:
331 typedef STORED stored_type;
332 typedef CONTAINER container_type;
335
337 HolderImp(const std::string& prefix, const std::string& label, uint16_t idx);
338 virtual ~HolderImp();
339
340 virtual IHolder* clone(const std::string& prefix, const std::string& label, uint16_t idx ) const;
341
345 virtual HLT::TriggerElement::ObjectIndex add( const STORED* f, bool inSG = false, const std::string& = "" );
346
350 virtual bool get(const STORED*& dest, HLT::TriggerElement::ObjectIndex idx);
351
355 virtual bool contains(const STORED* obj, HLT::TriggerElement::ObjectIndex& idx);
356
359
360 bool getWithLink(typename set_link<STORED,CONTAINER,std::is_same<STORED,CONTAINER>::value>::type& link,
362
363 virtual std::string getUniqueKey(); // this is backward compatibility for TrigCaloRec and TrigTauRec, whould be removed
364 virtual std::string getNextKey(); // this is backward compatibility for TrigCaloRec and TrigTauRec, whould be removed
365
366 virtual void prepare(const asg::AsgMessaging& logger, HLT::AccessProxy* sg, IConversionSvc* objSerializer, bool readonly = false);
369
370 virtual bool serialize(std::vector<uint32_t>& output) const;
371
372 virtual const std::string& key() const { return m_key; }
373 virtual void print(MsgStream& m) const;
374
375 virtual DataObject* getDataObject();
376 virtual DataObject* getAuxDataObject();
377 virtual bool setDataObject(DataObject* dobj);
378 virtual bool setAuxDataObject(DataObject* dobjaux);
379
380 virtual CLID typeClid() const { return ClassID_traits<STORED>::ID(); }
381 virtual const std::string& typeName() const { return ClassID_traits<STORED>::typeName(); }
383 virtual const std::string& collectionName() const { return ClassID_traits<CONTAINER>::typeName(); }
384 virtual CLID auxClidOrZero() const;
385
386 virtual const ITypeProxy& containerTypeProxy() const { return m_containerProxy; }
387
388 // for memory management
389 struct MemoryMgr {
391 MemoryMgr(const FeatureProxy& st, bool inSG);
392 void clear();
394 bool inSG;
395 };
396
398
399 typedef std::multimap<HLT::TriggerElement::ObjectIndex, MemoryMgr> MemoryMgrMap;
401
402 private:
403 std::string m_key; //<! StoreGate key
404 };
405
406 MsgStream& operator<< ( MsgStream& m, const HLTNavDetails::IHolder& nav ); //<! printing helper
407 template<class T>
408 MsgStream& operator<< ( MsgStream& m, const HLTNavDetails::Holder<T>& nav ); //<! printing helper
409 template<class T, class C>
410 MsgStream& operator<< ( MsgStream& m, const HLTNavDetails::HolderImp<T, C>& nav ); //<! printing helper
411} // end of namespace
412#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
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:328
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:380
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:330
bool getElementLinks(ElementLinkVector< CONTAINER > &cont, HLT::TriggerElement::ObjectIndex idx)
HLTNavDetails::TypeProxy< CONTAINER > ContainerProxy
Definition Holder.h:334
std::multimap< HLT::TriggerElement::ObjectIndex, MemoryMgr > MemoryMgrMap
Definition Holder.h:399
virtual DataObject * getDataObject()
virtual const std::string & collectionName() const
returns the collection's name stored by this holder
Definition Holder.h:383
HLTNavDetails::TypeProxy< STORED > FeatureProxy
Definition Holder.h:333
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:397
MemoryMgrMap m_memMgr
Definition Holder.h:400
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:332
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:381
virtual const std::string & key() const
returns the containers StoreGate key
Definition Holder.h:372
virtual CLID containerClid() const
Definition Holder.h:382
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:386
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:305
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:170
ITypeProxy * m_aux
Definition Holder.h:166
std::string generateAliasKey(CLID c, uint16_t sti, const std::string &label, unsigned size)
Definition Holder.cxx:98
virtual const std::string & key() const =0
returns the containers StoreGate key
bool serializeWithPayload(const xAOD::AuxSelection &sel, std::vector< uint32_t > &output, size_t &payloadsize)
serializes this Holder including payload
Definition Holder.cxx:79
virtual CLID containerClid() const =0
ToolHandle< ITrigSerializerToolBase > m_serializer
Serializer tool; used for dynamic variables.
Definition Holder.h:247
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:242
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:85
virtual bool setDataObject(DataObject *dobj)=0
virtual bool serialize(std::vector< uint32_t > &output) const
serializes this Holder
Definition Holder.cxx:62
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:345
HLT::AccessProxy * m_storeGate
pointer to SG
Definition Holder.h:163
const asg::AsgMessaging * m_logger
Definition Holder.h:161
virtual void print(MsgStream &m) const
Definition Holder.cxx:107
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:243
bool serializePayload(std::vector< uint32_t > &dataBlob, const xAOD::AuxSelection &sel)
serializes the payload of this Holder
Definition Holder.cxx:254
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:544
std::string m_prefix
prefix for key given to the objects
Definition Holder.h:241
virtual std::string getUniqueKey()=0
MsgStream & msg() const
Definition Holder.h:169
bool deserializePayload(const std::vector< uint32_t > &dataBlob, int version)
deserialization of holder payload
Definition Holder.cxx:148
virtual std::string getNextKey()=0
virtual CLID auxClidOrZero() const =0
IConversionSvc * m_objectserializerSvc
pointer to object serializer
Definition Holder.h:162
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:90
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:405
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:111
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:55
virtual bool setAuxDataObject(DataObject *dobjaux)=0
bool msgLvl(const MSG::Level lvl) const
Definition Holder.h:171
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:328
An auxiliary data store that holds data internally.
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:122
MsgStream & operator<<(MsgStream &m, const HLTNavDetails::IHolder &nav)
Definition Holder.cxx:112
StoreGateSvc AccessProxy
Definition AccessProxy.h:17
Forward declaration.
OwnershipPolicy
@ OWN_ELEMENTS
this data object owns its elements
MemoryMgr(const FeatureProxy &st, bool inSG)