1 /***************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
17 $Log: AliTOFClusterFinder.cxx,v $
18 Revision 1.31 2007/11/24 14:53:19 zampolli
19 Status flag implemented as UChar_t
21 Revision 1.30 2007/10/04 13:08:52 arcelli
22 updates to comply with AliTOFGeometryV5 becoming AliTOFGeometry
24 Revision 1.29 2007/10/03 10:42:33 arcelli
25 updates to handle new AliTOFcluster, inheriting form AliCluster3D
27 Revision 1.28 2007/05/31 16:06:05 arcelli
28 move instance of AliRawStream outside loop on DDL
30 Revision 1.27 2007/05/02 16:31:49 arcelli
31 Add methods to handle single event reconstruction. retrieval of Calib
32 info moved to AliTOFReconstructor ctor, and passed via a pointer to
35 Revision 1.26 2007/04/30 19:02:24 arcelli
36 hopefully the last refinements for correct type conversion in calibration
38 Revision 1.25 2007/04/30 15:22:17 arcelli
39 Change TOF digit Time, Tot etc to int type
41 Revision 1.24 2007/04/27 11:19:31 arcelli
42 updates for the new decoder
44 Revision 1.23 2007/04/23 16:51:39 decaro
45 Digits-to-raw_data conversion: correction for a more real description
46 (A.De Caro, R.Preghenella)
48 Revision 1.22 2007/04/19 17:26:32 arcelli
49 Fix a bug (add some debug printout
51 Revision 1.21 2007/04/18 17:28:12 arcelli
52 Set the ToT bin width to the one actually used...
54 Revision 1.20 2007/03/09 09:57:23 arcelli
55 Remove a forgotten include of Riostrem
57 Revision 1.19 2007/03/08 15:41:20 arcelli
58 set uncorrected times when filling RecPoints
60 Revision 1.18 2007/03/06 16:31:20 arcelli
61 Add Uncorrected TOF Time signal
63 Revision 1.17 2007/02/28 18:09:11 arcelli
64 Add protection against failed retrieval of the CDB cal object,
65 now Reconstruction exits with AliFatal
67 Revision 1.16 2007/02/20 15:57:00 decaro
68 Raw data update: to read the TOF raw data defined in UNPACKED mode
71 Revision 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
77 Revision 0.02 2005/07/27 A. De Caro
78 Implement public method
79 Digits2RecPoint(Int_t)
80 to convert digits in clusters
82 Revision 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
89 Revision 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
96 ////////////////////////////////////////////////////////////////
98 // Class for TOF cluster finder //
100 // Starting from Raw Data, create rec points, //
101 // fill TreeR for TOF, //
102 // write TOF.RecPoints.root file //
104 ////////////////////////////////////////////////////////////////
106 #include "Riostream.h"
108 #include "TClonesArray.h"
109 #include "TStopwatch.h"
111 //#include <TGeoManager.h>
112 #include <TGeoMatrix.h>
113 //#include <TGeoPhysicalNode.h>
116 #include "AliLoader.h"
118 #include "AliRawReader.h"
119 #include "AliRunLoader.h"
120 //#include "AliAlignObj.h"
121 #include <AliGeomManager.h>
123 #include "AliTOFcalib.h"
124 #include "AliTOFChannelOnlineArray.h"
125 #include "AliTOFChannelOnlineStatusArray.h"
126 #include "AliTOFChannelOffline.h"
127 #include "AliTOFClusterFinder.h"
128 #include "AliTOFcluster.h"
129 #include "AliTOFdigit.h"
130 #include "AliTOFGeometry.h"
131 #include "AliTOFrawData.h"
133 #include "AliTOFDeltaBCOffset.h"
134 #include "AliTOFCTPLatency.h"
135 #include "AliTOFRunParams.h"
137 //extern TFile *gFile;
139 ClassImp(AliTOFClusterFinder)
141 AliTOFClusterFinder::AliTOFClusterFinder(AliTOFcalib *calib):
142 TTask("AliTOFClusterFinder",""),
147 fDigits(new TClonesArray("AliTOFdigit", 4000)),
148 fRecPoints(new TClonesArray("AliTOFcluster", 4000)),
149 fNumberOfTofClusters(0),
153 fTOFRawStream(AliTOFRawStream())
159 for (Int_t ii=0; ii<kTofMaxCluster; ii++) fTofClusters[ii]=0x0;
161 TString validity = (TString)fTOFcalib->GetOfflineValidity();
162 if (validity.CompareTo("valid")==0) {
163 AliInfo(Form(" validity = %s - Using offline calibration parameters",validity.Data()));
165 AliInfo(Form(" validity = %s - Using online calibration parameters",validity.Data()));
170 //______________________________________________________________________________
172 AliTOFClusterFinder::AliTOFClusterFinder(AliRunLoader* runLoader, AliTOFcalib *calib):
173 TTask("AliTOFClusterFinder",""),
174 fRunLoader(runLoader),
175 fTOFLoader(runLoader->GetLoader("TOFLoader")),
178 fDigits(new TClonesArray("AliTOFdigit", 4000)),
179 fRecPoints(new TClonesArray("AliTOFcluster", 4000)),
180 fNumberOfTofClusters(0),
184 fTOFRawStream(AliTOFRawStream())
190 for (Int_t ii=0; ii<kTofMaxCluster; ii++) fTofClusters[ii]=0x0;
192 TString validity = (TString)fTOFcalib->GetOfflineValidity();
193 if (validity.CompareTo("valid")==0) {
194 AliInfo(Form(" validity = %s - Using offline calibration parameters",validity.Data()));
196 AliInfo(Form(" validity = %s - Using online calibration parameters",validity.Data()));
201 //------------------------------------------------------------------------
202 AliTOFClusterFinder::AliTOFClusterFinder(const AliTOFClusterFinder &source) :
208 fDigits(source.fDigits),
209 fRecPoints(source.fRecPoints),
210 fNumberOfTofClusters(0),
212 fDecoderVersion(source.fDecoderVersion),
213 fTOFcalib(source.fTOFcalib),
214 fTOFRawStream(source.fTOFRawStream)
218 for (Int_t ii=0; ii<kTofMaxCluster; ii++) fTofClusters[ii]=source.fTofClusters[ii];
222 //------------------------------------------------------------------------
223 AliTOFClusterFinder& AliTOFClusterFinder::operator=(const AliTOFClusterFinder &source)
230 TTask::operator=(source);
231 fDigits=source.fDigits;
232 fRecPoints=source.fRecPoints;
233 fVerbose=source.fVerbose;
234 fDecoderVersion=source.fDecoderVersion;
235 fTOFcalib=source.fTOFcalib;
236 fTOFRawStream=source.fTOFRawStream;
237 for (Int_t ii=0; ii<kTofMaxCluster; ii++) fTofClusters[ii]=source.fTofClusters[ii];
242 //______________________________________________________________________________
244 AliTOFClusterFinder::~AliTOFClusterFinder()
259 fRecPoints->Delete();
264 if (fTofClusters || fNumberOfTofClusters) {
265 for (Int_t ii=0; ii<fNumberOfTofClusters; ii++)
266 if (fTofClusters[ii]) fTofClusters[ii]->Delete();
267 fNumberOfTofClusters=0;
271 //______________________________________________________________________________
273 void AliTOFClusterFinder::Digits2RecPoints(Int_t iEvent)
276 // Converts digits to recpoints for TOF
279 TStopwatch stopwatch;
284 fRunLoader->GetEvent(iEvent);
286 fTreeD = fTOFLoader->TreeD();
288 AliFatal("AliTOFClusterFinder: Can not get TreeD");
293 fTreeD->GetBranch("TOF")->SetAutoDelete(kFALSE);
294 fTreeD->SetBranchAddress("TOF",&fDigits);
298 fTreeR = fTOFLoader->TreeR();
301 fTOFLoader->MakeTree("R");
302 fTreeR = fTOFLoader->TreeR();
305 Int_t bufsize = 32000;
306 fTreeR->Branch("TOF", &fRecPoints, bufsize);
309 Int_t nDigits = fDigits->GetEntriesFast();
310 AliDebug(2,Form("Number of TOF digits: %d",nDigits));
313 Int_t dig[5]={-1,-1,-1,-1,-1}; //cluster detector indeces
314 Int_t parTOF[7]={0,0,0,0,0,0,0}; //The TOF signal parameters
315 Bool_t status=kTRUE; // assume all sim channels ok in the beginning...
316 for (ii=0; ii<nDigits; ii++) {
317 AliTOFdigit *d = (AliTOFdigit*)fDigits->UncheckedAt(ii);
318 dig[0]=d->GetSector();
319 dig[1]=d->GetPlate();
320 dig[2]=d->GetStrip();
324 /* check valid index */
325 if (dig[0]==-1||dig[1]==-1||dig[2]==-1||dig[3]==-1||dig[4]==-1) continue;
327 // Do not reconstruct anything in the holes
328 if (dig[0]==13 || dig[0]==14 || dig[0]==15 ) { // sectors with holes
329 if (dig[1]==2) { // plate with holes
335 AliDebug(2,Form(" %2d %1d %2d %1d %2d ",dig[0],dig[1],dig[2],dig[3],dig[4]));
337 parTOF[0] = d->GetTdc(); //the TDC signal
338 parTOF[1] = d->GetToT(); //the ToT signal
339 parTOF[2] = d->GetAdc(); // the adc charge
340 parTOF[3] = d->GetTdcND(); // non decalibrated sim time
341 parTOF[4] = d->GetTdc(); // raw time, == Tdc time for the moment
342 parTOF[5] = 0; // deltaBC
343 parTOF[6] = 0; // L0-L1 latency
346 UShort_t volIdClus=GetClusterVolIndex(dig);
347 GetClusterPars(dig, posClus,covClus);
348 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);
349 InsertCluster(tofCluster);
353 AliDebug(1,Form("Number of found clusters: %d for event: %d", fNumberOfTofClusters, iEvent));
361 fTOFLoader = fRunLoader->GetLoader("TOFLoader");
362 fTOFLoader->WriteRecPoints("OVERWRITE");
364 AliDebug(1,Form("Execution time to read TOF digits and to write TOF clusters : R:%.4fs C:%.4fs",
365 stopwatch.RealTime(),stopwatch.CpuTime()));
366 if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
370 //______________________________________________________________________________
372 void AliTOFClusterFinder::Digits2RecPoints(TTree* digitsTree, TTree* clusterTree)
375 // Converts digits to recpoints for TOF
378 TStopwatch stopwatch;
383 if (digitsTree == 0x0) {
384 AliFatal("AliTOFClusterFinder: Can not get TreeD");
389 digitsTree->GetBranch("TOF")->SetAutoDelete(kFALSE);
390 digitsTree->SetBranchAddress("TOF",&fDigits);
393 Int_t bufsize = 32000;
394 clusterTree->Branch("TOF", &fRecPoints, bufsize);
396 digitsTree->GetEvent(0);
397 Int_t nDigits = fDigits->GetEntriesFast();
398 AliDebug(2,Form("Number of TOF digits: %d",nDigits));
401 Int_t dig[5]={-1,-1,-1,-1,-1}; //cluster detector indeces
402 Int_t parTOF[7]={0,0,0,0,0,0,0}; //The TOF signal parameters
403 Bool_t status=kTRUE; // assume all sim channels ok in the beginning...
404 for (ii=0; ii<nDigits; ii++) {
405 AliTOFdigit *d = (AliTOFdigit*)fDigits->UncheckedAt(ii);
406 dig[0]=d->GetSector();
407 dig[1]=d->GetPlate();
408 dig[2]=d->GetStrip();
412 /* check valid index */
413 if (dig[0]==-1||dig[1]==-1||dig[2]==-1||dig[3]==-1||dig[4]==-1) continue;
415 // Do not reconstruct anything in the holes
416 if (dig[0]==13 || dig[0]==14 || dig[0]==15 ) { // sectors with holes
417 if (dig[1]==2) { // plate with holes
423 // AliDebug(2,Form(" %2d %1d %2d %1d %2d ",dig[0],dig[1],dig[2],dig[3],dig[4]));
425 parTOF[0] = d->GetTdc(); //the TDC signal
426 parTOF[1] = d->GetToT(); //the ToT signal
427 parTOF[2] = d->GetAdc(); // the adc charge
428 parTOF[3] = d->GetTdcND(); // non decalibrated sim time
429 parTOF[4] = d->GetTdc(); // raw time, == Tdc time for the moment
430 parTOF[5] = 0; // deltaBC
431 parTOF[6] = 0; // L0-L1 latency
435 UShort_t volIdClus=GetClusterVolIndex(dig);
436 GetClusterPars(dig,posClus,covClus);
437 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);
438 InsertCluster(tofCluster);
442 AliDebug(1,Form("Number of found clusters: %d", fNumberOfTofClusters));
450 AliDebug(1,Form("Execution time to read TOF digits and to write TOF clusters : R:%.4fs C:%.4fs",
451 stopwatch.RealTime(),stopwatch.CpuTime()));
452 if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
455 //______________________________________________________________________________
457 void AliTOFClusterFinder::Digits2RecPoints(AliRawReader *rawReader,
461 // Converts RAW data to recpoints for TOF
464 TStopwatch stopwatch;
469 const Int_t kDDL = AliDAQ::NumberOfDdls("TOF");
473 Int_t bufsize = 32000;
474 clustersTree->Branch("TOF", &fRecPoints, bufsize);
476 TClonesArray * clonesRawData;
479 Int_t detectorIndex[5];
483 if (fVerbose==2) ftxt.open("TOFdigitsRead.txt",ios::app);
485 fTOFRawStream.Clear();
486 fTOFRawStream.SetRawReader(rawReader);
488 if (fDecoderVersion == 1) {
489 AliInfo("Using New Decoder");
491 else if (fDecoderVersion == 2) {
492 AliInfo("Using Enhanced Decoder");
495 AliInfo("Using Old Decoder");
499 for (indexDDL = 0; indexDDL < kDDL; indexDDL++) {
502 if (fDecoderVersion == 1) {
503 fTOFRawStream.LoadRawDataBuffers(indexDDL,fVerbose);
505 else if (fDecoderVersion == 2) {
506 fTOFRawStream.LoadRawDataBuffersV2(indexDDL,fVerbose);
509 fTOFRawStream.LoadRawData(indexDDL);
512 clonesRawData = (TClonesArray*)fTOFRawStream.GetRawData();
514 for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
516 AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
518 //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
519 if (tofRawDatum->GetTOF()==-1) continue;
522 if (indexDDL<10) ftxt << " " << indexDDL;
523 else ftxt << " " << indexDDL;
524 if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM();
525 else ftxt << " " << tofRawDatum->GetTRM();
526 ftxt << " " << tofRawDatum->GetTRMchain();
527 if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC();
528 else ftxt << " " << tofRawDatum->GetTDC();
529 ftxt << " " << tofRawDatum->GetTDCchannel();
532 fTOFRawStream.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
533 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
534 dummy = detectorIndex[3];
535 detectorIndex[3] = detectorIndex[4];
536 detectorIndex[4] = dummy;
539 if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0];
540 else ftxt << " -> " << detectorIndex[0];
541 ftxt << " " << detectorIndex[1];
542 if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2];
543 else ftxt << " " << detectorIndex[2];
544 ftxt << " " << detectorIndex[3];
545 if (detectorIndex[4]<10) ftxt << " " << detectorIndex[4];
546 else ftxt << " " << detectorIndex[4];
549 /* check valid index */
550 if (detectorIndex[0]==-1||detectorIndex[1]==-1||detectorIndex[2]==-1||detectorIndex[3]==-1||detectorIndex[4]==-1) continue;
552 // Do not reconstruct anything in the holes
553 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
554 if (detectorIndex[1]==2) { // plate with holes
560 parTOF[0] = tofRawDatum->GetTOF(); //TDC
561 parTOF[1] = tofRawDatum->GetTOT(); // TOT
562 parTOF[2] = tofRawDatum->GetTOT(); //ADC==TOF
563 parTOF[3] = 0;//raw data: no track of undecalib sim time
564 parTOF[4] = tofRawDatum->GetTOF(); // RAW time
565 parTOF[5] = tofRawDatum->GetDeltaBC(); // deltaBC
566 parTOF[6] = tofRawDatum->GetL0L1Latency(); // L0-L1 latency
569 UShort_t volIdClus=GetClusterVolIndex(detectorIndex);
570 Int_t lab[3]={-1,-1,-1};
572 GetClusterPars(detectorIndex,posClus,covClus);
573 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);
574 InsertCluster(tofCluster);
577 if (parTOF[1]<10)ftxt << " " << parTOF[1];
578 else if (parTOF[1]>=10 && parTOF[1]<100) ftxt << " " << parTOF[1];
579 else ftxt << " " << parTOF[1];
580 if (parTOF[0]<10) ftxt << " " << parTOF[0] << endl;
581 else if (parTOF[0]>=10 && parTOF[0]<100) ftxt << " " << parTOF[0] << endl;
582 else if (parTOF[0]>=100 && parTOF[0]<1000) ftxt << " " << parTOF[0] << endl;
583 else ftxt << " " << parTOF[3] << endl;
586 } // closed loop on TOF raw data per current DDL file
588 clonesRawData->Clear("C");
590 } // closed loop on DDL index
592 if (fVerbose==2) ftxt.close();
594 AliDebug(1,Form("Number of found clusters: %d", fNumberOfTofClusters));
596 CalibrateRecPoint(rawReader->GetTimestamp());
599 clustersTree->Fill();
603 AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters : R:%.4fs C:%.4fs",
604 stopwatch.RealTime(),stopwatch.CpuTime()));
605 if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
608 //______________________________________________________________________________
610 void AliTOFClusterFinder::Digits2RecPoints(Int_t iEvent, AliRawReader *rawReader)
613 // Converts RAW data to recpoints for TOF
616 TStopwatch stopwatch;
621 const Int_t kDDL = AliDAQ::NumberOfDdls("TOF");
623 fRunLoader->GetEvent(iEvent);
625 AliDebug(2,Form(" Event number %2d ", iEvent));
627 fTreeR = fTOFLoader->TreeR();
630 fTOFLoader->MakeTree("R");
631 fTreeR = fTOFLoader->TreeR();
634 Int_t bufsize = 32000;
635 fTreeR->Branch("TOF", &fRecPoints, bufsize);
637 TClonesArray * clonesRawData;
641 Int_t detectorIndex[5] = {-1, -1, -1, -1, -1};
644 if (fVerbose==2) ftxt.open("TOFdigitsRead.txt",ios::app);
646 fTOFRawStream.Clear();
647 fTOFRawStream.SetRawReader(rawReader);
649 if (fDecoderVersion == 1) {
650 AliInfo("Using New Decoder");
652 else if (fDecoderVersion == 2) {
653 AliInfo("Using Enhanced Decoder");
656 AliInfo("Using Old Decoder");
660 for (indexDDL = 0; indexDDL < kDDL; indexDDL++) {
663 if (fDecoderVersion == 1) {
664 fTOFRawStream.LoadRawDataBuffers(indexDDL,fVerbose);
666 else if (fDecoderVersion == 2) {
667 fTOFRawStream.LoadRawDataBuffersV2(indexDDL,fVerbose);
670 fTOFRawStream.LoadRawData(indexDDL);
673 clonesRawData = (TClonesArray*)fTOFRawStream.GetRawData();
675 for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
677 AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
679 //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
680 if (tofRawDatum->GetTOF()==-1) continue;
683 if (indexDDL<10) ftxt << " " << indexDDL;
684 else ftxt << " " << indexDDL;
685 if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM();
686 else ftxt << " " << tofRawDatum->GetTRM();
687 ftxt << " " << tofRawDatum->GetTRMchain();
688 if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC();
689 else ftxt << " " << tofRawDatum->GetTDC();
690 ftxt << " " << tofRawDatum->GetTDCchannel();
693 fTOFRawStream.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
694 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
695 dummy = detectorIndex[3];
696 detectorIndex[3] = detectorIndex[4];
697 detectorIndex[4] = dummy;
700 if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0];
701 else ftxt << " -> " << detectorIndex[0];
702 ftxt << " " << detectorIndex[1];
703 if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2];
704 else ftxt << " " << detectorIndex[2];
705 ftxt << " " << detectorIndex[3];
706 if (detectorIndex[4]<10) ftxt << " " << detectorIndex[4];
707 else ftxt << " " << detectorIndex[4];
710 /* check valid index */
711 if (detectorIndex[0]==-1||detectorIndex[1]==-1||detectorIndex[2]==-1||detectorIndex[3]==-1||detectorIndex[4]==-1) continue;
713 // Do not reconstruct anything in the holes
714 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
715 if (detectorIndex[1]==2) { // plate with holes
721 parTOF[0] = tofRawDatum->GetTOF(); // TDC
722 parTOF[1] = tofRawDatum->GetTOT(); // TOT
723 parTOF[2] = tofRawDatum->GetTOT(); // raw data have ADC=TOT
724 parTOF[3] = 0; //raw data: no track of the undecalib sim time
725 parTOF[4] = tofRawDatum->GetTOF(); // Raw time == TDC
726 parTOF[5] = tofRawDatum->GetDeltaBC(); // deltaBC
727 parTOF[6] = tofRawDatum->GetL0L1Latency(); // L0-L1 latency
730 UShort_t volIdClus=GetClusterVolIndex(detectorIndex);
731 Int_t lab[3]={-1,-1,-1};
733 GetClusterPars(detectorIndex,posClus,covClus);
734 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);
735 InsertCluster(tofCluster);
738 if (parTOF[1]<10)ftxt << " " << parTOF[1];
739 else if (parTOF[1]>=10 && parTOF[1]<100) ftxt << " " << parTOF[1];
740 else ftxt << " " << parTOF[1];
741 if (parTOF[0]<10) ftxt << " " << parTOF[0] << endl;
742 else if (parTOF[0]>=10 && parTOF[0]<100) ftxt << " " << parTOF[0] << endl;
743 else if (parTOF[0]>=100 && parTOF[0]<1000) ftxt << " " << parTOF[0] << endl;
744 else ftxt << " " << parTOF[3] << endl;
747 } // closed loop on TOF raw data per current DDL file
749 clonesRawData->Clear("C");
751 } // closed loop on DDL index
753 if (fVerbose==2) ftxt.close();
755 AliDebug(1,Form("Number of found clusters: %d for event: %d", fNumberOfTofClusters, iEvent));
757 CalibrateRecPoint(rawReader->GetTimestamp());
763 fTOFLoader = fRunLoader->GetLoader("TOFLoader");
764 fTOFLoader->WriteRecPoints("OVERWRITE");
766 AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters : R:%.4fs C:%.4fs",
767 stopwatch.RealTime(),stopwatch.CpuTime()));
768 if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
771 //______________________________________________________________________________
773 void AliTOFClusterFinder::Raw2Digits(Int_t iEvent, AliRawReader *rawReader)
776 // Converts RAW data to MC digits for TOF
778 // (temporary solution)
781 TStopwatch stopwatch;
784 const Int_t kDDL = AliTOFGeometry::NDDL()*AliTOFGeometry::NSectors();
786 fRunLoader->GetEvent(iEvent);
788 fTreeD = fTOFLoader->TreeD();
791 AliInfo("TreeD re-creation");
793 fTOFLoader->MakeTree("D");
794 fTreeD = fTOFLoader->TreeD();
797 Int_t bufsize = 32000;
799 fTreeD->Branch("TOF", &fDigits, bufsize);
801 fRunLoader->GetEvent(iEvent);
803 AliDebug(2,Form(" Event number %2d ", iEvent));
805 TClonesArray * clonesRawData;
809 Int_t detectorIndex[5];
812 fTOFRawStream.Clear();
813 fTOFRawStream.SetRawReader(rawReader);
815 if (fDecoderVersion == 1) {
816 AliInfo("Using New Decoder");
818 else if (fDecoderVersion == 2) {
819 AliInfo("Using Enhanced Decoder");
822 AliInfo("Using Old Decoder");
826 for (indexDDL = 0; indexDDL < kDDL; indexDDL++) {
829 if (fDecoderVersion == 1) {
830 fTOFRawStream.LoadRawDataBuffers(indexDDL,fVerbose);
832 else if (fDecoderVersion == 2) {
833 fTOFRawStream.LoadRawDataBuffersV2(indexDDL,fVerbose);
836 fTOFRawStream.LoadRawData(indexDDL);
839 clonesRawData = (TClonesArray*)fTOFRawStream.GetRawData();
841 for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
843 AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
845 //if (!tofRawDatum->GetTOT() || !tofRawDatum->GetTOF()) continue;
846 if (tofRawDatum->GetTOF()==-1) continue;
848 fTOFRawStream.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
849 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
850 dummy = detectorIndex[3];
851 detectorIndex[3] = detectorIndex[4];
852 detectorIndex[4] = dummy;
854 digit[0] = fTOFRawStream.GetTofBin();
855 digit[1] = fTOFRawStream.GetToTbin();
856 digit[2] = fTOFRawStream.GetToTbin();
859 Int_t tracknum[3]={-1,-1,-1};
861 TClonesArray &aDigits = *fDigits;
862 Int_t last=fDigits->GetEntriesFast();
863 new (aDigits[last]) AliTOFdigit(tracknum, detectorIndex, digit);
867 clonesRawData->Clear("C");
873 fTOFLoader = fRunLoader->GetLoader("TOFLoader");
874 fTOFLoader->WriteDigits("OVERWRITE");
876 AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters : R:%.2fs C:%.2fs",
877 stopwatch.RealTime(),stopwatch.CpuTime()));
881 //______________________________________________________________________________
883 void AliTOFClusterFinder::Raw2Digits(AliRawReader *rawReader, TTree* digitsTree)
886 // Converts RAW data to MC digits for TOF for the current event
890 TStopwatch stopwatch;
893 const Int_t kDDL = AliTOFGeometry::NDDL()*AliTOFGeometry::NSectors();
897 AliError("No input digits Tree");
901 Int_t bufsize = 32000;
902 digitsTree->Branch("TOF", &fDigits, bufsize);
904 TClonesArray * clonesRawData;
907 Int_t detectorIndex[5];
910 fTOFRawStream.Clear();
911 fTOFRawStream.SetRawReader(rawReader);
913 if (fDecoderVersion == 1) {
914 AliInfo("Using New Decoder");
916 else if (fDecoderVersion == 2) {
917 AliInfo("Using Enhanced Decoder");
920 AliInfo("Using Old Decoder");
924 for (indexDDL = 0; indexDDL < kDDL; indexDDL++) {
927 if (fDecoderVersion == 1) {
928 fTOFRawStream.LoadRawDataBuffers(indexDDL,fVerbose);
930 else if (fDecoderVersion == 2) {
931 fTOFRawStream.LoadRawDataBuffersV2(indexDDL,fVerbose);
934 fTOFRawStream.LoadRawData(indexDDL);
937 clonesRawData = (TClonesArray*)fTOFRawStream.GetRawData();
939 for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
941 AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
943 //if (!tofRawDatum->GetTOT() || !tofRawDatum->GetTOF()) continue;
944 if (tofRawDatum->GetTOF()==-1) continue;
946 fTOFRawStream.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
947 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
948 dummy = detectorIndex[3];
949 detectorIndex[3] = detectorIndex[4];
950 detectorIndex[4] = dummy;
952 digit[0] = fTOFRawStream.GetTofBin();
953 digit[1] = fTOFRawStream.GetToTbin();
954 digit[2] = fTOFRawStream.GetToTbin();
957 Int_t tracknum[3]={-1,-1,-1};
959 TClonesArray &aDigits = *fDigits;
960 Int_t last=fDigits->GetEntriesFast();
961 new (aDigits[last]) AliTOFdigit(tracknum, detectorIndex, digit);
965 clonesRawData->Clear("C");
971 AliDebug(1, Form("Got %d digits: ", fDigits->GetEntries()));
972 AliDebug(1, Form("Execution time to read TOF raw data and fill TOF digit tree : R:%.2fs C:%.2fs",
973 stopwatch.RealTime(),stopwatch.CpuTime()));
976 //______________________________________________________________________________
978 Int_t AliTOFClusterFinder::InsertCluster(AliTOFcluster *tofCluster) {
979 //---------------------------------------------------------------------------//
980 // This function adds a TOF cluster to the array of TOF clusters sorted in Z //
981 //---------------------------------------------------------------------------//
982 if (fNumberOfTofClusters==kTofMaxCluster) {
983 AliError("Too many clusters !");
987 if (fNumberOfTofClusters==0) {
988 fTofClusters[fNumberOfTofClusters++] = tofCluster;
992 Int_t ii = FindClusterIndex(tofCluster->GetZ());
993 memmove(fTofClusters+ii+1 ,fTofClusters+ii,(fNumberOfTofClusters-ii)*sizeof(AliTOFcluster*));
994 fTofClusters[ii] = tofCluster;
995 fNumberOfTofClusters++;
1000 //_________________________________________________________________________
1002 Int_t AliTOFClusterFinder::FindClusterIndex(Double_t z) const {
1003 //--------------------------------------------------------------------
1004 // This function returns the index of the nearest cluster in z
1005 //--------------------------------------------------------------------
1006 if (fNumberOfTofClusters==0) return 0;
1007 if (z <= fTofClusters[0]->GetZ()) return 0;
1008 if (z > fTofClusters[fNumberOfTofClusters-1]->GetZ()) return fNumberOfTofClusters;
1009 Int_t b = 0, e = fNumberOfTofClusters-1, m = (b+e)/2;
1010 for (; b<e; m=(b+e)/2) {
1011 if (z > fTofClusters[m]->GetZ()) b=m+1;
1018 //_________________________________________________________________________
1020 void AliTOFClusterFinder::FillRecPoint()
1023 // Copy the global array of AliTOFcluster, i.e. fTofClusters (sorted
1024 // in Z) in the global TClonesArray of AliTOFcluster,
1030 Int_t detectorIndex[5];
1032 Int_t trackLabels[3];
1033 Int_t digitIndex = -1;
1034 Bool_t status=kTRUE;
1036 TClonesArray &lRecPoints = *fRecPoints;
1038 for (ii=0; ii<fNumberOfTofClusters; ii++) {
1040 digitIndex = fTofClusters[ii]->GetIndex();
1041 for(jj=0; jj<5; jj++) detectorIndex[jj] = fTofClusters[ii]->GetDetInd(jj);
1042 for(jj=0; jj<3; jj++) trackLabels[jj] = fTofClusters[ii]->GetLabel(jj);
1043 parTOF[0] = fTofClusters[ii]->GetTDC(); // TDC
1044 parTOF[1] = fTofClusters[ii]->GetToT(); // TOT
1045 parTOF[2] = fTofClusters[ii]->GetADC(); // ADC=TOT
1046 parTOF[3] = fTofClusters[ii]->GetTDCND(); // TDCND
1047 parTOF[4] = fTofClusters[ii]->GetTDCRAW();//RAW
1048 parTOF[5] = fTofClusters[ii]->GetDeltaBC();//deltaBC
1049 parTOF[6] = fTofClusters[ii]->GetL0L1Latency();//L0-L1 latency
1050 status=fTofClusters[ii]->GetStatus();
1051 Double_t posClus[3];
1052 Double_t covClus[6];
1053 UShort_t volIdClus=GetClusterVolIndex(detectorIndex);
1054 GetClusterPars(detectorIndex,posClus,covClus);
1055 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);
1057 AliDebug(2, Form(" %4d %4d %f %f %f %f %f %f %f %f %f %3d %3d %3d %2d %1d %2d %1d %2d %4d %3d %3d %4d %4d %1d %4d",
1058 ii, volIdClus, posClus[0], posClus[1], posClus[2],
1059 fTofClusters[ii]->GetSigmaX2(),
1060 fTofClusters[ii]->GetSigmaXY(),
1061 fTofClusters[ii]->GetSigmaXZ(),
1062 fTofClusters[ii]->GetSigmaY2(),
1063 fTofClusters[ii]->GetSigmaYZ(),
1064 fTofClusters[ii]->GetSigmaZ2(),
1065 trackLabels[0], trackLabels[1], trackLabels[2],
1066 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[3], detectorIndex[4],
1067 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
1068 status, digitIndex));
1070 } // loop on clusters
1074 //_________________________________________________________________________
1077 * OLD CALIBRATE REC POINTS FUNCTION
1081 void AliTOFClusterFinder::CalibrateRecPoint(UInt_t timestamp)
1084 // Copy the global array of AliTOFcluster, i.e. fTofClusters (sorted
1085 // in Z) in the global TClonesArray of AliTOFcluster,
1091 Int_t detectorIndex[5];
1092 Int_t digitIndex = -1;
1096 Float_t tdcLatencyWindow;
1097 AliDebug(1," Calibrating TOF Clusters");
1099 AliTOFChannelOnlineArray *calDelay = fTOFcalib->GetTOFOnlineDelay();
1100 AliTOFChannelOnlineStatusArray *calStatus = fTOFcalib->GetTOFOnlineStatus();
1101 TObjArray *calTOFArrayOffline = fTOFcalib->GetTOFCalArrayOffline();
1103 AliTOFDeltaBCOffset *deltaBCOffsetObj = fTOFcalib->GetDeltaBCOffset();
1104 Int_t deltaBCOffset = deltaBCOffsetObj->GetDeltaBCOffset();
1105 AliTOFCTPLatency *ctpLatencyObj = fTOFcalib->GetCTPLatency();
1106 Float_t ctpLatency = ctpLatencyObj->GetCTPLatency();
1107 AliTOFRunParams *runParamsObj = fTOFcalib->GetRunParams();
1108 Float_t t0 = runParamsObj->EvalT0(timestamp);
1110 TString validity = (TString)fTOFcalib->GetOfflineValidity();
1111 Int_t calibration = -1;
1112 if (validity.CompareTo("valid")==0) {
1113 //AliInfo(Form(" validity = %s - Using offline calibration parameters",validity.Data()));
1116 //AliInfo(Form(" validity = %s - Using online calibration parameters",validity.Data()));
1120 for (ii=0; ii<fNumberOfTofClusters; ii++) {
1121 digitIndex = fTofClusters[ii]->GetIndex();
1122 for(jj=0; jj<5; jj++) detectorIndex[jj] = fTofClusters[ii]->GetDetInd(jj);
1124 Int_t index = AliTOFGeometry::GetIndex(detectorIndex);
1126 UChar_t statusPulser=calStatus->GetPulserStatus(index);
1127 UChar_t statusNoise=calStatus->GetNoiseStatus(index);
1128 UChar_t statusHW=calStatus->GetHWStatus(index);
1129 UChar_t status=calStatus->GetStatus(index);
1130 tdcLatencyWindow = calStatus->GetLatencyWindow(index) * 1.e3; /* ns -> ps */
1132 //check the status, also unknown is fine!!!!!!!
1134 AliDebug(2, Form(" Status for channel %d = %d",index, (Int_t)status));
1135 if((statusPulser & AliTOFChannelOnlineStatusArray::kTOFPulserBad)==(AliTOFChannelOnlineStatusArray::kTOFPulserBad)||(statusNoise & AliTOFChannelOnlineStatusArray::kTOFNoiseBad)==(AliTOFChannelOnlineStatusArray::kTOFNoiseBad)||(statusHW & AliTOFChannelOnlineStatusArray::kTOFHWBad)==(AliTOFChannelOnlineStatusArray::kTOFHWBad)){
1136 AliDebug(2, Form(" Bad Status for channel %d",index));
1137 fTofClusters[ii]->SetStatus(kFALSE); //odd convention, to avoid conflict with calibration objects currently in the db (temporary solution).
1140 AliDebug(2, Form(" Good Status for channel %d",index));
1142 // Get Rough channel online equalization
1143 Double_t roughDelay=(Double_t)calDelay->GetDelay(index); // in ns
1144 AliDebug(2,Form(" channel delay (ns) = %f", roughDelay));
1145 // Get Refined channel offline calibration parameters
1146 if (calibration ==1){
1147 AliTOFChannelOffline * calChannelOffline = (AliTOFChannelOffline*)calTOFArrayOffline->At(index);
1149 for (Int_t j = 0; j<6; j++){
1150 par[j]=(Double_t)calChannelOffline->GetSlewPar(j);
1152 AliDebug(2,Form(" Calib Pars = %f, %f, %f, %f, %f, %f ",par[0],par[1],par[2],par[3],par[4],par[5]));
1153 AliDebug(2,Form(" The ToT and Time, uncorr (counts) = %d , %d", fTofClusters[ii]->GetToT(),fTofClusters[ii]->GetTDC()));
1154 tToT = (Double_t)(fTofClusters[ii]->GetToT()*AliTOFGeometry::ToTBinWidth());
1155 tToT*=1.E-3; //ToT in ns
1157 /* check TOT limits and set new TOT in case */
1158 if (tToT < AliTOFGeometry::SlewTOTMin()) tToT = AliTOFGeometry::SlewTOTMin();
1159 if (tToT > AliTOFGeometry::SlewTOTMax()) tToT = AliTOFGeometry::SlewTOTMax();
1161 AliDebug(2,Form(" The ToT and Time, uncorr (ns)= %e, %e",fTofClusters[ii]->GetTDC()*AliTOFGeometry::TdcBinWidth()*1.E-3,tToT));
1162 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)
1165 timeCorr = roughDelay; // correction in ns
1167 AliDebug(2,Form(" The ToT and Time, uncorr (ns)= %e, %e",fTofClusters[ii]->GetTDC()*AliTOFGeometry::TdcBinWidth()*1.E-3,fTofClusters[ii]->GetToT()*AliTOFGeometry::ToTBinWidth()));
1168 AliDebug(2,Form(" The time correction (ns) = %f", timeCorr));
1169 timeCorr=(Double_t)(fTofClusters[ii]->GetTDC())*AliTOFGeometry::TdcBinWidth()*1.E-3-timeCorr;//redefine the time
1171 AliDebug(2,Form(" The channel time, corr (ps)= %e",timeCorr ));
1173 /* here timeCorr should be already corrected for calibration.
1174 * we now go into further corrections keeping in mind that timeCorr
1177 * the following corrections are performed in this way:
1179 * time = timeRaw - deltaBC + L0L1Latency + CTPLatency - TDCLatencyWindow - T0
1183 AliDebug(2, Form("applying further corrections (DeltaBC): DeltaBC=%d (BC bins), DeltaBCoffset=%d (BC bins)", fTofClusters[ii]->GetDeltaBC(), deltaBCOffset));
1184 AliDebug(2, Form("applying further corrections (L0L1Latency): L0L1Latency=%d (BC bins)", fTofClusters[ii]->GetL0L1Latency()));
1185 AliDebug(2, Form("applying further corrections (CTPLatency): CTPLatency=%f (ps)", ctpLatency));
1186 AliDebug(2, Form("applying further corrections (TDCLatencyWindow): TDCLatencyWindow=%f (ps)", tdcLatencyWindow));
1187 AliDebug(2, Form("applying further corrections (T0): T0=%f (ps)", t0));
1189 /* deltaBC correction (inhibited for the time being) */
1190 // timeCorr -= (fTofClusters[ii]->GetDeltaBC() - deltaBCOffset) * AliTOFGeometry::BunchCrossingBinWidth();
1191 /* L0L1-latency correction */
1192 timeCorr += fTofClusters[ii]->GetL0L1Latency() * AliTOFGeometry::BunchCrossingBinWidth();
1193 /* CTP-latency correction (from OCDB) */
1194 timeCorr += ctpLatency;
1195 /* TDC latency-window correction (from OCDB) */
1196 timeCorr -= tdcLatencyWindow;
1197 /* T0 correction (from OCDB) */
1201 * end of furhter corrections
1204 tdcCorr=(Int_t)(timeCorr/AliTOFGeometry::TdcBinWidth()); //the corrected time (tdc counts)
1205 fTofClusters[ii]->SetTDC(tdcCorr);
1206 } // loop on clusters
1211 //_________________________________________________________________________
1213 void AliTOFClusterFinder::CalibrateRecPoint(UInt_t timestamp)
1216 // Copy the global array of AliTOFcluster, i.e. fTofClusters (sorted
1217 // in Z) in the global TClonesArray of AliTOFcluster,
1221 Int_t detectorIndex[5];
1222 Double_t time, tot, corr;
1223 Int_t deltaBC, l0l1, tdcBin;
1224 for (Int_t ii = 0; ii < fNumberOfTofClusters; ii++) {
1225 for(Int_t jj = 0; jj < 5; jj++) detectorIndex[jj] = fTofClusters[ii]->GetDetInd(jj);
1227 Int_t index = AliTOFGeometry::GetIndex(detectorIndex);
1229 /* check channel enabled */
1230 if (!fTOFcalib->IsChannelEnabled(index)) fTofClusters[ii]->SetStatus(kFALSE);
1232 /* get cluster info */
1233 time = fTofClusters[ii]->GetTDC() * AliTOFGeometry::TdcBinWidth(); /* ps */
1234 tot = fTofClusters[ii]->GetToT() * AliTOFGeometry::ToTBinWidth() * 1.e-3; /* ns */
1235 deltaBC = fTofClusters[ii]->GetDeltaBC();
1236 l0l1 = fTofClusters[ii]->GetL0L1Latency();
1238 /* get correction */
1239 corr = fTOFcalib->GetTimeCorrection(index, tot, deltaBC, l0l1, timestamp); /* ps */
1240 AliDebug(2, Form("calibrate index %d: time=%f (ps) tot=%f (ns) deltaBC=%d l0l1=%d timestamp=%d corr=%f (ps)", index, time, tot, deltaBC, l0l1, timestamp, corr));
1242 /* apply time correction */
1245 /* convert in TDC bins and set cluster */
1246 //tdcBin = (Int_t)(time / AliTOFGeometry::TdcBinWidth()); //the corrected time (tdc counts)
1247 tdcBin = TMath::Nint(time / AliTOFGeometry::TdcBinWidth()); //the corrected time (tdc counts)
1248 fTofClusters[ii]->SetTDC(tdcBin);
1250 } // loop on clusters
1254 //______________________________________________________________________________
1256 void AliTOFClusterFinder::ResetRecpoint()
1259 // Clear the list of reconstructed points
1262 fNumberOfTofClusters = 0;
1263 if (fRecPoints) fRecPoints->Clear();
1266 //______________________________________________________________________________
1268 void AliTOFClusterFinder::Load()
1271 // Load TOF.Digits.root and TOF.RecPoints.root files
1274 fTOFLoader->LoadDigits("READ");
1275 fTOFLoader->LoadRecPoints("recreate");
1278 //______________________________________________________________________________
1280 void AliTOFClusterFinder::LoadClusters()
1283 // Load TOF.RecPoints.root file
1286 fTOFLoader->LoadRecPoints("recreate");
1289 //______________________________________________________________________________
1291 void AliTOFClusterFinder::UnLoad()
1294 // Unload TOF.Digits.root and TOF.RecPoints.root files
1297 fTOFLoader->UnloadDigits();
1298 fTOFLoader->UnloadRecPoints();
1301 //______________________________________________________________________________
1303 void AliTOFClusterFinder::UnLoadClusters()
1306 // Unload TOF.RecPoints.root file
1309 fTOFLoader->UnloadRecPoints();
1312 //-------------------------------------------------------------------------
1313 UShort_t AliTOFClusterFinder::GetClusterVolIndex(const Int_t * const ind) const {
1315 //First of all get the volume ID to retrieve the l2t transformation...
1317 // Detector numbering scheme
1324 Int_t isector =ind[0];
1325 if (isector >= nSector)
1326 AliError(Form("Wrong sector number in TOF (%d) !",isector));
1327 Int_t iplate = ind[1];
1328 if (iplate >= nPlate)
1329 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
1330 Int_t istrip = ind[2];
1332 Int_t stripOffset = 0;
1338 stripOffset = nStripC;
1341 stripOffset = nStripC+nStripB;
1344 stripOffset = nStripC+nStripB+nStripA;
1347 stripOffset = nStripC+nStripB+nStripA+nStripB;
1350 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
1354 Int_t index= (2*(nStripC+nStripB)+nStripA)*isector +
1358 UShort_t volIndex = AliGeomManager::LayerToVolUID(AliGeomManager::kTOF,index);
1362 //-------------------------------------------------------------------------
1363 void AliTOFClusterFinder::GetClusterPars(Int_t *ind, Double_t* pos,Double_t* cov) const {
1365 //First of all get the volume ID to retrieve the l2t transformation...
1367 UShort_t volIndex = GetClusterVolIndex(ind);
1370 //we now go in the system of the strip: determine the local coordinates
1373 // 47---------------------------------------------------0 ^ z
1374 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 1 |
1375 // ----------------------------------------------------- | y going outwards
1376 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 0 | par[0]=0;
1378 // ----------------------------------------------------- |
1379 // x <-----------------------------------------------------
1382 Float_t localX = (ind[4]-23.5)*AliTOFGeometry::XPad();
1384 Float_t localZ = (ind[3]- 0.5)*AliTOFGeometry::ZPad();
1386 Float_t localX = (ind[4]-AliTOFGeometry::NpadX()/2)*AliTOFGeometry::XPad()+AliTOFGeometry::XPad()/2.;
1388 Float_t localZ = (ind[3]-AliTOFGeometry::NpadZ()/2)*AliTOFGeometry::ZPad()+AliTOFGeometry::ZPad()/2.;
1389 //move to the tracking ref system
1396 const TGeoHMatrix *l2t= AliGeomManager::GetTracking2LocalMatrix(volIndex);
1397 // Get The position in the track ref system
1399 l2t->MasterToLocal(lpos,tpos);
1404 //Get The cluster covariance in the track ref system
1407 //cluster covariance in the local system:
1412 lcov[0] = AliTOFGeometry::XPad()*AliTOFGeometry::XPad()/12.;
1420 lcov[8] = AliTOFGeometry::ZPad()*AliTOFGeometry::ZPad()/12.;
1422 //cluster covariance in the tracking system:
1424 m.SetRotation(lcov);
1426 m.MultiplyLeft(&l2t->Inverse());
1427 Double_t *tcov = m.GetRotationMatrix();
1428 cov[0] = tcov[0]; cov[1] = tcov[1]; cov[2] = tcov[2];
1429 cov[3] = tcov[4]; cov[4] = tcov[5];