20#include <boost/assign/list_of.hpp>
23using boost::assign::list_of;
37 vector<string> split = Split(name,
'_');
38 return split[1] +
":" + split[3];
45 return NumberToString<Double_t>(hist->GetEntries());
50 return NumberToString<Double_t>(hist->GetMean());
55 return NumberToString<Double_t>(hist->GetMean());
60 return NumberToString<Double_t>(hist->GetEntries() / nofEvents);
81 Out() <<
PrintTable(
"Number of all, true and fake hits in tracks and rings",
"hth_.+_TrackHits_.*",
91 string (*rowNameFormatter)(
const string&),
92 string (*cellFormatter)(
const TH1*, Int_t))
const
94 Int_t nofStudies =
HM().size();
95 vector<vector<TH1*>> histos(nofStudies);
96 for (Int_t i = 0; i < nofStudies; i++) {
97 histos[i] =
HM(i)->H1Vector(pattern);
100 for (UInt_t iHist = 0; iHist < histos[0].size(); iHist++) {
101 string cellName = rowNameFormatter(histos[0][iHist]->GetName());
102 vector<string> cells(nofStudies);
103 for (Int_t i = 0; i < nofStudies; i++) {
104 Int_t nofEvents =
HM(i)->H1(
"hen_EventNo_TrackingQa")->GetEntries();
105 cells[i] = cellFormatter(histos[i][iHist], nofEvents);
107 str +=
R()->
TableRow(list_of(cellName).range(cells));
115 Int_t nofStudies =
HM().size();
116 vector<vector<TH1*>> histos(nofStudies);
117 for (Int_t i = 0; i < nofStudies; i++) {
118 histos[i] =
HM(i)->H1Vector(pattern);
122 for (UInt_t iHist = 0; iHist != histos[0].size(); iHist++) {
123 vector<string> split = Split(histos[0][iHist]->GetName(),
'_');
124 string cellName = split[1] +
"(" + split[2] +
"):" + split[3];
125 vector<string> cells(nofStudies);
126 for (Int_t i = 0; i < nofStudies; i++) {
127 Int_t nofEvents =
HM(i)->H1(
"hen_EventNo_TrackingQa")->GetEntries();
128 string effName = histos[0][iHist]->GetName();
129 string accName = FindAndReplace(effName,
"_Eff_",
"_Acc_");
130 string recName = FindAndReplace(effName,
"_Eff_",
"_Rec_");
131 Double_t acc =
HM(i)->H1(accName)->GetEntries() / nofEvents;
132 Double_t rec =
HM(i)->H1(recName)->GetEntries() / nofEvents;
133 Double_t eff = (acc != 0.) ? 100. * rec / acc : 0.;
134 string accStr = NumberToString<Double_t>(acc);
135 string recStr = NumberToString<Double_t>(rec);
136 string effStr = NumberToString<Double_t>(eff);
137 cells[i] = effStr +
"(" + recStr +
"/" + accStr +
")";
139 str +=
R()->
TableRow(list_of(cellName).range(cells));
154 string histNamePattern =
"hte_.+_.+_(All|Electron|Muon)_Eff_(p|Angle)";
155 vector<TH1*> histos =
HM()[0]->H1Vector(histNamePattern);
156 for (UInt_t i = 0; i < histos.size(); i++) {
157 string histName = histos[i]->GetName();
161 histNamePattern =
"hte_.+_.+_(All|Electron|Muon)_Acc_(p|Angle)";
162 histos =
HM()[0]->H1Vector(histNamePattern);
163 for (UInt_t i = 0; i < histos.size(); i++) {
164 string histName = histos[i]->GetName();
168 histNamePattern =
"hte_.+_.+_(All|Electron|Muon)_Rec_(p|Angle)";
169 histos =
HM()[0]->H1Vector(histNamePattern);
170 for (UInt_t i = 0; i < histos.size(); i++) {
171 string histName = histos[i]->GetName();
178 TCanvas* canvas =
CreateCanvas(canvasName.c_str(), canvasName.c_str(), 600, 500);
182 Int_t nofStudies =
HM().size();
183 vector<string> labels(nofStudies);
184 vector<TH1*> histos(nofStudies);
185 vector<Double_t> efficiencies(nofStudies);
186 for (Int_t iStudy = 0; iStudy < nofStudies; iStudy++) {
188 histos[iStudy] = hm->
H1(histName);
189 efficiencies[iStudy] =
CalcEfficiency(hm->
H1(FindAndReplace(histName,
"_Eff_",
"_Rec_")),
190 hm->
H1(FindAndReplace(histName,
"_Eff_",
"_Acc_")), 100.);
191 labels[iStudy] =
GetStudyName(iStudy) +
"(" + NumberToString<Double_t>(efficiencies[iStudy], 1) +
")";
200 TCanvas* canvas =
CreateCanvas(canvasName.c_str(), canvasName.c_str(), 600, 500);
204 Int_t nofStudies =
HM().size();
205 vector<string> labels(nofStudies);
206 vector<TH1*> histos(nofStudies);
207 for (Int_t iStudy = 0; iStudy < nofStudies; iStudy++) {
209 Int_t nofEvents = hm->
H1(
"hen_EventNo_TrackingQa")->GetEntries();
210 histos[iStudy] = hm->
H1(histName);
211 histos[iStudy]->Scale(1. / nofEvents);
212 Double_t nofObjects = histos[iStudy]->GetEntries() / nofEvents;
213 labels[iStudy] =
GetStudyName(iStudy) +
"(" + NumberToString<Double_t>(nofObjects, 1) +
")";
224 histo3->Divide(histo1, histo2, 1., 1.,
"B");
225 histo3->Scale(scale);
229 const vector<Double_t>& efficiencies)
231 assert(histos.size() != 0 && efficiencies.size() == histos.size());
233 Double_t minX = histos[0]->GetXaxis()->GetXmin();
234 Double_t maxX = histos[0]->GetXaxis()->GetXmax();
235 Int_t nofHistos = histos.size();
236 for (Int_t iHist = 0; iHist < nofHistos; iHist++) {
237 TLine* line =
new TLine(minX, efficiencies[iHist], maxX, efficiencies[iHist]);
238 line->SetLineWidth(1);
239 line->SetLineColor(histos[iHist]->GetLineColor());
246 if (histAcc->Integral() == 0 || histRec->Integral() == 0) {
250 return scale * Double_t(histRec->Integral()) / Double_t(histAcc->Integral());
256 Int_t nofStudies =
HM().size();
257 for (Int_t iStudy = 0; iStudy < nofStudies; iStudy++) {
258 vector<TH1*> effHistos =
HM()[iStudy]->H1Vector(
"hte_.+_Eff_.+");
259 Int_t nofEffHistos = effHistos.size();
260 for (Int_t iHist = 0; iHist < nofEffHistos; iHist++) {
261 TH1* effHist = effHistos[iHist];
262 string effHistName = effHist->GetName();
263 string accHistName = FindAndReplace(effHistName,
"_Eff_",
"_Acc_");
264 string recHistName = FindAndReplace(effHistName,
"_Eff_",
"_Rec_");
265 DivideHistos(
HM()[iStudy]->H1(recHistName),
HM()[iStudy]->H1(accHistName), effHist, 100.);
266 effHist->SetMinimum(0.);
267 effHist->SetMaximum(100.);
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)
Helper functions for drawing 1D and 2D histograms and graphs.
string TrackHitsRowNameFormatter(const string &name)
string TrackHitsCellFormatter(const TH1 *hist, Int_t)
string NofObjectsCellFormatter(const TH1 *hist, Int_t)
string NofObjectsRowNameFormatter(const string &name)
string NofGhostsCellFormatter(const TH1 *hist, Int_t nofEvents)
string DefaultRowNameFormatter(const string &name)
string EventNoRowNameFormatter(const string &name)
string NofGhostsRowNameFormatter(const string &name)
string EventNoCellFormatter(const TH1 *hist, Int_t)
Creates study report for tracking QA.
Abstract class for basic report elements (headers, tables, images etc.).
TH1 * H1(const std::string &name) const
Return pointer to TH1 histogram.
Creates study report for tracking QA.
void CalculateEfficiencyHistos()
Calculate efficiency histograms.
virtual ~CbmLitTrackingQaStudyReport()
Destructor.
void DrawMeanEfficiencyLines(const std::vector< TH1 * > &histos, const std::vector< Double_t > &efficiencies)
Draw mean efficiency lines on histogram.
void DrawAccAndRec(const string &canvasName, const string &histName)
Draw accepted and reconstructed tracks histograms.
void DrawEfficiency(const string &canvasName, const string &histName)
Draw efficiency histogram.
string PrintTable(const string &tableName, const string &pattern, string(*rowNameFormatter)(const string &), string(*cellFormatter)(const TH1 *, Int_t)) const
Return formated string with table of numbers.
string PrintEfficiencyTable(const string &tableName, const string &pattern) const
Return formated string with table of efficiency numbers.
CbmLitTrackingQaStudyReport()
Constructor.
void Draw()
Inherited from CbmLitStudyReport.
Double_t CalcEfficiency(const TH1 *histRec, const TH1 *histAcc, Double_t scale=1.) const
Calculate efficiency for two histograms.
void Create()
Inherited from CbmLitStudyReport.
void DrawEfficiencyHistos()
Main function for drawing efficiency histograms.
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.
void SetReportTitle(const std::string &title)
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 study reports.
const std::vector< std::string > & GetStudyNames() const
const std::vector< CbmHistManager * > & HM() const
const std::string & GetStudyName(Int_t index) const
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)