AliPhysics  323987d (323987d)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliMultiDimVector.h
Go to the documentation of this file.
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 
20 
21 #include "TArrayF.h"
22 #include "TArrayI.h"
23 #include "TNamed.h"
24 #include "TH2.h"
25 #include "TMath.h"
26 #include "TString.h"
27 
28 class AliMultiDimVector : public TNamed{
29 
30  public:
34  AliMultiDimVector(const char *name, const char *title, const Int_t nptbins,
35  const Float_t* ptlimits, const Int_t npars, const Int_t *nofcells, const Float_t *loosecuts, const Float_t *tightcuts, const TString *axisTitles);
36  virtual ~AliMultiDimVector(){};
37 
38  ULong64_t GetNTotCells() const {return fNTotCells;}
39  Int_t GetNVariables() const {return fNVariables;}
40  Int_t GetNPtBins() const {return fNPtBins;}
41  Int_t GetNCutSteps(Int_t iVar) const {return fNCutSteps[iVar];}
42  Float_t GetMinLimit(Int_t iVar) const {return fMinLimits[iVar];}
43  Float_t GetMaxLimit(Int_t iVar) const {return fMaxLimits[iVar];}
44  Float_t GetCutStep(Int_t iVar) const {return (fMaxLimits[iVar]-fMinLimits[iVar])/(Float_t)fNCutSteps[iVar];}
45  TString GetAxisTitle(Int_t iVar) const {return fAxisTitles[iVar];}
46  Bool_t IsIntegrated() const {return fIsIntegrated;}
47 
48  void CopyStructure(const AliMultiDimVector* mv);
49 
50  Float_t GetCutValue(Int_t iVar, Int_t iCell) const{
51  if(fGreaterThan[iVar]) return fMinLimits[iVar]+(Float_t)iCell*GetCutStep(iVar);
52  else return fMaxLimits[iVar]-(Float_t)iCell*GetCutStep(iVar);
53  }
54  Float_t GetElement(ULong64_t globadd) const {return fVett[globadd];}
55  Float_t GetElement(const Int_t *ind, Int_t ptbin) const {
56  ULong64_t elem=GetGlobalAddressFromIndices(ind,ptbin);
57  return fVett[elem];
58  }
59  Float_t GetPtLimit(Int_t i) const{return fPtLimits[i];}
60  Int_t GetPtBin(const Float_t pt) const{
61  Int_t theBin=TMath::BinarySearch(fNPtBins+1,fPtLimits,pt);
62  if(theBin>=fNPtBins) theBin=-1;
63  return theBin;
64  }
65  void GetEntireMultiDimVector(Float_t *vett) const {
66  for(ULong64_t i=0; i<fNTotCells; i++) vett[i]=fVett[i];
67  }
68 
69  Bool_t GetIndicesFromGlobalAddress(ULong64_t globadd, Int_t *ind, Int_t &ptbin) const;
70  ULong64_t GetGlobalAddressFromIndices(const Int_t *ind, Int_t ptbin) const;
71  Bool_t GetIndicesFromValues(const Float_t *values, Int_t *ind) const;
72  ULong64_t GetGlobalAddressFromValues(const Float_t *values, Int_t ptbin) const;
73  Bool_t GetCutValuesFromGlobalAddress(ULong64_t globadd, Float_t *cuts, Int_t &ptbin) const;
74 
75  ULong64_t* GetGlobalAddressesAboveCuts(const Float_t *values, Float_t pt, Int_t& nVals) const{
76  Int_t theBin=GetPtBin(pt);
77  if(theBin>=0) return GetGlobalAddressesAboveCuts(values,theBin,nVals);
78  else return 0x0;
79  }
80  ULong64_t* GetGlobalAddressesAboveCuts(const Float_t *values, Int_t ptbin, Int_t& nVals) const;
81  Bool_t GetGreaterThan(Int_t iVar) const {return fGreaterThan[iVar];}
82 
83  void SetElement(ULong64_t globadd,Float_t val) {fVett[globadd]=val;}
84  void SetElement(Int_t *ind, Int_t ptbin, Float_t val){
85  ULong64_t elem=GetGlobalAddressFromIndices(ind,ptbin);
86  if(elem>fNTotCells){
87  printf("SetElement: indices %d %d %d ptbin %d elem %d\n",ind[0],ind[1],ind[2],ptbin,(Int_t)elem);
88  }
89  fVett[elem]=val;
90  }
91  void IncrementElement(Int_t *ind, Int_t ptbin){
92  SetElement(ind,ptbin,GetElement(ind,ptbin)+1);
93  }
94  void IncrementElement(ULong64_t globadd){
95  SetElement(globadd,GetElement(globadd)+1.);
96  }
97 
98  void Fill(Float_t* values, Int_t ptbin);
99  void FillAndIntegrate(Float_t* values, Int_t ptbin);
100  void Integrate();
101 
102  void Reset(){
103  for(ULong64_t i=0; i<fNTotCells; i++) fVett[i]=0.;
104  }
105  void MultiplyBy(Float_t factor);
106  void Multiply(const AliMultiDimVector* mv,Float_t factor);
107  void Multiply(const AliMultiDimVector* mv1, const AliMultiDimVector* mv2);
108  void Add(const AliMultiDimVector* mv);
109  void Sum(const AliMultiDimVector* mv1, const AliMultiDimVector* mv2);
110  void LinearComb(const AliMultiDimVector* mv1, Float_t norm1, const AliMultiDimVector* mv2, Float_t norm2);
111  void DivideBy(const AliMultiDimVector* mv);
112  void Divide(const AliMultiDimVector* mv1, const AliMultiDimVector* mv2);
113  void Sqrt();
114  void Sqrt(const AliMultiDimVector* mv);
115 
116  void FindMaximum(Float_t& max_value, Int_t *ind, Int_t ptbin);
117  Int_t* FindLocalMaximum(Float_t& maxValue, Int_t *numFixed,Int_t* indFixed, Int_t nfixed,Int_t ptbin);
118 
119  TH2F* Project(Int_t firstVar, Int_t secondVar, const Int_t* fixedVars, Int_t ptbin, Float_t norm=1.);
120 
121  void SuppressZeroBKGEffect(const AliMultiDimVector* BKG);
122  AliMultiDimVector* ShrinkPtBins(Int_t firstBin, Int_t lastBin);
123 
124  void SetNewLimits(Float_t* loose,Float_t* tight);
125  void SwapLimits(Int_t ilim);
126 
127 
128  void PrintStatus();
129 
130  protected:
131  void GetIntegrationLimits(Int_t iVar, Int_t iCell, Int_t& minbin, Int_t& maxbin) const;
132  void GetFillRange(Int_t iVar, Int_t iCell, Int_t& minbin, Int_t& maxbin) const;
133  Float_t CountsAboveCell(ULong64_t globadd) const;
134 
135  //void SetMinLimits(Int_t nvar, Float_t* minlim);
136  //void SetMaxLimits(Int_t nvar, Float_t* maxlim);
137  private:
138  static const Int_t fgkMaxNVariables=10;
139  static const Int_t fgkMaxNPtBins=10;
140 
145  Float_t fMinLimits[fgkMaxNVariables]; // lower cut value for each variable
149  TArrayF fVett;
150  ULong64_t fNTotCells;
152 
154  ClassDef(AliMultiDimVector,2);
155 };
157 
158 #endif
static const Int_t fgkMaxNVariables
ULong64_t fNTotCells
array with n. of candidates vs. cuts
Definition: External.C:236
void FillAndIntegrate(Float_t *values, Int_t ptbin)
const char * title
Definition: MakeQAPdf.C:26
Bool_t fGreaterThan[fgkMaxNVariables]
higher cut value for each variable
void SuppressZeroBKGEffect(const AliMultiDimVector *BKG)
void LinearComb(const AliMultiDimVector *mv1, Float_t norm1, const AliMultiDimVector *mv2, Float_t norm2)
Float_t fMinLimits[fgkMaxNVariables]
n. of cut step for each variable
Int_t fNPtBins
n. of selection variables
void DivideBy(const AliMultiDimVector *mv)
Float_t fPtLimits[fgkMaxNPtBins+1]
n. of pt bins
Bool_t IsIntegrated() const
Bool_t fIsIntegrated
total number of matrix elements
Int_t GetNVariables() const
void SetElement(ULong64_t globadd, Float_t val)
Int_t fNVariables
max. n. of Pt bins
void CopyStructure(const AliMultiDimVector *mv)
Float_t GetCutStep(Int_t iVar) const
static const Int_t fgkMaxNPtBins
max. n. of selection variables
ULong64_t GetGlobalAddressFromValues(const Float_t *values, Int_t ptbin) const
Float_t GetPtLimit(Int_t i) const
void IncrementElement(ULong64_t globadd)
void FindMaximum(Float_t &max_value, Int_t *ind, Int_t ptbin)
Bool_t GetCutValuesFromGlobalAddress(ULong64_t globadd, Float_t *cuts, Int_t &ptbin) const
Float_t GetElement(const Int_t *ind, Int_t ptbin) const
Int_t GetNPtBins() const
int Int_t
Definition: External.C:63
void SetNewLimits(Float_t *loose, Float_t *tight)
void MultiplyBy(Float_t factor)
void IncrementElement(Int_t *ind, Int_t ptbin)
float Float_t
Definition: External.C:68
Bool_t GetGreaterThan(Int_t iVar) const
Int_t GetPtBin(const Float_t pt) const
TH2F * Project(Int_t firstVar, Int_t secondVar, const Int_t *fixedVars, Int_t ptbin, Float_t norm=1.)
Float_t GetCutValue(Int_t iVar, Int_t iCell) const
void SwapLimits(Int_t ilim)
void Add(const AliMultiDimVector *mv)
ULong64_t * GetGlobalAddressesAboveCuts(const Float_t *values, Float_t pt, Int_t &nVals) const
Float_t fMaxLimits[fgkMaxNVariables]
void SetElement(Int_t *ind, Int_t ptbin, Float_t val)
void Sum(const AliMultiDimVector *mv1, const AliMultiDimVector *mv2)
ULong64_t GetGlobalAddressFromIndices(const Int_t *ind, Int_t ptbin) const
void Multiply(const AliMultiDimVector *mv, Float_t factor)
void Divide(const AliMultiDimVector *mv1, const AliMultiDimVector *mv2)
Float_t GetMaxLimit(Int_t iVar) const
ULong64_t GetNTotCells() const
Int_t GetNCutSteps(Int_t iVar) const
void Fill(Float_t *values, Int_t ptbin)
Int_t * FindLocalMaximum(Float_t &maxValue, Int_t *numFixed, Int_t *indFixed, Int_t nfixed, Int_t ptbin)
AliMultiDimVector & operator=(const AliMultiDimVector &mv)
Bool_t GetIndicesFromValues(const Float_t *values, Int_t *ind) const
AliMultiDimVector * ShrinkPtBins(Int_t firstBin, Int_t lastBin)
TString fAxisTitles[fgkMaxNVariables]
sign of the cut (> or <)
TString GetAxisTitle(Int_t iVar) const
void GetEntireMultiDimVector(Float_t *vett) const
Float_t CountsAboveCell(ULong64_t globadd) const
Int_t fNCutSteps[fgkMaxNVariables]
limits of pt bins
void GetFillRange(Int_t iVar, Int_t iCell, Int_t &minbin, Int_t &maxbin) const
Float_t GetMinLimit(Int_t iVar) const
bool Bool_t
Definition: External.C:53
void GetIntegrationLimits(Int_t iVar, Int_t iCell, Int_t &minbin, Int_t &maxbin) const
Bool_t GetIndicesFromGlobalAddress(ULong64_t globadd, Int_t *ind, Int_t &ptbin) const
virtual ~AliMultiDimVector()
Int_t nptbins
Float_t GetElement(ULong64_t globadd) const
TArrayF fVett
titles for variables