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, Cornelius Feier-Riesen */
4
5#ifndef LMVM_HIST_H
6#define LMVM_HIST_H
7
8#include "CbmHistManager.h"
9#include "LmvmDef.h"
10#include "TH1D.h"
11#include "TH2D.h"
12#include "TObject.h"
13
14#include <string>
15#include <vector>
16
17
18class LmvmHist {
19 public:
20 LmvmHist();
21 virtual ~LmvmHist() { ; }
22
23 double fRebinMinv = 1.; // Rebin for minv histograms
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 const static std::vector<ELmvmAnaStep> fAnaStepsFS; // steps that are used for Fast Simulations
37
38 static const int fNofSignals = 5;
39 const static std::vector<std::string> fSignalNames;
40 const static std::vector<ELmvmSignal> fSignals;
41
42 const static int fNofBgPairSrc = 6;
43 const static std::vector<std::string> fBgPairSrcNames;
44 const static std::vector<std::string> fBgPairSrcLatex;
45
46 const static int fNofGTrackNames = 15;
47 const static std::vector<std::string> fGTrackNames;
48 const static std::vector<std::string> fGTrackLatex;
49
50 const static int fNofCandNames = 10;
51 const static std::vector<std::string> fCandNames;
52 const static std::vector<std::string> fCandLatex;
53
54 const static std::vector<std::string> fFSCandNames;
55 const static std::vector<std::string> fFSCandLatex;
56
57
58 std::vector<std::string> CombineNames(const std::string& name, const std::vector<std::string>& subNames);
59
60 std::vector<std::string> CombineNames(const std::string& name, const std::vector<std::string>& subNames1,
61 const std::vector<std::string>& subNames2);
63 // Probably one can move these many methods to main CbmHistManager class
64 void CreateH1(const std::string& name, const std::string& axisX, const std::string& axisY, double nBins, double min,
65 double max);
66
67 void CreateH1(const std::string& name, const std::string& axisX, const std::string& axisY, double nBins, double min,
68 double max, bool doSumw2);
69
70 void CreateH1(const std::string& name, const std::vector<std::string>& subNames, const std::string& axisX,
71 const std::string& axisY, double nBins, double min, double max);
72
73 void CreateH1(const std::string& name, const std::vector<std::string>& subNames, const std::string& axisX,
74 const std::string& axisY, double nBins, double min, double max, bool doSumw2);
76 void CreateH1(const std::string& name, const std::vector<std::string>& subNames1,
77 const std::vector<std::string>& subNames2, const std::string& axisX, const std::string& axisY,
78 double nBins, double min, double max);
79
80 void CreateH1(const std::string& name, const std::vector<std::string>& subNames1,
81 const std::vector<std::string>& subNames2, const std::string& axisX, const std::string& axisY,
82 double nBins, double min, double max, bool doSumw2);
83
84 void CreateH2(const std::string& name, const std::string& axisX, const std::string& axisY, const std::string& axisZ,
85 double nBinsX, double minX, double maxX, double nBinsY, double minY, double maxY);
86
87 void CreateH2(const std::string& name, const std::vector<std::string>& subNames, const std::string& axisX,
88 const std::string& axisY, const std::string& axisZ, double nBinsX, double minX, double maxX,
89 double nBinsY, double minY, double maxY);
90
91 void CreateH2(const std::string& name, const std::vector<std::string>& subNames1,
92 const std::vector<std::string>& subNames2, const std::string& axisX, const std::string& axisY,
93 const std::string& axisZ, double nBinsX, double minX, double maxX, double nBinsY, double minY,
94 double maxY);
95
96
97 template<typename T>
98 T* CreateHByClone(const std::string& name, const std::string& newName)
99 {
100 T* hNew = static_cast<T*>(fHM.GetObject(name)->Clone());
101 hNew->SetNameTitle(newName.c_str(), newName.c_str());
102 fHM.Add(newName, hNew);
103 return hNew;
104 }
105
106 //template<typename T>
107 TH1D* CreateHByClone(TH1D* h, const std::string& newName)
108 {
109 TH1D* hNew = static_cast<TH1D*>(h->Clone());
110 hNew->SetNameTitle(newName.c_str(), newName.c_str());
111 fHM.Add(newName, hNew);
112 return hNew;
113 }
114
115 template<typename T>
116 T* CreateHByClone(const std::string& name, const std::string& newName, ELmvmAnaStep step)
117 {
118 return CreateHByClone<T>(GetName(name, step), GetName(newName, step));
119 }
120
121 void FillH1(const std::string& name, double x, double w = 1.);
122 void FillH2(const std::string& name, double x, double y, double w = 1.);
123 void FillH1(const std::string& name, ELmvmAnaStep step, double x, double w = 1.);
124 void FillH2(const std::string& name, ELmvmAnaStep step, double x, double y, double w = 1.);
125 void FillH1(const std::string& name, ELmvmSrc src, double x, double wSignal);
126 void FillH2(const std::string& name, ELmvmSrc src, double x, double y, double wSignal);
127 void FillH1(const std::string& name, ELmvmSrc src, ELmvmAnaStep step, double x, double wSignal);
128 void FillH2(const std::string& name, ELmvmSrc src, ELmvmAnaStep step, double x, double y, double wSignal);
129
130 TNamed* GetObject(const std::string& name) { return fHM.GetObject(name); }
131
132 TH1D* H1(const std::string& name) { return static_cast<TH1D*>(fHM.H1(name)); }
133 TH2D* H2(const std::string& name) { return static_cast<TH2D*>(fHM.H2(name)); }
134 TH1D* H1(const std::string& name, ELmvmAnaStep step) { return H1(GetName(name, step)); }
135 TH2D* H2(const std::string& name, ELmvmAnaStep step) { return H2(GetName(name, step)); }
136 TH1D* H1(const std::string& name, ELmvmSrc src) { return H1(GetName(name, src)); }
137 TH2D* H2(const std::string& name, ELmvmSrc src) { return H2(GetName(name, src)); }
138 TH1D* H1(const std::string& name, ELmvmSrc src, ELmvmAnaStep step) { return H1(GetName(name, src, step)); }
139 TH2D* H2(const std::string& name, ELmvmSrc src, ELmvmAnaStep step) { return H2(GetName(name, src, step)); }
140
141 TH1D* H1Clone(const std::string& name) { return static_cast<TH1D*>(H1(name)->Clone()); }
142 TH2D* H2Clone(const std::string& name) { return static_cast<TH2D*>(H2(name)->Clone()); }
143 TH1D* H1Clone(const std::string& name, ELmvmAnaStep step) { return static_cast<TH1D*>(H1(name, step)->Clone()); }
144 TH2D* H2Clone(const std::string& name, ELmvmAnaStep step) { return static_cast<TH2D*>(H2(name, step)->Clone()); }
145 TH1D* H1Clone(const std::string& name, ELmvmSrc src) { return static_cast<TH1D*>(H1(name, src)->Clone()); }
146 TH2D* H2Clone(const std::string& name, ELmvmSrc src) { return static_cast<TH2D*>(H2(name, src)->Clone()); }
147 TH1D* H1Clone(const std::string& name, ELmvmSrc src, ELmvmAnaStep step)
148 {
149 return static_cast<TH1D*>(H1(name, src, step)->Clone());
150 }
151 TH2D* H2Clone(const std::string& name, ELmvmSrc src, ELmvmAnaStep step)
152 {
153 return static_cast<TH2D*>(H2(name, src, step)->Clone());
154 }
155
156 std::string GetName(const std::string& name, ELmvmAnaStep step);
157 std::string GetName(const std::string& name, ELmvmSrc src);
158 std::string GetName(const std::string& name, ELmvmSrc src, ELmvmAnaStep step);
159
160 void SetOptH1(TH1D* hist, TString xAxisTitle, TString yAxisTitle, Int_t Ndevision, Int_t style, Float_t size,
161 Int_t color, std::string opt = "");
162 void SetOptCanvas(TCanvas* canvas);
163 void SetLegend(std::vector<LmvmLegend>, double textsize, double x1, double y1, double x2, double y2);
164 void DrawSimDataLabel(double xPos, double yPos);
165 void DrawSimDataLabel(double xPos, double yPos, double textSize);
166
167 void SetAnalysisStepAxis(TH1* hist);
168
169 void Rebin(const std::string& name, int nGroup); // TODO: used?
170 void Rebin(const std::string& name, const std::vector<std::string>& subNames, int nGroup);
171 void Rebin(const std::string& name, const std::vector<std::string>& subNames1,
172 const std::vector<std::string>& subNames2, int nGroup);
173
174 TH1D* CreateSignificanceH1(TH1D* s, TH1D* bg, const std::string& name, const std::string& option);
175 TH2D* CreateSignificanceH2(TH2D* signal, TH2D* bg, const std::string& name, const std::string& title);
176
177 void DrawAll(int dim, const std::string& hFullname, const std::string& padText, std::vector<std::string> xLabel,
178 std::vector<std::string> yLabel, bool logX, bool logY, double min, double max);
179 void DrawAllGTracks(int dim, const std::string& cName, const std::string& hName, std::vector<std::string> xLabel,
180 std::vector<std::string> yLabel, bool logX, bool logY, double min, double max);
181 void DrawAllCands(int dim, const std::string& cName, const std::string& hName, std::vector<std::string> xLabel,
182 std::vector<std::string> yLabel, bool logX, bool logY, double min, double max);
183 void DrawAllCandsAndSteps(int dim, const std::string& cName, const std::string& hName,
184 std::vector<std::string> xLabel, std::vector<std::string> yLabel, bool logX, bool logY,
185 double min, double max);
186 void DrawRatioElectronsOthers(const std::string& cName, const std::string& hName);
187 TH2D* GetRatioElectronsOthers(const std::string& hName, ELmvmAnaStep step);
188
189 void WriteToFile();
190
191 void DrawEfficiency(TH1* h1, TH1* h2, double xPos, double yPos);
192
193 static void DrawAnaStepOnPad(ELmvmAnaStep step);
194
196
198};
199
200#endif
Histogram manager.
friend fscal max(fscal x, fscal y)
friend fscal min(fscal x, fscal y)
static constexpr size_t size()
Definition KfSimdPseudo.h:2
ELmvmSrc
Definition LmvmDef.h:23
ELmvmAnaStep
Definition LmvmDef.h:34
float Float_t
int Int_t
Histogram manager.
Data class with information on a STS local track.
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:39
static const std::vector< ELmvmSrc > fSrcs
Definition LmvmHist.h:21
static const std::vector< std::string > fCandNames
Definition LmvmHist.h:60
static const std::vector< std::string > fAnaStepLatex
Definition LmvmHist.h:33
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, bool doSumw2)
double fRebinMinv
Definition LmvmHist.h:23
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:151
void DrawEfficiency(TH1 *h1, TH1 *h2, double xPos, double yPos)
Definition LmvmHist.cxx:585
void DrawSimDataLabel(double xPos, double yPos)
Definition LmvmHist.cxx:343
TH1D * CreateSignificanceH1(TH1D *s, TH1D *bg, const std::string &name, const std::string &option)
Definition LmvmHist.cxx:384
void FillH1(const std::string &name, double x, double w=1.)
TH2D * GetRatioElectronsOthers(const std::string &hName, ELmvmAnaStep step)
Definition LmvmHist.cxx:551
void CreateH1(const std::string &name, const std::string &axisX, const std::string &axisY, double nBins, double min, double max, bool doSumw2)
void FillH2(const std::string &name, ELmvmSrc src, double x, double y, double wSignal)
CbmHistManager fHM
Definition LmvmHist.h:195
TH2D * H2Clone(const std::string &name)
Definition LmvmHist.h:142
TH2D * H2(const std::string &name)
Definition LmvmHist.h:133
TH2D * H2(const std::string &name, ELmvmSrc src, ELmvmAnaStep step)
Definition LmvmHist.h:139
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:254
static const int fNofSignals
Definition LmvmHist.h:38
TH2D * H2Clone(const std::string &name, ELmvmSrc src)
Definition LmvmHist.h:146
static const std::vector< int > fSrcColors
Definition LmvmHist.h:25
static const int fNofGTrackNames
Definition LmvmHist.h:46
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:47
static const std::vector< ELmvmSignal > fSignals
Definition LmvmHist.h:44
TH1D * H1Clone(const std::string &name, ELmvmSrc src)
Definition LmvmHist.h:145
std::vector< std::string > CombineNames(const std::string &name, const std::vector< std::string > &subNames)
static const std::vector< std::string > fFSCandLatex
Definition LmvmHist.h:75
void SetOptCanvas(TCanvas *canvas)
Definition LmvmHist.cxx:298
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:42
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:23
static const std::vector< std::string > fCandLatex
Definition LmvmHist.h:62
TH2D * H2Clone(const std::string &name, ELmvmAnaStep step)
Definition LmvmHist.h:144
TH1D * CreateHByClone(TH1D *h, const std::string &newName)
Definition LmvmHist.h:107
TH1D * H1(const std::string &name, ELmvmAnaStep step)
Definition LmvmHist.h:134
static const std::vector< ELmvmAnaStep > fAnaStepsFS
Definition LmvmHist.h:36
virtual ~LmvmHist()
Definition LmvmHist.h:21
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.)
void DrawAll(int dim, const std::string &hFullname, const std::string &padText, std::vector< std::string > xLabel, std::vector< std::string > yLabel, bool logX, bool logY, double min, double max)
Definition LmvmHist.cxx:505
TH1D * H1(const std::string &name, ELmvmSrc src)
Definition LmvmHist.h:136
TH2D * H2(const std::string &name, ELmvmAnaStep step)
Definition LmvmHist.h:135
TH1D * H1Clone(const std::string &name, ELmvmAnaStep step)
Definition LmvmHist.h:143
static const std::vector< std::string > fGTrackNames
Definition LmvmHist.h:52
TH1D * H1(const std::string &name, ELmvmSrc src, ELmvmAnaStep step)
Definition LmvmHist.h:138
void DrawAllCandsAndSteps(int dim, const std::string &cName, const std::string &hName, std::vector< std::string > xLabel, std::vector< std::string > yLabel, bool logX, bool logY, double min, double max)
Definition LmvmHist.cxx:476
static const std::vector< std::string > fSrcLatex
Definition LmvmHist.h:24
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:413
static const std::vector< std::string > fGTrackLatex
Definition LmvmHist.h:55
static const std::vector< ELmvmAnaStep > fAnaSteps
Definition LmvmHist.h:27
static const int fNofCandNames
Definition LmvmHist.h:50
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:137
void DrawAllGTracks(int dim, const std::string &cName, const std::string &hName, std::vector< std::string > xLabel, std::vector< std::string > yLabel, bool logX, bool logY, double min, double max)
Definition LmvmHist.cxx:450
static const std::vector< std::string > fSignalNames
Definition LmvmHist.h:42
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 DrawAllCands(int dim, const std::string &cName, const std::string &hName, std::vector< std::string > xLabel, std::vector< std::string > yLabel, bool logX, bool logY, double min, double max)
Definition LmvmHist.cxx:463
void Rebin(const std::string &name, const std::vector< std::string > &subNames, int nGroup)
static const std::vector< std::string > fFSCandNames
Definition LmvmHist.h:73
static const int fNofSrc
Definition LmvmHist.h:25
static const int fNofAnaSteps
Definition LmvmHist.h:31
void SetAnalysisStepAxis(TH1 *hist)
Definition LmvmHist.cxx:354
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, bool doSumw2)
T * CreateHByClone(const std::string &name, const std::string &newName)
Definition LmvmHist.h:98
TH1D * H1Clone(const std::string &name)
Definition LmvmHist.h:141
TNamed * GetObject(const std::string &name)
Definition LmvmHist.h:130
TH1D * H1(const std::string &name)
Definition LmvmHist.h:132
void DrawRatioElectronsOthers(const std::string &cName, const std::string &hName)
Definition LmvmHist.cxx:567
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:48
T * CreateHByClone(const std::string &name, const std::string &newName, ELmvmAnaStep step)
Definition LmvmHist.h:116
static const std::vector< std::string > fAnaStepNames
Definition LmvmHist.h:31
void SetLegend(std::vector< LmvmLegend >, double textsize, double x1, double y1, double x2, double y2)
Definition LmvmHist.cxx:324
void FillH2(const std::string &name, ELmvmSrc src, ELmvmAnaStep step, double x, double y, double wSignal)
void WriteToFile()
Definition LmvmHist.cxx:583
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:594
TH1D * H1Clone(const std::string &name, ELmvmSrc src, ELmvmAnaStep step)
Definition LmvmHist.h:147