The Gaudi Framework  master (da3d77e1)
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 = {
29  &saveProfileHisto<1, Accumulators::atomicity::full, double> },
31  &saveProfileHisto<1, Accumulators::atomicity::none, double> },
33  &saveProfileHisto<1, Accumulators::atomicity::full, float> },
35  &saveProfileHisto<1, Accumulators::atomicity::none, float> },
37  &saveProfileHisto<2, Accumulators::atomicity::full, double> },
39  &saveProfileHisto<2, Accumulators::atomicity::none, double> },
41  &saveProfileHisto<2, Accumulators::atomicity::full, float> },
43  &saveProfileHisto<2, Accumulators::atomicity::none, float> },
45  &saveProfileHisto<3, Accumulators::atomicity::full, double> },
47  &saveProfileHisto<3, Accumulators::atomicity::none, double> },
49  &saveProfileHisto<3, Accumulators::atomicity::full, float> },
51  &saveProfileHisto<3, Accumulators::atomicity::none, float> },
52  };
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 
71  StatusCode initialize() override {
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
cpluginsvc.registry
def registry()
Definition: cpluginsvc.py:83
StatusCode::andThen
StatusCode andThen(F &&f, ARGS &&... args) const
Chain code blocks making the execution conditional a success result.
Definition: StatusCode.h:163
gaudirun.s
string s
Definition: gaudirun.py:346
Gaudi::Accumulators::HistogramingCounterBase
A base counter dealing with Histograms.
Definition: StaticHistogram.h:653
std::type_index
Gaudi::Histograming::Sink::Base::initialize
StatusCode initialize() override
Definition: Base.h:45
Utils.h
StatusCode
Definition: StatusCode.h:65
cpluginsvc.func
func
Definition: cpluginsvc.py:235
Gaudi::Histograming::Sink::Base::registerHandler
void registerHandler(HistoBinIdentification const &id, HistoBinHandler const &func)
Definition: Base.h:83
Gaudi::Histograming::Sink
Definition: RootHistogramSink.cpp:23
Gaudi::Histograming::Sink::Root
Definition: RootHistogramSink.cpp:68
Base.h
std::map< HistoBinIdentification, HistoBinHandler >
Service.h
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition: PluginServiceV1.h:46
Gaudi::Histograming::Sink::Base
Definition: Base.h:28
Gaudi::Histograming::Sink::Root::initialize
StatusCode initialize() override
Definition: RootHistogramSink.cpp:71
Gaudi::Histograming::Sink::Base::Base
Base(const std::string &name, ISvcLocator *svcloc)
Definition: Base.h:39
StaticHistogram.h