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