simple-tof-analysis
 All Classes Namespaces Functions Variables Groups Pages
TSDEdxGenerator.h
1 /*
2  * TSDEdxGenerator.h
3  *
4  * Created on: Jun 14, 2014
5  * Author: Silvestro di Luise
6  * Silvestro.Di.Luise@cern.ch
7  *
8  *
9  * Generate Monte Carlo <dEdx> for a charged particle track
10  * af a given momentum.
11  *
12  * The mean-<dEdx> must be calculated form a
13  * Bethe-Bloch function.
14  *
15  * The spread around the mean-<dEdx> is calculated according to
16  * the selected option.
17  *
18  * Simulation Options:
19  *
20  * - Generate According to given distribution function, independently
21  * on the Number of Points.
22  *
23  * Distrib. Function already implemented.
24  *
25  * Gaussian
26  * Asymmetric Gaussian
27  * Double Tailed Gaussian
28  * Superposition of Gaussians weighted According to a Number of Points Distr.
29  *
30  *
31  *
32  * Mean Values of the Distrib. Function are set to zero
33  * as the central <dEdx> is to be calculated from the provided Bethe-Bloch function.
34  *
35  * Sigma Scaling Option:
36  *
37  * alpha
38  *
39  *
40  * Use Defined Distribution Function
41  *
42  *
43  * - Generate <dEdx> as truncated average of the clusters
44  * charges
45  *
46  *
47  *
48  *
49  *
50  *
51  *
52  */
53 
54 
55 
56 #ifndef TSDEDXGENERATOR_H_
57 #define TSDEDXGENERATOR_H_
58 
59 #include <map>
60 #include <vector>
61 
62 
63 #include <TString.h>
64 
65 #include <TF1.h>
66 #include <TGraph.h>
67 #include <TH1F.h>
68 #include <TObject.h>
69 
70 #include "TH1FAuto.h"
71 
72 #include "TSNamed.h"
73 
74 #include "TSVariable.h"
75 
76 #include "TSBetheBlochFunc.h"
77 
78 
79 
80 class TSDEdxDistrib;
81 
82 
83 class TSDEdxGenerator: public TSNamed {
84 
85 
86 public:
87  TSDEdxGenerator(TString name, TString title);
88  TSDEdxGenerator(TString name, TString title, const TSVariable &dedx_var);
89 
90 
91  virtual ~TSDEdxGenerator();
92 
93  void ApplyCalibrationCorrection(bool);
94 
95  double ComputeAverage(std::vector<double> &clusters, double trunc_low, double trunc_up, int algo, double param=0) const;
96 
97  double Generate() const;
98  double Generate(int num_clusters) const;
99  double Generate(double momentum, double mass, int num_clusters=0) const;
100 
101  double GetMean() const {return fMean;}
102  int GetNumOfUsedClusters() const {return fNumOfUsedClusters;}
103  TObject* GetTrackDEdxDistrib() const;
104  TObject* ImportTrackDEdxDistrib() const;
105 
106 
107  void Init();
108 
109  void SetAverageAlgoType(int);
110  void SetAverageAlgoParam(double);
111 
112  void SetAsymmetry(double);
113 
114  void SetBetheBloch(const TSBetheBlochFunc &);
115 
116  void SetClusterChargeDistrib(TF1 &);
117  void SetClusterChargeDistrib(TH1F &);
118  void SetClusterChargeDistrib(TString fname, double min, double max, double p0, double p1=0, double p2=0, double p3=0);
119 
120  void SetDEdxVariable(const TSVariable &v);
121 
122  //this is an averall mean shift of the distrib you use to generate dE/dx
123  void SetMean(double) const;
124  void SetPointDistrib(TH1F &);
125  void SetSigmaScaling(double m, double alpha);
126 
127  void SetTrackDEdxDistrib(TF1 &);
128  void SetTrackDEdxDistrib(TH1F &);
129  void SetTrackDEdxDistrib(TString fname, double min, double max, double p0, double p1=0, double p2=0, double p3=0);
130  void SetTruncation(double up, double low=0);
131  void SetWidthSmearing(double);
132 
133 
134 private:
135 
136  double fComputeCalibrationCorrection(int nclusters) const;
137 
138  void fInitTrackDistrib();
139  void fSetDistribTitles();
140  void fSetIsClusterDistrib();
141  void fSetIsTrackDistrib();
142 
143  int fAverageAlgoType;
144  double fAverageAlgoParam;
145 
146  TObject *fTrackDistrib;
147 
148  TSDEdxDistrib *fDistrib;
149 
150  mutable int fNumOfUsedClusters;
151 
152  double fTruncUp;
153  double fTruncLow;
154 
155  mutable double fMean;
156 
157  const TSBetheBlochFunc *fBetheBloch;
158 
159  bool fApplyCalibCorr;
160 
161  TString fTrackDedxDistrName;
162  TString fClusterDedxDistrName;
163 
164  bool fIsClusterDistrib;
165  bool fIsTrackDistrib;
166  TString fClusterChargeDistrTitle;
167  TString fTrackChargeDistrTitle;
168 
169  TSVariable fVariableX;
170 
171  TH1FAuto autoTH1F;
172 
173 };
174 
175 
176 
177 
178 
179 
180 
181 class TSDEdxDistrib {
182 
183 public:
184 
185  TSDEdxDistrib(TString fname="");
186  double Distrib(double *x, double *p);
187  double PointAveragedDistrib(double *x, double *p);
188 
189  double GetMin() const {return xmin;}
190  double GetMax() const {return xmax;}
191 
192  int GetNpar();
193  int GetNpar() const;
194  bool HasPointDistrib() const {return HasPointDistr;}
195  void Init();
196  void InitFunctionParNames(TF1 &);
197  bool IsLandau() const {return fIsLandau;}
198  void SetFunctionPars(TF1 &);
199  void SetPointDistrib(TH1F &);
200 
201 
202  double GetMean() const {return mean;}
203  double GetSigma() const {return sigma;}
204  double GetSigmaTails() const {return sigma_tails;}
205  double GetRatioTails() const {return ratio_tails;}
206  double GetSigmaScaleBase() const {return sigma_scale_base;}
207  double GetSigmaScalePow() const {return alpha;}
208  double GetDelta() const {return delta;}
209  double GetSpread() const {return spread;}
210 
211 
212  void SetMean(double);
213  void SetSigma(double);
214  void SetSigmaTails(double);
215  void SetRatioTails(double);
216  void SetSigmaScaleBase(double);
217  void SetSigmaScaling(double);
218  void SetDelta(double);
219  void SetSpread(double);
220  void SetNPoints(double);
221 
222  bool MeanSet() const {return fMeanSet;}
223  void Print();
224  bool SigmaSet() const {return fSigmaSet;}
225  bool SigmaTailsSet() const {return fSigmaTailsSet;}
226  bool RatioTailsSet() const {return fRatioTailsSet;}
227  bool SigmaScaleBaseSet() const {return fSigmaScaleBaseSet;}
228  bool SigmaScalingSet() const {return fSigmaScalingSet;}
229  bool DeltaSet() const {return fDeltaSet;}
230  bool SpreadSet() const {return fSpreadSet;}
231  bool NPointsSet() const {return fNPointsSet;}
232 
233  void SetParameters(double m, double s, double s2=0, double r=0, double scale=1, double alpha=0, double delta=0, double rms=0, double npts=1);
234 
235  void SetMin(double v) {xmin=v;}
236  void SetMax(double v) {xmax=v;}
237 
238 
239 
240 private:
241 
242  double GNorm;
243 
244  bool fIsLandau;
245 
246  double mean;
247  double sigma;
248  double sigma_tails;
249  double ratio_tails;
250  double sigma_scale_base;
251  double alpha;
252  double delta;
253  double spread;
254  double npoints;
255 
256  double landau_mpv_shift;
257 
258  double xmin,xmax;
259 
260  bool HasPointDistr;
261 
262  std::map<int,bool> par_used;
263  std::map<int,TString> par_name;
264  std::map<TString,int> par_num;
265  std::map<int,double> par_val;
266 
267  std::vector<float> mult;
268  std::vector<float> npts;
269 
270  int ip_mean,ip_sigma,ip_sigma_tails
271  ,ip_ratio_tails,ip_sigma_scale_base,ip_sigma_scale_pow
272  ,ip_delta,ip_spread,ip_npoints;
273 
274  bool fMeanSet,fSigmaSet,fSigmaTailsSet,fRatioTailsSet
275  ,fSigmaScaleBaseSet,fSigmaScalingSet,fDeltaSet,fSpreadSet,fNPointsSet;
276 
277 
278 };
279 
280 
281 #endif /* TSDEDXGENERATOR_H_ */
Definition: TH1FAuto.h:41
double Distrib(double *x, double *p)
Definition: TSDEdxGenerator.cc:250
Definition: TSDEdxGenerator.h:181
Definition: TSVariable.h:55
Definition: TSDEdxGenerator.h:83
double PointAveragedDistrib(double *x, double *p)
Definition: TSDEdxGenerator.cc:206
Definition: TSBetheBlochFunc.h:30
double ComputeAverage(std::vector< double > &clusters, double trunc_low, double trunc_up, int algo, double param=0) const
Definition: TSDEdxGenerator.cc:720
Definition: TSNamed.h:38