StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
GetdEdxResolution.cxx
1 #include "Bichsel.h"
2 #include "TMath.h"
3 #include "tpcCorrection.h"
4 struct Sigma_t {
5  tpcCorrection_st params;
6  Int_t utime, date, time;
7 };
8 /*mysql> select
9  type,nrows,idx,npar,OffSet,min,max,a,beginTime,entryTime from TpcLengthCorrectionB where idx=2 and deactive=0 order by beginTime; */
10 static Sigma_t Sigmas[] = {
11  {{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},// 0 run II 20040717 221107
12  {{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},// 1 run II AuAu19, 20071105 155039
13  {{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},// 2 run III 20040717 221152
14  {{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},// 3 run IV 20050214 173752
15  {{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},// 4 run IV b 20050214 173813
16  {{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},// 5 run IV c 20050214 173841
17  {{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},// 6 run VI d 20050214 173903
18  {{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},// 7 run V 20050513 203842
19  {{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},// 8 run V b 20050729 201656
20  {{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},// 9 run VI 20060820 214522
21  {{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},//10 run VI b 20060808 160055
22  {{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},//11 run VI c 20060808 160310
23  {{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} //12 run VII 20071008 205348
24 };
25 static Int_t N = sizeof(Sigmas)/sizeof(Sigma_t);
26 //________________________________________________________________________________
27 Double_t Bichsel::GetdEdxResolution(Int_t k, Double_t TrackLengthInTPC) {
28  if (TrackLengthInTPC <= 0.0 || k < 0) return -999;
29  if (k >= N) {
30  Int_t uc = k;
31  for (k = N - 1; k > 0; k--) {
32  if (uc >= Sigmas[k].utime) break;
33  }
34  }
35  if (k >= N) return -999;
36  Double_t X = TMath::Log(TrackLengthInTPC);
37  return CalcCorrection(&Sigmas[k].params, X);
38 }
39 //________________________________________________________________________________
40 Double_t Bichsel::GetdEdxResolution(Double_t *x, Double_t *p) {
41  Int_t k = (Int_t) p[0];
42  return GetdEdxResolution(k,x[0]);
43 }
44 //________________________________________________________________________________
45 Double_t Bichsel::CalcCorrection(const tpcCorrection_st *cor,const Double_t x) {
46  Int_t N = TMath::Abs(cor->npar);
47  Double_t X = x;
48  if (cor->npar < 0) X = TMath::Exp(x);
49  if (N > 0) {
50  if (cor->min < cor->max) {
51  if (X < cor->min) X = cor->min;
52  if (X > cor->max) X = cor->max;
53  }
54  return SumSeries(X,N,&cor->a[0]);
55  }
56  else return 0;
57 }
58 //________________________________________________________________________________
59 Double_t Bichsel::SumSeries(const Double_t &X,const Int_t &N,const Double_t *params) {
60  Double_t Sum = 0;
61  if (N > 0) {
62  Sum = params[N-1];
63  for (int n = N-2; n>=0; n--) Sum = X*Sum + params[n];
64  }
65  return Sum;
66 }