ATLAS Offline Software
AlgorithmIdentifier.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "AthViews/View.h"
8 
10 
12 
14  m_realSlot(),
15  m_slotToSaveInto(),
16  m_caller(""),
17  m_store(""),
18  m_viewID(0),
19  m_hash(0)
20  {}
21 
22 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
23 
24 AlgorithmIdentifier::AlgorithmIdentifier(const size_t realSlot, const size_t saveSlot, const std::string& caller, const std::string& storeName, const int16_t viewID) :
25  m_realSlot(realSlot),
26  m_slotToSaveInto(saveSlot),
27  m_caller(caller),
28  m_store(storeName),
29  m_viewID(viewID),
30  m_hash(std::hash<std::string>{}(m_caller + m_store + std::to_string(realSlot)))
31  {}
32 
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
34 
36  try {
38  } catch (const std::exception& ex) {
39  msg << MSG::DEBUG << "Caught " << typeid(ex).name() << ": " << ex.what() << endmsg;
40  }
41  return 0;
42 }
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
45 
47  try {
49  } catch (const std::exception& ex) {
50  msg << MSG::DEBUG << "Caught " << typeid(ex).name() << ": " << ex.what() << endmsg;
51  }
52  return 0;
53 }
54 
55 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
56 
58  if (m_caller == "" || m_store == "" || !m_hash) {
59  return StatusCode::FAILURE;
60  }
61  return StatusCode::SUCCESS;
62 }
63 
64 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
65 
66 void AlgorithmIdentifier::dump (MsgStream& msg) {
67  TrigConf::HLTHash theCallerHash = callerHash(msg);
68  TrigConf::HLTHash theStoreHash = storeHash(msg);
69 
70  msg << MSG::INFO << "----------" << endmsg;
71  msg << "Valid? " << (isValid() ? "YES" : "NO") << endmsg;
72  msg << "Real Slot:" << m_realSlot << endmsg;
73  msg << "Slot Save Overrride:" << m_slotToSaveInto << endmsg;
74  msg << "Caller:'" << m_caller << "'" << endmsg;
75  msg << "Caller Hash:" << theCallerHash << endmsg;
76  msg << "Store:'" << m_store << "'" << endmsg;
77  msg << "Store Hash:" << theStoreHash << endmsg;
78  msg << "View ID:" << m_viewID << endmsg;
79  msg << "AI Hash:" << m_hash << endmsg;
80 }
81 
82 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
83 
84 AlgorithmIdentifier AlgorithmIdentifierMaker::make(const EventContext& context, const std::string& caller, MsgStream& msg, const int16_t slotOverride) {
85  const SG::View* view = nullptr;
86  const IProxyDict* proxy = nullptr;
87  if (Atlas::hasExtendedEventContext(context)) {
88  proxy = Atlas::getExtendedEventContext(context).proxy();
89  if (proxy) view = dynamic_cast<const SG::View*>(proxy);
90  }
91  if (!proxy) {
92  msg << MSG::ERROR << "Unable to obtain IProxyDict from Atlas::ExtendedEventContext" << endmsg;
93  return AlgorithmIdentifier(); // Return a default constructed, invalid, identifier
94  }
95  const int16_t viewID = (view == nullptr ? AlgorithmIdentifier::s_noView : view->viewID());
96  const size_t saveSlot = (slotOverride >= 0 ? slotOverride : context.slot());
97  return AlgorithmIdentifier(context.slot(), saveSlot, caller, proxy->name(), viewID);
98 }
99 
100 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
AlgorithmIdentifier::m_slotToSaveInto
size_t m_slotToSaveInto
The slot which is used for the purposes of recording data on this algorithm's execution.
Definition: AlgorithmIdentifier.h:32
AlgorithmIdentifier::storeHash
TrigConf::HLTHash storeHash(MsgStream &msg) const
Definition: AlgorithmIdentifier.cxx:46
StateLessPT_NewConfig.proxy
proxy
Definition: StateLessPT_NewConfig.py:392
AlgorithmIdentifier::AlgorithmIdentifier
AlgorithmIdentifier()
Definition: AlgorithmIdentifier.cxx:13
AthCheckMacros.h
AlgorithmIdentifier
Small structure to hold an algorithm's name and store, plus some details on its EventView....
Definition: AlgorithmIdentifier.h:21
AlgorithmIdentifier::m_caller
std::string m_caller
Name of the algorithm.
Definition: AlgorithmIdentifier.h:33
AlgorithmIdentifier::s_noView
static constexpr int16_t s_noView
Constant value used to express an Algorithm which is not running in a View.
Definition: AlgorithmIdentifier.h:38
TrigConf::HLTHash
uint32_t HLTHash
Definition: TrigConfHLTUtils/TrigConfHLTUtils/HLTUtils.h:19
ExtendedEventContext.h
Atlas::hasExtendedEventContext
bool hasExtendedEventContext(const EventContext &ctx)
Test whether a context object has an extended context installed.
Definition: ExtendedEventContext.cxx:23
AlgorithmIdentifier.h
AlgorithmIdentifierMaker::make
static AlgorithmIdentifier make(const EventContext &context, const std::string &caller, MsgStream &msg, const int16_t slotOverride=-1)
Construct an AlgorithmIdentifier.
Definition: AlgorithmIdentifier.cxx:84
IProxyDict
A proxy dictionary.
Definition: AthenaKernel/AthenaKernel/IProxyDict.h:51
xAOD::int16_t
setScaleOne setStatusOne setSaturated int16_t
Definition: gFexGlobalRoI_v1.cxx:55
Atlas::getExtendedEventContext
const ExtendedEventContext & getExtendedEventContext(const EventContext &ctx)
Retrieve an extended context from a context object.
Definition: ExtendedEventContext.cxx:32
AlgorithmIdentifier::m_store
std::string m_store
Name of the algorithm's store.
Definition: AlgorithmIdentifier.h:34
AlgorithmIdentifier::m_hash
size_t m_hash
Hash of algorithm + store + realSlot.
Definition: AlgorithmIdentifier.h:36
TrigConf::HLTUtils::string2hash
static HLTHash string2hash(const std::string &, const std::string &category="TE")
hash function translating TE names into identifiers
AlgorithmIdentifier::dump
void dump(MsgStream &msg)
Definition: AlgorithmIdentifier.cxx:66
AlgorithmIdentifier::isValid
StatusCode isValid() const
Definition: AlgorithmIdentifier.cxx:57
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
AlgorithmIdentifier::callerHash
TrigConf::HLTHash callerHash(MsgStream &msg) const
Definition: AlgorithmIdentifier.cxx:35
calibdata.exception
exception
Definition: calibdata.py:496
AlgorithmIdentifier::m_viewID
int16_t m_viewID
If not within an event view, then the m_iewID = s_noView = -1.
Definition: AlgorithmIdentifier.h:35
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
AlgorithmIdentifier::m_realSlot
size_t m_realSlot
The actual slot of the algorithm.
Definition: AlgorithmIdentifier.h:31
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
DEBUG
#define DEBUG
Definition: page_access.h:11
View.h
SG::View
Definition: View.h:25
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
drawFromPickle.view
view
Definition: drawFromPickle.py:294