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