1 | // ESAF : Euso Simulation and Analysis Framework |
---|
2 | // $Id: EsafSpectrum.hh 1786 2005-04-26 15:38:55Z thea $ |
---|
3 | // R.Pesce created Oct, 31 2003 |
---|
4 | |
---|
5 | // |
---|
6 | // spectrum facility |
---|
7 | // Able to generate random number according to the defined distribution |
---|
8 | // Use Float_t arrays |
---|
9 | // |
---|
10 | |
---|
11 | |
---|
12 | #ifndef __EUSOSPECTRUM_HH_ |
---|
13 | #define __EUSOSPECTRUM_HH_ |
---|
14 | |
---|
15 | #include "euso.hh" |
---|
16 | #include "TH1.h" |
---|
17 | #include "TF1.h" |
---|
18 | #include "TAxis.h" |
---|
19 | #include "TFormula.h" |
---|
20 | #include "TGraph.h" |
---|
21 | #include "TString.h" |
---|
22 | #include "EsafMsgSource.hh" |
---|
23 | |
---|
24 | class EsafSpectrum: public EsafMsgSource { |
---|
25 | public: |
---|
26 | EsafSpectrum(); |
---|
27 | EsafSpectrum(Float_t wl); |
---|
28 | EsafSpectrum(Float_t wlmin, Float_t wlmax); |
---|
29 | EsafSpectrum(const char* name); |
---|
30 | EsafSpectrum(const TH1F* histo); |
---|
31 | EsafSpectrum(const TF1* func); |
---|
32 | EsafSpectrum(TFormula* formula, Int_t nbins, Float_t xmin, Float_t xmax); |
---|
33 | // copy ctor |
---|
34 | EsafSpectrum(const EsafSpectrum&); |
---|
35 | virtual ~EsafSpectrum(); |
---|
36 | |
---|
37 | void Copy(EsafSpectrum&) const; |
---|
38 | |
---|
39 | void Reset(Float_t wl); |
---|
40 | void Reset(Float_t wlmin, Float_t wlmax); |
---|
41 | void Reset(const TH1F* histo); |
---|
42 | void Reset(const TF1* func); |
---|
43 | void Reset(TFormula* formula, Int_t nbins, Float_t xmin, Float_t xmax); |
---|
44 | |
---|
45 | Float_t GetLambda() const; |
---|
46 | Float_t GetLambda(Int_t i) const; |
---|
47 | |
---|
48 | inline Float_t GetLambdaMin() const {return (Float_t)fAxis.GetXmin();} |
---|
49 | inline Float_t GetLambdaMax() const {return (Float_t)fAxis.GetXmax();} |
---|
50 | |
---|
51 | inline Float_t GetLambdaEntry(Int_t i) const { return (Float_t)fAxis.GetBinCenter(i+1); } |
---|
52 | |
---|
53 | // GetMember methods |
---|
54 | inline const TAxis& GetAxis() const {return fAxis;} |
---|
55 | inline const TGraph* GetGraph() const {return fGraph;} |
---|
56 | inline const TString& GetString() const {return fName;} |
---|
57 | inline const Float_t* GetSpec() const {return fSpectrum.GetArray();} |
---|
58 | inline const Float_t* GetIntegral() const {return fIntegral.GetArray();} |
---|
59 | inline const char* GetName() const {return fName.Data();} |
---|
60 | // return the " fSpectrum[i]*binwidth[i] " |
---|
61 | inline Float_t GetWeight(Int_t i) const {return (i == 0) ? fIntegral[0] : fIntegral[i] - fIntegral[i-1];} |
---|
62 | |
---|
63 | // fill all the bins with the given value |
---|
64 | void Clear(Float_t val = 1); |
---|
65 | void Draw(); |
---|
66 | |
---|
67 | // convolute the spectrum with the given table of coefficients |
---|
68 | // spectrum is renormalized (integration equal to one) |
---|
69 | // and the normalization value is returned |
---|
70 | Float_t ConvoluteAndNormalize(const Double_t*); |
---|
71 | |
---|
72 | // idem ConvoluteAndNormalize() method, but WITHOUT renormalization |
---|
73 | void Convolute(const Double_t*); |
---|
74 | |
---|
75 | private: |
---|
76 | void BuildMono(Float_t wl); |
---|
77 | void BuildFlat(Float_t wlmin, Float_t wlmax); |
---|
78 | void BuildHisto(const TH1F* histo); |
---|
79 | void BuildFunction(const TF1* func); |
---|
80 | void BuildFormula(TFormula* formula, Int_t nbins, Float_t xmin, Float_t xmax); |
---|
81 | |
---|
82 | void BuildTest(); |
---|
83 | |
---|
84 | inline void SetArraysSize( Int_t ); |
---|
85 | |
---|
86 | TArrayF fSpectrum; |
---|
87 | TArrayF fIntegral; |
---|
88 | |
---|
89 | TAxis fAxis; |
---|
90 | TGraph *fGraph; |
---|
91 | TString fName; |
---|
92 | |
---|
93 | ClassDef(EsafSpectrum,0) |
---|
94 | }; |
---|
95 | |
---|
96 | // inline functions |
---|
97 | inline void EsafSpectrum::SetArraysSize( Int_t size ) { |
---|
98 | |
---|
99 | fSpectrum.Set(size); |
---|
100 | fIntegral.Set(size+2); |
---|
101 | } |
---|
102 | |
---|
103 | #endif /* __EUSOSPECTRUM_HH_ */ |
---|
104 | |
---|