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