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"
132 //#include "AliTOFRawStream.h"
134 #include "AliTOFDeltaBCOffset.h"
135 #include "AliTOFCTPLatency.h"
136 #include "AliTOFRunParams.h"
138 //extern TFile *gFile;
140 ClassImp(AliTOFClusterFinder)
142 AliTOFClusterFinder::AliTOFClusterFinder(AliTOFcalib *calib):
143 TTask("AliTOFClusterFinder",""),
148 fDigits(new TClonesArray("AliTOFdigit", 4000)),
149 fRecPoints(new TClonesArray("AliTOFcluster", 4000)),
150 fNumberOfTofClusters(0),
154 fTOFRawStream(AliTOFRawStream())
160 TString validity = (TString)fTOFcalib->GetOfflineValidity();
161 if (validity.CompareTo("valid")==0) {
162 AliInfo(Form(" validity = %s - Using offline calibration parameters",validity.Data()));
164 AliInfo(Form(" validity = %s - Using online calibration parameters",validity.Data()));
169 //______________________________________________________________________________
171 AliTOFClusterFinder::AliTOFClusterFinder(AliRunLoader* runLoader, AliTOFcalib *calib):
172 TTask("AliTOFClusterFinder",""),
173 fRunLoader(runLoader),
174 fTOFLoader(runLoader->GetLoader("TOFLoader")),
177 fDigits(new TClonesArray("AliTOFdigit", 4000)),
178 fRecPoints(new TClonesArray("AliTOFcluster", 4000)),
179 fNumberOfTofClusters(0),
183 fTOFRawStream(AliTOFRawStream())
189 TString validity = (TString)fTOFcalib->GetOfflineValidity();
190 if (validity.CompareTo("valid")==0) {
191 AliInfo(Form(" validity = %s - Using offline calibration parameters",validity.Data()));
193 AliInfo(Form(" validity = %s - Using online calibration parameters",validity.Data()));
198 //------------------------------------------------------------------------
199 AliTOFClusterFinder::AliTOFClusterFinder(const AliTOFClusterFinder &source)
205 fDigits(source.fDigits),
206 fRecPoints(source.fRecPoints),
207 fNumberOfTofClusters(0),
209 fDecoderVersion(source.fDecoderVersion),
210 fTOFcalib(source.fTOFcalib),
211 fTOFRawStream(source.fTOFRawStream)
216 //------------------------------------------------------------------------
217 AliTOFClusterFinder& AliTOFClusterFinder::operator=(const AliTOFClusterFinder &source)
224 TTask::operator=(source);
225 fDigits=source.fDigits;
226 fRecPoints=source.fRecPoints;
227 fVerbose=source.fVerbose;
228 fDecoderVersion=source.fDecoderVersion;
229 fTOFcalib=source.fTOFcalib;
230 fTOFRawStream=source.fTOFRawStream;
234 //______________________________________________________________________________
236 AliTOFClusterFinder::~AliTOFClusterFinder()
251 fRecPoints->Delete();
256 if (fTofClusters || fNumberOfTofClusters) {
257 for (Int_t ii=0; ii<fNumberOfTofClusters; ii++)
258 if (fTofClusters[ii]) fTofClusters[ii]->Delete();
259 fNumberOfTofClusters=0;
263 //______________________________________________________________________________
265 void AliTOFClusterFinder::Digits2RecPoints(Int_t iEvent)
268 // Converts digits to recpoints for TOF
271 TStopwatch stopwatch;
276 fRunLoader->GetEvent(iEvent);
278 fTreeD = fTOFLoader->TreeD();
281 AliFatal("AliTOFClusterFinder: Can not get TreeD");
284 TBranch *branch = fTreeD->GetBranch("TOF");
286 AliError("can't get the branch with the TOF digits !");
290 TClonesArray staticdigits("AliTOFdigit",10000);
291 staticdigits.Clear();
292 TClonesArray *digits =&staticdigits;
293 branch->SetAddress(&digits);
297 fTreeR = fTOFLoader->TreeR();
300 fTOFLoader->MakeTree("R");
301 fTreeR = fTOFLoader->TreeR();
304 Int_t bufsize = 32000;
305 fTreeR->Branch("TOF", &fRecPoints, bufsize);
308 Int_t nDigits = digits->GetEntriesFast();
309 AliDebug(2,Form("Number of TOF digits: %d",nDigits));
312 Int_t dig[5]; //cluster detector indeces
313 Int_t parTOF[7]; //The TOF signal parameters
314 Bool_t status=kTRUE; // assume all sim channels ok in the beginning...
315 for (ii=0; ii<nDigits; ii++) {
316 AliTOFdigit *d = (AliTOFdigit*)digits->UncheckedAt(ii);
317 dig[0]=d->GetSector();
318 dig[1]=d->GetPlate();
319 dig[2]=d->GetStrip();
323 /* check valid index */
324 if (dig[0]==-1||dig[1]==-1||dig[2]==-1||dig[3]==-1||dig[4]==-1) continue;
326 // Do not reconstruct anything in the holes
327 if (dig[0]==13 || dig[0]==14 || dig[0]==15 ) { // sectors with holes
328 if (dig[1]==2) { // plate with holes
334 AliDebug(2,Form(" %2d %1d %2d %1d %2d ",dig[0],dig[1],dig[2],dig[3],dig[4]));
336 parTOF[0] = d->GetTdc(); //the TDC signal
337 parTOF[1] = d->GetToT(); //the ToT signal
338 parTOF[2] = d->GetAdc(); // the adc charge
339 parTOF[3] = d->GetTdcND(); // non decalibrated sim time
340 parTOF[4] = d->GetTdc(); // raw time, == Tdc time for the moment
341 parTOF[5] = 0; // deltaBC
342 parTOF[6] = 0; // L0-L1 latency
345 UShort_t volIdClus=GetClusterVolIndex(dig);
346 GetClusterPars(dig, posClus,covClus);
347 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);
348 InsertCluster(tofCluster);
352 AliDebug(1,Form("Number of found clusters: %d for event: %d", fNumberOfTofClusters, iEvent));
360 fTOFLoader = fRunLoader->GetLoader("TOFLoader");
361 fTOFLoader->WriteRecPoints("OVERWRITE");
363 AliDebug(1,Form("Execution time to read TOF digits and to write TOF clusters : R:%.4fs C:%.4fs",
364 stopwatch.RealTime(),stopwatch.CpuTime()));
365 if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
369 //______________________________________________________________________________
371 void AliTOFClusterFinder::Digits2RecPoints(TTree* digitsTree, TTree* clusterTree)
374 // Converts digits to recpoints for TOF
377 TStopwatch stopwatch;
382 /// fRunLoader->GetEvent(iEvent);
384 if (digitsTree == 0x0)
386 AliFatal("AliTOFClusterFinder: Can not get TreeD");
389 TBranch *branch = digitsTree->GetBranch("TOF");
391 AliError("can't get the branch with the TOF digits !");
395 TClonesArray staticdigits("AliTOFdigit",10000);
396 staticdigits.Clear();
397 TClonesArray *digits = & staticdigits;
398 branch->SetAddress(&digits);
403 Int_t bufsize = 32000;
404 fTreeR->Branch("TOF", &fRecPoints, bufsize);
406 digitsTree->GetEvent(0);
407 Int_t nDigits = digits->GetEntriesFast();
408 AliDebug(2,Form("Number of TOF digits: %d",nDigits));
411 Int_t dig[5]; //cluster detector indeces
412 Int_t parTOF[7]; //The TOF signal parameters
413 Bool_t status=kTRUE; // assume all sim channels ok in the beginning...
414 for (ii=0; ii<nDigits; ii++) {
415 AliTOFdigit *d = (AliTOFdigit*)digits->UncheckedAt(ii);
416 dig[0]=d->GetSector();
417 dig[1]=d->GetPlate();
418 dig[2]=d->GetStrip();
422 /* check valid index */
423 if (dig[0]==-1||dig[1]==-1||dig[2]==-1||dig[3]==-1||dig[4]==-1) continue;
425 // Do not reconstruct anything in the holes
426 if (dig[0]==13 || dig[0]==14 || dig[0]==15 ) { // sectors with holes
427 if (dig[1]==2) { // plate with holes
433 // AliDebug(2,Form(" %2d %1d %2d %1d %2d ",dig[0],dig[1],dig[2],dig[3],dig[4]));
435 parTOF[0] = d->GetTdc(); //the TDC signal
436 parTOF[1] = d->GetToT(); //the ToT signal
437 parTOF[2] = d->GetAdc(); // the adc charge
438 parTOF[3] = d->GetTdcND(); // non decalibrated sim time
439 parTOF[4] = d->GetTdc(); // raw time, == Tdc time for the moment
440 parTOF[5] = 0; // deltaBC
441 parTOF[6] = 0; // L0-L1 latency
445 UShort_t volIdClus=GetClusterVolIndex(dig);
446 GetClusterPars(dig,posClus,covClus);
447 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);
448 InsertCluster(tofCluster);
452 AliDebug(1,Form("Number of found clusters: %d", fNumberOfTofClusters));
460 AliDebug(1,Form("Execution time to read TOF digits and to write TOF clusters : R:%.4fs C:%.4fs",
461 stopwatch.RealTime(),stopwatch.CpuTime()));
462 if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
465 //______________________________________________________________________________
467 void AliTOFClusterFinder::Digits2RecPoints(AliRawReader *rawReader,
471 // Converts RAW data to recpoints for TOF
474 TStopwatch stopwatch;
479 const Int_t kDDL = AliDAQ::NumberOfDdls("TOF");
483 Int_t bufsize = 32000;
484 clustersTree->Branch("TOF", &fRecPoints, bufsize);
486 TClonesArray * clonesRawData;
490 Int_t detectorIndex[5];
494 if (fVerbose==2) ftxt.open("TOFdigitsRead.txt",ios::app);
496 //AliTOFRawStream tofInput(rawReader);
497 fTOFRawStream.Clear();
498 fTOFRawStream.SetRawReader(rawReader);
500 if (fDecoderVersion == 1) {
501 AliInfo("Using New Decoder");
503 else if (fDecoderVersion == 2) {
504 AliInfo("Using Enhanced Decoder");
507 AliInfo("Using Old Decoder");
511 for (indexDDL = 0; indexDDL < kDDL; indexDDL++) {
514 if (fDecoderVersion == 1) {
515 fTOFRawStream.LoadRawDataBuffers(indexDDL,fVerbose);
517 else if (fDecoderVersion == 2) {
518 fTOFRawStream.LoadRawDataBuffersV2(indexDDL,fVerbose);
521 fTOFRawStream.LoadRawData(indexDDL);
524 clonesRawData = (TClonesArray*)fTOFRawStream.GetRawData();
526 for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
528 AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
530 //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
531 if (tofRawDatum->GetTOF()==-1) continue;
534 if (indexDDL<10) ftxt << " " << indexDDL;
535 else ftxt << " " << indexDDL;
536 if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM();
537 else ftxt << " " << tofRawDatum->GetTRM();
538 ftxt << " " << tofRawDatum->GetTRMchain();
539 if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC();
540 else ftxt << " " << tofRawDatum->GetTDC();
541 ftxt << " " << tofRawDatum->GetTDCchannel();
544 fTOFRawStream.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
545 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
546 dummy = detectorIndex[3];
547 detectorIndex[3] = detectorIndex[4];
548 detectorIndex[4] = dummy;
551 if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0];
552 else ftxt << " -> " << detectorIndex[0];
553 ftxt << " " << detectorIndex[1];
554 if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2];
555 else ftxt << " " << detectorIndex[2];
556 ftxt << " " << detectorIndex[3];
557 if (detectorIndex[4]<10) ftxt << " " << detectorIndex[4];
558 else ftxt << " " << detectorIndex[4];
561 /* check valid index */
562 if (detectorIndex[0]==-1||detectorIndex[1]==-1||detectorIndex[2]==-1||detectorIndex[3]==-1||detectorIndex[4]==-1) continue;
564 // Do not reconstruct anything in the holes
565 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
566 if (detectorIndex[1]==2) { // plate with holes
572 parTOF[0] = tofRawDatum->GetTOF(); //TDC
573 parTOF[1] = tofRawDatum->GetTOT(); // TOT
574 parTOF[2] = tofRawDatum->GetTOT(); //ADC==TOF
575 parTOF[3] = -1;//raw data: no track of undecalib sim time
576 parTOF[4] = tofRawDatum->GetTOF(); // RAW time
577 parTOF[5] = tofRawDatum->GetDeltaBC(); // deltaBC
578 parTOF[6] = tofRawDatum->GetL0L1Latency(); // L0-L1 latency
581 UShort_t volIdClus=GetClusterVolIndex(detectorIndex);
582 Int_t lab[3]={-1,-1,-1};
584 GetClusterPars(detectorIndex,posClus,covClus);
585 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);
586 InsertCluster(tofCluster);
589 if (parTOF[1]<10)ftxt << " " << parTOF[1];
590 else if (parTOF[1]>=10 && parTOF[1]<100) ftxt << " " << parTOF[1];
591 else ftxt << " " << parTOF[1];
592 if (parTOF[0]<10) ftxt << " " << parTOF[0] << endl;
593 else if (parTOF[0]>=10 && parTOF[0]<100) ftxt << " " << parTOF[0] << endl;
594 else if (parTOF[0]>=100 && parTOF[0]<1000) ftxt << " " << parTOF[0] << endl;
595 else ftxt << " " << parTOF[3] << endl;
598 } // closed loop on TOF raw data per current DDL file
600 clonesRawData->Clear();
602 } // closed loop on DDL index
604 if (fVerbose==2) ftxt.close();
606 AliDebug(1,Form("Number of found clusters: %d", fNumberOfTofClusters));
608 CalibrateRecPoint(rawReader->GetTimestamp());
611 clustersTree->Fill();
615 AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters : R:%.4fs C:%.4fs",
616 stopwatch.RealTime(),stopwatch.CpuTime()));
617 if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
620 //______________________________________________________________________________
622 void AliTOFClusterFinder::Digits2RecPoints(Int_t iEvent, AliRawReader *rawReader)
625 // Converts RAW data to recpoints for TOF
628 TStopwatch stopwatch;
633 const Int_t kDDL = AliDAQ::NumberOfDdls("TOF");
635 fRunLoader->GetEvent(iEvent);
637 AliDebug(2,Form(" Event number %2d ", iEvent));
639 fTreeR = fTOFLoader->TreeR();
642 fTOFLoader->MakeTree("R");
643 fTreeR = fTOFLoader->TreeR();
646 Int_t bufsize = 32000;
647 fTreeR->Branch("TOF", &fRecPoints, bufsize);
649 TClonesArray * clonesRawData;
653 Int_t detectorIndex[5] = {-1, -1, -1, -1, -1};
656 if (fVerbose==2) ftxt.open("TOFdigitsRead.txt",ios::app);
658 //AliTOFRawStream tofInput(rawReader);
659 fTOFRawStream.Clear();
660 fTOFRawStream.SetRawReader(rawReader);
662 if (fDecoderVersion == 1) {
663 AliInfo("Using New Decoder");
665 else if (fDecoderVersion == 2) {
666 AliInfo("Using Enhanced Decoder");
669 AliInfo("Using Old Decoder");
673 for (indexDDL = 0; indexDDL < kDDL; indexDDL++) {
676 if (fDecoderVersion == 1) {
677 fTOFRawStream.LoadRawDataBuffers(indexDDL,fVerbose);
679 else if (fDecoderVersion == 2) {
680 fTOFRawStream.LoadRawDataBuffersV2(indexDDL,fVerbose);
683 fTOFRawStream.LoadRawData(indexDDL);
686 clonesRawData = (TClonesArray*)fTOFRawStream.GetRawData();
688 for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
690 AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
692 //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
693 if (tofRawDatum->GetTOF()==-1) continue;
696 if (indexDDL<10) ftxt << " " << indexDDL;
697 else ftxt << " " << indexDDL;
698 if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM();
699 else ftxt << " " << tofRawDatum->GetTRM();
700 ftxt << " " << tofRawDatum->GetTRMchain();
701 if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC();
702 else ftxt << " " << tofRawDatum->GetTDC();
703 ftxt << " " << tofRawDatum->GetTDCchannel();
706 fTOFRawStream.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
707 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
708 dummy = detectorIndex[3];
709 detectorIndex[3] = detectorIndex[4];
710 detectorIndex[4] = dummy;
713 if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0];
714 else ftxt << " -> " << detectorIndex[0];
715 ftxt << " " << detectorIndex[1];
716 if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2];
717 else ftxt << " " << detectorIndex[2];
718 ftxt << " " << detectorIndex[3];
719 if (detectorIndex[4]<10) ftxt << " " << detectorIndex[4];
720 else ftxt << " " << detectorIndex[4];
723 /* check valid index */
724 if (detectorIndex[0]==-1||detectorIndex[1]==-1||detectorIndex[2]==-1||detectorIndex[3]==-1||detectorIndex[4]==-1) continue;
726 // Do not reconstruct anything in the holes
727 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
728 if (detectorIndex[1]==2) { // plate with holes
734 parTOF[0] = tofRawDatum->GetTOF(); // TDC
735 parTOF[1] = tofRawDatum->GetTOT(); // TOT
736 parTOF[2] = tofRawDatum->GetTOT(); // raw data have ADC=TOT
737 parTOF[3] = -1; //raw data: no track of the undecalib sim time
738 parTOF[4] = tofRawDatum->GetTOF(); // Raw time == TDC
739 parTOF[5] = tofRawDatum->GetDeltaBC(); // deltaBC
740 parTOF[6] = tofRawDatum->GetL0L1Latency(); // L0-L1 latency
743 UShort_t volIdClus=GetClusterVolIndex(detectorIndex);
744 Int_t lab[3]={-1,-1,-1};
746 GetClusterPars(detectorIndex,posClus,covClus);
747 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);
748 InsertCluster(tofCluster);
751 if (parTOF[1]<10)ftxt << " " << parTOF[1];
752 else if (parTOF[1]>=10 && parTOF[1]<100) ftxt << " " << parTOF[1];
753 else ftxt << " " << parTOF[1];
754 if (parTOF[0]<10) ftxt << " " << parTOF[0] << endl;
755 else if (parTOF[0]>=10 && parTOF[0]<100) ftxt << " " << parTOF[0] << endl;
756 else if (parTOF[0]>=100 && parTOF[0]<1000) ftxt << " " << parTOF[0] << endl;
757 else ftxt << " " << parTOF[3] << endl;
760 } // closed loop on TOF raw data per current DDL file
762 clonesRawData->Clear();
764 } // closed loop on DDL index
766 if (fVerbose==2) ftxt.close();
768 AliDebug(1,Form("Number of found clusters: %d for event: %d", fNumberOfTofClusters, iEvent));
770 CalibrateRecPoint(rawReader->GetTimestamp());
776 fTOFLoader = fRunLoader->GetLoader("TOFLoader");
777 fTOFLoader->WriteRecPoints("OVERWRITE");
779 AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters : R:%.4fs C:%.4fs",
780 stopwatch.RealTime(),stopwatch.CpuTime()));
781 if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
784 //______________________________________________________________________________
786 void AliTOFClusterFinder::Raw2Digits(Int_t iEvent, AliRawReader *rawReader)
789 // Converts RAW data to MC digits for TOF
791 // (temporary solution)
794 TStopwatch stopwatch;
797 const Int_t kDDL = AliTOFGeometry::NDDL()*AliTOFGeometry::NSectors();
799 fRunLoader->GetEvent(iEvent);
801 fTreeD = fTOFLoader->TreeD();
804 AliInfo("TreeD re-creation");
806 fTOFLoader->MakeTree("D");
807 fTreeD = fTOFLoader->TreeD();
810 TClonesArray *tofDigits = new TClonesArray("AliTOFdigit",10000);
811 Int_t bufsize = 32000;
812 fTreeD->Branch("TOF", &tofDigits, bufsize);
814 fRunLoader->GetEvent(iEvent);
816 AliDebug(2,Form(" Event number %2d ", iEvent));
818 TClonesArray * clonesRawData;
822 Int_t detectorIndex[5];
825 //AliTOFRawStream tofInput(rawReader);
826 fTOFRawStream.Clear();
827 fTOFRawStream.SetRawReader(rawReader);
829 if (fDecoderVersion == 1) {
830 AliInfo("Using New Decoder");
832 else if (fDecoderVersion == 2) {
833 AliInfo("Using Enhanced Decoder");
836 AliInfo("Using Old Decoder");
840 for (indexDDL = 0; indexDDL < kDDL; indexDDL++) {
843 if (fDecoderVersion == 1) {
844 fTOFRawStream.LoadRawDataBuffers(indexDDL,fVerbose);
846 else if (fDecoderVersion == 2) {
847 fTOFRawStream.LoadRawDataBuffersV2(indexDDL,fVerbose);
850 fTOFRawStream.LoadRawData(indexDDL);
853 clonesRawData = (TClonesArray*)fTOFRawStream.GetRawData();
855 for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
857 AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
859 //if (!tofRawDatum->GetTOT() || !tofRawDatum->GetTOF()) continue;
860 if (tofRawDatum->GetTOF()==-1) continue;
862 fTOFRawStream.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
863 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
864 dummy = detectorIndex[3];
865 detectorIndex[3] = detectorIndex[4];
866 detectorIndex[4] = dummy;
868 digit[0] = fTOFRawStream.GetTofBin();
869 digit[1] = fTOFRawStream.GetToTbin();
870 digit[2] = fTOFRawStream.GetToTbin();
873 Int_t tracknum[3]={-1,-1,-1};
875 TClonesArray &aDigits = *tofDigits;
876 Int_t last=tofDigits->GetEntriesFast();
877 new (aDigits[last]) AliTOFdigit(tracknum, detectorIndex, digit);
881 clonesRawData->Clear();
887 fTOFLoader = fRunLoader->GetLoader("TOFLoader");
888 fTOFLoader->WriteDigits("OVERWRITE");
892 AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters : R:%.2fs C:%.2fs",
893 stopwatch.RealTime(),stopwatch.CpuTime()));
897 //______________________________________________________________________________
899 void AliTOFClusterFinder::Raw2Digits(AliRawReader *rawReader, TTree* digitsTree)
902 // Converts RAW data to MC digits for TOF for the current event
906 TStopwatch stopwatch;
909 const Int_t kDDL = AliTOFGeometry::NDDL()*AliTOFGeometry::NSectors();
913 AliError("No input digits Tree");
917 TClonesArray *tofDigits = new TClonesArray("AliTOFdigit",10000);
918 Int_t bufsize = 32000;
919 digitsTree->Branch("TOF", &tofDigits, bufsize);
921 TClonesArray * clonesRawData;
925 Int_t detectorIndex[5];
928 //AliTOFRawStream tofInput(rawReader);
929 fTOFRawStream.Clear();
930 fTOFRawStream.SetRawReader(rawReader);
932 if (fDecoderVersion == 1) {
933 AliInfo("Using New Decoder");
935 else if (fDecoderVersion == 2) {
936 AliInfo("Using Enhanced Decoder");
939 AliInfo("Using Old Decoder");
943 for (indexDDL = 0; indexDDL < kDDL; indexDDL++) {
946 if (fDecoderVersion == 1) {
947 fTOFRawStream.LoadRawDataBuffers(indexDDL,fVerbose);
949 else if (fDecoderVersion == 2) {
950 fTOFRawStream.LoadRawDataBuffersV2(indexDDL,fVerbose);
953 fTOFRawStream.LoadRawData(indexDDL);
956 clonesRawData = (TClonesArray*)fTOFRawStream.GetRawData();
958 for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
960 AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
962 //if (!tofRawDatum->GetTOT() || !tofRawDatum->GetTOF()) continue;
963 if (tofRawDatum->GetTOF()==-1) continue;
965 fTOFRawStream.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
966 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
967 dummy = detectorIndex[3];
968 detectorIndex[3] = detectorIndex[4];
969 detectorIndex[4] = dummy;
971 digit[0] = fTOFRawStream.GetTofBin();
972 digit[1] = fTOFRawStream.GetToTbin();
973 digit[2] = fTOFRawStream.GetToTbin();
976 Int_t tracknum[3]={-1,-1,-1};
978 TClonesArray &aDigits = *tofDigits;
979 Int_t last=tofDigits->GetEntriesFast();
980 new (aDigits[last]) AliTOFdigit(tracknum, detectorIndex, digit);
984 clonesRawData->Clear();
992 AliDebug(1, Form("Got %d digits: ", fDigits->GetEntries()));
993 AliDebug(1, Form("Execution time to read TOF raw data and fill TOF digit tree : R:%.2fs C:%.2fs",
994 stopwatch.RealTime(),stopwatch.CpuTime()));
997 //______________________________________________________________________________
999 Int_t AliTOFClusterFinder::InsertCluster(AliTOFcluster *tofCluster) {
1000 //---------------------------------------------------------------------------//
1001 // This function adds a TOF cluster to the array of TOF clusters sorted in Z //
1002 //---------------------------------------------------------------------------//
1003 if (fNumberOfTofClusters==kTofMaxCluster) {
1004 AliError("Too many clusters !");
1008 if (fNumberOfTofClusters==0) {
1009 fTofClusters[fNumberOfTofClusters++] = tofCluster;
1013 Int_t ii = FindClusterIndex(tofCluster->GetZ());
1014 memmove(fTofClusters+ii+1 ,fTofClusters+ii,(fNumberOfTofClusters-ii)*sizeof(AliTOFcluster*));
1015 fTofClusters[ii] = tofCluster;
1016 fNumberOfTofClusters++;
1021 //_________________________________________________________________________
1023 Int_t AliTOFClusterFinder::FindClusterIndex(Double_t z) const {
1024 //--------------------------------------------------------------------
1025 // This function returns the index of the nearest cluster in z
1026 //--------------------------------------------------------------------
1027 if (fNumberOfTofClusters==0) return 0;
1028 if (z <= fTofClusters[0]->GetZ()) return 0;
1029 if (z > fTofClusters[fNumberOfTofClusters-1]->GetZ()) return fNumberOfTofClusters;
1030 Int_t b = 0, e = fNumberOfTofClusters-1, m = (b+e)/2;
1031 for (; b<e; m=(b+e)/2) {
1032 if (z > fTofClusters[m]->GetZ()) b=m+1;
1039 //_________________________________________________________________________
1041 void AliTOFClusterFinder::FillRecPoint()
1044 // Copy the global array of AliTOFcluster, i.e. fTofClusters (sorted
1045 // in Z) in the global TClonesArray of AliTOFcluster,
1051 Int_t detectorIndex[5];
1053 Int_t trackLabels[3];
1054 Int_t digitIndex = -1;
1055 Bool_t status=kTRUE;
1057 TClonesArray &lRecPoints = *fRecPoints;
1059 for (ii=0; ii<fNumberOfTofClusters; ii++) {
1061 digitIndex = fTofClusters[ii]->GetIndex();
1062 for(jj=0; jj<5; jj++) detectorIndex[jj] = fTofClusters[ii]->GetDetInd(jj);
1063 for(jj=0; jj<3; jj++) trackLabels[jj] = fTofClusters[ii]->GetLabel(jj);
1064 parTOF[0] = fTofClusters[ii]->GetTDC(); // TDC
1065 parTOF[1] = fTofClusters[ii]->GetToT(); // TOT
1066 parTOF[2] = fTofClusters[ii]->GetADC(); // ADC=TOT
1067 parTOF[3] = fTofClusters[ii]->GetTDCND(); // TDCND
1068 parTOF[4] = fTofClusters[ii]->GetTDCRAW();//RAW
1069 parTOF[5] = fTofClusters[ii]->GetDeltaBC();//deltaBC
1070 parTOF[6] = fTofClusters[ii]->GetL0L1Latency();//L0-L1 latency
1071 status=fTofClusters[ii]->GetStatus();
1072 Double_t posClus[3];
1073 Double_t covClus[6];
1074 UShort_t volIdClus=GetClusterVolIndex(detectorIndex);
1075 GetClusterPars(detectorIndex,posClus,covClus);
1076 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);
1078 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",
1079 ii, volIdClus, posClus[0], posClus[1], posClus[2],
1080 fTofClusters[ii]->GetSigmaX2(),
1081 fTofClusters[ii]->GetSigmaXY(),
1082 fTofClusters[ii]->GetSigmaXZ(),
1083 fTofClusters[ii]->GetSigmaY2(),
1084 fTofClusters[ii]->GetSigmaYZ(),
1085 fTofClusters[ii]->GetSigmaZ2(),
1086 trackLabels[0], trackLabels[1], trackLabels[2],
1087 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[3], detectorIndex[4],
1088 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
1089 status, digitIndex));
1091 } // loop on clusters
1095 //_________________________________________________________________________
1098 * OLD CALIBRATE REC POINTS FUNCTION
1102 void AliTOFClusterFinder::CalibrateRecPoint(UInt_t timestamp)
1105 // Copy the global array of AliTOFcluster, i.e. fTofClusters (sorted
1106 // in Z) in the global TClonesArray of AliTOFcluster,
1112 Int_t detectorIndex[5];
1113 Int_t digitIndex = -1;
1117 Float_t tdcLatencyWindow;
1118 AliDebug(1," Calibrating TOF Clusters");
1120 AliTOFChannelOnlineArray *calDelay = fTOFcalib->GetTOFOnlineDelay();
1121 AliTOFChannelOnlineStatusArray *calStatus = fTOFcalib->GetTOFOnlineStatus();
1122 TObjArray *calTOFArrayOffline = fTOFcalib->GetTOFCalArrayOffline();
1124 AliTOFDeltaBCOffset *deltaBCOffsetObj = fTOFcalib->GetDeltaBCOffset();
1125 Int_t deltaBCOffset = deltaBCOffsetObj->GetDeltaBCOffset();
1126 AliTOFCTPLatency *ctpLatencyObj = fTOFcalib->GetCTPLatency();
1127 Float_t ctpLatency = ctpLatencyObj->GetCTPLatency();
1128 AliTOFRunParams *runParamsObj = fTOFcalib->GetRunParams();
1129 Float_t t0 = runParamsObj->EvalT0(timestamp);
1131 TString validity = (TString)fTOFcalib->GetOfflineValidity();
1132 Int_t calibration = -1;
1133 if (validity.CompareTo("valid")==0) {
1134 //AliInfo(Form(" validity = %s - Using offline calibration parameters",validity.Data()));
1137 //AliInfo(Form(" validity = %s - Using online calibration parameters",validity.Data()));
1141 for (ii=0; ii<fNumberOfTofClusters; ii++) {
1142 digitIndex = fTofClusters[ii]->GetIndex();
1143 for(jj=0; jj<5; jj++) detectorIndex[jj] = fTofClusters[ii]->GetDetInd(jj);
1145 Int_t index = AliTOFGeometry::GetIndex(detectorIndex);
1147 UChar_t statusPulser=calStatus->GetPulserStatus(index);
1148 UChar_t statusNoise=calStatus->GetNoiseStatus(index);
1149 UChar_t statusHW=calStatus->GetHWStatus(index);
1150 UChar_t status=calStatus->GetStatus(index);
1151 tdcLatencyWindow = calStatus->GetLatencyWindow(index) * 1.e3; /* ns -> ps */
1153 //check the status, also unknown is fine!!!!!!!
1155 AliDebug(2, Form(" Status for channel %d = %d",index, (Int_t)status));
1156 if((statusPulser & AliTOFChannelOnlineStatusArray::kTOFPulserBad)==(AliTOFChannelOnlineStatusArray::kTOFPulserBad)||(statusNoise & AliTOFChannelOnlineStatusArray::kTOFNoiseBad)==(AliTOFChannelOnlineStatusArray::kTOFNoiseBad)||(statusHW & AliTOFChannelOnlineStatusArray::kTOFHWBad)==(AliTOFChannelOnlineStatusArray::kTOFHWBad)){
1157 AliDebug(2, Form(" Bad Status for channel %d",index));
1158 fTofClusters[ii]->SetStatus(kFALSE); //odd convention, to avoid conflict with calibration objects currently in the db (temporary solution).
1161 AliDebug(2, Form(" Good Status for channel %d",index));
1163 // Get Rough channel online equalization
1164 Double_t roughDelay=(Double_t)calDelay->GetDelay(index); // in ns
1165 AliDebug(2,Form(" channel delay (ns) = %f", roughDelay));
1166 // Get Refined channel offline calibration parameters
1167 if (calibration ==1){
1168 AliTOFChannelOffline * calChannelOffline = (AliTOFChannelOffline*)calTOFArrayOffline->At(index);
1170 for (Int_t j = 0; j<6; j++){
1171 par[j]=(Double_t)calChannelOffline->GetSlewPar(j);
1173 AliDebug(2,Form(" Calib Pars = %f, %f, %f, %f, %f, %f ",par[0],par[1],par[2],par[3],par[4],par[5]));
1174 AliDebug(2,Form(" The ToT and Time, uncorr (counts) = %d , %d", fTofClusters[ii]->GetToT(),fTofClusters[ii]->GetTDC()));
1175 tToT = (Double_t)(fTofClusters[ii]->GetToT()*AliTOFGeometry::ToTBinWidth());
1176 tToT*=1.E-3; //ToT in ns
1178 /* check TOT limits and set new TOT in case */
1179 if (tToT < AliTOFGeometry::SlewTOTMin()) tToT = AliTOFGeometry::SlewTOTMin();
1180 if (tToT > AliTOFGeometry::SlewTOTMax()) tToT = AliTOFGeometry::SlewTOTMax();
1182 AliDebug(2,Form(" The ToT and Time, uncorr (ns)= %e, %e",fTofClusters[ii]->GetTDC()*AliTOFGeometry::TdcBinWidth()*1.E-3,tToT));
1183 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)
1186 timeCorr = roughDelay; // correction in ns
1188 AliDebug(2,Form(" The ToT and Time, uncorr (ns)= %e, %e",fTofClusters[ii]->GetTDC()*AliTOFGeometry::TdcBinWidth()*1.E-3,fTofClusters[ii]->GetToT()*AliTOFGeometry::ToTBinWidth()));
1189 AliDebug(2,Form(" The time correction (ns) = %f", timeCorr));
1190 timeCorr=(Double_t)(fTofClusters[ii]->GetTDC())*AliTOFGeometry::TdcBinWidth()*1.E-3-timeCorr;//redefine the time
1192 AliDebug(2,Form(" The channel time, corr (ps)= %e",timeCorr ));
1194 /* here timeCorr should be already corrected for calibration.
1195 * we now go into further corrections keeping in mind that timeCorr
1198 * the following corrections are performed in this way:
1200 * time = timeRaw - deltaBC + L0L1Latency + CTPLatency - TDCLatencyWindow - T0
1204 AliDebug(2, Form("applying further corrections (DeltaBC): DeltaBC=%d (BC bins), DeltaBCoffset=%d (BC bins)", fTofClusters[ii]->GetDeltaBC(), deltaBCOffset));
1205 AliDebug(2, Form("applying further corrections (L0L1Latency): L0L1Latency=%d (BC bins)", fTofClusters[ii]->GetL0L1Latency()));
1206 AliDebug(2, Form("applying further corrections (CTPLatency): CTPLatency=%f (ps)", ctpLatency));
1207 AliDebug(2, Form("applying further corrections (TDCLatencyWindow): TDCLatencyWindow=%f (ps)", tdcLatencyWindow));
1208 AliDebug(2, Form("applying further corrections (T0): T0=%f (ps)", t0));
1210 /* deltaBC correction (inhibited for the time being) */
1211 // timeCorr -= (fTofClusters[ii]->GetDeltaBC() - deltaBCOffset) * AliTOFGeometry::BunchCrossingBinWidth();
1212 /* L0L1-latency correction */
1213 timeCorr += fTofClusters[ii]->GetL0L1Latency() * AliTOFGeometry::BunchCrossingBinWidth();
1214 /* CTP-latency correction (from OCDB) */
1215 timeCorr += ctpLatency;
1216 /* TDC latency-window correction (from OCDB) */
1217 timeCorr -= tdcLatencyWindow;
1218 /* T0 correction (from OCDB) */
1222 * end of furhter corrections
1225 tdcCorr=(Int_t)(timeCorr/AliTOFGeometry::TdcBinWidth()); //the corrected time (tdc counts)
1226 fTofClusters[ii]->SetTDC(tdcCorr);
1227 } // loop on clusters
1232 //_________________________________________________________________________
1234 void AliTOFClusterFinder::CalibrateRecPoint(UInt_t timestamp)
1237 // Copy the global array of AliTOFcluster, i.e. fTofClusters (sorted
1238 // in Z) in the global TClonesArray of AliTOFcluster,
1242 Int_t detectorIndex[5];
1243 Double_t time, tot, corr;
1244 Int_t deltaBC, l0l1, tdcBin;
1245 for (Int_t ii = 0; ii < fNumberOfTofClusters; ii++) {
1246 for(Int_t jj = 0; jj < 5; jj++) detectorIndex[jj] = fTofClusters[ii]->GetDetInd(jj);
1248 Int_t index = AliTOFGeometry::GetIndex(detectorIndex);
1250 /* check channel enabled */
1251 if (!fTOFcalib->IsChannelEnabled(index)) fTofClusters[ii]->SetStatus(kFALSE);
1253 /* get cluster info */
1254 time = fTofClusters[ii]->GetTDC() * AliTOFGeometry::TdcBinWidth(); /* ps */
1255 tot = fTofClusters[ii]->GetToT() * AliTOFGeometry::ToTBinWidth() * 1.e-3; /* ns */
1256 deltaBC = fTofClusters[ii]->GetDeltaBC();
1257 l0l1 = fTofClusters[ii]->GetL0L1Latency();
1259 /* get correction */
1260 corr = fTOFcalib->GetTimeCorrection(index, tot, deltaBC, l0l1, timestamp); /* ps */
1261 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));
1263 /* apply time correction */
1266 /* convert in TDC bins and set cluster */
1267 tdcBin = (Int_t)(time / AliTOFGeometry::TdcBinWidth()); //the corrected time (tdc counts)
1268 fTofClusters[ii]->SetTDC(tdcBin);
1270 } // loop on clusters
1274 //______________________________________________________________________________
1276 void AliTOFClusterFinder::ResetRecpoint()
1279 // Clear the list of reconstructed points
1282 fNumberOfTofClusters = 0;
1283 if (fRecPoints) fRecPoints->Clear();
1286 //______________________________________________________________________________
1288 void AliTOFClusterFinder::Load()
1291 // Load TOF.Digits.root and TOF.RecPoints.root files
1294 fTOFLoader->LoadDigits("READ");
1295 fTOFLoader->LoadRecPoints("recreate");
1298 //______________________________________________________________________________
1300 void AliTOFClusterFinder::LoadClusters()
1303 // Load TOF.RecPoints.root file
1306 fTOFLoader->LoadRecPoints("recreate");
1309 //______________________________________________________________________________
1311 void AliTOFClusterFinder::UnLoad()
1314 // Unload TOF.Digits.root and TOF.RecPoints.root files
1317 fTOFLoader->UnloadDigits();
1318 fTOFLoader->UnloadRecPoints();
1321 //______________________________________________________________________________
1323 void AliTOFClusterFinder::UnLoadClusters()
1326 // Unload TOF.RecPoints.root file
1329 fTOFLoader->UnloadRecPoints();
1332 //-------------------------------------------------------------------------
1333 UShort_t AliTOFClusterFinder::GetClusterVolIndex(const Int_t * const ind) const {
1335 //First of all get the volume ID to retrieve the l2t transformation...
1337 // Detector numbering scheme
1344 Int_t isector =ind[0];
1345 if (isector >= nSector)
1346 AliError(Form("Wrong sector number in TOF (%d) !",isector));
1347 Int_t iplate = ind[1];
1348 if (iplate >= nPlate)
1349 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
1350 Int_t istrip = ind[2];
1352 Int_t stripOffset = 0;
1358 stripOffset = nStripC;
1361 stripOffset = nStripC+nStripB;
1364 stripOffset = nStripC+nStripB+nStripA;
1367 stripOffset = nStripC+nStripB+nStripA+nStripB;
1370 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
1374 Int_t index= (2*(nStripC+nStripB)+nStripA)*isector +
1378 UShort_t volIndex = AliGeomManager::LayerToVolUID(AliGeomManager::kTOF,index);
1382 //-------------------------------------------------------------------------
1383 void AliTOFClusterFinder::GetClusterPars(Int_t *ind, Double_t* pos,Double_t* cov) const {
1385 //First of all get the volume ID to retrieve the l2t transformation...
1387 UShort_t volIndex = GetClusterVolIndex(ind);
1390 //we now go in the system of the strip: determine the local coordinates
1393 // 47---------------------------------------------------0 ^ z
1394 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 1 |
1395 // ----------------------------------------------------- | y going outwards
1396 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 0 | par[0]=0;
1398 // ----------------------------------------------------- |
1399 // x <-----------------------------------------------------
1402 Float_t localX = (ind[4]-23.5)*AliTOFGeometry::XPad();
1404 Float_t localZ = (ind[3]- 0.5)*AliTOFGeometry::ZPad();
1406 Float_t localX = (ind[4]-AliTOFGeometry::NpadX()/2)*AliTOFGeometry::XPad()+AliTOFGeometry::XPad()/2.;
1408 Float_t localZ = (ind[3]-AliTOFGeometry::NpadZ()/2)*AliTOFGeometry::ZPad()+AliTOFGeometry::ZPad()/2.;
1409 //move to the tracking ref system
1416 const TGeoHMatrix *l2t= AliGeomManager::GetTracking2LocalMatrix(volIndex);
1417 // Get The position in the track ref system
1419 l2t->MasterToLocal(lpos,tpos);
1424 //Get The cluster covariance in the track ref system
1427 //cluster covariance in the local system:
1432 lcov[0] = AliTOFGeometry::XPad()*AliTOFGeometry::XPad()/12.;
1440 lcov[8] = AliTOFGeometry::ZPad()*AliTOFGeometry::ZPad()/12.;
1442 //cluster covariance in the tracking system:
1444 m.SetRotation(lcov);
1446 m.MultiplyLeft(&l2t->Inverse());
1447 Double_t *tcov = m.GetRotationMatrix();
1448 cov[0] = tcov[0]; cov[1] = tcov[1]; cov[2] = tcov[2];
1449 cov[3] = tcov[4]; cov[4] = tcov[5];