Setting run number in CDB manager added. GRP now read from default cdb storage instea...
[u/mrichter/AliRoot.git] / CORRFW / AliCFContainer.h
CommitLineData
563113d0 1#ifndef ALICFCONTAINER_H
2#define ALICFCONTAINER_H
3
4/* $Id$ */
5
6//--------------------------------------------------------------------//
7// //
8// AliCFContainer Class //
9// Class to handle input data for correction Framework //
10// //
11//--------------------------------------------------------------------//
12
13#include "AliCFFrame.h"
fb494025 14#include "AliCFGridSparse.h"
563113d0 15
1e9dad92 16class TH1D;
17class TH2D;
18class TH3D;
07b0477d 19class TCollection;
563113d0 20
21class AliCFContainer : public AliCFFrame
22{
23 public:
24 AliCFContainer();
fb494025 25 AliCFContainer(const Char_t* name, const Char_t* title,const Int_t nSelStep, const Int_t nVarIn, const Int_t* nBinIn);
563113d0 26 AliCFContainer(const AliCFContainer& c);
563113d0 27 AliCFContainer& operator=(const AliCFContainer& corr);
fb494025 28 virtual void Copy(TObject& c) const;
29
30 virtual ~AliCFContainer();
31
32 // AliCFFrame functions
33 virtual Int_t GetNVar() const {return fGrid[0]->GetNVar();}
34 virtual void PrintBinLimits() const {fGrid[0]->PrintBinLimits();}
35 virtual void PrintNBins() const {fGrid[0]->PrintNBins();}
aa29aca9 36 virtual void SetBinLimits(Int_t ivar, Double_t min, Double_t max) ; // for uniform bin width only
37 virtual void SetBinLimits(Int_t ivar, const Double_t * array) ; // for variable or uniform bin width
1db34d6e 38 virtual void SetBinLabel (Int_t ivar,Int_t ibin, const Char_t* label);// set a label to bin ibin on axis ivar
39 virtual void SetBinContent(Int_t* bin, Int_t step, Double_t value);
40 virtual void SetBinError (Int_t* bin, Int_t step, Double_t value);
fb494025 41 virtual void GetBinLimits(Int_t ivar, Double_t * array) const {return fGrid[0]->GetBinLimits(ivar,array);}
42 virtual Double_t * GetBinLimits(Int_t ivar) const {return fGrid[0]->GetBinLimits(ivar);}
43 virtual Long_t GetNBinsTotal() const {return fGrid[0]->GetNBinsTotal()*fNStep;}
44 virtual Int_t GetNBins(Int_t ivar) const {return fGrid[0]->GetNBins(ivar);}
45 virtual Int_t * GetNBins() const {return fGrid[0]->GetNBins();}
46 virtual Float_t GetBinCenter(Int_t ivar,Int_t ibin) const {return fGrid[0]->GetBinCenter(ivar,ibin);}
47 virtual Float_t GetBinSize (Int_t ivar,Int_t ibin) const {return fGrid[0]->GetBinSize (ivar,ibin);}
4b7819c4 48 virtual Float_t GetBinContent(const Int_t* coordinates, Int_t step) const {return fGrid[step]->GetGrid()->GetBinContent(coordinates);}
49 virtual Float_t GetBinError (const Int_t* coordinates, Int_t step) const {return fGrid[step]->GetGrid()->GetBinError (coordinates);}
1db34d6e 50 virtual const Char_t* GetBinLabel (Int_t ivar,Int_t ibin) const {return GetAxis(ivar,0)->GetBinLabel(ibin);}
fb494025 51
71b2614f 52 virtual void Print(const Option_t*) const ;
53
fb494025 54 virtual TAxis * GetAxis(Int_t ivar, Int_t istep) const {return fGrid[istep]->GetAxis(ivar);}
55 virtual void SetVarTitle (Int_t ivar, const Char_t* title) ;
56 virtual void SetStepTitle(Int_t istep, const Char_t* title) ;
57 virtual const Char_t* GetVarTitle (Int_t ivar) const {return GetAxis(ivar,0)->GetTitle();}
58 virtual const Char_t* GetStepTitle(Int_t istep) const {return fGrid[istep]->GetTitle();}
59 virtual Int_t GetStep(const Char_t* title) const ; // returns the step corresponding to the given title
60 virtual Int_t GetVar (const Char_t* title) const ; // returns the variable corresponding to the given title
9105291d 61
fb494025 62 virtual Int_t GetNStep() const {return fNStep;};
9105291d 63 virtual void SetNStep(Int_t nStep) {fNStep=nStep;}
fb494025 64 virtual void Fill(const Double_t *var, Int_t istep, Double_t weight=1.) ;
9105291d 65
fb494025 66 virtual Float_t GetOverFlows (Int_t var,Int_t istep,Bool_t excl=kFALSE) const;
67 virtual Float_t GetUnderFlows(Int_t var,Int_t istep,Bool_t excl=kFALSE) const ;
68 virtual Float_t GetEntries (Int_t istep) const ;
69 virtual Long_t GetEmptyBins(Int_t istep) const {return fGrid[istep]->GetEmptyBins();}
fb494025 70 virtual Double_t GetIntegral (Int_t istep) const ;
563113d0 71
fb494025 72 //basic operations
73 virtual void Add(const AliCFContainer* aContainerToAdd, Double_t c=1.);
563113d0 74 virtual Long64_t Merge(TCollection* list);
75
d91baff0 76 virtual TH1* Project (Int_t istep, Int_t ivar1, Int_t ivar2=-1 ,Int_t ivar3=-1) const;
77 virtual AliCFContainer* MakeSlice(Int_t nVars, const Int_t* vars, const Double_t* varMin=0x0, const Double_t* varMax=0x0, Bool_t useBins=0) const ;
78 virtual AliCFContainer* MakeSlice(Int_t nStep, const Int_t* steps,
79 Int_t nVars, const Int_t* vars, const Double_t* varMin=0x0, const Double_t* varMax=0x0,
80 Bool_t useBins=0) const ;
7036630f 81 virtual void Smooth(Int_t istep) {GetGrid(istep)->Smooth();}
98a5f772 82
d91baff0 83 virtual void SetRangeUser(Int_t ivar, Double_t varMin, Double_t varMax, Bool_t useBins=kFALSE) const ;
84 virtual void SetRangeUser(const Double_t* varMin, const Double_t* varMax, Bool_t useBins=kFALSE) const ;
85
4b7819c4 86 virtual void SetGrid(Int_t step, AliCFGridSparse* grid) {if (fGrid[step]) delete fGrid[step]; fGrid[step]=grid;}
fb494025 87 virtual AliCFGridSparse * GetGrid(Int_t istep) const {return fGrid[istep];};
1db34d6e 88
89 virtual void Scale(Double_t factor) const;
d91baff0 90
91 /**** TO BE REMOVED SOON ******/
92 virtual TH1D* ShowProjection( Int_t ivar, Int_t istep) const {return (TH1D*)Project(istep,ivar);}
93 virtual TH2D* ShowProjection( Int_t ivar1, Int_t ivar2, Int_t istep) const {return (TH2D*)Project(istep,ivar1,ivar2);}
94 virtual TH3D* ShowProjection( Int_t ivar1, Int_t ivar2,Int_t ivar3, Int_t istep) const {return (TH3D*)Project(istep,ivar1,ivar2,ivar3);}
563113d0 95
96 private:
97 Int_t fNStep; //number of selection steps
fb494025 98 AliCFGridSparse **fGrid;//[fNStep]
563113d0 99
fb494025 100 ClassDef(AliCFContainer,5);
563113d0 101};
fb494025 102
103inline void AliCFContainer::SetBinLimits(Int_t ivar, const Double_t* array) {
104 for (Int_t iStep=0; iStep<GetNStep(); iStep++) {
105 fGrid[iStep]->SetBinLimits(ivar,array);
106 }
107}
108
aa29aca9 109inline void AliCFContainer::SetBinLimits(Int_t ivar, Double_t min, Double_t max) {
110 for (Int_t iStep=0; iStep<GetNStep(); iStep++) {
111 fGrid[iStep]->SetBinLimits(ivar,min,max);
112 }
113}
114
fb494025 115inline void AliCFContainer::SetVarTitle(Int_t ivar, const Char_t* title) {
116 for (Int_t iStep=0; iStep<fNStep; iStep++) {
117 GetAxis(ivar,iStep)->SetTitle(title);
118 }
119}
120
121inline void AliCFContainer::SetStepTitle(Int_t istep, const Char_t* title) {
122 fGrid[istep]->SetTitle(title);
123}
124
125inline Int_t AliCFContainer::GetStep(const Char_t* title) const {
126 TString str(title);
127 for (Int_t iStep=0; iStep<fNStep; iStep++) {
128 if (!str.CompareTo(GetStepTitle(iStep))) return iStep;
129 }
130 AliError("Step not found");
131 return -1;
132}
133
134inline Int_t AliCFContainer::GetVar(const Char_t* title) const {
135 return fGrid[0]->GetVar(title);
136}
1db34d6e 137
138inline void AliCFContainer::SetBinLabel(Int_t iVar, Int_t iBin, const Char_t* label) {
139 for (Int_t iStep=0; iStep<GetNStep(); iStep++) GetAxis(iVar,iStep)->SetBinLabel(iBin,label);
140}
141
142inline void AliCFContainer::Scale(Double_t factor) const {
143 Double_t fact[2] = {factor,0} ;
144 for (Int_t iStep=0; iStep<fNStep; iStep++) fGrid[iStep]->Scale(fact);
145}
146
147inline void AliCFContainer::SetBinContent(Int_t* bin, Int_t step, Double_t value) {
4b7819c4 148 // sets the content 'value' to the current container, at step 'step'
149 // 'bin' is the array of the bin coordinates
1db34d6e 150 GetGrid(step)->GetGrid()->SetBinContent(bin,value);
151}
152
153inline void AliCFContainer::SetBinError(Int_t* bin, Int_t step, Double_t value) {
4b7819c4 154 // sets the error 'value' to the current container, at step 'step'
155 // 'bin' is the array of the bin coordinates
1db34d6e 156 GetGrid(step)->GetGrid()->SetBinError(bin,value);
157}
158
563113d0 159#endif
160