Loading [MathJax]/extensions/tex2jax.js
 |
ATLAS Offline Software
|
Go to the documentation of this file.
9 #include "GaudiKernel/IConversionSvc.h"
22 #include <unordered_map>
29 std::ostream&
operator<<( std::ostream&
s,
const std::vector<T>&
v)
31 s<<
"[";
for(
auto i:
v){
s <<
i <<
", ";}
s <<
"]";
37 m_serializerSvc(nullptr),
39 m_objectsKeyPrefix(
"HLT"),
40 m_objectsIndexOffset(0),
41 m_holderfactory(nullptr),
62 if (
it == input.end() )
65 unsigned sizeOfBlob = *
it;
66 std::vector<uint32_t>::const_iterator
begin =
it;
68 std::vector<uint32_t>::const_iterator
end =
it;
70 advance(
end, sizeOfBlob);
71 if (
end <= input.end()) {
82 std::vector<unsigned int>
cuts;
87 std::vector<std::pair<CLID, std::string> > clid_name;
92 bool NavigationCore::serialize( std::vector<uint32_t>& output, std::vector<unsigned int>&
cuts, std::vector<std::pair<CLID, std::string> >& clid_name )
const {
93 std::vector<uint32_t> holderdata;
94 std::vector<unsigned int> holderblobsizes;
96 std::lock_guard<std::recursive_mutex> lock(
getMutex());
118 ATH_MSG_DEBUG(
"total size of serialized navigation: " << output.size());
124 std::vector<uint32_t> holderdata;
125 std::vector<unsigned int> holderblobsizes;
139 ATH_MSG_DEBUG(
"total size of serialized navigation (DS only): " << output.size());
152 std::lock_guard<std::recursive_mutex> lock(
getMutex());
155 std::vector<uint32_t>::const_iterator inputIt = input.begin();
157 ATH_MSG_DEBUG(
"deserialize: deserializing input of size: " << input.size());
160 if (input.size()==0) {
164 unsigned int version = *inputIt++;
169 ATH_MSG_WARNING(
"No backward compatibility beyond version 3 possible; data was serialized with V: " <<
version
170 <<
" while we are in version 4");
177 ATH_MSG_WARNING(
"deserialize: the navigation is truncated: " << input.size()
180 if ( input.size() == 2 ) {
181 ATH_MSG_WARNING(
"deserialize: the navigation is truncated badly, no recovery possible " );
185 bool tesDeserializationStatus =
deserializeTEs(inputIt,input.size());
186 ATH_MSG_DEBUG(
"deserialize: TEs structure unpacked, status: " << tesDeserializationStatus );
189 ATH_MSG_DEBUG(
"do we have holder payload? " << (inputIt != input.end()));
192 struct DeserializedMemo
195 EventContext::ContextEvt_t m_evt;
196 std::unordered_map<uint64_t, std::shared_ptr<HLT::BaseHolder>> m_holders;
200 const EventContext& ctx = Gaudi::Hive::currentContext();
201 DeserializedMemo& memo = *memos.get (ctx);
202 std::scoped_lock memolock (memo.m_mutex);
203 if (memo.m_evt != ctx.evt()) {
204 memo.m_holders.clear();
205 memo.m_evt = ctx.evt();
210 std::vector<uint32_t>::const_iterator
it = inputIt;
211 std::vector<uint32_t>
blob;
218 auto& holder = memo.m_holders[
hash];
222 if (! holder )
continue;
225 <<
" already deserialized; re-using holder");
229 ATH_MSG_WARNING(
"deserialize: holder registration for holder with clid: " << holder->typeClid() <<
" and label: " << holder->label() <<
" failed.");
236 std::lock_guard<std::recursive_mutex> l2lock(
l2.getMutex());
242 std::string
label(l2holder->label());
244 if ( efholder != 0 ) {
245 if ( (efholder->
label() != l2holder->label())
246 || (efholder->
subTypeIndex() != l2holder->subTypeIndex()) ) {
266 if(efholder->
key()!=l2holder->key()){
267 ATH_MSG_WARNING(
"in merge the created EF holder has different SG access key than L2 holder we tried to copy");
288 std::lock_guard<std::recursive_mutex> lock(
getMutex());
293 if ( holders.empty() )
296 std::vector<sub_index_type> sub_indices(holders.size());
297 std::transform(holders.begin(), holders.end(), sub_indices.begin(),
300 return (*std::max_element(sub_indices.begin(),sub_indices.end()))+1;
305 ATH_MSG_VERBOSE(
"NavigationCore::prepare preregistering objects of clid: " << clid <<
" label: " <<
label);
308 ATH_MSG_VERBOSE(
"NavigationCore::prepare preregistering objects not executed as it already exists " << *holder);
313 ATH_MSG_VERBOSE(
"NavigationCore::prepare creating handler for type (CLID): " << clid
314 <<
" label: " <<
label <<
" index: " <<
index);
317 ATH_MSG_INFO(
"NavigationCore::prepare Can't create storage for objects of CLID: " << clid <<
" as it is requested by configuration");
321 ATH_MSG_VERBOSE(
"Holder created, registering " << holder <<
" " << *holder);
324 ATH_MSG_WARNING(
"Holder registration failed " << holder <<
" " << *holder);
338 ATH_MSG_VERBOSE(
"NavigationCore::prepare Compile time known types : " << *holder);
349 ATH_MSG_WARNING(
"NavigationCore::prepare failed preparing the holder for CLID: " << clid <<
" and label " <<
label);
352 ATH_MSG_DEBUG(
"NavigationCore::prepare Navigation structure prepared for next event");
356 std::lock_guard<std::recursive_mutex> lock(
getMutex());
359 auto shared_holder = std::shared_ptr<HLT::BaseHolder>(holder);
366 ATH_MSG_DEBUG(
"createHolder: creating holder for CLID: " << clid <<
" label: " <<
label <<
" and index: " <<
index);
371 ATH_MSG_ERROR(
"createHolder: creation of holder for CLID: " << clid <<
" label: " <<
label <<
" and index: " <<
index <<
" failed");
374 holder =
dynamic_cast<IHolder*
>(baseholder);
384 std::lock_guard<std::recursive_mutex> lock(
getMutex());
391 std::lock_guard<std::recursive_mutex> lock(
getMutex());
402 const bool activeOnly)
const {
404 return getAll(output, activeOnly);
412 bool only_single_feature,
414 bool travel_backward_recursively,
416 std::string& sourcelabel)
const {
423 bool only_single_feature,
426 std::string& sourcelabel )
const {
431 if(index_or_label.index() == 0)
return status;
437 std::vector<unsigned int>&
cuts ,std::vector<std::pair<CLID, std::string> >& )
const {
446 unsigned int totalSizeIndex = output.size();
450 cuts.push_back(output.size());
454 ATH_MSG_DEBUG(
"serializes: TE serialization status: " << tesSerializationStatus <<
" size: " << output.size());
456 cuts.push_back(output.size());
458 output.insert(output.end(),holderdata.begin(),holderdata.end());
460 for(
auto hc : holderblobsizes){
cuts.push_back(
cuts.back()+hc);}
462 output[totalSizeIndex] = output.size();
469 std::vector<uint32_t>& holderblobsizes,
470 std::vector<std::pair<CLID, std::string> >& clid_name)
const {
474 ATH_MSG_DEBUG(
"serialization (ordered) of featue attempting : " <<
cl.first <<
" " <<
cl.second);
478 ATH_MSG_DEBUG(
"serialization (ordered) of feature skipped, nothing know on this objects" );
482 <<
" size of payload up to now: " << output.size());
484 std::vector<uint32_t> holderblob;
485 size_t payloadsize = 0;
492 output.push_back(holderblob.size());
493 output.insert(output.end(),holderblob.begin(),holderblob.end());
495 holderblobsizes.push_back(1+holderblob.size());
496 clid_name.push_back(std::pair < CLID, std::string> (holder->
typeClid(), holder->
label()));
503 for(
auto& holder : holders){
504 ATH_MSG_DEBUG(
"serialization of feature: " << holder->typeClid() <<
" label: " << holder->label()
505 <<
" size of payload: " << output.size());
507 std::vector<uint32_t> holderblob;
508 bool status = holder->serialize(holderblob);
513 output.push_back(holderblob.size());
514 output.insert(output.end(),holderblob.begin(),holderblob.end());
516 holderblobsizes.push_back(1+holderblob.size());
517 clid_name.push_back(std::pair < CLID, std::string> (holder->typeClid(), holder->label()));
HLTNavDetails::IHolder * prepareOneHolder(CLID clid, const std::string &label)
void getAll(std::vector< TriggerElement * > &output, const bool activeOnly=true) const
The query returning a collection of all TriggerElements.
const std::string & label() const
returns the label of objects stores by this holder
void getAllOfType(const te_id_type id, std::vector< TriggerElement * > &output, const bool activeOnly=true) const
The query returning a collection of all TriggerElements if name is given.
std::string label(class_id_type clid, const index_or_label_type &sti_or_label) const
unsigned m_objectsIndexOffset
small integer used to generate sub type index
void printASCIIArt(std::string &str, const TriggerElement *te=0, int offset=0) const
pretty printing of the navigational structure (heavy)
bool serialize_DSonly(std::vector< uint32_t > &output, std::vector< unsigned int > &cuts, std::vector< std::pair< CLID, std::string > > &clid_name) const
bool extractBlob(const std::vector< uint32_t > &input, std::vector< uint32_t >::const_iterator &it, std::vector< uint32_t > &blob) const
std::vector< FeatureAccessHelper > FeatureVec
std::recursive_mutex & getMutex()
bool deserialize(const std::vector< uint32_t > &input)
virtual bool getFeatureAccessors(const TriggerElement *te, class_id_type clid, const index_or_label_type &index_or_label, bool only_single_feature, TriggerElement::FeatureVec &features, bool travel_backward_recursively, const TriggerElement *&source=m_unspecifiedTE, std::string &sourcelabel=m_unspecifiedLabel) const
retrieve features accessors according to the requrements This method is actually workhorse for all ab...
static const CLIDtoHolderMap & holders()
virtual bool getFeatureAccessorsSingleTE(const TriggerElement *te, class_id_type clid, const index_or_label_type &index_or_label, bool only_single_feature, TriggerElement::FeatureVec &features, const TriggerElement *&source, std::string &sourcelabel) const
virtual void reset(bool inFinalize=false)
resets all the navigation, goes to the factory and asks to withdraw all produced objects
static uint32_t string2hash(const std::string &, const std::string &category="TE")
convert strin g to hash.
std::vector< HolderType * > getHoldersOfClid(class_id_type clid) const
bool merge(const NavigationCore &l2)
attemtps to merge two trees
#define ATH_MSG_VERBOSE(x)
bool createHolder(HLTNavDetails::IHolder *&holder, CLID clid, const std::string &label, uint16_t idx) const
creates holder for type given by CLID
bool registerHolder(const std::shared_ptr< BaseHolder > &holder)
virtual bool getFeatureAccessors(const TriggerElement *te, class_id_type clid, const index_or_label_type &index_or_label, bool only_single_feature, TriggerElement::FeatureVec &features, bool travel_backward_recursively, const TriggerElement *&source=m_unspecifiedTE, std::string &sourcelabel=m_unspecifiedLabel) const
virtual void reset(bool inFinalize=false)
resets all the navigation, goes to the factory and asks to withdraw all produced objects
virtual void prepare()
prepapres the navigation for next event
HLTNavDetails::Holder< T > * getHolder(uint16_t subTypeIndex) const
as above but does not create holder on demand (return 0 if not found)
virtual bool syncWithSG(SG::OwnershipPolicy policy=SG::OWN_ELEMENTS)=0
MsgStream & operator<<(MsgStream &m, const Navigation &nav)
The NavigationCore class, adds on top of the TrigNavStructure the EDM read-only handling.
NavigationCore(const AthAlgTool &logger)
constructor with parent AlgTool for printing
std::vector< CSPair > m_classesToPayload
classess are put to payload according to that priority list (CLID + key)
Maintain a set of objects, one per slot.
bool deserializeTEs(std::vector< uint32_t >::const_iterator &start, unsigned int totalSize)
bool serializeHoldersWithPayload(const std::vector< CSPair > &payload, std::vector< uint32_t > &output, std::vector< uint32_t > &holderblobsizes, std::vector< std::pair< CLID, std::string > > &clid_name) const
bool serializeTEs(std::vector< uint32_t > &output) const
method serizlizes the navigation structure
static HLTHash string2hash(const std::string &, const std::string &category="TE")
hash function translating TE names into identifiers
std::variant< sub_index_type, std::string > index_or_label_type
It used to be useful piece of code for replacing actual SG with other store of similar functionality ...
ITrigHolderFactory * m_holderfactory
TriggerElement is the basic ingreedient of the interface between HLT algorithms and the navigation It...
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.
static const TriggerElement *m_unspecifiedTE ATLAS_THREAD_SAFE
uint16_t nextSubTypeIndex(CLID clid, const std::string &label) const
TrigHolderStructure & getHolderStorage()
bool msgLvl(const MSG::Level lvl) const
uint32_t CLID
The Class ID type.
uint64_t crc64(const CRCTable &table, const char *data, size_t data_len)
Find the CRC-64 of a string,.
void getAllOfType(const std::string &id, std::vector< HLT::TriggerElement * > &output, const bool activeOnly=true) const
return trigger elements given the name of TEs
bool serializeWithHolderSection(const std::vector< uint32_t > &holderdata, const std::vector< unsigned int > &holderblobsizes, std::vector< uint32_t > &output, std::vector< unsigned int > &cuts, std::vector< std::pair< CLID, std::string > > &clid_name) const
virtual BaseHolder * createHolder(class_id_type clid, const std::string &label, sub_index_type index) const =0
std::vector< CSPair > m_classesToPreregister
classes mentioned here will be put to SG irrespectively of thier presence in event
virtual bool serialize(std::vector< uint32_t > &output) const
method serizlizes the navigation structure The structure is serrizlized in following order ....
virtual bool getFeatureAccessorsSingleTE(const TriggerElement *te, CLID clid, const index_or_label_type &index_or_label, bool only_single_feature, TriggerElement::FeatureVec &features, const TriggerElement *&source=::HLT::TrigNavStructure::m_unspecifiedTE, std::string &sourcelabel=::HLT::TrigNavStructure::m_unspecifiedLabel) const
virtual CLID typeClid() const =0
returns the CLID of objects stores by this holder
#define ATH_MSG_WARNING(x)
uint16_t subTypeIndex() const
returns the index (short number used when linking object to the TE) of objects stores by this holder
bool registerHolder(HLTNavDetails::IHolder *holder)
Maintain a set of objects, one per slot.
virtual BaseHolder * fromSerialized(int version, const std::vector< uint32_t >::const_iterator &start, const std::vector< uint32_t >::const_iterator &end)=0
std::vector< HolderType * > getAllHolders() const
A crc-64 implementation, using pclmul where possible.
virtual const std::string & key() const =0
returns the containers StoreGate key
std::vector< CSPair > m_classesToPayload_DSonly
classess are put to payload according to that priority list (CLID + key)
HolderType * getHolder(class_id_type clid, const std::variant< sub_index_type, std::string > &stiOrLabel) const
Define macros for attributes used to control the static checker.
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]
bool serializeHoldersWithoutPayload(const std::vector< HLTNavDetails::IHolder * > &holders, std::vector< uint32_t > &output, std::vector< uint32_t > &holderblobsizes, std::vector< std::pair< CLID, std::string > > &clid_name) const
bool serializeWithPayload(const xAOD::AuxSelection &sel, std::vector< uint32_t > &output, size_t &payloadsize)
serializes this Holder including payload