ATLAS Offline Software
GenericMonitoringTool.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef AthenaMonitoringKernel_GenericMonitoringTool_h
6 #define AthenaMonitoringKernel_GenericMonitoringTool_h
7 
8 #include <functional>
9 #include <vector>
10 #include <mutex>
11 #include <memory>
12 
13 #include "TH1.h"
14 #include "TH2.h"
15 #include "TProfile.h"
16 #include "TProfile2D.h"
17 
18 #include "GaudiKernel/ITHistSvc.h"
19 
21 
24 
25 /* Here, by forward declaring these two classes, which appear as parameters and values
26  in GenericMonitoringTool functions only as pointers (not as the objects themselves),
27  we can avoid including those class headers here, moving them to the implementation
28  file instead. This prevents external dependancy of the public-facing tool on the
29  internals of AthenaMonitoringKernel. */
30 namespace Monitored {
32  class HistogramFiller;
34  class IMonitoredVariable;
35 }
36 
50 namespace Monitored {
51  class Group;
52 }
53 class GenericMonitoringTool : public extends<AthAlgTool, IIncidentListener> {
54 public:
55  using extends::extends;
56 
57  virtual ~GenericMonitoringTool() override;
58  virtual StatusCode initialize() override;
59  virtual StatusCode start() override;
60  virtual StatusCode stop() override;
61  void handle( const Incident& ) override;
62 
64  void invokeFillers(const std::vector<std::reference_wrapper<Monitored::IMonitoredVariable>>& monitoredVariables) const;
65 
67  StatusCode book();
69  void setPath( const std::string& newPath ) { m_histoPath = newPath; }
70  const std::string getPath() const { return m_histoPath; }
71 
72  virtual const ServiceHandle<ITHistSvc>& histogramService() const { return m_histSvc; }
73  virtual uint32_t runNumber();
74  virtual uint32_t lumiBlock();
75 
76 private:
77  void invokeFillersDebug(const std::shared_ptr<Monitored::HistogramFiller>& filler,
78  const std::vector<std::reference_wrapper<Monitored::IMonitoredVariable>>& monitoredVariables) const;
79 
81  ServiceHandle<ITHistSvc> m_histSvc { this, "THistSvc", "THistSvc", "Histogramming svc" };
82  Gaudi::Property<std::string> m_histoPath { this, "HistPath", {}, "Directory for histograms [name of parent if not set]" };
83  Gaudi::Property<std::vector<std::string> > m_histograms { this, "Histograms", {}, "Definitions of histograms", "OrderedSet<std::string>"};
84  Gaudi::Property<bool> m_explicitBooking { this, "ExplicitBooking", false, "Do not create histograms automatically in initialize but wait until the method book is called." };
85  Gaudi::Property<bool> m_failOnEmpty { this, "FailOnEmpty", true, "Fail in initialize() if no histograms defined" };
86  BooleanProperty m_useCache { this, "UseCache", true, "Cache filler lookups" };
87  BooleanProperty m_registerHandler { this, "RegisterHandler", true, "Use incident handler to make 'always book' plots (else only check once)" };
88 
89  std::vector<std::shared_ptr<Monitored::HistogramFiller>> m_fillers;
90  std::vector<std::shared_ptr<Monitored::HistogramFiller>> m_alwaysCreateFillers;
91  mutable std::map<std::vector<std::string>,std::unique_ptr<std::vector<std::shared_ptr<Monitored::HistogramFiller>>>,std::less<>> m_fillerCacheMap ATLAS_THREAD_SAFE;
93 
94 };
95 
105 class VoidMonitoringTool : public ToolHandle<GenericMonitoringTool> {
106 public:
107  VoidMonitoringTool(const IInterface* parent) :
108  ToolHandle<GenericMonitoringTool>("", parent) {}
109 };
110 
111 #endif /* AthenaMonitoringKernel_GenericMonitoringTool_h */
ReadHandleKey.h
Property holding a SG store/key/clid from which a ReadHandle is made.
GenericMonitoringTool::m_useCache
BooleanProperty m_useCache
Definition: GenericMonitoringTool.h:86
TrigDefs::Group
Group
Properties of a chain group.
Definition: GroupProperties.h:13
GenericMonitoringTool::stop
virtual StatusCode stop() override
Definition: GenericMonitoringTool.cxx:38
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
GenericMonitoringTool::m_histoPath
Gaudi::Property< std::string > m_histoPath
Definition: GenericMonitoringTool.h:82
BeamSpot::mutex
std::mutex mutex
Definition: InDetBeamSpotVertex.cxx:18
GenericMonitoringTool::m_alwaysCreateFillers
std::vector< std::shared_ptr< Monitored::HistogramFiller > > m_alwaysCreateFillers
fillers that need touching, usually empty
Definition: GenericMonitoringTool.h:90
GenericMonitoringTool::m_histograms
Gaudi::Property< std::vector< std::string > > m_histograms
Definition: GenericMonitoringTool.h:83
GenericMonitoringTool::lumiBlock
virtual uint32_t lumiBlock()
Definition: GenericMonitoringTool.cxx:286
GenericMonitoringTool::m_registerHandler
BooleanProperty m_registerHandler
Definition: GenericMonitoringTool.h:87
VoidMonitoringTool::VoidMonitoringTool
VoidMonitoringTool(const IInterface *parent)
Definition: GenericMonitoringTool.h:107
GenericMonitoringTool::book
StatusCode book()
Book histograms.
Definition: GenericMonitoringTool.cxx:56
GenericMonitoringTool::getPath
const std::string getPath() const
Definition: GenericMonitoringTool.h:70
GenericMonitoringTool::~GenericMonitoringTool
virtual ~GenericMonitoringTool() override
Definition: GenericMonitoringTool.cxx:23
GenericMonitoringTool::initialize
virtual StatusCode initialize() override
Definition: GenericMonitoringTool.cxx:25
GenericMonitoringTool::m_explicitBooking
Gaudi::Property< bool > m_explicitBooking
Definition: GenericMonitoringTool.h:84
GenericMonitoringTool::setPath
void setPath(const std::string &newPath)
Overrride configured booking path.
Definition: GenericMonitoringTool.h:69
GenericMonitoringTool::invokeFillersDebug
void invokeFillersDebug(const std::shared_ptr< Monitored::HistogramFiller > &filler, const std::vector< std::reference_wrapper< Monitored::IMonitoredVariable >> &monitoredVariables) const
Definition: GenericMonitoringTool.cxx:259
GenericMonitoringTool::m_cacheMutex
std::mutex m_cacheMutex
Definition: GenericMonitoringTool.h:92
Monitored::IMonitoredVariable
Definition: IMonitoredVariable.h:14
GenericMonitoringTool::m_failOnEmpty
Gaudi::Property< bool > m_failOnEmpty
Definition: GenericMonitoringTool.h:85
Monitored
Generic monitoring tool for athena components.
Definition: GenericMonitoringTool.h:30
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
AthAlgTool.h
GenericMonitoringTool::handle
void handle(const Incident &) override
Definition: GenericMonitoringTool.cxx:50
test_pyathena.parent
parent
Definition: test_pyathena.py:15
GenericMonitoringTool::runNumber
virtual uint32_t runNumber()
Definition: GenericMonitoringTool.cxx:282
GenericMonitoringTool::invokeFillers
void invokeFillers(const std::vector< std::reference_wrapper< Monitored::IMonitoredVariable >> &monitoredVariables) const
feed the fillers
Definition: GenericMonitoringTool.cxx:164
GenericMonitoringTool::start
virtual StatusCode start() override
Definition: GenericMonitoringTool.cxx:30
Monitored::HistogramFiller
Base class for all histogram fillers.
Definition: HistogramFiller.h:43
GenericMonitoringTool
Definition: GenericMonitoringTool.py:1
VoidMonitoringTool
Helper class to declare an empty monitoring ToolHandle.
Definition: GenericMonitoringTool.h:105
GenericMonitoringTool::histogramService
virtual const ServiceHandle< ITHistSvc > & histogramService() const
Definition: GenericMonitoringTool.h:72
GenericMonitoringTool::ATLAS_THREAD_SAFE
std::map< std::vector< std::string >, std::unique_ptr< std::vector< std::shared_ptr< Monitored::HistogramFiller > > >, std::less<> > m_fillerCacheMap ATLAS_THREAD_SAFE
lookup map to speed up filler searches
Definition: GenericMonitoringTool.h:91
EventInfo.h
GenericMonitoringTool::m_fillers
std::vector< std::shared_ptr< Monitored::HistogramFiller > > m_fillers
plain list of fillers
Definition: GenericMonitoringTool.h:89
GenericMonitoringTool::m_histSvc
ServiceHandle< ITHistSvc > m_histSvc
THistSvc (do NOT fix the service type (only the name) to allow for a different implementation online.
Definition: GenericMonitoringTool.h:81
ServiceHandle< ITHistSvc >