1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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: AliTOFT0maker.cxx,v 1.8 2010/01/19 16:32:20 noferini Exp $ */
17 /////////////////////////////////////////////////////////////////////////////
19 // This class contains the basic functions for the time zero //
20 // evaluation with TOF detector informations. //
21 // Use case in an analysis task: //
23 // Create the object in the task constructor (fTOFmaker is a private var) //
24 // fTOFmaker = new AliTOFT0maker(); //
25 // fTOFmaker->SetTimeResolution(115.0e-12); // if you want set the TOF res //
26 // 115 ps is the TOF default resolution value //
28 // Use the RemakePID method in the task::Exec //
29 // Double_t* calcolot0; //
30 // calcolot0=fTOFmaker->RemakePID(fESD); //
31 // //calcolot0[0] = calculated event time //
32 // //calcolot0[1] = event time time resolution //
33 // //calcolot0[2] = average event time for the current fill //
35 // Let consider that: //
36 // - the PIF is automatically recalculated with the event time subtrction //
38 /////////////////////////////////////////////////////////////////////////////
40 #include <Riostream.h>
43 #include "AliTOFT0v1.h"
44 #include "AliTOFT0maker.h"
45 #include "AliTOFcalibHisto.h"
47 #include "AliESDpid.h"
49 ClassImp(AliTOFT0maker)
51 //____________________________________________________________________________
52 AliTOFT0maker::AliTOFT0maker() :
54 fCalib(new AliTOFcalibHisto()),
67 fCalib->LoadCalibPar();
69 if(AliPID::ParticleMass(0) == 0) new AliPID();
71 //____________________________________________________________________________
72 AliTOFT0maker::AliTOFT0maker(const AliTOFT0maker & t) :
75 fESDswitch(t.fESDswitch),
76 fTimeResolution(t.fTimeResolution),
81 //____________________________________________________________________________
82 AliTOFT0maker& AliTOFT0maker::operator=(const AliTOFT0maker &t)
91 fESDswitch = t.fESDswitch;
92 fTimeResolution = t.fTimeResolution;
93 fT0sigma = t.fT0sigma;
97 //____________________________________________________________________________
98 AliTOFT0maker::~AliTOFT0maker()
101 if(fCalib) delete fCalib;
103 //____________________________________________________________________________
104 Double_t* AliTOFT0maker::RemakePID(AliESDEvent *esd,Double_t t0time,Double_t t0sigma){
106 // Remake TOF PID probabilities
111 AliTOFT0v1* t0maker=new AliTOFT0v1(esd);
112 t0maker->SetCalib(fCalib);
113 t0maker->SetTimeResolution(fTimeResolution*1e-12);
116 t0tof=t0maker->DefineT0RawCorrection("all");
117 TakeTimeRawCorrection(esd);
119 else t0tof=t0maker->DefineT0("all");
121 Float_t lT0Current=0.;
124 Int_t nrun = esd->GetRunNumber();
125 Double_t t0fill = GetT0Fill(nrun);
127 fCalculated[0]=-1000*t0tof[0];
128 fCalculated[1]=1000*t0tof[1];
129 fCalculated[2] = t0fill;
131 if(fCalculated[1] < 150 && TMath::Abs(fCalculated[0] - t0fill) < 500){
132 fT0sigma=fCalculated[1];
133 lT0Current=fCalculated[0];
138 Double_t w1 = 1./t0sigma/t0sigma;
139 Double_t w2 = 1./fCalculated[1]/fCalculated[1];
141 Double_t wtot = w1+w2;
143 lT0Current = (w1*t0time + w2*fCalculated[0]) / wtot;
144 fT0sigma = TMath::Sqrt(1./wtot);
152 if(fT0sigma >= 1000){
156 fCalculated[0] = t0fill;
157 fCalculated[1] = 150;
160 RemakeTOFpid(esd,lT0Current);
164 //____________________________________________________________________________
165 void AliTOFT0maker::TakeTimeRawCorrection(AliESDEvent * const esd){
167 // Take raw corrections for time measurements
170 Int_t ntracks = esd->GetNumberOfTracks();
173 AliESDtrack *t=esd->GetTrack(ntracks);
175 if ((t->GetStatus()&AliESDtrack::kTOFout)==0) continue;
177 Double_t time=t->GetTOFsignalRaw();
178 Double_t tot = t->GetTOFsignalToT();
179 Int_t chan = t->GetTOFCalChannel();
180 Double_t corr = fCalib->GetFullCorrection(chan,tot) - fCalib->GetCorrection(AliTOFcalibHisto::kTimeSlewingCorr,chan,0);
183 Int_t crate = Int_t(fCalib->GetCalibMap(AliTOFcalibHisto::kDDL,chan));
185 if(crate == 63 || crate == 62){
189 t->SetTOFsignal(time);
192 //____________________________________________________________________________
193 void AliTOFT0maker::RemakeTOFpid(AliESDEvent *esd,Float_t timezero){
195 // Recalculate TOF PID probabilities
199 pidESD.GetTOFResponse().SetTimeResolution(TMath::Sqrt(fT0sigma*fT0sigma + fTimeResolution*fTimeResolution));
200 pidESD.MakePID(esd,kFALSE,timezero);
203 //____________________________________________________________________________
204 Double_t AliTOFT0maker::GetT0Fill(Int_t nrun) const {
206 // Return T0 of filling
210 if(nrun==104065) t0= 1771614;
211 else if(nrun==104068) t0= 1771603;
212 else if(nrun==104070) t0= 1771594;
213 else if(nrun==104073) t0= 1771610;
214 else if(nrun==104080) t0= 1771305;
215 else if(nrun==104083) t0= 1771613;
216 else if(nrun==104157) t0= 1771665;
217 else if(nrun==104159) t0= 1771679;
218 else if(nrun==104160) t0= 1771633;
219 else if(nrun==104316) t0= 1764344;
220 else if(nrun==104320) t0= 1764342;
221 else if(nrun==104321) t0= 1764371;
222 else if(nrun==104439) t0= 1771750;
223 else if(nrun==104792) t0= 1771755;
224 else if(nrun==104793) t0= 1771762;
225 else if(nrun==104799) t0= 1771828;
226 else if(nrun==104800) t0= 1771788;
227 else if(nrun==104801) t0= 1771796;
228 else if(nrun==104802) t0= 1771775;
229 else if(nrun==104803) t0= 1771795;
230 else if(nrun==104824) t0= 1771751;
231 else if(nrun==104825) t0= 1771763;
232 else if(nrun==104845) t0= 1771792;
233 else if(nrun==104852) t0= 1771817;
234 else if(nrun==104864) t0= 1771825;
235 else if(nrun==104865) t0= 1771827;
236 else if(nrun==104867) t0= 1771841;
237 else if(nrun==104876) t0= 1771856;
238 else if(nrun==104878) t0= 1771847;
239 else if(nrun==104879) t0= 1771830;
240 else if(nrun==104892) t0= 1771837;
243 if(fESDswitch) t0 -= 487;