ATLAS Offline Software
Loading...
Searching...
No Matches
CounterGlobal.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7#include "CounterGlobal.h"
8
9CounterGlobal::CounterGlobal(const std::string& name, const MonitorBase* parent)
10 : CounterBase(name, parent)
11{
12 regHistogram("AlgTime_perCall", "Algorithm CPU Time/Call;Time [ms];Events", VariableType::kPerCall, kLog, 0.01, 100000);
13 regHistogram("AlgTime_perEvent", "Algorithm CPU Time/Event;Time [ms];Events", VariableType::kPerEvent);
14 regHistogram("AlgCalls_perEvent", "Algorithm Calls/Event;Calls;Events", VariableType::kPerEvent, kLinear, -0.5, 4999.5, 500);
15 regHistogram("SteeringTime_perEvent", "Steering Time/Event;Time [ms];Events", VariableType::kPerEvent);
16 regHistogram("LbLength", "LBLength;Entry;LB Length [s]", VariableType::kPerEvent, kLinear, -0.5, 0.5, 1);
17}
18
19
20StatusCode CounterGlobal::newEvent(const CostData& data, size_t incrementWalltime, const float weight) {
21
22 uint64_t lowTimestamp = std::numeric_limits<uint64_t>::max();
23 uint64_t highTimestamp = 0;
24 for (const xAOD::TrigComposite* tc : data.costCollection()) {
25 const uint32_t slot = tc->getDetail<uint32_t>("slot");
26 if (slot != data.onlineSlot()) {
27 continue; // When monitoring the master slot, this Counter ignores algs running in different slots
28 }
29
30 const uint64_t start = tc->getDetail<uint64_t>("start"); // in mus
31 const uint64_t stop = tc->getDetail<uint64_t>("stop"); // in mus
32 const float cpuTime = timeToMilliSec(start, stop);
33 ATH_CHECK( fill("AlgTime_perCall", cpuTime, weight) );
34 ATH_CHECK( fill("AlgTime_perEvent", cpuTime, weight) );
35 ATH_CHECK( increment("AlgCalls_perEvent", weight) );
36 lowTimestamp = std::min(lowTimestamp, start);
37 highTimestamp = std::max(highTimestamp, stop);
38 }
39
40 const float steeringTime = timeToMilliSec(lowTimestamp, highTimestamp);
41 ATH_CHECK( fill("SteeringTime_perEvent", steeringTime, weight) );
42
43 if (incrementWalltime == 1) {
44 // Note: This accumulator doesn't use the standard weight.
45 // For P1 data taking it will be filled exactly once per LB
46 ATH_CHECK( fill("LbLength", 0.0, data.liveTime()) );
47 }
48
49 return StatusCode::SUCCESS;
50}
#define ATH_CHECK
Evaluate an expression and check for errors.
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
static Double_t tc
@ kPerEvent
Variable should buffer fill calls in an accumulator and fill the underlying histogram once at the end...
Definition Variable.h:19
@ kPerCall
Variable should fill underlying histogram on each fill.
Definition Variable.h:18
@ kLinear
Linear x-binning.
Definition Variable.h:27
@ kLog
Logarithmic x-binning.
Definition Variable.h:28
Caches and propagates event data to be used by monitoring algorithms.
Definition CostData.h:26
StatusCode fill(const std::string &name, float value, float weight=1.0)
Fill (for per-Call) or accumulate in a buffer (for per-Event) a quantity histogrammed by a named Vari...
float timeToMilliSec(const uint64_t start, const uint64_t stop) const
Helper function.
CounterBase()=delete
Forbid default constructor.
void regHistogram(const std::string &name, const std::string &title, const VariableType type=VariableType::kPerCall, const LogType xaxis=kLog, const float min=0.1, const float max=1000000., const size_t bins=70)
Book a histogram for this Counter, to be filled in per-event monitoring.
StatusCode increment(const std::string &name, float weight=1.0)
Convenience function.
CounterGlobal()=delete
Forbid default constructor.
virtual StatusCode newEvent(const CostData &data, size_t incrementWalltime, const float weight=1.) override
Concrete implementation.
TrigComposite_v1 TrigComposite
Declare the latest version of the class.