]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TOF/AliTOFT0maker.cxx
Coding convention violations: suppression
[u/mrichter/AliRoot.git] / TOF / AliTOFT0maker.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15 /* $Id:  $ */
16
17 /////////////////////////////////////////////////////////////////////////////
18 //                                                                         //
19 //  This class contains the basic functions for the time zero              //
20 //  evaluation with TOF detecyor informations.                             //
21 //                                                                         //
22 /////////////////////////////////////////////////////////////////////////////
23
24 #include <Riostream.h>
25 #include <stdlib.h>
26
27 #include "AliTOFT0v1.h"
28 #include "AliTOFT0maker.h"
29 #include "AliTOFcalibHisto.h"
30 #include "AliPID.h"
31 #include "AliESDpid.h"
32
33 ClassImp(AliTOFT0maker)
34            
35 //____________________________________________________________________________ 
36   AliTOFT0maker::AliTOFT0maker():
37 fCalib(new AliTOFcalibHisto()),
38   fESDswitch(0),
39   fTimeResolution(115),
40   fT0sigma(1000)
41 {
42   //fCalib = new AliTOFcalibHisto();
43   fCalib->LoadCalibPar();
44
45   if(AliPID::ParticleMass(0) == 0) new AliPID();
46 }
47 //____________________________________________________________________________ 
48 AliTOFT0maker::AliTOFT0maker(const AliTOFT0maker & t) :
49 TObject(),
50   fCalib(t.fCalib),
51   fESDswitch(t.fESDswitch),
52   fTimeResolution(t.fTimeResolution),
53   fT0sigma(t.fT0sigma)
54 {
55 }
56
57 //____________________________________________________________________________ 
58 AliTOFT0maker& AliTOFT0maker::operator=(const AliTOFT0maker &t)
59 {
60  //
61   // assign. operator
62   //
63
64   if (this == &t)
65     return *this;
66   fCalib = t.fCalib;
67   fESDswitch = t.fESDswitch;
68   fTimeResolution = t.fTimeResolution;
69   fT0sigma = t.fT0sigma;
70
71   return *this;
72 }
73 //____________________________________________________________________________ 
74 AliTOFT0maker::~AliTOFT0maker()
75 {
76   // dtor
77   if(fCalib) delete fCalib;
78 }
79 //____________________________________________________________________________ 
80 Double_t* AliTOFT0maker::RemakePID(AliESDEvent *esd,Double_t t0time,Double_t t0sigma){
81   //
82   // Remake TOF PID probabilities
83   //
84
85   Double_t calcolot0[3];
86   Double_t *t0tof;
87
88   AliTOFT0v1* t0maker=new AliTOFT0v1(esd);
89   t0maker->SetCalib(fCalib);
90   t0maker->SetTimeResolution(fTimeResolution*1e-12);
91
92   if(! fESDswitch){
93     t0tof=t0maker->DefineT0RawCorrection("all");
94     TakeTimeRawCorrection(esd);
95   }
96   else t0tof=t0maker->DefineT0("all");
97
98   Float_t lT0Current=0.;
99   fT0sigma=1000;
100
101   Int_t nrun = esd->GetRunNumber();
102   Double_t t0fill = GetT0Fill(nrun);
103
104   calcolot0[0]=-1000*t0tof[0];
105   calcolot0[1]=1000*t0tof[1];
106   calcolot0[2] = t0fill;
107
108   if(calcolot0[1] < 150 && TMath::Abs(calcolot0[0] - t0fill) < 500){
109     fT0sigma=calcolot0[1];
110     lT0Current=calcolot0[0];
111   }
112
113   if(t0sigma < 1000){
114     if(fT0sigma < 1000){
115       Double_t w1 = 1./t0sigma/t0sigma;
116       Double_t w2 = 1./calcolot0[1]/calcolot0[1];
117
118       Double_t wtot = w1+w2;
119
120       lT0Current = (w1*t0time + w2*calcolot0[0]) / wtot;
121       fT0sigma = TMath::Sqrt(1./wtot);
122     }
123     else{
124       lT0Current=t0time;
125       fT0sigma=t0sigma;
126     }
127   }
128
129   if(fT0sigma >= 1000){
130     lT0Current = t0fill;
131     fT0sigma = 135;
132
133     calcolot0[0] = t0fill;
134     calcolot0[1] = 150;
135   }
136
137   RemakeTOFpid(esd,lT0Current);
138
139   return calcolot0;
140 }
141 //____________________________________________________________________________ 
142 void AliTOFT0maker::TakeTimeRawCorrection(AliESDEvent * const esd){
143   //
144   // Take raw corrections for time measurements
145   //
146
147   Int_t ntracks = esd->GetNumberOfTracks();
148
149   while (ntracks--) {
150     AliESDtrack *t=esd->GetTrack(ntracks);
151     
152     if ((t->GetStatus()&AliESDtrack::kTOFout)==0) continue;
153     
154     Double_t time=t->GetTOFsignalRaw();
155     Double_t tot = t->GetTOFsignalToT();
156     Int_t chan = t->GetTOFCalChannel();
157     Double_t corr = fCalib->GetFullCorrection(chan,tot) - fCalib->GetCorrection(AliTOFcalibHisto::kTimeSlewingCorr,chan,0);
158     time -= corr*1000;
159
160     Int_t crate = Int_t(fCalib->GetCalibMap(AliTOFcalibHisto::kDDL,chan));
161
162     if(crate == 63 || crate == 62){
163       time += 9200;
164     }
165
166     t->SetTOFsignal(time);
167   }
168 }
169 //____________________________________________________________________________ 
170 void AliTOFT0maker::RemakeTOFpid(AliESDEvent *esd,Float_t timezero){
171   //
172   // Recalculate TOF PID probabilities
173   //
174
175   AliESDpid pidESD;
176   pidESD.GetTOFResponse().SetTimeResolution(TMath::Sqrt(fT0sigma*fT0sigma + fTimeResolution*fTimeResolution));
177   pidESD.MakePID(esd,kFALSE,timezero);
178   
179 }
180 //____________________________________________________________________________ 
181 Double_t AliTOFT0maker::GetT0Fill(Int_t nrun) const {
182   //
183   // Return T0 of filling
184   //
185
186   Double_t t0;
187   if(nrun==104065) t0= 1771614;
188   else if(nrun==104068) t0= 1771603;
189   else if(nrun==104070) t0= 1771594;
190   else if(nrun==104073) t0= 1771610;
191   else if(nrun==104080) t0= 1771305;
192   else if(nrun==104083) t0= 1771613;
193   else if(nrun==104157) t0= 1771665;
194   else if(nrun==104159) t0= 1771679;
195   else if(nrun==104160) t0= 1771633;
196   else if(nrun==104316) t0= 1764344;
197   else if(nrun==104320) t0= 1764342;
198   else if(nrun==104321) t0= 1764371;
199   else if(nrun==104439) t0= 1771750;
200   else if(nrun==104792) t0= 1771755;
201   else if(nrun==104793) t0= 1771762;
202   else if(nrun==104799) t0= 1771828;
203   else if(nrun==104800) t0= 1771788;
204   else if(nrun==104801) t0= 1771796;
205   else if(nrun==104802) t0= 1771775;
206   else if(nrun==104803) t0= 1771795;
207   else if(nrun==104824) t0= 1771751;
208   else if(nrun==104825) t0= 1771763;
209   else if(nrun==104845) t0= 1771792;
210   else if(nrun==104852) t0= 1771817;
211   else if(nrun==104864) t0= 1771825;
212   else if(nrun==104865) t0= 1771827;
213   else if(nrun==104867) t0= 1771841;
214   else if(nrun==104876) t0= 1771856;
215   else if(nrun==104878) t0= 1771847;
216   else if(nrun==104879) t0= 1771830;
217   else if(nrun==104892) t0= 1771837;
218   else t0= 1771837;
219
220   if(fESDswitch) t0 -= 487;
221   
222   return t0;
223 }