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: AliRsnTOFT0maker.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 (fTOFmakerANA is a private var) //
24 // fTOFmakerANA = new AliRsnTOFT0maker(); //
25 // fTOFmakerANA->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=fTOFmakerANA->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 "AliTOFcalibHisto.h"
46 #include "AliESDpid.h"
48 #include "AliRsnTOFT0maker.h"
50 ClassImp(AliRsnTOFT0maker)
52 //____________________________________________________________________________
53 AliRsnTOFT0maker::AliRsnTOFT0maker():
55 fCalib(new AliTOFcalibHisto()),
68 fCalib->LoadCalibPar();
70 if(AliPID::ParticleMass(0) == 0) new AliPID();
72 //____________________________________________________________________________
73 AliRsnTOFT0maker::AliRsnTOFT0maker(const AliRsnTOFT0maker & t) :
75 fSettings(t.fSettings),
77 fESDswitch(t.fESDswitch),
78 fTimeResolution(t.fTimeResolution),
80 fHmapChannel(t.fHmapChannel),
86 //____________________________________________________________________________
87 AliRsnTOFT0maker& AliRsnTOFT0maker::operator=(const AliRsnTOFT0maker &t)
93 fSettings = t.fSettings;
97 fESDswitch = t.fESDswitch;
98 fTimeResolution = t.fTimeResolution;
99 fT0sigma = t.fT0sigma;
103 //____________________________________________________________________________
104 AliRsnTOFT0maker::~AliRsnTOFT0maker()
107 if(fCalib) delete fCalib;
109 //____________________________________________________________________________
110 Double_t* AliRsnTOFT0maker::RemakePID(AliESDEvent *esd,Double_t t0time,Double_t t0sigma){
112 // Remake TOF PID probabilities
117 if(fKmask) ApplyMask(esd);
119 AliTOFT0v1* t0makerANA=new AliTOFT0v1(esd);
120 // t0makerANA->SetCalib(fCalib);
121 t0makerANA->SetTimeResolution(fTimeResolution*1e-12);
124 TakeTimeRawCorrection(esd);
127 t0tof=t0makerANA->DefineT0("all");
129 Float_t lT0Current=0.;
132 Int_t nrun = 0;//esd->GetRunNumber();
133 Double_t t0fill = 175;//GetT0Fill(nrun);
134 if (fSettings == kPass2 || fSettings == kPass4) // cambiato!!!!!!!!
136 nrun = esd->GetRunNumber();
137 t0fill = GetT0Fill(nrun);
139 else if (fSettings == kLHC09d10) // e' il MC del pass2?
141 t0fill = GetT0Fill(nrun);
144 fCalculated[0]=-1000*t0tof[0];
145 fCalculated[1]=1000*t0tof[1];
146 fCalculated[2] = t0fill;
147 fCalculated[3] = t0tof[2];
149 if(fCalculated[1] < 150 && TMath::Abs(fCalculated[0] - t0fill) < 500){
150 fT0sigma=fCalculated[1];
151 lT0Current=fCalculated[0];
156 Double_t w1 = 1./t0sigma/t0sigma;
157 Double_t w2 = 1./fCalculated[1]/fCalculated[1];
159 Double_t wtot = w1+w2;
161 lT0Current = (w1*t0time + w2*fCalculated[0]) / wtot;
162 fT0sigma = TMath::Sqrt(1./wtot);
170 if(fT0sigma >= 1000 || fNoTOFT0){
174 fCalculated[0] = t0fill;
175 fCalculated[1] = 150;
178 RemakeTOFpid(esd,lT0Current);
182 //____________________________________________________________________________
183 void AliRsnTOFT0maker::TakeTimeRawCorrection(AliESDEvent * const esd){
185 // Take raw corrections for time measurements
188 Int_t ntracks = esd->GetNumberOfTracks();
191 AliESDtrack *t=esd->GetTrack(ntracks);
193 if ((t->GetStatus()&AliESDtrack::kTOFout)==0) continue;
195 Double_t time=t->GetTOFsignalRaw();
196 Double_t tot = t->GetTOFsignalToT();
197 Int_t chan = t->GetTOFCalChannel();
198 Double_t corr = fCalib->GetFullCorrection(chan,tot) - fCalib->GetCorrection(AliTOFcalibHisto::kTimeSlewingCorr,chan,0);
201 //Int_t crate = Int_t(fCalib->GetCalibMap(AliTOFcalibHisto::kDDL,chan));
203 // if(crate == 63 || crate == 62){
208 // if(crate == 63 || crate == 62|| crate == 61){
209 // printf("%i) %f\n",crate,time);
212 t->SetTOFsignal(time);
215 //____________________________________________________________________________
216 void AliRsnTOFT0maker::RemakeTOFpid(AliESDEvent *esd,Float_t timezero){
218 // Recalculate TOF PID probabilities
221 pidESD.GetTOFResponse().SetTimeResolution(TMath::Sqrt(fT0sigma*fT0sigma + fTimeResolution*fTimeResolution));
222 pidESD.MakePID(esd,kFALSE,timezero);
225 //____________________________________________________________________________
226 Double_t AliRsnTOFT0maker::GetT0Fill(Int_t nrun) const {
228 // Return T0 of filling
232 if(nrun==104065) t0= 1771614;
233 else if(nrun==104068) t0= 1771603;
234 else if(nrun==104070) t0= 1771594;
235 else if(nrun==104073) t0= 1771610;
236 else if(nrun==104080) t0= 1771305;
237 else if(nrun==104083) t0= 1771613;
238 else if(nrun==104157) t0= 1771665;
239 else if(nrun==104159) t0= 1771679;
240 else if(nrun==104160) t0= 1771633;
241 else if(nrun==104316) t0= 1764344;
242 else if(nrun==104320) t0= 1764342;
243 else if(nrun==104321) t0= 1764371;
244 else if(nrun==104439) t0= 1771750;
245 else if(nrun==104792) t0= 1771755;
246 else if(nrun==104793) t0= 1771762;
247 else if(nrun==104799) t0= 1771828;
248 else if(nrun==104800) t0= 1771788;
249 else if(nrun==104801) t0= 1771796;
250 else if(nrun==104802) t0= 1771775;
251 else if(nrun==104803) t0= 1771795;
252 else if(nrun==104824) t0= 1771751;
253 else if(nrun==104825) t0= 1771763;
254 else if(nrun==104845) t0= 1771792;
255 else if(nrun==104852) t0= 1771817;
256 else if(nrun==104864) t0= 1771825;
257 else if(nrun==104865) t0= 1771827;
258 else if(nrun==104867) t0= 1771841;
259 else if(nrun==104876) t0= 1771856;
260 else if(nrun==104878) t0= 1771847;
261 else if(nrun==104879) t0= 1771830;
262 else if(nrun==104892) t0= 1771837;
265 if(fESDswitch) t0 -= 487;
266 else { if (fSettings == kPass4) t0 -=37*1024*24.4; }
271 //____________________________________________________________________________
272 void AliRsnTOFT0maker::LoadChannelMap(char *filename){
273 // Load the histo with the channel off map
274 TFile *f= new TFile(filename);
276 printf("Cannot open the channel map file (%s)\n",filename);
280 fHmapChannel = (TH1F *) f->Get("hChEnabled");
283 printf("Cannot laod the channel map histo (from %s)\n",filename);
288 //____________________________________________________________________________
289 void AliRsnTOFT0maker::ApplyMask(AliESDEvent *esd){
290 // Switch off the disable channel
292 printf("Channel Map is not available\n");
296 Int_t ntracks = esd->GetNumberOfTracks();
299 AliESDtrack *t=esd->GetTrack(ntracks);
301 if ((t->GetStatus()&AliESDtrack::kTOFout)==0) continue;
303 Int_t chan = t->GetTOFCalChannel();
305 if(fHmapChannel->GetBinContent(chan) < 0.01){
306 t->ResetStatus(AliESDtrack::kTOFout);