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 if (fNumberOfTofClusters) {
266 for (Int_t ii=0; ii<fNumberOfTofClusters; ii++)
267 if (fTofClusters[ii]) fTofClusters[ii]->Delete();
268 fNumberOfTofClusters=0;
272 //______________________________________________________________________________
274 void AliTOFClusterFinder::Digits2RecPoints(Int_t iEvent)
277 // Converts digits to recpoints for TOF
280 TStopwatch stopwatch;
285 fRunLoader->GetEvent(iEvent);
287 fTreeD = fTOFLoader->TreeD();
289 AliFatal("AliTOFClusterFinder: Can not get TreeD");
294 fTreeD->GetBranch("TOF")->SetAutoDelete(kFALSE);
295 fTreeD->SetBranchAddress("TOF",&fDigits);
299 fTreeR = fTOFLoader->TreeR();
302 fTOFLoader->MakeTree("R");
303 fTreeR = fTOFLoader->TreeR();
306 Int_t bufsize = 32000;
307 fTreeR->Branch("TOF", &fRecPoints, bufsize);
310 Int_t nDigits = fDigits->GetEntriesFast();
311 AliDebug(2,Form("Number of TOF digits: %d",nDigits));
314 Int_t dig[5]={-1,-1,-1,-1,-1}; //cluster detector indeces
315 Int_t parTOF[7]={0,0,0,0,0,0,0}; //The TOF signal parameters
316 Bool_t status=kTRUE; // assume all sim channels ok in the beginning...
317 for (ii=0; ii<nDigits; ii++) {
318 AliTOFdigit *d = (AliTOFdigit*)fDigits->UncheckedAt(ii);
319 dig[0]=d->GetSector();
320 dig[1]=d->GetPlate();
321 dig[2]=d->GetStrip();
325 /* check valid index */
326 if (dig[0]==-1||dig[1]==-1||dig[2]==-1||dig[3]==-1||dig[4]==-1) continue;
328 // Do not reconstruct anything in the holes
329 if (dig[0]==13 || dig[0]==14 || dig[0]==15 ) { // sectors with holes
330 if (dig[1]==2) { // plate with holes
336 AliDebug(2,Form(" %2d %1d %2d %1d %2d ",dig[0],dig[1],dig[2],dig[3],dig[4]));
338 parTOF[0] = d->GetTdc(); //the TDC signal
339 parTOF[1] = d->GetToT(); //the ToT signal
340 parTOF[2] = d->GetAdc(); // the adc charge
341 parTOF[3] = d->GetTdcND(); // non decalibrated sim time
342 parTOF[4] = d->GetTdc(); // raw time, == Tdc time for the moment
343 parTOF[5] = 0; // deltaBC
344 parTOF[6] = 0; // L0-L1 latency
347 UShort_t volIdClus=GetClusterVolIndex(dig);
348 GetClusterPars(dig, posClus,covClus);
349 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);
350 InsertCluster(tofCluster);
354 AliDebug(1,Form("Number of found clusters: %d for event: %d", fNumberOfTofClusters, iEvent));
362 fTOFLoader = fRunLoader->GetLoader("TOFLoader");
363 fTOFLoader->WriteRecPoints("OVERWRITE");
365 AliDebug(1,Form("Execution time to read TOF digits and to write TOF clusters : R:%.4fs C:%.4fs",
366 stopwatch.RealTime(),stopwatch.CpuTime()));
367 if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
371 //______________________________________________________________________________
373 void AliTOFClusterFinder::Digits2RecPoints(TTree* digitsTree, TTree* clusterTree)
376 // Converts digits to recpoints for TOF
379 TStopwatch stopwatch;
384 if (digitsTree == 0x0) {
385 AliFatal("AliTOFClusterFinder: Can not get TreeD");
390 digitsTree->GetBranch("TOF")->SetAutoDelete(kFALSE);
391 digitsTree->SetBranchAddress("TOF",&fDigits);
394 Int_t bufsize = 32000;
395 clusterTree->Branch("TOF", &fRecPoints, bufsize);
397 digitsTree->GetEvent(0);
398 Int_t nDigits = fDigits->GetEntriesFast();
399 AliDebug(2,Form("Number of TOF digits: %d",nDigits));
402 Int_t dig[5]={-1,-1,-1,-1,-1}; //cluster detector indeces
403 Int_t parTOF[7]={0,0,0,0,0,0,0}; //The TOF signal parameters
404 Bool_t status=kTRUE; // assume all sim channels ok in the beginning...
405 for (ii=0; ii<nDigits; ii++) {
406 AliTOFdigit *d = (AliTOFdigit*)fDigits->UncheckedAt(ii);
407 dig[0]=d->GetSector();
408 dig[1]=d->GetPlate();
409 dig[2]=d->GetStrip();
413 /* check valid index */
414 if (dig[0]==-1||dig[1]==-1||dig[2]==-1||dig[3]==-1||dig[4]==-1) continue;
416 // Do not reconstruct anything in the holes
417 if (dig[0]==13 || dig[0]==14 || dig[0]==15 ) { // sectors with holes
418 if (dig[1]==2) { // plate with holes
424 // AliDebug(2,Form(" %2d %1d %2d %1d %2d ",dig[0],dig[1],dig[2],dig[3],dig[4]));
426 parTOF[0] = d->GetTdc(); //the TDC signal
427 parTOF[1] = d->GetToT(); //the ToT signal
428 parTOF[2] = d->GetAdc(); // the adc charge
429 parTOF[3] = d->GetTdcND(); // non decalibrated sim time
430 parTOF[4] = d->GetTdc(); // raw time, == Tdc time for the moment
431 parTOF[5] = 0; // deltaBC
432 parTOF[6] = 0; // L0-L1 latency
436 UShort_t volIdClus=GetClusterVolIndex(dig);
437 GetClusterPars(dig,posClus,covClus);
438 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);
439 InsertCluster(tofCluster);
443 AliDebug(1,Form("Number of found clusters: %d", fNumberOfTofClusters));
451 AliDebug(1,Form("Execution time to read TOF digits and to write TOF clusters : R:%.4fs C:%.4fs",
452 stopwatch.RealTime(),stopwatch.CpuTime()));
453 if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
456 //______________________________________________________________________________
458 void AliTOFClusterFinder::Digits2RecPoints(AliRawReader *rawReader,
462 // Converts RAW data to recpoints for TOF
465 TStopwatch stopwatch;
470 const Int_t kDDL = AliDAQ::NumberOfDdls("TOF");
474 Int_t bufsize = 32000;
475 clustersTree->Branch("TOF", &fRecPoints, bufsize);
477 TClonesArray * clonesRawData;
480 Int_t detectorIndex[5];
484 if (fVerbose==2) ftxt.open("TOFdigitsRead.txt",ios::app);
486 fTOFRawStream.Clear();
487 fTOFRawStream.SetRawReader(rawReader);
489 if (fDecoderVersion == 1) {
490 AliInfo("Using New Decoder");
492 else if (fDecoderVersion == 2) {
493 AliInfo("Using Enhanced Decoder");
496 AliInfo("Using Old Decoder");
500 for (indexDDL = 0; indexDDL < kDDL; indexDDL++) {
503 if (fDecoderVersion == 1) {
504 fTOFRawStream.LoadRawDataBuffers(indexDDL,fVerbose);
506 else if (fDecoderVersion == 2) {
507 fTOFRawStream.LoadRawDataBuffersV2(indexDDL,fVerbose);
510 fTOFRawStream.LoadRawData(indexDDL);
513 clonesRawData = (TClonesArray*)fTOFRawStream.GetRawData();
515 for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
517 AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
519 //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
520 if (tofRawDatum->GetTOF()==-1) continue;
523 if (indexDDL<10) ftxt << " " << indexDDL;
524 else ftxt << " " << indexDDL;
525 if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM();
526 else ftxt << " " << tofRawDatum->GetTRM();
527 ftxt << " " << tofRawDatum->GetTRMchain();
528 if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC();
529 else ftxt << " " << tofRawDatum->GetTDC();
530 ftxt << " " << tofRawDatum->GetTDCchannel();
533 fTOFRawStream.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
534 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
535 dummy = detectorIndex[3];
536 detectorIndex[3] = detectorIndex[4];
537 detectorIndex[4] = dummy;
540 if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0];
541 else ftxt << " -> " << detectorIndex[0];
542 ftxt << " " << detectorIndex[1];
543 if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2];
544 else ftxt << " " << detectorIndex[2];
545 ftxt << " " << detectorIndex[3];
546 if (detectorIndex[4]<10) ftxt << " " << detectorIndex[4];
547 else ftxt << " " << detectorIndex[4];
550 /* check valid index */
551 if (detectorIndex[0]==-1||detectorIndex[1]==-1||detectorIndex[2]==-1||detectorIndex[3]==-1||detectorIndex[4]==-1) continue;
553 // Do not reconstruct anything in the holes
554 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
555 if (detectorIndex[1]==2) { // plate with holes
561 parTOF[0] = tofRawDatum->GetTOF(); //TDC
562 parTOF[1] = tofRawDatum->GetTOT(); // TOT
563 parTOF[2] = tofRawDatum->GetTOT(); //ADC==TOF
564 parTOF[3] = 0;//raw data: no track of undecalib sim time
565 parTOF[4] = tofRawDatum->GetTOF(); // RAW time
566 parTOF[5] = tofRawDatum->GetDeltaBC(); // deltaBC
567 parTOF[6] = tofRawDatum->GetL0L1Latency(); // L0-L1 latency
570 UShort_t volIdClus=GetClusterVolIndex(detectorIndex);
571 Int_t lab[3]={-1,-1,-1};
573 GetClusterPars(detectorIndex,posClus,covClus);
574 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);
575 InsertCluster(tofCluster);
578 if (parTOF[1]<10)ftxt << " " << parTOF[1];
579 else if (parTOF[1]>=10 && parTOF[1]<100) ftxt << " " << parTOF[1];
580 else ftxt << " " << parTOF[1];
581 if (parTOF[0]<10) ftxt << " " << parTOF[0] << endl;
582 else if (parTOF[0]>=10 && parTOF[0]<100) ftxt << " " << parTOF[0] << endl;
583 else if (parTOF[0]>=100 && parTOF[0]<1000) ftxt << " " << parTOF[0] << endl;
584 else ftxt << " " << parTOF[0] << endl;
587 } // closed loop on TOF raw data per current DDL file
589 clonesRawData->Clear("C");
591 } // closed loop on DDL index
593 if (fVerbose==2) ftxt.close();
595 AliDebug(1,Form("Number of found clusters: %d", fNumberOfTofClusters));
597 CalibrateRecPoint(rawReader->GetTimestamp());
600 clustersTree->Fill();
604 AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters : R:%.4fs C:%.4fs",
605 stopwatch.RealTime(),stopwatch.CpuTime()));
606 if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
609 //______________________________________________________________________________
611 void AliTOFClusterFinder::Digits2RecPoints(Int_t iEvent, AliRawReader *rawReader)
614 // Converts RAW data to recpoints for TOF
617 TStopwatch stopwatch;
622 const Int_t kDDL = AliDAQ::NumberOfDdls("TOF");
624 fRunLoader->GetEvent(iEvent);
626 AliDebug(2,Form(" Event number %2d ", iEvent));
628 fTreeR = fTOFLoader->TreeR();
631 fTOFLoader->MakeTree("R");
632 fTreeR = fTOFLoader->TreeR();
635 Int_t bufsize = 32000;
636 fTreeR->Branch("TOF", &fRecPoints, bufsize);
638 TClonesArray * clonesRawData;
642 Int_t detectorIndex[5] = {-1, -1, -1, -1, -1};
645 if (fVerbose==2) ftxt.open("TOFdigitsRead.txt",ios::app);
647 fTOFRawStream.Clear();
648 fTOFRawStream.SetRawReader(rawReader);
650 if (fDecoderVersion == 1) {
651 AliInfo("Using New Decoder");
653 else if (fDecoderVersion == 2) {
654 AliInfo("Using Enhanced Decoder");
657 AliInfo("Using Old Decoder");
661 for (indexDDL = 0; indexDDL < kDDL; indexDDL++) {
664 if (fDecoderVersion == 1) {
665 fTOFRawStream.LoadRawDataBuffers(indexDDL,fVerbose);
667 else if (fDecoderVersion == 2) {
668 fTOFRawStream.LoadRawDataBuffersV2(indexDDL,fVerbose);
671 fTOFRawStream.LoadRawData(indexDDL);
674 clonesRawData = (TClonesArray*)fTOFRawStream.GetRawData();
676 for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
678 AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
680 //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
681 if (tofRawDatum->GetTOF()==-1) continue;
684 if (indexDDL<10) ftxt << " " << indexDDL;
685 else ftxt << " " << indexDDL;
686 if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM();
687 else ftxt << " " << tofRawDatum->GetTRM();
688 ftxt << " " << tofRawDatum->GetTRMchain();
689 if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC();
690 else ftxt << " " << tofRawDatum->GetTDC();
691 ftxt << " " << tofRawDatum->GetTDCchannel();
694 fTOFRawStream.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
695 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
696 dummy = detectorIndex[3];
697 detectorIndex[3] = detectorIndex[4];
698 detectorIndex[4] = dummy;
701 if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0];
702 else ftxt << " -> " << detectorIndex[0];
703 ftxt << " " << detectorIndex[1];
704 if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2];
705 else ftxt << " " << detectorIndex[2];
706 ftxt << " " << detectorIndex[3];
707 if (detectorIndex[4]<10) ftxt << " " << detectorIndex[4];
708 else ftxt << " " << detectorIndex[4];
711 /* check valid index */
712 if (detectorIndex[0]==-1||detectorIndex[1]==-1||detectorIndex[2]==-1||detectorIndex[3]==-1||detectorIndex[4]==-1) continue;
714 // Do not reconstruct anything in the holes
715 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
716 if (detectorIndex[1]==2) { // plate with holes
722 parTOF[0] = tofRawDatum->GetTOF(); // TDC
723 parTOF[1] = tofRawDatum->GetTOT(); // TOT
724 parTOF[2] = tofRawDatum->GetTOT(); // raw data have ADC=TOT
725 parTOF[3] = 0; //raw data: no track of the undecalib sim time
726 parTOF[4] = tofRawDatum->GetTOF(); // Raw time == TDC
727 parTOF[5] = tofRawDatum->GetDeltaBC(); // deltaBC
728 parTOF[6] = tofRawDatum->GetL0L1Latency(); // L0-L1 latency
731 UShort_t volIdClus=GetClusterVolIndex(detectorIndex);
732 Int_t lab[3]={-1,-1,-1};
734 GetClusterPars(detectorIndex,posClus,covClus);
735 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);
736 InsertCluster(tofCluster);
739 if (parTOF[1]<10)ftxt << " " << parTOF[1];
740 else if (parTOF[1]>=10 && parTOF[1]<100) ftxt << " " << parTOF[1];
741 else ftxt << " " << parTOF[1];
742 if (parTOF[0]<10) ftxt << " " << parTOF[0] << endl;
743 else if (parTOF[0]>=10 && parTOF[0]<100) ftxt << " " << parTOF[0] << endl;
744 else if (parTOF[0]>=100 && parTOF[0]<1000) ftxt << " " << parTOF[0] << endl;
745 else ftxt << " " << parTOF[0] << endl;
748 } // closed loop on TOF raw data per current DDL file
750 clonesRawData->Clear("C");
752 } // closed loop on DDL index
754 if (fVerbose==2) ftxt.close();
756 AliDebug(1,Form("Number of found clusters: %d for event: %d", fNumberOfTofClusters, iEvent));
758 CalibrateRecPoint(rawReader->GetTimestamp());
764 fTOFLoader = fRunLoader->GetLoader("TOFLoader");
765 fTOFLoader->WriteRecPoints("OVERWRITE");
767 AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters : R:%.4fs C:%.4fs",
768 stopwatch.RealTime(),stopwatch.CpuTime()));
769 if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
772 //______________________________________________________________________________
774 void AliTOFClusterFinder::Raw2Digits(Int_t iEvent, AliRawReader *rawReader)
777 // Converts RAW data to MC digits for TOF
779 // (temporary solution)
782 TStopwatch stopwatch;
785 const Int_t kDDL = AliTOFGeometry::NDDL()*AliTOFGeometry::NSectors();
787 fRunLoader->GetEvent(iEvent);
789 fTreeD = fTOFLoader->TreeD();
792 AliInfo("TreeD re-creation");
794 fTOFLoader->MakeTree("D");
795 fTreeD = fTOFLoader->TreeD();
798 AliFatal("Can not get TreeD");
802 Int_t bufsize = 32000;
804 fTreeD->Branch("TOF", &fDigits, bufsize);
806 fRunLoader->GetEvent(iEvent);
808 AliDebug(2,Form(" Event number %2d ", iEvent));
810 TClonesArray * clonesRawData;
814 Int_t detectorIndex[5];
817 fTOFRawStream.Clear();
818 fTOFRawStream.SetRawReader(rawReader);
820 if (fDecoderVersion == 1) {
821 AliInfo("Using New Decoder");
823 else if (fDecoderVersion == 2) {
824 AliInfo("Using Enhanced Decoder");
827 AliInfo("Using Old Decoder");
831 for (indexDDL = 0; indexDDL < kDDL; indexDDL++) {
834 if (fDecoderVersion == 1) {
835 fTOFRawStream.LoadRawDataBuffers(indexDDL,fVerbose);
837 else if (fDecoderVersion == 2) {
838 fTOFRawStream.LoadRawDataBuffersV2(indexDDL,fVerbose);
841 fTOFRawStream.LoadRawData(indexDDL);
844 clonesRawData = (TClonesArray*)fTOFRawStream.GetRawData();
846 for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
848 AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
850 //if (!tofRawDatum->GetTOT() || !tofRawDatum->GetTOF()) continue;
851 if (tofRawDatum->GetTOF()==-1) continue;
853 fTOFRawStream.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
854 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
855 dummy = detectorIndex[3];
856 detectorIndex[3] = detectorIndex[4];
857 detectorIndex[4] = dummy;
859 digit[0] = fTOFRawStream.GetTofBin();
860 digit[1] = fTOFRawStream.GetToTbin();
861 digit[2] = fTOFRawStream.GetToTbin();
864 Int_t tracknum[3]={-1,-1,-1};
866 TClonesArray &aDigits = *fDigits;
867 Int_t last=fDigits->GetEntriesFast();
868 new (aDigits[last]) AliTOFdigit(tracknum, detectorIndex, digit);
872 clonesRawData->Clear("C");
878 fTOFLoader = fRunLoader->GetLoader("TOFLoader");
879 fTOFLoader->WriteDigits("OVERWRITE");
881 AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters : R:%.2fs C:%.2fs",
882 stopwatch.RealTime(),stopwatch.CpuTime()));
886 //______________________________________________________________________________
888 void AliTOFClusterFinder::Raw2Digits(AliRawReader *rawReader, TTree* digitsTree)
891 // Converts RAW data to MC digits for TOF for the current event
895 TStopwatch stopwatch;
898 const Int_t kDDL = AliTOFGeometry::NDDL()*AliTOFGeometry::NSectors();
902 AliError("No input digits Tree");
906 Int_t bufsize = 32000;
907 digitsTree->Branch("TOF", &fDigits, bufsize);
909 TClonesArray * clonesRawData;
912 Int_t detectorIndex[5];
915 fTOFRawStream.Clear();
916 fTOFRawStream.SetRawReader(rawReader);
918 if (fDecoderVersion == 1) {
919 AliInfo("Using New Decoder");
921 else if (fDecoderVersion == 2) {
922 AliInfo("Using Enhanced Decoder");
925 AliInfo("Using Old Decoder");
929 for (indexDDL = 0; indexDDL < kDDL; indexDDL++) {
932 if (fDecoderVersion == 1) {
933 fTOFRawStream.LoadRawDataBuffers(indexDDL,fVerbose);
935 else if (fDecoderVersion == 2) {
936 fTOFRawStream.LoadRawDataBuffersV2(indexDDL,fVerbose);
939 fTOFRawStream.LoadRawData(indexDDL);
942 clonesRawData = (TClonesArray*)fTOFRawStream.GetRawData();
944 for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
946 AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
948 //if (!tofRawDatum->GetTOT() || !tofRawDatum->GetTOF()) continue;
949 if (tofRawDatum->GetTOF()==-1) continue;
951 fTOFRawStream.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
952 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
953 dummy = detectorIndex[3];
954 detectorIndex[3] = detectorIndex[4];
955 detectorIndex[4] = dummy;
957 digit[0] = fTOFRawStream.GetTofBin();
958 digit[1] = fTOFRawStream.GetToTbin();
959 digit[2] = fTOFRawStream.GetToTbin();
962 Int_t tracknum[3]={-1,-1,-1};
964 TClonesArray &aDigits = *fDigits;
965 Int_t last=fDigits->GetEntriesFast();
966 new (aDigits[last]) AliTOFdigit(tracknum, detectorIndex, digit);
970 clonesRawData->Clear("C");
976 AliDebug(1, Form("Got %d digits: ", fDigits->GetEntries()));
977 AliDebug(1, Form("Execution time to read TOF raw data and fill TOF digit tree : R:%.2fs C:%.2fs",
978 stopwatch.RealTime(),stopwatch.CpuTime()));
981 //______________________________________________________________________________
983 Int_t AliTOFClusterFinder::InsertCluster(AliTOFcluster *tofCluster) {
984 //---------------------------------------------------------------------------//
985 // This function adds a TOF cluster to the array of TOF clusters sorted in Z //
986 //---------------------------------------------------------------------------//
987 if (fNumberOfTofClusters==kTofMaxCluster) {
988 AliError("Too many clusters !");
992 if (fNumberOfTofClusters==0) {
993 fTofClusters[fNumberOfTofClusters++] = tofCluster;
997 Int_t ii = FindClusterIndex(tofCluster->GetZ());
998 memmove(fTofClusters+ii+1 ,fTofClusters+ii,(fNumberOfTofClusters-ii)*sizeof(AliTOFcluster*));
999 fTofClusters[ii] = tofCluster;
1000 fNumberOfTofClusters++;
1005 //_________________________________________________________________________
1007 Int_t AliTOFClusterFinder::FindClusterIndex(Double_t z) const {
1008 //--------------------------------------------------------------------
1009 // This function returns the index of the nearest cluster in z
1010 //--------------------------------------------------------------------
1011 if (fNumberOfTofClusters==0) return 0;
1012 if (z <= fTofClusters[0]->GetZ()) return 0;
1013 if (z > fTofClusters[fNumberOfTofClusters-1]->GetZ()) return fNumberOfTofClusters;
1014 Int_t b = 0, e = fNumberOfTofClusters-1, m = (b+e)/2;
1015 for (; b<e; m=(b+e)/2) {
1016 if (z > fTofClusters[m]->GetZ()) b=m+1;
1023 //_________________________________________________________________________
1025 void AliTOFClusterFinder::FillRecPoint()
1028 // Copy the global array of AliTOFcluster, i.e. fTofClusters (sorted
1029 // in Z) in the global TClonesArray of AliTOFcluster,
1035 Int_t detectorIndex[5];
1037 Int_t trackLabels[3];
1038 Int_t digitIndex = -1;
1039 Bool_t status=kTRUE;
1041 TClonesArray &lRecPoints = *fRecPoints;
1043 for (ii=0; ii<fNumberOfTofClusters; ii++) {
1045 digitIndex = fTofClusters[ii]->GetIndex();
1046 for(jj=0; jj<5; jj++) detectorIndex[jj] = fTofClusters[ii]->GetDetInd(jj);
1047 for(jj=0; jj<3; jj++) trackLabels[jj] = fTofClusters[ii]->GetLabel(jj);
1048 parTOF[0] = fTofClusters[ii]->GetTDC(); // TDC
1049 parTOF[1] = fTofClusters[ii]->GetToT(); // TOT
1050 parTOF[2] = fTofClusters[ii]->GetADC(); // ADC=TOT
1051 parTOF[3] = fTofClusters[ii]->GetTDCND(); // TDCND
1052 parTOF[4] = fTofClusters[ii]->GetTDCRAW();//RAW
1053 parTOF[5] = fTofClusters[ii]->GetDeltaBC();//deltaBC
1054 parTOF[6] = fTofClusters[ii]->GetL0L1Latency();//L0-L1 latency
1055 status=fTofClusters[ii]->GetStatus();
1056 Double_t posClus[3];
1057 Double_t covClus[6];
1058 UShort_t volIdClus=GetClusterVolIndex(detectorIndex);
1059 GetClusterPars(detectorIndex,posClus,covClus);
1060 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);
1062 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",
1063 ii, volIdClus, posClus[0], posClus[1], posClus[2],
1064 fTofClusters[ii]->GetSigmaX2(),
1065 fTofClusters[ii]->GetSigmaXY(),
1066 fTofClusters[ii]->GetSigmaXZ(),
1067 fTofClusters[ii]->GetSigmaY2(),
1068 fTofClusters[ii]->GetSigmaYZ(),
1069 fTofClusters[ii]->GetSigmaZ2(),
1070 trackLabels[0], trackLabels[1], trackLabels[2],
1071 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[3], detectorIndex[4],
1072 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
1073 status, digitIndex));
1075 } // loop on clusters
1079 //_________________________________________________________________________
1082 * OLD CALIBRATE REC POINTS FUNCTION
1086 void AliTOFClusterFinder::CalibrateRecPoint(UInt_t timestamp)
1089 // Copy the global array of AliTOFcluster, i.e. fTofClusters (sorted
1090 // in Z) in the global TClonesArray of AliTOFcluster,
1096 Int_t detectorIndex[5];
1097 Int_t digitIndex = -1;
1101 Float_t tdcLatencyWindow;
1102 AliDebug(1," Calibrating TOF Clusters");
1104 AliTOFChannelOnlineArray *calDelay = fTOFcalib->GetTOFOnlineDelay();
1105 AliTOFChannelOnlineStatusArray *calStatus = fTOFcalib->GetTOFOnlineStatus();
1106 TObjArray *calTOFArrayOffline = fTOFcalib->GetTOFCalArrayOffline();
1108 AliTOFDeltaBCOffset *deltaBCOffsetObj = fTOFcalib->GetDeltaBCOffset();
1109 Int_t deltaBCOffset = deltaBCOffsetObj->GetDeltaBCOffset();
1110 AliTOFCTPLatency *ctpLatencyObj = fTOFcalib->GetCTPLatency();
1111 Float_t ctpLatency = ctpLatencyObj->GetCTPLatency();
1112 AliTOFRunParams *runParamsObj = fTOFcalib->GetRunParams();
1113 Float_t t0 = runParamsObj->EvalT0(timestamp);
1115 TString validity = (TString)fTOFcalib->GetOfflineValidity();
1116 Int_t calibration = -1;
1117 if (validity.CompareTo("valid")==0) {
1118 //AliInfo(Form(" validity = %s - Using offline calibration parameters",validity.Data()));
1121 //AliInfo(Form(" validity = %s - Using online calibration parameters",validity.Data()));
1125 for (ii=0; ii<fNumberOfTofClusters; ii++) {
1126 digitIndex = fTofClusters[ii]->GetIndex();
1127 for(jj=0; jj<5; jj++) detectorIndex[jj] = fTofClusters[ii]->GetDetInd(jj);
1129 Int_t index = AliTOFGeometry::GetIndex(detectorIndex);
1131 UChar_t statusPulser=calStatus->GetPulserStatus(index);
1132 UChar_t statusNoise=calStatus->GetNoiseStatus(index);
1133 UChar_t statusHW=calStatus->GetHWStatus(index);
1134 UChar_t status=calStatus->GetStatus(index);
1135 tdcLatencyWindow = calStatus->GetLatencyWindow(index) * 1.e3; /* ns -> ps */
1137 //check the status, also unknown is fine!!!!!!!
1139 AliDebug(2, Form(" Status for channel %d = %d",index, (Int_t)status));
1140 if((statusPulser & AliTOFChannelOnlineStatusArray::kTOFPulserBad)==(AliTOFChannelOnlineStatusArray::kTOFPulserBad)||(statusNoise & AliTOFChannelOnlineStatusArray::kTOFNoiseBad)==(AliTOFChannelOnlineStatusArray::kTOFNoiseBad)||(statusHW & AliTOFChannelOnlineStatusArray::kTOFHWBad)==(AliTOFChannelOnlineStatusArray::kTOFHWBad)){
1141 AliDebug(2, Form(" Bad Status for channel %d",index));
1142 fTofClusters[ii]->SetStatus(kFALSE); //odd convention, to avoid conflict with calibration objects currently in the db (temporary solution).
1145 AliDebug(2, Form(" Good Status for channel %d",index));
1147 // Get Rough channel online equalization
1148 Double_t roughDelay=(Double_t)calDelay->GetDelay(index); // in ns
1149 AliDebug(2,Form(" channel delay (ns) = %f", roughDelay));
1150 // Get Refined channel offline calibration parameters
1151 if (calibration ==1){
1152 AliTOFChannelOffline * calChannelOffline = (AliTOFChannelOffline*)calTOFArrayOffline->At(index);
1154 for (Int_t j = 0; j<6; j++){
1155 par[j]=(Double_t)calChannelOffline->GetSlewPar(j);
1157 AliDebug(2,Form(" Calib Pars = %f, %f, %f, %f, %f, %f ",par[0],par[1],par[2],par[3],par[4],par[5]));
1158 AliDebug(2,Form(" The ToT and Time, uncorr (counts) = %d , %d", fTofClusters[ii]->GetToT(),fTofClusters[ii]->GetTDC()));
1159 tToT = (Double_t)(fTofClusters[ii]->GetToT()*AliTOFGeometry::ToTBinWidth());
1160 tToT*=1.E-3; //ToT in ns
1162 /* check TOT limits and set new TOT in case */
1163 if (tToT < AliTOFGeometry::SlewTOTMin()) tToT = AliTOFGeometry::SlewTOTMin();
1164 if (tToT > AliTOFGeometry::SlewTOTMax()) tToT = AliTOFGeometry::SlewTOTMax();
1166 AliDebug(2,Form(" The ToT and Time, uncorr (ns)= %e, %e",fTofClusters[ii]->GetTDC()*AliTOFGeometry::TdcBinWidth()*1.E-3,tToT));
1167 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)
1170 timeCorr = roughDelay; // correction in ns
1172 AliDebug(2,Form(" The ToT and Time, uncorr (ns)= %e, %e",fTofClusters[ii]->GetTDC()*AliTOFGeometry::TdcBinWidth()*1.E-3,fTofClusters[ii]->GetToT()*AliTOFGeometry::ToTBinWidth()));
1173 AliDebug(2,Form(" The time correction (ns) = %f", timeCorr));
1174 timeCorr=(Double_t)(fTofClusters[ii]->GetTDC())*AliTOFGeometry::TdcBinWidth()*1.E-3-timeCorr;//redefine the time
1176 AliDebug(2,Form(" The channel time, corr (ps)= %e",timeCorr ));
1178 /* here timeCorr should be already corrected for calibration.
1179 * we now go into further corrections keeping in mind that timeCorr
1182 * the following corrections are performed in this way:
1184 * time = timeRaw - deltaBC + L0L1Latency + CTPLatency - TDCLatencyWindow - T0
1188 AliDebug(2, Form("applying further corrections (DeltaBC): DeltaBC=%d (BC bins), DeltaBCoffset=%d (BC bins)", fTofClusters[ii]->GetDeltaBC(), deltaBCOffset));
1189 AliDebug(2, Form("applying further corrections (L0L1Latency): L0L1Latency=%d (BC bins)", fTofClusters[ii]->GetL0L1Latency()));
1190 AliDebug(2, Form("applying further corrections (CTPLatency): CTPLatency=%f (ps)", ctpLatency));
1191 AliDebug(2, Form("applying further corrections (TDCLatencyWindow): TDCLatencyWindow=%f (ps)", tdcLatencyWindow));
1192 AliDebug(2, Form("applying further corrections (T0): T0=%f (ps)", t0));
1194 /* deltaBC correction (inhibited for the time being) */
1195 // timeCorr -= (fTofClusters[ii]->GetDeltaBC() - deltaBCOffset) * AliTOFGeometry::BunchCrossingBinWidth();
1196 /* L0L1-latency correction */
1197 timeCorr += fTofClusters[ii]->GetL0L1Latency() * AliTOFGeometry::BunchCrossingBinWidth();
1198 /* CTP-latency correction (from OCDB) */
1199 timeCorr += ctpLatency;
1200 /* TDC latency-window correction (from OCDB) */
1201 timeCorr -= tdcLatencyWindow;
1202 /* T0 correction (from OCDB) */
1206 * end of furhter corrections
1209 tdcCorr=(Int_t)(timeCorr/AliTOFGeometry::TdcBinWidth()); //the corrected time (tdc counts)
1210 fTofClusters[ii]->SetTDC(tdcCorr);
1211 } // loop on clusters
1216 //_________________________________________________________________________
1218 void AliTOFClusterFinder::CalibrateRecPoint(UInt_t timestamp)
1221 // Copy the global array of AliTOFcluster, i.e. fTofClusters (sorted
1222 // in Z) in the global TClonesArray of AliTOFcluster,
1226 Int_t detectorIndex[5];
1227 Double_t time, tot, corr;
1228 Int_t deltaBC, l0l1, tdcBin;
1229 for (Int_t ii = 0; ii < fNumberOfTofClusters; ii++) {
1230 for(Int_t jj = 0; jj < 5; jj++) detectorIndex[jj] = fTofClusters[ii]->GetDetInd(jj);
1232 Int_t index = AliTOFGeometry::GetIndex(detectorIndex);
1234 /* check channel enabled */
1235 if (!fTOFcalib->IsChannelEnabled(index)) fTofClusters[ii]->SetStatus(kFALSE);
1237 /* get cluster info */
1238 time = fTofClusters[ii]->GetTDC() * AliTOFGeometry::TdcBinWidth(); /* ps */
1239 tot = fTofClusters[ii]->GetToT() * AliTOFGeometry::ToTBinWidth() * 1.e-3; /* ns */
1240 deltaBC = fTofClusters[ii]->GetDeltaBC();
1241 l0l1 = fTofClusters[ii]->GetL0L1Latency();
1243 /* get correction */
1244 corr = fTOFcalib->GetTimeCorrection(index, tot, deltaBC, l0l1, timestamp); /* ps */
1245 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));
1247 /* apply time correction */
1250 /* convert in TDC bins and set cluster */
1251 //tdcBin = (Int_t)(time / AliTOFGeometry::TdcBinWidth()); //the corrected time (tdc counts)
1252 tdcBin = TMath::Nint(time / AliTOFGeometry::TdcBinWidth()); //the corrected time (tdc counts)
1253 fTofClusters[ii]->SetTDC(tdcBin);
1255 } // loop on clusters
1259 //______________________________________________________________________________
1261 void AliTOFClusterFinder::ResetRecpoint()
1264 // Clear the list of reconstructed points
1267 fNumberOfTofClusters = 0;
1268 if (fRecPoints) fRecPoints->Clear();
1271 //______________________________________________________________________________
1273 void AliTOFClusterFinder::Load()
1276 // Load TOF.Digits.root and TOF.RecPoints.root files
1279 fTOFLoader->LoadDigits("READ");
1280 fTOFLoader->LoadRecPoints("recreate");
1283 //______________________________________________________________________________
1285 void AliTOFClusterFinder::LoadClusters()
1288 // Load TOF.RecPoints.root file
1291 fTOFLoader->LoadRecPoints("recreate");
1294 //______________________________________________________________________________
1296 void AliTOFClusterFinder::UnLoad()
1299 // Unload TOF.Digits.root and TOF.RecPoints.root files
1302 fTOFLoader->UnloadDigits();
1303 fTOFLoader->UnloadRecPoints();
1306 //______________________________________________________________________________
1308 void AliTOFClusterFinder::UnLoadClusters()
1311 // Unload TOF.RecPoints.root file
1314 fTOFLoader->UnloadRecPoints();
1317 //-------------------------------------------------------------------------
1318 UShort_t AliTOFClusterFinder::GetClusterVolIndex(const Int_t * const ind) const {
1320 //First of all get the volume ID to retrieve the l2t transformation...
1322 // Detector numbering scheme
1329 Int_t isector =ind[0];
1330 if (isector >= nSector)
1331 AliError(Form("Wrong sector number in TOF (%d) !",isector));
1332 Int_t iplate = ind[1];
1333 if (iplate >= nPlate)
1334 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
1335 Int_t istrip = ind[2];
1337 Int_t stripOffset = 0;
1343 stripOffset = nStripC;
1346 stripOffset = nStripC+nStripB;
1349 stripOffset = nStripC+nStripB+nStripA;
1352 stripOffset = nStripC+nStripB+nStripA+nStripB;
1355 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
1359 Int_t index= (2*(nStripC+nStripB)+nStripA)*isector +
1363 UShort_t volIndex = AliGeomManager::LayerToVolUID(AliGeomManager::kTOF,index);
1367 //-------------------------------------------------------------------------
1368 void AliTOFClusterFinder::GetClusterPars(Int_t *ind, Double_t* pos,Double_t* cov) const {
1370 //First of all get the volume ID to retrieve the l2t transformation...
1372 UShort_t volIndex = GetClusterVolIndex(ind);
1375 //we now go in the system of the strip: determine the local coordinates
1378 // 47---------------------------------------------------0 ^ z
1379 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 1 |
1380 // ----------------------------------------------------- | y going outwards
1381 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 0 | par[0]=0;
1383 // ----------------------------------------------------- |
1384 // x <-----------------------------------------------------
1387 Float_t localX = (ind[4]-23.5)*AliTOFGeometry::XPad();
1389 Float_t localZ = (ind[3]- 0.5)*AliTOFGeometry::ZPad();
1391 Float_t localX = (ind[4]-AliTOFGeometry::NpadX()/2)*AliTOFGeometry::XPad()+AliTOFGeometry::XPad()/2.;
1393 Float_t localZ = (ind[3]-AliTOFGeometry::NpadZ()/2)*AliTOFGeometry::ZPad()+AliTOFGeometry::ZPad()/2.;
1394 //move to the tracking ref system
1401 const TGeoHMatrix *l2t= AliGeomManager::GetTracking2LocalMatrix(volIndex);
1402 // Get The position in the track ref system
1404 l2t->MasterToLocal(lpos,tpos);
1409 //Get The cluster covariance in the track ref system
1412 //cluster covariance in the local system:
1417 lcov[0] = AliTOFGeometry::XPad()*AliTOFGeometry::XPad()/12.;
1425 lcov[8] = AliTOFGeometry::ZPad()*AliTOFGeometry::ZPad()/12.;
1427 //cluster covariance in the tracking system:
1429 m.SetRotation(lcov);
1431 m.MultiplyLeft(&l2t->Inverse());
1432 Double_t *tcov = m.GetRotationMatrix();
1433 cov[0] = tcov[0]; cov[1] = tcov[1]; cov[2] = tcov[2];
1434 cov[3] = tcov[4]; cov[4] = tcov[5];