]>
Commit | Line | Data |
---|---|---|
8c6a71ab | 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 | ||
4f679a16 | 16 | /* $Id$ */ |
17 | ||
8c6a71ab | 18 | //----------------------------------------------------------------- |
19 | // Implementation of the combined PID class | |
4f679a16 | 20 | // For the Event Summary Data Class |
21 | // produced by the reconstruction process | |
22 | // and containing information on the particle identification | |
8c6a71ab | 23 | // Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch |
24 | //----------------------------------------------------------------- | |
25 | ||
f858b00e | 26 | #include "TArrayI.h" |
27 | #include "TArrayF.h" | |
28 | ||
10d100d4 | 29 | #include "AliLog.h" |
30 | #include "AliPID.h" | |
f858b00e | 31 | #include "AliTOFHeader.h" |
8c6a71ab | 32 | #include "AliESDpid.h" |
af885e0f | 33 | #include "AliESDEvent.h" |
8c6a71ab | 34 | #include "AliESDtrack.h" |
35 | ||
36 | ClassImp(AliESDpid) | |
37 | ||
f858b00e | 38 | Int_t AliESDpid::MakePID(AliESDEvent *event, Bool_t TPConly, Float_t timeZeroTOF) const { |
10d100d4 | 39 | // |
40 | // Calculate probabilities for all detectors, except if TPConly==kTRUE | |
41 | // and combine PID | |
42 | // | |
43 | // Option TPConly==kTRUE is used during reconstruction, | |
44 | // because ITS tracking uses TPC pid | |
45 | // HMPID and TRD pid are done in detector reconstructors | |
46 | // | |
47 | ||
48 | /* | |
f858b00e | 49 | Float_t timeZeroTOF = 0; |
10d100d4 | 50 | if (subtractT0) |
f858b00e | 51 | timeZeroTOF = event->GetT0(); |
10d100d4 | 52 | */ |
53 | Int_t nTrk=event->GetNumberOfTracks(); | |
54 | for (Int_t iTrk=0; iTrk<nTrk; iTrk++) { | |
55 | AliESDtrack *track=event->GetTrack(iTrk); | |
56 | MakeTPCPID(track); | |
57 | if (!TPConly) { | |
58 | MakeITSPID(track); | |
f858b00e | 59 | MakeTOFPID(track, timeZeroTOF); |
10d100d4 | 60 | //MakeHMPIDPID(track); |
ce5d6908 | 61 | //MakeTRDPID(track); |
10d100d4 | 62 | } |
63 | CombinePID(track); | |
64 | } | |
65 | return 0; | |
66 | } | |
8c6a71ab | 67 | //_________________________________________________________________________ |
10d100d4 | 68 | void AliESDpid::MakeTPCPID(AliESDtrack *track) const |
8c6a71ab | 69 | { |
4f679a16 | 70 | // |
10d100d4 | 71 | // TPC pid using bethe-bloch and gaussian response |
4f679a16 | 72 | // |
10d100d4 | 73 | if ((track->GetStatus()&AliESDtrack::kTPCin )==0) |
74 | if ((track->GetStatus()&AliESDtrack::kTPCout)==0) return; | |
8c6a71ab | 75 | |
10d100d4 | 76 | Double_t mom = track->GetP(); |
77 | const AliExternalTrackParam *in=track->GetInnerParam(); | |
78 | if (in) mom = in->GetP(); | |
8c6a71ab | 79 | |
10d100d4 | 80 | Double_t p[AliPID::kSPECIES]; |
81 | Double_t dedx=track->GetTPCsignal(); | |
82 | Bool_t mismatch=kTRUE, heavy=kTRUE; | |
8c6a71ab | 83 | |
10d100d4 | 84 | for (Int_t j=0; j<AliPID::kSPECIES; j++) { |
85 | AliPID::EParticleType type=AliPID::EParticleType(j); | |
86 | Double_t bethe=fTPCResponse.GetExpectedSignal(mom,type); | |
87 | Double_t sigma=fTPCResponse.GetExpectedSigma(mom,track->GetTPCsignalN(),type); | |
88 | if (TMath::Abs(dedx-bethe) > fRange*sigma) { | |
89 | p[j]=TMath::Exp(-0.5*fRange*fRange)/sigma; | |
90 | } else { | |
91 | p[j]=TMath::Exp(-0.5*(dedx-bethe)*(dedx-bethe)/(sigma*sigma))/sigma; | |
92 | mismatch=kFALSE; | |
93 | } | |
8c6a71ab | 94 | |
10d100d4 | 95 | // Check for particles heavier than (AliPID::kSPECIES - 1) |
96 | if (dedx < (bethe + fRange*sigma)) heavy=kFALSE; | |
c630aafd | 97 | |
4a78b8c5 | 98 | } |
99 | ||
10d100d4 | 100 | if (mismatch) |
77638021 | 101 | for (Int_t j=0; j<AliPID::kSPECIES; j++) p[j]=1./AliPID::kSPECIES; |
10d100d4 | 102 | |
103 | track->SetTPCpid(p); | |
104 | ||
105 | if (heavy) track->ResetStatus(AliESDtrack::kTPCpid); | |
106 | ||
107 | } | |
108 | //_________________________________________________________________________ | |
109 | void AliESDpid::MakeITSPID(AliESDtrack *track) const | |
110 | { | |
111 | // | |
112 | // ITS PID | |
113 | // Two options, depending on fITSPIDmethod: | |
114 | // 1) Truncated mean method | |
115 | // 2) Likelihood, using charges measured in all 4 layers and | |
116 | // Landau+gaus response functions | |
117 | // | |
118 | ||
119 | if ((track->GetStatus()&AliESDtrack::kITSin)==0 && | |
120 | (track->GetStatus()&AliESDtrack::kITSout)==0) return; | |
121 | ||
122 | Double_t mom=track->GetP(); | |
123 | if (fITSPIDmethod == kITSTruncMean) { | |
124 | Double_t dedx=track->GetITSsignal(); | |
15e979c9 | 125 | Bool_t isSA=kTRUE; |
126 | Double_t momITS=mom; | |
127 | ULong_t trStatus=track->GetStatus(); | |
99daa709 | 128 | if(trStatus&AliESDtrack::kTPCin) isSA=kFALSE; |
15e979c9 | 129 | UChar_t clumap=track->GetITSClusterMap(); |
130 | Int_t nPointsForPid=0; | |
131 | for(Int_t i=2; i<6; i++){ | |
132 | if(clumap&(1<<i)) ++nPointsForPid; | |
133 | } | |
134 | ||
135 | if(nPointsForPid<3) { // track not to be used for combined PID purposes | |
136 | track->ResetStatus(AliESDtrack::kITSpid); | |
137 | return; | |
138 | } | |
139 | ||
10d100d4 | 140 | Double_t p[10]; |
15e979c9 | 141 | |
10d100d4 | 142 | Bool_t mismatch=kTRUE, heavy=kTRUE; |
143 | for (Int_t j=0; j<AliPID::kSPECIES; j++) { | |
144 | Double_t mass=AliPID::ParticleMass(j);//GeV/c^2 | |
15e979c9 | 145 | Double_t bethe=fITSResponse.Bethe(momITS,mass); |
146 | Double_t sigma=fITSResponse.GetResolution(bethe,nPointsForPid,isSA); | |
10d100d4 | 147 | if (TMath::Abs(dedx-bethe) > fRange*sigma) { |
148 | p[j]=TMath::Exp(-0.5*fRange*fRange)/sigma; | |
149 | } else { | |
150 | p[j]=TMath::Exp(-0.5*(dedx-bethe)*(dedx-bethe)/(sigma*sigma))/sigma; | |
151 | mismatch=kFALSE; | |
152 | } | |
153 | ||
154 | // Check for particles heavier than (AliPID::kSPECIES - 1) | |
155 | if (dedx < (bethe + fRange*sigma)) heavy=kFALSE; | |
156 | ||
4a78b8c5 | 157 | } |
c630aafd | 158 | |
10d100d4 | 159 | if (mismatch) |
160 | for (Int_t j=0; j<AliPID::kSPECIES; j++) p[j]=1./AliPID::kSPECIES; | |
161 | ||
162 | track->SetITSpid(p); | |
163 | ||
164 | if (heavy) track->ResetStatus(AliESDtrack::kITSpid); | |
165 | } | |
166 | else { // Likelihood method | |
167 | Double_t condprobfun[AliPID::kSPECIES]; | |
168 | Double_t qclu[4]; | |
169 | track->GetITSdEdxSamples(qclu); | |
170 | fITSResponse.GetITSProbabilities(mom,qclu,condprobfun); | |
171 | track->SetITSpid(condprobfun); | |
8c6a71ab | 172 | } |
7a8614f3 | 173 | |
10d100d4 | 174 | } |
175 | //_________________________________________________________________________ | |
f858b00e | 176 | void AliESDpid::MakeTOFPID(AliESDtrack *track, Float_t /*timeZeroTOF*/) const |
10d100d4 | 177 | { |
178 | // | |
179 | // TOF PID using gaussian response | |
180 | // | |
f858b00e | 181 | |
10d100d4 | 182 | if ((track->GetStatus()&AliESDtrack::kTOFout)==0) return; |
183 | if ((track->GetStatus()&AliESDtrack::kTIME)==0) return; | |
a512bf97 | 184 | if ((track->GetStatus()&AliESDtrack::kITSin)==0) return; |
10d100d4 | 185 | |
f858b00e | 186 | Int_t ibin = fTOFResponse.GetMomBin(track->GetP()); |
187 | Float_t timezero = fTOFResponse.GetT0bin(ibin); | |
188 | ||
10d100d4 | 189 | Double_t time[AliPID::kSPECIESN]; |
190 | track->GetIntegratedTimes(time); | |
191 | ||
192 | Double_t sigma[AliPID::kSPECIES]; | |
193 | for (Int_t iPart = 0; iPart < AliPID::kSPECIES; iPart++) { | |
194 | sigma[iPart] = fTOFResponse.GetExpectedSigma(track->GetP(),time[iPart],AliPID::ParticleMass(iPart)); | |
195 | } | |
196 | ||
197 | AliDebugGeneral("AliESDpid::MakeTOFPID",2, | |
198 | Form("Expected TOF signals [ps]: %f %f %f %f %f", | |
199 | time[AliPID::kElectron], | |
200 | time[AliPID::kMuon], | |
201 | time[AliPID::kPion], | |
202 | time[AliPID::kKaon], | |
203 | time[AliPID::kProton])); | |
204 | ||
205 | AliDebugGeneral("AliESDpid::MakeTOFPID",2, | |
206 | Form("Expected TOF std deviations [ps]: %f %f %f %f %f", | |
207 | sigma[AliPID::kElectron], | |
208 | sigma[AliPID::kMuon], | |
209 | sigma[AliPID::kPion], | |
210 | sigma[AliPID::kKaon], | |
211 | sigma[AliPID::kProton] | |
212 | )); | |
213 | ||
f858b00e | 214 | Double_t tof = track->GetTOFsignal() - timezero; |
10d100d4 | 215 | |
216 | Double_t p[AliPID::kSPECIES]; | |
217 | Bool_t mismatch = kTRUE, heavy = kTRUE; | |
218 | for (Int_t j=0; j<AliPID::kSPECIES; j++) { | |
219 | Double_t sig = sigma[j]; | |
f858b00e | 220 | if (TMath::Abs(tof-time[j]) > (fRange+2)*sig) { |
221 | p[j] = TMath::Exp(-0.5*(fRange+2)*(fRange+2))/sig; | |
10d100d4 | 222 | } else |
223 | p[j] = TMath::Exp(-0.5*(tof-time[j])*(tof-time[j])/(sig*sig))/sig; | |
224 | ||
225 | // Check the mismatching | |
ee251349 | 226 | |
10d100d4 | 227 | Double_t mass = AliPID::ParticleMass(j); |
228 | Double_t pm = fTOFResponse.GetMismatchProbability(track->GetP(),mass); | |
229 | if (p[j]>pm) mismatch = kFALSE; | |
230 | ||
231 | // Check for particles heavier than (AliPID::kSPECIES - 1) | |
232 | if (tof < (time[j] + fRange*sig)) heavy=kFALSE; | |
233 | ||
234 | } | |
235 | ||
ee251349 | 236 | /* |
237 | if (mismatch) | |
77638021 | 238 | for (Int_t j=0; j<AliPID::kSPECIES; j++) p[j]=1./AliPID::kSPECIES; |
ee251349 | 239 | */ |
10d100d4 | 240 | |
241 | track->SetTOFpid(p); | |
242 | ||
ee251349 | 243 | if (heavy) track->ResetStatus(AliESDtrack::kTOFpid); |
f858b00e | 244 | |
ee251349 | 245 | if (!CheckTOFMatching(track)) track->SetStatus(AliESDtrack::kTOFmismatch); |
246 | else track->ResetStatus(AliESDtrack::kTOFmismatch); | |
10d100d4 | 247 | } |
248 | //_________________________________________________________________________ | |
b439f460 | 249 | void AliESDpid::MakeTRDPID(AliESDtrack *track) const |
250 | { | |
251 | // | |
252 | // Method to recalculate the TRD PID probabilities | |
253 | // | |
ea235c90 | 254 | Double_t prob[AliPID::kSPECIES]; |
255 | ComputeTRDProbability(track, AliPID::kSPECIES, prob); | |
b439f460 | 256 | track->SetTRDpid(prob); |
257 | } | |
258 | //_________________________________________________________________________ | |
10d100d4 | 259 | void AliESDpid::CombinePID(AliESDtrack *track) const |
260 | { | |
261 | // | |
262 | // Combine the information of various detectors | |
263 | // to determine the Particle Identification | |
264 | // | |
265 | Int_t ns=AliPID::kSPECIES; | |
266 | Double_t p[10]={1.,1.,1.,1.,1.,1.,1.,1.,1.,1.}; | |
267 | ||
268 | if (track->IsOn(AliESDtrack::kITSpid)) { | |
269 | Double_t d[10]; | |
270 | track->GetITSpid(d); | |
271 | for (Int_t j=0; j<ns; j++) p[j]*=d[j]; | |
272 | } | |
273 | ||
274 | if (track->IsOn(AliESDtrack::kTPCpid)) { | |
275 | Double_t d[10]; | |
276 | track->GetTPCpid(d); | |
277 | for (Int_t j=0; j<ns; j++) p[j]*=d[j]; | |
278 | } | |
279 | ||
280 | if (track->IsOn(AliESDtrack::kTRDpid)) { | |
281 | Double_t d[10]; | |
282 | track->GetTRDpid(d); | |
283 | for (Int_t j=0; j<ns; j++) p[j]*=d[j]; | |
284 | } | |
285 | ||
286 | if (track->IsOn(AliESDtrack::kTOFpid)) { | |
287 | Double_t d[10]; | |
288 | track->GetTOFpid(d); | |
289 | for (Int_t j=0; j<ns; j++) p[j]*=d[j]; | |
290 | } | |
291 | ||
292 | if (track->IsOn(AliESDtrack::kHMPIDpid)) { | |
293 | Double_t d[10]; | |
294 | track->GetHMPIDpid(d); | |
295 | for (Int_t j=0; j<ns; j++) p[j]*=d[j]; | |
296 | } | |
297 | ||
298 | track->SetESDpid(p); | |
8c6a71ab | 299 | } |
f858b00e | 300 | //_________________________________________________________________________ |
301 | Bool_t AliESDpid::CheckTOFMatching(AliESDtrack *track) const{ | |
ea235c90 | 302 | // |
303 | // Check pid matching of TOF with TPC as reference | |
304 | // | |
f858b00e | 305 | Bool_t status = kFALSE; |
306 | ||
307 | Double_t exptimes[5]; | |
308 | track->GetIntegratedTimes(exptimes); | |
309 | ||
f858b00e | 310 | Float_t p = track->P(); |
311 | ||
7170298c | 312 | Float_t dedx = track->GetTPCsignal(); |
313 | Float_t time = track->GetTOFsignal() - fTOFResponse.GetStartTime(p); | |
314 | ||
f858b00e | 315 | Double_t ptpc[3]; |
316 | track->GetInnerPxPyPz(ptpc); | |
317 | Float_t momtpc=TMath::Sqrt(ptpc[0]*ptpc[0] + ptpc[1]*ptpc[1] + ptpc[2]*ptpc[2]); | |
318 | ||
319 | for(Int_t i=0;i < 5;i++){ | |
320 | AliPID::EParticleType type=AliPID::EParticleType(i); | |
321 | ||
322 | Float_t resolutionTOF = fTOFResponse.GetExpectedSigma(p, exptimes[i], AliPID::ParticleMass(i)); | |
323 | if(TMath::Abs(exptimes[i] - time) < fRange * resolutionTOF){ | |
324 | Float_t dedxExp = fTPCResponse.GetExpectedSignal(momtpc,type); | |
325 | Float_t resolutionTPC = fTPCResponse.GetExpectedSigma(momtpc,track->GetTPCsignalN(),type); | |
326 | ||
7170298c | 327 | if(TMath::Abs(dedx - dedxExp) < fRangeTOFMismatch * resolutionTPC){ |
f858b00e | 328 | status = kTRUE; |
329 | } | |
330 | } | |
331 | } | |
332 | ||
333 | // for nuclei | |
c1252298 | 334 | Float_t resolutionTOFpr = fTOFResponse.GetExpectedSigma(p, exptimes[4], AliPID::ParticleMass(4)); |
335 | if(!status && (exptimes[4] + fRange*resolutionTOFpr < time)) status = kTRUE; | |
f858b00e | 336 | |
337 | ||
338 | return status; | |
339 | } | |
340 | //_________________________________________________________________________ | |
fca752cb | 341 | void AliESDpid::SetTOFResponse(AliVEvent *vevent,EStartTimeType_t option){ |
f858b00e | 342 | // |
343 | // Set TOF response function | |
344 | // Input option for event_time used | |
345 | // | |
346 | ||
fca752cb | 347 | AliESDEvent *event=(AliESDEvent*)vevent; |
348 | ||
f858b00e | 349 | Float_t t0spread = 0.; //event->GetEventTimeSpread(); |
350 | if(t0spread < 10) t0spread = 80; | |
351 | ||
352 | // T0 from TOF algorithm | |
f858b00e | 353 | |
354 | Bool_t flagT0TOF=kFALSE; | |
355 | Bool_t flagT0T0=kFALSE; | |
2f43a5ff | 356 | Float_t *startTime = new Float_t[fTOFResponse.GetNmomBins()]; |
357 | Float_t *startTimeRes = new Float_t[fTOFResponse.GetNmomBins()]; | |
d4d15b21 | 358 | Int_t *startTimeMask = new Int_t[fTOFResponse.GetNmomBins()]; |
f858b00e | 359 | |
7eb68cb5 | 360 | // T0-TOF arrays |
2f43a5ff | 361 | Float_t *estimatedT0event = new Float_t[fTOFResponse.GetNmomBins()]; |
362 | Float_t *estimatedT0resolution = new Float_t[fTOFResponse.GetNmomBins()]; | |
f858b00e | 363 | for(Int_t i=0;i<fTOFResponse.GetNmomBins();i++){ |
364 | estimatedT0event[i]=0.0; | |
365 | estimatedT0resolution[i]=0.0; | |
d4d15b21 | 366 | startTimeMask[i] = 0; |
f858b00e | 367 | } |
368 | ||
7eb68cb5 | 369 | Float_t resT0A=75,resT0C=65,resT0AC=55; |
370 | if(event->GetT0TOF()){ // check if T0 detector information is available | |
f858b00e | 371 | flagT0T0=kTRUE; |
372 | } | |
373 | ||
374 | ||
375 | AliTOFHeader *tofHeader =(AliTOFHeader*)event->GetTOFHeader(); | |
376 | ||
7eb68cb5 | 377 | if(tofHeader){ // read global info and T0-TOF info from ESD |
4d197ca4 | 378 | fTOFResponse.SetTimeResolution(tofHeader->GetTOFResolution()); |
7eb68cb5 | 379 | t0spread = tofHeader->GetT0spread(); // read t0 sprad |
4d197ca4 | 380 | if(t0spread < 10) t0spread = 80; |
f858b00e | 381 | |
382 | flagT0TOF=kTRUE; | |
7eb68cb5 | 383 | for(Int_t i=0;i<fTOFResponse.GetNmomBins();i++){ // read T0-TOF default value |
384 | startTime[i]=tofHeader->GetDefaultEventTimeVal(); | |
385 | startTimeRes[i]=tofHeader->GetDefaultEventTimeRes(); | |
edc91478 | 386 | if(startTimeRes[i] < 1.e-5) startTimeRes[i] = t0spread; |
f858b00e | 387 | } |
388 | ||
389 | TArrayI *ibin=tofHeader->GetNvalues(); | |
390 | TArrayF *t0Bin=tofHeader->GetEventTimeValues(); | |
391 | TArrayF *t0ResBin=tofHeader->GetEventTimeRes(); | |
7eb68cb5 | 392 | for(Int_t j=0;j < tofHeader->GetNbins();j++){ // fill T0-TOF in p-bins |
f858b00e | 393 | Int_t icurrent = (Int_t)ibin->GetAt(j); |
7eb68cb5 | 394 | startTime[icurrent]=t0Bin->GetAt(j); |
395 | startTimeRes[icurrent]=t0ResBin->GetAt(j); | |
edc91478 | 396 | if(startTimeRes[icurrent] < 1.e-5) startTimeRes[icurrent] = t0spread; |
397 | } | |
f858b00e | 398 | } |
399 | ||
7eb68cb5 | 400 | // for cut of 3 sigma on t0 spread |
401 | Float_t t0cut = 3 * t0spread; | |
402 | if(t0cut < 500) t0cut = 500; | |
403 | ||
f858b00e | 404 | if(option == kFILL_T0){ // T0-FILL is used |
405 | for(Int_t i=0;i<fTOFResponse.GetNmomBins();i++){ | |
406 | estimatedT0event[i]=0.0; | |
407 | estimatedT0resolution[i]=t0spread; | |
f858b00e | 408 | } |
409 | fTOFResponse.SetT0event(estimatedT0event); | |
410 | fTOFResponse.SetT0resolution(estimatedT0resolution); | |
411 | } | |
7eb68cb5 | 412 | |
f858b00e | 413 | if(option == kTOF_T0){ // T0-TOF is used when available (T0-FILL otherwise) from ESD |
414 | if(flagT0TOF){ | |
f858b00e | 415 | fTOFResponse.SetT0event(startTime); |
416 | fTOFResponse.SetT0resolution(startTimeRes); | |
d4d15b21 | 417 | for(Int_t i=0;i<fTOFResponse.GetNmomBins();i++){ |
418 | if(startTimeRes[i]<t0spread) startTimeMask[i]=1; | |
419 | fTOFResponse.SetT0binMask(i,startTimeMask[i]); | |
420 | } | |
f858b00e | 421 | } |
422 | else{ | |
423 | for(Int_t i=0;i<fTOFResponse.GetNmomBins();i++){ | |
424 | estimatedT0event[i]=0.0; | |
425 | estimatedT0resolution[i]=t0spread; | |
d4d15b21 | 426 | fTOFResponse.SetT0binMask(i,startTimeMask[i]); |
f858b00e | 427 | } |
428 | fTOFResponse.SetT0event(estimatedT0event); | |
429 | fTOFResponse.SetT0resolution(estimatedT0resolution); | |
430 | } | |
431 | } | |
d4d15b21 | 432 | else if(option == kBest_T0){ // T0-T0 or T0-TOF are used when available (T0-FILL otherwise) from ESD |
f858b00e | 433 | Float_t t0AC=-10000; |
434 | Float_t t0A=-10000; | |
435 | Float_t t0C=-10000; | |
436 | if(flagT0T0){ | |
437 | t0AC= event->GetT0TOF()[0]; | |
438 | t0A= event->GetT0TOF()[1]; | |
439 | t0C= event->GetT0TOF()[2]; | |
440 | } | |
441 | ||
442 | Float_t t0t0Best = 0; | |
443 | Float_t t0t0BestRes = 9999; | |
d4d15b21 | 444 | Int_t t0used=0; |
7eb68cb5 | 445 | if(TMath::Abs(t0A) < t0cut && TMath::Abs(t0C) < t0cut && TMath::Abs(t0C-t0A) < 500){ |
f858b00e | 446 | t0t0Best = t0AC; |
7eb68cb5 | 447 | t0t0BestRes = resT0AC; |
d4d15b21 | 448 | t0used=6; |
f858b00e | 449 | } |
7eb68cb5 | 450 | else if(TMath::Abs(t0C) < t0cut){ |
f858b00e | 451 | t0t0Best = t0C; |
7eb68cb5 | 452 | t0t0BestRes = resT0C; |
d4d15b21 | 453 | t0used=4; |
7eb68cb5 | 454 | } |
455 | else if(TMath::Abs(t0A) < t0cut){ | |
456 | t0t0Best = t0A; | |
457 | t0t0BestRes = resT0A; | |
d4d15b21 | 458 | t0used=2; |
f858b00e | 459 | } |
460 | ||
461 | if(flagT0TOF){ // if T0-TOF info is available | |
462 | for(Int_t i=0;i<fTOFResponse.GetNmomBins();i++){ | |
7eb68cb5 | 463 | if(t0t0BestRes < 999){ |
464 | if(startTimeRes[i] < t0spread){ | |
f858b00e | 465 | Double_t wtot = 1./startTimeRes[i]/startTimeRes[i] + 1./t0t0BestRes/t0t0BestRes; |
466 | Double_t t0best = startTime[i]/startTimeRes[i]/startTimeRes[i] + t0t0Best/t0t0BestRes/t0t0BestRes; | |
467 | estimatedT0event[i]=t0best / wtot; | |
468 | estimatedT0resolution[i]=1./TMath::Sqrt(wtot); | |
d4d15b21 | 469 | startTimeMask[i] = t0used+1; |
f858b00e | 470 | } |
471 | else { | |
472 | estimatedT0event[i]=t0t0Best; | |
473 | estimatedT0resolution[i]=t0t0BestRes; | |
d4d15b21 | 474 | startTimeMask[i] = t0used; |
f858b00e | 475 | } |
476 | } | |
477 | else{ | |
478 | estimatedT0event[i]=startTime[i]; | |
479 | estimatedT0resolution[i]=startTimeRes[i]; | |
d4d15b21 | 480 | if(startTimeRes[i]<t0spread) startTimeMask[i]=1; |
f858b00e | 481 | } |
d4d15b21 | 482 | fTOFResponse.SetT0binMask(i,startTimeMask[i]); |
f858b00e | 483 | } |
484 | fTOFResponse.SetT0event(estimatedT0event); | |
485 | fTOFResponse.SetT0resolution(estimatedT0resolution); | |
486 | } | |
487 | else{ // if no T0-TOF info is available | |
488 | for(Int_t i=0;i<fTOFResponse.GetNmomBins();i++){ | |
d4d15b21 | 489 | fTOFResponse.SetT0binMask(i,t0used); |
490 | if(t0t0BestRes < 999){ | |
491 | estimatedT0event[i]=t0t0Best; | |
492 | estimatedT0resolution[i]=t0t0BestRes; | |
493 | } | |
494 | else{ | |
495 | estimatedT0event[i]=0.0; | |
496 | estimatedT0resolution[i]=t0spread; | |
497 | } | |
f858b00e | 498 | } |
499 | fTOFResponse.SetT0event(estimatedT0event); | |
500 | fTOFResponse.SetT0resolution(estimatedT0resolution); | |
501 | } | |
502 | } | |
7eb68cb5 | 503 | |
d4d15b21 | 504 | else if(option == kT0_T0){ // T0-T0 is used when available (T0-FILL otherwise) from ESD |
f858b00e | 505 | Float_t t0AC=-10000; |
506 | Float_t t0A=-10000; | |
507 | Float_t t0C=-10000; | |
508 | if(flagT0T0){ | |
509 | t0AC= event->GetT0TOF()[0]; | |
510 | t0A= event->GetT0TOF()[1]; | |
511 | t0C= event->GetT0TOF()[2]; | |
512 | } | |
513 | ||
7eb68cb5 | 514 | if(TMath::Abs(t0A) < t0cut && TMath::Abs(t0C) < t0cut && TMath::Abs(t0C-t0A) < 500){ |
f858b00e | 515 | for(Int_t i=0;i<fTOFResponse.GetNmomBins();i++){ |
516 | estimatedT0event[i]=t0AC; | |
7eb68cb5 | 517 | estimatedT0resolution[i]=resT0AC; |
d4d15b21 | 518 | fTOFResponse.SetT0binMask(i,6); |
f858b00e | 519 | } |
520 | } | |
7eb68cb5 | 521 | else if(TMath::Abs(t0C) < t0cut){ |
f858b00e | 522 | for(Int_t i=0;i<fTOFResponse.GetNmomBins();i++){ |
7eb68cb5 | 523 | estimatedT0event[i]=t0C; |
524 | estimatedT0resolution[i]=resT0C; | |
d4d15b21 | 525 | fTOFResponse.SetT0binMask(i,4); |
f858b00e | 526 | } |
527 | } | |
7eb68cb5 | 528 | else if(TMath::Abs(t0A) < t0cut){ |
f858b00e | 529 | for(Int_t i=0;i<fTOFResponse.GetNmomBins();i++){ |
7eb68cb5 | 530 | estimatedT0event[i]=t0A; |
531 | estimatedT0resolution[i]=resT0A; | |
d4d15b21 | 532 | fTOFResponse.SetT0binMask(i,2); |
f858b00e | 533 | } |
534 | } | |
535 | else{ | |
536 | for(Int_t i=0;i<fTOFResponse.GetNmomBins();i++){ | |
537 | estimatedT0event[i]=0.0; | |
538 | estimatedT0resolution[i]=t0spread; | |
d4d15b21 | 539 | fTOFResponse.SetT0binMask(i,0); |
f858b00e | 540 | } |
541 | } | |
542 | fTOFResponse.SetT0event(estimatedT0event); | |
543 | fTOFResponse.SetT0resolution(estimatedT0resolution); | |
544 | } | |
2f43a5ff | 545 | delete [] startTime; |
546 | delete [] startTimeRes; | |
d4d15b21 | 547 | delete [] startTimeMask; |
2f43a5ff | 548 | delete [] estimatedT0event; |
549 | delete [] estimatedT0resolution; | |
f858b00e | 550 | } |