The Gaudi Framework  master (82fdf313)
Loading...
Searching...
No Matches
RootHistogramSink.cpp
Go to the documentation of this file.
1/***********************************************************************************\
2* (c) Copyright 1998-2024 CERN for the benefit of the LHCb and ATLAS collaborations *
3* *
4* This software is distributed under the terms of the Apache version 2 licence, *
5* copied verbatim in the file "LICENSE". *
6* *
7* In applying this licence, CERN does not waive the privileges and immunities *
8* granted to it by virtue of its status as an Intergovernmental Organization *
9* or submit itself to any jurisdiction. *
10\***********************************************************************************/
11
15#include <GaudiKernel/Service.h>
16#include <TH1D.h>
17#include <TH2D.h>
18#include <TH3D.h>
19#include <TProfile.h>
20#include <TProfile2D.h>
21#include <TProfile3D.h>
22
24
25 namespace {
26 using namespace std::string_literals;
27 Base::HistoBinRegistry const binRegistry = {
52 };
53 Base::HistoRegistry const registry = {
54 { { "histogram:Histogram"s, 1 }, &saveRootHisto<1, false, TH1D> },
55 { { "histogram:WeightedHistogram"s, 1 }, &saveRootHisto<1, false, TH1D> },
56 { { "histogram:Histogram"s, 2 }, &saveRootHisto<2, false, TH2D> },
57 { { "histogram:WeightedHistogram"s, 2 }, &saveRootHisto<2, false, TH2D> },
58 { { "histogram:Histogram"s, 3 }, &saveRootHisto<3, false, TH3D> },
59 { { "histogram:WeightedHistogram"s, 3 }, &saveRootHisto<3, false, TH3D> },
60 { { "histogram:ProfileHistogram"s, 1 }, &saveRootHisto<1, true, TProfile> },
61 { { "histogram:WeightedProfileHistogram"s, 1 }, &saveRootHisto<1, true, TProfile> },
62 { { "histogram:ProfileHistogram"s, 2 }, &saveRootHisto<2, true, TProfile2D> },
63 { { "histogram:WeightedProfileHistogram"s, 2 }, &saveRootHisto<2, true, TProfile2D> },
64 { { "histogram:ProfileHistogram"s, 3 }, &saveRootHisto<3, true, TProfile3D> },
65 { { "histogram:WeightedProfileHistogram"s, 3 }, &saveRootHisto<3, true, TProfile3D> } };
66 } // namespace
67
68 struct Root : Base {
69 using Base::Base;
70
72 return Base::initialize().andThen( [&] {
73 for ( auto& [id, func] : binRegistry ) { registerHandler( id, func ); }
74 for ( auto& [id, func] : registry ) { registerHandler( id, func ); }
75 } );
76 }
77 };
78
79 DECLARE_COMPONENT( Root )
80
81} // namespace Gaudi::Histograming::Sink
#define DECLARE_COMPONENT(type)
Base(const std::string &name, ISvcLocator *svcloc)
Definition Base.h:43
std::map< HistoBinIdentification, HistoBinHandler > HistoBinRegistry
Definition Base.h:41
StatusCode initialize() override
Definition Base.h:49
void registerHandler(HistoBinIdentification const &id, HistoBinHandler const &func)
Definition Base.h:99
std::map< HistoIdentification, HistoHandler > HistoRegistry
Definition Base.h:36
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64
StatusCode andThen(F &&f, ARGS &&... args) const
Chain code blocks making the execution conditional a success result.
Definition StatusCode.h:163
HistogramingCounterBase< ND, Atomicity, Arithmetic, naming::profilehistogramString, ProfileHistogramingAccumulator, AxisTupleType > StaticProfileHistogram
profile static histograming counter. See HistogramingCounterBase for details
void saveProfileHisto(TFile &file, std::string dir, std::string name, Monitoring::Hub::Entity const &ent)
Definition Utils.h:588
void saveRootHisto(TFile &file, std::string dir, std::string name, nlohmann::json const &j)
generic method to save histograms to files, based on Traits
Definition Utils.h:459
Base(const std::string &name, ISvcLocator *svcloc)
Definition Base.h:43