simple-tof-analysis
 All Classes Namespaces Functions Variables Groups Pages
TSToFGenerator.h
1 /*
2  * TSToFGenerator.h
3  *
4  * Created on: Jun 16, 2014
5  * Author: Silvestro di Luise
6  * Silvestro.Di.Luise@cern.ch
7  *
8  *
9  *
10  *
11  *
12  * Momentum is in GeV/c, Mass is in GeV/c^2
13  * Lengths are in m
14  * Times in ns
15  *
16  * Time resolution is the Pdf of the smearing
17  * to be added to the calculated ToF
18  *
19  * ToF offset is a time bias to be added to the ToF
20  * calculated from the kinematics (mass,mom,path len)
21  *
22  * Momentum Resolution is the expression
23  * of dP/P as a function of the P (second order poly)
24  *
25  * Path Length Resolution is the sigma
26  * to be used for a Guassian smearing
27  *
28  *
29  *
30  * Typical Parametrizations for parameters of Gauss shaped
31  * resolution at a given momentum:
32  *
33  * N.B.: If a user def function of the mass2 distribution is provided
34  * the first param must be the mean of the distrib.
35  * An option exists to provide the number of the parameter that
36  * can represents the width of the distribution.
37  * This will be used to auto set the limits in m2 over
38  * a wide range of momenta
39  * (and also for the width scaling as a function of the mass)
40  * if no param number is specified the RMS of the function
41  * will be calculated numerically using the CentralMoment
42  * method of TF1
43  *
44  *
45  *
46  *
47  * proton: 0
48  * kaon: 1
49  * pion: 2
50  * electron: 3
51  *
52  double m2_m_p0[4];
53  double m2_m_p1[4];
54 
55  double m2_s_p0[4];
56  double m2_s_p1[4];
57  double m2_s_p2[4];
58 
59 
60  Mean-Parameter linear parametrization:
61 
62  m2_m_p0[0]= 0.8876;
63  m2_m_p1[0]= 0;
64 
65  m2_m_p0[1]= mass_k*mass_k;
66  m2_m_p1[1]= 0;
67 
68  m2_m_p0[2]= 0.0167222;
69  m2_m_p1[2]= 0;
70 
71  m2_m_p0[3]= 0.;
72  m2_m_p1[3]= 0.;
73 
74 
75  Width-Parameter parabolic parametrization
76 
77  //p
78  m2_s_p0[0]= 0.0295321;
79  m2_s_p1[0]= -0.00630375;
80  m2_s_p2[0]= 0.00799005;
81 
82  //k
83  m2_s_p0[1]= 0.00557491;
84  m2_s_p1[1]= -0.00219247;
85  m2_s_p2[1]= 0.00820526;
86 
87  //pi
88  m2_s_p0[2]= 0.00557491;
89  m2_s_p1[2]= -0.00219247;
90  m2_s_p2[2]= 0.00820526;
91 
92  //e
93  m2_s_p0[3]= 0.00557491;
94  m2_s_p1[3]= -0.00219247;
95  m2_s_p2[3]= 0.00820526;
96 
97  *
98  *
99  *
100  * TODO:
101  * TODO: ToFGenerator
102  * TODO: copy ctor for bothe the classes
103  * TODO:
104  *
105  *
106  * //example on how to set a Landau shaped pdf for the m2 distrib
107  * and set the individual param parametrization as function of the momentum
108  * TF1 *fLan=new TF1("fLan","landau",-1,100);
109  * fLan->SetParNames("a","m","w");
110  *
111  * tofGen.SetMass2DistributionFunction("part",*fLan,2);
112  *
113  * tofGen.SetParamFunction("part", 0 , "linear", m2_m_p0[0],m2_m_p1[0]);
114  * tofGen.SetParamFunction("part", 1 , "parab", m2_s_p0[0],m2_s_p1[0],m2_s_p2[0]);
115  * tofGen.SetParamFunction("part", 2 , "parab", m2_s_p0[2],m2_s_p1[2],3*m2_s_p2[2]);
116  *
117  */
118 
119 #ifndef TSTOFGENERATOR_H_
120 #define TSTOFGENERATOR_H_
121 
122 #include <string>
123 #include <vector>
124 #include <map>
125 
126 #include <TString.h>
127 #include <TF1.h>
128 #include <TMath.h>
129 
130 #include "TSNamed.h"
131 
132 #include "TSVariable.h"
133 
134 
135 class TSToF_Part;
136 
137 
138 
139 class TSToFGenerator: public TSNamed {
140 
141 
142 public:
143 
144  TSToFGenerator(TString);
145  TSToFGenerator(TString, const TSVariable &vx, const TSVariable &vy);
146 
147  virtual ~TSToFGenerator();
148 
149  double ComputeDm2(double tof, double mom, double len) const;
150  double ComputeDm2dp(double tof, double mom, double len) const;
151  double ComputeDm2dt(double tof, double mom, double len) const;
152  double ComputeDm2dL(double tof, double mom, double len) const;
153  double ComputeMass(double tof, double mom, double len) const;
154  double ComputeToF(double mass, double mom, double len) const;
155  double GenerateMass2(TString part, double mom) const;
156  double GenerateMass2(double mass, double mom, double len) const;
157  TF1* GetMass2Distrib(TString part, double mom) const;
158  int GetMass2DistribNPars(TString part) const;
159  TF1* GetMomResolFunc() const {return fMomResol;}
160  TF1* GetParametrization(TString name, int par) const;
161  double GetParamValue(TString name, int par, double p) const;
162  double GetSigmaMom(double) const;
163  double GetSigmaPathLen() const {return fSigmaLen;}
164  double GetSigmaToF() const {return fSigmaToF;}
165  double GetToFOffset() const {return fToFT0;}
166  TF1* GetToFResolDistr() const {return fToFResolDistr;}
167 
168  void Init();
169  TF1* ImportMass2Distrib(TString part,double mom) const;
170 
171  void SetParticle(TString name, TString label, float mass=0);
172 
173  void SetMass2DistributionFunction(TString name, TF1&, int width_par=-1);
174  void SetMass2DistributionFunction(TString name, TString fname,int width_par=-1);
175  void SetMass2MeanFunction(TString name, TF1&);
176  void SetMass2MeanFunction(TString name, TString poly_name, double, double=0, double=0);
177  void SetMass2WidthFunction(TString name, TF1&);
178  void SetMass2WidthFunction(TString name, TString poly_name, double, double=0, double=0);
179  void SetMass2WidthScaling(TString part1, TString part2);
180  void SetParamFunction(TString, int par, TF1&);
181  void SetParamFunction(TString name, int par, TString poly_name, double, double=0, double=0);
182 
183  void SetMomentumVariable(const TSVariable &);
184  void SetMomentumResolution(double,double =0,double =0); // dP/P
185  void SetPathLengthResolution(double); //m
186  void SetMomentumRange(double min, double max);
187  void SetToFResolution(double); // ps
188  void SetToFResolution(TF1&);
189  void SetToFVariable(const TSVariable &);
190  void SetToFRange(double, double);
191  void SetToFOffset(double); //ps applied only to mass2 generation not to compute ToF
192 
193 
194 private:
195 
196  TSToF_Part* fGetParticle(TString) const;
197 
198  std::map<TString,TSToF_Part*> fPartList;
199 
200  TF1* fToFResolDistr;
201  TF1* fMomResol;
202 
203  double fToFT0;
204  double fSigmaToF;
205  double fSigmaLen;
206 
207  TSVariable fVariableX;
208  TSVariable fVariableY;
209 
210  double CL; // c light in m/ns
211 
212 };
213 
214 
215 
216 
217 
218 
219 
220 
221 
222 
223 class TSToF_Part{
224 
225 
226 
227 public:
228  TSToF_Part(TString name, TString label, float mass=0);
229  ~TSToF_Part();
230 
231  TString GetLabel() const {return Label;}
232  float GetMass() const {return Mass;}
233  TF1* GetMass2Distrib() const {return fMass2Distrib;}
234  TF1* GetMass2Distrib(double mom) const;
235  TString GetMass2DistribName() const {return fMass2DistribName;}
236  TString GetName() const {return Name;}
237  TF1* GetParamFunction(int) const;
238  double GetParamValue(int par, double p) const;
239  int GetNpar() const {return fMass2Distrib==0 ? 0 : fMass2Distrib->GetNpar();}
240  int GetNumOfParFuncs() const {return fParamFunc.size();}
241  double GetMassScale() const {return fMassScale;}
242  double GetMassScaling(int, double) const;
243  int GetWidthParam() const {return fWidthPar;}
244  bool Mass2IsGaussian() const {return fMass2IsGauss;}
245  void SetMass(float m) {Mass=m;}
246  void SetMassScale(float m) {fMassScale=m; SetUseMassScale(true);}
247  void SetMass2Distrib(TString fname, double xmin, double xmax, int width_par=-1);
248  void SetMass2Distrib(TF1&, int width_par=-1);
249 
250  void SetMomentumVariable(const TSVariable &);
251  void SetToFVariable(const TSVariable &);
252  void SetParamFunc(int, TF1 &);
253  void SetUseMassScale(bool b) {fUseMassScale=b;}
254  void SetWidthPar(int p) {fWidthPar=p;}
255  bool UseMassScale() const {return fUseMassScale;}
256 
257 private:
258 
259  TString Name;
260  TString Label;
261  float Mass;
262 
263  bool fUseMassScale;
264  float fMassScale;
265 
266  TF1* fMass2Distrib;
267  std::map<int,TF1*> fParamFunc;
268 
269  TString fMass2DistribName;
270  bool fMass2IsGauss;
271 
272  TSVariable fVariableX;
273  TSVariable fVariableY;
274 
275  int fWidthPar;
276  int fNpx;
277 
278 };
279 
280 
281 #endif /* TSTOFGENERATOR_H_ */
void SetMass2WidthScaling(TString part1, TString part2)
Definition: TSToFGenerator.cc:1195
void SetMass2MeanFunction(TString name, TF1 &)
Definition: TSToFGenerator.cc:902
Definition: TSToFGenerator.h:139
Definition: TSVariable.h:55
double ComputeToF(double mass, double mom, double len) const
Definition: TSToFGenerator.cc:551
double GetMassScaling(int, double) const
Definition: TSToFGenerator.cc:272
void SetParamFunction(TString, int par, TF1 &)
Definition: TSToFGenerator.cc:1266
Definition: TSNamed.h:38
double ComputeMass(double tof, double mom, double len) const
Definition: TSToFGenerator.cc:533
void SetMass2DistributionFunction(TString name, TF1 &, int width_par=-1)
Definition: TSToFGenerator.cc:797
void SetMass2WidthFunction(TString name, TF1 &)
Definition: TSToFGenerator.cc:1046
void SetParamFunc(int, TF1 &)
Definition: TSToFGenerator.cc:381
Definition: TSToFGenerator.h:223