7#include <tbb/concurrent_unordered_map.h>
23#include "GaudiKernel/IConversionSvc.h"
27#include "TVirtualCollectionProxy.h"
71 std::vector<uint32_t> serializedLabel;
74 output.push_back( serializedLabel.size() );
75 output.insert(output.end(), serializedLabel.begin(), serializedLabel.end());
80 std::vector<uint32_t>& output,
81 size_t& payloadsize) {
87 std::vector<uint32_t> payload;
93 payloadsize = payload.size();
94 output.insert(output.end(), payload.begin(), payload.end());
99 std::ostringstream
ss;
100 ss <<
"HLTAutoKey_" <<
label <<
"_" << c <<
"_" << sti <<
"_" << (size == 0xffffffff ?
"back" :
"to") <<
"_" <<
m_uniqueCounter;
101 std::string st =
ss.str();
102 ATH_MSG_DEBUG(
"IHolder::generateAliasKey generated key: " << st);
119 const std::regex
rx1(R
"(_v[0-9]+$)");
124 static tbb::concurrent_unordered_map<std::string,std::string> memo
ATLAS_THREAD_SAFE;
125 const std::string key = prefix+containername+
label;
127 const auto itr = memo.find(key);
128 if (itr!=memo.end())
return itr->second;
131 std::string ret = std::regex_replace(containername,
rx1,std::string(
""));
134 size_t pos = ret.find(
"::");
135 if (pos!=std::string::npos) ret.replace(pos,2,
"__");
138 ret = prefix +
"_" + ret;
141 else if (!
label.empty())
142 ret += (
"_" +
label);
144 memo.insert({key, ret});
149 const std::string sgkey =
key();
154 if (
m_storeGate->transientContains(container_clid, sgkey) ) {
155 ATH_MSG_VERBOSE(
"deserialize: while working on: " << container_typename <<
" and key: " << sgkey
156 <<
" from serialized form found it in SG already, sync with it");
160 ATH_MSG_VERBOSE(
"deserializing a data blob of size " << dataBlob.size() <<
" navi version is " << version);
161 ATH_MSG_DEBUG(
"holder type clid " << feature_clid<<
" collection clid: " << container_clid);
163 if (container_clid<1){
164 ATH_MSG_WARNING(
"holder type clid " << feature_clid <<
" collection clid: " << container_clid);
167 typedef std::vector<uint32_t>::const_iterator it_type;
168 it_type it = std::begin(dataBlob);
170 if(!dataBlob.size())
return false;
172 std::vector<uint32_t> first, second;
175 auto firstsize = *(it++);
178 first = std::vector<uint32_t>(it,it+firstsize);
180 std::advance(it,firstsize);
182 if(!(it!=dataBlob.end())){
183 ATH_MSG_VERBOSE(
"this datablob only has a first part (non xAOD case)");
186 auto secondsize = *(it++);
188 second = std::vector<uint32_t>(it,it+secondsize);
189 std::advance(it,secondsize);
193 first = std::vector<uint32_t>(dataBlob.begin(),dataBlob.end());
210 if(!setcontainer)
return false;
212 DataObject* dobjaux(0);
214 std::string sgkeyaux = sgkey+
"Aux.";
225 if (it != dataBlob.end()) {
230 dobjBaseAux->template cast<xAOD::AuxContainerBase> (
nullptr,
false))
236 it - dataBlob.begin(),
249 if(!setaux)
return false;
267 ATH_MSG_VERBOSE(
"serialization of feature (object) successful, blob size: " << addr->
get().size());
268 dataBlob.push_back(addr->
get().size());
269 dataBlob.insert(dataBlob.end(), addr->
get().begin(), addr->
get().end());
292 ATH_MSG_VERBOSE(
"aux conversion success! aux blob has size: " << auxaddr->
get().size());
293 dataBlob.push_back(auxaddr->
get().size());
294 dataBlob.insert(dataBlob.end(), auxaddr->
get().begin(), auxaddr->
get().end());
304 dobjBaseAux->template cast<xAOD::AuxContainerBase> (
nullptr,
true))
317 ATH_MSG_ERROR(
"Serialization of dynamic aux variables failed.");
322 ATH_MSG_VERBOSE(
"finished serializing payload. size: " << dataBlob.size());
347 std::vector<uint32_t>& dataBlob)
354 const std::type_info* tinfo = iio.
getIOType (
id);
356 ATH_MSG_ERROR(
"serialize aux dyn vars failed: can't get type_info.");
359 TClass* cls = TClass::GetClass (*tinfo);
361 ATH_MSG_ERROR(
"serialize aux dyn vars failed: can't get TClass.");
366 std::vector<uint32_t> serialized =
372 std::vector<uint32_t> serializedName;
373 ss.serialize (
r.getName(
id), serializedName);
374 dataBlob.push_back (serializedName.size());
375 dataBlob.insert(dataBlob.end(), serializedName.begin(), serializedName.end());
377 std::vector<uint32_t> serializedType;
378 ss.serialize (cls->GetName(), serializedType);
379 dataBlob.push_back (serializedType.size());
380 dataBlob.insert(dataBlob.end(), serializedType.begin(), serializedType.end());
383 dataBlob.push_back (serialized.size());
384 dataBlob.insert(dataBlob.end(), serialized.begin(), serialized.end());
411 ATH_MSG_ERROR(
"deserialize aux dyn vars failed: can't convert to IAuxStoreHolder.");
416 if (!newstore)
return false;
417 holder->
setStore (newstore.release());
427std::string stripStdVec (
const std::string& s_in)
429 std::string s = s_in;
430 std::string::size_type pos{0};
431 while ((pos = s.find (
"std::vector<")) != std::string::npos) {
451std::unique_ptr<SG::IAuxStore>
459 auto store = std::make_unique<HLTNavDetails::TrigAuxStore>();
462 std::vector<uint32_t>::const_iterator it = dataBlob.begin() + offs;
463 while (it < dataBlob.end()) {
465 size_t name_size = *it++;
467 ss.deserialize (it, it+name_size, name);
470 size_t tname_size = *it++;
472 ss.deserialize (it, it+tname_size, tname);
476 size_t var_size = *it++;
478 const static char*
const packed_pref =
"SG::PackedContainer<";
479 const static unsigned int packed_preflen = strlen(packed_pref);
480 std::string vecname = tname;
481 if (strncmp (vecname.c_str(), packed_pref, packed_preflen) == 0) {
485 auto makeRules = []() {
487 rules.
add (
"SG::PackedContainer<$T, std::allocator<$T> >",
489 rules.
add (
"SG::PackedContainer<$T, allocator<$T> >",
491 rules.
add (
"SG::PackedContainer<$T, $ALLOC>",
492 "vector<$T, $ALLOC>");
496 vecname = rules.
apply (vecname);
502 if (
id !=
SG::null_auxid && stripStdVec(
r.getVecTypeName(
id)) != stripStdVec(vecname)) {
503 vecname =
r.getVecTypeName (
id);
511 std::string elementTypeName;
512 const std::type_info* elt_tinfo =
getElementType (vecname, elementTypeName);
516 ATH_MSG_ERROR(
"deserialize aux dyn var failed; can't find auxid for:" << name);
517 return std::unique_ptr<SG::IAuxStore> (std::move(store));
522 std::vector<uint32_t> buf (it, it+var_size);
526 bool isPacked = (strncmp (tname.c_str(), packed_pref, packed_preflen) == 0);
527 std::unique_ptr<SG::IAuxTypeVector>
vec
528 (
r.makeVectorFromData (
id, obj,
nullptr, isPacked,
true));
529 store->addVector (std::move(
vec),
false);
532 return std::unique_ptr<SG::IAuxStore> (std::move(store));
545 std::string& elementTypeName)
const
547 TClass* cls = TClass::GetClass (tname.c_str());
548 if (!cls)
return nullptr;
549 TVirtualCollectionProxy* prox = cls->GetCollectionProxy();
550 if (!prox)
return nullptr;
551 if (prox->GetValueClass()) {
552 elementTypeName = prox->GetValueClass()->GetName();
553 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.