AliRoot Core  edcc906 (edcc906)
AliNDLocalRegression.h
Go to the documentation of this file.
1 #ifndef ALINDLOCALREGRESSION_H
2 #define ALINDLOCALREGRESSION_H
3 /* Copyright(c) 2006-07, ALICE Experiment at CERN, All rights reserved. *
4  * See cxx source for full Copyright notice */
5 
6 #include "TGraph.h"
7 #include "TGraphSmooth.h"
8 #include "TRandom.h"
9 #include "TSpline.h"
10 #include "TLinearFitter.h"
11 #include "TDecompSVD.h"
12 #include "TDecompSparse.h"
13 #include "TMatrixDSparse.h"
14 #include "TF1.h"
15 #include "TH1F.h"
16 #include "TNamed.h"
17 #include "TClonesArray.h"
18 #include "TMath.h"
19 
20 
21 #include "TTreeStream.h"
22 class TTreeSRedirector;
23 class THn;
24 class TObjString;
25 
26 class AliNDLocalRegression : public TNamed {
27  public:
29  AliNDLocalRegression(const char* name, const char* title);
31 
32  Bool_t MakeFit(TTree * tree , const char *formulaVal, const char * formulaVar, const char*selection, const char * formulaKernel, const char * dimensionFormula, Double_t weightCut=0.00001, Int_t entries=1000000000, Bool_t useBinNorm=kTRUE);
33  Bool_t CleanCovariance();
34  Double_t Eval(Double_t *point);
35  Double_t EvalError(Double_t *point);
36  Bool_t Derivative(Double_t *point, Double_t *d);
37  Bool_t EvalAndDerivative(Double_t *point, Double_t &val, Double_t *d);
38  const THn *GetHistogram() {return fHistPoints;}
39  const TObjArray * GetFitParam(){ return fLocalFitParam;}
40  void SetCuts(Double_t nSigma=6, Double_t robustFraction=0.95, Int_t estimator=1);
41  void SetHistogram(THn* histo );
42  void SetTree(TTree * tree) {fInputTree = tree;}
44  void SetStreamer( TTreeSRedirector *streamer){ fStreamer=streamer;}
45  Bool_t AddWeekConstrainsAtBoundaries(Int_t nDims, Int_t *indexes, Double_t *relWeight, TTreeSRedirector* pcstream, Bool_t useCommon=kFALSE);
46  void DumpToTree(Int_t div, TTreeStream & stream);
47  //
48  const TObjArray *GetLocalFitParam() const { return fLocalFitParam; }
49  const TObjArray *GetLocalFitQuality() const { return fLocalFitQuality; }
50  const TObjArray *GetLocalFitCovar() const { return fLocalFitCovar; }
51  //
52  const TMatrixD *GetLocalRobustStat() const { return fLocalRobustStat; }
53  //
54  // function to access the Local Regression from the TFormula
55  static void AddVisualCorrection(AliNDLocalRegression* corr, Int_t position=0);
56  static AliNDLocalRegression* GetVisualCorrection(Int_t position);
57  static AliNDLocalRegression* GetVisualCorrection(const char *corName){return (fgVisualCorrection==NULL) ? 0: ( AliNDLocalRegression*) fgVisualCorrection->FindObject(corName);}
58  static Int_t GetVisualCorrectionIndex(const char *corName);
61  //
62  static Double_t GetCorrND(Double_t index, Double_t par0);
63  static Double_t GetCorrNDError(Double_t index, Double_t par0);
64  static Double_t GetCorrND(Double_t index, Double_t par0,Double_t par1);
65  static Double_t GetCorrNDError(Double_t index, Double_t par0,Double_t par1);
66  static Double_t GetCorrND(Double_t index, Double_t par0,Double_t par1, Double_t par2);
67  static Double_t GetCorrNDError(Double_t index, Double_t par0,Double_t par1, Double_t par2);
68  static Double_t GetCorrND(Double_t index, Double_t par0,Double_t par1, Double_t par2, Double_t par3);
69  static Double_t GetCorrNDError(Double_t index, Double_t par0,Double_t par1, Double_t par2, Double_t par3);
70  static void SetVerboseLevel(Int_t verbose){ fgVerboseLevel=TMath::Max(verbose,1);}
71  //
72  static Double_t EvalGraphKernel(TGraph * gr, Double_t evalTime, Double_t kernelWidth, Double_t sigmaCut=3, Bool_t evalLog=kFALSE, Int_t pol=1, TVectorD *param=0, TMatrixD *covar=0);
73  public:
74  Bool_t MakeRobustStatistic(TVectorD &values,TVectorD &errors, TObjArray &pointArray, TObjArray &kernelArrayI2, Double_t weightCut, Double_t robustFraction);
75 
76 protected:
77  THn *fHistPoints; // histogram local point distoribution
78  Double_t fRobustFractionLTS; // fraction of data used for the robust mean and robust rms estimator (LTS https://en.wikipedia.org/wiki/Least_trimmed_squares)
79  Double_t fRobustRMSLTSCut; // cut on the robust RMS |value-localmean|<fRobustRMSLTSCut*localRMS
80  Int_t fCutType; // type of the cut 0- no cut 1-cut localmean=median, 2-cut localmen=rosbut mean
81  TTree * fInputTree; // ! input tree - object not owner
82  TTreeSRedirector * fStreamer; // ! streamer to keep - test intermediate data
83  //
84  TObjString *fFormulaVal; // value:error definition formula
85  TObjString *fSelection; // point selector formula
86  //
87  TObjString *fFormulaVar; // :separated variable definition formula
88  TObjString *fKernelWidthFormula; //: separated - kernel width for the regression
89  TObjString *fPolDimensionFormula; //: separated - polynom for the regression
90  //
91  Int_t fNVar; // number of variables
92  Int_t fNParameters; // number of local parameters to fit
93  //
94  TObjArray *fLocalFitParam; // local fit parameters + RMS + chi2
95  TObjArray *fLocalFitQuality; // local fit npoints chi2
96  TObjArray *fLocalFitCovar; // local fit covariance matrix
97  //
98  TMatrixD *fLocalRobustStat; // local robust statistic
99 protected:
101  static Int_t fgVerboseLevel;
102  Int_t *fBinIndex; //[fNParameters] working arrays current bin index
103  Double_t *fBinCenter; //[fNParameters] working current local variables - bin center
104  Double_t *fBinDelta; //[fNParameters] working current local variables - bin delta
105  Double_t *fBinWidth; //[fNParameters] working current local variables - bin delta
106  Bool_t fUseBinNorm; // switch make polynom in units of bins (kTRUE) or in natural units (kFALSE)
107 private:
110  ClassDef(AliNDLocalRegression, 2);
111 };
112 #endif
static Int_t fgVerboseLevel
verbose level
TObjString * fPolDimensionFormula
static Double_t GetCorrND(Double_t index, Double_t par0)
Bool_t MakeFit(TTree *tree, const char *formulaVal, const char *formulaVar, const char *selection, const char *formulaKernel, const char *dimensionFormula, Double_t weightCut=0.00001, Int_t entries=1000000000, Bool_t useBinNorm=kTRUE)
#define TObjArray
static AliNDLocalRegression * GetVisualCorrection(Int_t position)
const TObjArray * GetLocalFitParam() const
TTreeSRedirector * pcstream
Bool_t AddWeekConstrainsAtBoundaries(Int_t nDims, Int_t *indexes, Double_t *relWeight, TTreeSRedirector *pcstream, Bool_t useCommon=kFALSE)
TTreeSRedirector * GetStreamer()
void SetStreamer(TTreeSRedirector *streamer)
Bool_t MakeRobustStatistic(TVectorD &values, TVectorD &errors, TObjArray &pointArray, TObjArray &kernelArrayI2, Double_t weightCut, Double_t robustFraction)
TTree * tree
Double_t sigmaCut
Definition: DIMUONFakes.C:36
static void AddVisualCorrection(AliNDLocalRegression *corr, Int_t position=0)
static TObjArray * fgVisualCorrection
array of orrection for visualization
TObjString * fKernelWidthFormula
Double_t EvalError(Double_t *point)
TTreeSRedirector * fStreamer
static Double_t EvalGraphKernel(TGraph *gr, Double_t evalTime, Double_t kernelWidth, Double_t sigmaCut=3, Bool_t evalLog=kFALSE, Int_t pol=1, TVectorD *param=0, TMatrixD *covar=0)
TGraph * gr
Definition: CalibTime.C:25
static Double_t GetCorrNDError(Double_t index, Double_t par0)
static TObjArray * GetVisualCorrections()
AliNDLocalRegression & operator=(const AliNDLocalRegression &)
TVectorD errors
Definition: driftITSTPC.C:97
Bool_t Derivative(Double_t *point, Double_t *d)
static AliNDLocalRegression * GetVisualCorrection(const char *corName)
const TObjArray * GetFitParam()
Bool_t EvalAndDerivative(Double_t *point, Double_t &val, Double_t *d)
class TVectorT< Double_t > TVectorD
static void SetVerboseLevel(Int_t verbose)
const TObjArray * GetLocalFitQuality() const
const TMatrixD * GetLocalRobustStat() const
void SetCuts(Double_t nSigma=6, Double_t robustFraction=0.95, Int_t estimator=1)
void SetTree(TTree *tree)
Double_t Eval(Double_t *point)
class TMatrixT< Double_t > TMatrixD
void DumpToTree(Int_t div, TTreeStream &stream)
const TObjArray * GetLocalFitCovar() const