ATLAS Offline Software
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 
16 using namespace HLT;
17 
18 Navigation::Navigation( const std::string& type, const std::string& name,
19  const IInterface* parent )
21  NavigationCore(static_cast<AthAlgTool&>(*this)),
22  m_serializerServiceHandle("TrigSerializeCnvSvc", name),
23  m_clidSvc("ClassIDSvc", name),
24  m_fullholderfactory(m_objectsKeyPrefix)
25 {
26 
27  declareProperty("ClassesToPayload", m_classesToPayloadProperty,
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 
45 }
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 
114 Navigation::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 
168 MsgStream& HLT::operator<< ( MsgStream& m, const Navigation& nav ) {
169  m << (NavigationCore&)nav;
170  return m;
171 }
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
HLT::NavigationCore::m_objectsKeyPrefix
std::string m_objectsKeyPrefix
property setting prefix which is to be given to all trigger EDM objects
Definition: NavigationCore.h:371
SG::Accessor
Helper class to provide type-safe access to aux data.
Definition: Control/AthContainers/AthContainers/Accessor.h:68
HLT::NavigationCore::m_objectsIndexOffset
unsigned m_objectsIndexOffset
small integer used to generate sub type index
Definition: NavigationCore.h:372
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
HLT::Navigation::m_readonly
bool m_readonly
Definition: Navigation.h:171
HLT::NavigationCore::m_classesToPayloadProperty
std::vector< std::string > m_classesToPayloadProperty
list of classes::keys to be put to BS payload
Definition: NavigationCore.h:388
HLT::TypeMaps::holders
static const CLIDtoHolderMap & holders()
Definition: TypeMaps.h:30
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
beamspotman.tokens
tokens
Definition: beamspotman.py:1284
HLT::FullHolderFactory::addClassToIgnore
void addClassToIgnore(class_id_type clid, const std::string &label="")
Ignore class with clid (and optional label) during deserialization.
Definition: FullHolderFactory.h:39
HLT::operator<<
MsgStream & operator<<(MsgStream &m, const Navigation &nav)
Definition: Navigation.cxx:168
HLT::NavigationCore
The NavigationCore class, adds on top of the TrigNavStructure the EDM read-only handling.
Definition: NavigationCore.h:96
DiTauMassTools::ignore
void ignore(T &&)
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:58
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
HLT::NavigationCore::m_classesToPayload
std::vector< CSPair > m_classesToPayload
classess are put to payload according to that priority list (CLID + key)
Definition: NavigationCore.h:389
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
HLT::NavigationCore::m_classesToPayloadProperty_DSonly
std::vector< std::string > m_classesToPayloadProperty_DSonly
list of classes::keys to be put to DS payload
Definition: NavigationCore.h:391
HLT
It used to be useful piece of code for replacing actual SG with other store of similar functionality ...
Definition: HLTResultReader.h:26
HLT::NavigationCore::m_holderfactory
ITrigHolderFactory * m_holderfactory
Definition: NavigationCore.h:375
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
sel
sel
Definition: SUSYToolsTester.cxx:97
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
Navigation.h
HLT::Navigation
The Navigation class, organizes TriggerElements into the tree structure.
Definition: Navigation.h:100
HLT::NavigationCore::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition: NavigationCore.h:411
HLT::Navigation::initialize
virtual StatusCode initialize() override
Definition: Navigation.cxx:48
HLT::FullHolderFactory::prepare
void prepare(StoreGateSvc *store, IConversionSvc *serializer, bool readonly=true)
Definition: FullHolderFactory.h:32
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
HLT::Navigation::m_serializerServiceHandle
ServiceHandle< IConversionSvc > m_serializerServiceHandle
Definition: Navigation.h:167
HLT::NavigationCore::m_serializerSvc
IConversionSvc * m_serializerSvc
Definition: NavigationCore.h:369
grepfile.sep
sep
Definition: grepfile.py:38
xAOD::AuxSelection
Class helping in dealing with dynamic branch selection.
Definition: AuxSelection.h:31
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
HLT::NavigationCore::m_storeGate
StoreGateSvc * m_storeGate
Definition: NavigationCore.h:370
HLT::NavigationCore::m_classesToPreregister
std::vector< CSPair > m_classesToPreregister
classes mentioned here will be put to SG irrespectively of thier presence in event
Definition: NavigationCore.h:397
HLT::Navigation::m_fullholderfactory
FullHolderFactory m_fullholderfactory
Definition: Navigation.h:170
HLT::Navigation::Navigation
Navigation()
HLT::Navigation::~Navigation
virtual ~Navigation()
Definition: Navigation.cxx:44
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
HLT::Navigation::m_clidSvc
ServiceHandle< IClassIDSvc > m_clidSvc
Definition: Navigation.h:168
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:14
HLT::NavigationCore::m_classesToPayload_DSonly
std::vector< CSPair > m_classesToPayload_DSonly
classess are put to payload according to that priority list (CLID + key)
Definition: NavigationCore.h:392
AthAlgTool
Definition: AthAlgTool.h:26
HLT::Navigation::classKey2CLIDKey
StatusCode classKey2CLIDKey(const std::vector< std::string > &property, std::vector< CSPair > &decoded)
Definition: Navigation.cxx:114
HLT::Navigation::m_dlls
Gaudi::Property< std::vector< std::string > > m_dlls
Definition: Navigation.h:169
python.compressB64.c
def c
Definition: compressB64.py:93
dq_make_web_display.cl
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]
Definition: dq_make_web_display.py:26
HLT::NavigationCore::CSPair
Definition: NavigationCore.h:378
HLT::NavigationCore::m_classesFromPayloadIgnoreProperty
std::vector< std::string > m_classesFromPayloadIgnoreProperty
list of classes::keys to ignore on deserialization
Definition: NavigationCore.h:394
AuxElement.h
Base class for elements of a container that can have aux data.
HLT::NavigationCore::m_classesToPreregisterProperty
std::vector< std::string > m_classesToPreregisterProperty
as above but for preregistration
Definition: NavigationCore.h:396
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37