/** * \file CbmLitTrackingQaReport.cxx * \author Semen Lebedev * \date 2011 */ #include "CbmLitTrackingQaReport.h" #include "CbmLitTrackingQaHistCreator.h" #include "../base/CbmLitPropertyTree.h" #include "CbmReportElement.h" #include "std/utils/CbmLitUtils.h" #include #include using std::endl; using std::vector; using std::make_pair; using boost::assign::list_of; using lit::NumberToString; using lit::FindAndReplace; using lit::Split; CbmLitTrackingQaReport::CbmLitTrackingQaReport(): fPT(NULL) { } CbmLitTrackingQaReport::~CbmLitTrackingQaReport() { } void CbmLitTrackingQaReport::Create( ostream& out) { fPT = new CbmLitPropertyTree(fQa); out.precision(3); out << fR->DocumentBegin(); out << fR->Title(0, fTitle); out << "Number of events: " << PrintValue("hen_EventNo_TrackingQa.entries") << endl; out << PrintNofObjects(); out << PrintTrackHits(); out << PrintTrackingEfficiency(false); out << PrintTrackingEfficiency(true); out << PrintNofGhosts(); out << PrintImages(".*tracking_qa_.*png"); out << fR->DocumentEnd(); delete fPT; } string CbmLitTrackingQaReport::PrintNofObjects() const { map properties = fPT->GetByPattern("hno_NofObjects_.+"); map::const_iterator it; string str = fR->TableBegin("Number of objects per event", list_of("Name")("Value")); for (it = properties.begin(); it != properties.end(); it++) { string cellName = Split(it->first, '_')[2]; str += fR->TableRow(list_of(cellName)(NumberToString(it->second))); } str += fR->TableEnd(); return str; } string CbmLitTrackingQaReport::PrintTrackHits() const { string str = fR->TableBegin("Number of all, true and fake hits in tracks and rings", list_of("")("all")("true")("fake")("true/all")("fake/all")); map properties = fPT->GetByPattern("hth_.+_TrackHits_All.*"); map::const_iterator it; for (it = properties.begin(); it != properties.end(); it++) { string name = it->first; string cellName = Split(name, '_')[1]; string all = NumberToString(it->second, 2); string trueh = NumberToString(fQa.get(FindAndReplace(name, "_All", "_True"), -1.), 2); string fakeh = NumberToString(fQa.get(FindAndReplace(name, "_All", "_Fake"), -1.), 2); string toa = NumberToString(fQa.get(FindAndReplace(name, "_All", "_TrueOverAll"), -1.), 2); string foa = NumberToString(fQa.get(FindAndReplace(name, "_All", "_FakeOverAll"), -1.), 2); str += fR->TableRow(list_of(cellName)(all)(trueh)(fakeh)(toa)(foa)); } str += fR->TableEnd(); return str; } string CbmLitTrackingQaReport::PrintNofGhosts() const { map properties = fPT->GetByPattern("hng_NofGhosts_.+"); map::const_iterator it; string str = fR->TableBegin("Number of ghosts per event", list_of("Name")("Value")); for (it = properties.begin(); it != properties.end(); it++) { string cellName = Split(it->first, '_')[2]; str += fR->TableRow(list_of(cellName)(NumberToString(it->second))); } str += fR->TableEnd(); return str; } string CbmLitTrackingQaReport::PrintTrackingEfficiency( Bool_t includeRich) const { // If includeRich == true than search for tracking efficiency histograms which contain "Rich" // otherwise search for tracking efficiency histograms excluding those which contain "Rich" string effRegex = (includeRich) ? "hte_.*Rich.*_Eff_p" : "hte_((?!Rich).)*_Eff_p"; map properties = fPT->GetByPattern(effRegex); if (properties.size() == 0) return ""; const vector& cat = (includeRich) ? CbmLitTrackingQaHistCreator::Instance()->GetRingCategories() : CbmLitTrackingQaHistCreator::Instance()->GetTrackCategories(); Int_t nofCats = cat.size(); Int_t nofRows = properties.size() / nofCats; // Maps category name to cell index map catToCell; for (Int_t iCat = 0; iCat < nofCats; iCat++) { catToCell.insert(make_pair(cat[iCat], iCat)); } string str = fR->TableBegin("Tracking efficiency", list_of(string("")).range(cat)); map::const_iterator it = properties.begin(); for (Int_t iRow = 0; iRow < nofRows; iRow++) { vector cells(nofCats); string rowName; for (Int_t iCat = 0; iCat < nofCats; iCat++) { string effName = it->first; string accName = FindAndReplace(effName, "_Eff_", "_Acc_") + ".entries"; string recName = FindAndReplace(effName, "_Eff_", "_Rec_") + ".entries"; string eff = NumberToString(fQa.get(effName, -1.)); string acc = NumberToString(fQa.get(accName, -1.)); string rec = NumberToString(fQa.get(recName, -1.)); vector split = Split(effName, '_'); cells[catToCell[split[3]]] = eff + "(" + rec + "/" + acc + ")"; it++; rowName = split[1] + " (" + split[2] + ")"; } str += fR->TableRow(list_of(rowName).range(cells)); } str += fR->TableEnd(); return str; }