]>
Commit | Line | Data |
---|---|---|
ac7636a0 | 1 | #ifndef ALIMULTIDIMVECTOR_H |
2 | #define ALIMULTIDIMVECTOR_H | |
3 | ||
4 | /* Copyright(c) 2007-2009, ALICE Experiment at CERN, All rights reserved. * | |
5 | * See cxx source for full Copyright notice */ | |
6 | ||
7 | /* $Id: $ */ | |
8 | ||
9 | /////////////////////////////////////////////////////////////////// | |
10 | // // | |
11 | // Class to store number of signal and background candidates // | |
12 | // in bins of cut variables // | |
13 | // Origin: Elena Bruna (bruna@to.infn.it) // | |
14 | // Updated: Sergey Senyukov (senyukov@to.infn.it) // | |
15 | // Last updated: Francesco Prino (prino@to.infn.it) // | |
16 | // // | |
17 | /////////////////////////////////////////////////////////////////// | |
18 | ||
19 | #include "TArrayF.h" | |
20 | #include "TArrayI.h" | |
21 | #include "TNamed.h" | |
22 | #include "TH2.h" | |
bac542b0 | 23 | #include "TMath.h" |
ac7636a0 | 24 | #include "TString.h" |
25 | ||
26 | class AliMultiDimVector : public TNamed{ | |
27 | ||
28 | public: | |
29 | AliMultiDimVector(); | |
30 | AliMultiDimVector(const AliMultiDimVector &mv); | |
bac542b0 | 31 | AliMultiDimVector(const char *name, const char *title, const Int_t nptbins, Float_t* ptlimits, const Int_t npars, Int_t *nofcells, Float_t *loosecuts, Float_t *tightcuts, TString *axisTitles); |
ac7636a0 | 32 | virtual ~AliMultiDimVector(){}; |
33 | ||
34 | ULong64_t GetNTotCells() const {return fNTotCells;} | |
35 | Int_t GetNVariables() const {return fNVariables;} | |
36 | Int_t GetNPtBins() const {return fNPtBins;} | |
37 | Int_t GetNCutSteps(Int_t iVar) const {return fNCutSteps[iVar];} | |
38 | Float_t GetMinLimit(Int_t iVar) const {return fMinLimits[iVar];} | |
39 | Float_t GetMaxLimit(Int_t iVar) const {return fMaxLimits[iVar];} | |
40 | Float_t GetCutStep(Int_t iVar) const {return (fMaxLimits[iVar]-fMinLimits[iVar])/(Float_t)fNCutSteps[iVar];} | |
41 | TString GetAxisTitle(Int_t iVar) const {return fAxisTitles[iVar];} | |
42 | Bool_t IsIntegrated() const {return fIsIntegrated;} | |
43 | ||
44 | void CopyStructure(const AliMultiDimVector* mv); | |
45 | ||
46 | Float_t GetCutValue(Int_t iVar, Int_t iCell) const{ | |
47 | if(fGreaterThan[iVar]) return fMinLimits[iVar]+(Float_t)iCell*GetCutStep(iVar); | |
48 | else return fMaxLimits[iVar]-(Float_t)iCell*GetCutStep(iVar); | |
49 | } | |
50 | Float_t GetElement(ULong64_t globadd) const {return fVett[globadd];} | |
51 | Float_t GetElement(Int_t *ind, Int_t ptbin) const { | |
52 | ULong64_t elem=GetGlobalAddressFromIndices(ind,ptbin); | |
53 | return fVett[elem]; | |
54 | } | |
bac542b0 | 55 | Float_t GetPtLimit(Int_t i) const{return fPtLimits[i];} |
56 | Int_t GetPtBin(const Float_t pt) const{ | |
57 | Int_t theBin=TMath::BinarySearch(fNPtBins+1,fPtLimits,pt); | |
58 | if(theBin>=fNPtBins) theBin=-1; | |
59 | return theBin; | |
60 | } | |
ac7636a0 | 61 | void GetEntireMultiDimVector(Float_t *vett) const { |
62 | for(ULong64_t i=0; i<fNTotCells; i++) vett[i]=fVett[i]; | |
63 | } | |
64 | ||
65 | Bool_t GetIndicesFromGlobalAddress(ULong64_t globadd, Int_t *ind, Int_t &ptbin) const; | |
66 | ULong64_t GetGlobalAddressFromIndices(Int_t *ind, Int_t ptbin) const; | |
67 | Bool_t GetIndicesFromValues(Float_t *values, Int_t *ind) const; | |
68 | ULong64_t GetGlobalAddressFromValues(Float_t *values, Int_t ptbin) const; | |
69 | Bool_t GetCutValuesFromGlobalAddress(ULong64_t globadd, Float_t *cuts, Int_t &ptbin) const; | |
bac542b0 | 70 | |
71 | ULong64_t* GetGlobalAddressesAboveCuts(Float_t *values, Float_t pt, Int_t& nVals) const{ | |
72 | Int_t theBin=GetPtBin(pt); | |
73 | if(theBin>=0) return GetGlobalAddressesAboveCuts(values,theBin,nVals); | |
74 | else return 0x0; | |
75 | } | |
76 | ULong64_t* GetGlobalAddressesAboveCuts(Float_t *values, Int_t ptbin, Int_t& nVals) const; | |
ac7636a0 | 77 | |
78 | void SetElement(ULong64_t globadd,Float_t val) {fVett[globadd]=val;} | |
79 | void SetElement(Int_t *ind, Int_t ptbin, Float_t val){ | |
80 | ULong64_t elem=GetGlobalAddressFromIndices(ind,ptbin); | |
81 | fVett[elem]=val; | |
82 | } | |
83 | void IncrementElement(Int_t *ind, Int_t ptbin){ | |
84 | SetElement(ind,ptbin,GetElement(ind,ptbin)+1); | |
85 | } | |
86 | void IncrementElement(ULong64_t globadd){ | |
87 | SetElement(globadd,GetElement(globadd)+1.); | |
88 | } | |
89 | ||
90 | void Fill(Float_t* values, Int_t ptbin); | |
91 | void FillAndIntegrate(Float_t* values, Int_t ptbin); | |
92 | void Integrate(); | |
93 | ||
94 | void Reset(){ | |
95 | for(ULong64_t i=0; i<fNTotCells; i++) fVett[i]=0.; | |
96 | } | |
97 | void MultiplyBy(Float_t factor); | |
98 | void Multiply(AliMultiDimVector* mv,Float_t factor); | |
99 | void Multiply(AliMultiDimVector* mv1, AliMultiDimVector* mv2); | |
100 | void Add(AliMultiDimVector* mv); | |
101 | void Sum(AliMultiDimVector* mv1, AliMultiDimVector* mv2); | |
102 | void LinearComb(AliMultiDimVector* mv1, Float_t norm1, AliMultiDimVector* mv2, Float_t norm2); | |
103 | void DivideBy(AliMultiDimVector* mv); | |
104 | void Divide(AliMultiDimVector* mv1, AliMultiDimVector* mv2); | |
105 | void Sqrt(); | |
106 | void Sqrt(AliMultiDimVector* mv); | |
107 | ||
108 | void FindMaximum(Float_t& max_value, Int_t *ind, Int_t ptbin); | |
109 | ||
110 | TH2F* Project(Int_t firstVar, Int_t secondVar, Int_t* fixedVars, Int_t ptbin, Float_t norm=1.); | |
111 | ||
112 | void SuppressZeroBKGEffect(AliMultiDimVector* BKG); | |
bac542b0 | 113 | AliMultiDimVector* ShrinkPtBins(Int_t firstBin, Int_t lastBin); |
114 | void PrintStatus(); | |
ac7636a0 | 115 | |
116 | protected: | |
117 | void GetIntegrationLimits(Int_t iVar, Int_t iCell, Int_t& minbin, Int_t& maxbin) const; | |
118 | void GetFillRange(Int_t iVar, Int_t iCell, Int_t& minbin, Int_t& maxbin) const; | |
119 | Bool_t GetGreaterThan(Int_t iVar) const {return fGreaterThan[iVar];} | |
120 | Float_t CountsAboveCell(ULong64_t globadd) const; | |
121 | ||
122 | private: | |
123 | static const Int_t fgkMaxNVariables=10; // max. n. of selection variables | |
bac542b0 | 124 | static const Int_t fgkMaxNPtBins=10; // max. n. of Pt bins |
ac7636a0 | 125 | |
126 | Int_t fNVariables; // n. of selection variables | |
127 | Int_t fNPtBins; // n. of pt bins | |
bac542b0 | 128 | Float_t fPtLimits[fgkMaxNPtBins+1]; // limits of pt bins |
ac7636a0 | 129 | Int_t fNCutSteps[fgkMaxNVariables]; // n. of cut step for each variable |
130 | Float_t fMinLimits[fgkMaxNVariables]; // lower cut value for each variable | |
131 | Float_t fMaxLimits[fgkMaxNVariables]; // higher cut value for each variable | |
132 | Bool_t fGreaterThan[fgkMaxNVariables];// sign of the cut (> or <) | |
133 | TString fAxisTitles[fgkMaxNVariables]; // titles for variables | |
134 | TArrayF fVett; // array with n. of candidates vs. cuts | |
135 | ULong64_t fNTotCells; // total number of matrix elements | |
136 | Bool_t fIsIntegrated; // flag for integrated matrix | |
137 | ||
bac542b0 | 138 | ClassDef(AliMultiDimVector,2); // a multi-dimensional vector class |
ac7636a0 | 139 | |
140 | }; | |
141 | ||
142 | #endif |