30 vector<string> geoTestOmega8Pathes, vector<string> urqmdTestPathes,
31 vector<string> recoQaBoxPathes, vector<string> recoQaUrqmdPathes)
72 if (path ==
"")
return make_pair(0., 0.);
75 TFile* oldFile = gFile;
76 TDirectory* oldDir = gDirectory;
78 TFile* file =
new TFile(path.c_str(),
"READ");
79 if (file ==
nullptr)
return make_pair(0., 0.);
80 TH1D* hist = file->Get<TH1D>(histName.c_str());
81 if (hist ==
nullptr)
return make_pair(0., 0.);
82 double mean = hist->GetMean();
83 double rms = hist->GetRMS();
91 return make_pair(mean, rms);
95 const string& histName)
98 if (path ==
"")
return make_pair(0., 0.);
101 TFile* oldFile = gFile;
102 TDirectory* oldDir = gDirectory;
104 TFile* file =
new TFile(path.c_str(),
"READ");
105 if (file ==
nullptr)
return make_pair(0., 0.);
106 TH2D* hist = file->Get<TH2D>(histName.c_str());
107 if (hist ==
nullptr)
return make_pair(0., 0.);
108 TH1D* py = hist->ProjectionY((histName + to_string(iFile) +
"_py").c_str());
109 double mean = py->GetMean();
110 double rms = py->GetRMS();
118 return make_pair(mean, rms);
124 if (path ==
"")
return 0.;
127 TFile* oldFile = gFile;
128 TDirectory* oldDir = gDirectory;
130 TFile* file =
new TFile(path.c_str(),
"READ");
131 if (file ==
nullptr)
return 0.;
132 TH1* hist = file->Get<TH1>(histName.c_str());
133 if (hist ==
nullptr)
return 0.;
134 double entries = hist->GetEntries();
148 int nofParts,
int nofFilesPart)
150 string canvasName =
"richgeoopt_sim_" +
GetFileEnumName(fileEnum) +
"_" + histName + to_string(nofParts);
153 vector<string> legend;
154 double refValue = 0.;
155 for (
int iP = 0; iP < nofParts; iP++) {
157 GetFileEnumName(fileEnum) +
"_sim_" + histName +
"_" + to_string(nofParts) +
"_" + to_string(iP);
158 fHM->
Create1<TH1D>(histNameInd, histNameInd +
";Geometry;" + titleY, nofFilesPart, .5, nofFilesPart + .5);
159 for (
int iF = 0; iF < nofFilesPart; iF++) {
161 int ind = iP * nofFilesPart + iF;
163 value =
H1MeanRms(fileEnum, ind, histName).first;
165 value =
H1MeanRms(fileEnum, ind, histName).second;
171 value =
HEntries(fileEnum, ind, histName) / 1000.;
174 fHM->
H1(histNameInd)->SetBinContent(iF + 1, value);
176 hists.push_back(
fHM->
H1(histNameInd));
177 legend.push_back(to_string(iP));
186 const string& histName2,
const string& titleY,
double minY,
double maxY,
187 int nofParts,
int nofFilesPart,
double effCoeff)
190 "richgeoopt_sim_" +
GetFileEnumName(fileEnum) +
"_" + histName1 +
"_" + histName2 + to_string(nofParts);
193 vector<string> legend;
194 double refValue = 0.;
195 for (
int iP = 0; iP < nofParts; iP++) {
196 string histEffName =
GetFileEnumName(fileEnum) +
"_sim_" + histName1 +
"_" + histName2 +
"_" + to_string(nofParts)
197 +
"_" + to_string(iP);
199 fHM->
Create1<TH1D>(histEffName, histEffName +
";Geometry;" + titleY, nofFilesPart, .5, nofFilesPart + .5);
200 for (
int iF = 0; iF < nofFilesPart; iF++) {
201 int ind = iP * nofFilesPart + iF;
202 double entries1 =
HEntries(fileEnum, ind, histName1);
203 double entries2 =
HEntries(fileEnum, ind, histName2);
204 double value = (entries2 != 0) ? effCoeff * entries1 / entries2 : 0.;
206 fHM->
H1(histEffName)->SetBinContent(iF + 1, value);
208 hists.push_back(
fHM->
H1(histEffName));
209 legend.push_back(to_string(iP));
217 double maxZ,
int precision)
219 string canvasName =
"richgeoopt_sim_" +
GetFileEnumName(fileEnum) +
"_" + histName +
"_2d";
222 vector<string> camTilt = {
"0 deg",
"3 deg",
"6 deg",
"9 deg",
"12 deg",
"15 deg",
"18 deg",
"21 deg"};
223 int nofParts = camTilt.size();
227 double shift = 0.5 * 200. / 10.;
228 double refBinCenterX = -1., refBinCenterY = -1.;
229 double refBinWidthX = -1., refBinWidthY = -1.;
230 for (
int iP = 0; iP < nofParts; iP++) {
231 string histNameInd =
GetFileEnumName(fileEnum) +
"_sim_" + histName +
"_" + to_string(iP) +
"_2d";
232 fHM->
Create2<TH2D>(histNameInd, histNameInd +
";Shift CamY [mm];Shift CamZ [mm];" + titleZ, nofX, -100. - shift,
233 100 + shift, nofY, -100. - shift, 100 + shift);
234 for (
int iX = 0; iX < nofX; iX++) {
235 for (
int iY = 0; iY < nofY; iY++) {
237 int ind = iP * nofFilesPart + iX * nofX + iY;
240 value =
H1MeanRms(fileEnum, ind, histName).first;
242 value =
H1MeanRms(fileEnum, ind, histName).second;
248 value =
HEntries(fileEnum, ind, histName) / 1000.;
250 refBinCenterX =
fHM->
H2(histNameInd)->GetXaxis()->GetBinCenter(iX + 1);
251 refBinCenterY =
fHM->
H2(histNameInd)->GetYaxis()->GetBinCenter(iY + 1);
252 refBinWidthX =
fHM->
H2(histNameInd)->GetXaxis()->GetBinWidth(iX + 1);
253 refBinWidthY =
fHM->
H2(histNameInd)->GetYaxis()->GetBinWidth(iY + 1);
255 fHM->
H2(histNameInd)->SetBinContent(iX + 1, iY + 1, value);
261 fHM->
H2(histNameInd)->GetZaxis()->SetRangeUser(minZ, maxZ);
262 fHM->
H2(histNameInd)->SetMarkerSize(1.2);
264 if (refBinWidthX > 0. && refBinWidthY > 0.) {
273 const string& histName2,
const string& titleZ,
double minZ,
double maxZ,
274 double effCoeff,
int precision)
276 string canvasName =
"richgeoopt_sim_" +
GetFileEnumName(fileEnum) +
"_" + histName1 +
"_" + histName2 +
"_2d";
279 vector<string> camTilt = {
"0 deg",
"3 deg",
"6 deg",
"9 deg",
"12 deg",
"15 deg",
"18 deg",
"21 deg"};
280 int nofParts = camTilt.size();
284 double shift = 0.5 * 200. / 10.;
285 double refBinCenterX = -1., refBinCenterY = -1.;
286 double refBinWidthX = -1., refBinWidthY = -1.;
287 for (
int iP = 0; iP < nofParts; iP++) {
289 GetFileEnumName(fileEnum) +
"_sim_" + histName1 +
"_" + histName2 +
"_" + to_string(iP) +
"_2d";
290 fHM->
Create2<TH2D>(histNameInd, histNameInd +
";Shift CamY [mm];Shift CamZ [mm];" + titleZ, nofX, -100. - shift,
291 100 + shift, nofY, -100. - shift, 100 + shift);
292 for (
int iX = 0; iX < nofX; iX++) {
293 for (
int iY = 0; iY < nofY; iY++) {
294 int ind = iP * nofFilesPart + iX * nofX + iY;
296 double entries1 =
HEntries(fileEnum, ind, histName1);
297 double entries2 =
HEntries(fileEnum, ind, histName2);
298 double value = (entries2 != 0) ? effCoeff * entries1 / entries2 : 0.;
300 refBinCenterX =
fHM->
H2(histNameInd)->GetXaxis()->GetBinCenter(iX + 1);
301 refBinCenterY =
fHM->
H2(histNameInd)->GetYaxis()->GetBinCenter(iY + 1);
302 refBinWidthX =
fHM->
H2(histNameInd)->GetXaxis()->GetBinWidth(iX + 1);
303 refBinWidthY =
fHM->
H2(histNameInd)->GetYaxis()->GetBinWidth(iY + 1);
305 fHM->
H2(histNameInd)->SetBinContent(iX + 1, iY + 1, value);
311 fHM->
H2(histNameInd)->SetMarkerSize(1.2);
312 fHM->
H2(histNameInd)->GetZaxis()->SetRangeUser(minZ, maxZ);
314 if (refBinWidthX > 0. && refBinWidthY > 0.) {
324 for (
int i = 1; i <=
h->GetNbinsX(); i++) {
325 for (
int j = 1; j <=
h->GetNbinsY(); j++) {
326 auto t =
new TText(
h->GetXaxis()->GetBinCenter(i),
h->GetYaxis()->GetBinCenter(j),
331 t->SetTextColor(kBlack);
339 vector<string> camTilt = {
"0 deg",
"3 deg",
"6 deg",
"9 deg",
"12 deg",
"15 deg",
"18 deg",
"21 deg"};
340 bool drawLegend = (hist.size() == 1) ? false :
true;
341 DrawH1(hist, (hist.size() == camTilt.size()) ? camTilt : legend,
kLinear,
kLinear, drawLegend, 0.9, 0.75, 0.99, 0.99);
342 gPad->SetLeftMargin(0.1);
343 gPad->SetRightMargin(0.01);
344 hist[0]->GetYaxis()->SetTitleOffset(0.8);
345 hist[0]->GetYaxis()->SetRangeUser(minY, maxY);
351 double nMinY = minY + 0.8 * (maxY - minY);
355 for (
int i = 1; i <= 72; i++) {
356 TLine* line =
new TLine(i * 9 + .5, nMinY, i * 9 + .5, nMaxY);
357 line->SetLineColor(kGreen + 2);
358 line->SetLineWidth(2);
365 for (
int i = 1; i <= 8; i++) {
366 TLine* line =
new TLine(i * 81 + .5, nMinY, i * 81 + .5, nMaxY);
367 line->SetLineColor(kBlue + 2);
368 line->SetLineWidth(2);
378 TLine* line =
new TLine(0., value, 1e5, value);
379 line->SetLineColor(kGreen + 4);
380 line->SetLineWidth(1);
388 TBox* box =
new TBox(centerX - 0.5 * widthX, centerY - 0.5 * widthY, centerX + 0.5 * widthX, centerY + 0.5 * widthY);
389 box->SetLineColor(kGreen + 4);
390 box->SetLineWidth(2);
391 box->SetFillStyle(0);
406 nofFilesPartCamTilt);
412 nofFilesPartCamTilt);
414 24, 8, nofFilesPartCamTilt);
416 "Ring reco efficiency [%]", 84, 98, 8, nofFilesPartCamTilt, 100.);
418 "STS-RICH matching efficiency [%]", 80, 90, 8, nofFilesPartCamTilt, 100.);
420 "Ring reco efficiency [%]", 86, 100, 8, nofFilesPartCamTilt, 100.);
422 "STS-RICH matching efficiency [%]", 82, 94, 8, nofFilesPartCamTilt, 100.);
424 nofFilesPartCamTilt, 1.);
426 "El id (RICH) [%]", 80, 92, 8, nofFilesPartCamTilt, 100.);
428 nofFilesPartCamTilt, 100.);
430 nofFilesPartCamTilt, 100.);
442 "Ring reco efficiency [%]", 84, 98, 100., 1);
444 "STS-RICH matching efficiency [%]", 80, 90, 100., 1);
446 "Ring reco efficiency [%]", 86, 100, 100., 1);
448 "STS-RICH matching efficiency [%]", 82, 94, 100., 1);
452 "El id (RICH) [%]", 80, 92, 100., 1);
ClassImp(CbmConverterManager)
void DrawTextOnPad(const string &text, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
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)
void DrawH2(TH2 *hist, HistScale logx, HistScale logy, HistScale logz, const string &drawOpt)
Helper functions for drawing 1D and 2D histograms and graphs.
Creates comparison plots for RICH geometry testing.
CbmRichGeoTestOptFileEnum
CbmRichGeoTestOptHistEnum
Generates beam ions for transport simulation.
TCanvas * CreateCanvas(const std::string &name, const std::string &title, Int_t width, Int_t height)
Create and draw TCanvas and store pointer to it.
void SaveCanvasToImage(const std::string &outputDir, const std::string &options="png,eps")
Save all stored canvases to images.
TH2 * H2(const std::string &name) const
Return pointer to TH2 histogram.
void Create2(const std::string &name, const std::string &title, Int_t nofBinsX, Double_t minBinX, Double_t maxBinX, Int_t nofBinsY, Double_t minBinY, Double_t maxBinY)
Helper function for creation of 2-dimensional histograms and profiles. Template argument is a real ob...
void Create1(const std::string &name, const std::string &title, Int_t nofBins, Double_t minBin, Double_t maxBin)
Helper function for creation of 1-dimensional histograms and profiles. Template argument is a real ob...
TH1 * H1(const std::string &name) const
Return pointer to TH1 histogram.
void DrawMeanRms(CbmRichGeoTestOptFileEnum fileEnum, const string &histName, CbmRichGeoTestOptHistEnum histEnum, const string &titleY, double minY, double maxY, int nofParts, int nofFilesPart)
void SetFilePathes(vector< string > geoTestPathes, vector< string > geoTestOmega3Pathes, vector< string > geoTestOmega8Pathes, vector< string > urqmdTestPathes, vector< string > recoQaBoxPathes, vector< string > recoQaUrqmdPathes)
vector< string > fGeoTestBoxPathes
void DrawReferenceLineH1(double value)
void Draw(Option_t *option="")
string GetFilePath(CbmRichGeoTestOptFileEnum fileType, int iFile)
vector< string > fUrqmdTestPathes
double HEntries(CbmRichGeoTestOptFileEnum fileEnum, int iFile, const string &histName)
void DrawTextLabelsH2(TH2 *h, int precision)
CbmRichGeoTestOpt()
Constructor.
pair< double, double > H2ProjYMeanRms(CbmRichGeoTestOptFileEnum fileType, int iFile, const string &histName)
string GetFileEnumName(CbmRichGeoTestOptFileEnum fileEnum)
vector< string > fRecoQaBoxPathes
void DrawLines(bool drawCamTilt, bool drawCamY, double minY, double maxY)
virtual ~CbmRichGeoTestOpt()
Destructor.
void DrawMeanEff2D(CbmRichGeoTestOptFileEnum fileEnum, const string &histName1, const string &histName2, const string &titleZ, double minZ, double maxZ, double effCoeff, int precision)
void DrawMeanRms2D(CbmRichGeoTestOptFileEnum fileEnum, const string &histName, CbmRichGeoTestOptHistEnum histEnum, const string &titleZ, double minZ, double maxZ, int precision)
vector< string > fRecoQaUrqmdPathes
vector< string > fGeoTestOmega3Pathes
void DrawMeanEff(CbmRichGeoTestOptFileEnum fileEnum, const string &histName1, const string &histName2, const string &titleY, double minY, double maxY, int nofParts, int nofFilesPart, double effCoeff)
void DrawManyH1(const vector< TH1 * > &hist, const vector< string > &legend, double minY, double maxY)
pair< double, double > H1MeanRms(CbmRichGeoTestOptFileEnum fileType, int iFile, const string &histName)
void DrawReferenceBoxH2(double centerX, double centerY, double widthX, double widthY)
vector< string > fGeoTestOmega8Pathes
std::string NumberToString(const T &value, int precision=1)