9 using namespace RecoBTag;
20 const int& nBins = theHisto->GetSize() ;
22 if ( iBin < 0 || iBin >= nBins )
return 0.0 ;
24 if ( iBin == 0 )
return theHisto->GetBinWidth ( 1 ) ;
26 if ( iBin == nBins - 1 )
return theHisto->GetBinWidth ( nBins - 2 ) ;
28 return theHisto->GetBinWidth ( iBin ) ;
38 double histoIntegral = 0.0 ;
39 const int& nBins = theHisto->GetSize() ;
44 for (
int iBin = 0 ; iBin != nBins ; ++iBin ) {
46 histoIntegral += (*theHisto)[iBin] * binWidth ;
49 return histoIntegral ;
59 const int& nBins = theHisto->GetSize() ;
62 if ( nBins == theNormalizedArray.GetSize() &&
63 nBins == theLeftOfBinArray .GetSize() &&
64 nBins == theBinWidthArray .GetSize() ) {
68 for (
int iBin = 0 ; iBin != nBins ; ++iBin ) {
69 theNormalizedArray[iBin] = (*theHisto)[iBin] / histoIntegral ;
70 theLeftOfBinArray [iBin] = theHisto->GetBinLowEdge(iBin) ;
76 cout <<
"============>>>>>>>>>>>>>>>>" << endl
77 <<
"============>>>>>>>>>>>>>>>>" << endl
78 <<
"============>>>>>>>>>>>>>>>>" << endl
79 <<
"============>>>>>>>>>>>>>>>>" << endl
80 <<
"============>>>>>>>>>>>>>>>> HistoToNormalizedArrays failed: not equal sizes of all arrays!!" << endl
81 <<
"============>>>>>>>>>>>>>>>>" << endl
82 <<
"============>>>>>>>>>>>>>>>>" << endl
83 <<
"============>>>>>>>>>>>>>>>>" << endl
84 <<
"============>>>>>>>>>>>>>>>>" << endl ;
95 double arrayIntegral = 0.0 ;
96 const int& nBins = theArray.GetSize() ;
98 for (
int iBin = 0 ; iBin != nBins ; ++iBin ) {
99 arrayIntegral += theArray[iBin] * theBinWidth[iBin] ;
102 return arrayIntegral ;
119 if ( psFile !=
"" ) canvas->Print ( psFile.c_str() ) ;
120 if ( epsFile !=
"" ) canvas->Print ( epsFile.c_str() ,
"eps" ) ;
122 const std::string& rootVersion ( gROOT->GetVersion() ) ;
123 const bool& rootCanGif = rootVersion.find(
"4") == 0 || rootVersion.find(
"5") == 0 ;
124 if ( gifFile !=
"" ) {
125 if ( !(gROOT->IsBatch()) || rootCanGif ) {
126 cout <<
"--> Print directly gif!" << endl ;
127 canvas->Print ( gifFile.c_str() ,
"gif" ) ;
130 if ( epsFile !=
"" ) {
131 cout <<
"--> Print gif via scripts!" << endl ;
132 const std::string& executeString1 =
"pstopnm -ppm -xborder 0 -yborder 0 -portrait " + epsFile ;
133 gSystem->Exec(executeString1.c_str()) ;
135 const std::string& executeString2 =
"ppmtogif " + ppmFile +
" > " + gifFile ;
136 gSystem->Exec(executeString2.c_str()) ;
137 const std::string& executeString3 =
"rm " + ppmFile ;
138 gSystem->Exec(executeString3.c_str()) ;
158 histos.Add ( (TH1F*)histoFile->Get( nameB.c_str() ) ) ;
159 histos.Add ( (TH1F*)histoFile->Get( nameC.c_str() ) ) ;
160 histos.Add ( (TH1F*)histoFile->Get( nameDUSG.c_str() ) ) ;
206 cout <<
"====>>>> ToolsC:checkCreateDirectory() : " << endl ;
207 int exists = gSystem->Exec ( (
"ls -d " + directory).c_str() ) ;
210 cout <<
"====>>>> ToolsC:checkCreateDirectory() : The directory does not exist : " << directory << endl ;
211 cout <<
"====>>>> ToolsC:checkCreateDirectory() : I'll try to create it" << endl ;
212 const int&
create = gSystem->Exec ( (
"mkdir " + directory).c_str() ) ;
214 cout <<
"====>>>> ToolsC:checkCreateDirectory() : Creation of directory failed : " << directory << endl
215 <<
"====>>>> ToolsC:checkCreateDirectory() : Please check your write permissions!" << endl ;
218 cout <<
"====>>>> ToolsC:checkCreateDirectory() : Creation of directory successful!" << endl ;
220 cout <<
"====>>>> ToolsC:checkCreateDirectory() : " << endl ;
221 exists = gSystem->Exec ( (
"ls -d " + directory).c_str() ) ;
222 if ( exists != 0 )
cout <<
"ToolsC:checkCreateDirectory() : However, it still doesn't exist!?" << endl ;
243 const int& nBins = histo->GetNbinsX() - 2 ;
248 const float&
maxInHisto = histo->GetMaximum() ;
249 const float&
minInHisto = histo->GetMinimum() ;
252 if ( yVal <= maxInHisto ) {
253 yClosestInit = maxInHisto + 1 ; }
256 yClosestInit = minInHisto - 1.0 ;
263 for (
int iBin = 1 ; iBin <= nBins ; ++iBin ) {
264 const float&
yBin = histo->GetBinContent(iBin) ;
265 if ( fabs(yBin-yVal) < fabs(yClosest-yVal) ) {
272 if ( yClosest < yLow || yClosest > yHigh ) {
277 if ( iBinClosest == iBinClosestInit ) {
278 cout <<
"====>>>> ToolsC=>findBinClosestYValue() : WARNING: returned bin is the initialization bin!!" << endl ;
288 TStyle *
tdrStyle =
new TStyle(
"tdrStyle",
"Style for P-TDR");
291 tdrStyle->SetCanvasBorderMode(0);
292 tdrStyle->SetCanvasColor(kWhite);
293 tdrStyle->SetCanvasDefH(600);
294 tdrStyle->SetCanvasDefW(600);
295 tdrStyle->SetCanvasDefX(0);
296 tdrStyle->SetCanvasDefY(0);
299 tdrStyle->SetPadBorderMode(0);
301 tdrStyle->SetPadColor(kWhite);
302 tdrStyle->SetPadGridX(
false);
303 tdrStyle->SetPadGridY(
false);
304 tdrStyle->SetGridColor(0);
305 tdrStyle->SetGridStyle(3);
306 tdrStyle->SetGridWidth(1);
309 tdrStyle->SetFrameBorderMode(0);
310 tdrStyle->SetFrameBorderSize(1);
311 tdrStyle->SetFrameFillColor(0);
312 tdrStyle->SetFrameFillStyle(0);
313 tdrStyle->SetFrameLineColor(1);
314 tdrStyle->SetFrameLineStyle(1);
315 tdrStyle->SetFrameLineWidth(1);
320 tdrStyle->SetHistLineColor(1);
321 tdrStyle->SetHistLineStyle(0);
322 tdrStyle->SetHistLineWidth(1);
326 tdrStyle->SetEndErrorSize(15);
328 tdrStyle->SetErrorX(1);
330 tdrStyle->SetMarkerStyle(21);
331 tdrStyle->SetMarkerSize(1.);
334 tdrStyle->SetOptFit(0);
335 tdrStyle->SetFitFormat(
"5.4g");
336 tdrStyle->SetFuncColor(2);
337 tdrStyle->SetFuncStyle(1);
338 tdrStyle->SetFuncWidth(1);
341 tdrStyle->SetOptDate(0);
346 tdrStyle->SetOptFile(1111);
347 tdrStyle->SetOptStat(0);
348 tdrStyle->SetStatColor(kWhite);
349 tdrStyle->SetStatFont(42);
350 tdrStyle->SetStatFontSize(0.025);
351 tdrStyle->SetStatTextColor(1);
352 tdrStyle->SetStatFormat(
"6.4g");
353 tdrStyle->SetStatBorderSize(1);
354 tdrStyle->SetStatH(0.2);
355 tdrStyle->SetStatW(0.15);
361 tdrStyle->SetPadTopMargin(0.05);
362 tdrStyle->SetPadBottomMargin(0.13);
363 tdrStyle->SetPadLeftMargin(0.16);
364 tdrStyle->SetPadRightMargin(0.02);
368 tdrStyle->SetOptTitle(0);
369 tdrStyle->SetTitleW(0.8);
371 tdrStyle->SetTitleFont(42);
372 tdrStyle->SetTitleColor(1);
373 tdrStyle->SetTitleTextColor(1);
374 tdrStyle->SetTitleFillColor(10);
375 tdrStyle->SetTitleFontSize(0.05);
384 tdrStyle->SetTitleColor(1,
"XYZ");
385 tdrStyle->SetTitleFont(42,
"XYZ");
386 tdrStyle->SetTitleSize(0.06,
"XYZ");
389 tdrStyle->SetTitleXOffset(0.75);
390 tdrStyle->SetTitleYOffset(0.75);
395 tdrStyle->SetLabelColor(1,
"XYZ");
396 tdrStyle->SetLabelFont(42,
"XYZ");
397 tdrStyle->SetLabelOffset(0.007,
"XYZ");
398 tdrStyle->SetLabelSize(0.05,
"XYZ");
402 tdrStyle->SetAxisColor(1,
"XYZ");
403 tdrStyle->SetStripDecimals(kTRUE);
404 tdrStyle->SetTickLength(0.03,
"XYZ");
405 tdrStyle->SetNdivisions(510,
"XYZ");
406 tdrStyle->SetPadTickX(1);
407 tdrStyle->SetPadTickY(1);
410 tdrStyle->SetOptLogx(0);
411 tdrStyle->SetOptLogy(0);
412 tdrStyle->SetOptLogz(0);
415 tdrStyle->SetPaperSize(21.,28.);
436 tdrStyle->SetPadGridX(gridOn);
437 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)