00001 #include "Bichsel.h"
00002 #include "TMath.h"
00003 #include "tpcCorrection.h"
00004 struct Sigma_t {
00005 tpcCorrection_st params;
00006 Int_t utime, date, time;
00007 };
00008
00009
00010 static Sigma_t Sigmas[] = {
00011 {{0,10,2,4,0, 2.30, 4.79, {1.82545,-1.13077,0.249432,-0.0189606,0,0,0,0,0,0} }, 994003200, 20010701, 120000},
00012 {{0, 6,2,3,0, 2.30, 4.70, {0.621603,-0.228409,0.0236501,0,0,0,0,0,0,0} },1001304004, 20010924, 4},
00013 {{0,13,2,4,0, 0.00, 0.00, {0.0370811,0.142838,-0.0513699,0.00477384,0,0,0,0,0,0 } },1041829200, 20030106, 0},
00014 {{0, 6,2,3,0, 0.00, 0.00, {0.399909,-0.113657,0.0089704,0,0,0,0,0,0,0} },1073192401, 20040104, 1},
00015 {{0, 6,2,3,0, 0.00, 0.00, {0.399909,-0.113657,0.0089704,0,0,0,0,0,0,0} },1075957201, 20040205, 1},
00016 {{0, 6,2,3,0, 0.00, 0.00, {0.399909,-0.113657,0.0089704,0,0,0,0,0,0,0} },1076994001, 20040217, 1},
00017 {{0, 6,2,3,0, 0.00, 0.00, {0.399909,-0.113657,0.0089704,0,0,0,0,0,0,0} },1080104401, 20040324, 1},
00018 {{0, 6,2,5,0, 2.30, 4.80, {1.27303,-1.25341,0.532478,-0.102658,0.00733247,0,0,0,0,0} },1105498801, 20050111, 220001},
00019 {{0, 6,2,4,0, 2.30, 4.70, {-0.314706,0.404681,-0.116752,0.0101701,0,0,0,0,0,0} },1112508000, 20050403, 10000},
00020 {{0, 6,2,6,0, 2.30, 4.79, {2.7451,-3.64943,1.98889,-0.525204,0.0666543,-0.00324793,0,0,0,0}},1141837080, 20060308, 115800},
00021 {{0, 6,2,6,0, 0.00, 0.00, {2.7451,-3.64943,1.98889,-0.525204,0.0666543,-0.00324793,0,0,0,0}},1144314000, 20060406, 50000},
00022 {{0, 6,2,5,0, 0.00, 0.00, {1.11775,-1.24347,0.586667,-0.121644,0.00915544,0,0,0,0,0} },1147287961, 20060510, 150601},
00023 {{0, 6,2,4,0, 2.30, 4.70, {-0.0748715,0.243322,-0.0793629,0.00726962,0,0,0,0,0,0 } },1174449642, 20070321, 42}
00024 };
00025 static Int_t N = sizeof(Sigmas)/sizeof(Sigma_t);
00026
00027 Double_t Bichsel::GetdEdxResolution(Int_t k, Double_t TrackLengthInTPC) {
00028 if (TrackLengthInTPC <= 0.0 || k < 0) return -999;
00029 if (k >= N) {
00030 Int_t uc = k;
00031 for (k = N - 1; k > 0; k--) {
00032 if (uc >= Sigmas[k].utime) break;
00033 }
00034 }
00035 if (k >= N) return -999;
00036 Double_t X = TMath::Log(TrackLengthInTPC);
00037 return CalcCorrection(&Sigmas[k].params, X);
00038 }
00039
00040 Double_t Bichsel::GetdEdxResolution(Double_t *x, Double_t *p) {
00041 Int_t k = (Int_t) p[0];
00042 return GetdEdxResolution(k,x[0]);
00043 }
00044
00045 Double_t Bichsel::CalcCorrection(const tpcCorrection_st *cor,const Double_t x) {
00046 Int_t N = TMath::Abs(cor->npar);
00047 Double_t X = x;
00048 if (cor->npar < 0) X = TMath::Exp(x);
00049 if (N > 0) {
00050 if (cor->min < cor->max) {
00051 if (X < cor->min) X = cor->min;
00052 if (X > cor->max) X = cor->max;
00053 }
00054 return SumSeries(X,N,&cor->a[0]);
00055 }
00056 else return 0;
00057 }
00058
00059 Double_t Bichsel::SumSeries(const Double_t &X,const Int_t &N,const Double_t *params) {
00060 Double_t Sum = 0;
00061 if (N > 0) {
00062 Sum = params[N-1];
00063 for (int n = N-2; n>=0; n--) Sum = X*Sum + params[n];
00064 }
00065 return Sum;
00066 }