ATLAS Offline Software
Loading...
Searching...
No Matches
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
21
22// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
23
24AlgorithmIdentifier::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
57StatusCode AlgorithmIdentifier::isValid() const {
58 if (m_caller == "" || m_store == "" || !m_hash) {
59 return StatusCode::FAILURE;
60 }
61 return StatusCode::SUCCESS;
62}
63
64// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
65
66void 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
84AlgorithmIdentifier 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// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
#define endmsg
A "view" of the event store (IProxyDict).
Definition View.h:46
static HLTHash string2hash(const std::string &, const std::string &category="TE")
hash function translating TE names into identifiers
STL class.
const ExtendedEventContext & getExtendedEventContext(const EventContext &ctx)
Retrieve an extended context from a context object.
bool hasExtendedEventContext(const EventContext &ctx)
Test whether a context object has an extended context installed.
STL namespace.
static AlgorithmIdentifier make(const EventContext &context, const std::string &caller, MsgStream &msg, const int16_t slotOverride=-1)
Construct an AlgorithmIdentifier.
Small structure to hold an algorithm's name and store, plus some details on its EventView.
std::string m_caller
Name of the algorithm.
std::string m_store
Name of the algorithm's store.
TrigConf::HLTHash callerHash(MsgStream &msg) const
size_t m_slotToSaveInto
The slot which is used for the purposes of recording data on this algorithm's execution.
static constexpr int16_t s_noView
Constant value used to express an Algorithm which is not running in a View.
TrigConf::HLTHash storeHash(MsgStream &msg) const
void dump(MsgStream &msg)
size_t m_realSlot
The actual slot of the algorithm.
size_t m_hash
Hash of algorithm + store + realSlot.
StatusCode isValid() const
int16_t m_viewID
If not within an event view, then the m_iewID = s_noView = -1.
MsgStream & msg
Definition testRead.cxx:32