New classes and test macro for significance maximisation in multi-dimensional cuts...
[u/mrichter/AliRoot.git] / PWG3 / vertexingHF / AliSignificanceCalculator.h
1 #ifndef ALISIGNIFICANCECALCULATOR_H
2 #define ALISIGNIFICANCECALCULATOR_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 calculate the statistical significance from          //
12 // AliMultiVeector objects for signal and background             //
13 // Origin: Francesco Prino (prino@to.infn.it)                    //
14 //                                                               //
15 ///////////////////////////////////////////////////////////////////
16
17 #include "AliMultiDimVector.h"
18 #include "TObject.h"
19
20 class AliSignificanceCalculator : public TObject{
21  public:
22   AliSignificanceCalculator();
23   AliSignificanceCalculator(AliMultiDimVector* sig, AliMultiDimVector* bkg, Float_t normsig=1., Float_t normbkg=1.);
24   AliSignificanceCalculator(AliMultiDimVector* sig, AliMultiDimVector* bkg, AliMultiDimVector* err2sig, AliMultiDimVector* err2bkg, Float_t normsig=1., Float_t normbkg=1.);
25
26   ~AliSignificanceCalculator();
27
28   void SetSignal(AliMultiDimVector* sig, Float_t norm=1.){
29     if(fSignal) delete fSignal;
30     fSignal=sig;
31     fNormSig=norm;
32     if(fSignal && fBackground) CalculateSignificance();
33   }
34   void SetBackground(AliMultiDimVector* bac, Float_t norm=1.){
35     if(fBackground) delete fBackground;
36     fBackground=bac;
37     fNormBkg=norm;
38     if(fSignal && fBackground) CalculateSignificance();
39   }
40   void SetErrSquareSignal(AliMultiDimVector* err2sig, Float_t norm=1.){
41     if(fErrSquareSignal) delete fErrSquareSignal;
42     fErrSquareSignal=err2sig;
43     fNormSig=norm;
44     if(fSignal && fBackground) CalculateSignificance();
45   }
46   void SetErrSquareBackground(AliMultiDimVector* err2bkg, Float_t norm=1.){
47     if(fErrSquareBackground) delete fErrSquareBackground;
48     fErrSquareBackground=err2bkg;
49     fNormBkg=norm;
50     if(fSignal && fBackground) CalculateSignificance();
51   }
52   
53   void SetNormalizations(Float_t normSig, Float_t normBkg){
54     fNormSig=normSig;
55     fNormBkg=normBkg;
56     if(fSignal && fBackground) CalculateSignificance();
57   }
58
59   AliMultiDimVector* GetSignal() const {return fSignal;}
60   AliMultiDimVector* GetBackground() const {return fBackground;}
61   AliMultiDimVector* GetSignificance() const {return fSignificance;}
62   AliMultiDimVector* GetSignificanceError() const {return fErrSignificance;}
63
64   void CalculateSignificance();
65   Float_t GetMaxSignificance(Int_t* cutIndices, Int_t ptbin) const{
66     Float_t sigMax=0;
67     if(fSignificance) fSignificance->FindMaximum(sigMax,cutIndices,ptbin);
68     return sigMax;
69   }
70   AliMultiDimVector* CalculatePurity() const;
71   AliMultiDimVector* CalculatePurityError() const;
72   AliMultiDimVector* CalculateSOverB() const;
73   AliMultiDimVector* CalculateSOverBError() const;
74
75  private:
76   Bool_t Check() const;
77   AliSignificanceCalculator(const AliSignificanceCalculator& c);
78   AliSignificanceCalculator& operator=(const AliSignificanceCalculator& c);
79
80   AliMultiDimVector* fSignal;              // signal matrix
81   AliMultiDimVector* fErrSquareSignal;     // matrix with err^2 for signal
82   AliMultiDimVector* fBackground;          // background matrix
83   AliMultiDimVector* fErrSquareBackground; // matrix with err^2 for background
84   AliMultiDimVector* fSignificance;        // significance matrix
85   AliMultiDimVector* fErrSignificance;     // matrix with error on significance
86   Float_t fNormSig;                        // signal normalization
87   Float_t fNormBkg;                        // background normalization
88
89   ClassDef(AliSignificanceCalculator,1); // class to compute and maximise significance
90
91 };
92
93 #endif