CbmRoot
Loading...
Searching...
No Matches
CbmLitFitQaStudyReport.cxx
Go to the documentation of this file.
1/* Copyright (C) 2013-2014 GSI/JINR-LIT, Darmstadt/Dubna
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Andrey Lebedev [committer] */
4
11
12#include "CbmDrawHist.h"
13#include "CbmHistManager.h"
14#include "CbmReportElement.h"
15#include "CbmUtils.h"
16#include "TCanvas.h"
17#include "TDirectory.h"
18#include "TF1.h"
19#include "TH1.h"
20
21#include <boost/assign/list_of.hpp>
22
23#include <vector>
24using boost::assign::list_of;
27using Cbm::Split;
28using std::vector;
29
31{
32 SetReportName("fit_qa_study");
33 SetReportTitle("Fit QA study report");
34}
35
37
39{
40 Out().precision(3);
41 Out() << R()->DocumentBegin();
42 Out() << R()->Title(0, GetTitle());
44 Out() << R()->DocumentEnd();
45}
46
52
54{
55 Int_t nofStudies = HM().size();
56
57 CreateCanvas("fit_study_qa_momentum_projection", "fit_study_qa_momentum_projection", 600, 600);
58 vector<TH1*> histos1(nofStudies);
59 for (Int_t iStudy = 0; iStudy < nofStudies; iStudy++) {
60 histos1[iStudy] = HM()[iStudy]
61 ->H2("htf_MomRes_Mom")
62 ->ProjectionY(string("htf_MomRes_Mom_ProjectionY_" + NumberToString<Int_t>(iStudy)).c_str());
63 histos1[iStudy]->SetStats(true);
64 histos1[iStudy]->Fit("gaus");
65 histos1[iStudy]->SetMaximum(histos1[iStudy]->GetMaximum() * 1.25);
66 }
67 DrawH1(histos1, GetStudyNames(), kLinear, kLinear);
68 for (Int_t iStudy = 0; iStudy < nofStudies; iStudy++) {
69 histos1[iStudy]->GetFunction("gaus")->SetLineColor(histos1[iStudy]->GetLineColor());
70 }
71 gPad->SetGridx(true);
72 gPad->SetGridy(true);
73
74 CreateCanvas("fit_study_qa_momentum_momres_mom_sigma", "fit_study_qa_momentum_momres_mom_sigma", 600, 600);
75 vector<TH1*> histos2(nofStudies);
76 for (Int_t iStudy = 0; iStudy < nofStudies; iStudy++) {
77 HM()[iStudy]->H2("htf_MomRes_Mom")->FitSlicesY();
78 histos2[iStudy] = gDirectory->Get<TH1>("htf_MomRes_Mom_2");
79 histos2[iStudy]->SetName(string("htf_MomRes_Mom_2_" + NumberToString<Int_t>(iStudy)).c_str());
80 histos2[iStudy]->GetXaxis()->SetTitle("P [GeV/c]");
81 histos2[iStudy]->GetYaxis()->SetTitle("dP/P, #sigma [%]");
82 histos2[iStudy]->SetMinimum(0.);
83 histos2[iStudy]->SetMaximum(3.);
84 }
85 DrawH1(histos2, GetStudyNames(), kLinear, kLinear);
86 gPad->SetGridx(true);
87 gPad->SetGridy(true);
88
89 CreateCanvas("fit_study_qa_momentum_momres_mom_rms", "fit_study_qa_momentum_momres_mom_rms", 600, 600);
90 vector<TH1*> histos3(nofStudies);
91 for (Int_t iStudy = 0; iStudy < nofStudies; iStudy++) {
92 TH2* hMomres = HM()[iStudy]->H2("htf_MomRes_Mom");
93 Int_t nBins = hMomres->GetNbinsX();
94 histos3[iStudy] =
95 hMomres->ProjectionX(string("htf_MomRes_Mom_ProjectionX_" + NumberToString<Int_t>(iStudy)).c_str());
96 for (Int_t i = 1; i < nBins; i++) {
97 TH1* projY = hMomres->ProjectionY("_py", i, i);
98 Double_t rms = projY->GetRMS();
99 histos3[iStudy]->SetBinContent(i, rms);
100 histos3[iStudy]->SetBinError(i, histos2[iStudy]->GetBinError(i));
101 }
102 histos3[iStudy]->GetXaxis()->SetTitle("P [GeV/c]");
103 histos3[iStudy]->GetYaxis()->SetTitle("dP/P, RMS [%]");
104 histos3[iStudy]->SetMinimum(0.);
105 histos3[iStudy]->SetMaximum(3.);
106 }
107 DrawH1(histos3, GetStudyNames(), kLinear, kLinear, "P");
108 gPad->SetGridx(true);
109 gPad->SetGridy(true);
110
111 CreateCanvas("fit_study_qa_chi_primary", "fit_study_qa_chi_primary", 600, 600);
112 vector<TH1*> histos4(nofStudies);
113 for (Int_t iStudy = 0; iStudy < nofStudies; iStudy++) {
114 histos4[iStudy] = HM()[iStudy]->H1("htf_ChiPrimary");
115 histos4[iStudy]->Scale(1. / histos4[iStudy]->Integral());
116 }
117 DrawH1(histos4, GetStudyNames(), kLinear, kLog);
118 gPad->SetGridx(true);
119 gPad->SetGridy(true);
120}
121
ClassImp(CbmConverterManager)
void SetDefaultDrawStyle()
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)
Helper functions for drawing 1D and 2D histograms and graphs.
@ kLinear
Definition CbmDrawHist.h:69
@ kLog
Definition CbmDrawHist.h:68
Histogram manager.
Creates study report for fit QA.
Abstract class for basic report elements (headers, tables, images etc.).
Creates study report for fit QA.
void Create()
Inherited from CbmLitStudyReport.
virtual ~CbmLitFitQaStudyReport()
Destructor.
void Draw()
Inherited from CbmLitStudyReport.
virtual std::string Title(int size, const std::string &title) const =0
Return string with title.
virtual std::string DocumentBegin() const =0
Return string with open tags for document.
virtual std::string DocumentEnd() const =0
Return string with close tags of the document.
std::ostream & Out() const
All text output goes to this stream.
Definition CbmReport.h:66
void SetReportName(const std::string &name)
Definition CbmReport.h:69
void PrintCanvases() const
Print images created from canvases in the report.
void SetReportTitle(const std::string &title)
Definition CbmReport.h:70
const CbmReportElement * R() const
Accessor to CbmReportElement object. User has to write the report using available tags from CbmReport...
Definition CbmReport.h:61
TCanvas * CreateCanvas(const char *name, const char *title, Int_t ww, Int_t wh)
Create canvas and put it to vector of TCanvases. Canvases created with this function will be automati...
Definition CbmReport.cxx:94
Base class for study reports.
const std::vector< std::string > & GetStudyNames() const
const std::vector< CbmHistManager * > & HM() const
string FindAndReplace(const string &name, const string &oldSubstr, const string &newSubstr)
Definition CbmUtils.cxx:59
vector< string > Split(const string &name, char delimiter)
Definition CbmUtils.cxx:67
std::string NumberToString(const T &value, int precision=1)
Definition CbmUtils.h:34