|
ATLAS Offline Software
|
Go to the documentation of this file.
6 #include <boost/regex.hpp>
7 #include <tbb/concurrent_unordered_map.h>
23 #include "GaudiKernel/IConversionSvc.h"
27 #include "TVirtualCollectionProxy.h"
39 : m_serializer(
"TrigTSerializer/TrigTSerializer")
46 m_serializer(
"TrigTSerializer/TrigTSerializer")
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) {
99 std::ostringstream
ss;
101 std::string st =
ss.str();
102 ATH_MSG_DEBUG(
"IHolder::generateAliasKey generated key: " << st);
124 static tbb::concurrent_unordered_map<std::string,std::string> memo
ATLAS_THREAD_SAFE;
127 const auto itr = memo.find(
key);
128 if (itr!=memo.end())
return itr->second;
131 std::string ret = boost::regex_replace(containername,
rx1,std::string(
""));
134 size_t pos = ret.find(
"::");
135 if (
pos!=std::string::npos) ret.replace(
pos,2,
"__");
141 else if (!
label.empty())
142 ret += (
"_" +
label);
144 memo.insert({
key, ret});
152 const std::string container_typename = collectionName();
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;
170 if(!dataBlob.size())
return false;
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());
200 if (m_objectserializerSvc->createObj((IOpaqueAddress*)&addr, dobj).isFailure() ){
205 bool setcontainer = setDataObject(dobj);
210 if(!setcontainer)
return false;
212 DataObject* dobjaux(0);
214 std::string sgkeyaux =
sgkey+
"Aux.";
219 if (m_objectserializerSvc->createObj((IOpaqueAddress*)&auxaddr, dobjaux).isFailure() ){
225 if (
it != dataBlob.end()) {
230 dobjBaseAux->template cast<xAOD::AuxContainerBase> (
nullptr,
false))
235 if (!istore || !deserializeDynVars (dataBlob,
236 it - dataBlob.begin(),
244 bool setaux = setAuxDataObject(dobjaux);
249 if(!setaux)
return false;
256 DataObject* dobj = getDataObject();
266 if ( m_objectserializerSvc->createRep(dobj, *pp_cast<IOpaqueAddress>(&addr) ).isSuccess() ) {
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());
284 DataObject* dobjaux = getAuxDataObject();
291 if(m_objectserializerSvc->createRep(dobjaux,*pp_cast<IOpaqueAddress>(&auxaddr) ).isSuccess() ){
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))
316 if (!serializeDynVars (*iio,
sel, dataBlob)) {
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());
427 std::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) {
451 std::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++;
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);
509 if (
id == SG::null_auxid)
511 std::string elementTypeName;
512 const std::type_info* elt_tinfo =
getElementType (vecname, elementTypeName);
515 if (
id == SG::null_auxid) {
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));
543 const std::type_info*
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();
virtual CLID containerClid() const =0
Recursively separate out template arguments in a C++ class name.
virtual bool serialize(std::vector< uint32_t > &output) const
serializes this Holder
bool deserializeDynVars(const std::vector< uint32_t > &dataBlob, size_t offs, SG::IAuxStore &store)
Read dynamic auxiliary variables from a serialized buffer.
void add(const ClassName &pattern, const ClassName &replacement)
Add a new transformation rule.
const std::string & label() const
returns the label of objects stores by this holder
A non-templated base class for DataBucket, allows to access the transient object address as a void*.
virtual const std::string & typeName() const =0
returns the object's name stored by this holder
static AuxTypeRegistry & instance()
Return the singleton registry instance.
const std::type_info * getTypeInfo() const
Return the type_info for the described type.
Common base class for the auxiliary containers.
ToolHandle< ITrigSerializerToolBase > m_serializer
Serializer tool; used for dynamic variables.
std::string m_label
label given to the objects in this holder (labels given at attachFeature)
std::vector< size_t > vec
std::string formatSGkey(const std::string &prefix, const std::string &containername, const std::string &label)
declaration of formatting function.
#define ATH_MSG_VERBOSE(x)
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.
HLT::AccessProxy * m_storeGate
pointer to SG
Interface providing I/O for a generic auxiliary store.
Handle mappings between names and auxid_t.
Aux store instance used to hold dynamic variables deserialized from the bytestream.
typename vecDetail::vec_typedef< T, N >::type vec
Define a nice alias for the vectorized type.
virtual void print(MsgStream &m) const
size_t auxid_t
Identifier for a particular aux data item.
The Athena Transient Store API.
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.
void add(const std::vector< uint32_t > &a)
IConversionSvc * m_objectserializerSvc
pointer to object serializer
bool deserializePayload(const std::vector< uint32_t > &dataBlob, int version)
deserialization of holder payload
Find the auxid for a dynamic branch.
std::string apply(const std::string &name) const
Apply transformations to a class name.
A set of transformation rules to use with ClassName.
uint32_t CLID
The Class ID type.
virtual const SG::auxid_set_t & getDynamicAuxIDs() const =0
Get the list of all dynamically created variables.
const asg::AsgMessaging * m_logger
const std::vector< uint32_t > & get() const
virtual void setStore(IAuxStore *store)=0
Give an auxiliary store object to the holder object.
Class helping in dealing with dynamic branch selection.
Class mimicking the AthMessaging class from the offline software.
virtual const void * getIOData(SG::auxid_t auxid) const =0
Return a pointer to the data to be stored for one aux data item.
bool serializePayload(std::vector< uint32_t > &dataBlob, const xAOD::AuxSelection &sel)
serializes the payload of this Holder
virtual const std::string & collectionName() const =0
returns the collection's name stored by this holder
MsgStream & operator<<(MsgStream &m, const HLTNavDetails::IHolder &nav)
Interface for non-const operations on an auxiliary store.
a static registry of CLID->typeName entries. NOT for general use. Use ClassIDSvc instead.
virtual CLID typeClid() const =0
returns the CLID of objects stores by this holder
#define ATH_MSG_WARNING(x)
std::string generateAliasKey(CLID c, uint16_t sti, const std::string &label, unsigned size)
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
uint16_t subTypeIndex() const
returns the index (short number used when linking object to the TE) of objects stores by this holder
IOpaqueAddress for TrigSerializenCnvSvc.
Handle mappings between names and auxid_t.
virtual void relinquish()=0
Give up ownership of the DataBucket contents.
A set of aux data identifiers.
std::string getTypeName() const
Return the name of this type.
#define ATLAS_THREAD_SAFE
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...
An auxiliary data store that holds data internally.
Interface for objects taking part in direct ROOT I/O.
bool serializeDynVars(const SG::IAuxStoreIO &iio, const xAOD::AuxSelection &sel, std::vector< uint32_t > &dataBlob)
Serialize all selected dynamic variables for an xAOD object.
setPassBits containerClid
const std::type_info * getElementType(const std::string &tname, std::string &elementTypeName) const
Find the type of an element of a vector.
const boost::regex rx1("_v[0-9]+$")
bool serializeWithPayload(const xAOD::AuxSelection &sel, std::vector< uint32_t > &output, size_t &payloadsize)
serializes this Holder including payload