The Gaudi Framework  v38r3 (c3fc9673)
RootHistogramSink.cpp
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2023 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 
14 #include <GaudiKernel/Service.h>
15 #include <TH1D.h>
16 #include <TH2D.h>
17 #include <TH3D.h>
18 #include <TProfile.h>
19 #include <TProfile2D.h>
20 #include <TProfile3D.h>
21 
23 
24  namespace {
25  using namespace std::string_literals;
26  Base::HistoBinRegistry const binRegistry = {
28  &saveProfileHisto<1, Accumulators::atomicity::full, double> },
30  &saveProfileHisto<1, Accumulators::atomicity::none, double> },
32  &saveProfileHisto<1, Accumulators::atomicity::full, float> },
34  &saveProfileHisto<1, Accumulators::atomicity::none, float> },
36  &saveProfileHisto<2, Accumulators::atomicity::full, double> },
38  &saveProfileHisto<2, Accumulators::atomicity::none, double> },
40  &saveProfileHisto<2, Accumulators::atomicity::full, float> },
42  &saveProfileHisto<2, Accumulators::atomicity::none, float> },
44  &saveProfileHisto<3, Accumulators::atomicity::full, double> },
46  &saveProfileHisto<3, Accumulators::atomicity::none, double> },
48  &saveProfileHisto<3, Accumulators::atomicity::full, float> },
50  &saveProfileHisto<3, Accumulators::atomicity::none, float> },
51  };
53  { { "histogram:Histogram"s, 1 }, &saveRootHisto<1, false, TH1D> },
54  { { "histogram:WeightedHistogram"s, 1 }, &saveRootHisto<1, false, TH1D> },
55  { { "histogram:Histogram"s, 2 }, &saveRootHisto<2, false, TH2D> },
56  { { "histogram:WeightedHistogram"s, 2 }, &saveRootHisto<2, false, TH2D> },
57  { { "histogram:Histogram"s, 3 }, &saveRootHisto<3, false, TH3D> },
58  { { "histogram:WeightedHistogram"s, 3 }, &saveRootHisto<3, false, TH3D> },
59  { { "histogram:ProfileHistogram"s, 1 }, &saveRootHisto<1, true, TProfile> },
60  { { "histogram:WeightedProfileHistogram"s, 1 }, &saveRootHisto<1, true, TProfile> },
61  { { "histogram:ProfileHistogram"s, 2 }, &saveRootHisto<2, true, TProfile2D> },
62  { { "histogram:WeightedProfileHistogram"s, 2 }, &saveRootHisto<2, true, TProfile2D> },
63  { { "histogram:ProfileHistogram"s, 3 }, &saveRootHisto<3, true, TProfile3D> },
64  { { "histogram:WeightedProfileHistogram"s, 3 }, &saveRootHisto<3, true, TProfile3D> } };
65  } // namespace
66 
67  struct Root : Base {
68  using Base::Base;
69 
70  StatusCode initialize() override {
71  return Base::initialize().andThen( [&] {
72  for ( auto& [id, func] : binRegistry ) { registerHandler( id, func ); }
73  for ( auto& [id, func] : registry ) { registerHandler( id, func ); }
74  } );
75  }
76  };
77 
78  DECLARE_COMPONENT( Root )
79 
80 } // namespace Gaudi::Histograming::Sink
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
std::type_index
Gaudi::Histograming::Sink::Base::initialize
StatusCode initialize() override
Definition: Base.h:45
Utils.h
GaudiPluginService.cpluginsvc.registry
def registry()
Definition: cpluginsvc.py:83
StatusCode
Definition: StatusCode.h:65
Gaudi::Histograming::Sink::Base::registerHandler
void registerHandler(HistoBinIdentification const &id, HistoBinHandler const &func)
Definition: Base.h:83
GaudiPluginService.cpluginsvc.func
func
Definition: cpluginsvc.py:235
Gaudi::Histograming::Sink
Definition: RootHistogramSink.cpp:22
Gaudi::Histograming::Sink::Root
Definition: RootHistogramSink.cpp:67
Base.h
std::map< HistoBinIdentification, HistoBinHandler >
Service.h
Gaudi::Histograming::Sink::Base::Base
Base(std::string name, ISvcLocator *svcloc)
Definition: Base.h:39
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition: PluginServiceV1.h:46
Gaudi::Histograming::Sink::Base
Definition: Base.h:28
Gaudi::Accumulators::HistogramingCounterBaseInternal
A base counter dealing with Histograms.
Definition: Histogram.h:464
Gaudi::Histograming::Sink::Root::initialize
StatusCode initialize() override
Definition: RootHistogramSink.cpp:70