]>
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); | |
2350a1d9 | 31 | AliMultiDimVector(const char *name, const char *title, const Int_t nptbins, |
32 | const Float_t* ptlimits, const Int_t npars, const Int_t *nofcells, const Float_t *loosecuts, const Float_t *tightcuts, const TString *axisTitles); | |
ac7636a0 | 33 | virtual ~AliMultiDimVector(){}; |
34 | ||
35 | ULong64_t GetNTotCells() const {return fNTotCells;} | |
36 | Int_t GetNVariables() const {return fNVariables;} | |
37 | Int_t GetNPtBins() const {return fNPtBins;} | |
38 | Int_t GetNCutSteps(Int_t iVar) const {return fNCutSteps[iVar];} | |
39 | Float_t GetMinLimit(Int_t iVar) const {return fMinLimits[iVar];} | |
40 | Float_t GetMaxLimit(Int_t iVar) const {return fMaxLimits[iVar];} | |
41 | Float_t GetCutStep(Int_t iVar) const {return (fMaxLimits[iVar]-fMinLimits[iVar])/(Float_t)fNCutSteps[iVar];} | |
42 | TString GetAxisTitle(Int_t iVar) const {return fAxisTitles[iVar];} | |
43 | Bool_t IsIntegrated() const {return fIsIntegrated;} | |
44 | ||
45 | void CopyStructure(const AliMultiDimVector* mv); | |
46 | ||
47 | Float_t GetCutValue(Int_t iVar, Int_t iCell) const{ | |
48 | if(fGreaterThan[iVar]) return fMinLimits[iVar]+(Float_t)iCell*GetCutStep(iVar); | |
49 | else return fMaxLimits[iVar]-(Float_t)iCell*GetCutStep(iVar); | |
50 | } | |
51 | Float_t GetElement(ULong64_t globadd) const {return fVett[globadd];} | |
2350a1d9 | 52 | Float_t GetElement(const Int_t *ind, Int_t ptbin) const { |
ac7636a0 | 53 | ULong64_t elem=GetGlobalAddressFromIndices(ind,ptbin); |
54 | return fVett[elem]; | |
55 | } | |
bac542b0 | 56 | Float_t GetPtLimit(Int_t i) const{return fPtLimits[i];} |
57 | Int_t GetPtBin(const Float_t pt) const{ | |
58 | Int_t theBin=TMath::BinarySearch(fNPtBins+1,fPtLimits,pt); | |
59 | if(theBin>=fNPtBins) theBin=-1; | |
60 | return theBin; | |
61 | } | |
ac7636a0 | 62 | void GetEntireMultiDimVector(Float_t *vett) const { |
63 | for(ULong64_t i=0; i<fNTotCells; i++) vett[i]=fVett[i]; | |
64 | } | |
65 | ||
66 | Bool_t GetIndicesFromGlobalAddress(ULong64_t globadd, Int_t *ind, Int_t &ptbin) const; | |
2350a1d9 | 67 | ULong64_t GetGlobalAddressFromIndices(const Int_t *ind, Int_t ptbin) const; |
68 | Bool_t GetIndicesFromValues(const Float_t *values, Int_t *ind) const; | |
69 | ULong64_t GetGlobalAddressFromValues(const Float_t *values, Int_t ptbin) const; | |
ac7636a0 | 70 | Bool_t GetCutValuesFromGlobalAddress(ULong64_t globadd, Float_t *cuts, Int_t &ptbin) const; |
bac542b0 | 71 | |
2350a1d9 | 72 | ULong64_t* GetGlobalAddressesAboveCuts(const Float_t *values, Float_t pt, Int_t& nVals) const{ |
bac542b0 | 73 | Int_t theBin=GetPtBin(pt); |
74 | if(theBin>=0) return GetGlobalAddressesAboveCuts(values,theBin,nVals); | |
75 | else return 0x0; | |
76 | } | |
2350a1d9 | 77 | ULong64_t* GetGlobalAddressesAboveCuts(const Float_t *values, Int_t ptbin, Int_t& nVals) const; |
ac7636a0 | 78 | |
79 | void SetElement(ULong64_t globadd,Float_t val) {fVett[globadd]=val;} | |
80 | void SetElement(Int_t *ind, Int_t ptbin, Float_t val){ | |
81 | ULong64_t elem=GetGlobalAddressFromIndices(ind,ptbin); | |
82 | fVett[elem]=val; | |
83 | } | |
84 | void IncrementElement(Int_t *ind, Int_t ptbin){ | |
85 | SetElement(ind,ptbin,GetElement(ind,ptbin)+1); | |
86 | } | |
87 | void IncrementElement(ULong64_t globadd){ | |
88 | SetElement(globadd,GetElement(globadd)+1.); | |
89 | } | |
90 | ||
91 | void Fill(Float_t* values, Int_t ptbin); | |
92 | void FillAndIntegrate(Float_t* values, Int_t ptbin); | |
93 | void Integrate(); | |
94 | ||
95 | void Reset(){ | |
96 | for(ULong64_t i=0; i<fNTotCells; i++) fVett[i]=0.; | |
97 | } | |
98 | void MultiplyBy(Float_t factor); | |
2350a1d9 | 99 | void Multiply(const AliMultiDimVector* mv,Float_t factor); |
100 | void Multiply(const AliMultiDimVector* mv1, const AliMultiDimVector* mv2); | |
101 | void Add(const AliMultiDimVector* mv); | |
102 | void Sum(const AliMultiDimVector* mv1, const AliMultiDimVector* mv2); | |
103 | void LinearComb(const AliMultiDimVector* mv1, Float_t norm1, const AliMultiDimVector* mv2, Float_t norm2); | |
104 | void DivideBy(const AliMultiDimVector* mv); | |
105 | void Divide(const AliMultiDimVector* mv1, const AliMultiDimVector* mv2); | |
ac7636a0 | 106 | void Sqrt(); |
2350a1d9 | 107 | void Sqrt(const AliMultiDimVector* mv); |
ac7636a0 | 108 | |
109 | void FindMaximum(Float_t& max_value, Int_t *ind, Int_t ptbin); | |
110 | ||
2350a1d9 | 111 | TH2F* Project(Int_t firstVar, Int_t secondVar, const Int_t* fixedVars, Int_t ptbin, Float_t norm=1.); |
ac7636a0 | 112 | |
2350a1d9 | 113 | void SuppressZeroBKGEffect(const AliMultiDimVector* BKG); |
bac542b0 | 114 | AliMultiDimVector* ShrinkPtBins(Int_t firstBin, Int_t lastBin); |
115 | void PrintStatus(); | |
ac7636a0 | 116 | |
117 | protected: | |
118 | void GetIntegrationLimits(Int_t iVar, Int_t iCell, Int_t& minbin, Int_t& maxbin) const; | |
119 | void GetFillRange(Int_t iVar, Int_t iCell, Int_t& minbin, Int_t& maxbin) const; | |
120 | Bool_t GetGreaterThan(Int_t iVar) const {return fGreaterThan[iVar];} | |
121 | Float_t CountsAboveCell(ULong64_t globadd) const; | |
122 | ||
123 | private: | |
124 | static const Int_t fgkMaxNVariables=10; // max. n. of selection variables | |
bac542b0 | 125 | static const Int_t fgkMaxNPtBins=10; // max. n. of Pt bins |
ac7636a0 | 126 | |
127 | Int_t fNVariables; // n. of selection variables | |
128 | Int_t fNPtBins; // n. of pt bins | |
bac542b0 | 129 | Float_t fPtLimits[fgkMaxNPtBins+1]; // limits of pt bins |
ac7636a0 | 130 | Int_t fNCutSteps[fgkMaxNVariables]; // n. of cut step for each variable |
131 | Float_t fMinLimits[fgkMaxNVariables]; // lower cut value for each variable | |
132 | Float_t fMaxLimits[fgkMaxNVariables]; // higher cut value for each variable | |
133 | Bool_t fGreaterThan[fgkMaxNVariables];// sign of the cut (> or <) | |
134 | TString fAxisTitles[fgkMaxNVariables]; // titles for variables | |
135 | TArrayF fVett; // array with n. of candidates vs. cuts | |
136 | ULong64_t fNTotCells; // total number of matrix elements | |
137 | Bool_t fIsIntegrated; // flag for integrated matrix | |
138 | ||
bac542b0 | 139 | ClassDef(AliMultiDimVector,2); // a multi-dimensional vector class |
ac7636a0 | 140 | |
141 | }; | |
142 | ||
143 | #endif |