simple-tof-analysis
 All Classes Namespaces Functions Variables Groups Pages
TSBetheBlochFunc.h
1 /*
2  *
3  *
4  * TSBetheBlochFunc.h
5  *
6  * Created on: Jun 13, 2014
7  * Author: Silvestro Di Luise
8  * Silvestro.Di.Luise@cern.ch
9  *
10  *
11  *
12  *
13  *
14  */
15 
16 #ifndef TSBETHEBLOCHFUNC_H_
17 #define TSBETHEBLOCHFUNC_H_
18 
19 #include <vector>
20 
21 #include <TMath.h>
22 #include <TString.h>
23 #include <TF1.h>
24 #include <TGraph.h>
25 
26 #include "BetheBlochFunctions.h"
27 
28 
29 
30 class TSBetheBlochFunc: public TF1 {
31 
32 
33 public:
35  TSBetheBlochFunc(TString name, TString title, double (*fcn)(double*, double*), double xmin, double xmax, int npar);
36  TSBetheBlochFunc(TString name, TString title, TString table_file);
37  virtual ~TSBetheBlochFunc();
38 
39 
40  TGraph* BuildGraphFromFunction(int npt=300,double xmin=0,double xmax=0) const;
41  void BuildTableFromFunction(int npts, int opt=0);
42 
43  void Clear();
44 
45  TGraph *CloneTable(TString ="") const;
46 
47  void ComputeMoments(std::vector<double> &ptot_data,double mass, double &mean,double &rms) const;
48  void ComputeMoments(TH1F &h_ptot,double mass,double &mean,double &rms) const;
49 
50  Double_t Eval(Double_t momentum, Double_t mass = 0, Double_t z = 0, Double_t t = 0) const;
51 
52 
53  bool HasFunction() const {return fHasFunc;}
54  bool HasTable() const {return fHasTable;}
55 
56  TString GetAxisTitleX() const {return fAxisTitleX;}
57  TString GetAxisTitleY() const {return fAxisTitleY;}
58 
59  int GetInterpType() const {return fInterpType;}
60  TString GetInterpOpt() const {return fInterpOpt;}
61  int GetNumOfPoints() const {return fTable.GetN();}
62  double* GetPointsArrayX() const {return fTable.GetX();}
63  double* GetPointsArrayY() const {return fTable.GetY();}
64 
65 
66  bool ImportGraph(const TGraph &);
67  bool ImportTable(const TGraph& g) {return ImportGraph(g);}
68  bool ImportTable(TString file_name);
69  void Init();
70 
71  void SetInterpolation(int);
72  void SetParNames(TString, TString ="",TString ="",TString ="",TString ="", TString ="");
73  void UseFunction(bool);
74  void UseTable(bool);
75  bool UsingFunction() const {return fUseFunc;}
76  bool UsingTable() const {return fUseTable;}
77 
78 private:
79 
80  double fEvalFunction(double, int opt=0) const;
81  double fEvalTabular(double, int opt=0) const;
82  void fSetTitles();
83 
84  bool fHasFunc;
85  bool fHasTable;
86  int fInterpType;
87  TString fInterpOpt;
88  bool fUseFunc;
89  bool fUseTable;
90 
91  TGraph fTable;
92 
93  TString fAxisTitleX;
94  TString fAxisTitleY;
95 
96 };
97 
98 #endif /* TSBETHEBLOCHFUNC_H_ */
void BuildTableFromFunction(int npts, int opt=0)
Definition: TSBetheBlochFunc.cc:116
Double_t Eval(Double_t momentum, Double_t mass=0, Double_t z=0, Double_t t=0) const
Definition: TSBetheBlochFunc.cc:235
Definition: TSBetheBlochFunc.h:30