17#include "TDirectory.h"
24#include <boost/assign/list_of.hpp>
28using boost::assign::list_of;
45 Out() <<
R()->
TableBegin(
"Residuals and pulls (standard deviation)",
46 list_of(
"")(
"x")(
"y")(
"tx")(
"ty")(
"q/p")(
"x")(
"y")(
"tx")(
"ty")(
"q/p"));
56 list_of(
"")(
"x")(
"y")(
"tx")(
"ty")(
"q/p")(
"x")(
"y")(
"tx")(
"ty")(
"q/p"));
66 list_of(
"")(
"x")(
"y")(
"tx")(
"ty")(
"q/p")(
"x")(
"y")(
"tx")(
"ty")(
"q/p"));
83 static map<string, Int_t> ctc;
91 Int_t nofHistos = histos.size();
92 if (nofHistos == 0)
return "";
93 vector<string> parameters(nofHistos);
94 for (UInt_t iHist = 0; iHist < histos.size(); iHist++) {
95 vector<string> split = Split(histos[iHist]->GetName(),
'_');
96 TH1D* py = histos[iHist]->ProjectionY();
98 Int_t parIndex = (split[3] ==
"Res") ? (ctc[split[4]]) : (ctc[split[4]] + 5);
99 if (propertyName ==
"mean") {
100 parameters[parIndex] = NumberToString<Float_t>(py->GetMean(), 2);
102 else if (propertyName ==
"rms") {
103 parameters[parIndex] = NumberToString<Float_t>(py->GetRMS(), 2);
105 else if (propertyName ==
"sigma") {
106 py->Fit(
"gaus",
"RQ");
107 TF1* fit = py->GetFunction(
"gaus");
108 parameters[parIndex] = NumberToString<Float_t>((NULL != fit) ? fit->GetParameter(2) : 0., 2);
111 return R()->
TableRow(list_of(rowName).range(parameters));
138 text.SetTextAlign(21);
139 text.SetTextSize(0.08);
140 text.DrawTextNDC(0.5, 0.83, txt1.c_str());
145 string parameterNames[] = {
"X",
"Y",
"Tx",
"Ty",
"Qp"};
146 string catNames[] = {
"Res",
"Pull",
"WrongCov"};
148 if (!
HM()->Exists(
"htf_" + detName +
"_FirstParam_Res_X"))
return;
151 for (Int_t i = 0; i < 2; i++) {
152 string trackParamName = (i == 0) ?
"FirstParam" :
"LastParam";
154 string canvasName =
"fit_qa_" + detName +
"_" + trackParamName;
155 if (draw2D) canvasName +=
"_2d";
156 TCanvas* canvas =
CreateCanvas(canvasName.c_str(), canvasName.c_str(), 1400, 900);
157 canvas->Divide(5, 3);
160 for (Int_t iCat = 0; iCat < 3; iCat++) {
161 for (Int_t iPar = 0; iPar < 5; iPar++) {
162 string histName =
"htf_" + detName +
"_" + trackParamName +
"_" + catNames[iCat] +
"_" + parameterNames[iPar];
163 if (!
HM()->Exists(histName))
return;
164 Int_t histId = iCat * 5 + iPar;
165 canvas->cd(histId + 1);
166 TH2* hist2D =
HM()->
H2(histName);
172 TH1* hist = (TH1D*) hist2D->ProjectionY()->Clone();
176 hist->Fit(
"gaus",
"RQ");
177 hist->SetMaximum(hist->GetMaximum() * 1.50);
178 TF1* fit = hist->GetFunction(
"gaus");
179 Double_t sigma = (NULL != fit) ? fit->GetParameter(2) : 0.;
180 Double_t rms = hist->GetRMS();
191 if (!
HM()->Exists(
"htp_" + detName +
"_FirstParam_X"))
return;
192 for (Int_t i = 0; i < 2; i++) {
193 string trackParamName = (i == 0) ?
"FirstParam" :
"LastParam";
194 string canvasName = string(
"fit_qa_track_params_" + detName + trackParamName);
195 TCanvas* canvas =
CreateCanvas(canvasName.c_str(), canvasName.c_str(), 2000, 1000);
196 canvas->Divide(4, 2);
197 string pattern = string(
"htp_") + detName +
"_" + trackParamName +
"_.+";
198 vector<TH1*> histos =
HM()->
H1Vector(pattern);
199 Int_t nofHistos = histos.size();
200 for (Int_t iHist = 0; iHist < nofHistos; iHist++) {
201 canvas->cd(iHist + 1);
203 gPad->SetGridx(
true);
204 gPad->SetGridy(
true);
211 TCanvas* canvas1 =
CreateCanvas(
"fit_qa_momentum_momres_mom_2D",
"fit_qa_momentum_momres_mom_2D", 600, 600);
214 gPad->SetGridx(
true);
215 gPad->SetGridy(
true);
217 TCanvas* canvas2 =
CreateCanvas(
"fit_qa_momentum_projection",
"fit_qa_momentum_projection", 600, 600);
219 TH1* projY =
HM()->
H2(
"htf_MomRes_Mom")->ProjectionY(
"htf_MomRes_Mom_ProjectionY");
221 projY->SetStats(
true);
222 projY->Fit(
"gaus",
"RQ");
223 projY->SetMaximum(projY->GetMaximum() * 1.25);
224 gPad->SetGridx(
true);
225 gPad->SetGridy(
true);
227 TCanvas* canvas3 =
CreateCanvas(
"fit_qa_momentum_momres_mom_sigma",
"fit_qa_momentum_momres_mom_sigma", 600, 600);
229 HM()->
H2(
"htf_MomRes_Mom")->FitSlicesY();
230 TH1* momslice = gDirectory->Get<TH1>(
"htf_MomRes_Mom_2");
231 momslice->GetXaxis()->SetTitle(
"P [GeV/c]");
232 momslice->GetYaxis()->SetTitle(
"dP/P, #sigma [%]");
233 momslice->SetMinimum(0.);
234 momslice->SetMaximum(3.);
236 gPad->SetGridx(
true);
237 gPad->SetGridy(
true);
239 TCanvas* canvas4 =
CreateCanvas(
"fit_qa_momentum_momres_mom_rms",
"fit_qa_momentum_momres_mom_rms", 600, 600);
241 TH2* hMomres =
HM()->
H2(
"htf_MomRes_Mom");
242 Int_t nBins = hMomres->GetNbinsX();
243 TH1* momResRms = hMomres->ProjectionX();
244 for (Int_t i = 1; i < nBins; i++) {
245 projY = hMomres->ProjectionY(
"_py", i, i);
246 Double_t rms = projY->GetRMS();
247 momResRms->SetBinContent(i, rms);
248 momResRms->SetBinError(i, momslice->GetBinError(i));
250 momResRms->GetXaxis()->SetTitle(
"P [GeV/c]");
251 momResRms->GetYaxis()->SetTitle(
"dP/P, RMS [%]");
252 momResRms->SetMinimum(0.);
253 momResRms->SetMaximum(3.);
255 gPad->SetGridx(
true);
256 gPad->SetGridy(
true);
258 TCanvas* canvas5 =
CreateCanvas(
"fit_qa_chi_primary",
"fit_qa_chi_primary", 600, 600);
260 TH1* hChiprim =
HM()->
H1(
"htf_ChiPrimary");
261 hChiprim->Scale(1. / hChiprim->Integral());
263 gPad->SetGridx(
true);
264 gPad->SetGridy(
true);
269 const char* histNames[] = {
"htp_PrimaryVertexResidualPx",
"htp_PrimaryVertexResidualPy",
270 "htp_PrimaryVertexResidualPz",
"htp_PrimaryVertexPullPx",
271 "htp_PrimaryVertexPullPy",
"htp_PrimaryVertexPullPz"};
272 TCanvas* canvas =
CreateCanvas(
"Momentum at primary vertex residuals and pulls",
273 "Momentum at primary vertex residuals and pulls", 900, 600);
274 canvas->Divide(3, 2);
276 for (Int_t i = 0; i < 2; ++i) {
277 for (Int_t j = 0; j < 3; ++j) {
278 Int_t histId = i * 3 + j;
279 canvas->cd(histId + 1);
280 TH1* hist =
HM()->
H1(histNames[histId]);
282 hist->SetStats(
true);
284 gStyle->SetOptFit(1);
288 const char* histNames2[] = {
"htp_PrimaryVertexResidualTx",
"htp_PrimaryVertexResidualTy",
289 "htp_PrimaryVertexResidualQp",
"htp_PrimaryVertexPullTx",
290 "htp_PrimaryVertexPullTy",
"htp_PrimaryVertexPullQp"};
291 TCanvas* canvas2 =
CreateCanvas(
"Tangents and Qp at primary vertex residuals and pulls",
292 "Tangents and Qp at primary vertex residuals and pulls", 900, 600);
293 canvas2->Divide(3, 2);
295 for (Int_t i = 0; i < 2; ++i) {
296 for (Int_t j = 0; j < 3; ++j) {
297 Int_t histId = i * 3 + j;
298 canvas2->cd(histId + 1);
299 TH1* hist =
HM()->
H1(histNames2[histId]);
301 hist->SetStats(
true);
303 gStyle->SetOptFit(1);
ClassImp(CbmConverterManager)
void DrawH2WithProfile(TH2 *hist, Bool_t doGaussFit, Bool_t drawOnlyMean, const string &drawOpt2D, Int_t profileColor, Int_t profileLineWidth)
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.
Create report for fit QA.
Abstract class for basic report elements (headers, tables, images etc.).
std::vector< TH1 * > H1Vector(const std::vector< std::string > &names) const
Return vector of pointers to TH1 histogram.
TH2 * H2(const std::string &name) const
Return pointer to TH2 histogram.
std::vector< TH2 * > H2Vector(const std::vector< std::string > &names) const
Return vector of pointers to TH2 histogram.
TH1 * H1(const std::string &name) const
Return pointer to TH1 histogram.
Create report for fit QA.
void DrawResidualAndPullHistograms(const string &detName, Bool_t draw2D)
void DrawTrackParamsAtVertex()
void DrawTrackMomentumAtVertex()
virtual void Create()
Inherited from CbmSimulationReport.
CbmLitFitQaReport()
Constructor.
void DrawTrackParams(const string &detName)
string PrintResAndPullRow(const string &rowName, const string &histName, const string &propertyName)
virtual void Draw()
Inherited from CbmSimulationReport.
void DrawHistSigmaRMS(Double_t sigma, Double_t rms)
Draw sigma and RMS on histogram.
virtual ~CbmLitFitQaReport()
Destructor.
virtual std::string TableRow(const std::vector< std::string > &row) const =0
Return string with table row tags.
virtual std::string Title(int size, const std::string &title) const =0
Return string with title.
virtual std::string TableBegin(const std::string &caption, const std::vector< std::string > &colNames) const =0
Return string with table open tag.
virtual std::string DocumentBegin() const =0
Return string with open tags for document.
virtual std::string TableEnd() const =0
Return string with table close tag.
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.
void SetReportName(const std::string &name)
void PrintCanvases() const
Print images created from canvases in the report.
const CbmReportElement * R() const
Accessor to CbmReportElement object. User has to write the report using available tags from CbmReport...
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...
Base class for simulation reports.
TH2 * H2(const std::string &name) const
Return pointer to TH2 histogram.
CbmHistManager * HM() const
Return pointer to Histogram manager.
vector< string > Split(const string &name, char delimiter)
std::string NumberToString(const T &value, int precision=1)