energyCalibration.h

Go to the documentation of this file.
00001 
00002 #ifndef ENERGYCALIBRATION_H
00003 #define ENERGYCALIBRATION_H
00004 
00005 #include <TROOT.h>
00006 #include <TF1.h>
00007 
00008 using namespace std;
00009 
00010 class TH1F;
00011 class TGraphErrors;
00012 
00013 
00014 
00015 
00016 
00017 const float conven=1000./3.6; 
00018 const float el=1.67E-4; 
00050 class energyCalibrationFunctions {
00051 
00052  public:
00053   
00054   energyCalibrationFunctions(int s=-1) {setScanSign(s);};
00055   
00060   int setScanSign(int s=0) {if (s==1 || s==-1) sign=s; return sign;};;
00061   
00062 
00072   Double_t gaussChargeSharing(Double_t *x, Double_t *par);
00073 
00080 Double_t erfFunction(Double_t *x, Double_t *par) ;
00081 
00090 Double_t erfFunctionChargeSharing(Double_t *x, Double_t *par);
00091   
00105 Double_t erfFuncFluo(Double_t *x, Double_t *par);
00106 
00107 
00109   static float median(float *x, int n);
00111   static int quick_select(int arr[], int n);
00113   static int kth_smallest(int *a, int n, int k);
00114 
00115   
00124   Double_t spectrum(Double_t *x, Double_t *par);
00125 
00126 
00135   Double_t scurve(Double_t *x, Double_t *par);
00136 
00137 
00138 
00151   Double_t scurveFluo(Double_t *x, Double_t *par);
00152 
00153 
00154  private:
00155   int sign;
00156     
00157 
00158 };
00159 
00165 class energyCalibration  {
00166 
00167 
00168  public:
00172   energyCalibration();
00173     
00177   ~energyCalibration();
00178     
00183   int setPlotFlag(int p=-1) {if (p>=0) plot_flag=p; return plot_flag;};
00184 
00189   int setScanSign(int s=0) {return funcs->setScanSign(s);};
00190   
00195   int setChargeSharing(int p=-1);
00196   
00201   void setFitRange(Double_t mi, Double_t ma){fit_min=mi; fit_max=ma;};
00202 
00207   void getFitRange(Double_t &mi, Double_t &ma){mi=fit_min; ma=fit_max;};
00208 
00209 
00219   void setStartParameters(Double_t *par);
00220   
00230   void getStartParameters(Double_t *par);
00231 
00239   TF1 *fitSCurve(TH1 *h1, Double_t *mypar, Double_t *emypar);
00240 
00241 
00249   TF1 *fitSpectrum(TH1 *h1, Double_t *mypar, Double_t *emypar);
00250 
00251 
00265   TGraphErrors* linearCalibration(int nscan, Double_t *en, Double_t *een, Double_t *fl, Double_t *efl, Double_t &gain, Double_t &off, Double_t &egain, Double_t &eoff);  
00266 
00279   TGraphErrors* calibrateScurves(int nscan, Double_t *en, Double_t *een, TH1F **h1, Double_t &gain, Double_t &off, Double_t &egain, Double_t &eoff){return calibrate(nscan, en, een, h1, gain, off, egain, eoff, 1);};    
00280 
00293   TGraphErrors* calibrateSpectra(int nscan, Double_t *en, Double_t *een, TH1F **h1, Double_t &gain, Double_t &off, Double_t &egain, Double_t &eoff){return calibrate(nscan, en, een, h1, gain, off, egain, eoff, 0);};  
00294 
00295 
00296 
00297  private:
00309   TGraphErrors* calibrate(int nscan, Double_t *en, Double_t *een, TH1F **h1, Double_t &gain, Double_t &off, Double_t &egain, Double_t &eoff, int integral=1);  
00310 
00311 
00319   void initFitFunction(TF1 *fun, TH1 *h1);
00320 
00321 
00330   TF1 *fitFunction(TF1 *fun, TH1 *h1, Double_t *mypar, Double_t *emypar);  
00331 
00332 
00333   int plot_flag; 
00335   int cs_flag; 
00337   Double_t fit_min; 
00338   Double_t fit_max; 
00340   Double_t bg_offset; 
00341   Double_t bg_slope; 
00342   Double_t flex; 
00343   Double_t noise; 
00344   Double_t ampl; 
00345   Double_t cs_slope; 
00347   energyCalibrationFunctions *funcs;
00348 
00349   TF1 *fscurve; 
00351   TF1 *fspectrum; 
00354 };
00355 
00356 #endif
00357 
00358 
00359 
00360 
00361 
00362 
00363 
00364 
00365 
00366 
00367 
00368 
00369 
00370 
00371 
00372 
00373 
00374 
00375 

Generated on Tue Mar 27 16:32:29 2012 by  doxygen 1.4.7