ATLAS Offline Software
Loading...
Searching...
No Matches
Navigation.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5
6
7#include "GaudiKernel/System.h"
8
11#include "GaudiKernel/MsgStream.h"
12#include <sstream>
13#include <iostream>
14#include <algorithm>
15#include <ranges>
16#include <string_view>
17
18using namespace HLT;
19
20Navigation::Navigation( const std::string& type, const std::string& name,
21 const IInterface* parent )
22 : AthAlgTool(type, name, parent),
23 NavigationCore(static_cast<AthAlgTool&>(*this)),
24 m_serializerServiceHandle("TrigSerializeCnvSvc", name),
25 m_clidSvc("ClassIDSvc", name),
27{
28
30 "List of classes which need to be serialized together with the Navigation.");
31
32 declareProperty("ClassesToPayload_DSonly", m_classesToPayloadProperty_DSonly,
33 "List of classes which need to be serialized together with the Navigation (Only in DataScouting collection).");
34
35 declareProperty("ClassesFromPayloadIgnore", m_classesFromPayloadIgnoreProperty,
36 "List of classes (Type[#Key]) to ignore on deserialization of the Navigation.");
37
38 declareProperty("ClassesToPreregister", m_classesToPreregisterProperty,
39 "List of classes which need to be put in SG independently if they appear in event.");
40
41 declareProperty("ObjectsKeyPrefix", m_objectsKeyPrefix="HLT", "The prefix which all Trigger EDM objects will get, by default it is HLT");
42 declareProperty("ObjectsIndexOffset", m_objectsIndexOffset=0, "The offset with which the objects idx is be shifted.");
43 declareProperty("ReadonlyHolders", m_readonly = false, "read only flag for holders (cannot create new feature containers");
44}
45
48
49
51
52 // initialize some pointers of our base class
53 //m_log = &msg();
54 m_storeGate = evtStore().operator->();
55
58
61
62 ATH_CHECK(m_clidSvc.retrieve());
63
64 // payload def
67
68 // ignored classes
69 std::vector<CSPair> ignore;
71 if ( !ignore.empty() ) {
72 ATH_MSG_INFO( "Ignoring " << m_classesFromPayloadIgnoreProperty << " during deserialization");
73 }
74 for (const auto& c : ignore) {
75 ATH_MSG_DEBUG("Ignoring CLID " << c.first << (c.second.empty() ? "" : " with label "+c.second) <<
76 " during deserialization");
77 m_fullholderfactory.addClassToIgnore(c.first, c.second);
78 }
79
80 // initialize converters
81 for (const CSPair& p : m_classesToPayload) {
82 const CLID cl = p.first;
83 StatusCode stmp = m_serializerSvc->addConverter(cl);
84 if (stmp.isFailure())
85 ATH_MSG_WARNING("Initialization of a converter for CLID=" << cl << " failed");
86 }
87
88 // preregistration def
90
91 // print out registered holders
92 if ( msgLvl(MSG::VERBOSE) ) {
93 for (const auto& [clid, holder] : HLT::TypeMaps::holders()) {
94 if (holder==nullptr)
95 ATH_MSG_ERROR("static type information not intialized. Holder is null pointer");
96 else
97 ATH_MSG_VERBOSE(*holder);
98 }
99 }
100
101 // load libraries
102 for ( const std::string& dll : m_dlls ) {
103 System::ImageHandle handle = 0;
104 if ( System::loadDynamicLib( dll, &handle) != 1 )
105 ATH_MSG_WARNING("failed to load " << dll);
106 else
107 ATH_MSG_DEBUG("forcibly loaded library " << dll);
108 }
109
110 ATH_MSG_DEBUG(" successfully initialized Navigation");
111
112 return StatusCode::SUCCESS;
113}
114
115StatusCode
116Navigation::classKey2CLIDKey(const std::vector<std::string>& property,
117 std::vector<CSPair>& decoded ) {
118 // translate Class names into CLID numbers
119
120 for ( const std::string& cname : property ) {
121 CLID clid{0};
122 std::string key;
123 std::string type;
124
125 if ( auto hashPos = cname.find('#'); hashPos!= std::string::npos ) {
126 type = cname.substr(0, hashPos);
127 key = cname.substr(hashPos+1 );
128 } else {
129 type = cname;
130 key = "";
131 }
132
133 if ( m_clidSvc->getIDOfTypeName(type, clid).isFailure() ) {
134 ATH_MSG_ERROR("Unable to get CLID for class: " << cname);
135 return StatusCode::FAILURE;
136 }
137
138 ATH_MSG_DEBUG("Recognized CLID : " << type << " and key: " << key);
139
141
142 // anything after a dot is a list of dynamic Aux attributes, separated by dots
143 size_t dotpos = key.find('.');
144 if( dotpos == std::string::npos ) {
145 // If no explicit selection, we want to select nothing (this is a
146 // difference from the offline logic). But an empty selection list
147 // in AuxSelection means to accept everything. So add a dummy name
148 // that shouldn't match anything.
149 const char* dummyName = "__dummyThatShouldNotMatch";
150 [[maybe_unused]]
151 static const SG::AuxElement::Accessor<int> dummyVar (dummyName);
152 static const std::set<std::string> dummySet { dummyName };
153 sel.selectAux (dummySet);
154 }
155 else {
156 std::string aux_attr = key.substr(dotpos+1);
157 key.erase (dotpos, std::string::npos);
158 std::vector<std::string> tokens;
159 for (auto&& token : std::views::split(std::string_view{aux_attr}, '.')) tokens.emplace_back(token.begin(), token.end());
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_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_VERBOSE(x,...)
#define ATH_MSG_INFO(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
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)