From 3392b4c9d750650d4d740ceeea82cb16fbf9bd39 Mon Sep 17 00:00:00 2001 From: hristov Date: Sun, 7 Oct 2007 20:54:37 +0000 Subject: [PATCH] New methods: MakeStat1D and MakeStat2D (Marian) --- STEER/AliMathBase.cxx | 84 +++++++++++++++++++++++++++++++++++++++++++ STEER/AliMathBase.h | 8 +++++ 2 files changed, 92 insertions(+) diff --git a/STEER/AliMathBase.cxx b/STEER/AliMathBase.cxx index 89d9a87c40a..13e7e69ecd1 100644 --- a/STEER/AliMathBase.cxx +++ b/STEER/AliMathBase.cxx @@ -25,6 +25,7 @@ #include "AliMathBase.h" #include "Riostream.h" #include "TH1F.h" +#include "TH3.h" #include "TF1.h" #include "TLinearFitter.h" @@ -641,4 +642,87 @@ void AliMathBase::TestGausFit(Int_t nhistos){ +TGraph2D * AliMathBase::MakeStat2D(TH3 * his, Int_t delta0, Int_t delta1, Int_t type){ + // + // + // + // delta - number of bins to integrate + // type - 0 - mean value + + TAxis * xaxis = his->GetXaxis(); + TAxis * yaxis = his->GetYaxis(); + // TAxis * zaxis = his->GetZaxis(); + Int_t nbinx = xaxis->GetNbins(); + Int_t nbiny = yaxis->GetNbins(); + char name[1000]; + Int_t icount=0; + TGraph2D *graph = new TGraph2D(nbinx*nbiny); + TF1 f1("f1","gaus"); + for (Int_t ix=0; ixGetBinCenter(ix); + Float_t ycenter = yaxis->GetBinCenter(iy); + sprintf(name,"%s_%d_%d",his->GetName(), ix,iy); + TH1 *projection = his->ProjectionZ(name,ix-delta0,ix+delta0,iy-delta1,iy+delta1); + Float_t stat= 0; + if (type==0) stat = projection->GetMean(); + if (type==1) stat = projection->GetRMS(); + if (type==2 || type==3){ + TVectorD vec(3); + AliMathBase::LTM((TH1F*)projection,&vec,0.7); + if (type==2) stat= vec[1]; + if (type==3) stat= vec[0]; + } + if (type==4|| type==5){ + projection->Fit(&f1); + if (type==4) stat= f1.GetParameter(1); + if (type==5) stat= f1.GetParameter(2); + } + //printf("%d\t%f\t%f\t%f\n", icount,xcenter, ycenter, stat); + graph->SetPoint(icount,xcenter, ycenter, stat); + icount++; + } + return graph; +} +TGraph * AliMathBase::MakeStat1D(TH3 * his, Int_t delta1, Int_t type){ + // + // + // + // delta - number of bins to integrate + // type - 0 - mean value + + TAxis * xaxis = his->GetXaxis(); + TAxis * yaxis = his->GetYaxis(); + // TAxis * zaxis = his->GetZaxis(); + Int_t nbinx = xaxis->GetNbins(); + Int_t nbiny = yaxis->GetNbins(); + char name[1000]; + Int_t icount=0; + TGraph *graph = new TGraph(nbinx); + TF1 f1("f1","gaus"); + for (Int_t ix=0; ixGetBinCenter(ix); + // Float_t ycenter = yaxis->GetBinCenter(iy); + sprintf(name,"%s_%d",his->GetName(), ix); + TH1 *projection = his->ProjectionZ(name,ix-delta1,ix+delta1,0,nbiny); + Float_t stat= 0; + if (type==0) stat = projection->GetMean(); + if (type==1) stat = projection->GetRMS(); + if (type==2 || type==3){ + TVectorD vec(3); + AliMathBase::LTM((TH1F*)projection,&vec,0.7); + if (type==2) stat= vec[1]; + if (type==3) stat= vec[0]; + } + if (type==4|| type==5){ + projection->Fit(&f1); + if (type==4) stat= f1.GetParameter(1); + if (type==5) stat= f1.GetParameter(2); + } + //printf("%d\t%f\t%f\t%f\n", icount,xcenter, ycenter, stat); + graph->SetPoint(icount,xcenter, stat); + icount++; + } + return graph; +} diff --git a/STEER/AliMathBase.h b/STEER/AliMathBase.h index 88626602980..48244b9ab1f 100644 --- a/STEER/AliMathBase.h +++ b/STEER/AliMathBase.h @@ -8,8 +8,12 @@ #include "TObject.h" #include "TVectorD.h" #include "TMatrixD.h" +#include "TGraph2D.h" +#include "TGraph.h" class TH1F; +class TH3; + class AliMathBase : public TObject { @@ -25,6 +29,10 @@ class AliMathBase : public TObject static Double_t FitGaus(Float_t *arr, Int_t nBins, Float_t xMin, Float_t xMax, TVectorD *param=0, TMatrixD *matrix=0, Bool_t verbose=kFALSE); static Float_t GetCOG(Short_t *arr, Int_t nBins, Float_t xMin, Float_t xMax, Float_t *rms=0, Float_t *sum=0); + + static TGraph2D * MakeStat2D(TH3 * his, Int_t delta0, Int_t delta1, Int_t type); + static TGraph * MakeStat1D(TH3 * his, Int_t delta1, Int_t type); + // // TestFunctions: // -- 2.43.0