7#include <tbb/concurrent_unordered_map.h>
23#include "GaudiKernel/IConversionSvc.h"
27#include "TVirtualCollectionProxy.h"
70 std::vector<uint32_t> serializedLabel;
73 output.push_back( serializedLabel.size() );
74 output.insert(output.end(), serializedLabel.begin(), serializedLabel.end());
79 std::vector<uint32_t>& output,
80 size_t& payloadsize) {
86 std::vector<uint32_t> payload;
92 payloadsize = payload.size();
93 output.insert(output.end(), payload.begin(), payload.end());
98 std::ostringstream
ss;
99 ss <<
"HLTAutoKey_" <<
label <<
"_" << c <<
"_" << sti <<
"_" << (size == 0xffffffff ?
"back" :
"to") <<
"_" <<
m_uniqueCounter;
100 std::string st =
ss.str();
101 ATH_MSG_DEBUG(
"IHolder::generateAliasKey generated key: " << st);
118 const std::regex
rx1(R
"(_v[0-9]+$)");
123 static tbb::concurrent_unordered_map<std::string,std::string> memo
ATLAS_THREAD_SAFE;
124 const std::string key = prefix+containername+
label;
126 const auto itr = memo.find(key);
127 if (itr!=memo.end())
return itr->second;
130 std::string ret = std::regex_replace(containername,
rx1,std::string(
""));
133 size_t pos = ret.find(
"::");
134 if (pos!=std::string::npos) ret.replace(pos,2,
"__");
137 ret = prefix +
"_" + ret;
140 else if (!
label.empty())
141 ret += (
"_" +
label);
143 memo.insert({key, ret});
148 const std::string sgkey =
key();
153 if (
m_storeGate->transientContains(container_clid, sgkey) ) {
154 ATH_MSG_VERBOSE(
"deserialize: while working on: " << container_typename <<
" and key: " << sgkey
155 <<
" from serialized form found it in SG already, sync with it");
159 ATH_MSG_VERBOSE(
"deserializing a data blob of size " << dataBlob.size() <<
" navi version is " << version);
160 ATH_MSG_DEBUG(
"holder type clid " << feature_clid<<
" collection clid: " << container_clid);
162 if (container_clid<1){
163 ATH_MSG_WARNING(
"holder type clid " << feature_clid <<
" collection clid: " << container_clid);
166 typedef std::vector<uint32_t>::const_iterator it_type;
167 it_type it = std::begin(dataBlob);
169 if(!dataBlob.size())
return false;
171 std::vector<uint32_t> first, second;
174 auto firstsize = *(it++);
177 first = std::vector<uint32_t>(it,it+firstsize);
179 std::advance(it,firstsize);
181 if(!(it!=dataBlob.end())){
182 ATH_MSG_VERBOSE(
"this datablob only has a first part (non xAOD case)");
185 auto secondsize = *(it++);
187 second = std::vector<uint32_t>(it,it+secondsize);
188 std::advance(it,secondsize);
192 first = std::vector<uint32_t>(dataBlob.begin(),dataBlob.end());
209 if(!setcontainer)
return false;
211 DataObject* dobjaux(0);
213 std::string sgkeyaux = sgkey+
"Aux.";
224 if (it != dataBlob.end()) {
229 dobjBaseAux->template cast<xAOD::AuxContainerBase> (
nullptr,
false))
235 it - dataBlob.begin(),
248 if(!setaux)
return false;
266 ATH_MSG_VERBOSE(
"serialization of feature (object) successful, blob size: " << addr->
get().size());
267 dataBlob.push_back(addr->
get().size());
268 dataBlob.insert(dataBlob.end(), addr->
get().begin(), addr->
get().end());
291 ATH_MSG_VERBOSE(
"aux conversion success! aux blob has size: " << auxaddr->
get().size());
292 dataBlob.push_back(auxaddr->
get().size());
293 dataBlob.insert(dataBlob.end(), auxaddr->
get().begin(), auxaddr->
get().end());
303 dobjBaseAux->template cast<xAOD::AuxContainerBase> (
nullptr,
true))
316 ATH_MSG_ERROR(
"Serialization of dynamic aux variables failed.");
321 ATH_MSG_VERBOSE(
"finished serializing payload. size: " << dataBlob.size());
346 std::vector<uint32_t>& dataBlob)
353 const std::type_info* tinfo = iio.
getIOType (
id);
355 ATH_MSG_ERROR(
"serialize aux dyn vars failed: can't get type_info.");
358 TClass* cls = TClass::GetClass (*tinfo);
360 ATH_MSG_ERROR(
"serialize aux dyn vars failed: can't get TClass.");
365 std::vector<uint32_t> serialized =
371 std::vector<uint32_t> serializedName;
372 ss.serialize (
r.getName(
id), serializedName);
373 dataBlob.push_back (serializedName.size());
374 dataBlob.insert(dataBlob.end(), serializedName.begin(), serializedName.end());
376 std::vector<uint32_t> serializedType;
377 ss.serialize (cls->GetName(), serializedType);
378 dataBlob.push_back (serializedType.size());
379 dataBlob.insert(dataBlob.end(), serializedType.begin(), serializedType.end());
382 dataBlob.push_back (serialized.size());
383 dataBlob.insert(dataBlob.end(), serialized.begin(), serialized.end());
410 ATH_MSG_ERROR(
"deserialize aux dyn vars failed: can't convert to IAuxStoreHolder.");
415 if (!newstore)
return false;
416 holder->
setStore (newstore.release());
426std::string stripStdVec (
const std::string& s_in)
428 std::string s = s_in;
429 std::string::size_type pos{0};
430 while ((pos = s.find (
"std::vector<")) != std::string::npos) {
450std::unique_ptr<SG::IAuxStore>
458 auto store = std::make_unique<HLTNavDetails::TrigAuxStore>();
461 std::vector<uint32_t>::const_iterator it = dataBlob.begin() + offs;
462 while (it < dataBlob.end()) {
464 size_t name_size = *it++;
466 ss.deserialize (it, it+name_size, name);
469 size_t tname_size = *it++;
471 ss.deserialize (it, it+tname_size, tname);
475 size_t var_size = *it++;
477 const static char*
const packed_pref =
"SG::PackedContainer<";
478 const static unsigned int packed_preflen = strlen(packed_pref);
479 std::string vecname = tname;
480 if (strncmp (vecname.c_str(), packed_pref, packed_preflen) == 0) {
484 auto makeRules = []() {
486 rules.
add (
"SG::PackedContainer<$T, std::allocator<$T> >",
488 rules.
add (
"SG::PackedContainer<$T, allocator<$T> >",
490 rules.
add (
"SG::PackedContainer<$T, $ALLOC>",
491 "vector<$T, $ALLOC>");
495 vecname = rules.
apply (vecname);
501 if (
id !=
SG::null_auxid && stripStdVec(
r.getVecTypeName(
id)) != stripStdVec(vecname)) {
502 vecname =
r.getVecTypeName (
id);
510 std::string elementTypeName;
511 const std::type_info* elt_tinfo =
getElementType (vecname, elementTypeName);
515 ATH_MSG_ERROR(
"deserialize aux dyn var failed; can't find auxid for:" << name);
516 return std::unique_ptr<SG::IAuxStore> (std::move(store));
521 std::vector<uint32_t> buf (it, it+var_size);
525 bool isPacked = (strncmp (tname.c_str(), packed_pref, packed_preflen) == 0);
526 std::unique_ptr<SG::IAuxTypeVector>
vec
527 (
r.makeVectorFromData (
id, obj,
nullptr, isPacked,
true));
528 store->addVector (std::move(
vec),
false);
531 return std::unique_ptr<SG::IAuxStore> (std::move(store));
544 std::string& elementTypeName)
const
546 TClass* cls = TClass::GetClass (tname.c_str());
547 if (!cls)
return nullptr;
548 TVirtualCollectionProxy* prox = cls->GetCollectionProxy();
549 if (!prox)
return nullptr;
550 if (prox->GetValueClass()) {
551 elementTypeName = prox->GetValueClass()->GetName();
552 return prox->GetValueClass()->GetTypeInfo();
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
An auxiliary data store that holds data internally.
Handle mappings between names and auxid_t.
a static registry of CLID->typeName entries.
std::vector< size_t > vec
Recursively separate out template arguments in a C++ class name.
uint32_t CLID
The Class ID type.
Aux store instance used to hold dynamic variables deserialized from the bytestream.
#define ATLAS_THREAD_SAFE
A set of transformation rules to use with ClassName.
std::string apply(const std::string &name) const
Apply transformations to a class name.
void add(const ClassName &pattern, const ClassName &replacement)
Add a new transformation rule.
A non-templated base class for DataBucket, allows to access the transient object address as a void*.
virtual void relinquish()=0
Give up ownership of the DataBucket contents.
std::string generateAliasKey(CLID c, uint16_t sti, const std::string &label, unsigned size)
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
virtual CLID containerClid() const =0
ToolHandle< ITrigSerializerToolBase > m_serializer
Serializer tool; used for dynamic variables.
virtual DataObject * getAuxDataObject()=0
std::string m_label
label given to the objects in this holder (labels given at attachFeature)
virtual bool syncWithSG(SG::OwnershipPolicy policy=SG::OWN_ELEMENTS)=0
const std::string & label() const
returns the label of objects stores by this holder
virtual bool setDataObject(DataObject *dobj)=0
virtual bool serialize(std::vector< uint32_t > &output) const
serializes this Holder
bool serializeDynVars(const SG::IAuxStoreIO &iio, const xAOD::AuxSelection &sel, std::vector< uint32_t > &dataBlob)
Serialize all selected dynamic variables for an xAOD object.
HLT::AccessProxy * m_storeGate
pointer to SG
const asg::AsgMessaging * m_logger
virtual void print(MsgStream &m) const
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...
bool serializePayload(std::vector< uint32_t > &dataBlob, const xAOD::AuxSelection &sel)
serializes the payload of this Holder
const std::type_info * getElementType(const std::string &tname, std::string &elementTypeName) const
Find the type of an element of a vector.
std::string m_prefix
prefix for key given to the objects
bool deserializePayload(const std::vector< uint32_t > &dataBlob, int version)
deserialization of holder payload
virtual CLID auxClidOrZero() const =0
IConversionSvc * m_objectserializerSvc
pointer to object serializer
virtual CLID typeClid() const =0
returns the CLID of objects stores by this holder
virtual DataObject * getDataObject()=0
virtual const std::string & prefix() const
returns the containers StoreGate prefix
bool deserializeDynVars(const std::vector< uint32_t > &dataBlob, size_t offs, SG::IAuxStore &store)
Read dynamic auxiliary variables from a serialized buffer.
virtual const std::string & typeName() const =0
returns the object's name stored by this holder
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
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
virtual bool setAuxDataObject(DataObject *dobjaux)=0
std::string getTypeName() const
Return the name of this type.
const std::type_info * getTypeInfo() const
Return the type_info for the described type.
Handle mappings between names and auxid_t.
static AuxTypeRegistry & instance()
Return the singleton registry instance.
Interface for objects taking part in direct ROOT I/O.
virtual void setStore(IAuxStore *store)=0
Give an auxiliary store object to the holder object.
Interface providing I/O for a generic auxiliary store.
virtual const std::type_info * getIOType(SG::auxid_t auxid) const =0
Return the type of the data to be stored for one aux data item.
virtual const void * getIOData(SG::auxid_t auxid) const =0
Return a pointer to the data to be stored for one aux data item.
virtual const SG::auxid_set_t & getDynamicAuxIDs() const =0
Get the list of all dynamically created variables.
Interface for non-const operations on an auxiliary store.
A set of aux data identifiers.
Utility class (not a tool or so) to serialize strings into stream of 32bit integers.
IOpaqueAddress for TrigSerializenCnvSvc.
void add(const std::vector< uint32_t > &a)
const std::vector< uint32_t > & get() const
Class mimicking the AthMessaging class from the offline software.
Common base class for the auxiliary containers.
Class helping in dealing with dynamic branch selection.
Find the auxid for a dynamic branch.
static Root::TMsgLogger logger("iLumiCalc")
std::string label(const std::string &format, int i)
const std::regex rx1(R"(_v[0-9]+$)")
std::string formatSGkey(const std::string &prefix, const std::string &containername, const std::string &label)
declaration of formatting function.
MsgStream & operator<<(MsgStream &m, const HLTNavDetails::IHolder &nav)
static const auxid_t null_auxid
To signal no aux data item.
SG::auxid_t getDynamicAuxID(const std::type_info &ti, const std::string &name, const std::string &elementTypeName, const std::string &branch_type_name, bool standalone, SG::auxid_t linked_auxid)
Find the auxid for a dynamic branch.
size_t auxid_t
Identifier for a particular aux data item.