Heavy ion Analysis Libriares
Loading...
Searching...
No Matches
Splines.h
1/*
2 * HalSplines.h
3 *
4 * Created on: 30-04-2022
5 * Author: Daniel Wielanek
6 * E-mail: daniel.wielanek@gmail.com
7 * Warsaw University of Technology, Faculty of Physics
8 */
9#ifndef HALSPLINES_H_
10#define HALSPLINES_H_
11
12#include "Array.h"
13
14#include <TString.h>
15
16
17class TAxis;
18class TH1;
19class TH1D;
20class TH2;
21class TH2D;
22class TH3;
23class TH3D;
24
32namespace Hal {
33 class Spline1D : public TObject {
34 TAxis* fXaxis;
35 Int_t fNbins;
36 Double_t* fA; //[fNbins]
37 Double_t* fB; //[fNbins]
38 Double_t* fC; //[fNbins]
39 Double_t* fAe; //[fNbins]
40 Double_t* fBe; //[fNbins]
41 void CalcParams(Double_t x1,
42 Double_t y1,
43 Double_t x2,
44 Double_t y2,
45 Double_t x3,
46 Double_t y3,
47 Double_t& A,
48 Double_t& B,
49 Double_t& C);
50 void SetFirstBin(TH1* h, Double_t begval, Bool_t use_begval = kFALSE);
51 void SetLastBin(TH1* h, Double_t enval, Bool_t use_endval = kFALSE);
52
53 public:
54 Spline1D(TH1* h = NULL, Double_t begval = 0, Double_t endval = 0);
62 void FastOverwrite(TH1D* h, Double_t begval = 0, Double_t endval = 0);
66 void Refit();
72 Double_t Eval(Double_t x) const;
78 Double_t GetError(Double_t x) const;
84 Double_t EvalBin(Int_t bin) const;
90 Double_t ErrorBin(Int_t bin) const;
97 void Eval(Double_t x, Double_t& f, Double_t& error) const;
103 virtual TH1D* GetTHD(TString name = "spline_thd") const;
104 TAxis* GetXaxis() const { return fXaxis; };
105 virtual ~Spline1D();
106 ClassDef(Spline1D, 1)
107 };
108
115 class Spline2D : public TObject {
116 TAxis* fXaxis;
117 TAxis* fYaxis;
118 Int_t fNbinsX;
119 Int_t fNbinsY;
122 void CalcParams(Double_t x[3], Double_t y[3], Double_t z[3][3], Double_t params[9]);
123 void Extrapolate(TH2* h, Option_t* extraopolation_opt) const;
124 Double_t Extrapolate(TH2* h, Int_t ix1, Int_t ix2, Int_t x, Int_t iy1, Int_t iy2, Int_t y, Int_t opt) const;
125 // TODO default constructor & copy constructor
126 public:
136 Spline2D(TH2* h = NULL, Option_t* interpolation = "");
140 void Refit();
148 Double_t GetExtrapolationParam(Double_t x, Double_t y, Int_t param) const;
155 Double_t Eval(Double_t x, Double_t y) const;
162 Double_t GetError(Double_t x, Double_t y) const;
169 Double_t EvalBin(Int_t bin_x, Int_t bin_y) const;
176 Double_t ErrorBin(Int_t bin_x, Int_t bin_y) const;
184 void SetPoint(Int_t xbin, Int_t ybin, Double_t val, Double_t err = 0);
190 void PrintParams(Double_t x, Double_t y);
199 void Eval(Double_t x, Double_t y, Double_t& f, Double_t& error) const;
204 TAxis* GetXaxis() const { return fXaxis; };
209 TAxis* GetYaxis() const { return fYaxis; };
215 virtual TH2D* GetTHD(TString name = "spline_thd") const;
216 virtual ~Spline2D();
217 ClassDef(Spline2D, 1)
218 };
227 class Spline3D : public TObject {
228 TAxis* fXaxis;
229 TAxis* fYaxis;
230 TAxis* fZaxis;
231 Int_t fNbinsX;
232 Int_t fNbinsY;
233 Int_t fNbinsZ;
236 Double_t EvalBin(Int_t ix, Int_t iy, Int_t iz, Double_t x, Double_t y, Double_t z) const;
237 void CalcParams(Double_t x[2], Double_t y[2], Double_t z[2], Double_t v[2][2][2], Double_t params[8]);
238
239 public:
248 Spline3D(TH3* h = NULL, Option_t* interpolation = "");
254 void FastOverwrite(TH3* h, Option_t* interpolation = "");
262 Double_t Eval(Double_t x, Double_t y, Double_t z) const;
270 Double_t GetError(Double_t x, Double_t y, Double_t z) const;
279 Double_t EvalBin(Int_t x, Int_t y, Int_t z) const;
287 Double_t ErrorBin(Int_t x, Int_t y, Int_t z) const;
291 void Refit();
298 void PrintParams(Double_t x, Double_t y, Double_t z) const;
308 void Eval(Double_t x, Double_t y, Double_t z, Double_t& f, Double_t& error) const;
313 TAxis* GetXaxis() const { return fXaxis; };
318 TAxis* GetYaxis() const { return fYaxis; };
323 TAxis* GetZaxis() const { return fZaxis; };
329 virtual TH3D* GetTHD(TString name = "spline_thd") const;
330 virtual ~Spline3D();
331 ClassDef(Spline3D, 1)
332 };
333} // namespace Hal
334#endif /* HALSPLINES_H_ */
virtual TH1D * GetTHD(TString name="spline_thd") const
Definition Splines.cxx:191
Double_t Eval(Double_t x) const
Definition Splines.cxx:55
Double_t EvalBin(Int_t bin) const
Definition Splines.cxx:65
Double_t GetError(Double_t x) const
Definition Splines.cxx:60
void FastOverwrite(TH1D *h, Double_t begval=0, Double_t endval=0)
Definition Splines.cxx:489
Double_t ErrorBin(Int_t bin) const
Definition Splines.cxx:70
void PrintParams(Double_t x, Double_t y)
Definition Splines.cxx:399
virtual TH2D * GetTHD(TString name="spline_thd") const
Definition Splines.cxx:698
Double_t Eval(Double_t x, Double_t y) const
Definition Splines.cxx:327
Double_t ErrorBin(Int_t bin_x, Int_t bin_y) const
Definition Splines.cxx:356
TAxis * GetXaxis() const
Definition Splines.h:204
TAxis * GetYaxis() const
Definition Splines.h:209
Double_t EvalBin(Int_t bin_x, Int_t bin_y) const
Definition Splines.cxx:347
Spline2D(TH2 *h=NULL, Option_t *interpolation="")
Definition Splines.cxx:213
void SetPoint(Int_t xbin, Int_t ybin, Double_t val, Double_t err=0)
Definition Splines.cxx:508
Double_t GetError(Double_t x, Double_t y) const
Definition Splines.cxx:481
Double_t GetExtrapolationParam(Double_t x, Double_t y, Int_t param) const
Definition Splines.cxx:445
void PrintParams(Double_t x, Double_t y, Double_t z) const
Definition Splines.cxx:661
Spline3D(TH3 *h=NULL, Option_t *interpolation="")
Definition Splines.cxx:550
virtual TH3D * GetTHD(TString name="spline_thd") const
Definition Splines.cxx:721
Double_t ErrorBin(Int_t x, Int_t y, Int_t z) const
Definition Splines.cxx:688
Double_t Eval(Double_t x, Double_t y, Double_t z) const
Definition Splines.cxx:645
Double_t GetError(Double_t x, Double_t y, Double_t z) const
Definition Splines.cxx:654
TAxis * GetYaxis() const
Definition Splines.h:318
TAxis * GetXaxis() const
Definition Splines.h:313
void FastOverwrite(TH3 *h, Option_t *interpolation="")
Definition Splines.cxx:820
TAxis * GetZaxis() const
Definition Splines.h:323