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 **************************************************************************/
18 Revision 1.24 2007/04/27 11:19:31 arcelli
19 updates for the new decoder
21 Revision 1.23 2007/04/23 16:51:39 decaro
22 Digits-to-raw_data conversion: correction for a more real description (A.De Caro, R.Preghenella)
24 Revision 1.22 2007/04/19 17:26:32 arcelli
25 Fix a bug (add some debug printout
27 Revision 1.21 2007/04/18 17:28:12 arcelli
28 Set the ToT bin width to the one actually used...
30 Revision 1.20 2007/03/09 09:57:23 arcelli
31 Remove a forgotten include of Riostrem
33 Revision 1.19 2007/03/08 15:41:20 arcelli
34 set uncorrected times when filling RecPoints
36 Revision 1.18 2007/03/06 16:31:20 arcelli
37 Add Uncorrected TOF Time signal
39 Revision 1.17 2007/02/28 18:09:11 arcelli
40 Add protection against failed retrieval of the CDB cal object, now Reconstruction exits with AliFatal
42 Revision 1.16 2007/02/20 15:57:00 decaro
43 Raw data update: to read the TOF raw data defined in UNPACKED mode
46 Revision 0.03 2005/07/28 A. De Caro
47 Implement public method
48 Raw2Digits(Int_t, AliRawReader *)
49 to convert digits from raw data in MC digits
52 Revision 0.02 2005/07/27 A. De Caro
53 Implement public method
54 Digits2RecPoint(Int_t)
55 to convert digits in clusters
57 Revision 0.02 2005/07/26 A. De Caro
58 Implement private methods
59 InsertCluster(AliTOFcluster *)
60 FindClusterIndex(Double_t)
61 originally implemented in AliTOFtracker
62 by S. Arcelli and C. Zampolli
64 Revision 0.01 2005/07/25 A. De Caro
65 Implement public methods
66 Digits2RecPoint(AliRawReader *, TTree *)
67 Digits2RecPoint(Int_t, AliRawReader *)
68 to convert raw data in clusters
71 ////////////////////////////////////////////////////////////////
73 // Class for TOF cluster finder //
75 // Starting from Raw Data, create rec points, //
76 // fill TreeR for TOF, //
77 // write TOF.RecPoints.root file //
79 ////////////////////////////////////////////////////////////////
82 #include "TClonesArray.h"
84 #include "TStopwatch.h"
88 #include "AliLoader.h"
90 #include "AliRawReader.h"
91 #include "AliRunLoader.h"
93 #include "AliTOFCal.h"
94 #include "AliTOFcalib.h"
95 #include "AliTOFChannel.h"
96 #include "AliTOFClusterFinder.h"
97 #include "AliTOFcluster.h"
98 #include "AliTOFdigit.h"
99 #include "AliTOFGeometry.h"
100 #include "AliTOFGeometryV5.h"
101 #include "AliTOFrawData.h"
102 #include "AliTOFRawStream.h"
103 #include "Riostream.h"
105 //extern TFile *gFile;
107 ClassImp(AliTOFClusterFinder)
109 AliTOFClusterFinder::AliTOFClusterFinder():
114 fTOFGeometry(new AliTOFGeometryV5()),
115 fDigits(new TClonesArray("AliTOFdigit", 4000)),
116 fRecPoints(new TClonesArray("AliTOFcluster", 4000)),
117 fNumberOfTofClusters(0),
125 AliInfo("V5 TOF Geometry is taken as the default");
128 //______________________________________________________________________________
130 AliTOFClusterFinder::AliTOFClusterFinder(AliRunLoader* runLoader):
131 fRunLoader(runLoader),
132 fTOFLoader(runLoader->GetLoader("TOFLoader")),
135 fTOFGeometry(new AliTOFGeometryV5()),
136 fDigits(new TClonesArray("AliTOFdigit", 4000)),
137 fRecPoints(new TClonesArray("AliTOFcluster", 4000)),
138 fNumberOfTofClusters(0),
146 // runLoader->CdGAFile();
147 // TFile *in=(TFile*)gFile;
149 // fTOFGeometry = (AliTOFGeometry*)in->Get("TOFgeometry");
153 //------------------------------------------------------------------------
154 AliTOFClusterFinder::AliTOFClusterFinder(const AliTOFClusterFinder &source)
160 fTOFGeometry(new AliTOFGeometryV5()),
161 fDigits(new TClonesArray("AliTOFdigit", 4000)),
162 fRecPoints(new TClonesArray("AliTOFcluster", 4000)),
163 fNumberOfTofClusters(0),
168 this->fDigits=source.fDigits;
169 this->fRecPoints=source.fRecPoints;
170 this->fTOFGeometry=source.fTOFGeometry;
171 this->fDecoderVersion=source.fDecoderVersion;
175 //------------------------------------------------------------------------
176 AliTOFClusterFinder& AliTOFClusterFinder::operator=(const AliTOFClusterFinder &source)
179 this->fDigits=source.fDigits;
180 this->fRecPoints=source.fRecPoints;
181 this->fTOFGeometry=source.fTOFGeometry;
182 this->fVerbose=source.fVerbose;
183 this->fDecoderVersion=source.fDecoderVersion;
187 //______________________________________________________________________________
189 AliTOFClusterFinder::~AliTOFClusterFinder()
204 fRecPoints->Delete();
212 //______________________________________________________________________________
214 void AliTOFClusterFinder::Digits2RecPoints(Int_t iEvent)
217 // Converts digits to recpoints for TOF
220 TStopwatch stopwatch;
223 fRunLoader->GetEvent(iEvent);
225 fTreeD = fTOFLoader->TreeD();
228 AliFatal("AliTOFClusterFinder: Can not get TreeD");
231 TBranch *branch = fTreeD->GetBranch("TOF");
233 AliError("can't get the branch with the TOF digits !");
237 TClonesArray *digits = new TClonesArray("AliTOFdigit",10000);
238 branch->SetAddress(&digits);
242 fTreeR = fTOFLoader->TreeR();
245 fTOFLoader->MakeTree("R");
246 fTreeR = fTOFLoader->TreeR();
249 Int_t bufsize = 32000;
250 fTreeR->Branch("TOF", &fRecPoints, bufsize);
253 Int_t nDigits = digits->GetEntriesFast();
254 AliDebug(2,Form("Number of TOF digits: %d",nDigits));
257 Int_t dig[5]; //cluster detector indeces
258 Float_t g[3]; //cluster cartesian coord
259 Double_t h[3]; // the cluster spatial cyl. coordinates
260 Int_t parTOF[5]; //The TOF signal parameters
261 Bool_t status=kTRUE; // assume all sim channels ok in the beginning...
262 for (ii=0; ii<nDigits; ii++) {
263 AliTOFdigit *d = (AliTOFdigit*)digits->UncheckedAt(ii);
264 dig[0]=d->GetSector();
265 dig[1]=d->GetPlate();
266 dig[2]=d->GetStrip();
270 // AliDebug(2,Form(" %2i %1i %2i %1i %2i ",dig[0],dig[1],dig[2],dig[3],dig[4]));
272 for (jj=0; jj<3; jj++) g[jj] = 0.;
273 fTOFGeometry->GetPos(dig,g);
275 h[0] = TMath::Sqrt(g[0]*g[0]+g[1]*g[1]);
276 h[1] = TMath::ATan2(g[1],g[0]);
279 parTOF[0] = d->GetTdc(); //the TDC signal
280 parTOF[1] = d->GetToT(); //the ToT signal
281 parTOF[2] = d->GetAdc(); // the adc charge
282 parTOF[3] = d->GetTdcND(); // non decalibrated sim time
283 parTOF[4] = d->GetTdc(); // raw time, == Tdc time for the moment
284 AliTOFcluster *tofCluster = new AliTOFcluster(h,dig,parTOF,status,d->GetTracks(),ii);
285 InsertCluster(tofCluster);
289 AliInfo(Form("Number of found clusters: %i", fNumberOfTofClusters));
297 fTOFLoader = fRunLoader->GetLoader("TOFLoader");
298 fTOFLoader->WriteRecPoints("OVERWRITE");
300 AliInfo(Form("Execution time to read TOF digits and to write TOF clusters : R:%.4fs C:%.4fs",
301 stopwatch.RealTime(),stopwatch.CpuTime()));
304 //______________________________________________________________________________
306 void AliTOFClusterFinder::Digits2RecPoints(AliRawReader *rawReader,
310 // Converts RAW data to recpoints for TOF
313 TStopwatch stopwatch;
316 //const Int_t kDDL = fTOFGeometry->NDDL()*fTOFGeometry->NSectors();
317 const Int_t kDDL = AliDAQ::NumberOfDdls("TOF");
321 Int_t bufsize = 32000;
322 clustersTree->Branch("TOF", &fRecPoints, bufsize);
324 TClonesArray * clonesRawData;
329 Int_t detectorIndex[5];
331 Double_t cylindricalPosition[3];
335 if (fVerbose==2) ftxt.open("TOFdigitsRead.txt",ios::app);
338 for (indexDDL = 0; indexDDL < kDDL; indexDDL++) {
341 AliTOFRawStream tofInput(rawReader);
342 if (fDecoderVersion) {
343 AliInfo("Using New Decoder \n");
344 tofInput.LoadRawDataBuffers(indexDDL,fVerbose);
346 else tofInput.LoadRawData(indexDDL);
348 clonesRawData = (TClonesArray*)tofInput.GetRawData();
350 for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
352 AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
354 if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
357 if (indexDDL<10) ftxt << " " << indexDDL;
358 else ftxt << " " << indexDDL;
359 if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM();
360 else ftxt << " " << tofRawDatum->GetTRM();
361 ftxt << " " << tofRawDatum->GetTRMchain();
362 if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC();
363 else ftxt << " " << tofRawDatum->GetTDC();
364 ftxt << " " << tofRawDatum->GetTDCchannel();
367 tofInput.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
368 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
369 dummy = detectorIndex[3];
370 detectorIndex[3] = detectorIndex[4];
371 detectorIndex[4] = dummy;
374 if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0];
375 else ftxt << " -> " << detectorIndex[0];
376 ftxt << " " << detectorIndex[1];
377 if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2];
378 else ftxt << " " << detectorIndex[2];
379 ftxt << " " << detectorIndex[3];
380 if (detectorIndex[4]<10) ftxt << " " << detectorIndex[4];
381 else ftxt << " " << detectorIndex[4];
384 for (ii=0; ii<3; ii++) position[ii] = 0.;
385 fTOFGeometry->GetPos(detectorIndex, position);
387 cylindricalPosition[0] = TMath::Sqrt(position[0]*position[0] + position[1]*position[1]);
388 cylindricalPosition[1] = TMath::ATan2(position[1], position[0]);
389 cylindricalPosition[2] = position[2];
391 parTOF[0] = tofRawDatum->GetTOF(); //TDC
392 parTOF[1] = tofRawDatum->GetTOT(); // TOT
393 parTOF[2] = tofRawDatum->GetTOT(); //ADC==TOF
394 parTOF[3] = -1;//raw data: no track of undecalib sim time
395 parTOF[4] = tofRawDatum->GetTOF(); // RAW time
396 AliTOFcluster *tofCluster = new AliTOFcluster(cylindricalPosition, detectorIndex, parTOF);
397 InsertCluster(tofCluster);
400 if (parTOF[1]<10)ftxt << " " << parTOF[1];
401 else if (parTOF[1]>=10 && parTOF[1]<100) ftxt << " " << parTOF[1];
402 else ftxt << " " << parTOF[1];
403 if (parTOF[0]<10) ftxt << " " << parTOF[0] << endl;
404 else if (parTOF[0]>=10 && parTOF[0]<100) ftxt << " " << parTOF[0] << endl;
405 else if (parTOF[0]>=100 && parTOF[0]<1000) ftxt << " " << parTOF[0] << endl;
406 else ftxt << " " << parTOF[3] << endl;
409 } // closed loop on TOF raw data per current DDL file
411 clonesRawData->Clear();
413 } // closed loop on DDL index
415 if (fVerbose==2) ftxt.close();
417 AliInfo(Form("Number of found clusters: %i", fNumberOfTofClusters));
422 clustersTree->Fill();
426 AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters : R:%.4fs C:%.4fs",
427 stopwatch.RealTime(),stopwatch.CpuTime()));
430 //______________________________________________________________________________
432 void AliTOFClusterFinder::Digits2RecPoints(Int_t iEvent, AliRawReader *rawReader)
435 // Converts RAW data to recpoints for TOF
438 TStopwatch stopwatch;
441 //const Int_t kDDL = fTOFGeometry->NDDL()*fTOFGeometry->NSectors();
442 const Int_t kDDL = AliDAQ::NumberOfDdls("TOF");
444 fRunLoader->GetEvent(iEvent);
446 AliDebug(2,Form(" Event number %2i ", iEvent));
448 fTreeR = fTOFLoader->TreeR();
451 fTOFLoader->MakeTree("R");
452 fTreeR = fTOFLoader->TreeR();
455 Int_t bufsize = 32000;
456 fTreeR->Branch("TOF", &fRecPoints, bufsize);
458 TClonesArray * clonesRawData;
463 Int_t detectorIndex[5] = {-1, -1, -1, -1, -1};
465 Double_t cylindricalPosition[5];
468 if (fVerbose==2) ftxt.open("TOFdigitsRead.txt",ios::app);
471 for (indexDDL = 0; indexDDL < kDDL; indexDDL++) {
474 AliTOFRawStream tofInput(rawReader);
475 if (fDecoderVersion) {
476 AliInfo("Using New Decoder \n");
477 tofInput.LoadRawDataBuffers(indexDDL,fVerbose);
479 else tofInput.LoadRawData(indexDDL);
481 clonesRawData = (TClonesArray*)tofInput.GetRawData();
483 for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
485 AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
487 if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
490 if (indexDDL<10) ftxt << " " << indexDDL;
491 else ftxt << " " << indexDDL;
492 if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM();
493 else ftxt << " " << tofRawDatum->GetTRM();
494 ftxt << " " << tofRawDatum->GetTRMchain();
495 if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC();
496 else ftxt << " " << tofRawDatum->GetTDC();
497 ftxt << " " << tofRawDatum->GetTDCchannel();
500 tofInput.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
501 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
502 dummy = detectorIndex[3];
503 detectorIndex[3] = detectorIndex[4];
504 detectorIndex[4] = dummy;
507 if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0];
508 else ftxt << " -> " << detectorIndex[0];
509 ftxt << " " << detectorIndex[1];
510 if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2];
511 else ftxt << " " << detectorIndex[2];
512 ftxt << " " << detectorIndex[3];
513 if (detectorIndex[4]<10) ftxt << " " << detectorIndex[4];
514 else ftxt << " " << detectorIndex[4];
517 for (ii=0; ii<3; ii++) position[ii] = 0.;
518 fTOFGeometry->GetPos(detectorIndex, position);
520 cylindricalPosition[0] = TMath::Sqrt(position[0]*position[0] + position[1]*position[1]);
521 cylindricalPosition[1] = TMath::ATan2(position[1], position[0]);
522 cylindricalPosition[2] = position[2];
523 parTOF[0] = tofRawDatum->GetTOF(); // TDC
524 parTOF[1] = tofRawDatum->GetTOT(); // TOT
525 parTOF[2] = tofRawDatum->GetTOT(); // raw data have ADC=TOT
526 parTOF[3] = -1; //raw data: no track of the undecalib sim time
527 parTOF[4] = tofRawDatum->GetTOF(); // Raw time == TDC
528 AliTOFcluster *tofCluster = new AliTOFcluster(cylindricalPosition, detectorIndex, parTOF);
529 InsertCluster(tofCluster);
532 if (parTOF[1]<10)ftxt << " " << parTOF[1];
533 else if (parTOF[1]>=10 && parTOF[1]<100) ftxt << " " << parTOF[1];
534 else ftxt << " " << parTOF[1];
535 if (parTOF[0]<10) ftxt << " " << parTOF[0] << endl;
536 else if (parTOF[0]>=10 && parTOF[0]<100) ftxt << " " << parTOF[0] << endl;
537 else if (parTOF[0]>=100 && parTOF[0]<1000) ftxt << " " << parTOF[0] << endl;
538 else ftxt << " " << parTOF[3] << endl;
541 } // closed loop on TOF raw data per current DDL file
543 clonesRawData->Clear();
545 } // closed loop on DDL index
547 if (fVerbose==2) ftxt.close();
549 AliInfo(Form("Number of found clusters: %i", fNumberOfTofClusters));
557 fTOFLoader = fRunLoader->GetLoader("TOFLoader");
558 fTOFLoader->WriteRecPoints("OVERWRITE");
560 AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters : R:%.4fs C:%.4fs",
561 stopwatch.RealTime(),stopwatch.CpuTime()));
564 //______________________________________________________________________________
566 void AliTOFClusterFinder::Raw2Digits(Int_t iEvent, AliRawReader *rawReader)
569 // Converts RAW data to MC digits for TOF
571 // (temporary solution)
574 TStopwatch stopwatch;
577 //const Int_t kDDL = fTOFGeometry->NDDL()*fTOFGeometry->NSectors();
578 const Int_t kDDL = fTOFGeometry->NDDL()*fTOFGeometry->NSectors();
580 fRunLoader->GetEvent(iEvent);
582 fTreeD = fTOFLoader->TreeD();
585 AliInfo("TreeD re-creation");
587 fTOFLoader->MakeTree("D");
588 fTreeD = fTOFLoader->TreeD();
591 TClonesArray *tofDigits = new TClonesArray("AliTOFdigit",10000);
592 Int_t bufsize = 32000;
593 fTreeD->Branch("TOF", &tofDigits, bufsize);
595 fRunLoader->GetEvent(iEvent);
597 AliDebug(2,Form(" Event number %2i ", iEvent));
599 TClonesArray * clonesRawData;
603 Int_t detectorIndex[5];
607 for (indexDDL = 0; indexDDL < kDDL; indexDDL++) {
610 AliTOFRawStream tofInput(rawReader);
611 if (fDecoderVersion) {
612 AliInfo("Using New Decoder \n");
613 tofInput.LoadRawDataBuffers(indexDDL,fVerbose);
615 else tofInput.LoadRawData(indexDDL);
617 clonesRawData = (TClonesArray*)tofInput.GetRawData();
619 for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
621 AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
623 if (!tofRawDatum->GetTOT() || !tofRawDatum->GetTOF()) continue;
625 tofInput.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
626 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
627 dummy = detectorIndex[3];
628 detectorIndex[3] = detectorIndex[4];
629 detectorIndex[4] = dummy;
631 digit[0] = tofInput.GetTofBin();
632 digit[1] = tofInput.GetToTbin();
633 digit[2] = tofInput.GetToTbin();
636 Int_t tracknum[3]={-1,-1,-1};
638 TClonesArray &aDigits = *tofDigits;
639 Int_t last=tofDigits->GetEntriesFast();
640 new (aDigits[last]) AliTOFdigit(tracknum, detectorIndex, digit);
644 clonesRawData->Clear();
650 fTOFLoader = fRunLoader->GetLoader("TOFLoader");
651 fTOFLoader->WriteDigits("OVERWRITE");
653 AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters : R:%.2fs C:%.2fs",
654 stopwatch.RealTime(),stopwatch.CpuTime()));
657 //______________________________________________________________________________
659 Int_t AliTOFClusterFinder::InsertCluster(AliTOFcluster *tofCluster) {
660 //---------------------------------------------------------------------------//
661 // This function adds a TOF cluster to the array of TOF clusters sorted in Z //
662 //---------------------------------------------------------------------------//
663 if (fNumberOfTofClusters==kTofMaxCluster) {
664 AliError("Too many clusters !");
668 if (fNumberOfTofClusters==0) {
669 fTofClusters[fNumberOfTofClusters++] = tofCluster;
673 Int_t ii = FindClusterIndex(tofCluster->GetZ());
674 memmove(fTofClusters+ii+1 ,fTofClusters+ii,(fNumberOfTofClusters-ii)*sizeof(AliTOFcluster*));
675 fTofClusters[ii] = tofCluster;
676 fNumberOfTofClusters++;
681 //_________________________________________________________________________
683 Int_t AliTOFClusterFinder::FindClusterIndex(Double_t z) const {
684 //--------------------------------------------------------------------
685 // This function returns the index of the nearest cluster
686 //--------------------------------------------------------------------
687 if (fNumberOfTofClusters==0) return 0;
688 if (z <= fTofClusters[0]->GetZ()) return 0;
689 if (z > fTofClusters[fNumberOfTofClusters-1]->GetZ()) return fNumberOfTofClusters;
690 Int_t b = 0, e = fNumberOfTofClusters-1, m = (b+e)/2;
691 for (; b<e; m=(b+e)/2) {
692 if (z > fTofClusters[m]->GetZ()) b=m+1;
699 //_________________________________________________________________________
701 void AliTOFClusterFinder::FillRecPoint()
704 // Copy the global array of AliTOFcluster, i.e. fTofClusters (sorted
705 // in Z) in the global TClonesArray of AliTOFcluster,
711 Int_t detectorIndex[5];
712 Double_t cylindricalPosition[3];
714 Int_t trackLabels[3];
715 Int_t digitIndex = -1;
718 TClonesArray &lRecPoints = *fRecPoints;
720 for (ii=0; ii<fNumberOfTofClusters; ii++) {
722 digitIndex = fTofClusters[ii]->GetIndex();
723 for(jj=0; jj<5; jj++) detectorIndex[jj] = fTofClusters[ii]->GetDetInd(jj);
724 for(jj=0; jj<3; jj++) trackLabels[jj] = fTofClusters[ii]->GetLabel(jj);
725 cylindricalPosition[0] = fTofClusters[ii]->GetR();
726 cylindricalPosition[1] = fTofClusters[ii]->GetPhi();
727 cylindricalPosition[2] = fTofClusters[ii]->GetZ();
728 parTOF[0] = fTofClusters[ii]->GetTDC(); // TDC
729 parTOF[1] = fTofClusters[ii]->GetToT(); // TOT
730 parTOF[2] = fTofClusters[ii]->GetADC(); // ADC=TOT
731 parTOF[3] = fTofClusters[ii]->GetTDCND(); // TDCND
732 parTOF[4] = fTofClusters[ii]->GetTDCRAW();//RAW
733 status=fTofClusters[ii]->GetStatus();
734 new(lRecPoints[ii]) AliTOFcluster(cylindricalPosition, detectorIndex, parTOF,status,trackLabels,digitIndex);
736 } // loop on clusters
740 //_________________________________________________________________________
741 void AliTOFClusterFinder::CalibrateRecPoint()
744 // Copy the global array of AliTOFcluster, i.e. fTofClusters (sorted
745 // in Z) in the global TClonesArray of AliTOFcluster,
751 Int_t detectorIndex[5];
752 Int_t digitIndex = -1;
756 AliInfo(" Calibrating TOF Clusters: ")
757 AliTOFcalib *calib = new AliTOFcalib(fTOFGeometry);
758 if(!calib->ReadParFromCDB("TOF/Calib",-1)) {AliFatal("Exiting, no CDB object found!!!");exit(0);}
760 AliTOFCal *calTOFArray = calib->GetTOFCalArray();
762 for (ii=0; ii<fNumberOfTofClusters; ii++) {
763 digitIndex = fTofClusters[ii]->GetIndex();
764 for(jj=0; jj<5; jj++) detectorIndex[jj] = fTofClusters[ii]->GetDetInd(jj);
766 Int_t index = calib->GetIndex(detectorIndex);
768 AliTOFChannel * calChannel = calTOFArray->GetChannel(index);
770 // Get channel status
771 Bool_t status=calChannel->GetStatus();
772 if(status)fTofClusters[ii]->SetStatus(!status); //odd convention, to avoid conflict with calibration objects currently in the db (temporary solution).
773 // Get Rough channel online equalization
774 Float_t roughDelay=calChannel->GetDelay();
775 AliDebug(2,Form(" channel delay = %f", roughDelay));
776 // Get Refined channel offline calibration parameters
778 for (Int_t j = 0; j<6; j++){
779 par[j]=calChannel->GetSlewPar(j);
780 AliDebug(2,Form(" Calib Pars = %f, %f, %f, %f, %f, %f ",par[0],par[1],par[2],par[3],par[4],par[5]));
782 AliDebug(2,Form(" The ToT and Time, uncorr (counts) = %i , %i", fTofClusters[ii]->GetToT(),fTofClusters[ii]->GetTDC()));
783 tToT = (Float_t)(fTofClusters[ii]->GetToT())*AliTOFGeometry::ToTBinWidth()*1.E-3; //ToT in ns
784 AliDebug(2,Form(" The ToT and Time, uncorr (ns)= %f, %f",fTofClusters[ii]->GetTDC()*AliTOFGeometry::TdcBinWidth()*1.E-3,tToT));
785 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+roughDelay; // the time correction
786 AliDebug(2,Form(" The time correction (ns) = %f", timeCorr));
787 timeCorr=((Float_t)(fTofClusters[ii]->GetTDC())*AliTOFGeometry::TdcBinWidth()+32)*1.E-3-timeCorr;//redefine the time
788 AliDebug(2,Form(" The channel time, corr (ns)= %f",timeCorr ));
789 tdcCorr=(Int_t)((timeCorr*1E3-32)/AliTOFGeometry::TdcBinWidth()); //the corrected time (tdc counts)
790 fTofClusters[ii]->SetTDC(tdcCorr);
791 AliDebug(2,Form(" The channel time, corr (counts) counts= %i",fTofClusters[ii]->GetTDC()));
793 } // loop on clusters
797 //______________________________________________________________________________
799 void AliTOFClusterFinder::ResetRecpoint()
802 // Clear the list of reconstructed points
805 fNumberOfTofClusters = 0;
806 if (fRecPoints) fRecPoints->Clear();
809 //______________________________________________________________________________
811 void AliTOFClusterFinder::Load()
814 // Load TOF.Digits.root and TOF.RecPoints.root files
817 fTOFLoader->LoadDigits("READ");
818 fTOFLoader->LoadRecPoints("recreate");
821 //______________________________________________________________________________
823 void AliTOFClusterFinder::LoadClusters()
826 // Load TOF.RecPoints.root file
829 fTOFLoader->LoadRecPoints("recreate");
832 //______________________________________________________________________________
834 void AliTOFClusterFinder::UnLoad()
837 // Unload TOF.Digits.root and TOF.RecPoints.root files
840 fTOFLoader->UnloadDigits();
841 fTOFLoader->UnloadRecPoints();
844 //______________________________________________________________________________
846 void AliTOFClusterFinder::UnLoadClusters()
849 // Unload TOF.RecPoints.root file
852 fTOFLoader->UnloadRecPoints();
855 //______________________________________________________________________________