AliPhysics  db95e02 (db95e02)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliTHn.h
Go to the documentation of this file.
1 #ifndef AliTHn_H
2 #define AliTHn_H
3 
4 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5  * See cxx source for full Copyright notice */
6 
7 // optimized data container reusing functionality of AliCFContainer / THnsparse
8 //
9 // Use AliTHn instead of AliCFContainer and your memory consumption will be drastically reduced
10 // As AliTHn derives from AliCFContainer, you can just replace your current AliCFContainer object by AliTHn
11 // Once you have the merged output, call FillParent() and you can use AliCFContainer as usual
12 
13 #include "TObject.h"
14 #include "TString.h"
15 #include "AliCFContainer.h"
16 
17 class TArray;
18 class TArrayF;
19 class TArrayD;
20 class TCollection;
21 
22 class AliTHnBase : public AliCFContainer
23 {
24 public:
25  AliTHnBase() : AliCFContainer() { }
26  AliTHnBase(const Char_t* name, const Char_t* title,const Int_t nSelStep, const Int_t nVarIn, const Int_t* nBinIn) : AliCFContainer(name, title, nSelStep, nVarIn, nBinIn) { }
27 
28  virtual void Fill(const Double_t *var, Int_t istep, Double_t weight=1.) = 0;
29  virtual void FillParent() = 0;
30  virtual void FillContainer(AliCFContainer* cont) = 0;
31 
32  virtual TArray* GetValues(Int_t step) = 0;
33  virtual TArray* GetSumw2(Int_t step) = 0;
34 
35  virtual void DeleteContainers() = 0;
36  virtual void ReduceAxis() = 0;
37 
38  ClassDef(AliTHnBase, 1) // AliTHn base class
39 };
40 
41 template <class TemplateArray, typename TemplateType>
42 class AliTHnT : public AliTHnBase
43 {
44  public:
45  AliTHnT();
46  AliTHnT(const Char_t* name, const Char_t* title,const Int_t nSelStep, const Int_t nVarIn, const Int_t* nBinIn);
47 
48  virtual ~AliTHnT();
49 
50  virtual void Fill(const Double_t *var, Int_t istep, Double_t weight=1.) ;
51  virtual void FillParent();
52  virtual void FillContainer(AliCFContainer* cont);
53 
54  virtual TArray* GetValues(Int_t step) { return fValues[step]; }
55  virtual TArray* GetSumw2(Int_t step) { return fSumw2[step]; }
56 
57  virtual void DeleteContainers();
58  virtual void ReduceAxis();
59 
60  AliTHnT(const AliTHnT &c);
61  AliTHnT& operator=(const AliTHnT& corr);
62  virtual void Copy(TObject& c) const;
63 
64  virtual Long64_t Merge(TCollection* list);
65 
66 protected:
67  void Init();
68  Long64_t GetGlobalBinIndex(const Int_t* binIdx);
69 
70  Long64_t fNBins; // number of total bins
71  Int_t fNVars; // number of variables
72  Int_t fNSteps; // number of selection steps
73  TemplateArray **fValues; //[fNSteps] data container
74  TemplateArray **fSumw2; //[fNSteps] data container
75 
80 
81  ClassDef(AliTHnT, 5) // THn like container
82 };
83 
86 
87 #endif
double Double_t
Definition: External.C:58
const char * title
Definition: MakeQAPdf.C:26
Double_t * fLastVars
cache Nbins per axis
Definition: AliTHn.h:78
virtual void FillParent()
Definition: AliTHn.cxx:447
virtual Long64_t Merge(TCollection *list)
Definition: AliTHn.cxx:233
long long Long64_t
Definition: External.C:43
AliTHnBase()
Definition: AliTHn.h:25
virtual void DeleteContainers()
Definition: AliTHn.cxx:141
char Char_t
Definition: External.C:18
TList * list
TCanvas * c
Definition: TestFitELoss.C:172
virtual TArray * GetValues(Int_t step)=0
Int_t * fNbinsCache
cache axis pointers (about 50% of the time in Fill is spent in GetAxis otherwise) ...
Definition: AliTHn.h:77
AliTHnT< TArrayF, Float_t > AliTHn
Definition: AliTHn.h:84
virtual void Copy(TObject &c) const
Definition: AliTHn.cxx:203
TemplateArray ** fSumw2
Definition: AliTHn.h:74
Long64_t GetGlobalBinIndex(const Int_t *binIdx)
Definition: AliTHn.cxx:364
int Int_t
Definition: External.C:63
TemplateArray ** fValues
Definition: AliTHn.h:73
Definition: AliTHn.h:42
Int_t fNSteps
Definition: AliTHn.h:72
virtual void FillParent()=0
virtual void FillContainer(AliCFContainer *cont)
Definition: AliTHn.cxx:381
virtual void Fill(const Double_t *var, Int_t istep, Double_t weight=1.)
Definition: AliTHn.cxx:285
AliTHnT & operator=(const AliTHnT &corr)
Definition: AliTHn.cxx:163
Int_t * fLastBins
caching of last used bins (in many loops some vars are the same for a while)
Definition: AliTHn.h:79
virtual ~AliTHnT()
Definition: AliTHn.cxx:126
TAxis ** axisCache
Definition: AliTHn.h:76
virtual void DeleteContainers()=0
virtual TArray * GetValues(Int_t step)
Definition: AliTHn.h:54
virtual void Fill(const Double_t *var, Int_t istep, Double_t weight=1.)=0
virtual void FillContainer(AliCFContainer *cont)=0
AliTHnT< TArrayD, Double_t > AliTHnD
Definition: AliTHn.h:85
AliTHnBase(const Char_t *name, const Char_t *title, const Int_t nSelStep, const Int_t nVarIn, const Int_t *nBinIn)
Definition: AliTHn.h:26
Int_t fNVars
Definition: AliTHn.h:71
Long64_t fNBins
Definition: AliTHn.h:70
AliTHnT()
Definition: AliTHn.cxx:46
void Init()
virtual void ReduceAxis()
Definition: AliTHn.cxx:455
virtual TArray * GetSumw2(Int_t step)=0
virtual TArray * GetSumw2(Int_t step)
Definition: AliTHn.h:55
virtual void ReduceAxis()=0