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();
73 for (i = 0; i < 4; i++) fCalculated[i] = 0.0;
75 //____________________________________________________________________________
76 AliRsnTOFT0maker::AliRsnTOFT0maker(const AliRsnTOFT0maker & t) :
78 fSettings(t.fSettings),
80 fESDswitch(t.fESDswitch),
81 fTimeResolution(t.fTimeResolution),
83 fHmapChannel(t.fHmapChannel),
87 fCalculated[0] = t.fCalculated[0];
88 fCalculated[1] = t.fCalculated[1];
89 fCalculated[2] = t.fCalculated[2];
90 fCalculated[3] = t.fCalculated[3];
93 //____________________________________________________________________________
94 AliRsnTOFT0maker& AliRsnTOFT0maker::operator=(const AliRsnTOFT0maker &t)
100 fCalculated[0] = t.fCalculated[0];
101 fCalculated[1] = t.fCalculated[1];
102 fCalculated[2] = t.fCalculated[2];
103 fCalculated[3] = t.fCalculated[3];
105 fSettings = t.fSettings;
109 fESDswitch = t.fESDswitch;
110 fTimeResolution = t.fTimeResolution;
111 fT0sigma = t.fT0sigma;
115 //____________________________________________________________________________
116 AliRsnTOFT0maker::~AliRsnTOFT0maker()
119 if (fCalib) delete fCalib;
121 //____________________________________________________________________________
122 Double_t* AliRsnTOFT0maker::RemakePID(AliESDEvent *esd, Double_t t0time, Double_t t0sigma)
125 // Remake TOF PID probabilities
130 if (fKmask) ApplyMask(esd);
132 AliTOFT0v1* t0makerANA = new AliTOFT0v1(esd);
133 // t0makerANA->SetCalib(fCalib);
134 t0makerANA->SetTimeResolution(fTimeResolution * 1e-12);
137 TakeTimeRawCorrection(esd);
140 t0tof = t0makerANA->DefineT0("all");
142 Float_t lT0Current = 0.;
145 Int_t nrun = 0;//esd->GetRunNumber();
146 Double_t t0fill = 175;//GetT0Fill(nrun);
147 if (fSettings == kPass2 || fSettings == kPass4) { // cambiato!!!!!!!!
148 nrun = esd->GetRunNumber();
149 t0fill = GetT0Fill(nrun);
150 } else if (fSettings == kLHC09d10) { // e' il MC del pass2?
151 t0fill = GetT0Fill(nrun);
154 fCalculated[0] = -1000 * t0tof[0];
155 fCalculated[1] = 1000 * t0tof[1];
156 fCalculated[2] = t0fill;
157 fCalculated[3] = t0tof[2];
159 if (fCalculated[1] < 150 && TMath::Abs(fCalculated[0] - t0fill) < 500) {
160 fT0sigma = fCalculated[1];
161 lT0Current = fCalculated[0];
164 if (t0sigma < 1000) {
165 if (fT0sigma < 1000) {
166 Double_t w1 = 1. / t0sigma / t0sigma;
167 Double_t w2 = 1. / fCalculated[1] / fCalculated[1];
169 Double_t wtot = w1 + w2;
171 lT0Current = (w1 * t0time + w2 * fCalculated[0]) / wtot;
172 fT0sigma = TMath::Sqrt(1. / wtot);
179 if (fT0sigma >= 1000 || fNoTOFT0) {
183 fCalculated[0] = t0fill;
184 fCalculated[1] = 150;
187 RemakeTOFpid(esd, lT0Current);
191 //____________________________________________________________________________
192 void AliRsnTOFT0maker::TakeTimeRawCorrection(AliESDEvent * const esd)
195 // Take raw corrections for time measurements
198 Int_t ntracks = esd->GetNumberOfTracks();
201 AliESDtrack *t = esd->GetTrack(ntracks);
203 if ((t->GetStatus()&AliESDtrack::kTOFout) == 0) continue;
205 Double_t time = t->GetTOFsignalRaw();
206 Double_t tot = t->GetTOFsignalToT();
207 Int_t chan = t->GetTOFCalChannel();
208 Double_t corr = fCalib->GetFullCorrection(chan, tot) - fCalib->GetCorrection(AliTOFcalibHisto::kTimeSlewingCorr, chan, 0);
211 //Int_t crate = Int_t(fCalib->GetCalibMap(AliTOFcalibHisto::kDDL,chan));
213 // if(crate == 63 || crate == 62){
218 // if(crate == 63 || crate == 62|| crate == 61){
219 // printf("%i) %f\n",crate,time);
222 t->SetTOFsignal(time);
225 //____________________________________________________________________________
226 void AliRsnTOFT0maker::RemakeTOFpid(AliESDEvent *esd, Float_t timezero)
229 // Recalculate TOF PID probabilities
232 pidESD.GetTOFResponse().SetTimeResolution(TMath::Sqrt(fT0sigma * fT0sigma + fTimeResolution * fTimeResolution));
233 pidESD.MakePID(esd, kFALSE, timezero);
236 //____________________________________________________________________________
237 Double_t AliRsnTOFT0maker::GetT0Fill(Int_t nrun) const
240 // Return T0 of filling
244 if (nrun == 104065) t0 = 1771614;
245 else if (nrun == 104068) t0 = 1771603;
246 else if (nrun == 104070) t0 = 1771594;
247 else if (nrun == 104073) t0 = 1771610;
248 else if (nrun == 104080) t0 = 1771305;
249 else if (nrun == 104083) t0 = 1771613;
250 else if (nrun == 104157) t0 = 1771665;
251 else if (nrun == 104159) t0 = 1771679;
252 else if (nrun == 104160) t0 = 1771633;
253 else if (nrun == 104316) t0 = 1764344;
254 else if (nrun == 104320) t0 = 1764342;
255 else if (nrun == 104321) t0 = 1764371;
256 else if (nrun == 104439) t0 = 1771750;
257 else if (nrun == 104792) t0 = 1771755;
258 else if (nrun == 104793) t0 = 1771762;
259 else if (nrun == 104799) t0 = 1771828;
260 else if (nrun == 104800) t0 = 1771788;
261 else if (nrun == 104801) t0 = 1771796;
262 else if (nrun == 104802) t0 = 1771775;
263 else if (nrun == 104803) t0 = 1771795;
264 else if (nrun == 104824) t0 = 1771751;
265 else if (nrun == 104825) t0 = 1771763;
266 else if (nrun == 104845) t0 = 1771792;
267 else if (nrun == 104852) t0 = 1771817;
268 else if (nrun == 104864) t0 = 1771825;
269 else if (nrun == 104865) t0 = 1771827;
270 else if (nrun == 104867) t0 = 1771841;
271 else if (nrun == 104876) t0 = 1771856;
272 else if (nrun == 104878) t0 = 1771847;
273 else if (nrun == 104879) t0 = 1771830;
274 else if (nrun == 104892) t0 = 1771837;
277 if (fESDswitch) t0 -= 487;
278 else { if (fSettings == kPass4) t0 -= 37 * 1024 * 24.4; }
283 //____________________________________________________________________________
284 void AliRsnTOFT0maker::LoadChannelMap(char *filename)
286 // Load the histo with the channel off map
287 TFile *f = new TFile(filename);
289 printf("Cannot open the channel map file (%s)\n", filename);
293 fHmapChannel = (TH1F *) f->Get("hChEnabled");
296 printf("Cannot laod the channel map histo (from %s)\n", filename);
301 //____________________________________________________________________________
302 void AliRsnTOFT0maker::ApplyMask(AliESDEvent *esd)
304 // Switch off the disable channel
306 printf("Channel Map is not available\n");
310 Int_t ntracks = esd->GetNumberOfTracks();
313 AliESDtrack *t = esd->GetTrack(ntracks);
315 if ((t->GetStatus()&AliESDtrack::kTOFout) == 0) continue;
317 Int_t chan = t->GetTOFCalChannel();
319 if (fHmapChannel->GetBinContent(chan) < 0.01) {
320 t->ResetStatus(AliESDtrack::kTOFout);