]>
Commit | Line | Data |
---|---|---|
596a855f | 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 | **************************************************************************/ | |
0e46b9ae | 15 | |
16 | //--------------------------------------------------------------------// | |
17 | // // | |
18 | // AliTOFtracker Class // | |
19 | // Task: Perform association of the ESD tracks to TOF Clusters // | |
20 | // and Update ESD track with associated TOF Cluster parameters // | |
21 | // // | |
22 | // -- Authors : S. Arcelli, C. Zampolli (Bologna University and INFN) // | |
23 | // -- Contacts: Annalisa.De.Caro@cern.ch // | |
24 | // -- : Chiara.Zampolli@bo.infn.it // | |
25 | // -- : Silvia.Arcelli@bo.infn.it // | |
26 | // // | |
27 | //--------------------------------------------------------------------// | |
28 | ||
08048cd3 | 29 | #include <Rtypes.h> |
30 | #include <TROOT.h> | |
571dda3d | 31 | |
5c7c93fa | 32 | #include <TSeqCollection.h> |
08048cd3 | 33 | #include <TClonesArray.h> |
0841bd02 | 34 | #include <TObjArray.h> |
08048cd3 | 35 | #include <TGeoManager.h> |
36 | #include <TTree.h> | |
37 | #include <TFile.h> | |
38 | #include <TH2F.h> | |
571dda3d | 39 | |
5c7c93fa | 40 | #include "AliGeomManager.h" |
0e46b9ae | 41 | #include "AliESDtrack.h" |
af885e0f | 42 | #include "AliESDEvent.h" |
10d100d4 | 43 | #include "AliESDpid.h" |
d076c8d5 | 44 | #include "AliLog.h" |
0e46b9ae | 45 | #include "AliTrackPointArray.h" |
5c7c93fa | 46 | #include "AliCDBManager.h" |
596a855f | 47 | |
10d100d4 | 48 | //#include "AliTOFpidESD.h" |
e0ddb533 | 49 | #include "AliTOFRecoParam.h" |
3a646035 | 50 | #include "AliTOFReconstructor.h" |
571dda3d | 51 | #include "AliTOFcluster.h" |
ba66add8 | 52 | #include "AliTOFGeometry.h" |
571dda3d | 53 | #include "AliTOFtracker.h" |
0e46b9ae | 54 | #include "AliTOFtrack.h" |
571dda3d | 55 | |
0e46b9ae | 56 | extern TGeoManager *gGeoManager; |
d200609f | 57 | extern TROOT *gROOT; |
d4754572 | 58 | |
de60fa8a | 59 | |
596a855f | 60 | ClassImp(AliTOFtracker) |
61 | ||
74ea065c | 62 | //_____________________________________________________________________________ |
e0ddb533 | 63 | AliTOFtracker::AliTOFtracker(): |
f31a249f | 64 | fkRecoParam(0x0), |
e0ddb533 | 65 | fGeom(0x0), |
58d8d9a3 | 66 | fN(0), |
67 | fNseeds(0), | |
68 | fNseedsTOF(0), | |
69 | fngoodmatch(0), | |
70 | fnbadmatch(0), | |
71 | fnunmatch(0), | |
72 | fnmatch(0), | |
9d802709 | 73 | fTracks(new TClonesArray("AliTOFtrack")), |
de60fa8a | 74 | fSeeds(new TObjArray(100)), |
75 | fTOFtrackPoints(new TObjArray(10)), | |
5664c6ed | 76 | fHDigClusMap(0x0), |
77 | fHDigNClus(0x0), | |
78 | fHDigClusTime(0x0), | |
79 | fHDigClusToT(0x0), | |
80 | fHRecNClus(0x0), | |
81 | fHRecDist(0x0), | |
82 | fHRecSigYVsP(0x0), | |
83 | fHRecSigZVsP(0x0), | |
84 | fHRecSigYVsPWin(0x0), | |
85 | fHRecSigZVsPWin(0x0), | |
86 | fCalTree(0x0), | |
87 | fIch(-1), | |
88 | fToT(-1.), | |
89 | fTime(-1.), | |
90 | fExpTimePi(-1.), | |
91 | fExpTimeKa(-1.), | |
92 | fExpTimePr(-1.) | |
58d8d9a3 | 93 | { |
74ea065c | 94 | //AliTOFtracker main Ctor |
e0ddb533 | 95 | |
1d834a1e | 96 | for (Int_t ii=0; ii<kMaxCluster; ii++) fClusters[ii]=0x0; |
97 | ||
91219c0b | 98 | // Gettimg the geometry |
ba66add8 | 99 | fGeom= new AliTOFGeometry(); |
3a646035 | 100 | |
e0ddb533 | 101 | InitCheckHists(); |
3a646035 | 102 | |
7aeeaf38 | 103 | } |
5664c6ed | 104 | //_____________________________________________________________________________ |
105 | AliTOFtracker::~AliTOFtracker() { | |
106 | // | |
107 | // Dtor | |
108 | // | |
e0ddb533 | 109 | |
5664c6ed | 110 | SaveCheckHists(); |
e0ddb533 | 111 | |
5d456bcd | 112 | if(!(AliCDBManager::Instance()->GetCacheFlag())){ |
f31a249f | 113 | delete fkRecoParam; |
5d456bcd | 114 | } |
e0ddb533 | 115 | delete fGeom; |
5664c6ed | 116 | delete fHDigClusMap; |
117 | delete fHDigNClus; | |
118 | delete fHDigClusTime; | |
119 | delete fHDigClusToT; | |
120 | delete fHRecNClus; | |
121 | delete fHRecDist; | |
122 | delete fHRecSigYVsP; | |
123 | delete fHRecSigZVsP; | |
124 | delete fHRecSigYVsPWin; | |
125 | delete fHRecSigZVsPWin; | |
126 | delete fCalTree; | |
9d802709 | 127 | if (fTracks){ |
128 | fTracks->Delete(); | |
129 | delete fTracks; | |
130 | fTracks=0x0; | |
131 | } | |
132 | if (fSeeds){ | |
133 | fSeeds->Delete(); | |
134 | delete fSeeds; | |
135 | fSeeds=0x0; | |
136 | } | |
de60fa8a | 137 | if (fTOFtrackPoints){ |
138 | fTOFtrackPoints->Delete(); | |
139 | delete fTOFtrackPoints; | |
140 | fTOFtrackPoints=0x0; | |
141 | } | |
9d802709 | 142 | |
7e96dc55 | 143 | for (Int_t ii=0; ii<kMaxCluster; ii++) |
144 | if (fClusters[ii]) fClusters[ii]->Delete(); | |
1d834a1e | 145 | |
5664c6ed | 146 | } |
74ea065c | 147 | //_____________________________________________________________________________ |
10d100d4 | 148 | void AliTOFtracker::GetPidSettings(AliESDpid *esdPID) { |
149 | // | |
150 | // Sets TOF resolution from RecoParams | |
151 | // | |
f31a249f | 152 | if (fkRecoParam) |
153 | esdPID->GetTOFResponse().SetTimeResolution(fkRecoParam->GetTimeResolution()); | |
10d100d4 | 154 | else |
f31a249f | 155 | AliWarning("fkRecoParam not yet set; cannot set PID settings"); |
10d100d4 | 156 | } |
157 | //_____________________________________________________________________________ | |
f31a249f | 158 | Int_t AliTOFtracker::PropagateBack(AliESDEvent * const event) { |
74ea065c | 159 | // |
160 | // Gets seeds from ESD event and Match with TOF Clusters | |
161 | // | |
162 | ||
3a646035 | 163 | // initialize RecoParam for current event |
bafe290d | 164 | AliDebug(1,"Initializing params for TOF"); |
3a646035 | 165 | |
f31a249f | 166 | fkRecoParam = AliTOFReconstructor::GetRecoParam(); // instantiate reco param from STEER... |
90b234fe | 167 | |
f31a249f | 168 | if (fkRecoParam == 0x0) { |
3a646035 | 169 | AliFatal("No Reco Param found for TOF!!!"); |
170 | } | |
f31a249f | 171 | //fkRecoParam->Dump(); |
172 | //if(fkRecoParam->GetApplyPbPbCuts())fkRecoParam=fkRecoParam->GetPbPbparam(); | |
173 | //fkRecoParam->PrintParameters(); | |
174 | ||
74ea065c | 175 | //Initialise some counters |
176 | ||
177 | fNseeds=0; | |
178 | fNseedsTOF=0; | |
179 | fngoodmatch=0; | |
180 | fnbadmatch=0; | |
181 | fnunmatch=0; | |
182 | fnmatch=0; | |
183 | ||
184 | Int_t ntrk=event->GetNumberOfTracks(); | |
185 | fNseeds = ntrk; | |
74ea065c | 186 | |
187 | ||
188 | //Load ESD tracks into a local Array of ESD Seeds | |
0841bd02 | 189 | for (Int_t i=0; i<fNseeds; i++) |
190 | fSeeds->AddLast(event->GetTrack(i)); | |
74ea065c | 191 | |
192 | //Prepare ESD tracks candidates for TOF Matching | |
193 | CollectESD(); | |
194 | ||
195 | //First Step with Strict Matching Criterion | |
196 | MatchTracks(kFALSE); | |
197 | ||
198 | //Second Step with Looser Matching Criterion | |
199 | MatchTracks(kTRUE); | |
200 | ||
8a06b2a0 | 201 | AliInfo(Form("Number of matched tracks = %d (good = %d, bad = %d)",fnmatch,fngoodmatch,fnbadmatch)); |
74ea065c | 202 | |
203 | //Update the matched ESD tracks | |
204 | ||
205 | for (Int_t i=0; i<ntrk; i++) { | |
206 | AliESDtrack *t=event->GetTrack(i); | |
0841bd02 | 207 | AliESDtrack *seed =(AliESDtrack*)fSeeds->At(i); |
ff826920 | 208 | |
af61c656 | 209 | if ( (seed->GetStatus()&AliESDtrack::kTOFin)!=0 ) { |
210 | t->SetStatus(AliESDtrack::kTOFin); | |
211 | //if(seed->GetTOFsignal()>0){ | |
212 | if ( (seed->GetStatus()&AliESDtrack::kTOFout)!=0 ) { | |
213 | t->SetStatus(AliESDtrack::kTOFout); | |
214 | t->SetTOFsignal(seed->GetTOFsignal()); | |
215 | t->SetTOFcluster(seed->GetTOFcluster()); | |
216 | t->SetTOFsignalToT(seed->GetTOFsignalToT()); | |
217 | t->SetTOFsignalRaw(seed->GetTOFsignalRaw()); | |
218 | t->SetTOFsignalDz(seed->GetTOFsignalDz()); | |
46d7d82e | 219 | t->SetTOFsignalDx(seed->GetTOFsignalDx()); |
8b441e14 | 220 | t->SetTOFDeltaBC(seed->GetTOFDeltaBC()); |
221 | t->SetTOFL0L1(seed->GetTOFL0L1()); | |
af61c656 | 222 | t->SetTOFCalChannel(seed->GetTOFCalChannel()); |
223 | Int_t tlab[3]; seed->GetTOFLabel(tlab); | |
224 | t->SetTOFLabel(tlab); | |
225 | ||
0841bd02 | 226 | Double_t alphaA = (Double_t)t->GetAlpha(); |
227 | Double_t xA = (Double_t)t->GetX(); | |
228 | Double_t yA = (Double_t)t->GetY(); | |
229 | Double_t zA = (Double_t)t->GetZ(); | |
230 | Double_t p1A = (Double_t)t->GetSnp(); | |
231 | Double_t p2A = (Double_t)t->GetTgl(); | |
232 | Double_t p3A = (Double_t)t->GetSigned1Pt(); | |
233 | const Double_t *covA = (Double_t*)t->GetCovariance(); | |
e81ea7b6 | 234 | |
235 | // Make attention, please: | |
236 | // AliESDtrack::fTOFInfo array does not be stored in the AliESDs.root file | |
237 | // it is there only for a check during the reconstruction step. | |
238 | Float_t info[10]; seed->GetTOFInfo(info); | |
24322e5c | 239 | t->SetTOFInfo(info); |
e81ea7b6 | 240 | AliDebug(3,Form(" distance=%f; residual in the pad reference frame: dX=%f, dZ=%f", info[0],info[1],info[2])); |
241 | ||
242 | // Check done: | |
243 | // by calling the AliESDtrack::UpdateTrackParams, | |
244 | // the current track parameters are changed | |
245 | // and it could cause refit problems. | |
246 | // We need to update only the following track parameters: | |
247 | // the track length and expected times. | |
248 | // Removed AliESDtrack::UpdateTrackParams call | |
249 | // Called AliESDtrack::SetIntegratedTimes(...) and | |
250 | // AliESDtrack::SetIntegratedLength() routines. | |
251 | /* | |
252 | AliTOFtrack *track = new AliTOFtrack(*seed); | |
253 | t->UpdateTrackParams(track,AliESDtrack::kTOFout); // to be checked - AdC | |
254 | delete track; | |
255 | Double_t time[10]; t->GetIntegratedTimes(time); | |
256 | */ | |
257 | ||
258 | Double_t time[10]; seed->GetIntegratedTimes(time); | |
259 | t->SetIntegratedTimes(time); | |
260 | ||
261 | Double_t length = seed->GetIntegratedLength(); | |
262 | t->SetIntegratedLength(length); | |
263 | ||
0841bd02 | 264 | Double_t alphaB = (Double_t)t->GetAlpha(); |
265 | Double_t xB = (Double_t)t->GetX(); | |
266 | Double_t yB = (Double_t)t->GetY(); | |
267 | Double_t zB = (Double_t)t->GetZ(); | |
268 | Double_t p1B = (Double_t)t->GetSnp(); | |
269 | Double_t p2B = (Double_t)t->GetTgl(); | |
270 | Double_t p3B = (Double_t)t->GetSigned1Pt(); | |
271 | const Double_t *covB = (Double_t*)t->GetCovariance(); | |
e81ea7b6 | 272 | AliDebug(2,"Track params -now(before)-:"); |
273 | AliDebug(2,Form(" X: %f(%f), Y: %f(%f), Z: %f(%f) --- alpha: %f(%f)", | |
274 | xB,xA, | |
275 | yB,yA, | |
276 | zB,zA, | |
277 | alphaB,alphaA)); | |
278 | AliDebug(2,Form(" p1: %f(%f), p2: %f(%f), p3: %f(%f)", | |
279 | p1B,p1A, | |
280 | p2B,p2A, | |
281 | p3B,p3A)); | |
282 | AliDebug(2,Form(" cov1: %f(%f), cov2: %f(%f), cov3: %f(%f)" | |
283 | " cov4: %f(%f), cov5: %f(%f), cov6: %f(%f)" | |
284 | " cov7: %f(%f), cov8: %f(%f), cov9: %f(%f)" | |
285 | " cov10: %f(%f), cov11: %f(%f), cov12: %f(%f)" | |
286 | " cov13: %f(%f), cov14: %f(%f), cov15: %f(%f)", | |
287 | covB[0],covA[0], | |
288 | covB[1],covA[1], | |
289 | covB[2],covA[2], | |
290 | covB[3],covA[3], | |
291 | covB[4],covA[4], | |
292 | covB[5],covA[5], | |
293 | covB[6],covA[6], | |
294 | covB[7],covA[7], | |
295 | covB[8],covA[8], | |
296 | covB[9],covA[9], | |
297 | covB[10],covA[10], | |
298 | covB[11],covA[11], | |
299 | covB[12],covA[12], | |
300 | covB[13],covA[13], | |
301 | covB[14],covA[14] | |
302 | )); | |
303 | AliDebug(3,Form(" TOF params: %6d %f %f %f %f %f %6d %3d %f %f %f %f %f %f", | |
af61c656 | 304 | i, |
305 | t->GetTOFsignalRaw(), | |
306 | t->GetTOFsignal(), | |
307 | t->GetTOFsignalToT(), | |
308 | t->GetTOFsignalDz(), | |
46d7d82e | 309 | t->GetTOFsignalDx(), |
af61c656 | 310 | t->GetTOFCalChannel(), |
311 | t->GetTOFcluster(), | |
312 | t->GetIntegratedLength(), | |
313 | time[0], time[1], time[2], time[3], time[4] | |
314 | ) | |
315 | ); | |
316 | } | |
74ea065c | 317 | } |
318 | } | |
319 | ||
74ea065c | 320 | //Make TOF PID |
10d100d4 | 321 | // Now done in AliESDpid |
322 | // fPid->MakePID(event,timeZero); | |
74ea065c | 323 | |
de60fa8a | 324 | fSeeds->Clear(); |
1d834a1e | 325 | //fTracks->Delete(); |
326 | fTracks->Clear(); | |
74ea065c | 327 | return 0; |
328 | ||
329 | } | |
330 | //_________________________________________________________________________ | |
331 | void AliTOFtracker::CollectESD() { | |
332 | //prepare the set of ESD tracks to be matched to clusters in TOF | |
5478df1f | 333 | |
334 | Int_t seedsTOF1=0; | |
335 | Int_t seedsTOF2=0; | |
74ea065c | 336 | |
74ea065c | 337 | TClonesArray &aTOFTrack = *fTracks; |
338 | for (Int_t i=0; i<fNseeds; i++) { | |
339 | ||
0841bd02 | 340 | AliESDtrack *t =(AliESDtrack*)fSeeds->At(i); |
74ea065c | 341 | if ((t->GetStatus()&AliESDtrack::kTPCout)==0)continue; |
342 | ||
56da420e | 343 | AliTOFtrack *track = new AliTOFtrack(*t); // New |
af61c656 | 344 | Float_t x = (Float_t)track->GetX(); //New |
345 | ||
346 | // TRD 'good' tracks, already propagated at 371 cm | |
347 | if ( ( (t->GetStatus()&AliESDtrack::kTRDout)!=0 ) && | |
348 | ( x >= AliTOFGeometry::Rmin() ) ) { | |
349 | if ( track->PropagateToInnerTOF() ) { | |
350 | ||
351 | AliDebug(1,Form(" TRD propagated track till rho = %fcm." | |
352 | " And then the track has been propagated till rho = %fcm.", | |
353 | x, (Float_t)track->GetX())); | |
354 | ||
355 | track->SetSeedIndex(i); | |
356 | t->UpdateTrackParams(track,AliESDtrack::kTOFin); | |
357 | new(aTOFTrack[fNseedsTOF]) AliTOFtrack(*track); | |
358 | fNseedsTOF++; | |
359 | seedsTOF1++; | |
360 | } | |
74ea065c | 361 | delete track; |
362 | } | |
363 | ||
364 | // Propagate the rest of TPCbp | |
74ea065c | 365 | else { |
af61c656 | 366 | if ( track->PropagateToInnerTOF() ) { |
367 | ||
368 | AliDebug(1,Form(" TPC propagated track till rho = %fcm." | |
369 | " And then the track has been propagated till rho = %fcm.", | |
370 | x, (Float_t)track->GetX())); | |
371 | ||
74ea065c | 372 | track->SetSeedIndex(i); |
af61c656 | 373 | t->UpdateTrackParams(track,AliESDtrack::kTOFin); |
74ea065c | 374 | new(aTOFTrack[fNseedsTOF]) AliTOFtrack(*track); |
375 | fNseedsTOF++; | |
5478df1f | 376 | seedsTOF2++; |
74ea065c | 377 | } |
378 | delete track; | |
379 | } | |
380 | } | |
381 | ||
8a06b2a0 | 382 | AliInfo(Form("Number of TOF seeds = %d (Type 1 = %d, Type 2 = %d)",fNseedsTOF,seedsTOF1,seedsTOF2)); |
7b61cd9c | 383 | |
74ea065c | 384 | // Sort according uncertainties on track position |
385 | fTracks->Sort(); | |
386 | ||
387 | } | |
388 | //_________________________________________________________________________ | |
389 | void AliTOFtracker::MatchTracks( Bool_t mLastStep){ | |
390 | ||
e0ddb533 | 391 | |
392 | // Parameters used/regulating the reconstruction | |
393 | ||
394 | static Float_t corrLen=0.75; | |
395 | static Float_t detDepth=15.3; | |
d01bf4f4 | 396 | static Float_t padDepth=0.5; |
e0ddb533 | 397 | |
6819758a | 398 | const Float_t kSpeedOfLight= 2.99792458e-2; // speed of light [cm/ps] |
f2524833 | 399 | const Float_t kTimeOffset = 0.; // time offset for tracking algorithm [ps] |
6819758a | 400 | |
ba66add8 | 401 | Float_t dY=AliTOFGeometry::XPad(); |
402 | Float_t dZ=AliTOFGeometry::ZPad(); | |
e0ddb533 | 403 | |
f31a249f | 404 | Float_t sensRadius = fkRecoParam->GetSensRadius(); |
405 | Float_t stepSize = fkRecoParam->GetStepSize(); | |
406 | Float_t scaleFact = fkRecoParam->GetWindowScaleFact(); | |
407 | Float_t dyMax=fkRecoParam->GetWindowSizeMaxY(); | |
408 | Float_t dzMax=fkRecoParam->GetWindowSizeMaxZ(); | |
409 | Float_t dCut=fkRecoParam->GetDistanceCut(); | |
410 | Double_t maxChi2=fkRecoParam->GetMaxChi2TRD(); | |
411 | Bool_t timeWalkCorr = fkRecoParam->GetTimeWalkCorr(); | |
a838421b | 412 | if(!mLastStep){ |
413 | AliDebug(1,"++++++++++++++TOF Reconstruction Parameters:++++++++++++ \n"); | |
414 | AliDebug(1,Form("TOF sens radius: %f",sensRadius)); | |
415 | AliDebug(1,Form("TOF step size: %f",stepSize)); | |
416 | AliDebug(1,Form("TOF Window scale factor: %f",scaleFact)); | |
417 | AliDebug(1,Form("TOF Window max dy: %f",dyMax)); | |
418 | AliDebug(1,Form("TOF Window max dz: %f",dzMax)); | |
419 | AliDebug(1,Form("TOF distance Cut: %f",dCut)); | |
420 | AliDebug(1,Form("TOF Max Chi2: %f",maxChi2)); | |
421 | AliDebug(1,Form("Time Walk Correction? : %d",timeWalkCorr)); | |
422 | } | |
74ea065c | 423 | |
53884c34 | 424 | //Match ESD tracks to clusters in TOF |
a533f541 | 425 | |
e0ddb533 | 426 | // Get the number of propagation steps |
e0ddb533 | 427 | Int_t nSteps=(Int_t)(detDepth/stepSize); |
7bf28302 | 428 | |
429 | //PH Arrays (moved outside of the loop) | |
430 | Float_t * trackPos[4]; | |
431 | for (Int_t ii=0; ii<4; ii++) trackPos[ii] = new Float_t[nSteps]; | |
128563f6 | 432 | Int_t * clind = new Int_t[fN]; |
74ea065c | 433 | |
53884c34 | 434 | // Some init |
53884c34 | 435 | const Int_t kNclusterMax = 1000; // related to fN value |
de60fa8a | 436 | TGeoHMatrix global[kNclusterMax]; |
437 | ||
af61c656 | 438 | //The matching loop |
c0545837 | 439 | for (Int_t iseed=0; iseed<fNseedsTOF; iseed++) { |
74ea065c | 440 | |
de60fa8a | 441 | fTOFtrackPoints->Clear(); |
442 | ||
53884c34 | 443 | for (Int_t ii=0; ii<kNclusterMax; ii++) |
444 | global[ii] = 0x0; | |
c0545837 | 445 | AliTOFtrack *track =(AliTOFtrack*)fTracks->UncheckedAt(iseed); |
0841bd02 | 446 | AliESDtrack *t =(AliESDtrack*)fSeeds->At(track->GetSeedIndex()); |
af61c656 | 447 | //if ( t->GetTOFsignal()>0. ) continue; |
448 | if ( (t->GetStatus()&AliESDtrack::kTOFout)!=0 ) continue; | |
de60fa8a | 449 | AliTOFtrack *trackTOFin = new AliTOFtrack(*track); |
74ea065c | 450 | |
74ea065c | 451 | // Determine a window around the track |
74ea065c | 452 | Double_t x,par[5]; |
453 | trackTOFin->GetExternalParameters(x,par); | |
454 | Double_t cov[15]; | |
455 | trackTOFin->GetExternalCovariance(cov); | |
6c94f330 | 456 | |
53884c34 | 457 | if (cov[0]<0. || cov[2]<0.) { |
458 | AliWarning(Form("Very strange track (%d)! At least one of its covariance matrix diagonal elements is negative!",iseed)); | |
ecd795d8 | 459 | //delete trackTOFin; |
460 | //continue; | |
53884c34 | 461 | } |
462 | ||
74ea065c | 463 | Double_t dphi= |
e0ddb533 | 464 | scaleFact* |
ecd795d8 | 465 | ((5*TMath::Sqrt(TMath::Abs(cov[0])) + 0.5*dY + 2.5*TMath::Abs(par[2]))/sensRadius); |
74ea065c | 466 | Double_t dz= |
e0ddb533 | 467 | scaleFact* |
ecd795d8 | 468 | (5*TMath::Sqrt(TMath::Abs(cov[2])) + 0.5*dZ + 2.5*TMath::Abs(par[3])); |
6c94f330 | 469 | |
74ea065c | 470 | Double_t phi=TMath::ATan2(par[0],x) + trackTOFin->GetAlpha(); |
471 | if (phi<-TMath::Pi())phi+=2*TMath::Pi(); | |
472 | if (phi>=TMath::Pi())phi-=2*TMath::Pi(); | |
473 | Double_t z=par[1]; | |
474 | ||
c0545837 | 475 | //upper limit on window's size. |
de60fa8a | 476 | if (dz> dzMax) dz=dzMax; |
477 | if (dphi*sensRadius> dyMax) dphi=dyMax/sensRadius; | |
c0545837 | 478 | |
479 | ||
74ea065c | 480 | // find the clusters in the window of the track |
de60fa8a | 481 | Int_t nc=0; |
74ea065c | 482 | for (Int_t k=FindClusterIndex(z-dz); k<fN; k++) { |
7b61cd9c | 483 | |
53884c34 | 484 | if (nc>=kNclusterMax) { |
485 | AliWarning("No more matchable clusters can be stored! Please, increase the corresponding vectors size."); | |
486 | break; | |
487 | } | |
488 | ||
74ea065c | 489 | AliTOFcluster *c=fClusters[k]; |
490 | if (c->GetZ() > z+dz) break; | |
491 | if (c->IsUsed()) continue; | |
17149e6b | 492 | if (!c->GetStatus()) { |
53884c34 | 493 | AliDebug(1,"Cluster in channel declared bad!"); |
494 | continue; // skip bad channels as declared in OCDB | |
17149e6b | 495 | } |
7b61cd9c | 496 | |
74ea065c | 497 | Double_t dph=TMath::Abs(c->GetPhi()-phi); |
498 | if (dph>TMath::Pi()) dph-=2.*TMath::Pi(); | |
9b49e4c9 | 499 | if (TMath::Abs(dph)>dphi) continue; |
ba66add8 | 500 | |
6c94f330 | 501 | Double_t yc=(c->GetPhi() - trackTOFin->GetAlpha())*c->GetR(); |
502 | Double_t p[2]={yc, c->GetZ()}; | |
3c609b5c | 503 | Double_t cov2[3]= {dY*dY/12., 0., dZ*dZ/12.}; |
504 | if (trackTOFin->AliExternalTrackParam::GetPredictedChi2(p,cov2) > maxChi2)continue; | |
6c94f330 | 505 | |
128563f6 | 506 | clind[nc] = k; |
de40f9c1 | 507 | Char_t path[200]; |
c0545837 | 508 | Int_t ind[5]; |
128563f6 | 509 | ind[0]=c->GetDetInd(0); |
510 | ind[1]=c->GetDetInd(1); | |
511 | ind[2]=c->GetDetInd(2); | |
512 | ind[3]=c->GetDetInd(3); | |
513 | ind[4]=c->GetDetInd(4); | |
c0545837 | 514 | fGeom->GetVolumePath(ind,path); |
515 | gGeoManager->cd(path); | |
516 | global[nc] = *gGeoManager->GetCurrentMatrix(); | |
74ea065c | 517 | nc++; |
518 | } | |
519 | ||
53884c34 | 520 | AliDebug(1,Form(" Number of matchable TOF clusters for the track number %d: %d",iseed,nc)); |
521 | ||
74ea065c | 522 | //start fine propagation |
523 | ||
524 | Int_t nStepsDone = 0; | |
525 | for( Int_t istep=0; istep<nSteps; istep++){ | |
526 | ||
ba66add8 | 527 | Float_t xs=AliTOFGeometry::RinTOF()+istep*0.1; |
528 | Double_t ymax=xs*TMath::Tan(0.5*AliTOFGeometry::GetAlpha()); | |
74ea065c | 529 | |
530 | Bool_t skip=kFALSE; | |
531 | Double_t ysect=trackTOFin->GetYat(xs,skip); | |
6c94f330 | 532 | if (skip) break; |
74ea065c | 533 | if (ysect > ymax) { |
ba66add8 | 534 | if (!trackTOFin->Rotate(AliTOFGeometry::GetAlpha())) { |
74ea065c | 535 | break; |
536 | } | |
537 | } else if (ysect <-ymax) { | |
13c769b4 | 538 | if (!trackTOFin->Rotate(-AliTOFGeometry::GetAlpha())) { |
74ea065c | 539 | break; |
540 | } | |
541 | } | |
542 | ||
543 | if(!trackTOFin->PropagateTo(xs)) { | |
544 | break; | |
545 | } | |
546 | ||
547 | nStepsDone++; | |
548 | ||
549 | // store the running point (Globalrf) - fine propagation | |
550 | ||
6c94f330 | 551 | Double_t r[3]; |
552 | trackTOFin->GetXYZ(r); | |
553 | trackPos[0][istep]= (Float_t) r[0]; | |
554 | trackPos[1][istep]= (Float_t) r[1]; | |
555 | trackPos[2][istep]= (Float_t) r[2]; | |
74ea065c | 556 | trackPos[3][istep]= trackTOFin->GetIntegratedLength(); |
557 | } | |
558 | ||
559 | ||
560 | Int_t nfound = 0; | |
d01bf4f4 | 561 | Bool_t accept = kFALSE; |
6819758a | 562 | Bool_t isInside = kFALSE; |
74ea065c | 563 | for (Int_t istep=0; istep<nStepsDone; istep++) { |
564 | ||
53884c34 | 565 | Float_t ctrackPos[3]; |
ff826920 | 566 | ctrackPos[0] = trackPos[0][istep]; |
567 | ctrackPos[1] = trackPos[1][istep]; | |
568 | ctrackPos[2] = trackPos[2][istep]; | |
74ea065c | 569 | |
570 | //now see whether the track matches any of the TOF clusters | |
571 | ||
524da123 | 572 | Float_t dist3d[3]; |
ff826920 | 573 | accept = kFALSE; |
574 | for (Int_t i=0; i<nc; i++) { | |
8104fec9 | 575 | isInside = fGeom->IsInsideThePad((TGeoHMatrix*)(&global[i]),ctrackPos,dist3d); |
d01bf4f4 | 576 | |
6819758a | 577 | if ( mLastStep ) { |
578 | Float_t yLoc = dist3d[1]; | |
579 | Float_t rLoc = TMath::Sqrt(dist3d[0]*dist3d[0]+dist3d[2]*dist3d[2]); | |
580 | accept = (TMath::Abs(yLoc)<padDepth*0.5 && rLoc<dCut); | |
581 | AliDebug(2," I am in the case mLastStep==kTRUE "); | |
d01bf4f4 | 582 | } |
ff826920 | 583 | else { |
d01bf4f4 | 584 | accept = isInside; |
585 | } | |
ff826920 | 586 | if (accept) { |
6819758a | 587 | |
de60fa8a | 588 | fTOFtrackPoints->AddLast(new AliTOFtrackPoint(clind[i], |
589 | TMath::Sqrt(dist3d[0]*dist3d[0] + dist3d[1]*dist3d[1] + dist3d[2]*dist3d[2]), | |
590 | dist3d[2], dist3d[0], | |
591 | AliTOFGeometry::RinTOF()+istep*0.1,trackPos[3][istep])); | |
592 | ||
593 | AliDebug(2,Form(" dist3dLoc[0] = %f, dist3dLoc[1] = %f, dist3dLoc[2] = %f ",dist3d[0],dist3d[1],dist3d[2])); | |
74ea065c | 594 | nfound++; |
d01bf4f4 | 595 | if(accept &&!mLastStep)break; |
74ea065c | 596 | }//end if accept |
524da123 | 597 | |
74ea065c | 598 | } //end for on the clusters |
d01bf4f4 | 599 | if(accept &&!mLastStep)break; |
74ea065c | 600 | } //end for on the steps |
601 | ||
53884c34 | 602 | AliDebug(1,Form(" Number of track points for the track number %d: %d",iseed,nfound)); |
9b49e4c9 | 603 | |
604 | ||
74ea065c | 605 | if (nfound == 0 ) { |
606 | fnunmatch++; | |
7bf28302 | 607 | delete trackTOFin; |
74ea065c | 608 | continue; |
609 | } | |
610 | ||
611 | fnmatch++; | |
612 | ||
613 | // now choose the cluster to be matched with the track. | |
614 | ||
90b234fe | 615 | Int_t idclus=-1; |
74ea065c | 616 | Float_t recL = 0.; |
617 | Float_t xpos=0.; | |
618 | Float_t mindist=1000.; | |
e0ddb533 | 619 | Float_t mindistZ=0.; |
24322e5c | 620 | Float_t mindistY=0.; |
74ea065c | 621 | for (Int_t iclus= 0; iclus<nfound;iclus++){ |
de60fa8a | 622 | AliTOFtrackPoint *matchableTOFcluster = (AliTOFtrackPoint*)fTOFtrackPoints->At(iclus); |
623 | if (matchableTOFcluster->Distance()<mindist) { | |
624 | mindist = matchableTOFcluster->Distance(); | |
625 | mindistZ = matchableTOFcluster->DistanceZ(); // Z distance in the | |
626 | // RF of the hit pad | |
627 | // closest to the | |
628 | // reconstructed | |
629 | // track | |
630 | mindistY = matchableTOFcluster->DistanceY(); // Y distance in the | |
631 | // RF of the hit pad | |
632 | // closest to the | |
633 | // reconstructed | |
634 | // track | |
635 | xpos = matchableTOFcluster->PropRadius(); | |
636 | idclus = matchableTOFcluster->Index(); | |
637 | recL = matchableTOFcluster->Length() + corrLen*0.5; | |
74ea065c | 638 | } |
de60fa8a | 639 | } // loop on found TOF track points |
74ea065c | 640 | |
1d834a1e | 641 | if (idclus==-1) { |
642 | AliDebug(1,Form("Reconstructed track %d doesn't match any TOF cluster", iseed)); | |
643 | delete trackTOFin; | |
644 | continue; | |
645 | } | |
d01bf4f4 | 646 | |
74ea065c | 647 | AliTOFcluster *c=fClusters[idclus]; |
de60fa8a | 648 | |
6819758a | 649 | AliDebug(2, Form("%7d %7d %10d %10d %10d %10d %7d", |
32ead898 | 650 | iseed, |
3a646035 | 651 | fnmatch-1, |
32ead898 | 652 | TMath::Abs(trackTOFin->GetLabel()), |
653 | c->GetLabel(0), c->GetLabel(1), c->GetLabel(2), | |
654 | idclus)); // AdC | |
655 | ||
e0ddb533 | 656 | c->Use(); |
74ea065c | 657 | |
658 | // Track length correction for matching Step 2 | |
659 | ||
de60fa8a | 660 | if (mLastStep) { |
661 | Float_t rc = TMath::Sqrt(c->GetR()*c->GetR() + c->GetZ()*c->GetZ()); | |
662 | Float_t rt = TMath::Sqrt(trackPos[0][70]*trackPos[0][70] | |
663 | +trackPos[1][70]*trackPos[1][70] | |
664 | +trackPos[2][70]*trackPos[2][70]); | |
665 | Float_t dlt=rc-rt; | |
74ea065c | 666 | recL=trackPos[3][70]+dlt; |
de60fa8a | 667 | } |
74ea065c | 668 | |
669 | if ( | |
670 | (c->GetLabel(0)==TMath::Abs(trackTOFin->GetLabel())) | |
671 | || | |
672 | (c->GetLabel(1)==TMath::Abs(trackTOFin->GetLabel())) | |
673 | || | |
674 | (c->GetLabel(2)==TMath::Abs(trackTOFin->GetLabel())) | |
675 | ) { | |
676 | fngoodmatch++; | |
d3c7bfac | 677 | |
6819758a | 678 | AliDebug(2,Form(" track label good %5d",trackTOFin->GetLabel())); |
d3c7bfac | 679 | |
74ea065c | 680 | } |
53884c34 | 681 | else { |
74ea065c | 682 | fnbadmatch++; |
d3c7bfac | 683 | |
6819758a | 684 | AliDebug(2,Form(" track label bad %5d",trackTOFin->GetLabel())); |
d3c7bfac | 685 | |
74ea065c | 686 | } |
687 | ||
688 | delete trackTOFin; | |
689 | ||
a533f541 | 690 | // Store quantities to be used in the TOF Calibration |
ba66add8 | 691 | Float_t tToT=AliTOFGeometry::ToTBinWidth()*c->GetToT()*1E-3; // in ns |
7aeeaf38 | 692 | t->SetTOFsignalToT(tToT); |
6819758a | 693 | Float_t rawTime=AliTOFGeometry::TdcBinWidth()*c->GetTDCRAW()+kTimeOffset; // RAW time,in ps |
d321691a | 694 | t->SetTOFsignalRaw(rawTime); |
695 | t->SetTOFsignalDz(mindistZ); | |
46d7d82e | 696 | t->SetTOFsignalDx(mindistY); |
8b441e14 | 697 | t->SetTOFDeltaBC(c->GetDeltaBC()); |
698 | t->SetTOFL0L1(c->GetL0L1Latency()); | |
6819758a | 699 | |
24322e5c | 700 | Float_t info[10] = {mindist,mindistY,mindistZ, |
701 | 0.,0.,0.,0.,0.,0.,0.}; | |
702 | t->SetTOFInfo(info); | |
703 | AliDebug(2,Form(" distance=%f; residual in the pad reference frame: dX=%f, dZ=%f", info[0],info[1],info[2])); | |
704 | ||
705 | ||
a533f541 | 706 | Int_t ind[5]; |
707 | ind[0]=c->GetDetInd(0); | |
708 | ind[1]=c->GetDetInd(1); | |
709 | ind[2]=c->GetDetInd(2); | |
710 | ind[3]=c->GetDetInd(3); | |
711 | ind[4]=c->GetDetInd(4); | |
ba66add8 | 712 | Int_t calindex = AliTOFGeometry::GetIndex(ind); |
a533f541 | 713 | t->SetTOFCalChannel(calindex); |
11c7ff68 | 714 | |
715 | // keep track of the track labels in the matched cluster | |
716 | Int_t tlab[3]; | |
717 | tlab[0]=c->GetLabel(0); | |
718 | tlab[1]=c->GetLabel(1); | |
719 | tlab[2]=c->GetLabel(2); | |
6819758a | 720 | AliDebug(2,Form(" tdc time of the matched track %6d = ",c->GetTDC())); |
721 | Double_t tof=AliTOFGeometry::TdcBinWidth()*c->GetTDC()+kTimeOffset; // in ps | |
5478df1f | 722 | AliDebug(2,Form(" tof time of the matched track: %f = ",tof)); |
5478df1f | 723 | Double_t tofcorr=tof; |
724 | if(timeWalkCorr)tofcorr=CorrectTimeWalk(mindistZ,tof); | |
725 | AliDebug(2,Form(" tof time of the matched track, after TW corr: %f = ",tofcorr)); | |
726 | //Set TOF time signal and pointer to the matched cluster | |
727 | t->SetTOFsignal(tofcorr); | |
ee77ad87 | 728 | t->SetTOFcluster(idclus); // pointing to the recPoints tree |
5478df1f | 729 | |
6819758a | 730 | AliDebug(2,Form(" Setting TOF raw time: %f, z distance: %f corrected time: %f ",rawTime,mindistZ,tofcorr)); |
731 | ||
5478df1f | 732 | //Tracking info |
6819758a | 733 | Double_t time[AliPID::kSPECIES]; t->GetIntegratedTimes(time); // in ps |
74ea065c | 734 | Double_t mom=t->GetP(); |
53884c34 | 735 | AliDebug(2,Form(" Momentum for track %d -> %f", iseed,mom)); |
736 | for (Int_t j=0;j<AliPID::kSPECIES;j++) { | |
304864ab | 737 | Double_t mass=AliPID::ParticleMass(j); |
6819758a | 738 | time[j]+=(recL-trackPos[3][0])/kSpeedOfLight*TMath::Sqrt(mom*mom+mass*mass)/mom; |
74ea065c | 739 | } |
740 | ||
741 | AliTOFtrack *trackTOFout = new AliTOFtrack(*t); | |
742 | trackTOFout->PropagateTo(xpos); | |
77a9ea9a | 743 | |
744 | // Fill the track residual histograms. | |
745 | FillResiduals(trackTOFout,c,kFALSE); | |
746 | ||
af61c656 | 747 | t->UpdateTrackParams(trackTOFout,AliESDtrack::kTOFout); |
74ea065c | 748 | t->SetIntegratedLength(recL); |
749 | t->SetIntegratedTimes(time); | |
11c7ff68 | 750 | t->SetTOFLabel(tlab); |
5478df1f | 751 | |
752 | ||
5664c6ed | 753 | // Fill Reco-QA histos for Reconstruction |
754 | fHRecNClus->Fill(nc); | |
755 | fHRecDist->Fill(mindist); | |
38c767fa | 756 | if (cov[0]>=0.) |
757 | fHRecSigYVsP->Fill(mom,TMath::Sqrt(cov[0])); | |
758 | else | |
57bd70af | 759 | fHRecSigYVsP->Fill(mom,-TMath::Sqrt(-cov[0])); |
38c767fa | 760 | if (cov[2]>=0.) |
761 | fHRecSigZVsP->Fill(mom,TMath::Sqrt(cov[2])); | |
762 | else | |
57bd70af | 763 | fHRecSigZVsP->Fill(mom,-TMath::Sqrt(-cov[2])); |
e0ddb533 | 764 | fHRecSigYVsPWin->Fill(mom,dphi*sensRadius); |
5664c6ed | 765 | fHRecSigZVsPWin->Fill(mom,dz); |
766 | ||
767 | // Fill Tree for on-the-fly offline Calibration | |
768 | ||
53884c34 | 769 | if ( !((t->GetStatus() & AliESDtrack::kTIME)==0 ) ) { |
5664c6ed | 770 | fIch=calindex; |
771 | fToT=tToT; | |
5478df1f | 772 | fTime=rawTime; |
5664c6ed | 773 | fExpTimePi=time[2]; |
774 | fExpTimeKa=time[3]; | |
775 | fExpTimePr=time[4]; | |
776 | fCalTree->Fill(); | |
777 | } | |
74ea065c | 778 | delete trackTOFout; |
779 | } | |
de60fa8a | 780 | |
7bf28302 | 781 | for (Int_t ii=0; ii<4; ii++) delete [] trackPos[ii]; |
128563f6 | 782 | delete [] clind; |
ba66add8 | 783 | |
74ea065c | 784 | } |
785 | //_________________________________________________________________________ | |
7b61cd9c | 786 | Int_t AliTOFtracker::LoadClusters(TTree *cTree) { |
74ea065c | 787 | //-------------------------------------------------------------------- |
788 | //This function loads the TOF clusters | |
789 | //-------------------------------------------------------------------- | |
790 | ||
ba66add8 | 791 | Int_t npadX = AliTOFGeometry::NpadX(); |
792 | Int_t npadZ = AliTOFGeometry::NpadZ(); | |
793 | Int_t nStripA = AliTOFGeometry::NStripA(); | |
794 | Int_t nStripB = AliTOFGeometry::NStripB(); | |
795 | Int_t nStripC = AliTOFGeometry::NStripC(); | |
5664c6ed | 796 | |
7b61cd9c | 797 | TBranch *branch=cTree->GetBranch("TOF"); |
74ea065c | 798 | if (!branch) { |
7b61cd9c | 799 | AliError("can't get the branch with the TOF clusters !"); |
74ea065c | 800 | return 1; |
801 | } | |
802 | ||
9d802709 | 803 | static TClonesArray dummy("AliTOFcluster",10000); |
804 | dummy.Clear(); | |
805 | TClonesArray *clusters=&dummy; | |
7b61cd9c | 806 | branch->SetAddress(&clusters); |
74ea065c | 807 | |
7b61cd9c | 808 | cTree->GetEvent(0); |
809 | Int_t nc=clusters->GetEntriesFast(); | |
5664c6ed | 810 | fHDigNClus->Fill(nc); |
811 | ||
7b61cd9c | 812 | AliInfo(Form("Number of clusters: %d",nc)); |
74ea065c | 813 | |
7b61cd9c | 814 | for (Int_t i=0; i<nc; i++) { |
815 | AliTOFcluster *c=(AliTOFcluster*)clusters->UncheckedAt(i); | |
16a2e36a | 816 | //PH fClusters[i]=new AliTOFcluster(*c); fN++; |
817 | fClusters[i]=c; fN++; | |
5664c6ed | 818 | |
819 | // Fill Digits QA histos | |
820 | ||
821 | Int_t isector = c->GetDetInd(0); | |
822 | Int_t iplate = c->GetDetInd(1); | |
823 | Int_t istrip = c->GetDetInd(2); | |
824 | Int_t ipadX = c->GetDetInd(4); | |
825 | Int_t ipadZ = c->GetDetInd(3); | |
826 | ||
ba66add8 | 827 | Float_t time =(AliTOFGeometry::TdcBinWidth()*c->GetTDC())*1E-3; // in ns |
828 | Float_t tot = (AliTOFGeometry::TdcBinWidth()*c->GetToT())*1E-3;//in ns | |
5664c6ed | 829 | |
830 | Int_t stripOffset = 0; | |
831 | switch (iplate) { | |
832 | case 0: | |
833 | stripOffset = 0; | |
834 | break; | |
835 | case 1: | |
836 | stripOffset = nStripC; | |
837 | break; | |
838 | case 2: | |
839 | stripOffset = nStripC+nStripB; | |
840 | break; | |
841 | case 3: | |
842 | stripOffset = nStripC+nStripB+nStripA; | |
843 | break; | |
844 | case 4: | |
845 | stripOffset = nStripC+nStripB+nStripA+nStripB; | |
846 | break; | |
847 | default: | |
848 | AliError(Form("Wrong plate number in TOF (%d) !",iplate)); | |
849 | break; | |
850 | }; | |
851 | Int_t zindex=npadZ*(istrip+stripOffset)+(ipadZ+1); | |
852 | Int_t phiindex=npadX*isector+ipadX+1; | |
853 | fHDigClusMap->Fill(zindex,phiindex); | |
854 | fHDigClusTime->Fill(time); | |
855 | fHDigClusToT->Fill(tot); | |
856 | ||
7b61cd9c | 857 | } |
74ea065c | 858 | |
74ea065c | 859 | |
860 | return 0; | |
861 | } | |
862 | //_________________________________________________________________________ | |
863 | void AliTOFtracker::UnloadClusters() { | |
864 | //-------------------------------------------------------------------- | |
865 | //This function unloads TOF clusters | |
866 | //-------------------------------------------------------------------- | |
7b61cd9c | 867 | for (Int_t i=0; i<fN; i++) { |
16a2e36a | 868 | //PH delete fClusters[i]; |
7b61cd9c | 869 | fClusters[i] = 0x0; |
74ea065c | 870 | } |
7b61cd9c | 871 | fN=0; |
74ea065c | 872 | } |
873 | ||
874 | //_________________________________________________________________________ | |
875 | Int_t AliTOFtracker::FindClusterIndex(Double_t z) const { | |
876 | //-------------------------------------------------------------------- | |
877 | // This function returns the index of the nearest cluster | |
878 | //-------------------------------------------------------------------- | |
879 | if (fN==0) return 0; | |
880 | if (z <= fClusters[0]->GetZ()) return 0; | |
881 | if (z > fClusters[fN-1]->GetZ()) return fN; | |
882 | Int_t b=0, e=fN-1, m=(b+e)/2; | |
883 | for (; b<e; m=(b+e)/2) { | |
884 | if (z > fClusters[m]->GetZ()) b=m+1; | |
885 | else e=m; | |
886 | } | |
887 | return m; | |
888 | } | |
d4754572 | 889 | |
890 | //_________________________________________________________________________ | |
891 | Bool_t AliTOFtracker::GetTrackPoint(Int_t index, AliTrackPoint& p) const | |
892 | { | |
893 | // Get track space point with index i | |
894 | // Coordinates are in the global system | |
895 | AliTOFcluster *cl = fClusters[index]; | |
896 | Float_t xyz[3]; | |
897 | xyz[0] = cl->GetR()*TMath::Cos(cl->GetPhi()); | |
898 | xyz[1] = cl->GetR()*TMath::Sin(cl->GetPhi()); | |
899 | xyz[2] = cl->GetZ(); | |
468f26c6 | 900 | Float_t phiangle = (Int_t(cl->GetPhi()*TMath::RadToDeg()/20.)+0.5)*20.*TMath::DegToRad(); |
901 | Float_t sinphi = TMath::Sin(phiangle), cosphi = TMath::Cos(phiangle); | |
ba66add8 | 902 | Float_t tiltangle = AliTOFGeometry::GetAngles(cl->GetDetInd(1),cl->GetDetInd(2))*TMath::DegToRad(); |
468f26c6 | 903 | Float_t sinth = TMath::Sin(tiltangle), costh = TMath::Cos(tiltangle); |
ba66add8 | 904 | Float_t sigmay2 = AliTOFGeometry::XPad()*AliTOFGeometry::XPad()/12.; |
905 | Float_t sigmaz2 = AliTOFGeometry::ZPad()*AliTOFGeometry::ZPad()/12.; | |
468f26c6 | 906 | Float_t cov[6]; |
907 | cov[0] = sinphi*sinphi*sigmay2 + cosphi*cosphi*sinth*sinth*sigmaz2; | |
908 | cov[1] = -sinphi*cosphi*sigmay2 + sinphi*cosphi*sinth*sinth*sigmaz2; | |
909 | cov[2] = -cosphi*sinth*costh*sigmaz2; | |
910 | cov[3] = cosphi*cosphi*sigmay2 + sinphi*sinphi*sinth*sinth*sigmaz2; | |
911 | cov[4] = -sinphi*sinth*costh*sigmaz2; | |
912 | cov[5] = costh*costh*sigmaz2; | |
913 | p.SetXYZ(xyz[0],xyz[1],xyz[2],cov); | |
d4754572 | 914 | |
915 | // Detector numbering scheme | |
ba66add8 | 916 | Int_t nSector = AliTOFGeometry::NSectors(); |
917 | Int_t nPlate = AliTOFGeometry::NPlates(); | |
918 | Int_t nStripA = AliTOFGeometry::NStripA(); | |
919 | Int_t nStripB = AliTOFGeometry::NStripB(); | |
920 | Int_t nStripC = AliTOFGeometry::NStripC(); | |
d4754572 | 921 | |
922 | Int_t isector = cl->GetDetInd(0); | |
923 | if (isector >= nSector) | |
924 | AliError(Form("Wrong sector number in TOF (%d) !",isector)); | |
925 | Int_t iplate = cl->GetDetInd(1); | |
926 | if (iplate >= nPlate) | |
927 | AliError(Form("Wrong plate number in TOF (%d) !",iplate)); | |
928 | Int_t istrip = cl->GetDetInd(2); | |
929 | ||
930 | Int_t stripOffset = 0; | |
931 | switch (iplate) { | |
932 | case 0: | |
933 | stripOffset = 0; | |
934 | break; | |
935 | case 1: | |
936 | stripOffset = nStripC; | |
937 | break; | |
938 | case 2: | |
939 | stripOffset = nStripC+nStripB; | |
940 | break; | |
941 | case 3: | |
942 | stripOffset = nStripC+nStripB+nStripA; | |
943 | break; | |
944 | case 4: | |
945 | stripOffset = nStripC+nStripB+nStripA+nStripB; | |
946 | break; | |
947 | default: | |
948 | AliError(Form("Wrong plate number in TOF (%d) !",iplate)); | |
949 | break; | |
950 | }; | |
951 | ||
952 | Int_t idet = (2*(nStripC+nStripB)+nStripA)*isector + | |
953 | stripOffset + | |
954 | istrip; | |
ae079791 | 955 | UShort_t volid = AliGeomManager::LayerToVolUID(AliGeomManager::kTOF,idet); |
d4754572 | 956 | p.SetVolumeID((UShort_t)volid); |
957 | return kTRUE; | |
958 | } | |
5664c6ed | 959 | //_________________________________________________________________________ |
960 | void AliTOFtracker::InitCheckHists() { | |
961 | ||
962 | //Init histos for Digits/Reco QA and Calibration | |
963 | ||
964 | ||
0366f10f | 965 | TDirectory *dir = gDirectory; |
966 | TFile *logFileTOF = 0; | |
967 | ||
968 | TSeqCollection *list = gROOT->GetListOfFiles(); | |
969 | int n = list->GetEntries(); | |
970 | Bool_t isThere=kFALSE; | |
971 | for(int i=0; i<n; i++) { | |
972 | logFileTOF = (TFile*)list->At(i); | |
973 | if (strstr(logFileTOF->GetName(), "TOFQA.root")){ | |
974 | isThere=kTRUE; | |
975 | break; | |
976 | } | |
977 | } | |
978 | ||
979 | if(!isThere)logFileTOF = new TFile( "TOFQA.root","RECREATE"); | |
980 | logFileTOF->cd(); | |
981 | ||
5664c6ed | 982 | fCalTree = new TTree("CalTree", "Tree for TOF calibration"); |
983 | fCalTree->Branch("TOFchannelindex",&fIch,"iTOFch/I"); | |
984 | fCalTree->Branch("ToT",&fToT,"TOFToT/F"); | |
985 | fCalTree->Branch("TOFtime",&fTime,"TOFtime/F"); | |
986 | fCalTree->Branch("PionExpTime",&fExpTimePi,"PiExpTime/F"); | |
987 | fCalTree->Branch("KaonExpTime",&fExpTimeKa,"KaExpTime/F"); | |
988 | fCalTree->Branch("ProtonExpTime",&fExpTimePr,"PrExpTime/F"); | |
989 | ||
990 | //Digits "QA" | |
991 | fHDigClusMap = new TH2F("TOFDig_ClusMap", "",182,0.5,182.5,864, 0.5,864.5); | |
992 | fHDigNClus = new TH1F("TOFDig_NClus", "",200,0.5,200.5); | |
993 | fHDigClusTime = new TH1F("TOFDig_ClusTime", "",2000,0.,200.); | |
994 | fHDigClusToT = new TH1F("TOFDig_ClusToT", "",500,0.,100); | |
995 | ||
996 | //Reco "QA" | |
997 | fHRecNClus =new TH1F("TOFRec_NClusW", "",50,0.5,50.5); | |
998 | fHRecDist=new TH1F("TOFRec_Dist", "",50,0.5,10.5); | |
999 | fHRecSigYVsP=new TH2F("TOFDig_SigYVsP", "",40,0.,4.,100, 0.,5.); | |
1000 | fHRecSigZVsP=new TH2F("TOFDig_SigZVsP", "",40,0.,4.,100, 0.,5.); | |
1001 | fHRecSigYVsPWin=new TH2F("TOFDig_SigYVsPWin", "",40,0.,4.,100, 0.,50.); | |
1002 | fHRecSigZVsPWin=new TH2F("TOFDig_SigZVsPWin", "",40,0.,4.,100, 0.,50.); | |
0366f10f | 1003 | |
1004 | dir->cd(); | |
1005 | ||
5664c6ed | 1006 | } |
1007 | ||
1008 | //_________________________________________________________________________ | |
1009 | void AliTOFtracker::SaveCheckHists() { | |
1010 | ||
1011 | //write histos for Digits/Reco QA and Calibration | |
1012 | ||
1013 | TDirectory *dir = gDirectory; | |
5664c6ed | 1014 | TFile *logFileTOF = 0; |
1015 | ||
1016 | TSeqCollection *list = gROOT->GetListOfFiles(); | |
d200609f | 1017 | int n = list->GetEntries(); |
5664c6ed | 1018 | Bool_t isThere=kFALSE; |
d200609f | 1019 | for(int i=0; i<n; i++) { |
5664c6ed | 1020 | logFileTOF = (TFile*)list->At(i); |
1021 | if (strstr(logFileTOF->GetName(), "TOFQA.root")){ | |
1022 | isThere=kTRUE; | |
1023 | break; | |
1024 | } | |
1025 | } | |
1026 | ||
0366f10f | 1027 | if(!isThere) { |
1028 | AliError(Form("File TOFQA.root not found!! not wring histograms....")); | |
1029 | return; | |
1030 | } | |
5664c6ed | 1031 | logFileTOF->cd(); |
1032 | fHDigClusMap->Write(fHDigClusMap->GetName(), TObject::kOverwrite); | |
1033 | fHDigNClus->Write(fHDigNClus->GetName(), TObject::kOverwrite); | |
1034 | fHDigClusTime->Write(fHDigClusTime->GetName(), TObject::kOverwrite); | |
1035 | fHDigClusToT->Write(fHDigClusToT->GetName(), TObject::kOverwrite); | |
1036 | fHRecNClus->Write(fHRecNClus->GetName(), TObject::kOverwrite); | |
1037 | fHRecDist->Write(fHRecDist->GetName(), TObject::kOverwrite); | |
1038 | fHRecSigYVsP->Write(fHRecSigYVsP->GetName(), TObject::kOverwrite); | |
1039 | fHRecSigZVsP->Write(fHRecSigZVsP->GetName(), TObject::kOverwrite); | |
1040 | fHRecSigYVsPWin->Write(fHRecSigYVsPWin->GetName(), TObject::kOverwrite); | |
1041 | fHRecSigZVsPWin->Write(fHRecSigZVsPWin->GetName(), TObject::kOverwrite); | |
1042 | fCalTree->Write(fCalTree->GetName(),TObject::kOverwrite); | |
1043 | logFileTOF->Flush(); | |
1044 | ||
1045 | dir->cd(); | |
1046 | } | |
e0ddb533 | 1047 | //_________________________________________________________________________ |
f31a249f | 1048 | Float_t AliTOFtracker::CorrectTimeWalk( Float_t dist, Float_t tof) const { |
e0ddb533 | 1049 | |
1050 | //dummy, for the moment | |
1051 | Float_t tofcorr=0.; | |
ba66add8 | 1052 | if(dist<AliTOFGeometry::ZPad()*0.5){ |
e0ddb533 | 1053 | tofcorr=tof; |
1054 | //place here the actual correction | |
1055 | }else{ | |
1056 | tofcorr=tof; | |
1057 | } | |
1058 | return tofcorr; | |
1059 | } | |
1060 | //_________________________________________________________________________ | |
128563f6 | 1061 | |
1062 | void AliTOFtracker::FillClusterArray(TObjArray* arr) const | |
1063 | { | |
1064 | // | |
1065 | // Returns the TOF cluster array | |
1066 | // | |
1067 | ||
1068 | if (fN==0) | |
1069 | arr = 0x0; | |
1070 | else | |
1071 | for (Int_t i=0; i<fN; ++i) arr->Add(fClusters[i]); | |
1072 | ||
1073 | } | |
ff826920 | 1074 | //_________________________________________________________________________ |
1075 |