ROOT logo
// Author: Daniel.Lohner@cern.ch

#ifndef ALIROOT_AliTRDNDFast
#define ALIROOT_AliTRDNDFast

#ifndef ROOT_TH1
#include "TH1F.h"
#endif
#ifndef ROOT_TArrayF
#include "TArrayF.h"
#endif
#ifndef ROOT_TF2
#include "TF1.h"
#endif
#ifndef ROOT_TMath
#include "TMath.h"
#endif
#ifndef ROOT_TRandom
#include "TRandom.h"
#endif

using namespace std;

extern Double_t langaufun(Double_t *x,Double_t *par);

class AliTRDNDFast : public TObject {

public:
    static const Int_t kNpar = 5;

    AliTRDNDFast();
    AliTRDNDFast(const char *name,Int_t ndim,Int_t nbins,Double_t xlow,Double_t xup);
    AliTRDNDFast(const AliTRDNDFast&);
    AliTRDNDFast &operator=(const AliTRDNDFast &ref);
    virtual ~AliTRDNDFast();
    
    TF1 *FitLandau(TString name,TH1F *htemp,Double_t range[2],TString option);

    void Build(TH1F **hdEdx,TString path="");
    void Build(Double_t **pars);
    Double_t Eval(Double_t *point) const;
    void Random(Double_t *point) const;
    Int_t GetNDim(){return fNDim;};
    Double_t GetParam(Int_t dim,Int_t par){if((dim>=0)&&(dim<fNDim)&&(par>=0)&&(par<kNpar)){return fPars[par].GetAt(dim);}else{return 0;}};
    void PrintPars();
    static void Random(Double_t *point,AliTRDNDFast *nd0,AliTRDNDFast *nd1,Double_t w0,Double_t w1);

private:

    void ScaleLangauFun(TF1 *func,Double_t mpv);
    TF1 *GetLangauFun(TString funcname,Double_t range[2],Double_t scalefactor=1);
    void BuildHistos();
    void Init();
    void Cleanup();
    
    static Int_t BinarySearchInterpolation(Int_t start,Int_t end,Double_t *a0,Double_t *a1,Double_t w0,Double_t w1,Double_t val);
    static Double_t GetRandomInterpolation(TH1F *hist0,TH1F *hist1,Double_t w0,Double_t w1);

    Int_t fNDim; // Dimensions
    TString fTitle; //title
    TF1 **fFunc; //! functions, do not store
    TH1F **fHistos; //[fNDim] Histograms
    TArrayF fPars[kNpar]; // parameters

    ClassDef(AliTRDNDFast,1)  //Fast TRD ND class
};

#endif
 AliTRDNDFast.h:1
 AliTRDNDFast.h:2
 AliTRDNDFast.h:3
 AliTRDNDFast.h:4
 AliTRDNDFast.h:5
 AliTRDNDFast.h:6
 AliTRDNDFast.h:7
 AliTRDNDFast.h:8
 AliTRDNDFast.h:9
 AliTRDNDFast.h:10
 AliTRDNDFast.h:11
 AliTRDNDFast.h:12
 AliTRDNDFast.h:13
 AliTRDNDFast.h:14
 AliTRDNDFast.h:15
 AliTRDNDFast.h:16
 AliTRDNDFast.h:17
 AliTRDNDFast.h:18
 AliTRDNDFast.h:19
 AliTRDNDFast.h:20
 AliTRDNDFast.h:21
 AliTRDNDFast.h:22
 AliTRDNDFast.h:23
 AliTRDNDFast.h:24
 AliTRDNDFast.h:25
 AliTRDNDFast.h:26
 AliTRDNDFast.h:27
 AliTRDNDFast.h:28
 AliTRDNDFast.h:29
 AliTRDNDFast.h:30
 AliTRDNDFast.h:31
 AliTRDNDFast.h:32
 AliTRDNDFast.h:33
 AliTRDNDFast.h:34
 AliTRDNDFast.h:35
 AliTRDNDFast.h:36
 AliTRDNDFast.h:37
 AliTRDNDFast.h:38
 AliTRDNDFast.h:39
 AliTRDNDFast.h:40
 AliTRDNDFast.h:41
 AliTRDNDFast.h:42
 AliTRDNDFast.h:43
 AliTRDNDFast.h:44
 AliTRDNDFast.h:45
 AliTRDNDFast.h:46
 AliTRDNDFast.h:47
 AliTRDNDFast.h:48
 AliTRDNDFast.h:49
 AliTRDNDFast.h:50
 AliTRDNDFast.h:51
 AliTRDNDFast.h:52
 AliTRDNDFast.h:53
 AliTRDNDFast.h:54
 AliTRDNDFast.h:55
 AliTRDNDFast.h:56
 AliTRDNDFast.h:57
 AliTRDNDFast.h:58
 AliTRDNDFast.h:59
 AliTRDNDFast.h:60
 AliTRDNDFast.h:61
 AliTRDNDFast.h:62
 AliTRDNDFast.h:63
 AliTRDNDFast.h:64
 AliTRDNDFast.h:65
 AliTRDNDFast.h:66
 AliTRDNDFast.h:67
 AliTRDNDFast.h:68