Go to the documentation of this file.
14 #include <boost/assign/list_of.hpp>
16 using boost::assign::list_of;
25 return Split(name,
'_')[1];
29 return Split(name,
'_')[2];
38 return Split(name,
'_')[2];
42 return NumberToString<Double_t>(hist->GetEntries());
46 return NumberToString<Double_t>(hist->GetMean());
50 return NumberToString<Double_t>(hist->GetMean());
54 return NumberToString<Double_t>(hist->GetEntries() / nofEvents);
71 "hen_EventNo_TrackingQa",
78 Out() <<
PrintTable(
"Number of all, true and fake hits in tracks and rings",
79 "hth_.+_TrackHits_.*",
87 "hte_.*Rich.*_Eff_p");
89 "hte_((?!Rich).)*_Eff_p");
95 const string& tableName,
96 const string& pattern,
97 string (*rowNameFormatter)(
const string&),
98 string (*cellFormatter)(
const TH1*, Int_t))
const {
99 Int_t nofStudies =
HM().size();
100 vector<vector<TH1*>> histos(nofStudies);
101 for (Int_t
i = 0;
i < nofStudies;
i++) {
102 histos[
i] =
HM(
i)->H1Vector(pattern);
106 for (Int_t iHist = 0; iHist < histos[0].size(); iHist++) {
107 string cellName = rowNameFormatter(histos[0][iHist]->GetName());
108 vector<string> cells(nofStudies);
109 for (Int_t
i = 0;
i < nofStudies;
i++) {
110 Int_t nofEvents =
HM(
i)->H1(
"hen_EventNo_TrackingQa")->GetEntries();
111 cells[
i] = cellFormatter(histos[
i][iHist], nofEvents);
113 str +=
R()->
TableRow(list_of(cellName).range(cells));
121 const string& pattern)
const {
122 Int_t nofStudies =
HM().size();
123 vector<vector<TH1*>> histos(nofStudies);
124 for (Int_t
i = 0;
i < nofStudies;
i++) {
125 histos[
i] =
HM(
i)->H1Vector(pattern);
130 for (Int_t iHist = 0; iHist != histos[0].size(); iHist++) {
131 vector<string>
split =
Split(histos[0][iHist]->GetName(),
'_');
133 vector<string> cells(nofStudies);
134 for (Int_t
i = 0;
i < nofStudies;
i++) {
135 Int_t nofEvents =
HM(
i)->H1(
"hen_EventNo_TrackingQa")->GetEntries();
136 string effName = histos[0][iHist]->GetName();
139 Double_t acc =
HM(
i)->H1(accName)->GetEntries() / nofEvents;
140 Double_t rec =
HM(
i)->H1(recName)->GetEntries() / nofEvents;
141 Double_t eff = (acc != 0.) ? 100. * rec / acc : 0.;
142 string accStr = NumberToString<Double_t>(acc);
143 string recStr = NumberToString<Double_t>(rec);
144 string effStr = NumberToString<Double_t>(eff);
145 cells[
i] = effStr +
"(" + recStr +
"/" + accStr +
")";
147 str +=
R()->
TableRow(list_of(cellName).range(cells));
160 string histNamePattern =
"hte_.+_.+_(All|Electron|Muon)_Eff_(p|Angle)";
161 vector<TH1*> histos =
HM()[0]->H1Vector(histNamePattern);
162 for (UInt_t
i = 0;
i < histos.size();
i++) {
163 string histName = histos[
i]->GetName();
167 histNamePattern =
"hte_.+_.+_(All|Electron|Muon)_Acc_(p|Angle)";
168 histos =
HM()[0]->H1Vector(histNamePattern);
169 for (UInt_t
i = 0;
i < histos.size();
i++) {
170 string histName = histos[
i]->GetName();
174 histNamePattern =
"hte_.+_.+_(All|Electron|Muon)_Rec_(p|Angle)";
175 histos =
HM()[0]->H1Vector(histNamePattern);
176 for (UInt_t
i = 0;
i < histos.size();
i++) {
177 string histName = histos[
i]->GetName();
183 const string& histName) {
185 CreateCanvas(canvasName.c_str(), canvasName.c_str(), 600, 500);
189 Int_t nofStudies =
HM().size();
190 vector<string> labels(nofStudies);
191 vector<TH1*> histos(nofStudies);
192 vector<Double_t> efficiencies(nofStudies);
193 for (UInt_t iStudy = 0; iStudy < nofStudies; iStudy++) {
195 histos[iStudy] = hm->
H1(histName);
196 efficiencies[iStudy] =
201 + NumberToString<Double_t>(efficiencies[iStudy], 1) +
")";
209 const string& histName) {
211 CreateCanvas(canvasName.c_str(), canvasName.c_str(), 600, 500);
215 Int_t nofStudies =
HM().size();
216 vector<string> labels(nofStudies);
217 vector<TH1*> histos(nofStudies);
218 for (UInt_t iStudy = 0; iStudy < nofStudies; iStudy++) {
220 Int_t nofEvents = hm->
H1(
"hen_EventNo_TrackingQa")->GetEntries();
221 histos[iStudy] = hm->
H1(histName);
222 histos[iStudy]->Scale(1. / nofEvents);
223 Double_t nofObjects = histos[iStudy]->GetEntries() / nofEvents;
225 + NumberToString<Double_t>(nofObjects, 1) +
")";
238 histo3->Divide(histo1, histo2, 1., 1.,
"B");
239 histo3->Scale(scale);
243 const vector<TH1*>& histos,
244 const vector<Double_t>& efficiencies) {
245 assert(histos.size() != 0 && efficiencies.size() == histos.size());
247 Double_t minX = histos[0]->GetXaxis()->GetXmin();
248 Double_t maxX = histos[0]->GetXaxis()->GetXmax();
249 Int_t nofHistos = histos.size();
250 for (UInt_t iHist = 0; iHist < nofHistos; iHist++) {
252 new TLine(minX, efficiencies[iHist], maxX, efficiencies[iHist]);
253 line->SetLineWidth(1);
254 line->SetLineColor(histos[iHist]->GetLineColor());
261 Double_t scale)
const {
262 if (histAcc->Integral() == 0 || histRec->Integral() == 0) {
265 return scale * Double_t(histRec->Integral())
266 / Double_t(histAcc->Integral());
271 Int_t nofStudies =
HM().size();
272 for (Int_t iStudy = 0; iStudy < nofStudies; iStudy++) {
273 vector<TH1*> effHistos =
HM()[iStudy]->H1Vector(
"hte_.+_Eff_.+");
274 Int_t nofEffHistos = effHistos.size();
275 for (Int_t iHist = 0; iHist < nofEffHistos; iHist++) {
276 TH1* effHist = effHistos[iHist];
277 string effHistName = effHist->GetName();
278 string accHistName =
FindAndReplace(effHistName,
"_Eff_",
"_Acc_");
279 string recHistName =
FindAndReplace(effHistName,
"_Eff_",
"_Rec_");
281 HM()[iStudy]->H1(accHistName),
284 effHist->SetMinimum(0.);
285 effHist->SetMaximum(100.);
virtual std::string TableBegin(const std::string &caption, const std::vector< std::string > &colNames) const =0
Return string with table open tag.
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...
void DrawMeanEfficiencyLines(const std::vector< TH1 * > &histos, const std::vector< Double_t > &efficiencies)
Draw mean efficiency lines on histogram.
std::vector< std::string > & split(const std::string &s, char delim, std::vector< std::string > &elems)
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.
const std::string & GetStudyName(Int_t index) const
void DivideHistos(TH1 *histo1, TH1 *histo2, TH1 *histo3, Double_t scale)
Divide two histograms.
Base class for study reports.
virtual std::string DocumentBegin() const =0
Return string with open tags for document.
void DrawEfficiencyHistos()
Main function for drawing efficiency histograms.
string FindAndReplace(const string &name, const string &oldSubstr, const string &newSubstr)
virtual std::string TableRow(const std::vector< std::string > &row) const =0
Return string with table row tags.
void CalculateEfficiencyHistos()
Calculate efficiency histograms.
string NofGhostsRowNameFormatter(const string &name)
virtual std::string DocumentEnd() const =0
Return string with close tags of the document.
void DrawEfficiency(const string &canvasName, const string &histName)
Draw efficiency histogram.
string NofGhostsCellFormatter(const TH1 *hist, Int_t nofEvents)
string DefaultRowNameFormatter(const string &name)
const CbmReportElement * R() const
Accessor to CbmReportElement object. User has to write the report using available tags from CbmReport...
Helper functions for drawing 1D and 2D histograms and graphs.
Abstract class for basic report elements (headers, tables, images etc.).
CbmLitTrackingQaStudyReport()
Constructor.
void SetReportName(const std::string &name)
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 PrintCanvases() const
Print images created from canvases in the report.
string EventNoRowNameFormatter(const string &name)
string PrintEfficiencyTable(const string &tableName, const string &pattern) const
Return formated string with table of efficiency numbers.
Creates study report for tracking QA.
string NofObjectsRowNameFormatter(const string &name)
virtual std::string TableEnd() const =0
Return string with table close tag.
const std::vector< CbmHistManager * > & HM() const
Creates study report for tracking QA.
void DrawAccAndRec(const string &canvasName, const string &histName)
Draw accepted and reconstructed tracks histograms.
string EventNoCellFormatter(const TH1 *hist, Int_t)
ClassImp(CbmConverterManager) InitStatus CbmConverterManager
TH1 * H1(const std::string &name) const
Return pointer to TH1 histogram.
string TrackHitsRowNameFormatter(const string &name)
string NofObjectsCellFormatter(const TH1 *hist, Int_t)
const std::vector< std::string > & GetStudyNames() const
std::ostream & Out() const
All text output goes to this stream.
void SetDefaultDrawStyle()
virtual ~CbmLitTrackingQaStudyReport()
Destructor.
Double_t CalcEfficiency(const TH1 *histRec, const TH1 *histAcc, Double_t scale=1.) const
Calculate efficiency for two histograms.
virtual std::string Title(int size, const std::string &title) const =0
Return string with title.
std::string NumberToString(const T &value, int precision=1)
vector< string > Split(const string &name, char delimiter)
string TrackHitsCellFormatter(const TH1 *hist, Int_t)
void SetReportTitle(const std::string &title)
void Draw()
Inherited from CbmLitStudyReport.
void Create()
Inherited from CbmLitStudyReport.