14 #include <boost/assign/list_of.hpp>
18 using boost::assign::list_of;
30 Double_t efficiency) {
33 + NumberToString<Double_t>(efficiency, 1) +
")";
37 Double_t efficiency) {
40 + NumberToString<Double_t>(efficiency, 1) +
")";
44 Double_t efficiency) {
46 return split[1] +
" (" + NumberToString<Double_t>(efficiency, 1) +
")";
61 Out() <<
"Number of events: "
62 <<
HM()->
H1(
"hen_EventNo_TrackingQa")->GetEntries() << endl;
79 vector<TH1*> histos =
HM()->
H1Vector(
"hno_NofObjects_.+");
80 Int_t nofHistos = histos.size();
82 R()->
TableBegin(
"Number of objects per event", list_of(
"Name")(
"Value"));
83 for (Int_t iHist = 0; iHist < nofHistos; iHist++) {
84 string cellName =
Split(histos[iHist]->GetName(),
'_')[2];
86 list_of(cellName)(NumberToString<Int_t>(histos[iHist]->GetMean())));
93 vector<TH1*> histos =
HM()->
H1Vector(
"hth_.+_TrackHits_All");
94 Int_t nofHistos = histos.size();
96 R()->
TableBegin(
"Number of all, true and fake hits in tracks and rings",
97 list_of(
"")(
"all")(
"true")(
"fake")(
"true/all")(
"fake/all"));
98 for (Int_t iHist = 0; iHist < nofHistos; iHist++) {
99 string name = histos[iHist]->GetName();
100 string cellName =
Split(name,
'_')[1];
101 string all = NumberToString<Double_t>(histos[iHist]->GetMean(), 2);
102 string trueh = NumberToString<Double_t>(
104 string fakeh = NumberToString<Double_t>(
106 string toa = NumberToString<Double_t>(
108 string foa = NumberToString<Double_t>(
110 str +=
R()->
TableRow(list_of(cellName)(all)(trueh)(fakeh)(toa)(foa));
117 Double_t nofEvents =
HM()->
H1(
"hen_EventNo_TrackingQa")->GetEntries();
118 vector<TH1*> histos =
HM()->
H1Vector(
"hng_NofGhosts_.+");
119 Int_t nofHistos = histos.size();
121 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];
125 NumberToString<Double_t>(histos[iHist]->GetEntries() / nofEvents, 2)));
133 Bool_t isPidEfficiency)
const {
136 string effRegex =
"";
137 if (!isPidEfficiency)
138 effRegex = (includeRich) ?
"hte_.*Rich.*_Eff_p" :
"hte_((?!Rich).)*_Eff_p";
140 effRegex = (includeRich) ?
"hpe_.*Rich.*_Eff_p" :
"hpe_((?!Rich).)*_Eff_p";
142 vector<TH1*> histos =
HM()->
H1Vector(effRegex);
143 Int_t nofHistos = histos.size();
144 if (nofHistos == 0)
return "";
147 map<string, Int_t> catToCell;
148 for (Int_t iHist = 0; iHist < nofHistos; iHist++) {
149 string effName = histos[iHist]->GetName();
150 pair<string, Int_t> tmp =
151 make_pair(
Split(effName,
'_')[3], catToCell.size());
152 catToCell.insert(tmp);
154 Int_t nofCats = catToCell.size();
155 Int_t nofRows = nofHistos / nofCats;
157 vector<string> cat(nofCats);
158 map<string, Int_t>::const_iterator it;
159 for (it = catToCell.begin(); it != catToCell.end(); it++) {
160 cat[(*it).second] = (*it).first;
163 Int_t nofEvents =
HM()->
H1(
"hen_EventNo_TrackingQa")->GetEntries();
165 (isPidEfficiency) ?
"PID efficiency" :
"Tracking efficiency";
167 tableTitle +=
" (with RICH)";
169 tableTitle +=
" (without RICH)";
171 string str =
R()->
TableBegin(tableTitle, list_of(
string(
"")).range(cat));
172 Int_t histCounter = 0;
173 for (Int_t iRow = 0; iRow < nofRows; iRow++) {
174 vector<string> cells(nofCats);
176 for (Int_t iCat = 0; iCat < nofCats; iCat++) {
177 string effName = histos[histCounter]->GetName();
180 Double_t acc =
HM()->
H1(accName)->GetEntries() / nofEvents;
181 Double_t rec =
HM()->
H1(recName)->GetEntries() / nofEvents;
182 Double_t eff = (acc != 0.) ? 100. * rec / acc : 0.;
183 string accStr = NumberToString<Double_t>(acc, 2);
184 string recStr = NumberToString<Double_t>(rec, 2);
185 string effStr = NumberToString<Double_t>(eff);
187 cells[catToCell[
split[3]]] = effStr +
"(" + recStr +
"/" + accStr +
")";
191 str +=
R()->
TableRow(list_of(rowName).range(cells));
198 vector<TH1*> histos =
HM()->
H1Vector(
"hps_.*_PionSup_p");
199 Int_t nofHistos = histos.size();
200 if (nofHistos == 0)
return "";
202 Int_t nofEvents =
HM()->
H1(
"hen_EventNo_TrackingQa")->GetEntries();
204 list_of(
string(
""))(
"Pion suppression"));
205 for (Int_t iHist = 0; iHist < nofHistos; iHist++) {
206 string psName = histos[iHist]->GetName();
208 string recPionsName =
FindAndReplace(psName,
"_PionSup_",
"_RecPions_");
209 Double_t rec =
HM()->
H1(recName)->GetEntries() / nofEvents;
210 Double_t recPions =
HM()->
H1(recPionsName)->GetEntries() / nofEvents;
211 Double_t pionSup = (rec != 0.) ? recPions / rec : 0.;
212 string pionSupStr = NumberToString<Double_t>(pionSup) +
" ("
213 + NumberToString<Double_t>(recPions) +
"/"
214 + NumberToString<Double_t>(rec) +
")";
216 string rowName =
split[1];
217 string category =
split[2];
218 str +=
R()->
TableRow(list_of(rowName +
" - " + category)(pionSupStr));
239 DrawEfficiency(
"tracking_qa_global_tracking_efficiency_all_" + variant
241 "hte_Sts.*_" + variant +
"_All_Eff_p",
243 DrawEfficiency(
"tracking_qa_global_tracking_efficiency_muon_" + variant
245 "hte_Sts.*_" + variant +
"_Muon_Eff_p",
247 DrawEfficiency(
"tracking_qa_global_tracking_efficiency_electron_" + variant
249 "hte_Sts.*_" + variant +
"_Electron_Eff_p",
251 DrawEfficiency(
"tracking_qa_pid_efficiency_electron_" + variant +
"_p",
252 "hpe_((?!Sts_))Sts.*_" + variant +
"_Electron_Eff_p",
256 DrawEfficiency(
"tracking_qa_global_tracking_efficiency_" + variant
258 "hte_Sts.*_" + variant +
"_All_Eff_Angle",
260 if (variant.find(
"Rich") != string::npos) {
262 + variant +
"_RingXc",
263 "hte_Sts.*_" + variant +
"_Electron_Eff_RingXc",
266 + variant +
"_RingYc",
267 "hte_Sts.*_" + variant +
"_Electron_Eff_RingYc",
273 vector<string> localTrackVariants =
274 list_of(
"Sts")(
"Trd")(
"Much")(
"Rich")(
"Tof");
275 for (UInt_t
i = 0;
i < localTrackVariants.size();
i++) {
276 string variant = localTrackVariants[
i];
277 string re = (variant ==
"Sts")
278 ?
"hte_Sts_Sts_(All|Muon|Electron)_Eff"
279 :
"hte_" + variant +
"_.*_(All|Muon|Electron)_Eff";
280 if (variant ==
"Rich")
281 re =
"hte_" + variant +
"_.*_(Electron|ElectronReference)_Eff";
282 DrawEfficiency(
"tracking_qa_local_tracking_efficiency_" + variant +
"_p",
288 string re2 = (variant ==
"Sts") ?
"hte_Sts_Sts_All_Eff"
289 :
"hte_" + variant +
"_.*_All_Eff";
297 DrawEfficiency(
"tracking_qa_local_tracking_efficiency_Rich_RingNh",
298 "hte_Rich_Rich_Electron_Eff_RingNh",
301 "hte_Rich_Rich_Electron_Eff_BoA",
303 DrawEfficiency(
"tracking_qa_local_tracking_efficiency_Rich_RingXc",
304 "hte_Rich_Rich_Electron_Eff_RingXc",
306 DrawEfficiency(
"tracking_qa_local_tracking_efficiency_Rich_RingYc",
307 "hte_Rich_Rich_Electron_Eff_RingYc",
309 DrawYPt(
"tracking_qa_Rich_Rich_Electron_Eff_RingXcYc",
310 "hte_Rich_Rich_Electron_Eff_RingXcYc",
315 vector<string> accRecTracks = list_of(
"Sts")(
"Trd")(
"Much")(
"Tof");
316 for (UInt_t
i = 0;
i < accRecTracks.size();
i++) {
317 string variant = accRecTracks[
i];
319 string re = (variant ==
"Sts")
320 ?
"hte_Sts_Sts_(All|Muon|Electron)_(Acc|Rec)_Np"
321 :
"hte_" + variant +
"_.*_(All|Muon|Electron)_(Acc|Rec)_Np";
322 DrawAccAndRec(
"tracking_qa_local_acc_and_rec_" + variant +
"_Np", re);
324 re = (variant ==
"Sts") ?
"hte_Sts_Sts_(All)_(Acc|Rec)_p"
325 :
"hte_" + variant +
"_.*_(All)_(Acc|Rec)_p";
326 DrawAccAndRec(
"tracking_qa_local_acc_and_rec_" + variant +
"_All_p", re);
328 re = (variant ==
"Sts")
329 ?
"hte_Sts_Sts_(Muon|Electron)_(Acc|Rec)_p"
330 :
"hte_" + variant +
"_.*_(Muon|Electron)_(Acc|Rec)_p";
332 "tracking_qa_local_acc_and_rec_" + variant +
"_ElectronMuon_p", re);
337 "hps_((?!Rich)).*All_PionSup_p",
340 "hps_Rich.*All_PionSup_p",
345 if (
HM()->Exists(
"hng_NofGhosts_Rich_RingXcYc")) {
346 TCanvas* canvas =
CreateCanvas(
"tracking_qa_hng_NofGhosts_Rich_RingXcYc",
347 "tracking_qa_hng_NofGhosts_Rich_RingXcYc",
350 Int_t nofEvents =
HM()->
H1(
"hen_EventNo_TrackingQa")->GetEntries();
351 HM()->
H2(
"hng_NofGhosts_Rich_RingXcYc")->Scale(1. / nofEvents);
352 DrawH2(
HM()->
H2(
"hng_NofGhosts_Rich_RingXcYc"));
357 const string& canvasName,
358 const string& histNamePattern,
359 string (*labelFormatter)(
const string&, Double_t)) {
360 vector<TH1*> histos =
HM()->
H1Vector(histNamePattern);
361 if (histos.size() == 0)
return;
364 CreateCanvas(canvasName.c_str(), canvasName.c_str(), 600, 500);
368 Int_t nofHistos = histos.size();
369 vector<string> labels(nofHistos);
370 vector<Double_t> efficiencies(nofHistos);
371 for (UInt_t iHist = 0; iHist < nofHistos; iHist++) {
372 string name = histos[iHist]->GetName();
373 efficiencies[iHist] =
377 labels[iHist] = labelFormatter(name, efficiencies[iHist]);
385 const string& canvasName,
386 const string& histNamePattern,
387 string (*labelFormatter)(
const string&, Double_t)) {
388 vector<TH1*> histos =
HM()->
H1Vector(histNamePattern);
389 if (histos.size() == 0)
return;
392 CreateCanvas(canvasName.c_str(), canvasName.c_str(), 600, 500);
396 Int_t nofHistos = histos.size();
397 vector<string> labels(nofHistos);
398 vector<Double_t> ps(nofHistos);
399 for (UInt_t iHist = 0; iHist < nofHistos; iHist++) {
400 string name = histos[iHist]->GetName();
405 labels[iHist] = labelFormatter(name, ps[iHist]);
413 const vector<TH1*>& histos,
414 const vector<Double_t>& efficiencies) {
415 assert(histos.size() != 0 && efficiencies.size() == histos.size());
417 Double_t minX = histos[0]->GetXaxis()->GetXmin();
418 Double_t maxX = histos[0]->GetXaxis()->GetXmax();
419 Int_t nofHistos = histos.size();
420 for (UInt_t iHist = 0; iHist < nofHistos; iHist++) {
422 new TLine(minX, efficiencies[iHist], maxX, efficiencies[iHist]);
423 line->SetLineWidth(1);
424 line->SetLineColor(histos[iHist]->GetLineColor());
430 const string& histNamePattern) {
431 vector<TH1*> histos =
HM()->
H1Vector(histNamePattern);
432 if (histos.size() == 0)
return;
435 CreateCanvas(canvasName.c_str(), canvasName.c_str(), 600, 500);
439 Int_t nofEvents =
HM()->
H1(
"hen_EventNo_TrackingQa")->GetEntries();
440 Int_t nofHistos = histos.size();
441 vector<string> labels(nofHistos);
442 for (UInt_t iHist = 0; iHist < nofHistos; iHist++) {
443 TH1* hist = histos[iHist];
444 hist->Scale(1. / nofEvents);
445 string name = hist->GetName();
449 + NumberToString<Double_t>(hist->GetEntries() / nofEvents, 2) +
")";
459 string effHistName =
"hte_" + variant +
"_" + variant;
460 DrawYPt(
"tracking_qa_" + variant +
"_all_ypt",
461 effHistName +
"_All_Eff_YPt");
462 DrawYPt(
"tracking_qa_" + variant +
"_proton_ypt",
463 effHistName +
"_Proton_Eff_YPt");
464 DrawYPt(
"tracking_qa_" + variant +
"_pion_plus_ypt",
465 effHistName +
"_PionPlus_Eff_YPt");
466 DrawYPt(
"tracking_qa_" + variant +
"_pion_minus_ypt",
467 effHistName +
"_PionMinus_Eff_YPt");
468 DrawYPt(
"tracking_qa_" + variant +
"_kaon_plus_ypt",
469 effHistName +
"_KaonPlus_Eff_YPt");
470 DrawYPt(
"tracking_qa_" + variant +
"_kaon_minus_ypt",
471 effHistName +
"_KaonMinus_Eff_YPt");
476 const string& effHistName,
477 Bool_t drawOnlyEfficiency) {
478 string accHistName =
FindAndReplace(effHistName,
"_Eff_",
"_Acc_");
479 string recHistName =
FindAndReplace(effHistName,
"_Eff_",
"_Rec_");
481 if (!(
HM()->Exists(effHistName) &&
HM()->Exists(accHistName)
482 &&
HM()->Exists(recHistName)))
485 TH2* accHist =
HM()->
H2(accHistName);
486 TH2* recHist =
HM()->
H2(recHistName);
487 TH2* effHist =
HM()->
H2(effHistName);
489 if (drawOnlyEfficiency) {
491 CreateCanvas(canvasName.c_str(), canvasName.c_str(), 800, 800);
496 CreateCanvas(canvasName.c_str(), canvasName.c_str(), 1800, 600);
497 canvas->Divide(3, 1);
520 const string& hist) {
521 if (!(
HM()->Exists(hist +
"_All") &&
HM()->Exists(hist +
"_True")
522 &&
HM()->Exists(hist +
"_Fake") &&
HM()->Exists(hist +
"_TrueOverAll")
523 &&
HM()->Exists(hist +
"_FakeOverAll")))
527 CreateCanvas(canvasName.c_str(), canvasName.c_str(), 1200, 600);
528 canvas->Divide(2, 1);
532 TH1* hAll =
HM()->
H1(hist +
"_All");
533 TH1* hTrue =
HM()->
H1(hist +
"_True");
534 TH1* hFake =
HM()->
H1(hist +
"_Fake");
535 DrawH1(list_of(hAll)(hTrue)(hFake),
536 list_of(
"all: " + NumberToString<Double_t>(hAll->GetMean(), 1))(
537 "true: " + NumberToString<Double_t>(hTrue->GetMean(), 1))(
538 "fake: " + NumberToString<Double_t>(hFake->GetMean(), 1)),
548 TH1* hTrueOverAll =
HM()->
H1(hist +
"_TrueOverAll");
549 TH1* hFakeOverAll =
HM()->
H1(hist +
"_FakeOverAll");
551 list_of(hTrueOverAll)(hFakeOverAll),
552 list_of(
"true/all: " + NumberToString<Double_t>(hTrueOverAll->GetMean()))(
553 "fake/all: " + NumberToString<Double_t>(hFakeOverAll->GetMean())),
565 Double_t scale)
const {
566 if (histAcc->Integral() == 0 || histRec->Integral() == 0) {
569 return scale * Double_t(histRec->Integral())
570 / Double_t(histAcc->Integral());
576 vector<TH1*> histos =
HM()->
H1Vector(
"hte_.*_Eff_p");
577 Int_t nofHistos = histos.size();
578 set<string> variants;
579 for (Int_t iHist = 0; iHist < nofHistos; iHist++) {
580 string effName = histos[iHist]->GetName();
581 variants.insert(
Split(effName,
'_')[2]);
593 histo3->Divide(histo1, histo2, 1., 1.,
"B");
594 histo3->Scale(scale);
598 vector<TH1*> effHistos =
HM()->
H1Vector(
"(hte|hpe)_.+_Eff_.+");
599 Int_t nofEffHistos = effHistos.size();
600 for (Int_t iHist = 0; iHist < nofEffHistos; iHist++) {
601 TH1* effHist = effHistos[iHist];
602 string effHistName = effHist->GetName();
603 string accHistName =
FindAndReplace(effHistName,
"_Eff_",
"_Acc_");
604 string recHistName =
FindAndReplace(effHistName,
"_Eff_",
"_Rec_");
606 effHist->SetMinimum(0.);
607 effHist->SetMaximum(100.);
612 vector<TH1*> histos =
HM()->
H1Vector(
"hps_.+_PionSup_.+");
613 Int_t nofHistos = histos.size();
614 for (Int_t iHist = 0; iHist < nofHistos; iHist++) {
615 TH1* psHist = histos[iHist];
616 string psHistName = psHist->GetName();
617 string recHistName =
FindAndReplace(psHistName,
"_PionSup_",
"_Rec_");
618 string pionRecHistName =