Juggler
Juggling algorithms and event processing using gaudi framework
Helpers.hpp
Go to the documentation of this file.
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2019 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #pragma once
10 
11 #include <string>
12 
13 #include "TEfficiency.h"
14 #include "TFitResult.h"
15 #include "TFitResultPtr.h"
16 #include "TH1F.h"
17 #include "TH2F.h"
18 #include "TProfile.h"
19 #include "TROOT.h"
20 
21 namespace Jug {
22 
23 namespace PlotHelpers {
24 /// @brief Nested binning struct for booking plots
25 struct Binning {
26  Binning(){};
27 
28  Binning(std::string bTitle, int bins, float bMin, float bMax)
29  : title(bTitle), nBins(bins), min(bMin), max(bMax){};
30 
31  std::string title; ///< title to be displayed
32  int nBins; ///< number of bins
33  float min; ///< minimum value
34  float max; ///< maximum value
35 };
36 
37 /// @brief book a 1D histogram
38 /// @param histName the name of histogram
39 /// @param histTitle the title of histogram
40 /// @param varBinning the binning info of variable
41 /// @return histogram pointer
42 TH1F* bookHisto(const char* histName, const char* histTitle,
43  const Binning& varBinning);
44 
45 /// @brief book a 2D histogram
46 /// @param histName the name of histogram
47 /// @param histTitle the title of histogram
48 /// @param varXBinning the binning info of variable at x axis
49 /// @param varYBinning the binning info of variable at y axis
50 /// @return histogram pointer
51 TH2F* bookHisto(const char* histName, const char* histTitle,
52  const Binning& varXBinning, const Binning& varYBinning);
53 
54 /// @brief fill a 1D histogram
55 /// @param hist histogram to fill
56 /// @param value value to fill
57 /// @param weight weight to fill
58 void fillHisto(TH1F* hist, float value, float weight = 1.0);
59 
60 /// @brief fill a 2D histogram
61 /// @param hist histogram to fill
62 /// @param xValue x value to fill
63 /// @param yValue y value to fill
64 /// @param weight weight to fill
65 void fillHisto(TH2F* hist, float xValue, float yValue, float weight = 1.0);
66 
67 /// @brief extract details, i.e. mean and width of a 1D histogram and fill
68 /// them into histograms
69 /// @param inputHist histogram to investigate
70 /// @param j which bin number of meanHist and widthHist to fill
71 /// @param meanHist histogram to fill the mean value of inputHist
72 /// @param widthHist histogram to fill the width value of inputHist
73 ///
74 /// @todo write specialized helper class to extract details of hists
75 void anaHisto(TH1D* inputHist, int j, TH1F* meanHist, TH1F* widthHist);
76 
77 /// @brief book a 1D efficiency plot
78 /// @param effName the name of plot
79 /// @param effTitle the title of plot
80 /// @param varBinning the binning info of variable
81 /// @return TEfficiency pointer
82 TEfficiency* bookEff(const char* effName, const char* effTitle,
83  const Binning& varBinning);
84 
85 /// @brief book a 2D efficiency plot
86 /// @param effName the name of plot
87 /// @param effTitle the title of plot
88 /// @param varXBinning the binning info of variable at x axis
89 /// @param varYBinning the binning info of variable at y axis
90 /// @return TEfficiency pointer
91 TEfficiency* bookEff(const char* effName, const char* effTitle,
92  const Binning& varXBinning, const Binning& varYBinning);
93 
94 /// @brief fill a 1D efficiency plot
95 /// @param efficiency plot to fill
96 /// @param value value to fill
97 /// @param status bool to denote passed or not
98 void fillEff(TEfficiency* efficiency, float value, bool status);
99 
100 /// @brief fill a 2D efficiency plot
101 /// @param efficiency plot to fill
102 /// @param xValue x value to fill
103 /// @param yValue y value to fill
104 /// @param status bool to denote passed or not
105 void fillEff(TEfficiency* efficiency, float xValue, float yValue, bool status);
106 
107 /// @brief book a TProfile plot
108 /// @param profName the name of plot
109 /// @param profTitle the title of plot
110 /// @param varXBinning the binning info of variable at x axis
111 /// @param varYBinning the binning info of variable at y axis
112 /// @return TProfile pointer
113 TProfile* bookProf(const char* profName, const char* profTitle,
114  const Binning& varXBinning, const Binning& varYBinning);
115 
116 /// @brief fill a TProfile plot
117 /// @param profile plot to fill
118 /// @param xValue xvalue to fill
119 /// @param yValue yvalue to fill
120 /// @param weight weight to fill
121 void fillProf(TProfile* profile, float xValue, float yValue,
122  float weight = 1.0);
123 
124 } // namespace PlotHelpers
125 
126 } // namespace Jug
Jug::PlotHelpers::Binning::max
float max
maximum value
Definition: Helpers.hpp:34
Jug::PlotHelpers::Binning::Binning
Binning()
Definition: Helpers.hpp:26
Jug::PlotHelpers::Binning::min
float min
minimum value
Definition: Helpers.hpp:33
Jug::PlotHelpers::bookProf
TProfile * bookProf(const char *profName, const char *profTitle, const Binning &varXBinning, const Binning &varYBinning)
book a TProfile plot
Definition: Helpers.cpp:86
Jug::PlotHelpers::bookHisto
TH1F * bookHisto(const char *histName, const char *histTitle, const Binning &varBinning)
book a 1D histogram
Definition: Helpers.cpp:14
Jug::PlotHelpers::Binning::Binning
Binning(std::string bTitle, int bins, float bMin, float bMax)
Definition: Helpers.hpp:28
Jug::PlotHelpers::fillHisto
void fillHisto(TH1F *hist, float value, float weight=1.0)
fill a 1D histogram
Definition: Helpers.cpp:35
Jug::PlotHelpers::Binning::title
std::string title
title to be displayed
Definition: Helpers.hpp:29
Jug::PlotHelpers::bookEff
TEfficiency * bookEff(const char *effName, const char *effTitle, const Binning &varBinning)
book a 1D efficiency plot
Definition: Helpers.cpp:61
Jug::PlotHelpers::anaHisto
void anaHisto(TH1D *inputHist, int j, TH1F *meanHist, TH1F *widthHist)
extract details, i.e. mean and width of a 1D histogram and fill them into histograms
Definition: Helpers.cpp:45
Jug::PlotHelpers::Binning::nBins
int nBins
number of bins
Definition: Helpers.hpp:32
Jug::PlotHelpers::fillProf
void fillProf(TProfile *profile, float xValue, float yValue, float weight=1.0)
fill a TProfile plot
Definition: Helpers.cpp:96
Jug::PlotHelpers::Binning
Nested binning struct for booking plots.
Definition: Helpers.hpp:25
Jug
Definition: DD4hepBField.h:22
Jug::PlotHelpers::fillEff
void fillEff(TEfficiency *efficiency, float value, bool status)
fill a 1D efficiency plot
Definition: Helpers.cpp:76