added class to handle TOF information including event-time measurement performed...
[u/mrichter/AliRoot.git] / TOF / AliTOFT0maker.cxx
CommitLineData
536031f2 1#include <Riostream.h>
2#include <stdlib.h>
3
4#include "AliTOFT0v1.h"
5#include "AliTOFT0maker.h"
6#include "AliTOFcalibHisto.h"
7#include "AliPID.h"
8#include "AliESDpid.h"
9#include "AliTOFpidESD.h"
10
11ClassImp(AliTOFT0maker)
12
13//____________________________________________________________________________
14 AliTOFT0maker::AliTOFT0maker(): fESDswitch(0), fTimeResolution(115), fT0sigma(1000)
15{
16 fCalib = new AliTOFcalibHisto();
17 fCalib->LoadCalibPar();
18
19 if(AliPID::ParticleMass(0) == 0) new AliPID();
20}
21//____________________________________________________________________________
22AliTOFT0maker::~AliTOFT0maker()
23{
24 // dtor
25 if(fCalib) delete fCalib;
26}
27//____________________________________________________________________________
28Double_t* AliTOFT0maker::RemakePID(AliESDEvent *esd,Double_t t0time,Double_t t0sigma){
29 Double_t* calcolot0;
30
31 AliTOFT0v1* t0maker=new AliTOFT0v1(esd);
32 t0maker->SetCalib(fCalib);
33 t0maker->SetTimeResolution(fTimeResolution*1e-12);
34
35 if(! fESDswitch){
36 calcolot0=t0maker->DefineT0RawCorrection("all");
37 TakeTimeRawCorrection(esd);
38 }
39 else calcolot0=t0maker->DefineT0("all");
40
41 calcolot0[0]*=-1000;
42 calcolot0[1]*=1000;
43
44 Float_t T0Current;
45 fT0sigma=1000;
46
47 if(calcolot0[1] < 300){
48 fT0sigma=calcolot0[1];
49 T0Current=calcolot0[0];
50 }
51
52 if(t0sigma < 1000){
53 if(fT0sigma < 1000){
54 Double_t w1 = 1./t0sigma/t0sigma;
55 Double_t w2 = 1./calcolot0[1]/calcolot0[1];
56
57 Double_t wtot = w1+w2;
58
59 T0Current = (w1*t0time + w2*calcolot0[0]) / wtot;
60 fT0sigma = TMath::Sqrt(1./wtot);
61 }
62 else{
63 T0Current=t0time;
64 fT0sigma=t0sigma;
65 }
66 }
67
68 Int_t nrun = esd->GetRunNumber();
69 Double_t t0fill = GetT0Fill(nrun);
70
71 if(fT0sigma >= 1000){
72 T0Current = t0fill;
73 fT0sigma = 135;
74 }
75
76 RemakeTOFpid(esd,T0Current);
77
78 return calcolot0;
79}
80//____________________________________________________________________________
81void AliTOFT0maker::TakeTimeRawCorrection(AliESDEvent *esd){
82 Int_t ntracks = esd->GetNumberOfTracks();
83
84 while (ntracks--) {
85 AliESDtrack *t=esd->GetTrack(ntracks);
86
87 if ((t->GetStatus()&AliESDtrack::kTOFout)==0) continue;
88
89 Double_t time=t->GetTOFsignalRaw();
90 Double_t tot = t->GetTOFsignalToT();
91 Int_t chan = t->GetTOFCalChannel();
92 Double_t corr = fCalib->GetFullCorrection(chan,tot) - fCalib->GetCorrection(AliTOFcalibHisto::kTimeSlewingCorr,chan,0);
93 time -= corr*1000;
94
95 Int_t crate = Int_t(fCalib->GetCalibMap(AliTOFcalibHisto::kDDL,chan));
96
97 if(crate == 63 || crate == 62){
98 time += 9200;
99 }
100
101 t->SetTOFsignal(time);
102 }
103}
104//____________________________________________________________________________
105void AliTOFT0maker::RemakeTOFpid(AliESDEvent *esd,Float_t timezero){
106 Double_t param[3];
107
108 param[0]=TMath::Sqrt(fT0sigma*fT0sigma + fTimeResolution*fTimeResolution);
109 param[1]=5;
110 param[2]=0.9;
111
112 AliTOFpidESD* pidTOF=new AliTOFpidESD(param);
113 pidTOF->MakePID(esd,timezero);
114
115 AliESDpid* pidESD = new AliESDpid();
116 pidESD->MakePID(esd);
117
118}
119//____________________________________________________________________________
120Double_t AliTOFT0maker::GetT0Fill(Int_t nrun){
121 Double_t t0;
122 if(nrun==104065) t0= 1771614;
123 else if(nrun==104068) t0= 1771603;
124 else if(nrun==104070) t0= 1771594;
125 else if(nrun==104073) t0= 1771610;
126 else if(nrun==104080) t0= 1771305;
127 else if(nrun==104083) t0= 1771613;
128 else if(nrun==104157) t0= 1771665;
129 else if(nrun==104159) t0= 1771679;
130 else if(nrun==104160) t0= 1771633;
131 else if(nrun==104316) t0= 1764344;
132 else if(nrun==104320) t0= 1764342;
133 else if(nrun==104321) t0= 1764371;
134 else if(nrun==104439) t0= 1771750;
135 else if(nrun==104792) t0= 1771755;
136 else if(nrun==104793) t0= 1771762;
137 else if(nrun==104799) t0= 1771828;
138 else if(nrun==104800) t0= 1771788;
139 else if(nrun==104801) t0= 1771796;
140 else if(nrun==104802) t0= 1771775;
141 else if(nrun==104803) t0= 1771795;
142 else if(nrun==104824) t0= 1771751;
143 else if(nrun==104825) t0= 1771763;
144 else if(nrun==104845) t0= 1771792;
145 else if(nrun==104852) t0= 1771817;
146 else if(nrun==104864) t0= 1771825;
147 else if(nrun==104865) t0= 1771827;
148 else if(nrun==104867) t0= 1771841;
149 else if(nrun==104876) t0= 1771856;
150 else if(nrun==104878) t0= 1771847;
151 else if(nrun==104879) t0= 1771830;
152 else if(nrun==104892) t0= 1771837;
153 else t0= 1771837;
154
155 if(fESDswitch) t0 -= 487;
156
157 return t0;
158}