ATLAS Offline Software
Loading...
Searching...
No Matches
Navigation.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include <sstream>
6#include <iostream>
7#include <algorithm>
8
9#include <boost/tokenizer.hpp>
10
11#include "GaudiKernel/System.h"
12
15
16using namespace HLT;
17
18Navigation::Navigation( const std::string& type, const std::string& name,
19 const IInterface* parent )
20 : AthAlgTool(type, name, parent),
21 NavigationCore(static_cast<AthAlgTool&>(*this)),
22 m_serializerServiceHandle("TrigSerializeCnvSvc", name),
23 m_clidSvc("ClassIDSvc", name),
25{
26
28 "List of classes which need to be serialized together with the Navigation.");
29
30 declareProperty("ClassesToPayload_DSonly", m_classesToPayloadProperty_DSonly,
31 "List of classes which need to be serialized together with the Navigation (Only in DataScouting collection).");
32
33 declareProperty("ClassesFromPayloadIgnore", m_classesFromPayloadIgnoreProperty,
34 "List of classes (Type[#Key]) to ignore on deserialization of the Navigation.");
35
36 declareProperty("ClassesToPreregister", m_classesToPreregisterProperty,
37 "List of classes which need to be put in SG independently if they appear in event.");
38
39 declareProperty("ObjectsKeyPrefix", m_objectsKeyPrefix="HLT", "The prefix which all Trigger EDM objects will get, by default it is HLT");
40 declareProperty("ObjectsIndexOffset", m_objectsIndexOffset=0, "The offset with which the objects idx is be shifted.");
41 declareProperty("ReadonlyHolders", m_readonly = false, "read only flag for holders (cannot create new feature containers");
42}
43
46
47
49
50 // initialize some pointers of our base class
51 //m_log = &msg();
52 m_storeGate = evtStore().operator->();
53
56
59
60 ATH_CHECK(m_clidSvc.retrieve());
61
62 // payload def
65
66 // ignored classes
67 std::vector<CSPair> ignore;
69 if ( !ignore.empty() ) {
70 ATH_MSG_INFO( "Ignoring " << m_classesFromPayloadIgnoreProperty << " during deserialization");
71 }
72 for (const auto& c : ignore) {
73 ATH_MSG_DEBUG("Ignoring CLID " << c.first << (c.second.empty() ? "" : " with label "+c.second) <<
74 " during deserialization");
75 m_fullholderfactory.addClassToIgnore(c.first, c.second);
76 }
77
78 // initialize converters
79 for (const CSPair& p : m_classesToPayload) {
80 const CLID cl = p.first;
81 StatusCode stmp = m_serializerSvc->addConverter(cl);
82 if (stmp.isFailure())
83 ATH_MSG_WARNING("Initialization of a converter for CLID=" << cl << " failed");
84 }
85
86 // preregistration def
88
89 // print out registered holders
90 if ( msgLvl(MSG::VERBOSE) ) {
91 for (const auto& [clid, holder] : HLT::TypeMaps::holders()) {
92 if (holder==nullptr)
93 ATH_MSG_ERROR("static type information not intialized. Holder is null pointer");
94 else
95 ATH_MSG_VERBOSE(*holder);
96 }
97 }
98
99 // load libraries
100 for ( const std::string& dll : m_dlls ) {
101 System::ImageHandle handle = 0;
102 if ( System::loadDynamicLib( dll, &handle) != 1 )
103 ATH_MSG_WARNING("failed to load " << dll);
104 else
105 ATH_MSG_DEBUG("forcibly loaded library " << dll);
106 }
107
108 ATH_MSG_DEBUG(" successfully initialized Navigation");
109
110 return StatusCode::SUCCESS;
111}
112
113StatusCode
114Navigation::classKey2CLIDKey(const std::vector<std::string>& property,
115 std::vector<CSPair>& decoded ) {
116 // translate Class names into CLID numbers
117
118 for ( const std::string& cname : property ) {
119 CLID clid{0};
120 std::string key;
121 std::string type;
122
123 if ( cname.find('#') != std::string::npos ) {
124 type = cname.substr(0, cname.find('#') );
125 key = cname.substr(cname.find('#')+1 );
126 } else {
127 type = cname;
128 key = "";
129 }
130
131 if ( m_clidSvc->getIDOfTypeName(type, clid).isFailure() ) {
132 ATH_MSG_ERROR("Unable to get CLID for class: " << cname);
133 return StatusCode::FAILURE;
134 }
135
136 ATH_MSG_DEBUG("Recognized CLID : " << type << " and key: " << key);
137
139
140 // anything after a dot is a list of dynamic Aux attributes, separated by dots
141 size_t dotpos = key.find('.');
142 if( dotpos == std::string::npos ) {
143 // If no explicit selection, we want to select nothing (this is a
144 // difference from the offline logic). But an empty selection list
145 // in AuxSelection means to accept everything. So add a dummy name
146 // that shouldn't match anything.
147 const char* dummyName = "__dummyThatShouldNotMatch";
148 [[maybe_unused]]
149 static const SG::AuxElement::Accessor<int> dummyVar (dummyName);
150 static const std::set<std::string> dummySet { dummyName };
151 sel.selectAux (dummySet);
152 }
153 else {
154 std::string aux_attr = key.substr(dotpos+1);
155 key.erase (dotpos, std::string::npos);
156
157 typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
158 boost::char_separator<char> sep(".");
159 tokenizer tokens (aux_attr, sep);
160 sel.selectAux (std::set<std::string> (tokens.begin(), tokens.end()));
161 }
162
163 decoded.emplace_back (clid, key, std::move (sel));
164 }
165 return StatusCode::SUCCESS;
166}
167
168MsgStream& HLT::operator<< ( MsgStream& m, const Navigation& nav ) {
169 m << (NavigationCore&)nav;
170 return m;
171}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Base class for elements of a container that can have aux data.
uint32_t CLID
The Class ID type.
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
ServiceHandle< StoreGateSvc > & evtStore()
The NavigationCore class, adds on top of the TrigNavStructure the EDM read-only handling.
NavigationCore(const AthAlgTool &logger)
constructor with parent AlgTool for printing
ITrigHolderFactory * m_holderfactory
std::vector< std::string > m_classesFromPayloadIgnoreProperty
list of classes::keys to ignore on deserialization
std::vector< CSPair > m_classesToPayload_DSonly
classess are put to payload according to that priority list (CLID + key)
IConversionSvc * m_serializerSvc
unsigned m_objectsIndexOffset
small integer used to generate sub type index
std::vector< std::string > m_classesToPayloadProperty_DSonly
list of classes::keys to be put to DS payload
std::vector< std::string > m_classesToPayloadProperty
list of classes::keys to be put to BS payload
StoreGateSvc * m_storeGate
std::vector< std::string > m_classesToPreregisterProperty
as above but for preregistration
std::vector< CSPair > m_classesToPayload
classess are put to payload according to that priority list (CLID + key)
std::vector< CSPair > m_classesToPreregister
classes mentioned here will be put to SG irrespectively of thier presence in event
bool msgLvl(const MSG::Level lvl) const
std::string m_objectsKeyPrefix
property setting prefix which is to be given to all trigger EDM objects
The Navigation class, organizes TriggerElements into the tree structure.
Definition Navigation.h:100
ServiceHandle< IClassIDSvc > m_clidSvc
Definition Navigation.h:168
StatusCode classKey2CLIDKey(const std::vector< std::string > &property, std::vector< CSPair > &decoded)
FullHolderFactory m_fullholderfactory
Definition Navigation.h:170
virtual StatusCode initialize() override
Gaudi::Property< std::vector< std::string > > m_dlls
Definition Navigation.h:169
virtual ~Navigation()
ServiceHandle< IConversionSvc > m_serializerServiceHandle
Definition Navigation.h:167
static const CLIDtoHolderMap & holders()
Definition TypeMaps.h:30
SG::Accessor< T, ALLOC > Accessor
Definition AuxElement.h:572
Class helping in dealing with dynamic branch selection.
It used to be useful piece of code for replacing actual SG with other store of similar functionality ...
MsgStream & operator<<(MsgStream &m, const Navigation &nav)