20#include <boost/assign/list_of.hpp>
25using boost::assign::list_of;
38 vector<string> split = Split(histName,
'_');
39 return split[1] +
":" + split[3] +
"(" + NumberToString<Double_t>(efficiency, 1) +
")";
44 vector<string> split = Split(histName,
'_');
45 return FindAndReplace(split[1],
"Sts",
"") +
" (" + NumberToString<Double_t>(efficiency, 1) +
")";
50 vector<string> split = Split(histName,
'_');
51 return split[1] +
" (" + NumberToString<Double_t>(efficiency, 1) +
")";
67 Out() <<
"Number of events: " <<
HM()->
H1(
"hen_EventNo_TrackingQa")->GetEntries() << endl;
85 vector<TH1*> histos =
HM()->
H1Vector(
"hno_NofObjects_.+");
86 Int_t nofHistos = histos.size();
87 string str =
R()->
TableBegin(
"Number of objects per event", list_of(
"Name")(
"Value"));
88 for (Int_t iHist = 0; iHist < nofHistos; iHist++) {
89 string cellName = Split(histos[iHist]->GetName(),
'_')[2];
90 str +=
R()->
TableRow(list_of(cellName)(NumberToString<Int_t>(histos[iHist]->GetMean())));
98 vector<TH1*> histos =
HM()->
H1Vector(
"hth_.+_TrackHits_All");
99 Int_t nofHistos = histos.size();
100 string str =
R()->
TableBegin(
"Number of all, true and fake hits in tracks and rings",
101 list_of(
"")(
"all")(
"true")(
"fake")(
"true/all")(
"fake/all"));
102 for (Int_t iHist = 0; iHist < nofHistos; iHist++) {
103 string name = histos[iHist]->GetName();
104 string cellName = Split(name,
'_')[1];
105 string all = NumberToString<Double_t>(histos[iHist]->GetMean(), 2);
106 string trueh = NumberToString<Double_t>(
HM()->
H1(FindAndReplace(name,
"_All",
"_True"))->GetMean(), 2);
107 string fakeh = NumberToString<Double_t>(
HM()->
H1(FindAndReplace(name,
"_All",
"_Fake"))->GetMean(), 2);
108 string toa = NumberToString<Double_t>(
HM()->
H1(FindAndReplace(name,
"_All",
"_TrueOverAll"))->GetMean(), 2);
109 string foa = NumberToString<Double_t>(
HM()->
H1(FindAndReplace(name,
"_All",
"_FakeOverAll"))->GetMean(), 2);
110 str +=
R()->
TableRow(list_of(cellName)(all)(trueh)(fakeh)(toa)(foa));
118 Double_t nofEvents =
HM()->
H1(
"hen_EventNo_TrackingQa")->GetEntries();
119 vector<TH1*> histos =
HM()->
H1Vector(
"hng_NofGhosts_.+");
120 Int_t nofHistos = histos.size();
121 string str =
R()->
TableBegin(
"Number of ghosts per event", list_of(
"Name")(
"Value"));
122 for (Int_t iHist = 0; iHist < nofHistos; iHist++) {
123 string cellName = Split(histos[iHist]->GetName(),
'_')[2];
124 str +=
R()->
TableRow(list_of(cellName)(NumberToString<Double_t>(histos[iHist]->GetEntries() / nofEvents, 2)));
134 string effRegex =
"";
135 if (!isPidEfficiency)
136 effRegex = (includeRich) ?
"hte_.*Rich.*_Eff_p" :
"hte_((?!Rich).)*_Eff_p";
138 effRegex = (includeRich) ?
"hpe_.*Rich.*_Eff_p" :
"hpe_((?!Rich).)*_Eff_p";
140 vector<TH1*> histos =
HM()->
H1Vector(effRegex);
141 Int_t nofHistos = histos.size();
142 if (nofHistos == 0)
return "";
145 map<string, Int_t> catToCell;
146 for (Int_t iHist = 0; iHist < nofHistos; iHist++) {
147 string effName = histos[iHist]->GetName();
148 pair<string, Int_t> tmp = make_pair(Split(effName,
'_')[3], catToCell.size());
149 catToCell.insert(tmp);
151 Int_t nofCats = catToCell.size();
152 Int_t nofRows = nofHistos / nofCats;
154 vector<string> cat(nofCats);
155 map<string, Int_t>::const_iterator it;
156 for (it = catToCell.begin(); it != catToCell.end(); it++) {
157 cat[(*it).second] = (*it).first;
160 Int_t nofEvents =
HM()->
H1(
"hen_EventNo_TrackingQa")->GetEntries();
161 string tableTitle = (isPidEfficiency) ?
"PID efficiency" :
"Tracking efficiency";
163 tableTitle +=
" (with RICH)";
165 tableTitle +=
" (without RICH)";
167 string str =
R()->
TableBegin(tableTitle, list_of(
string(
"")).range(cat));
168 Int_t histCounter = 0;
169 for (Int_t iRow = 0; iRow < nofRows; iRow++) {
170 vector<string> cells(nofCats);
172 for (Int_t iCat = 0; iCat < nofCats; iCat++) {
173 string effName = histos[histCounter]->GetName();
174 string accName = FindAndReplace(effName,
"_Eff_",
"_Acc_");
175 string recName = FindAndReplace(effName,
"_Eff_",
"_Rec_");
176 Double_t acc =
HM()->
H1(accName)->GetEntries() / nofEvents;
177 Double_t rec =
HM()->
H1(recName)->GetEntries() / nofEvents;
178 Double_t eff = (acc != 0.) ? 100. * rec / acc : 0.;
179 string accStr = NumberToString<Double_t>(acc, 2);
180 string recStr = NumberToString<Double_t>(rec, 2);
181 string effStr = NumberToString<Double_t>(eff);
182 vector<string> split = Split(effName,
'_');
183 cells[catToCell[split[3]]] = effStr +
"(" + recStr +
"/" + accStr +
")";
185 rowName = split[1] +
" (" + split[2] +
")";
187 str +=
R()->
TableRow(list_of(rowName).range(cells));
195 vector<TH1*> histos =
HM()->
H1Vector(
"hps_.*_PionSup_p");
196 Int_t nofHistos = histos.size();
197 if (nofHistos == 0)
return "";
199 Int_t nofEvents =
HM()->
H1(
"hen_EventNo_TrackingQa")->GetEntries();
200 string str =
R()->
TableBegin(
"Pion suppression", list_of(
string(
""))(
"Pion suppression"));
201 for (Int_t iHist = 0; iHist < nofHistos; iHist++) {
202 string psName = histos[iHist]->GetName();
203 string recName = FindAndReplace(psName,
"_PionSup_",
"_Rec_");
204 string recPionsName = FindAndReplace(psName,
"_PionSup_",
"_RecPions_");
205 Double_t rec =
HM()->
H1(recName)->GetEntries() / nofEvents;
206 Double_t recPions =
HM()->
H1(recPionsName)->GetEntries() / nofEvents;
207 Double_t pionSup = (rec != 0.) ? recPions / rec : 0.;
208 string pionSupStr = NumberToString<Double_t>(pionSup) +
" (" + NumberToString<Double_t>(recPions) +
"/"
209 + NumberToString<Double_t>(rec) +
")";
210 vector<string> split = Split(psName,
'_');
211 string rowName = split[1];
212 string category = split[2];
213 str +=
R()->
TableRow(list_of(rowName +
" - " + category)(pionSupStr));
236 DrawEfficiency(
"tracking_qa_global_tracking_efficiency_all_" + variant +
"_p",
238 DrawEfficiency(
"tracking_qa_global_tracking_efficiency_muon_" + variant +
"_p",
240 DrawEfficiency(
"tracking_qa_global_tracking_efficiency_electron_" + variant +
"_p",
242 DrawEfficiency(
"tracking_qa_pid_efficiency_electron_" + variant +
"_p",
246 DrawEfficiency(
"tracking_qa_global_tracking_efficiency_" + variant +
"_angle",
248 if (variant.find(
"Rich") != string::npos) {
249 DrawEfficiency(
"tracking_qa_global_tracking_efficiency_electron_" + variant +
"_RingXc",
251 DrawEfficiency(
"tracking_qa_global_tracking_efficiency_electron_" + variant +
"_RingYc",
257 vector<string> localTrackVariants = list_of(
"Sts")(
"Trd")(
"Much")(
"Rich")(
"Tof");
258 for (UInt_t i = 0; i < localTrackVariants.size(); i++) {
259 string variant = localTrackVariants[i];
261 (variant ==
"Sts") ?
"hte_Sts_Sts_(All|Muon|Electron)_Eff" :
"hte_" + variant +
"_.*_(All|Muon|Electron)_Eff";
262 if (variant ==
"Rich") re =
"hte_" + variant +
"_.*_(Electron|ElectronReference)_Eff";
263 DrawEfficiency(
"tracking_qa_local_tracking_efficiency_" + variant +
"_p", re +
"_p",
268 string re2 = (variant ==
"Sts") ?
"hte_Sts_Sts_All_Eff" :
"hte_" + variant +
"_.*_All_Eff";
269 DrawEfficiency(
"tracking_qa_local_tracking_efficiency_" + variant +
"_angle", re2 +
"_Angle",
274 DrawEfficiency(
"tracking_qa_local_tracking_efficiency_Rich_RingNh",
"hte_Rich_Rich_Electron_Eff_RingNh",
276 DrawEfficiency(
"tracking_qa_local_tracking_efficiency_Rich_BoA",
"hte_Rich_Rich_Electron_Eff_BoA",
278 DrawEfficiency(
"tracking_qa_local_tracking_efficiency_Rich_RingXc",
"hte_Rich_Rich_Electron_Eff_RingXc",
280 DrawEfficiency(
"tracking_qa_local_tracking_efficiency_Rich_RingYc",
"hte_Rich_Rich_Electron_Eff_RingYc",
282 DrawYPt(
"tracking_qa_Rich_Rich_Electron_Eff_RingXcYc",
"hte_Rich_Rich_Electron_Eff_RingXcYc",
true);
286 vector<string> accRecTracks = list_of(
"Sts")(
"Trd")(
"Much")(
"Tof");
287 for (UInt_t i = 0; i < accRecTracks.size(); i++) {
288 string variant = accRecTracks[i];
290 string re = (variant ==
"Sts") ?
"hte_Sts_Sts_(All|Muon|Electron)_(Acc|Rec)_Np"
291 :
"hte_" + variant +
"_.*_(All|Muon|Electron)_(Acc|Rec)_Np";
292 DrawAccAndRec(
"tracking_qa_local_acc_and_rec_" + variant +
"_Np", re);
294 re = (variant ==
"Sts") ?
"hte_Sts_Sts_(All)_(Acc|Rec)_p" :
"hte_" + variant +
"_.*_(All)_(Acc|Rec)_p";
295 DrawAccAndRec(
"tracking_qa_local_acc_and_rec_" + variant +
"_All_p", re);
297 re = (variant ==
"Sts") ?
"hte_Sts_Sts_(Muon|Electron)_(Acc|Rec)_p"
298 :
"hte_" + variant +
"_.*_(Muon|Electron)_(Acc|Rec)_p";
299 DrawAccAndRec(
"tracking_qa_local_acc_and_rec_" + variant +
"_ElectronMuon_p", re);
303 DrawPionSuppression(
"tracking_qa_pion_suppression_wo_Rich_p",
"hps_((?!Rich)).*All_PionSup_p",
310 if (
HM()->Exists(
"hng_NofGhosts_Rich_RingXcYc")) {
311 CreateCanvas(
"tracking_qa_hng_NofGhosts_Rich_RingXcYc",
"tracking_qa_hng_NofGhosts_Rich_RingXcYc", 800, 800);
312 Int_t nofEvents =
HM()->
H1(
"hen_EventNo_TrackingQa")->GetEntries();
313 HM()->
H2(
"hng_NofGhosts_Rich_RingXcYc")->Scale(1. / nofEvents);
314 DrawH2(
HM()->
H2(
"hng_NofGhosts_Rich_RingXcYc"));
319 string (*labelFormatter)(
const string&, Double_t))
321 vector<TH1*> histos =
HM()->
H1Vector(histNamePattern);
322 if (histos.size() == 0)
return;
324 TCanvas* canvas =
CreateCanvas(canvasName.c_str(), canvasName.c_str(), 600, 500);
328 Int_t nofHistos = histos.size();
329 vector<string> labels(nofHistos);
330 vector<Double_t> efficiencies(nofHistos);
331 for (Int_t iHist = 0; iHist < nofHistos; iHist++) {
332 string name = histos[iHist]->GetName();
333 efficiencies[iHist] =
CalcEfficiency(
HM()->
H1(FindAndReplace(name,
"_Eff_",
"_Rec_")),
334 HM()->
H1(FindAndReplace(name,
"_Eff_",
"_Acc_")), 100.);
335 labels[iHist] = labelFormatter(name, efficiencies[iHist]);
343 string (*labelFormatter)(
const string&, Double_t))
345 vector<TH1*> histos =
HM()->
H1Vector(histNamePattern);
346 if (histos.size() == 0)
return;
348 TCanvas* canvas =
CreateCanvas(canvasName.c_str(), canvasName.c_str(), 600, 500);
352 Int_t nofHistos = histos.size();
353 vector<string> labels(nofHistos);
354 vector<Double_t> ps(nofHistos);
355 for (Int_t iHist = 0; iHist < nofHistos; iHist++) {
356 string name = histos[iHist]->GetName();
358 HM()->
H1(FindAndReplace(name,
"_PionSup_",
"_Rec_")), 1.);
359 labels[iHist] = labelFormatter(name, ps[iHist]);
368 assert(histos.size() != 0 && efficiencies.size() == histos.size());
370 Double_t minX = histos[0]->GetXaxis()->GetXmin();
371 Double_t maxX = histos[0]->GetXaxis()->GetXmax();
372 Int_t nofHistos = histos.size();
373 for (Int_t iHist = 0; iHist < nofHistos; iHist++) {
374 TLine* line =
new TLine(minX, efficiencies[iHist], maxX, efficiencies[iHist]);
375 line->SetLineWidth(1);
376 line->SetLineColor(histos[iHist]->GetLineColor());
383 vector<TH1*> histos =
HM()->
H1Vector(histNamePattern);
384 if (histos.size() == 0)
return;
386 TCanvas* canvas =
CreateCanvas(canvasName.c_str(), canvasName.c_str(), 600, 500);
390 Int_t nofEvents =
HM()->
H1(
"hen_EventNo_TrackingQa")->GetEntries();
391 Int_t nofHistos = histos.size();
392 vector<string> labels(nofHistos);
393 for (Int_t iHist = 0; iHist < nofHistos; iHist++) {
394 TH1* hist = histos[iHist];
395 hist->Scale(1. / nofEvents);
396 string name = hist->GetName();
397 vector<string> split = Split(name,
'_');
398 labels[iHist] = split[4] +
":" + split[3] +
"(" + NumberToString<Double_t>(hist->GetEntries() / nofEvents, 2) +
")";
409 string effHistName =
"hte_" + variant +
"_" + variant;
410 DrawYPt(
"tracking_qa_" + variant +
"_all_ypt", effHistName +
"_All_Eff_YPt");
411 DrawYPt(
"tracking_qa_" + variant +
"_proton_ypt", effHistName +
"_Proton_Eff_YPt");
412 DrawYPt(
"tracking_qa_" + variant +
"_pion_plus_ypt", effHistName +
"_PionPlus_Eff_YPt");
413 DrawYPt(
"tracking_qa_" + variant +
"_pion_minus_ypt", effHistName +
"_PionMinus_Eff_YPt");
414 DrawYPt(
"tracking_qa_" + variant +
"_kaon_plus_ypt", effHistName +
"_KaonPlus_Eff_YPt");
415 DrawYPt(
"tracking_qa_" + variant +
"_kaon_minus_ypt", effHistName +
"_KaonMinus_Eff_YPt");
421 string accHistName = FindAndReplace(effHistName,
"_Eff_",
"_Acc_");
422 string recHistName = FindAndReplace(effHistName,
"_Eff_",
"_Rec_");
424 if (!(
HM()->Exists(effHistName) &&
HM()->Exists(accHistName) &&
HM()->Exists(recHistName)))
return;
426 TH2* accHist =
HM()->
H2(accHistName);
427 TH2* recHist =
HM()->
H2(recHistName);
428 TH2* effHist =
HM()->
H2(effHistName);
430 if (drawOnlyEfficiency) {
431 CreateCanvas(canvasName.c_str(), canvasName.c_str(), 800, 800);
436 TCanvas* canvas =
CreateCanvas(canvasName.c_str(), canvasName.c_str(), 1800, 600);
437 canvas->Divide(3, 1);
462 if (!(
HM()->Exists(hist +
"_All") &&
HM()->Exists(hist +
"_True") &&
HM()->Exists(hist +
"_Fake")
463 &&
HM()->Exists(hist +
"_TrueOverAll") &&
HM()->Exists(hist +
"_FakeOverAll")))
466 TCanvas* canvas =
CreateCanvas(canvasName.c_str(), canvasName.c_str(), 1200, 600);
467 canvas->Divide(2, 1);
471 TH1* hAll =
HM()->
H1(hist +
"_All");
472 TH1* hTrue =
HM()->
H1(hist +
"_True");
473 TH1* hFake =
HM()->
H1(hist +
"_Fake");
474 DrawH1(list_of(hAll)(hTrue)(hFake),
475 list_of(
"all: " + NumberToString<Double_t>(hAll->GetMean(), 1))(
476 "true: " + NumberToString<Double_t>(hTrue->GetMean(), 1))(
"fake: "
477 + NumberToString<Double_t>(hFake->GetMean(), 1)),
481 TH1* hTrueOverAll =
HM()->
H1(hist +
"_TrueOverAll");
482 TH1* hFakeOverAll =
HM()->
H1(hist +
"_FakeOverAll");
483 DrawH1(list_of(hTrueOverAll)(hFakeOverAll),
484 list_of(
"true/all: " + NumberToString<Double_t>(hTrueOverAll->GetMean()))(
485 "fake/all: " + NumberToString<Double_t>(hFakeOverAll->GetMean())),
491 if (histAcc->Integral() == 0 || histRec->Integral() == 0) {
495 return scale * Double_t(histRec->Integral()) / Double_t(histAcc->Integral());
502 vector<TH1*> histos =
HM()->
H1Vector(
"hte_.*_Eff_p");
503 Int_t nofHistos = histos.size();
504 set<string> variants;
505 for (Int_t iHist = 0; iHist < nofHistos; iHist++) {
506 string effName = histos[iHist]->GetName();
507 variants.insert(Split(effName,
'_')[2]);
517 histo3->Divide(histo1, histo2, 1., 1.,
"B");
518 histo3->Scale(scale);
523 vector<TH1*> effHistos =
HM()->
H1Vector(
"(hte|hpe)_.+_Eff_.+");
524 Int_t nofEffHistos = effHistos.size();
525 for (Int_t iHist = 0; iHist < nofEffHistos; iHist++) {
526 TH1* effHist = effHistos[iHist];
527 string effHistName = effHist->GetName();
528 string accHistName = FindAndReplace(effHistName,
"_Eff_",
"_Acc_");
529 string recHistName = FindAndReplace(effHistName,
"_Eff_",
"_Rec_");
531 effHist->SetMinimum(0.);
532 effHist->SetMaximum(100.);
538 vector<TH1*> histos =
HM()->
H1Vector(
"hps_.+_PionSup_.+");
539 Int_t nofHistos = histos.size();
540 for (Int_t iHist = 0; iHist < nofHistos; iHist++) {
541 TH1* psHist = histos[iHist];
542 string psHistName = psHist->GetName();
543 string recHistName = FindAndReplace(psHistName,
"_PionSup_",
"_Rec_");
544 string pionRecHistName = FindAndReplace(psHistName,
"_PionSup_",
"_RecPions_");
546 psHist->SetMinimum(10.);
547 psHist->SetMaximum(2e5);
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)
void DrawH2(TH2 *hist, HistScale logx, HistScale logy, HistScale logz, const string &drawOpt)
Helper functions for drawing 1D and 2D histograms and graphs.
string ElectronIdEfficiencyLabelFormatter(const string &histName, Double_t efficiency)
string DefaultPionSuppressionLabelFormatter(const string &histName, Double_t efficiency)
string DefaultEfficiencyLabelFormatter(const string &histName, Double_t efficiency)
Create report for tracking QA.
Abstract class for basic report elements (headers, tables, images etc.).
void ShrinkEmptyBinsH1ByPattern(const std::string &pattern)
Shrink empty bins in H1.
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.
TH1 * H1(const std::string &name) const
Return pointer to TH1 histogram.
Create report for tracking QA.
void CalculateEfficiencyHistos()
Calculate efficiency histograms.
void DrawYPt(const string &canvasName, const string &effHistName, Bool_t drawOnlyEfficiency=false)
Draw Rapidity-Pt histograms.
virtual void Draw()
Inherited from CbmSimulationReport.
void DrawPionSuppression(const string &canvasName, const string &histNamePattern, string(*labelFormatter)(const string &, Double_t))
vector< string > fGlobalTrackVariants
string PrintNofGhosts() const
Return string with number of ghosts statistics.
virtual ~CbmLitTrackingQaReport()
Destructor.
virtual void Create()
Inherited from CbmSimulationReport.
void DrawMeanEfficiencyLines(const vector< TH1 * > &histos, const vector< Double_t > &efficiencies)
Draw mean efficiency lines on histogram.
void DrawYPtHistos()
Main function for drawing Rapidity-Pt histograms.
string PrintNofObjects() const
Return string with number of objects statistics.
Double_t CalcEfficiency(const TH1 *histRec, const TH1 *histAcc, Double_t scale=1.) const
Calculate efficiency for two histograms.
void CalculatePionSuppressionHistos()
void DrawEfficiency(const string &canvasName, const string &histNamePattern, string(*labelFormatter)(const string &, Double_t))
Draw efficiency histogram.
string PrintTrackingEfficiency(Bool_t includeRich, Bool_t isPidEfficiency) const
Return string with tracking efficiency.
string PrintTrackHits() const
Return string with hits histogram statistics (nof all, true, fake hits in track/ring).
CbmLitTrackingQaReport()
Constructor.
void DrawAccAndRec(const string &canvasName, const string &histNamePattern)
Draw accepted and reconstructed tracks histograms.
void FillGlobalTrackVariants()
string PrintPionSuppression() const
Return string with pion suppression efficiency.
void DrawEfficiencyHistos()
Main function for drawing efficiency histograms.
void DrawHitsHistos()
Draw histograms for hits.
void DivideHistos(TH1 *histo1, TH1 *histo2, TH1 *histo3, Double_t scale)
Divide two histograms.
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.
TH1 * H1(const std::string &name) const
Return pointer to TH1 histogram.
CbmHistManager * HM() const
Return pointer to Histogram manager.
string FindAndReplace(const string &name, const string &oldSubstr, const string &newSubstr)
vector< string > Split(const string &name, char delimiter)
std::string NumberToString(const T &value, int precision=1)