26const vector<std::string>
LmvmHist::fSrcLatex = {
"S",
"BG_{oth}",
"#pi^{0}",
"#gamma",
"#eta"};
34 "mvd1cut",
"mvd2cut",
"stcut",
"rtcut",
"ttcut",
"ptcut"};
36 "MC",
"ACC",
"REC",
"#chi^{2}_{prim}",
"ID",
"m_{#gamma}",
"mvd1",
"mvd2",
"ST",
"RT",
"TT",
"P_{t}"};
38 kRed, kPink - 6, kGreen, kOrange - 3,
39 kViolet + 10, kGreen - 3, kMagenta, kYellow + 1};
47 "#gamma-#pi^{0}",
"#gamma-o.",
"#pi^{0}-o."};
51 "el+",
"el+_prim",
"el-",
"el-_prim",
"pion+",
"pion+_prim",
"pion-",
"pion-_prim",
52 "proton",
"proton_prim",
"kaon+",
"kaon+_prim",
"kaon-",
"kaon-_prim",
"other"};
54 "e^{+}",
"e^{+}_{prim}",
"e^{-}",
"e^{-}_{prim}",
"#pi^{+}",
"#pi^{+}_{prim}",
"#pi^{-}",
"#pi^{-}_{prim}",
55 "p",
"p_{prim}",
"K^{+}",
"K^{+}_{prim}",
"K^{-}",
"K^{-}_{prim}",
"other"};
57const vector<std::string>
LmvmHist::fCandNames = {
"plutoEl+",
"plutoEl-",
"urqmdEl+",
"urqmdEl-",
"pion+",
58 "pion-",
"proton",
"kaon+",
"kaon-",
"other"};
75 vector<string> result;
76 for (
const auto& subName : subNames) {
77 result.push_back(name +
"_" + subName);
83 const vector<string>& subNames2)
85 vector<string> result;
86 for (
const auto& subName1 : subNames1) {
87 for (
const auto& subName2 : subNames2) {
88 result.push_back(name +
"_" + subName1 +
"_" + subName2);
94void LmvmHist::CreateH1(
const string& name,
const string& axisX,
const string& axisY,
double nBins,
double min,
97 string title = name +
";" + axisX +
";" + axisY;
101void LmvmHist::CreateH2(
const string& name,
const string& axisX,
const string& axisY,
const string& axisZ,
102 double nBinsX,
double minX,
double maxX,
double nBinsY,
double minY,
double maxY)
104 string title = name +
";" + axisX +
";" + axisY +
";" + axisZ;
105 fHM.
Create2<TH2D>(name, title, nBinsX, minX, maxX, nBinsY, minY, maxY);
109void LmvmHist::CreateH1(
const string& name,
const vector<string>& subNames,
const string& axisX,
const string& axisY,
110 double nBins,
double min,
double max)
113 for (
const auto& curName : names) {
114 string title = curName +
";" + axisX +
";" + axisY;
119void LmvmHist::CreateH2(
const string& name,
const vector<string>& subNames,
const string& axisX,
const string& axisY,
120 const string& axisZ,
double nBinsX,
double minX,
double maxX,
double nBinsY,
double minY,
124 for (
const auto& curName : names) {
125 string title = curName +
";" + axisX +
";" + axisY +
";" + axisZ;
126 fHM.
Create2<TH2D>(curName, title, nBinsX, minX, maxX, nBinsY, minY, maxY);
130void LmvmHist::CreateH1(
const string& name,
const vector<string>& subNames1,
const vector<string>& subNames2,
131 const string& axisX,
const string& axisY,
double nBins,
double min,
double max)
133 vector<string> names =
CombineNames(name, subNames1, subNames2);
134 for (
const auto& curName : names) {
135 string title = curName +
";" + axisX +
";" + axisY;
140void LmvmHist::CreateH2(
const string& name,
const vector<string>& subNames1,
const vector<string>& subNames2,
141 const string& axisX,
const string& axisY,
const string& axisZ,
double nBinsX,
double minX,
142 double maxX,
double nBinsY,
double minY,
double maxY)
144 vector<string> names =
CombineNames(name, subNames1, subNames2);
145 for (
const auto& curName : names) {
146 string title = curName +
";" + axisX +
";" + axisY +
";" + axisZ;
147 fHM.
Create2<TH2D>(curName, title, nBinsX, minX, maxX, nBinsY, minY, maxY);
160 H1(name, src)->Fill(
x, wSignal);
168 H2(name, src)->Fill(
x,
y, wSignal);
175 H2(name, step)->Fill(
x,
y, w);
198 LOG(error) <<
"LmvmHist::GetName step == ELmvmAnaStep::Undefined";
207 LOG(error) <<
"LmvmHist::GetName src == ELmvmSrc::Undefined";
210 return name +
"_" +
fSrcNames[
static_cast<int>(src)];
218void LmvmHist::SetOptH1(TH1D* hist, TString xAxisTitle =
" ", TString yAxisTitle =
" ", Int_t Ndevision = 510,
219 Int_t style = 1, Float_t
size = 2, Int_t color = 1,
string opt)
221 hist->GetXaxis()->SetTitle(xAxisTitle);
222 hist->GetYaxis()->SetTitle(yAxisTitle);
223 hist->GetXaxis()->SetTitleSize(0.05);
224 hist->GetYaxis()->SetTitleSize(0.05);
225 hist->GetXaxis()->SetTitleFont(42);
226 hist->GetYaxis()->SetTitleFont(42);
227 hist->GetXaxis()->SetNdivisions(Ndevision);
228 hist->GetYaxis()->SetTitleOffset(1.4);
229 hist->GetXaxis()->SetTitleOffset(1.);
232 hist->GetXaxis()->SetLabelFont(42);
233 hist->GetYaxis()->SetLabelFont(42);
234 hist->GetXaxis()->SetLabelSize(0.04);
235 hist->GetYaxis()->SetLabelSize(0.04);
236 if (opt ==
"marker") {
237 hist->SetMarkerStyle(style);
238 hist->SetMarkerSize(
size);
239 hist->SetMarkerColor(color);
240 hist->SetLineColor(color);
241 hist->SetLineWidth(2);
246 hist->GetXaxis()->SetLabelColor(1);
247 hist->GetYaxis()->SetLabelColor(1);
248 hist->GetXaxis()->SetTitleColor(1);
249 hist->GetYaxis()->SetTitleColor(1);
250 hist->SetFillColor(1);
252 else if (opt ==
"line") {
253 hist->SetLineStyle(style);
254 hist->SetLineColor(color);
256 hist->SetLineWidth(
size);
259 LOG(error) <<
"Option '" << opt <<
"' undefined. Choose 'marker' or 'line'." << std::endl;
264 gStyle->SetOptStat(0);
265 gStyle->SetEndErrorSize(5);
267 gStyle->SetLineStyleString(22,
"80 18 12 18 12 12");
268 gStyle->SetEndErrorSize(5);
269 gStyle->SetCanvasColor(10);
270 gStyle->SetPadColor(10);
271 canvas->SetLeftMargin(0.15);
272 canvas->SetRightMargin(0.04);
273 canvas->SetTopMargin(0.05);
274 canvas->SetBottomMargin(0.12);
275 canvas->ToggleEventStatus();
276 canvas->Range(-200, -10, 1000, -2);
277 canvas->SetFillColor(0);
278 canvas->SetBorderMode(0);
279 canvas->SetBorderSize(0);
283 canvas->SetFrameLineWidth(2);
284 canvas->SetFrameBorderMode(0);
285 canvas->SetFrameBorderSize(0);
288void LmvmHist::SetLegend(vector<LmvmLegend> legendV,
double textsize, Double_t x1, Double_t y1, Double_t x2,
291 auto leg =
new TLegend(x1, y1, x2, y2);
292 leg->SetLineColor(10);
293 leg->SetLineStyle(1);
294 leg->SetLineWidth(1);
295 leg->SetFillColor(10);
296 leg->SetTextSize(textsize);
297 leg->SetTextFont(42);
299 leg->SetBorderSize(0);
300 for (
size_t i = 0; i < legendV.size(); i++) {
301 const auto& l = legendV[i];
302 leg->AddEntry(l.fH, l.fName, l.fOpt);
309void LmvmHist::Rebin(
const string& name,
const vector<string>& subNames,
int nGroup)
312 for (
const auto& curName : names) {
317void LmvmHist::Rebin(
const string& name,
const vector<string>& subNames1,
const vector<string>& subNames2,
int nGroup)
319 vector<string> names =
CombineNames(name, subNames1, subNames2);
320 for (
const auto& curName : names) {
327 int nBins = s->GetNbinsX();
328 TH1D* hsig =
new TH1D(name.c_str(), name.c_str(), nBins, s->GetXaxis()->GetXmin(), s->GetXaxis()->GetXmax());
329 hsig->GetXaxis()->SetTitle(s->GetXaxis()->GetTitle());
332 if (option ==
"right") {
333 for (
int i = 1; i <= nBins; i++) {
334 double sumSignal = s->Integral(1, i,
"width");
335 double sumBg = bg->Integral(1, i,
"width");
336 double sign = (sumSignal + sumBg != 0.) ? sumSignal / std::sqrt(sumSignal + sumBg) : 0.;
337 hsig->SetBinContent(i, sign);
338 hsig->GetYaxis()->SetTitle(
"Significance");
342 else if (option ==
"left") {
343 for (
int i = nBins; i >= 1; i--) {
344 double sumSignal = s->Integral(i, nBins,
"width");
345 double sumBg = bg->Integral(i, nBins,
"width");
346 double sign = (sumSignal + sumBg != 0.) ? sumSignal / std::sqrt(sumSignal + sumBg) : 0.;
347 hsig->SetBinContent(i, sign);
348 hsig->GetYaxis()->SetTitle(
"Significance");
361 int nStepsX = (int) ((xmax - xmin) / delta);
362 int nStepsY = (int) ((ymax - ymin) / delta);
364 TH2D* hsig =
new TH2D(name.c_str(), title.c_str(), nStepsX, xmin, xmax, nStepsY, ymin, ymax);
367 for (
double xcut = xmin; xcut <= xmax; xcut += delta, binX++) {
369 for (
double ycut = ymin; ycut <= ymax; ycut += delta, binY++) {
370 double sumSignal = 0;
372 for (
int ix = 1; ix <= signal->GetNbinsX(); ix++) {
373 for (
int iy = 1; iy <= signal->GetNbinsY(); iy++) {
374 double xc = signal->GetXaxis()->GetBinCenter(ix);
375 double yc = signal->GetYaxis()->GetBinCenter(iy);
376 double val = -1 * (ycut / xcut) * xc + ycut;
378 if (!(xc < xcut && yc < val)) {
379 sumSignal += signal->GetBinContent(ix, iy);
380 sumBg += bg->GetBinContent(ix, iy);
384 double sign = (sumSignal + sumBg != 0.) ? sumSignal / std::sqrt(sumSignal + sumBg) : 0.;
385 hsig->SetBinContent(binX, binY, sign);
392 vector<string> yLabel,
double min,
double max)
399 string hFullname = hName +
"_" + ptcl;
405 vector<string> yLabel,
double min,
double max)
412 string hFullname = hName +
"_" + ptcl;
418 vector<string> yLabel,
double min,
double max)
426 string hFullname =
GetName(hName +
"_" + ptcl, step);
432 TCanvas* c =
fHM.
CreateCanvas(cName + ptcl +
"_steps", cName + ptcl +
"_steps", 2400, 1800);
437 string hFullname =
GetName(hName +
"_" + ptcl, step);
438 DrawAll(dim, hFullname.c_str(),
fAnaStepNames[
static_cast<int>(step)], xLabel, yLabel, min, max);
443void LmvmHist::DrawAll(
int dim,
const string& hFullname,
const string& text, vector<string> xLabel,
444 vector<string> yLabel,
double min,
double max)
447 TH1D*
h =
H1Clone(hFullname.c_str());
448 h->GetYaxis()->SetRangeUser(min, max);
450 if (xLabel.size() > 1) {
451 for (
size_t iL = 0; iL < xLabel.size(); iL++) {
452 h->GetXaxis()->SetBinLabel(iL + 1, xLabel[iL].c_str());
457 TH2D*
h =
H2Clone(hFullname.c_str());
458 h->GetZaxis()->SetRangeUser(min, max);
460 if (xLabel.size() > 1) {
461 for (
size_t iL = 0; iL < xLabel.size(); iL++) {
462 h->GetXaxis()->SetBinLabel(iL + 1, xLabel[iL].c_str());
465 if (yLabel.size() > 1) {
466 for (
size_t iL = 0; iL < yLabel.size(); iL++) {
467 h->GetYaxis()->SetBinLabel(iL + 1, yLabel[iL].c_str());
472 LOG(error) <<
"LmvmHist::DrawAll: Choose dimension 1 or 2";
483 TText* t =
new TText(xPos, yPos, effTxt.c_str());
void DrawTextOnPad(const string &text, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
void DrawH1(TH1 *hist, HistScale logx, HistScale logy, const string &drawOpt, Int_t color, Int_t lineWidth, Int_t lineStyle, Int_t markerSize, Int_t markerStyle)
void DrawH2(TH2 *hist, HistScale logx, HistScale logy, HistScale logz, const string &drawOpt)
Helper functions for drawing 1D and 2D histograms and graphs.
friend fscal max(fscal x, fscal y)
friend fscal min(fscal x, fscal y)
static constexpr size_t size()
TCanvas * CreateCanvas(const std::string &name, const std::string &title, Int_t width, Int_t height)
Create and draw TCanvas and store pointer to it.
void Rebin(const std::string &histName, Int_t ngroup)
Rebin histogram.
void Create2(const std::string &name, const std::string &title, Int_t nofBinsX, Double_t minBinX, Double_t maxBinX, Int_t nofBinsY, Double_t minBinY, Double_t maxBinY)
Helper function for creation of 2-dimensional histograms and profiles. Template argument is a real ob...
void WriteToFile()
Write all objects to current opened file.
void Create1(const std::string &name, const std::string &title, Int_t nofBins, Double_t minBin, Double_t maxBin)
Helper function for creation of 1-dimensional histograms and profiles. Template argument is a real ob...
Data class with information on a STS local track.
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
static const std::vector< ELmvmSrc > fSrcs
static const std::vector< std::string > fCandNames
static const std::vector< std::string > fAnaStepLatex
void DrawEfficiency(TH1 *h1, TH1 *h2, double xPos, double yPos)
TH1D * CreateSignificanceH1(TH1D *s, TH1D *bg, const std::string &name, const std::string &option)
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)
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)
TH2D * H2Clone(const std::string &name)
TH2D * H2(const std::string &name)
void SetOptH1(TH1D *hist, TString xAxisTitle, TString yAxisTitle, Int_t Ndevision, Int_t style, Float_t size, Int_t color, std::string opt="")
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)
static const std::vector< int > fSrcColors
static const std::vector< std::string > fBgPairSrcNames
static const std::vector< ELmvmSignal > fSignals
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)
void SetOptCanvas(TCanvas *canvas)
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 std::vector< std::string > fSrcNames
static const std::vector< std::string > fCandLatex
std::string GetName(const std::string &name, ELmvmAnaStep step)
void FillH2(const std::string &name, double x, double y, double w=1.)
static const std::vector< std::string > fGTrackNames
static const std::vector< std::string > fSrcLatex
void Rebin(const std::string &name, int nGroup)
TH2D * CreateSignificanceH2(TH2D *signal, TH2D *bg, const std::string &name, const std::string &title)
static const std::vector< std::string > fGTrackLatex
static const std::vector< ELmvmAnaStep > fAnaSteps
static const std::vector< std::string > fSignalNames
TH1D * H1Clone(const std::string &name)
TH1D * H1(const std::string &name)
static const std::vector< std::string > fBgPairSrcLatex
static const std::vector< std::string > fAnaStepNames
void SetLegend(std::vector< LmvmLegend >, double textsize, double x1, double y1, double x2, double y2)
static void DrawAnaStepOnPad(ELmvmAnaStep step)
std::string NumberToString(const T &value, int precision=1)