CbmRoot
Loading...
Searching...
No Matches
LmvmHist.h
Go to the documentation of this file.
1/* Copyright (C) 2012-2021 UGiessen, JINR-LIT
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Semen Lebedev [committer], Elena Lebedeva, Florian Uhlig */
4
5#ifndef LMVM_HIST_H
6#define LMVM_HIST_H
7
8#include "CbmHistManager.h"
9
10#include "TH1D.h"
11#include "TH2D.h"
12#include "TObject.h"
13
14#include <string>
15#include <vector>
16
17#include "LmvmDef.h"
18
19
20class LmvmHist {
21public:
22 LmvmHist();
23 virtual ~LmvmHist() { ; }
24
25 const static int fNofSrc = 5;
26 const static std::vector<ELmvmSrc> fSrcs;
27 const static std::vector<std::string> fSrcNames;
28 const static std::vector<std::string> fSrcLatex;
29 const static std::vector<int> fSrcColors;
30
31 const static int fNofAnaSteps = 12;
32 const static std::vector<ELmvmAnaStep> fAnaSteps;
33 const static std::vector<std::string> fAnaStepNames;
34 const static std::vector<std::string> fAnaStepLatex;
35 const static std::vector<int> fAnaStepColors;
36
37 static const int fNofSignals = 5;
38 const static std::vector<std::string> fSignalNames;
39 const static std::vector<ELmvmSignal> fSignals;
40
41 const static int fNofBgPairSrc = 6;
42 const static std::vector<std::string> fBgPairSrcNames;
43 const static std::vector<std::string> fBgPairSrcLatex;
44
45 const static int fNofGTrackNames = 15;
46 const static std::vector<std::string> fGTrackNames;
47 const static std::vector<std::string> fGTrackLatex;
48
49 const static int fNofCandNames = 10;
50 const static std::vector<std::string> fCandNames;
51 const static std::vector<std::string> fCandLatex;
52
54 std::vector<std::string> CombineNames(const std::string& name, const std::vector<std::string>& subNames);
55
56 std::vector<std::string> CombineNames(const std::string& name, const std::vector<std::string>& subNames1,
57 const std::vector<std::string>& subNames2);
58
59 // Probably one can move these many methods to main CbmHistManager class
60 void CreateH1(const std::string& name, const std::string& axisX, const std::string& axisY, double nBins, double min,
61 double max);
62
63 void CreateH2(const std::string& name, const std::string& axisX, const std::string& axisY, const std::string& axisZ,
64 double nBinsX, double minX, double maxX, double nBinsY, double minY, double maxY);
65
66 void CreateH1(const std::string& name, const std::vector<std::string>& subNames, const std::string& axisX,
67 const std::string& axisY, double nBins, double min, double max);
68
69 void CreateH2(const std::string& name, const std::vector<std::string>& subNames, const std::string& axisX,
70 const std::string& axisY, const std::string& axisZ, double nBinsX, double minX, double maxX,
71 double nBinsY, double minY, double maxY);
72
73 void CreateH1(const std::string& name, const std::vector<std::string>& subNames1,
74 const std::vector<std::string>& subNames2, const std::string& axisX, const std::string& axisY,
75 double nBins, double min, double max);
76
77 void CreateH2(const std::string& name, const std::vector<std::string>& subNames1,
78 const std::vector<std::string>& subNames2, const std::string& axisX, const std::string& axisY,
79 const std::string& axisZ, double nBinsX, double minX, double maxX, double nBinsY, double minY,
80 double maxY);
81
82
83 template<typename T>
84 T* CreateHByClone(const std::string& name, const std::string& newName)
85 {
86 T* hNew = static_cast<T*>(fHM.GetObject(name)->Clone());
87 hNew->SetNameTitle(newName.c_str(), newName.c_str());
88 fHM.Add(newName, hNew);
89 return hNew;
90 }
91
92 template<typename T>
93 T* CreateHByClone(const std::string& name, const std::string& newName, ELmvmAnaStep step)
94 {
95 return CreateHByClone<T>(GetName(name, step), GetName(newName, step));
96 }
97
98 void FillH1(const std::string& name, double x, double w = 1.);
99 void FillH2(const std::string& name, double x, double y, double w = 1.);
100 void FillH1(const std::string& name, ELmvmAnaStep step, double x, double w = 1.);
101 void FillH2(const std::string& name, ELmvmAnaStep step, double x, double y, double w = 1.);
102 void FillH1(const std::string& name, ELmvmSrc src, double x, double wSignal);
103 void FillH2(const std::string& name, ELmvmSrc src, double x, double y, double wSignal);
104 void FillH1(const std::string& name, ELmvmSrc src, ELmvmAnaStep step, double x, double wSignal);
105 void FillH2(const std::string& name, ELmvmSrc src, ELmvmAnaStep step, double x, double y, double wSignal);
106
107 TNamed* GetObject(const std::string& name) { return fHM.GetObject(name); }
108
109 TH1D* H1(const std::string& name) { return static_cast<TH1D*>(fHM.H1(name)); }
110 TH2D* H2(const std::string& name) { return static_cast<TH2D*>(fHM.H2(name)); }
111 TH1D* H1(const std::string& name, ELmvmAnaStep step) { return H1(GetName(name, step)); }
112 TH2D* H2(const std::string& name, ELmvmAnaStep step) { return H2(GetName(name, step)); }
113 TH1D* H1(const std::string& name, ELmvmSrc src) { return H1(GetName(name, src)); }
114 TH2D* H2(const std::string& name, ELmvmSrc src) { return H2(GetName(name, src)); }
115 TH1D* H1(const std::string& name, ELmvmSrc src, ELmvmAnaStep step) { return H1(GetName(name, src, step)); }
116 TH2D* H2(const std::string& name, ELmvmSrc src, ELmvmAnaStep step) { return H2(GetName(name, src, step)); }
117
118 TH1D* H1Clone(const std::string& name) { return static_cast<TH1D*>(H1(name)->Clone()); }
119 TH2D* H2Clone(const std::string& name) { return static_cast<TH2D*>(H2(name)->Clone()); }
120 TH1D* H1Clone(const std::string& name, ELmvmAnaStep step) { return static_cast<TH1D*>(H1(name, step)->Clone()); }
121 TH2D* H2Clone(const std::string& name, ELmvmAnaStep step) { return static_cast<TH2D*>(H2(name, step)->Clone()); }
122 TH1D* H1Clone(const std::string& name, ELmvmSrc src) { return static_cast<TH1D*>(H1(name, src)->Clone()); }
123 TH2D* H2Clone(const std::string& name, ELmvmSrc src) { return static_cast<TH2D*>(H2(name, src)->Clone()); }
124 TH1D* H1Clone(const std::string& name, ELmvmSrc src, ELmvmAnaStep step)
125 {
126 return static_cast<TH1D*>(H1(name, src, step)->Clone());
127 }
128 TH2D* H2Clone(const std::string& name, ELmvmSrc src, ELmvmAnaStep step)
129 {
130 return static_cast<TH2D*>(H2(name, src, step)->Clone());
131 }
132
133 std::string GetName(const std::string& name, ELmvmAnaStep step);
134 std::string GetName(const std::string& name, ELmvmSrc src);
135 std::string GetName(const std::string& name, ELmvmSrc src, ELmvmAnaStep step);
136
137 void SetOptH1(TH1D* hist, TString xAxisTitle, TString yAxisTitle, Int_t Ndevision, Int_t style, Float_t size,
138 Int_t color, std::string opt = ""); // copied from Tetyanas macro
139 void SetOptCanvas(TCanvas* canvas);
140 void SetLegend(std::vector<LmvmLegend>, double textsize, double x1, double y1, double x2, double y2);
141
142 void Rebin(const std::string& name, int nGroup); // TODO: used?
143 void Rebin(const std::string& name, const std::vector<std::string>& subNames, int nGroup);
144 void Rebin(const std::string& name, const std::vector<std::string>& subNames1,
145 const std::vector<std::string>& subNames2, int nGroup);
146
147 TH1D* CreateSignificanceH1(TH1D* s, TH1D* bg, const std::string& name, const std::string& option);
148 TH2D* CreateSignificanceH2(TH2D* signal, TH2D* bg, const std::string& name, const std::string& title);
149
150 void DrawAll(int dim, const std::string& hFullname, const std::string& padText, std::vector<std::string> xLabel,
151 std::vector<std::string> yLabel, double min, double max);
152 void DrawAllGTracks(int dim, const std::string& cName, const std::string& hName, std::vector<std::string> xLabel,
153 std::vector<std::string> yLabel, double min, double max);
154 void DrawAllCands(int dim, const std::string& cName, const std::string& hName, std::vector<std::string> xLabel,
155 std::vector<std::string> yLabel, double min, double max);
156 void DrawAllCandsAndSteps(int dim, const std::string& cName, const std::string& hName,
157 std::vector<std::string> xLabel, std::vector<std::string> yLabel, double min, double max);
158
159 void WriteToFile();
160
161 void DrawEfficiency(TH1* h1, TH1* h2, double xPos, double yPos);
162
163 static void DrawAnaStepOnPad(ELmvmAnaStep step);
164
166
168};
169
170#endif
Histogram manager.
static constexpr size_t size()
Definition KfSimdPseudo.h:2
ELmvmSrc
Definition LmvmDef.h:23
ELmvmAnaStep
Definition LmvmDef.h:34
Histogram manager.
TH2 * H2(const std::string &name) const
Return pointer to TH2 histogram.
TNamed * GetObject(const std::string &name) const
void Add(const std::string &name, TNamed *object)
Add new named object to manager.
TH1 * H1(const std::string &name) const
Return pointer to TH1 histogram.
void FillH1(const std::string &name, ELmvmAnaStep step, double x, double w=1.)
void CreateH1(const std::string &name, const std::string &axisX, const std::string &axisY, double nBins, double min, double max)
static const std::vector< int > fAnaStepColors
Definition LmvmHist.h:37
static const std::vector< ELmvmSrc > fSrcs
Definition LmvmHist.h:23
static const std::vector< std::string > fCandNames
Definition LmvmHist.h:57
static const std::vector< std::string > fAnaStepLatex
Definition LmvmHist.h:35
std::vector< std::string > CombineNames(const std::string &name, const std::vector< std::string > &subNames1, const std::vector< std::string > &subNames2)
TH2D * H2Clone(const std::string &name, ELmvmSrc src, ELmvmAnaStep step)
Definition LmvmHist.h:128
void DrawEfficiency(TH1 *h1, TH1 *h2, double xPos, double yPos)
Definition LmvmHist.cxx:479
TH1D * CreateSignificanceH1(TH1D *s, TH1D *bg, const std::string &name, const std::string &option)
Definition LmvmHist.cxx:325
void FillH1(const std::string &name, double x, double w=1.)
void DrawAllGTracks(int dim, const std::string &cName, const std::string &hName, std::vector< std::string > xLabel, std::vector< std::string > yLabel, double min, double max)
Definition LmvmHist.cxx:391
void FillH2(const std::string &name, ELmvmSrc src, double x, double y, double wSignal)
CbmHistManager fHM
Definition LmvmHist.h:165
void DrawAllCands(int dim, const std::string &cName, const std::string &hName, std::vector< std::string > xLabel, std::vector< std::string > yLabel, double min, double max)
Definition LmvmHist.cxx:404
TH2D * H2Clone(const std::string &name)
Definition LmvmHist.h:119
TH2D * H2(const std::string &name)
Definition LmvmHist.h:110
TH2D * H2(const std::string &name, ELmvmSrc src, ELmvmAnaStep step)
Definition LmvmHist.h:116
void SetOptH1(TH1D *hist, TString xAxisTitle, TString yAxisTitle, Int_t Ndevision, Int_t style, Float_t size, Int_t color, std::string opt="")
Definition LmvmHist.cxx:218
void DrawAll(int dim, const std::string &hFullname, const std::string &padText, std::vector< std::string > xLabel, std::vector< std::string > yLabel, double min, double max)
Definition LmvmHist.cxx:443
static const int fNofSignals
Definition LmvmHist.h:37
TH2D * H2Clone(const std::string &name, ELmvmSrc src)
Definition LmvmHist.h:123
static const std::vector< int > fSrcColors
Definition LmvmHist.h:27
static const int fNofGTrackNames
Definition LmvmHist.h:45
void CreateH2(const std::string &name, const std::vector< std::string > &subNames1, const std::vector< std::string > &subNames2, const std::string &axisX, const std::string &axisY, const std::string &axisZ, double nBinsX, double minX, double maxX, double nBinsY, double minY, double maxY)
static const std::vector< std::string > fBgPairSrcNames
Definition LmvmHist.h:45
static const std::vector< ELmvmSignal > fSignals
Definition LmvmHist.h:42
TH1D * H1Clone(const std::string &name, ELmvmSrc src)
Definition LmvmHist.h:122
std::vector< std::string > CombineNames(const std::string &name, const std::vector< std::string > &subNames)
void DrawAllCandsAndSteps(int dim, const std::string &cName, const std::string &hName, std::vector< std::string > xLabel, std::vector< std::string > yLabel, double min, double max)
Definition LmvmHist.cxx:417
void SetOptCanvas(TCanvas *canvas)
Definition LmvmHist.cxx:262
void CreateH2(const std::string &name, const std::string &axisX, const std::string &axisY, const std::string &axisZ, double nBinsX, double minX, double maxX, double nBinsY, double minY, double maxY)
static const int fNofBgPairSrc
Definition LmvmHist.h:41
void FillH2(const std::string &name, ELmvmAnaStep step, double x, double y, double w=1.)
static const std::vector< std::string > fSrcNames
Definition LmvmHist.h:25
static const std::vector< std::string > fCandLatex
Definition LmvmHist.h:59
TH2D * H2Clone(const std::string &name, ELmvmAnaStep step)
Definition LmvmHist.h:121
TH1D * H1(const std::string &name, ELmvmAnaStep step)
Definition LmvmHist.h:111
virtual ~LmvmHist()
Definition LmvmHist.h:23
std::string GetName(const std::string &name, ELmvmAnaStep step)
void FillH1(const std::string &name, ELmvmSrc src, ELmvmAnaStep step, double x, double wSignal)
ClassDef(LmvmHist, 1)
void FillH2(const std::string &name, double x, double y, double w=1.)
TH1D * H1(const std::string &name, ELmvmSrc src)
Definition LmvmHist.h:113
TH2D * H2(const std::string &name, ELmvmAnaStep step)
Definition LmvmHist.h:112
TH1D * H1Clone(const std::string &name, ELmvmAnaStep step)
Definition LmvmHist.h:120
static const std::vector< std::string > fGTrackNames
Definition LmvmHist.h:50
TH1D * H1(const std::string &name, ELmvmSrc src, ELmvmAnaStep step)
Definition LmvmHist.h:115
static const std::vector< std::string > fSrcLatex
Definition LmvmHist.h:26
void Rebin(const std::string &name, const std::vector< std::string > &subNames1, const std::vector< std::string > &subNames2, int nGroup)
void Rebin(const std::string &name, int nGroup)
TH2D * CreateSignificanceH2(TH2D *signal, TH2D *bg, const std::string &name, const std::string &title)
Definition LmvmHist.cxx:354
static const std::vector< std::string > fGTrackLatex
Definition LmvmHist.h:53
static const std::vector< ELmvmAnaStep > fAnaSteps
Definition LmvmHist.h:29
static const int fNofCandNames
Definition LmvmHist.h:49
void FillH1(const std::string &name, ELmvmSrc src, double x, double wSignal)
std::string GetName(const std::string &name, ELmvmSrc src)
TH2D * H2(const std::string &name, ELmvmSrc src)
Definition LmvmHist.h:114
static const std::vector< std::string > fSignalNames
Definition LmvmHist.h:41
void CreateH1(const std::string &name, const std::vector< std::string > &subNames, const std::string &axisX, const std::string &axisY, double nBins, double min, double max)
void Rebin(const std::string &name, const std::vector< std::string > &subNames, int nGroup)
static const int fNofSrc
Definition LmvmHist.h:25
static const int fNofAnaSteps
Definition LmvmHist.h:31
T * CreateHByClone(const std::string &name, const std::string &newName)
Definition LmvmHist.h:84
TH1D * H1Clone(const std::string &name)
Definition LmvmHist.h:118
TNamed * GetObject(const std::string &name)
Definition LmvmHist.h:107
TH1D * H1(const std::string &name)
Definition LmvmHist.h:109
std::string GetName(const std::string &name, ELmvmSrc src, ELmvmAnaStep step)
void CreateH1(const std::string &name, const std::vector< std::string > &subNames1, const std::vector< std::string > &subNames2, const std::string &axisX, const std::string &axisY, double nBins, double min, double max)
static const std::vector< std::string > fBgPairSrcLatex
Definition LmvmHist.h:46
T * CreateHByClone(const std::string &name, const std::string &newName, ELmvmAnaStep step)
Definition LmvmHist.h:93
static const std::vector< std::string > fAnaStepNames
Definition LmvmHist.h:33
void SetLegend(std::vector< LmvmLegend >, double textsize, double x1, double y1, double x2, double y2)
Definition LmvmHist.cxx:288
void FillH2(const std::string &name, ELmvmSrc src, ELmvmAnaStep step, double x, double y, double wSignal)
void WriteToFile()
Definition LmvmHist.cxx:477
void CreateH2(const std::string &name, const std::vector< std::string > &subNames, const std::string &axisX, const std::string &axisY, const std::string &axisZ, double nBinsX, double minX, double maxX, double nBinsY, double minY, double maxY)
static void DrawAnaStepOnPad(ELmvmAnaStep step)
Definition LmvmHist.cxx:488
TH1D * H1Clone(const std::string &name, ELmvmSrc src, ELmvmAnaStep step)
Definition LmvmHist.h:124