Go to the documentation of this file.
12 #include "TDirectory.h"
18 #include <boost/assign/list_of.hpp>
22 using boost::assign::list_of;
65 vector<string> categories =
66 list_of(
"Electron")(
"Muon")(
"Pion")(
"Proton")(
"Kaon");
67 Int_t nofCategories = categories.size();
68 for (Int_t iCat = 0; iCat < nofCategories; iCat++) {
69 string canvasName =
"tof_qa_fit_histograms_" + categories[iCat];
71 CreateCanvas(canvasName.c_str(), canvasName.c_str(), 1200, 1000);
73 string histName =
"hmp_Tof_RecoMCID_" + categories[iCat] +
"_m2p";
74 TH2* hist =
HM()->
H2(histName);
78 (TH1*) gDirectory->Get(
string(histName +
"_1").c_str());
80 (TH1*) gDirectory->Get(
string(histName +
"_2").c_str());
81 Int_t nofBins = meanHist->GetNbinsX();
82 TGraph* upGraph =
new TGraph(nofBins);
83 upGraph->GetXaxis()->SetRangeUser(meanHist->GetXaxis()->GetXmin(),
84 meanHist->GetXaxis()->GetXmax());
85 TGraph* downGraph =
new TGraph(nofBins);
86 downGraph->GetXaxis()->SetRangeUser(meanHist->GetXaxis()->GetXmin(),
87 meanHist->GetXaxis()->GetXmax());
88 TGraph* meanGraph =
new TGraph(nofBins);
89 meanGraph->GetXaxis()->SetRangeUser(meanHist->GetXaxis()->GetXmin(),
90 meanHist->GetXaxis()->GetXmax());
91 for (Int_t iBin = 1; iBin <= nofBins; iBin++) {
92 Double_t p = meanHist->GetBinCenter(iBin);
93 Double_t mean = meanHist->GetBinContent(iBin);
94 Double_t sigma = sigmaHist->GetBinContent(iBin);
95 upGraph->SetPoint(iBin - 1, p, mean + sigma);
96 downGraph->SetPoint(iBin - 1, p, mean - sigma);
97 meanGraph->SetPoint(iBin - 1, p, mean);
99 std::cout <<
"Upper function for " << categories[iCat] << std::endl;
101 std::cout <<
"Lower function for " << categories[iCat] << std::endl;
109 TF1* f1 =
new TF1(
"f1",
"[0]*x*x*x*x+[1]*x*x*x+[2]*x*x+[3]*x+[4]", 1., 8.);
110 f1->SetLineColor(kRed);
112 graph->Fit(f1,
"RQ");
113 Double_t p0 = f1->GetParameter(0);
114 Double_t p1 = f1->GetParameter(1);
115 Double_t p2 = f1->GetParameter(2);
116 Double_t p3 = f1->GetParameter(3);
117 Double_t p4 = f1->GetParameter(4);
118 std::cout <<
"Function: " << p0 <<
"*x^4" << string((p1 > 0) ?
"+" :
"") << p1
119 <<
"*x^3" << string((p2 > 0) ?
"+" :
"") << p2 <<
"*x^2"
120 << string((p3 > 0) ?
"+" :
"") << p3 <<
"*x"
121 << string((p4 > 0) ?
"+" :
"") << p4 << std::endl;
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...
void FitFunction(TGraph *graph)
Create report for TOF QA.
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.
TH2 * H2(const std::string &name) const
Return pointer to TH2 histogram.
const CbmReportElement * R() const
Accessor to CbmReportElement object. User has to write the report using available tags from CbmReport...
Helper functions for drawing 1D and 2D histograms and graphs.
Abstract class for basic report elements (headers, tables, images etc.).
virtual void Create()
Inherited from CbmSimulationReport.
void DrawGraph(TGraph *graph, HistScale logx, HistScale logy, const string &drawOpt, Int_t color, Int_t lineWidth, Int_t lineStyle, Int_t markerSize, Int_t markerStyle)
void SetReportName(const std::string &name)
CbmLitTofQaReport()
Constructor.
void NormalizeToIntegralByPattern(const std::string &pattern)
Normalize histograms to integral which name matches specified pattern.
void PrintCanvases() const
Print images created from canvases in the report.
virtual ~CbmLitTofQaReport()
Destructor.
ClassImp(CbmConverterManager) InitStatus CbmConverterManager
void DrawH1ByPattern(const std::string &histNamePattern)
Select by pattern TH1 histograms and draw each histogram on separate canvas.
void DrawH2ByPattern(const std::string &histNamePattern, HistScale logx=kLinear, HistScale logy=kLinear, HistScale logz=kLinear, const std::string &drawOpt="")
Select by pattern TH2 histograms and draw each histogram on separate canvas.
virtual void Draw()
Inherited from CbmSimulationReport.
CbmHistManager * HM() const
Return pointer to Histogram manager.
Base class for simulation reports.
std::ostream & Out() const
All text output goes to this stream.
void DrawH2(TH2 *hist, HistScale logx, HistScale logy, HistScale logz, const string &drawOpt)
virtual std::string Title(int size, const std::string &title) const =0
Return string with title.
std::string NumberToString(const T &value, int precision=1)
vector< string > Split(const string &name, char delimiter)
Create report for TOF QA.