ATLAS Offline Software
MonitoredRange.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 "TrigCostAnalysis.h"
6 #include "MonitoredRange.h"
7 #include "MonitorBase.h"
8 
9 #include "TProfile.h"
10 
12  m_name(name),
13  m_parent(parent),
14  m_cachedLifetimeHistPtr(nullptr),
15  m_monitors(),
16  m_seenLB()
17 {
18  std::string hisSvcName = getName() + "_walltime";
19  std::unique_ptr<TProfile> hist = std::make_unique<TProfile>(hisSvcName.c_str(), "Walltime;;Seconds", 5000, 0, 5000);
20  m_cachedLifetimeHistPtr = bookGetPointer(hist.release()); // Now owned by HistSvc
21 }
22 
23 
24 const std::string& MonitoredRange::getName() const {
25  return m_name;
26 }
27 
28 
30  return m_parent;
31 }
32 
33 
34 TH1* MonitoredRange::bookGetPointer(TH1* hist, const std::string& tDir) const {
35  std::string dir = getName();
36  if (tDir != "") {
37  dir += "/";
38  dir += tDir;
39  }
40  return getParent()->bookGetPointer(hist, dir);
41 }
42 
43 
44 std::set< std::unique_ptr<MonitorBase> >& MonitoredRange::getMonitors() {
45  return m_monitors;
46 }
47 
48 
49 StatusCode MonitoredRange::addMonitor(std::unique_ptr<MonitorBase> monitor) {
50  m_monitors.insert( std::move(monitor) );
51  return StatusCode::SUCCESS;
52 }
53 
54 
55 StatusCode MonitoredRange::newEvent(const CostData& data, const float weight, const bool skipMonitoringThisEvent) {
56  if (not skipMonitoringThisEvent) {
57  for (auto& monitor : getMonitors()) {
58  ATH_CHECK(monitor->newEvent(data, weight));
59  ATH_CHECK(monitor->endEvent(weight));
60  }
61  }
63  const bool isNewLB = m_seenLB.insert( data.lb() ).second; // .second is true if a new element was inserted
64  if (data.liveTimeIsPerEvent() or isNewLB) {
65  // We have two modes of operation. Either we process an EnhancedBias file where we know exactly how many events to expect
66  // and can hence fill a per-event live time (meaning that the normalisation is correct, even if we do not run over all events).
67  // For this case we increment this bin for event event this monitor sees.
68  // Or, we can process P1 data where we only know the LB length and must assume that all events are collected and processed,
69  // otherwise the normalisation will be off. For this case we increment this one for every unique LB this monitor sees.
70  m_cachedLifetimeHistPtr->Fill(data.lb(), data.liveTime());
71  }
72 
73  return StatusCode::SUCCESS;
74 }
MonitoredRange::m_parent
TrigCostAnalysis * m_parent
Cached ptr to the parent Athena algorithm.
Definition: MonitoredRange.h:102
MonitorBase.h
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
MonitoredRange::bookGetPointer
TH1 * bookGetPointer(TH1 *hist, const std::string &tDir="") const
Appends Range's name (to histogram path) and forwards histogram book request to parent Athena algorit...
Definition: MonitoredRange.cxx:34
TrigCostAnalysis::bookGetPointer
TH1 * bookGetPointer(TH1 *hist, const std::string &tDir="") const
Public method forwarded to this class' AthHistogramAlgorithm::bookGetPointer base.
Definition: TrigCostAnalysis.cxx:171
MonitoredRange.h
plotmaker.hist
hist
Definition: plotmaker.py:148
MonitoredRange::addMonitor
StatusCode addMonitor(std::unique_ptr< MonitorBase > monitor)
Adds a new Monitor into this Range.
Definition: MonitoredRange.cxx:49
MonitoredRange::m_monitors
std::set< std::unique_ptr< MonitorBase > > m_monitors
Storage of Range's Monitors.
Definition: MonitoredRange.h:104
MonitoredRange::m_seenLB
std::set< uint32_t > m_seenLB
Luminosity blocks for which we have seen at least one event.
Definition: MonitoredRange.h:105
MonitoredRange::getName
const std::string & getName() const
Getter for Range's name.
Definition: MonitoredRange.cxx:24
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:189
MonitoredRange::m_name
const std::string m_name
Name of the Monitored Range.
Definition: MonitoredRange.h:101
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
MonitoredRange::newEvent
StatusCode newEvent(const CostData &data, const float weight=1., const bool skipMonitoringThisEvent=false)
Interface called by TrigCostAnalysis algorithm to instruct this Range to trigger all its Monitors.
Definition: MonitoredRange.cxx:55
beamspotman.dir
string dir
Definition: beamspotman.py:623
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
MonitoredRange::getMonitors
std::set< std::unique_ptr< MonitorBase > > & getMonitors()
Getter for Range's owned Monitors.
Definition: MonitoredRange.cxx:44
TrigCostAnalysis.h
TrigCostAnalysis
Athena algorithm used to process Trigger cost monitoring data in Run 3 and above. Outputs histograms.
Definition: TrigCostAnalysis.h:36
MonitoredRange::m_cachedLifetimeHistPtr
TH1 * m_cachedLifetimeHistPtr
Cached histogram ptr used to store normalisation quantities.
Definition: MonitoredRange.h:103
MonitoredRange::MonitoredRange
MonitoredRange()=delete
Forbid default constructor.
CostData
Caches and propagates event data to be used by monitoring algorithms.
Definition: CostData.h:26
MonitoredRange::getParent
const TrigCostAnalysis * getParent() const
Return cached non-owning ptr to this Monitor's parent TrigCostAnalysis Athena algorithm.
Definition: MonitoredRange.cxx:29