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 ;
297 const int& nBinsX = histoY->GetNbinsX() - 2 ;
298 const int& nBinsY = histoY->GetNbinsY() - 2 ;
303 const float&
maxInHisto = histoY->GetMaximum() ;
304 const float&
minInHisto = histoY->GetMinimum() ;
308 if ( yVal <= maxInHisto ) {
320 for (
int iBinX = 1 ; iBinX <= nBinsX ; ++iBinX ) {
321 for (
int iBinY = 1 ; iBinY <= nBinsY ; ++iBinY ) {
322 const float&
yBin = histoY->GetBinContent(iBinX,iBinY);
323 for (
unsigned int i = 0;
i < zVal.size();
i++){
324 if ( fabs(yBin-yVal) < fabs(yClosest[
i]-yVal) ) {
325 const float& zLow = zVal[
i] - (yVal - yLow);
326 const float& zHigh = zVal[
i] + (yHigh - yVal);
327 const float&
zBin = histoZ->GetBinContent(iBinX,iBinY) ;
328 if(zBin < zLow || zBin > zHigh)
continue;
336 for (
unsigned int i = 0;
i < yClosest.size();
i++){
337 if ( yClosest[
i] < yLow || yClosest[
i] > yHigh )
347 TStyle *
tdrStyle =
new TStyle(
"tdrStyle",
"Style for P-TDR");
350 tdrStyle->SetCanvasBorderMode(0);
351 tdrStyle->SetCanvasColor(kWhite);
352 tdrStyle->SetCanvasDefH(600);
353 tdrStyle->SetCanvasDefW(600);
354 tdrStyle->SetCanvasDefX(0);
355 tdrStyle->SetCanvasDefY(0);
358 tdrStyle->SetPadBorderMode(0);
360 tdrStyle->SetPadColor(kWhite);
361 tdrStyle->SetPadGridX(
false);
362 tdrStyle->SetPadGridY(
false);
363 tdrStyle->SetGridColor(0);
364 tdrStyle->SetGridStyle(3);
365 tdrStyle->SetGridWidth(1);
368 tdrStyle->SetFrameBorderMode(0);
369 tdrStyle->SetFrameBorderSize(1);
370 tdrStyle->SetFrameFillColor(0);
371 tdrStyle->SetFrameFillStyle(0);
372 tdrStyle->SetFrameLineColor(1);
373 tdrStyle->SetFrameLineStyle(1);
374 tdrStyle->SetFrameLineWidth(1);
379 tdrStyle->SetHistLineColor(1);
380 tdrStyle->SetHistLineStyle(0);
381 tdrStyle->SetHistLineWidth(1);
385 tdrStyle->SetEndErrorSize(15);
387 tdrStyle->SetErrorX(1);
389 tdrStyle->SetMarkerStyle(21);
390 tdrStyle->SetMarkerSize(1.);
393 tdrStyle->SetOptFit(0);
394 tdrStyle->SetFitFormat(
"5.4g");
395 tdrStyle->SetFuncColor(2);
396 tdrStyle->SetFuncStyle(1);
397 tdrStyle->SetFuncWidth(1);
400 tdrStyle->SetOptDate(0);
405 tdrStyle->SetOptFile(1111);
406 tdrStyle->SetOptStat(0);
407 tdrStyle->SetStatColor(kWhite);
408 tdrStyle->SetStatFont(42);
409 tdrStyle->SetStatFontSize(0.025);
410 tdrStyle->SetStatTextColor(1);
411 tdrStyle->SetStatFormat(
"6.4g");
412 tdrStyle->SetStatBorderSize(1);
413 tdrStyle->SetStatH(0.2);
414 tdrStyle->SetStatW(0.15);
420 tdrStyle->SetPadTopMargin(0.05);
421 tdrStyle->SetPadBottomMargin(0.13);
422 tdrStyle->SetPadLeftMargin(0.16);
423 tdrStyle->SetPadRightMargin(0.02);
427 tdrStyle->SetOptTitle(0);
428 tdrStyle->SetTitleW(0.8);
430 tdrStyle->SetTitleFont(42);
431 tdrStyle->SetTitleColor(1);
432 tdrStyle->SetTitleTextColor(1);
433 tdrStyle->SetTitleFillColor(10);
434 tdrStyle->SetTitleFontSize(0.05);
443 tdrStyle->SetTitleColor(1,
"XYZ");
444 tdrStyle->SetTitleFont(42,
"XYZ");
445 tdrStyle->SetTitleSize(0.06,
"XYZ");
448 tdrStyle->SetTitleXOffset(0.75);
449 tdrStyle->SetTitleYOffset(0.75);
454 tdrStyle->SetLabelColor(1,
"XYZ");
455 tdrStyle->SetLabelFont(42,
"XYZ");
456 tdrStyle->SetLabelOffset(0.007,
"XYZ");
457 tdrStyle->SetLabelSize(0.05,
"XYZ");
461 tdrStyle->SetAxisColor(1,
"XYZ");
462 tdrStyle->SetStripDecimals(kTRUE);
463 tdrStyle->SetTickLength(0.03,
"XYZ");
464 tdrStyle->SetNdivisions(510,
"XYZ");
465 tdrStyle->SetPadTickX(1);
466 tdrStyle->SetPadTickY(1);
469 tdrStyle->SetOptLogx(0);
470 tdrStyle->SetOptLogy(0);
471 tdrStyle->SetOptLogz(0);
474 tdrStyle->SetPaperSize(21.,28.);
495 tdrStyle->SetPadGridX(gridOn);
496 tdrStyle->SetPadGridY(gridOn);
void PrintCanvasHistos(TCanvas *canvas, const std::string &psFile, const std::string &epsFile, const std::string &gifFile)
bool flavourIsG(const int &flav)
def create(alignables, pedeDump, additionalData, outputFile, config)
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)