]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG0/AliUnfolding.h
Fix for RETURN_LOCAL problem reported by Coverity
[u/mrichter/AliRoot.git] / PWG0 / AliUnfolding.h
CommitLineData
e6339065 1/* $Id$ */
2
3#ifndef ALIUNFOLDING_H
4#define ALIUNFOLDING_H
5
6//
7// class that implements several unfolding methods
19442b86 8// I.e. chi2 minimization and bayesian unfolding
9// The whole class is static and not thread-safe (due to the fact that MINUIT unfolding is not thread-safe)
e6339065 10//
11
12// TMatrixD, TVectorD defined here, because it does not seem possible to predeclare these (or i do not know how)
13// -->
14// $ROOTSYS/include/TVectorDfwd.h:21: conflicting types for `typedef struct TVectorT<Double_t> TVectorD'
15// PWG0/AliUnfolding.h:21: previous declaration as `struct TVectorD'
16
17#include "TObject.h"
18#include <TMatrixD.h>
19#include <TVectorD.h>
20
21class TH1;
22class TH2;
e6339065 23class TF1;
e6339065 24
25class AliUnfolding : public TObject
26{
27 public:
95e970ca 28 enum RegularizationType { kNone = 0, kPol0, kPol1, kLog, kEntropy, kCurvature, kRatio };
19442b86 29 enum MethodType { kInvalid = -1, kChi2Minimization = 0, kBayesian = 1, kFunction = 2};
e6339065 30
19442b86 31 virtual ~AliUnfolding() {};
e6339065 32
19442b86 33 static void SetUnfoldingMethod(MethodType methodType);
34 static void SetCreateOverflowBin(Float_t overflowBinLimit);
35 static void SetSkipBinsBegin(Int_t nBins);
36 static void SetNbins(Int_t nMeasured, Int_t nUnfolded);
37 static void SetChi2Regularization(RegularizationType type, Float_t weight);
38 static void SetMinuitStepSize(Float_t stepSize) { fgMinuitStepSize = stepSize; }
95e970ca 39 static void SetMinimumInitialValue(Bool_t flag, Float_t value = -1) { fgMinimumInitialValue = flag; fgMinimumInitialValueFix = value; }
19442b86 40 static void SetNormalizeInput(Bool_t flag) { fgNormalizeInput = flag; }
95e970ca 41 static void SetNotFoundEvents(Float_t notFoundEvents) { fgNotFoundEvents = notFoundEvents; }
42 static void SetSkip0BinInChi2(Bool_t flag) { fgSkipBin0InChi2 = flag; }
19442b86 43 static void SetBayesianParameters(Float_t smoothing, Int_t nIterations);
44 static void SetFunction(TF1* function);
45 static void SetDebug(Bool_t flag) { fgDebug = flag; }
e6339065 46
19442b86 47 static Int_t Unfold(TH2* correlation, TH1* efficiency, TH1* measured, TH1* initialConditions, TH1* result, Bool_t check = kFALSE);
95e970ca 48 static Int_t UnfoldGetBias(TH2* correlation, TH1* efficiency, TH1* measured, TH1* initialConditions, TH1* result);
e6339065 49
95e970ca 50 static TH1* GetPenaltyPlot(Double_t* params);
51 static TH1* GetPenaltyPlot(TH1* corrected);
52
19442b86 53 protected:
54 AliUnfolding() {};
e6339065 55
19442b86 56 static Int_t UnfoldWithMinuit(TH2* correlation, TH1* efficiency, TH1* measured, TH1* initialConditions, TH1* result, Bool_t check);
57 static Int_t UnfoldWithBayesian(TH2* correlation, TH1* aEfficiency, TH1* measured, TH1* initialConditions, TH1* aResult);
58 static Int_t UnfoldWithFunction(TH2* correlation, TH1* efficiency, TH1* measured, TH1* /* initialConditions */, TH1* aResult);
59
60 static void DrawGuess(Double_t *params);
61 static void CreateOverflowBin(TH2* correlation, TH1* measured);
95e970ca 62 static void SetStaticVariables(TH2* correlation, TH1* measured, TH1* efficiency);
e6339065 63
e6339065 64 static Double_t RegularizationPol0(TVectorD& params);
65 static Double_t RegularizationPol1(TVectorD& params);
66 static Double_t RegularizationTotalCurvature(TVectorD& params);
67 static Double_t RegularizationEntropy(TVectorD& params);
68 static Double_t RegularizationLog(TVectorD& params);
95e970ca 69 static Double_t RegularizationRatio(TVectorD& params);
e6339065 70
19442b86 71 static void Chi2Function(Int_t&, Double_t*, Double_t& chi2, Double_t *params, Int_t);
72 static void TF1Function(Int_t& unused1, Double_t* unused2, Double_t& chi2, Double_t *params, Int_t unused3);
e6339065 73
74 // static variable to be accessed by MINUIT
19442b86 75 static TMatrixD* fgCorrelationMatrix; // contains fCurrentCorrelation in matrix form
95e970ca 76 static TMatrixD* fgCorrelationMatrixSquared; // contains squared fCurrentCorrelation in matrix form
19442b86 77 static TMatrixD* fgCorrelationCovarianceMatrix; // contains the errors of fCurrentESD
78 static TVectorD* fgCurrentESDVector; // contains fCurrentESD
79 static TVectorD* fgEntropyAPriori; // a-priori distribution for entropy regularization
95e970ca 80 static TVectorD* fgEfficiency; // efficiency
81 static TVectorD* fgBinWidths; // bin widths to be taken into account in regularization
19442b86 82
83 static TF1* fgFitFunction; // fit function
e6339065 84
19442b86 85 // --- configuration params follow ---
86 static MethodType fgMethodType; // unfolding method to be used
87 static Int_t fgMaxParams; // bins in unfolded histogram = number of fit params
88 static Int_t fgMaxInput; // bins in measured histogram
89 static Float_t fgOverflowBinLimit; // to fix fluctuations at high multiplicities, all entries above the limit are summarized in one bin
e6339065 90
19442b86 91 static RegularizationType fgRegularizationType; // regularization that is used during Chi2 method
92 static Float_t fgRegularizationWeight; // factor for regularization term
93 static Int_t fgSkipBinsBegin; // (optional) skip the given number of bins in the regularization
94 static Float_t fgMinuitStepSize; // (usually not needed to be changed) step size in minimization
95e970ca 95 static Bool_t fgMinimumInitialValue; // set all initial values at least to the smallest value among the initial values
96 static Float_t fgMinimumInitialValueFix; // use this as the minimum initial value instead of determining it automatically
19442b86 97 static Bool_t fgNormalizeInput; // normalize input spectrum
95e970ca 98 static Float_t fgNotFoundEvents; // constraint on the total number of not found events sum(guess * (1/eff -1))
99 static Bool_t fgSkipBin0InChi2; // skip bin 0 (= 0 measured) in chi2 function
e6339065 100
19442b86 101 static Float_t fgBayesianSmoothing; // smoothing parameter (0 = no smoothing)
102 static Int_t fgBayesianIterations; // number of iterations in Bayesian method
e6339065 103
19442b86 104 static Bool_t fgDebug; // debug flag
105 // --- end of configuration ---
95e970ca 106
107 static Int_t fgCallCount; // call count to chi2 function
e6339065 108
19442b86 109private:
e6339065 110 AliUnfolding(const AliUnfolding&);
111 AliUnfolding& operator=(const AliUnfolding&);
112
113 ClassDef(AliUnfolding, 0);
114};
115
116#endif
117