+
+TH1D * AliOADBPWG2Spectra::GetHistoStandardBinning(const TH1D* h, Int_t det, Int_t pidType, Int_t part,
+ Int_t charge, const char * centrTag, Int_t centrBin) {
+ // Returns a histo with the standard binning and the same content of h
+ // if the bins of h are not a subset of the standard binning, it crashes with a fatal error
+ // under and overflows are ignored
+
+ // 1. Create a histogram with the standard binning
+ TH1D * hStd = BookHisto(det, pidType, part, charge, centrTag, centrBin);
+ Int_t nBinsH1=hStd->GetNbinsX();
+ Int_t nBinsH2=h->GetNbinsX();
+ // Loop over standard bins,
+ for(Int_t iBin=1; iBin<=nBinsH1; iBin++){
+ Float_t lowPtH1 =hStd->GetBinLowEdge(iBin);
+ Float_t binWidH1=hStd->GetBinWidth(iBin);
+ // Loop over H2 bins and find overlapping bins to H1
+ for(Int_t jBin=1; jBin<=nBinsH2; jBin++){
+ Float_t lowPtH2=h->GetBinLowEdge(jBin);
+ Float_t binWidH2=h->GetBinWidth(jBin);
+ if(TMath::Abs(lowPtH1-lowPtH2)<0.001 && TMath::Abs(binWidH2-binWidH1)<0.001){
+ hStd->SetBinContent(iBin, h->GetBinContent(jBin));
+ hStd->SetBinError (iBin, h->GetBinError (jBin));
+ break;
+ }
+ if(TMath::Abs(lowPtH1-lowPtH2)<0.001){
+ AliError(Form("Found partially overlapping bins! [(%f,%f)(%f,%f)]",lowPtH1,binWidH1,lowPtH2,binWidH2));
+ continue;
+ }
+ }
+ }
+ return hStd;
+}
+
+Bool_t AliOADBPWG2Spectra::CompareBinning(TH1 * h1, TH1 * h2) {
+
+ // returns true if h1 and h2 have the same binning
+ Int_t nbins1 = h1->GetNbinsX();
+ Int_t nbins2 = h2->GetNbinsX();
+
+ if(nbins1 != nbins2) return kFALSE;
+
+ for(Int_t ibin = 1; ibin <= nbins1; ibin++){
+ if(TMath::Abs(h1->GetBinLowEdge(ibin) - h2->GetBinLowEdge(ibin))>0.001) return kFALSE;
+ if(TMath::Abs(h1->GetBinWidth(ibin) - h2->GetBinWidth(ibin))>0.001) return kFALSE;
+ }
+
+ return kTRUE;
+}