]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TOF/AliTOFClusterFinder.cxx
Included the digits(raw data) which tot measurement is not available
[u/mrichter/AliRoot.git] / TOF / AliTOFClusterFinder.cxx
CommitLineData
d08a92dd 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
16/*
7fffa85b 17$Log: AliTOFClusterFinder.cxx,v $
18Revision 1.31 2007/11/24 14:53:19 zampolli
19Status flag implemented as UChar_t
20
98f5acd7 21Revision 1.30 2007/10/04 13:08:52 arcelli
22updates to comply with AliTOFGeometryV5 becoming AliTOFGeometry
23
ba66add8 24Revision 1.29 2007/10/03 10:42:33 arcelli
25updates to handle new AliTOFcluster, inheriting form AliCluster3D
26
ac359ffe 27Revision 1.28 2007/05/31 16:06:05 arcelli
28move instance of AliRawStream outside loop on DDL
29
ef58b2af 30Revision 1.27 2007/05/02 16:31:49 arcelli
c3891b7a 31Add methods to handle single event reconstruction. retrieval of Calib
32info moved to AliTOFReconstructor ctor, and passed via a pointer to
33AliTOFcalib
ef58b2af 34
94f5f8f2 35Revision 1.26 2007/04/30 19:02:24 arcelli
36hopefully the last refinements for correct type conversion in calibration
37
a33fec85 38Revision 1.25 2007/04/30 15:22:17 arcelli
39Change TOF digit Time, Tot etc to int type
40
bf33f8f0 41Revision 1.24 2007/04/27 11:19:31 arcelli
42updates for the new decoder
43
7813bb1a 44Revision 1.23 2007/04/23 16:51:39 decaro
c3891b7a 45Digits-to-raw_data conversion: correction for a more real description
46(A.De Caro, R.Preghenella)
7813bb1a 47
515faf5d 48Revision 1.22 2007/04/19 17:26:32 arcelli
49Fix a bug (add some debug printout
50
0451c2e6 51Revision 1.21 2007/04/18 17:28:12 arcelli
52Set the ToT bin width to the one actually used...
53
605370db 54Revision 1.20 2007/03/09 09:57:23 arcelli
55 Remove a forgotten include of Riostrem
56
c77771e2 57Revision 1.19 2007/03/08 15:41:20 arcelli
58set uncorrected times when filling RecPoints
59
3432ebfa 60Revision 1.18 2007/03/06 16:31:20 arcelli
61Add Uncorrected TOF Time signal
62
aa5476d8 63Revision 1.17 2007/02/28 18:09:11 arcelli
c3891b7a 64Add protection against failed retrieval of the CDB cal object,
65now Reconstruction exits with AliFatal
aa5476d8 66
a1cab04c 67Revision 1.16 2007/02/20 15:57:00 decaro
68Raw data update: to read the TOF raw data defined in UNPACKED mode
69
d08a92dd 70
71Revision 0.03 2005/07/28 A. De Caro
72 Implement public method
73 Raw2Digits(Int_t, AliRawReader *)
74 to convert digits from raw data in MC digits
75 (temporary solution)
76
77Revision 0.02 2005/07/27 A. De Caro
78 Implement public method
79 Digits2RecPoint(Int_t)
80 to convert digits in clusters
81
82Revision 0.02 2005/07/26 A. De Caro
83 Implement private methods
84 InsertCluster(AliTOFcluster *)
85 FindClusterIndex(Double_t)
86 originally implemented in AliTOFtracker
87 by S. Arcelli and C. Zampolli
88
89Revision 0.01 2005/07/25 A. De Caro
90 Implement public methods
91 Digits2RecPoint(AliRawReader *, TTree *)
92 Digits2RecPoint(Int_t, AliRawReader *)
93 to convert raw data in clusters
94 */
95
96////////////////////////////////////////////////////////////////
97// //
98// Class for TOF cluster finder //
99// //
100// Starting from Raw Data, create rec points, //
101// fill TreeR for TOF, //
102// write TOF.RecPoints.root file //
103// //
104////////////////////////////////////////////////////////////////
105
5c7c93fa 106#include "Riostream.h"
15ec34b9 107
0e46b9ae 108#include "TClonesArray.h"
515faf5d 109#include "TStopwatch.h"
0e46b9ae 110#include "TTree.h"
5c7c93fa 111//#include <TGeoManager.h>
ac359ffe 112#include <TGeoMatrix.h>
5c7c93fa 113//#include <TGeoPhysicalNode.h>
d08a92dd 114
d0eb8f39 115#include "AliDAQ.h"
0e46b9ae 116#include "AliLoader.h"
d08a92dd 117#include "AliLog.h"
0e46b9ae 118#include "AliRawReader.h"
d08a92dd 119#include "AliRunLoader.h"
5c7c93fa 120//#include "AliAlignObj.h"
121#include <AliGeomManager.h>
d08a92dd 122
15ec34b9 123#include "AliTOFcalib.h"
17149e6b 124#include "AliTOFChannelOnlineArray.h"
125#include "AliTOFChannelOnlineStatusArray.h"
ba66add8 126#include "AliTOFChannelOffline.h"
d08a92dd 127#include "AliTOFClusterFinder.h"
0e46b9ae 128#include "AliTOFcluster.h"
129#include "AliTOFdigit.h"
0e46b9ae 130#include "AliTOFGeometry.h"
15ec34b9 131#include "AliTOFrawData.h"
0e46b9ae 132#include "AliTOFRawStream.h"
133
15ec34b9 134//extern TFile *gFile;
d08a92dd 135
136ClassImp(AliTOFClusterFinder)
137
94f5f8f2 138AliTOFClusterFinder::AliTOFClusterFinder(AliTOFcalib *calib):
d08a92dd 139 fRunLoader(0),
140 fTOFLoader(0),
141 fTreeD(0),
142 fTreeR(0),
143 fDigits(new TClonesArray("AliTOFdigit", 4000)),
144 fRecPoints(new TClonesArray("AliTOFcluster", 4000)),
15ec34b9 145 fNumberOfTofClusters(0),
7813bb1a 146 fVerbose(0),
94f5f8f2 147 fDecoderVersion(0),
148 fTOFcalib(calib)
d08a92dd 149{
150//
151// Constructor
152//
153
d08a92dd 154}
155//______________________________________________________________________________
156
94f5f8f2 157AliTOFClusterFinder::AliTOFClusterFinder(AliRunLoader* runLoader, AliTOFcalib *calib):
d08a92dd 158 fRunLoader(runLoader),
159 fTOFLoader(runLoader->GetLoader("TOFLoader")),
160 fTreeD(0),
161 fTreeR(0),
162 fDigits(new TClonesArray("AliTOFdigit", 4000)),
163 fRecPoints(new TClonesArray("AliTOFcluster", 4000)),
15ec34b9 164 fNumberOfTofClusters(0),
7813bb1a 165 fVerbose(0),
94f5f8f2 166 fDecoderVersion(0),
167 fTOFcalib(calib)
d08a92dd 168{
169//
170// Constructor
171//
172
7aeeaf38 173}
174
175//------------------------------------------------------------------------
176AliTOFClusterFinder::AliTOFClusterFinder(const AliTOFClusterFinder &source)
58d8d9a3 177 :TObject(),
178 fRunLoader(0),
179 fTOFLoader(0),
180 fTreeD(0),
181 fTreeR(0),
58d8d9a3 182 fDigits(new TClonesArray("AliTOFdigit", 4000)),
183 fRecPoints(new TClonesArray("AliTOFcluster", 4000)),
15ec34b9 184 fNumberOfTofClusters(0),
94f5f8f2 185 fVerbose(0),
186 fDecoderVersion(0),
187 fTOFcalib(0)
7aeeaf38 188{
189 // copy constructor
190 this->fDigits=source.fDigits;
191 this->fRecPoints=source.fRecPoints;
7813bb1a 192 this->fDecoderVersion=source.fDecoderVersion;
94f5f8f2 193 this->fTOFcalib=source.fTOFcalib;
7aeeaf38 194
195}
196
197//------------------------------------------------------------------------
d0eb8f39 198AliTOFClusterFinder& AliTOFClusterFinder::operator=(const AliTOFClusterFinder &source)
7aeeaf38 199{
200 // ass. op.
201 this->fDigits=source.fDigits;
202 this->fRecPoints=source.fRecPoints;
15ec34b9 203 this->fVerbose=source.fVerbose;
7813bb1a 204 this->fDecoderVersion=source.fDecoderVersion;
94f5f8f2 205 this->fTOFcalib=source.fTOFcalib;
7aeeaf38 206 return *this;
207
d08a92dd 208}
209//______________________________________________________________________________
210
211AliTOFClusterFinder::~AliTOFClusterFinder()
212{
213
214 //
215 // Destructor
216 //
217
218 if (fDigits)
219 {
220 fDigits->Delete();
221 delete fDigits;
222 fDigits=0;
223 }
224 if (fRecPoints)
225 {
226 fRecPoints->Delete();
227 delete fRecPoints;
228 fRecPoints=0;
229 }
230
d08a92dd 231}
232//______________________________________________________________________________
233
234void AliTOFClusterFinder::Digits2RecPoints(Int_t iEvent)
235{
236 //
237 // Converts digits to recpoints for TOF
238 //
239
515faf5d 240 TStopwatch stopwatch;
241 stopwatch.Start();
242
d08a92dd 243 fRunLoader->GetEvent(iEvent);
244
245 fTreeD = fTOFLoader->TreeD();
246 if (fTreeD == 0x0)
247 {
248 AliFatal("AliTOFClusterFinder: Can not get TreeD");
249 }
250
251 TBranch *branch = fTreeD->GetBranch("TOF");
252 if (!branch) {
253 AliError("can't get the branch with the TOF digits !");
254 return;
255 }
256
b24266ca 257 TClonesArray staticdigits("AliTOFdigit",10000);
258 staticdigits.Clear();
259 TClonesArray *digits =&staticdigits;
d08a92dd 260 branch->SetAddress(&digits);
261
262 ResetRecpoint();
263
264 fTreeR = fTOFLoader->TreeR();
265 if (fTreeR == 0x0)
266 {
267 fTOFLoader->MakeTree("R");
268 fTreeR = fTOFLoader->TreeR();
269 }
270
271 Int_t bufsize = 32000;
272 fTreeR->Branch("TOF", &fRecPoints, bufsize);
273
274 fTreeD->GetEvent(0);
275 Int_t nDigits = digits->GetEntriesFast();
276 AliDebug(2,Form("Number of TOF digits: %d",nDigits));
277
ac359ffe 278 Int_t ii;
bf33f8f0 279 Int_t dig[5]; //cluster detector indeces
bf33f8f0 280 Int_t parTOF[5]; //The TOF signal parameters
281 Bool_t status=kTRUE; // assume all sim channels ok in the beginning...
d08a92dd 282 for (ii=0; ii<nDigits; ii++) {
283 AliTOFdigit *d = (AliTOFdigit*)digits->UncheckedAt(ii);
284 dig[0]=d->GetSector();
285 dig[1]=d->GetPlate();
286 dig[2]=d->GetStrip();
287 dig[3]=d->GetPadz();
288 dig[4]=d->GetPadx();
289
bf33f8f0 290 // AliDebug(2,Form(" %2i %1i %2i %1i %2i ",dig[0],dig[1],dig[2],dig[3],dig[4]));
d0eb8f39 291
bf33f8f0 292 parTOF[0] = d->GetTdc(); //the TDC signal
293 parTOF[1] = d->GetToT(); //the ToT signal
294 parTOF[2] = d->GetAdc(); // the adc charge
295 parTOF[3] = d->GetTdcND(); // non decalibrated sim time
296 parTOF[4] = d->GetTdc(); // raw time, == Tdc time for the moment
ac359ffe 297 Double_t posClus[3];
298 Double_t covClus[6];
299 UShort_t volIdClus=GetClusterVolIndex(dig);
300 GetClusterPars(dig, posClus,covClus);
301 AliTOFcluster *tofCluster = new AliTOFcluster(volIdClus,posClus[0],posClus[1],posClus[2],covClus[0],covClus[1],covClus[2],covClus[3],covClus[4],covClus[5],d->GetTracks(),dig,parTOF,status,ii);
d08a92dd 302 InsertCluster(tofCluster);
303
304 }
305
94f5f8f2 306 AliInfo(Form("Number of found clusters: %i for event: %i", fNumberOfTofClusters, iEvent));
d08a92dd 307
37879eed 308 CalibrateRecPoint();
d08a92dd 309 FillRecPoint();
310
311 fTreeR->Fill();
312 ResetRecpoint();
313
314 fTOFLoader = fRunLoader->GetLoader("TOFLoader");
315 fTOFLoader->WriteRecPoints("OVERWRITE");
316
515faf5d 317 AliInfo(Form("Execution time to read TOF digits and to write TOF clusters : R:%.4fs C:%.4fs",
318 stopwatch.RealTime(),stopwatch.CpuTime()));
319
94f5f8f2 320}
321
322//______________________________________________________________________________
323
324void AliTOFClusterFinder::Digits2RecPoints(TTree* digitsTree, TTree* clusterTree)
325{
326 //
327 // Converts digits to recpoints for TOF
328 //
329
330 TStopwatch stopwatch;
331 stopwatch.Start();
332
333 /// fRunLoader->GetEvent(iEvent);
334
335 if (digitsTree == 0x0)
336 {
337 AliFatal("AliTOFClusterFinder: Can not get TreeD");
338 }
339
340 TBranch *branch = digitsTree->GetBranch("TOF");
341 if (!branch) {
342 AliError("can't get the branch with the TOF digits !");
343 return;
344 }
345
b24266ca 346 TClonesArray staticdigits("AliTOFdigit",10000);
347 staticdigits.Clear();
348 TClonesArray *digits = & staticdigits;
94f5f8f2 349 branch->SetAddress(&digits);
350
351 ResetRecpoint();
352
353 fTreeR=clusterTree;
354 Int_t bufsize = 32000;
355 fTreeR->Branch("TOF", &fRecPoints, bufsize);
356
357 digitsTree->GetEvent(0);
358 Int_t nDigits = digits->GetEntriesFast();
359 AliDebug(2,Form("Number of TOF digits: %d",nDigits));
360
ac359ffe 361 Int_t ii;
94f5f8f2 362 Int_t dig[5]; //cluster detector indeces
94f5f8f2 363 Int_t parTOF[5]; //The TOF signal parameters
364 Bool_t status=kTRUE; // assume all sim channels ok in the beginning...
365 for (ii=0; ii<nDigits; ii++) {
366 AliTOFdigit *d = (AliTOFdigit*)digits->UncheckedAt(ii);
367 dig[0]=d->GetSector();
368 dig[1]=d->GetPlate();
369 dig[2]=d->GetStrip();
370 dig[3]=d->GetPadz();
371 dig[4]=d->GetPadx();
372
373 // AliDebug(2,Form(" %2i %1i %2i %1i %2i ",dig[0],dig[1],dig[2],dig[3],dig[4]));
374
94f5f8f2 375 parTOF[0] = d->GetTdc(); //the TDC signal
376 parTOF[1] = d->GetToT(); //the ToT signal
377 parTOF[2] = d->GetAdc(); // the adc charge
378 parTOF[3] = d->GetTdcND(); // non decalibrated sim time
379 parTOF[4] = d->GetTdc(); // raw time, == Tdc time for the moment
ac359ffe 380
381 Double_t posClus[3];
382 Double_t covClus[6];
383 UShort_t volIdClus=GetClusterVolIndex(dig);
384 GetClusterPars(dig,posClus,covClus);
385 AliTOFcluster *tofCluster = new AliTOFcluster(volIdClus,posClus[0],posClus[1],posClus[2],covClus[0],covClus[1],covClus[2],covClus[3],covClus[4],covClus[5],d->GetTracks(),dig,parTOF,status,ii);
94f5f8f2 386 InsertCluster(tofCluster);
387
388 }
389
390 AliInfo(Form("Number of found clusters: %i", fNumberOfTofClusters));
391
392 CalibrateRecPoint();
393 FillRecPoint();
394
395 clusterTree->Fill();
396 ResetRecpoint();
397
398 AliInfo(Form("Execution time to read TOF digits and to write TOF clusters : R:%.4fs C:%.4fs",
399 stopwatch.RealTime(),stopwatch.CpuTime()));
400
d08a92dd 401}
402//______________________________________________________________________________
403
404void AliTOFClusterFinder::Digits2RecPoints(AliRawReader *rawReader,
405 TTree *clustersTree)
406{
407 //
408 // Converts RAW data to recpoints for TOF
409 //
410
515faf5d 411 TStopwatch stopwatch;
412 stopwatch.Start();
413
d0eb8f39 414 //const Int_t kDDL = fTOFGeometry->NDDL()*fTOFGeometry->NSectors();
415 const Int_t kDDL = AliDAQ::NumberOfDdls("TOF");
d08a92dd 416
417 ResetRecpoint();
418
419 Int_t bufsize = 32000;
420 clustersTree->Branch("TOF", &fRecPoints, bufsize);
421
15ec34b9 422 TClonesArray * clonesRawData;
423
15ec34b9 424 Int_t dummy = -1;
d08a92dd 425
426 Int_t detectorIndex[5];
bf33f8f0 427 Int_t parTOF[5];
d08a92dd 428
15ec34b9 429 ofstream ftxt;
430 if (fVerbose==2) ftxt.open("TOFdigitsRead.txt",ios::app);
431
ef58b2af 432 AliTOFRawStream tofInput(rawReader);
433
15ec34b9 434 Int_t indexDDL = 0;
435 for (indexDDL = 0; indexDDL < kDDL; indexDDL++) {
436
437 rawReader->Reset();
7813bb1a 438 if (fDecoderVersion) {
439 AliInfo("Using New Decoder \n");
440 tofInput.LoadRawDataBuffers(indexDDL,fVerbose);
441 }
442 else tofInput.LoadRawData(indexDDL);
15ec34b9 443
444 clonesRawData = (TClonesArray*)tofInput.GetRawData();
445
446 for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
447
448 AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
449
c3891b7a 450 //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
451 if (tofRawDatum->GetTOF()==-1) continue;
15ec34b9 452
453 if (fVerbose==2) {
454 if (indexDDL<10) ftxt << " " << indexDDL;
455 else ftxt << " " << indexDDL;
456 if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM();
457 else ftxt << " " << tofRawDatum->GetTRM();
458 ftxt << " " << tofRawDatum->GetTRMchain();
459 if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC();
460 else ftxt << " " << tofRawDatum->GetTDC();
461 ftxt << " " << tofRawDatum->GetTDCchannel();
462 }
463
464 tofInput.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
465 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
466 dummy = detectorIndex[3];
467 detectorIndex[3] = detectorIndex[4];
468 detectorIndex[4] = dummy;
469
470 if (fVerbose==2) {
471 if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0];
472 else ftxt << " -> " << detectorIndex[0];
473 ftxt << " " << detectorIndex[1];
474 if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2];
475 else ftxt << " " << detectorIndex[2];
476 ftxt << " " << detectorIndex[3];
477 if (detectorIndex[4]<10) ftxt << " " << detectorIndex[4];
478 else ftxt << " " << detectorIndex[4];
479 }
480
bf33f8f0 481 parTOF[0] = tofRawDatum->GetTOF(); //TDC
482 parTOF[1] = tofRawDatum->GetTOT(); // TOT
483 parTOF[2] = tofRawDatum->GetTOT(); //ADC==TOF
484 parTOF[3] = -1;//raw data: no track of undecalib sim time
485 parTOF[4] = tofRawDatum->GetTOF(); // RAW time
ac359ffe 486 Double_t posClus[3];
487 Double_t covClus[6];
488 UShort_t volIdClus=GetClusterVolIndex(detectorIndex);
489 Int_t lab[3]={-1,-1,-1};
490 Bool_t status=kTRUE;
491 GetClusterPars(detectorIndex,posClus,covClus);
492 AliTOFcluster *tofCluster = new AliTOFcluster(volIdClus,posClus[0],posClus[1],posClus[2],covClus[0],covClus[1],covClus[2],covClus[3],covClus[4],covClus[5],lab,detectorIndex,parTOF,status,-1);
15ec34b9 493 InsertCluster(tofCluster);
494
495 if (fVerbose==2) {
bf33f8f0 496 if (parTOF[1]<10)ftxt << " " << parTOF[1];
497 else if (parTOF[1]>=10 && parTOF[1]<100) ftxt << " " << parTOF[1];
498 else ftxt << " " << parTOF[1];
499 if (parTOF[0]<10) ftxt << " " << parTOF[0] << endl;
500 else if (parTOF[0]>=10 && parTOF[0]<100) ftxt << " " << parTOF[0] << endl;
501 else if (parTOF[0]>=100 && parTOF[0]<1000) ftxt << " " << parTOF[0] << endl;
502 else ftxt << " " << parTOF[3] << endl;
15ec34b9 503 }
504
505 } // closed loop on TOF raw data per current DDL file
506
507 clonesRawData->Clear();
508
509 } // closed loop on DDL index
510
15ec34b9 511 if (fVerbose==2) ftxt.close();
d08a92dd 512
513 AliInfo(Form("Number of found clusters: %i", fNumberOfTofClusters));
514
37879eed 515 CalibrateRecPoint();
d08a92dd 516 FillRecPoint();
517
518 clustersTree->Fill();
37879eed 519
d08a92dd 520 ResetRecpoint();
521
515faf5d 522 AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters : R:%.4fs C:%.4fs",
523 stopwatch.RealTime(),stopwatch.CpuTime()));
524
d08a92dd 525}
526//______________________________________________________________________________
527
528void AliTOFClusterFinder::Digits2RecPoints(Int_t iEvent, AliRawReader *rawReader)
529{
530 //
531 // Converts RAW data to recpoints for TOF
532 //
533
515faf5d 534 TStopwatch stopwatch;
535 stopwatch.Start();
536
d0eb8f39 537 //const Int_t kDDL = fTOFGeometry->NDDL()*fTOFGeometry->NSectors();
538 const Int_t kDDL = AliDAQ::NumberOfDdls("TOF");
d08a92dd 539
540 fRunLoader->GetEvent(iEvent);
541
542 AliDebug(2,Form(" Event number %2i ", iEvent));
543
544 fTreeR = fTOFLoader->TreeR();
545
546 if (fTreeR == 0x0){
547 fTOFLoader->MakeTree("R");
548 fTreeR = fTOFLoader->TreeR();
549 }
550
551 Int_t bufsize = 32000;
552 fTreeR->Branch("TOF", &fRecPoints, bufsize);
553
15ec34b9 554 TClonesArray * clonesRawData;
555
15ec34b9 556 Int_t dummy = -1;
d08a92dd 557
d0eb8f39 558 Int_t detectorIndex[5] = {-1, -1, -1, -1, -1};
bf33f8f0 559 Int_t parTOF[5];
15ec34b9 560 ofstream ftxt;
561 if (fVerbose==2) ftxt.open("TOFdigitsRead.txt",ios::app);
562
ef58b2af 563 AliTOFRawStream tofInput(rawReader);
564
15ec34b9 565 Int_t indexDDL = 0;
d08a92dd 566 for (indexDDL = 0; indexDDL < kDDL; indexDDL++) {
567
568 rawReader->Reset();
7813bb1a 569 if (fDecoderVersion) {
570 AliInfo("Using New Decoder \n");
571 tofInput.LoadRawDataBuffers(indexDDL,fVerbose);
572 }
573 else tofInput.LoadRawData(indexDDL);
15ec34b9 574
575 clonesRawData = (TClonesArray*)tofInput.GetRawData();
576
577 for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
578
579 AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
580
c3891b7a 581 //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
582 if (tofRawDatum->GetTOF()==-1) continue;
15ec34b9 583
584 if (fVerbose==2) {
585 if (indexDDL<10) ftxt << " " << indexDDL;
586 else ftxt << " " << indexDDL;
587 if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM();
588 else ftxt << " " << tofRawDatum->GetTRM();
589 ftxt << " " << tofRawDatum->GetTRMchain();
590 if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC();
591 else ftxt << " " << tofRawDatum->GetTDC();
592 ftxt << " " << tofRawDatum->GetTDCchannel();
593 }
594
595 tofInput.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
596 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
597 dummy = detectorIndex[3];
598 detectorIndex[3] = detectorIndex[4];
599 detectorIndex[4] = dummy;
600
601 if (fVerbose==2) {
602 if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0];
603 else ftxt << " -> " << detectorIndex[0];
604 ftxt << " " << detectorIndex[1];
605 if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2];
606 else ftxt << " " << detectorIndex[2];
607 ftxt << " " << detectorIndex[3];
608 if (detectorIndex[4]<10) ftxt << " " << detectorIndex[4];
609 else ftxt << " " << detectorIndex[4];
610 }
d0eb8f39 611
bf33f8f0 612 parTOF[0] = tofRawDatum->GetTOF(); // TDC
613 parTOF[1] = tofRawDatum->GetTOT(); // TOT
614 parTOF[2] = tofRawDatum->GetTOT(); // raw data have ADC=TOT
615 parTOF[3] = -1; //raw data: no track of the undecalib sim time
616 parTOF[4] = tofRawDatum->GetTOF(); // Raw time == TDC
ac359ffe 617 Double_t posClus[3];
618 Double_t covClus[6];
619 UShort_t volIdClus=GetClusterVolIndex(detectorIndex);
620 Int_t lab[3]={-1,-1,-1};
621 Bool_t status=kTRUE;
622 GetClusterPars(detectorIndex,posClus,covClus);
623 AliTOFcluster *tofCluster = new AliTOFcluster(volIdClus,posClus[0],posClus[1],posClus[2],covClus[0],covClus[1],covClus[2],covClus[3],covClus[4],covClus[5],lab,detectorIndex,parTOF,status,-1);
d08a92dd 624 InsertCluster(tofCluster);
625
15ec34b9 626 if (fVerbose==2) {
bf33f8f0 627 if (parTOF[1]<10)ftxt << " " << parTOF[1];
628 else if (parTOF[1]>=10 && parTOF[1]<100) ftxt << " " << parTOF[1];
629 else ftxt << " " << parTOF[1];
630 if (parTOF[0]<10) ftxt << " " << parTOF[0] << endl;
631 else if (parTOF[0]>=10 && parTOF[0]<100) ftxt << " " << parTOF[0] << endl;
632 else if (parTOF[0]>=100 && parTOF[0]<1000) ftxt << " " << parTOF[0] << endl;
633 else ftxt << " " << parTOF[3] << endl;
15ec34b9 634 }
d08a92dd 635
15ec34b9 636 } // closed loop on TOF raw data per current DDL file
637
638 clonesRawData->Clear();
639
640 } // closed loop on DDL index
641
642 if (fVerbose==2) ftxt.close();
d08a92dd 643
94f5f8f2 644 AliInfo(Form("Number of found clusters: %i for event: %i", fNumberOfTofClusters, iEvent));
d08a92dd 645
37879eed 646 CalibrateRecPoint();
d08a92dd 647 FillRecPoint();
648
649 fTreeR->Fill();
650 ResetRecpoint();
651
652 fTOFLoader = fRunLoader->GetLoader("TOFLoader");
653 fTOFLoader->WriteRecPoints("OVERWRITE");
654
515faf5d 655 AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters : R:%.4fs C:%.4fs",
656 stopwatch.RealTime(),stopwatch.CpuTime()));
657
d08a92dd 658}
659//______________________________________________________________________________
660
661void AliTOFClusterFinder::Raw2Digits(Int_t iEvent, AliRawReader *rawReader)
662{
663 //
664 // Converts RAW data to MC digits for TOF
665 //
666 // (temporary solution)
667 //
668
515faf5d 669 TStopwatch stopwatch;
670 stopwatch.Start();
671
15ec34b9 672 //const Int_t kDDL = fTOFGeometry->NDDL()*fTOFGeometry->NSectors();
ba66add8 673 const Int_t kDDL = AliTOFGeometry::NDDL()*AliTOFGeometry::NSectors();
15ec34b9 674
d08a92dd 675 fRunLoader->GetEvent(iEvent);
676
677 fTreeD = fTOFLoader->TreeD();
678 if (fTreeD)
679 {
d0eb8f39 680 AliInfo("TreeD re-creation");
d08a92dd 681 fTreeD = 0x0;
682 fTOFLoader->MakeTree("D");
683 fTreeD = fTOFLoader->TreeD();
684 }
685
15ec34b9 686 TClonesArray *tofDigits = new TClonesArray("AliTOFdigit",10000);
d08a92dd 687 Int_t bufsize = 32000;
688 fTreeD->Branch("TOF", &tofDigits, bufsize);
689
d08a92dd 690 fRunLoader->GetEvent(iEvent);
691
692 AliDebug(2,Form(" Event number %2i ", iEvent));
693
15ec34b9 694 TClonesArray * clonesRawData;
695
696 Int_t dummy = -1;
d08a92dd 697
698 Int_t detectorIndex[5];
bf33f8f0 699 Int_t digit[4];
d08a92dd 700
ef58b2af 701 AliTOFRawStream tofInput(rawReader);
702
15ec34b9 703 Int_t indexDDL = 0;
d08a92dd 704 for (indexDDL = 0; indexDDL < kDDL; indexDDL++) {
705
706 rawReader->Reset();
7813bb1a 707 if (fDecoderVersion) {
708 AliInfo("Using New Decoder \n");
709 tofInput.LoadRawDataBuffers(indexDDL,fVerbose);
710 }
711 else tofInput.LoadRawData(indexDDL);
d08a92dd 712
15ec34b9 713 clonesRawData = (TClonesArray*)tofInput.GetRawData();
d08a92dd 714
15ec34b9 715 for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
d0eb8f39 716
15ec34b9 717 AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
d0eb8f39 718
15ec34b9 719 if (!tofRawDatum->GetTOT() || !tofRawDatum->GetTOF()) continue;
720
721 tofInput.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
722 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
723 dummy = detectorIndex[3];
724 detectorIndex[3] = detectorIndex[4];
725 detectorIndex[4] = dummy;
d0eb8f39 726
bf33f8f0 727 digit[0] = tofInput.GetTofBin();
728 digit[1] = tofInput.GetToTbin();
729 digit[2] = tofInput.GetToTbin();
730 digit[3] = -1;
d08a92dd 731
732 Int_t tracknum[3]={-1,-1,-1};
733
734 TClonesArray &aDigits = *tofDigits;
735 Int_t last=tofDigits->GetEntriesFast();
736 new (aDigits[last]) AliTOFdigit(tracknum, detectorIndex, digit);
737
738 } // while loop
739
15ec34b9 740 clonesRawData->Clear();
741
d08a92dd 742 } // DDL Loop
743
744 fTreeD->Fill();
745
746 fTOFLoader = fRunLoader->GetLoader("TOFLoader");
747 fTOFLoader->WriteDigits("OVERWRITE");
748
515faf5d 749 AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters : R:%.2fs C:%.2fs",
750 stopwatch.RealTime(),stopwatch.CpuTime()));
751
94f5f8f2 752}
753
754//______________________________________________________________________________
755
756void AliTOFClusterFinder::Raw2Digits(AliRawReader *rawReader, TTree* digitsTree)
757{
758 //
759 // Converts RAW data to MC digits for TOF for the current event
760 //
761 //
762
763 TStopwatch stopwatch;
764 stopwatch.Start();
765
ba66add8 766 const Int_t kDDL = AliTOFGeometry::NDDL()*AliTOFGeometry::NSectors();
94f5f8f2 767
768 if (!digitsTree)
769 {
770 AliError("No input digits Tree");
771 return;
772 }
773
774 TClonesArray *tofDigits = new TClonesArray("AliTOFdigit",10000);
775 Int_t bufsize = 32000;
776 digitsTree->Branch("TOF", &tofDigits, bufsize);
777
778 /// fRunLoader->GetEvent(iEvent);
779
780 /// AliDebug(2,Form(" Event number %2i ", iEvent));
781
782 TClonesArray * clonesRawData;
783
784 Int_t dummy = -1;
785
786 Int_t detectorIndex[5];
787 Int_t digit[4];
788
ef58b2af 789 AliTOFRawStream tofInput(rawReader);
790
94f5f8f2 791 Int_t indexDDL = 0;
792 for (indexDDL = 0; indexDDL < kDDL; indexDDL++) {
793
794 rawReader->Reset();
94f5f8f2 795 if (fDecoderVersion) {
796 AliInfo("Using New Decoder \n");
797 tofInput.LoadRawDataBuffers(indexDDL,fVerbose);
798 }
799 else tofInput.LoadRawData(indexDDL);
800
801 clonesRawData = (TClonesArray*)tofInput.GetRawData();
802
803 for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
804
805 AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
806
807 if (!tofRawDatum->GetTOT() || !tofRawDatum->GetTOF()) continue;
808
809 tofInput.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
810 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
811 dummy = detectorIndex[3];
812 detectorIndex[3] = detectorIndex[4];
813 detectorIndex[4] = dummy;
814
815 digit[0] = tofInput.GetTofBin();
816 digit[1] = tofInput.GetToTbin();
817 digit[2] = tofInput.GetToTbin();
818 digit[3] = -1;
819
820 Int_t tracknum[3]={-1,-1,-1};
821
822 TClonesArray &aDigits = *tofDigits;
823 Int_t last=tofDigits->GetEntriesFast();
824 new (aDigits[last]) AliTOFdigit(tracknum, detectorIndex, digit);
825
826 } // while loop
827
828 clonesRawData->Clear();
829
830 } // DDL Loop
831
832 digitsTree->Fill();
833
834 AliDebug(1, Form("Got %d digits: ", tofDigits->GetEntries()));
835 AliDebug(1, Form("Execution time to read TOF raw data and fill TOF digit tree : R:%.2fs C:%.2fs",
836 stopwatch.RealTime(),stopwatch.CpuTime()));
837
d08a92dd 838}
839//______________________________________________________________________________
840
841Int_t AliTOFClusterFinder::InsertCluster(AliTOFcluster *tofCluster) {
842 //---------------------------------------------------------------------------//
843 // This function adds a TOF cluster to the array of TOF clusters sorted in Z //
844 //---------------------------------------------------------------------------//
845 if (fNumberOfTofClusters==kTofMaxCluster) {
846 AliError("Too many clusters !");
847 return 1;
848 }
849
850 if (fNumberOfTofClusters==0) {
851 fTofClusters[fNumberOfTofClusters++] = tofCluster;
852 return 0;
853 }
854
855 Int_t ii = FindClusterIndex(tofCluster->GetZ());
856 memmove(fTofClusters+ii+1 ,fTofClusters+ii,(fNumberOfTofClusters-ii)*sizeof(AliTOFcluster*));
857 fTofClusters[ii] = tofCluster;
858 fNumberOfTofClusters++;
859
860 return 0;
861
862}
863//_________________________________________________________________________
864
865Int_t AliTOFClusterFinder::FindClusterIndex(Double_t z) const {
866 //--------------------------------------------------------------------
ac359ffe 867 // This function returns the index of the nearest cluster in z
d08a92dd 868 //--------------------------------------------------------------------
869 if (fNumberOfTofClusters==0) return 0;
870 if (z <= fTofClusters[0]->GetZ()) return 0;
871 if (z > fTofClusters[fNumberOfTofClusters-1]->GetZ()) return fNumberOfTofClusters;
872 Int_t b = 0, e = fNumberOfTofClusters-1, m = (b+e)/2;
873 for (; b<e; m=(b+e)/2) {
874 if (z > fTofClusters[m]->GetZ()) b=m+1;
875 else e=m;
876 }
877
878 return m;
879
880}
881//_________________________________________________________________________
882
883void AliTOFClusterFinder::FillRecPoint()
884{
885 //
886 // Copy the global array of AliTOFcluster, i.e. fTofClusters (sorted
887 // in Z) in the global TClonesArray of AliTOFcluster,
888 // i.e. fRecPoints.
889 //
890
891 Int_t ii, jj;
892
893 Int_t detectorIndex[5];
bf33f8f0 894 Int_t parTOF[5];
d08a92dd 895 Int_t trackLabels[3];
896 Int_t digitIndex = -1;
bf33f8f0 897 Bool_t status=kTRUE;
d08a92dd 898
899 TClonesArray &lRecPoints = *fRecPoints;
900
901 for (ii=0; ii<fNumberOfTofClusters; ii++) {
902
903 digitIndex = fTofClusters[ii]->GetIndex();
904 for(jj=0; jj<5; jj++) detectorIndex[jj] = fTofClusters[ii]->GetDetInd(jj);
905 for(jj=0; jj<3; jj++) trackLabels[jj] = fTofClusters[ii]->GetLabel(jj);
bf33f8f0 906 parTOF[0] = fTofClusters[ii]->GetTDC(); // TDC
907 parTOF[1] = fTofClusters[ii]->GetToT(); // TOT
908 parTOF[2] = fTofClusters[ii]->GetADC(); // ADC=TOT
909 parTOF[3] = fTofClusters[ii]->GetTDCND(); // TDCND
910 parTOF[4] = fTofClusters[ii]->GetTDCRAW();//RAW
911 status=fTofClusters[ii]->GetStatus();
ac359ffe 912 Double_t posClus[3];
913 Double_t covClus[6];
914 UShort_t volIdClus=GetClusterVolIndex(detectorIndex);
915 GetClusterPars(detectorIndex,posClus,covClus);
916 new(lRecPoints[ii]) AliTOFcluster(volIdClus,posClus[0],posClus[1],posClus[2],covClus[0],covClus[1],covClus[2],covClus[3],covClus[4],covClus[5],trackLabels,detectorIndex, parTOF,status,digitIndex);
d08a92dd 917
918 } // loop on clusters
919
920}
37879eed 921
922//_________________________________________________________________________
923void AliTOFClusterFinder::CalibrateRecPoint()
924{
925 //
926 // Copy the global array of AliTOFcluster, i.e. fTofClusters (sorted
927 // in Z) in the global TClonesArray of AliTOFcluster,
928 // i.e. fRecPoints.
929 //
930
931 Int_t ii, jj;
932
933 Int_t detectorIndex[5];
934 Int_t digitIndex = -1;
a33fec85 935 Double_t tToT;
936 Double_t timeCorr;
bf33f8f0 937 Int_t tdcCorr;
37879eed 938 AliInfo(" Calibrating TOF Clusters: ")
a1cab04c 939
17149e6b 940 AliTOFChannelOnlineArray *calDelay = fTOFcalib->GetTOFOnlineDelay();
941 AliTOFChannelOnlineStatusArray *calStatus = fTOFcalib->GetTOFOnlineStatus();
ba66add8 942 TObjArray *calTOFArrayOffline = fTOFcalib->GetTOFCalArrayOffline();
943 TString validity = (TString)fTOFcalib->GetOfflineValidity();
944 AliInfo(Form(" validity = %s",validity.Data()));
945 Int_t calibration = -1;
946 if (validity.CompareTo("valid")==0) {
947 AliInfo(" Using offline calibration parameters");
948 calibration = 1;
949 }
950 else {
951 AliInfo(" Using online calibration parameters");
952 calibration = 0 ;
953 }
37879eed 954 for (ii=0; ii<fNumberOfTofClusters; ii++) {
955 digitIndex = fTofClusters[ii]->GetIndex();
956 for(jj=0; jj<5; jj++) detectorIndex[jj] = fTofClusters[ii]->GetDetInd(jj);
957
ba66add8 958 Int_t index = AliTOFGeometry::GetIndex(detectorIndex);
37879eed 959
17149e6b 960 UChar_t statusPulser=calStatus->GetPulserStatus(index);
961 UChar_t statusNoise=calStatus->GetNoiseStatus(index);
962 UChar_t statusHW=calStatus->GetHWStatus(index);
963 UChar_t status=calStatus->GetStatus(index);
964
965 //check the status, also unknown is fine!!!!!!!
966
967 AliDebug(2, Form(" Status for channel %i = %i",index, (Int_t)status));
968 if((statusPulser & AliTOFChannelOnlineStatusArray::kTOFPulserBad)==(AliTOFChannelOnlineStatusArray::kTOFPulserBad)||(statusNoise & AliTOFChannelOnlineStatusArray::kTOFNoiseBad)==(AliTOFChannelOnlineStatusArray::kTOFNoiseBad)||(statusHW & AliTOFChannelOnlineStatusArray::kTOFHWBad)==(AliTOFChannelOnlineStatusArray::kTOFHWBad)){
7fffa85b 969 AliDebug(2, Form(" Bad Status for channel %i",index));
970 fTofClusters[ii]->SetStatus(kFALSE); //odd convention, to avoid conflict with calibration objects currently in the db (temporary solution).
971 }
972 else {
973 AliDebug(2, Form(" Good Status for channel %i",index));
974 }
58d8d9a3 975 // Get Rough channel online equalization
17149e6b 976 Double_t roughDelay=(Double_t)calDelay->GetDelay(index); // in ns
ba66add8 977 AliDebug(2,Form(" channel delay (ns) = %f", roughDelay));
58d8d9a3 978 // Get Refined channel offline calibration parameters
ba66add8 979 if (calibration ==1){
980 AliTOFChannelOffline * calChannelOffline = (AliTOFChannelOffline*)calTOFArrayOffline->At(index);
981 Double_t par[6];
982 for (Int_t j = 0; j<6; j++){
983 par[j]=(Double_t)calChannelOffline->GetSlewPar(j);
984 }
bf33f8f0 985 AliDebug(2,Form(" Calib Pars = %f, %f, %f, %f, %f, %f ",par[0],par[1],par[2],par[3],par[4],par[5]));
ba66add8 986 AliDebug(2,Form(" The ToT and Time, uncorr (counts) = %i , %i", fTofClusters[ii]->GetToT(),fTofClusters[ii]->GetTDC()));
987 tToT = (Double_t)(fTofClusters[ii]->GetToT()*AliTOFGeometry::ToTBinWidth());
988 tToT*=1.E-3; //ToT in ns
989 AliDebug(2,Form(" The ToT and Time, uncorr (ns)= %e, %e",fTofClusters[ii]->GetTDC()*AliTOFGeometry::TdcBinWidth()*1.E-3,tToT));
990 timeCorr=par[0]+par[1]*tToT+par[2]*tToT*tToT+par[3]*tToT*tToT*tToT+par[4]*tToT*tToT*tToT*tToT+par[5]*tToT*tToT*tToT*tToT*tToT; // the time correction (ns)
991 }
992 else {
993 timeCorr = roughDelay; // correction in ns
994 }
995 AliDebug(2,Form(" The ToT and Time, uncorr (ns)= %e, %e",fTofClusters[ii]->GetTDC()*AliTOFGeometry::TdcBinWidth()*1.E-3,fTofClusters[ii]->GetToT()*AliTOFGeometry::ToTBinWidth()));
bf33f8f0 996 AliDebug(2,Form(" The time correction (ns) = %f", timeCorr));
a33fec85 997 timeCorr=(Double_t)(fTofClusters[ii]->GetTDC())*AliTOFGeometry::TdcBinWidth()*1.E-3-timeCorr;//redefine the time
998 timeCorr*=1.E3;
999 AliDebug(2,Form(" The channel time, corr (ps)= %e",timeCorr ));
1000 tdcCorr=(Int_t)(timeCorr/AliTOFGeometry::TdcBinWidth()); //the corrected time (tdc counts)
340693af 1001 fTofClusters[ii]->SetTDC(tdcCorr);
37879eed 1002 } // loop on clusters
1003
37879eed 1004}
d08a92dd 1005//______________________________________________________________________________
1006
1007void AliTOFClusterFinder::ResetRecpoint()
1008{
1009 //
1010 // Clear the list of reconstructed points
1011 //
1012
1013 fNumberOfTofClusters = 0;
1014 if (fRecPoints) fRecPoints->Clear();
1015
1016}
1017//______________________________________________________________________________
1018
1019void AliTOFClusterFinder::Load()
1020{
1021 //
1022 // Load TOF.Digits.root and TOF.RecPoints.root files
1023 //
1024
1025 fTOFLoader->LoadDigits("READ");
1026 fTOFLoader->LoadRecPoints("recreate");
1027
1028}
1029//______________________________________________________________________________
1030
1031void AliTOFClusterFinder::LoadClusters()
1032{
1033 //
1034 // Load TOF.RecPoints.root file
1035 //
1036
1037 fTOFLoader->LoadRecPoints("recreate");
1038
1039}
1040//______________________________________________________________________________
1041
1042void AliTOFClusterFinder::UnLoad()
1043{
1044 //
1045 // Unload TOF.Digits.root and TOF.RecPoints.root files
1046 //
1047
1048 fTOFLoader->UnloadDigits();
1049 fTOFLoader->UnloadRecPoints();
1050
1051}
1052//______________________________________________________________________________
1053
1054void AliTOFClusterFinder::UnLoadClusters()
1055{
1056 //
1057 // Unload TOF.RecPoints.root file
1058 //
1059
1060 fTOFLoader->UnloadRecPoints();
1061
1062}
ac359ffe 1063//-------------------------------------------------------------------------
1064UShort_t AliTOFClusterFinder::GetClusterVolIndex(Int_t *ind) const {
1065
1066 //First of all get the volume ID to retrieve the l2t transformation...
1067 //
1068 // Detector numbering scheme
1069 Int_t nSector = 18;
1070 Int_t nPlate = 5;
1071 Int_t nStripA = 15;
1072 Int_t nStripB = 19;
1073 Int_t nStripC = 19;
1074
1075 Int_t isector =ind[0];
1076 if (isector >= nSector)
1077 AliError(Form("Wrong sector number in TOF (%d) !",isector));
1078 Int_t iplate = ind[1];
1079 if (iplate >= nPlate)
1080 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
1081 Int_t istrip = ind[2];
1082
1083 Int_t stripOffset = 0;
1084 switch (iplate) {
1085 case 0:
1086 stripOffset = 0;
1087 break;
1088 case 1:
1089 stripOffset = nStripC;
1090 break;
1091 case 2:
1092 stripOffset = nStripC+nStripB;
1093 break;
1094 case 3:
1095 stripOffset = nStripC+nStripB+nStripA;
1096 break;
1097 case 4:
1098 stripOffset = nStripC+nStripB+nStripA+nStripB;
1099 break;
1100 default:
1101 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
1102 break;
1103 };
1104
1105 Int_t index= (2*(nStripC+nStripB)+nStripA)*isector +
1106 stripOffset +
1107 istrip;
1108
1109 UShort_t volIndex = AliGeomManager::LayerToVolUID(AliGeomManager::kTOF,index);
1110 return volIndex;
1111}
1112//
1113//-------------------------------------------------------------------------
1114void AliTOFClusterFinder::GetClusterPars(Int_t *ind, Double_t* pos,Double_t* cov) const {
1115
1116 //First of all get the volume ID to retrieve the l2t transformation...
1117 //
1118 UShort_t volIndex = GetClusterVolIndex(ind);
1119 //
1120 //
1121 //we now go in the system of the strip: determine the local coordinates
1122 //
1123 //
1124 // 47---------------------------------------------------0 ^ z
1125 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 1 |
1126 // ----------------------------------------------------- | y going outwards
1127 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 0 | par[0]=0;
1128
1129 // ----------------------------------------------------- |
1130 // x <-----------------------------------------------------
1131
1132 Float_t localX=(ind[4]-23.5)*2.5;
1133 Float_t localY=0;
1134 Float_t localZ=(ind[3]-0.5)*3.5;
1135
1136 //move to the tracking ref system
1137
1138 Double_t lpos[3];
1139 lpos[0]=localX;
1140 lpos[1]=localY;
1141 lpos[2]=localZ;
1142
1143 const TGeoHMatrix *l2t= AliGeomManager::GetTracking2LocalMatrix(volIndex);
1144 // Get The position in the track ref system
1145 Double_t tpos[3];
1146 l2t->MasterToLocal(lpos,tpos);
1147 pos[0]=tpos[0];
1148 pos[1]=tpos[1];
1149 pos[2]=tpos[2];
1150
1151 //Get The cluster covariance in the track ref system
1152 Double_t lcov[9];
1153
1154 //cluster covariance in the local system:
1155 // sx2 0 0
1156 // 0 0 0
1157 // 0 0 sz2
1158
1159 lcov[0]=2.5*2.5/12.;
1160 lcov[1]=0;
1161 lcov[2]=0;
1162 lcov[3]=0;
1163 lcov[4]=0;
1164 lcov[5]=0;
1165 lcov[6]=0;
1166 lcov[7]=0;
1167 lcov[8]=3.5*3.5/12.;
1168
1169 //cluster covariance in the tracking system:
1170 TGeoHMatrix m;
1171 m.SetRotation(lcov);
1172 m.Multiply(l2t);
1173 m.MultiplyLeft(&l2t->Inverse());
1174 Double_t *tcov = m.GetRotationMatrix();
1175 cov[0] = tcov[0]; cov[1] = tcov[1]; cov[2] = tcov[2];
1176 cov[3] = tcov[4]; cov[4] = tcov[5];
1177 cov[5] = tcov[8];
1178
1179 return;
1180
1181}