22#include <boost/assign/list_of.hpp>
25using boost::assign::list_of;
30using std::stringstream;
36 (histName.find(
"_Eff_") != string::npos)
38 hm->
H1(FindAndReplace(histName,
"_Eff_",
"_Acc_")), 100.)
40 hm->
H1(FindAndReplace(histName,
"_CloneProb_",
"_Acc_")), 100.);
41 vector<string> split = Split(histName,
'_');
42 return split[1] +
":" + split[3] +
"(" + NumberToString<Double_t>(efficiency, 1) +
")";
47 Int_t nofEvents = hm->
H1(
"hen_EventNo_ClusteringQa")->GetEntries();
48 vector<string> split = Split(histName,
'_');
49 return split[3] +
" (" + NumberToString<Double_t>(hm->
H1(histName)->GetEntries() / nofEvents, 1) +
")";
62 Out() <<
"Number of events: " <<
HM()->
H1(
"hen_EventNo_ClusteringQa")->GetEntries() << endl;
72 vector<TH1*> histos =
HM()->
H1Vector(
"hno_NofObjects_.+_Event");
73 Int_t nofHistos = histos.size();
74 string str =
R()->
TableBegin(
"Number of objects per event", list_of(
"Name")(
"Value"));
75 for (Int_t iHist = 0; iHist < nofHistos; iHist++) {
76 string cellName = Split(histos[iHist]->GetName(),
'_')[2];
77 str +=
R()->
TableRow(list_of(cellName)(NumberToString<Int_t>(histos[iHist]->GetMean())));
104 DrawH1ByPattern(
"hpa_.*(Digi|Cluster|Hit)_NofPointsIn(Digi|Cluster|Hit)_H1");
123 if (!
HM()->Exists(
"hno_NofObjects_" + detName +
"Points_" + parameter))
return;
124 string canvasName =
GetReportName() +
"_NofObjects_" + detName +
"_" + parameter;
125 TCanvas* canvas =
CreateCanvas(canvasName.c_str(), canvasName.c_str(), 800, 500);
128 vector<string> labels = list_of(
"Points")(
"Digis")(
"Clusters")(
"Hits");
129 vector<TH1*> histos = list_of(
HM()->
H1(
"hno_NofObjects_" + detName +
"Points_" + parameter))(
130 HM()->
H1(
"hno_NofObjects_" + detName +
"Digis_" + parameter))(
131 HM()->
H1(
"hno_NofObjects_" + detName +
"Clusters_" + parameter));
132 if (
HM()->Exists(
"hno_NofObjects_" + detName +
"PixelHits_" + parameter))
133 histos.push_back(
HM()->
H1(
"hno_NofObjects_" + detName +
"PixelHits_" + parameter));
134 else if (
HM()->Exists(
"hno_NofObjects_" + detName +
"StrawHits_" + parameter))
135 histos.push_back(
HM()->
H1(
"hno_NofObjects_" + detName +
"StrawHits_" + parameter));
136 else if (
HM()->Exists(
"hno_NofObjects_" + detName +
"Hits_" + parameter))
137 histos.push_back(
HM()->
H1(
"hno_NofObjects_" + detName +
"Hits_" + parameter));
143 if (!(
HM()->Exists(
"hrp_" + detName +
"_ResidualX_H2") &&
HM()->Exists(
"hrp_" + detName +
"_ResidualY_H2")
144 &&
HM()->Exists(
"hrp_" + detName +
"_ResidualT_H2") &&
HM()->Exists(
"hrp_" + detName +
"_PullX_H2")
145 &&
HM()->Exists(
"hrp_" + detName +
"_PullY_H2") &&
HM()->Exists(
"hrp_" + detName +
"_PullT_H2")))
147 vector<string> par = list_of(
"ResidualX")(
"ResidualY")(
"ResidualT")(
"PullX")(
"PullY")(
"PullT");
148 Int_t nofCanvases = par.size();
149 for (Int_t iCanvas = 0; iCanvas < nofCanvases; iCanvas++) {
150 string histName =
"hrp_" + detName +
"_" + par[iCanvas] +
"_H2";
151 TH2* hist =
HM()->
H2(histName);
152 string canvasName =
GetReportName() +
"_" + histName +
"_station";
153 TCanvas* canvas =
CreateCanvas(canvasName.c_str(), canvasName.c_str(), 1600, 900);
155 Int_t nofColumns = 5;
156 Int_t nofRows = (nofBins / nofColumns) + ((nofBins % 5 == 0) ? 0 : 1);
157 canvas->Divide(nofColumns, nofRows);
159 std::cout << nofBins <<
" " << nofColumns <<
" " << nofRows << std::endl;
160 for (Int_t iBin = 1; iBin <= nofBins; iBin++) {
162 ss << histName <<
"_" << iBin <<
"_py";
163 TH1* projY = hist->ProjectionY(ss.str().c_str(), iBin, iBin);
164 projY->SetNameTitle(ss.str().c_str(), ss.str().c_str());
165 projY->SetXTitle(par[iCanvas].c_str());
166 projY->SetYTitle(
"Yield");
177 if (histAcc->Integral() == 0 || histRec->Integral() == 0) {
181 return scale * Double_t(histRec->Integral()) / Double_t(histAcc->Integral());
187 Int_t nofEvents =
HM()->
H1(
"hen_EventNo_ClusteringQa")->GetEntries();
215 histo3->Divide(histo1, histo2, 1., 1.,
"B");
216 histo3->Scale(scale);
221 vector<TH1*> effHistos =
HM()->
H1Vector(
"hhe_.+_" + eff +
"_.+");
222 Int_t nofEffHistos = effHistos.size();
223 for (Int_t iHist = 0; iHist < nofEffHistos; iHist++) {
224 TH1* effHist = effHistos[iHist];
225 string effHistName = effHist->GetName();
226 string accHistName = FindAndReplace(effHistName,
"_" + eff +
"_",
"_" + acc +
"_");
227 string recHistName = FindAndReplace(effHistName,
"_" + eff +
"_",
"_" + rec +
"_");
229 effHist->SetMinimum(0.);
230 effHist->SetMaximum(100.);
ClassImp(CbmConverterManager)
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 DefaultAccAndRecLabelFormatter(const string &histName, const CbmHistManager *hm)
string DefaultHitEfficiencyLabelFormatter(const string &histName, const CbmHistManager *hm)
Simulation report for clustering QA.
Abstract class for basic report elements (headers, tables, images etc.).
void ShrinkEmptyBinsH1ByPattern(const std::string &pattern)
Shrink empty bins in H1.
void ShrinkEmptyBinsH2ByPattern(const std::string &pattern)
Shrink empty bins in H2.
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.
void ScaleByPattern(const std::string &pattern, Double_t scale)
Scale histograms which name matches specified pattern.
void NormalizeToIntegralByPattern(const std::string &pattern)
Normalize histograms to integral which name matches specified pattern.
TH1 * H1(const std::string &name) const
Return pointer to TH1 histogram.
Simulation report for clustering QA.
CbmLitClusteringQaReport()
Constructor.
void ScaleAndShrinkHistograms()
void DivideHistos(TH1 *histo1, TH1 *histo2, TH1 *histo3, Double_t scale)
virtual void Create()
Inherited from CbmSimulationReport.
void CalculateEfficiencyHistos(const string &acc, const string &rec, const string &eff)
virtual ~CbmLitClusteringQaReport()
Destructor.
virtual void Draw()
Inherited from CbmSimulationReport.
void DrawResidualsAndPulls(const string &detName)
string PrintNofObjects() const
Print number of objects table.
static Double_t CalcEfficiency(const TH1 *histRec, const TH1 *histAcc, Double_t scale)
void DrawNofObjectsHistograms(const string &detName, const string ¶meter)
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 std::string & GetReportName() const
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.
void DrawH1ByPattern(const std::string &histNamePattern)
Select by pattern TH1 histograms and draw each histogram on separate canvas.
TH1 * H1(const std::string &name) const
Return pointer to TH1 histogram.
CbmHistManager * HM() const
Return pointer to Histogram manager.
void DrawH2ByPattern(const std::string &histNamePattern, HistScale logx=kLinear, HistScale logy=kLinear, HistScale logz=kLinear, const std::string &drawOpt="")
Select by pattern TH2 histograms and draw each histogram on separate canvas.
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)