9 using namespace RecoBTag;
19 const int& nBins = theHisto->GetSize();
21 if (iBin < 0 || iBin >= nBins)
25 return theHisto->GetBinWidth(1);
27 if (iBin == nBins - 1)
28 return theHisto->GetBinWidth(nBins - 2);
30 return theHisto->GetBinWidth(iBin);
39 double histoIntegral = 0.0;
40 const int& nBins = theHisto->GetSize();
45 for (
int iBin = 0; iBin != nBins; ++iBin) {
47 histoIntegral += (*theHisto)[iBin] * binWidth;
56 TArrayF& theNormalizedArray,
57 TArrayF& theLeftOfBinArray,
58 TArrayF& theBinWidthArray) {
59 const int& nBins = theHisto->GetSize();
62 if (nBins == theNormalizedArray.GetSize() && nBins == theLeftOfBinArray.GetSize() &&
63 nBins == theBinWidthArray.GetSize()) {
66 for (
int iBin = 0; iBin != nBins; ++iBin) {
67 theNormalizedArray[iBin] = (*theHisto)[iBin] / histoIntegral;
68 theLeftOfBinArray[iBin] = theHisto->GetBinLowEdge(iBin);
73 cout <<
"============>>>>>>>>>>>>>>>>" << endl
74 <<
"============>>>>>>>>>>>>>>>>" << endl
75 <<
"============>>>>>>>>>>>>>>>>" << endl
76 <<
"============>>>>>>>>>>>>>>>>" << endl
77 <<
"============>>>>>>>>>>>>>>>> HistoToNormalizedArrays failed: not equal sizes of all arrays!!" << endl
78 <<
"============>>>>>>>>>>>>>>>>" << endl
79 <<
"============>>>>>>>>>>>>>>>>" << endl
80 <<
"============>>>>>>>>>>>>>>>>" << endl
81 <<
"============>>>>>>>>>>>>>>>>" << endl;
88 double arrayIntegral = 0.0;
89 const int& nBins = theArray.GetSize();
91 for (
int iBin = 0; iBin != nBins; ++iBin) {
92 arrayIntegral += theArray[iBin] * theBinWidth[iBin];
114 canvas->Print(psFile.c_str());
115 if (!epsFile.empty())
116 canvas->Print(epsFile.c_str(),
"eps");
118 const std::string& rootVersion(gROOT->GetVersion());
119 const bool& rootCanGif = rootVersion.find(
'4') == 0 || rootVersion.find(
'5') == 0;
120 if (!gifFile.empty()) {
121 if (!(gROOT->IsBatch()) || rootCanGif) {
122 cout <<
"--> Print directly gif!" << endl;
123 canvas->Print(gifFile.c_str(),
"gif");
125 if (!epsFile.empty()) {
126 cout <<
"--> Print gif via scripts!" << endl;
127 const std::string& executeString1 =
"pstopnm -ppm -xborder 0 -yborder 0 -portrait " + epsFile;
128 gSystem->Exec(executeString1.c_str());
130 const std::string& executeString2 =
"ppmtogif " + ppmFile +
" > " + gifFile;
131 gSystem->Exec(executeString2.c_str());
132 const std::string& executeString3 =
"rm " + ppmFile;
133 gSystem->Exec(executeString3.c_str());
152 histos.Add((TH1F*)histoFile->Get(nameB.c_str()));
153 histos.Add((TH1F*)histoFile->Get(nameC.c_str()));
154 histos.Add((TH1F*)histoFile->Get(nameDUSG.c_str()));
200 cout <<
"====>>>> ToolsC:checkCreateDirectory() : " << endl;
201 int exists = gSystem->Exec((
"ls -d " + directory).c_str());
204 cout <<
"====>>>> ToolsC:checkCreateDirectory() : The directory does not exist : " << directory << endl;
205 cout <<
"====>>>> ToolsC:checkCreateDirectory() : I'll try to create it" << endl;
206 const int&
create = gSystem->Exec((
"mkdir " + directory).c_str());
208 cout <<
"====>>>> ToolsC:checkCreateDirectory() : Creation of directory failed : " << directory << endl
209 <<
"====>>>> ToolsC:checkCreateDirectory() : Please check your write permissions!" << endl;
211 cout <<
"====>>>> ToolsC:checkCreateDirectory() : Creation of directory successful!" << endl;
213 cout <<
"====>>>> ToolsC:checkCreateDirectory() : " << endl;
214 exists = gSystem->Exec((
"ls -d " + directory).c_str());
216 cout <<
"ToolsC:checkCreateDirectory() : However, it still doesn't exist!?" << endl;
235 const int& nBins = histo->GetNbinsX() - 2;
240 const float&
maxInHisto = histo->GetMaximum();
241 const float&
minInHisto = histo->GetMinimum();
244 if (yVal <= maxInHisto) {
245 yClosestInit = maxInHisto + 1;
248 yClosestInit = minInHisto - 1.0;
255 for (
int iBin = 1; iBin <= nBins; ++iBin) {
256 const float&
yBin = histo->GetBinContent(iBin);
257 if (fabs(yBin - yVal) < fabs(yClosest - yVal)) {
264 if (yClosest < yLow || yClosest > yHigh) {
269 if (iBinClosest == iBinClosestInit) {
270 cout <<
"====>>>> ToolsC=>findBinClosestYValue() : WARNING: returned bin is the initialization bin!!" << endl;
283 const vector<double>& zVal) {
294 const int& nBinsX = histoY->GetNbinsX() - 2;
295 const int& nBinsY = histoY->GetNbinsY() - 2;
300 const float&
maxInHisto = histoY->GetMaximum();
301 const float&
minInHisto = histoY->GetMinimum();
305 if (yVal <= maxInHisto) {
317 for (
int iBinX = 1; iBinX <= nBinsX; ++iBinX) {
318 for (
int iBinY = 1; iBinY <= nBinsY; ++iBinY) {
319 const float&
yBin = histoY->GetBinContent(iBinX, iBinY);
320 for (
unsigned int i = 0;
i < zVal.size();
i++) {
321 if (fabs(yBin - yVal) < fabs(yClosest[
i] - yVal)) {
322 const float& zLow = zVal[
i] - (yVal - yLow);
323 const float& zHigh = zVal[
i] + (yHigh - yVal);
324 const float& zBin = histoZ->GetBinContent(iBinX, iBinY);
325 if (zBin < zLow || zBin > zHigh)
334 for (
unsigned int i = 0;
i < yClosest.size();
i++) {
335 if (yClosest[
i] < yLow || yClosest[
i] > yHigh)
344 TStyle*
tdrStyle =
new TStyle(
"tdrStyle",
"Style for P-TDR");
347 tdrStyle->SetCanvasBorderMode(0);
348 tdrStyle->SetCanvasColor(kWhite);
349 tdrStyle->SetCanvasDefH(600);
350 tdrStyle->SetCanvasDefW(600);
351 tdrStyle->SetCanvasDefX(0);
352 tdrStyle->SetCanvasDefY(0);
355 tdrStyle->SetPadBorderMode(0);
357 tdrStyle->SetPadColor(kWhite);
358 tdrStyle->SetPadGridX(
false);
359 tdrStyle->SetPadGridY(
false);
360 tdrStyle->SetGridColor(0);
361 tdrStyle->SetGridStyle(3);
362 tdrStyle->SetGridWidth(1);
365 tdrStyle->SetFrameBorderMode(0);
366 tdrStyle->SetFrameBorderSize(1);
367 tdrStyle->SetFrameFillColor(0);
368 tdrStyle->SetFrameFillStyle(0);
369 tdrStyle->SetFrameLineColor(1);
370 tdrStyle->SetFrameLineStyle(1);
371 tdrStyle->SetFrameLineWidth(1);
376 tdrStyle->SetHistLineColor(1);
377 tdrStyle->SetHistLineStyle(0);
378 tdrStyle->SetHistLineWidth(1);
382 tdrStyle->SetEndErrorSize(15);
384 tdrStyle->SetErrorX(1);
386 tdrStyle->SetMarkerStyle(21);
387 tdrStyle->SetMarkerSize(1.);
390 tdrStyle->SetOptFit(0);
391 tdrStyle->SetFitFormat(
"5.4g");
392 tdrStyle->SetFuncColor(2);
393 tdrStyle->SetFuncStyle(1);
394 tdrStyle->SetFuncWidth(1);
397 tdrStyle->SetOptDate(0);
402 tdrStyle->SetOptFile(1111);
403 tdrStyle->SetOptStat(0);
404 tdrStyle->SetStatColor(kWhite);
405 tdrStyle->SetStatFont(42);
406 tdrStyle->SetStatFontSize(0.025);
407 tdrStyle->SetStatTextColor(1);
408 tdrStyle->SetStatFormat(
"6.4g");
409 tdrStyle->SetStatBorderSize(1);
410 tdrStyle->SetStatH(0.2);
411 tdrStyle->SetStatW(0.15);
417 tdrStyle->SetPadTopMargin(0.05);
418 tdrStyle->SetPadBottomMargin(0.13);
419 tdrStyle->SetPadLeftMargin(0.16);
420 tdrStyle->SetPadRightMargin(0.02);
424 tdrStyle->SetOptTitle(0);
425 tdrStyle->SetTitleW(0.8);
427 tdrStyle->SetTitleFont(42);
428 tdrStyle->SetTitleColor(1);
429 tdrStyle->SetTitleTextColor(1);
430 tdrStyle->SetTitleFillColor(10);
431 tdrStyle->SetTitleFontSize(0.05);
440 tdrStyle->SetTitleColor(1,
"XYZ");
441 tdrStyle->SetTitleFont(42,
"XYZ");
442 tdrStyle->SetTitleSize(0.06,
"XYZ");
445 tdrStyle->SetTitleXOffset(0.75);
446 tdrStyle->SetTitleYOffset(0.75);
451 tdrStyle->SetLabelColor(1,
"XYZ");
452 tdrStyle->SetLabelFont(42,
"XYZ");
453 tdrStyle->SetLabelOffset(0.007,
"XYZ");
454 tdrStyle->SetLabelSize(0.05,
"XYZ");
458 tdrStyle->SetAxisColor(1,
"XYZ");
459 tdrStyle->SetStripDecimals(kTRUE);
460 tdrStyle->SetTickLength(0.03,
"XYZ");
461 tdrStyle->SetNdivisions(510,
"XYZ");
462 tdrStyle->SetPadTickX(1);
463 tdrStyle->SetPadTickY(1);
466 tdrStyle->SetOptLogx(0);
467 tdrStyle->SetOptLogy(0);
468 tdrStyle->SetOptLogz(0);
471 tdrStyle->SetPaperSize(21., 28.);
492 tdrStyle->SetPadGridX(gridOn);
493 tdrStyle->SetPadGridY(gridOn);
void PrintCanvasHistos(TCanvas *canvas, const std::string &psFile, const std::string &epsFile, const std::string &gifFile)
bool flavourIsG(const int &flav)
bool flavourIsNI(const int &flav)
double IntegrateHistogram(const TH1F *theHisto)
bool flavourIsD(const int &flav)
int findBinClosestYValue(const TH1F *, const float &yVal, const float &yLow, const float &yHigh)
bool flavourIsC(const int &flav)
bool flavourIsU(const int &flav)
int checkCreateDirectory(const std::string &)
TObjArray getHistArray(TFile *histoFile, const std::string &baseName)
void tdrGrid(const bool &gridOn)
double IntegrateArray(const TArrayF &theArray, const TArrayF &theBinWidth)
double HistoBinWidth(const TH1F *theHisto, const int &iBin)
std::string flavour(const int &flav)
bool flavourIsB(const int &flav)
bool flavourIsDUSG(const int &flav)
void HistoToNormalizedArrays(const TH1F *theHisto, TArrayF &theNormalizedArray, TArrayF &theLeftOfBinArray, TArrayF &theBinWidthArray)
bool flavourIsS(const int &flav)
bool flavourIsDUS(const int &flav)
std::string itos(const int &i)
std::vector< int > findBinClosestYValueAtFixedZ(const TH2F *, const float &yVal, const float &yLow, const float &yHigh, const TH2F *, const std::vector< double > &zVal)