ATLAS Offline Software
Public Member Functions | Private Attributes | Static Private Attributes | List of all members
Monitored::LumiblockHistogramProvider Class Reference

Implementation of IHistogramProvider for lumi block based histograms. More...

#include <LumiblockHistogramProvider.h>

Inheritance diagram for Monitored::LumiblockHistogramProvider:
Collaboration diagram for Monitored::LumiblockHistogramProvider:

Public Member Functions

 LumiblockHistogramProvider (GenericMonitoringTool *const gmTool, std::shared_ptr< HistogramFactory > factory, const HistogramDef &histDef)
 Constructor. More...
 
TNamed * histogram () override
 Getter of ROOT object. More...
 

Private Attributes

GenericMonitoringTool *const m_gmTool
 
std::shared_ptr< HistogramFactorym_factory
 
const HistogramDef m_histDef
 
std::map< unsigned, std::pair< HistogramDef, TNamed * > > m_hists
 Map storing upper end of lumi page (or lumiblock if depth==1) with the corresponding histogram definition and pointer of currently active histograms. More...
 
std::mutex m_mutex
 ! mutex for the map More...
 

Static Private Attributes

static const unsigned s_deregDelay {5}
 Number of lumiblocks before histogram gets deregistered/deleted. More...
 

Detailed Description

Implementation of IHistogramProvider for lumi block based histograms.

This provider produces histograms that groups data based on current lumi block and defined history depth. Note: kLBNHistoryDepth must be defined in histogram definition options

Definition at line 25 of file LumiblockHistogramProvider.h.

Constructor & Destructor Documentation

◆ LumiblockHistogramProvider()

Monitored::LumiblockHistogramProvider::LumiblockHistogramProvider ( GenericMonitoringTool *const  gmTool,
std::shared_ptr< HistogramFactory factory,
const HistogramDef histDef 
)
inline

Constructor.

Parameters
gmToolSource of the lumi block info
factoryROOT object factory
defGeneral definition of a histogram

Definition at line 34 of file LumiblockHistogramProvider.h.

37  : IHistogramProvider()
38  , m_gmTool(gmTool)
39  , m_factory(factory)
40  , m_histDef(histDef)
41  {}

Member Function Documentation

◆ histogram()

TNamed* Monitored::LumiblockHistogramProvider::histogram ( )
inlineoverridevirtual

Getter of ROOT object.

Return the histogram for the current lumiblock. Create a new one if needed. A configurable number of histograms is kept active at a given time.

Returns
ROOT object

Implements Monitored::IHistogramProvider.

Definition at line 51 of file LumiblockHistogramProvider.h.

51  {
52 
53  const unsigned lumiBlock = m_gmTool->lumiBlock();
54  std::scoped_lock lock(m_mutex); // access to m_hists
55 
56  /* Find existing histogram. In the unlikely case of a very old lumiblock
57  being processed, it would be filled into the oldest histogram. */
58  const auto it = m_hists.lower_bound(lumiBlock);
59  if (it!=m_hists.end() && it->second.second!=nullptr) {
60  return it->second.second;
61  }
62 
63  if (m_histDef.kLBNHistoryDepth <= 0) {
64  throw HistogramException("Histogram >"+ m_histDef.path + "< has invalid kLBNHistoryDepth.");
65  }
66 
67  const int historyDepth = m_histDef.kLBNHistoryDepth;
68  const unsigned lumiPage = lumiBlock/historyDepth;
69 
70  // Helpers to calculate min/max lumiblock for a given "page" (histogram)
71  auto minLumiBlock = [=](unsigned lumiPage) { return lumiPage * historyDepth; };
72  auto maxLumiBlock = [=](unsigned lumiPage) { return (lumiPage+1) * historyDepth - 1; };
73 
74  // create new histogram definition with updated alias
75  HistogramDef def = m_histDef;
76  def.alias += "_LB" + std::to_string(minLumiBlock(lumiPage));
77  if (historyDepth > 1) {
78  def.alias += "_" + std::to_string(maxLumiBlock(lumiPage));
79  }
80 
81  TNamed* hist = m_factory->create(def);
82  m_hists.emplace(maxLumiBlock(lumiPage), std::make_pair(std::move(def), hist));
83 
84  // deregister old histograms
85  for (auto it = m_hists.begin(); it!=m_hists.end();) {
86  const unsigned maxLB = it->first;
87  if (maxLB + s_deregDelay <= lumiBlock) {
88  m_factory->remove(it->second.first);
89  it = m_hists.erase(it); // this advances iterator by one
90  }
91  else break; // don't need to search further as std::map is sorted
92  }
93 
94  return hist;
95  }

Member Data Documentation

◆ m_factory

std::shared_ptr<HistogramFactory> Monitored::LumiblockHistogramProvider::m_factory
private

Definition at line 99 of file LumiblockHistogramProvider.h.

◆ m_gmTool

GenericMonitoringTool* const Monitored::LumiblockHistogramProvider::m_gmTool
private

Definition at line 98 of file LumiblockHistogramProvider.h.

◆ m_histDef

const HistogramDef Monitored::LumiblockHistogramProvider::m_histDef
private

Definition at line 100 of file LumiblockHistogramProvider.h.

◆ m_hists

std::map<unsigned, std::pair<HistogramDef, TNamed*> > Monitored::LumiblockHistogramProvider::m_hists
private

Map storing upper end of lumi page (or lumiblock if depth==1) with the corresponding histogram definition and pointer of currently active histograms.

Note: map is sorted by key (lumiblock)

Definition at line 117 of file LumiblockHistogramProvider.h.

◆ m_mutex

std::mutex Monitored::LumiblockHistogramProvider::m_mutex
private

! mutex for the map

Definition at line 118 of file LumiblockHistogramProvider.h.

◆ s_deregDelay

const unsigned Monitored::LumiblockHistogramProvider::s_deregDelay {5}
staticprivate

Number of lumiblocks before histogram gets deregistered/deleted.

This number needs to be set large enough for each histogram to be at least published once in the online. E.g. with a publication interval of 80 seconds, it needs to be at least 2 (see ADHI-4905).

Definition at line 108 of file LumiblockHistogramProvider.h.


The documentation for this class was generated from the following file:
Monitored::LumiblockHistogramProvider::m_histDef
const HistogramDef m_histDef
Definition: LumiblockHistogramProvider.h:100
Monitored::LumiblockHistogramProvider::m_mutex
std::mutex m_mutex
! mutex for the map
Definition: LumiblockHistogramProvider.h:118
plotmaker.hist
hist
Definition: plotmaker.py:148
Monitored::LumiblockHistogramProvider::m_hists
std::map< unsigned, std::pair< HistogramDef, TNamed * > > m_hists
Map storing upper end of lumi page (or lumiblock if depth==1) with the corresponding histogram defini...
Definition: LumiblockHistogramProvider.h:117
GenericMonitoringTool::lumiBlock
virtual uint32_t lumiBlock()
Definition: GenericMonitoringTool.cxx:286
skel.it
it
Definition: skel.GENtoEVGEN.py:424
Monitored::LumiblockHistogramProvider::s_deregDelay
static const unsigned s_deregDelay
Number of lumiblocks before histogram gets deregistered/deleted.
Definition: LumiblockHistogramProvider.h:108
Monitored::HistogramDef::path
std::string path
booking path
Definition: HistogramDef.h:19
Monitored::HistogramDef::alias
std::string alias
unique alias for THistSvc
Definition: HistogramDef.h:17
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
Monitored::LumiblockHistogramProvider::m_gmTool
GenericMonitoringTool *const m_gmTool
Definition: LumiblockHistogramProvider.h:98
Monitored::LumiblockHistogramProvider::m_factory
std::shared_ptr< HistogramFactory > m_factory
Definition: LumiblockHistogramProvider.h:99
Monitored::HistogramDef::kLBNHistoryDepth
int kLBNHistoryDepth
length of lb history
Definition: HistogramDef.h:44
xAOD::lumiBlock
setTeId lumiBlock
Definition: L2StandAloneMuon_v1.cxx:327