Go to the documentation of this file.
12 #include "TDirectory.h"
18 #include <boost/assign/list_of.hpp>
21 using boost::assign::list_of;
40 "Residuals and pulls (standard deviation)",
41 list_of(
"")(
"x")(
"y")(
"tx")(
"ty")(
"q/p")(
"x")(
"y")(
"tx")(
"ty")(
"q/p"));
43 "STS first",
"htf_Sts_FirstParam_(Res|Pull)_.+",
"sigma");
45 "STS last",
"htf_Sts_LastParam_(Res|Pull)_.+",
"sigma");
47 "TRD first",
"htf_Trd_FirstParam_(Res|Pull)_.+",
"sigma");
49 "TRD last",
"htf_Trd_LastParam_(Res|Pull)_.+",
"sigma");
51 "MUCH first",
"htf_Much_FirstParam_(Res|Pull)_.+",
"sigma");
53 "MUCH last",
"htf_Much_LastParam_(Res|Pull)_.+",
"sigma");
57 "Residuals and pulls (RMS)",
58 list_of(
"")(
"x")(
"y")(
"tx")(
"ty")(
"q/p")(
"x")(
"y")(
"tx")(
"ty")(
"q/p"));
60 "STS first",
"htf_Sts_FirstParam_(Res|Pull)_.+",
"rms");
62 "STS last",
"htf_Sts_LastParam_(Res|Pull)_.+",
"rms");
64 "TRD first",
"htf_Trd_FirstParam_(Res|Pull)_.+",
"rms");
66 "TRD last",
"htf_Trd_LastParam_(Res|Pull)_.+",
"rms");
68 "MUCH first",
"htf_Much_FirstParam_(Res|Pull)_.+",
"rms");
70 "MUCH last",
"htf_Much_LastParam_(Res|Pull)_.+",
"rms");
74 "Residuals and pulls (mean)",
75 list_of(
"")(
"x")(
"y")(
"tx")(
"ty")(
"q/p")(
"x")(
"y")(
"tx")(
"ty")(
"q/p"));
77 "STS first",
"htf_Sts_FirstParam_(Res|Pull)_.+",
"mean");
79 "STS last",
"htf_Sts_LastParam_(Res|Pull)_.+",
"mean");
81 "TRD first",
"htf_Trd_FirstParam_(Res|Pull)_.+",
"mean");
83 "TRD last",
"htf_Trd_LastParam_(Res|Pull)_.+",
"mean");
85 "MUCH first",
"htf_Much_FirstParam_(Res|Pull)_.+",
"mean");
87 "MUCH last",
"htf_Much_LastParam_(Res|Pull)_.+",
"mean");
96 const string& pattern,
97 const string& propertyName) {
99 static map<string, Int_t> ctc;
106 vector<TH2*> histos =
HM()->
H2Vector(pattern);
107 Int_t nofHistos = histos.size();
108 if (nofHistos == 0)
return "";
109 vector<string> parameters(nofHistos);
110 for (UInt_t iHist = 0; iHist < histos.size(); iHist++) {
111 vector<string>
split =
Split(histos[iHist]->GetName(),
'_');
112 TH1D* py = histos[iHist]->ProjectionY();
116 if (propertyName ==
"mean") {
117 parameters[parIndex] = NumberToString<Float_t>(py->GetMean(), 2);
118 }
else if (propertyName ==
"rms") {
119 parameters[parIndex] = NumberToString<Float_t>(py->GetRMS(), 2);
120 }
else if (propertyName ==
"sigma") {
121 py->Fit(
"gaus",
"RQ");
122 TF1* fit = py->GetFunction(
"gaus");
123 parameters[parIndex] =
124 NumberToString<Float_t>((NULL != fit) ? fit->GetParameter(2) : 0., 2);
127 return R()->
TableRow(list_of(rowName).range(parameters));
150 string txt1 = Cbm::NumberToString<Double_t>(sigma, 2) +
" / "
151 + Cbm::NumberToString<Double_t>(rms, 2);
153 text.SetTextAlign(21);
154 text.SetTextSize(0.08);
155 text.DrawTextNDC(0.5, 0.83, txt1.c_str());
160 string parameterNames[] = {
"X",
"Y",
"Tx",
"Ty",
"Qp"};
161 string catNames[] = {
"Res",
"Pull",
"WrongCov"};
163 if (!
HM()->Exists(
"htf_" + detName +
"_FirstParam_Res_X"))
return;
166 for (Int_t
i = 0;
i < 2;
i++) {
167 string trackParamName = (
i == 0) ?
"FirstParam" :
"LastParam";
169 string canvasName =
"fit_qa_" + detName +
"_" + trackParamName;
170 if (draw2D) canvasName +=
"_2d";
172 CreateCanvas(canvasName.c_str(), canvasName.c_str(), 1400, 900);
173 canvas->Divide(5, 3);
176 for (Int_t iCat = 0; iCat < 3; iCat++) {
177 for (Int_t iPar = 0; iPar < 5; iPar++) {
178 string histName =
"htf_" + detName +
"_" + trackParamName +
"_"
179 + catNames[iCat] +
"_" + parameterNames[iPar];
180 if (!
HM()->Exists(histName))
return;
181 Int_t histId = iCat * 5 + iPar;
182 canvas->cd(histId + 1);
183 TH2* hist2D =
HM()->
H2(histName);
188 TH1* hist = (TH1D*) hist2D->ProjectionY()->Clone();
192 hist->Fit(
"gaus",
"RQ");
193 hist->SetMaximum(hist->GetMaximum() * 1.50);
194 TF1* fit = hist->GetFunction(
"gaus");
195 Double_t sigma = (NULL != fit) ? fit->GetParameter(2) : 0.;
196 Double_t rms = hist->GetRMS();
206 if (!
HM()->Exists(
"htp_" + detName +
"_FirstParam_X"))
return;
207 for (Int_t
i = 0;
i < 2;
i++) {
208 string trackParamName = (
i == 0) ?
"FirstParam" :
"LastParam";
210 string(
"fit_qa_track_params_" + detName + trackParamName);
212 CreateCanvas(canvasName.c_str(), canvasName.c_str(), 2000, 1000);
213 canvas->Divide(4, 2);
214 string pattern = string(
"htp_") + detName +
"_" + trackParamName +
"_.+";
215 vector<TH1*> histos =
HM()->
H1Vector(pattern);
216 Int_t nofHistos = histos.size();
217 for (Int_t iHist = 0; iHist < nofHistos; iHist++) {
218 canvas->cd(iHist + 1);
220 gPad->SetGridx(
true);
221 gPad->SetGridy(
true);
228 "fit_qa_momentum_momres_mom_2D",
"fit_qa_momentum_momres_mom_2D", 600, 600);
231 gPad->SetGridx(
true);
232 gPad->SetGridy(
true);
235 "fit_qa_momentum_projection",
"fit_qa_momentum_projection", 600, 600);
238 HM()->
H2(
"htf_MomRes_Mom")->ProjectionY(
"htf_MomRes_Mom_ProjectionY");
240 projY->SetStats(
true);
241 projY->Fit(
"gaus",
"RQ");
242 projY->SetMaximum(projY->GetMaximum() * 1.25);
243 gPad->SetGridx(
true);
244 gPad->SetGridy(
true);
246 TCanvas* canvas3 =
CreateCanvas(
"fit_qa_momentum_momres_mom_sigma",
247 "fit_qa_momentum_momres_mom_sigma",
251 HM()->
H2(
"htf_MomRes_Mom")->FitSlicesY();
252 TH1* momslice = (TH1*) gDirectory->Get(
"htf_MomRes_Mom_2");
253 momslice->GetXaxis()->SetTitle(
"P [GeV/c]");
254 momslice->GetYaxis()->SetTitle(
"dP/P, #sigma [%]");
255 momslice->SetMinimum(0.);
256 momslice->SetMaximum(3.);
258 gPad->SetGridx(
true);
259 gPad->SetGridy(
true);
261 TCanvas* canvas4 =
CreateCanvas(
"fit_qa_momentum_momres_mom_rms",
262 "fit_qa_momentum_momres_mom_rms",
266 TH2* hMomres =
HM()->
H2(
"htf_MomRes_Mom");
267 Int_t nBins = hMomres->GetNbinsX();
268 TH1* momResRms = hMomres->ProjectionX();
269 for (Int_t
i = 1;
i < nBins;
i++) {
270 TH1* projY = hMomres->ProjectionY(
"_py",
i,
i);
271 Double_t rms = projY->GetRMS();
272 momResRms->SetBinContent(
i, rms);
273 momResRms->SetBinError(
i, momslice->GetBinError(
i));
275 momResRms->GetXaxis()->SetTitle(
"P [GeV/c]");
276 momResRms->GetYaxis()->SetTitle(
"dP/P, RMS [%]");
277 momResRms->SetMinimum(0.);
278 momResRms->SetMaximum(3.);
280 gPad->SetGridx(
true);
281 gPad->SetGridy(
true);
284 CreateCanvas(
"fit_qa_chi_primary",
"fit_qa_chi_primary", 600, 600);
286 TH1* hChiprim =
HM()->
H1(
"htf_ChiPrimary");
287 hChiprim->Scale(1. / hChiprim->Integral());
289 gPad->SetGridx(
true);
290 gPad->SetGridy(
true);
294 const char* histNames[] = {
"htp_PrimaryVertexResidualPx",
295 "htp_PrimaryVertexResidualPy",
296 "htp_PrimaryVertexResidualPz",
297 "htp_PrimaryVertexPullPx",
298 "htp_PrimaryVertexPullPy",
299 "htp_PrimaryVertexPullPz"};
301 CreateCanvas(
"Momentum at primary vertex residuals and pulls",
302 "Momentum at primary vertex residuals and pulls",
305 canvas->Divide(3, 2);
307 for (Int_t
i = 0;
i < 2; ++
i) {
308 for (Int_t j = 0; j < 3; ++j) {
309 Int_t histId =
i * 3 + j;
310 canvas->cd(histId + 1);
311 TH1* hist =
HM()->
H1(histNames[histId]);
313 hist->SetStats(
true);
315 gStyle->SetOptFit(1);
319 const char* histNames2[] = {
"htp_PrimaryVertexResidualTx",
320 "htp_PrimaryVertexResidualTy",
321 "htp_PrimaryVertexResidualQp",
322 "htp_PrimaryVertexPullTx",
323 "htp_PrimaryVertexPullTy",
324 "htp_PrimaryVertexPullQp"};
326 CreateCanvas(
"Tangents and Qp at primary vertex residuals and pulls",
327 "Tangents and Qp at primary vertex residuals and pulls",
330 canvas2->Divide(3, 2);
332 for (Int_t
i = 0;
i < 2; ++
i) {
333 for (Int_t j = 0; j < 3; ++j) {
334 Int_t histId =
i * 3 + j;
335 canvas2->cd(histId + 1);
336 TH1* hist =
HM()->
H1(histNames2[histId]);
338 hist->SetStats(
true);
340 gStyle->SetOptFit(1);
virtual std::string TableBegin(const std::string &caption, const std::vector< std::string > &colNames) const =0
Return string with table open tag.
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...
virtual ~CbmLitFitQaReport()
Destructor.
std::vector< std::string > & split(const std::string &s, char delim, std::vector< std::string > &elems)
void DrawResidualAndPullHistograms(const string &detName, Bool_t draw2D)
TH2 * H2(const std::string &name) const
Return pointer to TH2 histogram.
virtual std::string DocumentBegin() const =0
Return string with open tags for document.
string PrintResAndPullRow(const string &rowName, const string &histName, const string &propertyName)
virtual std::string TableRow(const std::vector< std::string > &row) const =0
Return string with table row tags.
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.).
void SetReportName(const std::string &name)
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 PrintCanvases() const
Print images created from canvases in the report.
virtual std::string TableEnd() const =0
Return string with table close tag.
void DrawH2WithProfile(TH2 *hist, Bool_t doGaussFit, Bool_t drawOnlyMean, const string &drawOpt2D, Int_t profileColor, Int_t profileLineWidth)
virtual void Draw()
Inherited from CbmSimulationReport.
ClassImp(CbmConverterManager) InitStatus CbmConverterManager
TH1 * H1(const std::string &name) const
Return pointer to TH1 histogram.
virtual void Create()
Inherited from CbmSimulationReport.
std::vector< TH1 * > H1Vector(const std::string &pattern) const
Return vector of pointers to TH1 histogram.
void DrawHistSigmaRMS(Double_t sigma, Double_t rms)
Draw sigma and RMS on histogram.
CbmHistManager * HM() const
Return pointer to Histogram manager.
CbmLitFitQaReport()
Constructor.
void DrawTrackParamsAtVertex()
std::vector< TH2 * > H2Vector(const std::string &pattern) const
Return vector of pointers to TH2 histogram.
void DrawTrackParams(const string &detName)
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)
void DrawTrackMomentumAtVertex()
Create report for fit QA.
Create report for fit QA.