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: AliTOFClusterFinderV1.cxx,v $
18 Revision 2009/04/20 A. De Caro
19 - added two new global variables, called fTOFGeometry and fTOFdigits;
20 - added a new method, called FindClustersWithoutTOT,
21 to transform TOF digits with fTOT=0 in one pad clusters;
22 - update of the covariance matrix elements for the TOF clusters
24 Revision 0.01 2008/05/10 A. De Caro
27 /////////////////////////////////////////
29 // Class for TOF cluster finder (V1) //
31 // Input data: Raw Data or Digits; //
32 // Output data: Digits or Rec Points //
34 /////////////////////////////////////////
36 #include "Riostream.h"
38 #include "TClonesArray.h"
39 #include "TStopwatch.h"
41 #include "TGeoMatrix.h"
46 #include "AliRawReader.h"
47 #include "AliRunLoader.h"
48 #include "AliGeomManager.h"
50 #include "AliTOFcalib.h"
51 #include "AliTOFChannelOnlineArray.h"
52 #include "AliTOFChannelOnlineStatusArray.h"
53 #include "AliTOFChannelOffline.h"
54 #include "AliTOFClusterFinderV1.h"
55 #include "AliTOFcluster.h"
56 #include "AliTOFdigit.h"
57 #include "AliTOFDigitMap.h"
58 #include "AliTOFrawData.h"
59 #include "AliTOFReconstructor.h"
60 #include "AliTOFRecoParam.h"
62 ClassImp(AliTOFClusterFinderV1)
64 //_____________________________________________________________________________
65 AliTOFClusterFinderV1::AliTOFClusterFinderV1(AliTOFcalib *calib):
66 TTask("AliTOFClusterFinderV1",""),
68 fDigits(new TClonesArray("AliTOFdigit", 4000)),
69 fRecPoints(new TClonesArray("AliTOFcluster", 4000)),
70 fNumberOfTofClusters(0),
71 fNumberOfTofDigits(0),
72 fkRecoParam(0),//AliTOFReconstructor::GetRecoParam()),
73 fMaxDeltaTime(0),//fkRecoParam->GetMaxDeltaTime()),
77 fTOFdigitMap(new AliTOFDigitMap()),
78 fTOFGeometry(new AliTOFGeometry()),
79 fTOFdigits(new TTree()),
80 fTOFRawStream(AliTOFRawStream()),
87 if (AliTOFReconstructor::GetRecoParam()) {
88 fkRecoParam = AliTOFReconstructor::GetRecoParam();
89 fMaxDeltaTime = fkRecoParam->GetMaxDeltaTime();
94 TString validity = (TString)fTOFcalib->GetOfflineValidity();
95 if (validity.CompareTo("valid")==0) {
96 AliInfo(Form(" validity = %s - Using offline calibration parameters", validity.Data()));
98 AliInfo(Form(" validity = %s - Using online calibration parameters", validity.Data()));
103 //_____________________________________________________________________________
104 AliTOFClusterFinderV1::AliTOFClusterFinderV1(AliRunLoader* runLoader, AliTOFcalib *calib):
105 TTask("AliTOFClusterFinderV1",""),
106 fRunLoader(runLoader),
107 fDigits(new TClonesArray("AliTOFdigit", 4000)),
108 fRecPoints(new TClonesArray("AliTOFcluster", 4000)),
109 fNumberOfTofClusters(0),
110 fNumberOfTofDigits(0),
111 fkRecoParam(0),//AliTOFReconstructor::GetRecoParam()),
112 fMaxDeltaTime(0),//fkRecoParam->GetMaxDeltaTime()),
116 fTOFdigitMap(new AliTOFDigitMap()),
117 fTOFGeometry(new AliTOFGeometry()),
118 fTOFdigits(new TTree()),
119 fTOFRawStream(AliTOFRawStream()),
120 fCalibrateTOFtimes(1)
126 if (AliTOFReconstructor::GetRecoParam()) {
127 fkRecoParam = AliTOFReconstructor::GetRecoParam();
128 fMaxDeltaTime = fkRecoParam->GetMaxDeltaTime();
133 TString validity = (TString)fTOFcalib->GetOfflineValidity();
134 if (validity.CompareTo("valid")==0) {
135 AliInfo(Form(" validity = %s - Using offline calibration parameters", validity.Data()));
137 AliInfo(Form(" validity = %s - Using online calibration parameters", validity.Data()));
141 //_____________________________________________________________________________
143 AliTOFClusterFinderV1::AliTOFClusterFinderV1(const AliTOFClusterFinderV1 &source)
146 fDigits(source.fDigits),
147 fRecPoints(source.fRecPoints),
148 fNumberOfTofClusters(0),
149 fNumberOfTofDigits(0),
150 fkRecoParam(0),//AliTOFReconstructor::GetRecoParam()),
151 fMaxDeltaTime(0),//fkRecoParam->GetMaxDeltaTime()),
153 fDecoderVersion(source.fDecoderVersion),
154 fTOFcalib(source.fTOFcalib),
155 fTOFdigitMap(new AliTOFDigitMap()),
156 fTOFGeometry(new AliTOFGeometry()),
157 fTOFdigits(source.fTOFdigits),
158 fTOFRawStream(source.fTOFRawStream),
159 fCalibrateTOFtimes(1)
163 if (AliTOFReconstructor::GetRecoParam()) {
164 fkRecoParam = AliTOFReconstructor::GetRecoParam();
165 fMaxDeltaTime = fkRecoParam->GetMaxDeltaTime();
171 //_____________________________________________________________________________
173 AliTOFClusterFinderV1& AliTOFClusterFinderV1::operator=(const AliTOFClusterFinderV1 &source)
180 TObject::operator=(source);
181 fDigits=source.fDigits;
182 fRecPoints=source.fRecPoints;
183 fVerbose=source.fVerbose;
184 fDecoderVersion=source.fDecoderVersion;
185 fTOFcalib=source.fTOFcalib;
186 fTOFdigitMap=source.fTOFdigitMap;
187 fTOFGeometry=source.fTOFGeometry;
188 fTOFdigits=source.fTOFdigits;
189 fTOFRawStream=source.fTOFRawStream;
190 fCalibrateTOFtimes=source.fCalibrateTOFtimes;
194 //_____________________________________________________________________________
196 AliTOFClusterFinderV1::~AliTOFClusterFinderV1()
211 fRecPoints->Delete();
222 if (fTofClusters || fNumberOfTofClusters) {
223 for (Int_t ii=0; ii<fNumberOfTofClusters; ii++)
224 if (fTofClusters[ii]) fTofClusters[ii]->Delete();
225 fNumberOfTofClusters = 0;
229 //_____________________________________________________________________________
231 void AliTOFClusterFinderV1::Digits2RecPoints(TTree* digitsTree, TTree* clusterTree)
234 // Converts digits to recPoints for TOF
237 TStopwatch stopwatch;
243 TClonesArray &aDigits = *fDigits;
245 if (digitsTree == 0x0)
246 AliFatal("Can not get TreeD for TOF");
248 TBranch *branch = digitsTree->GetBranch("TOF");
250 AliError("Can not get branch with the TOF digits !");
254 TClonesArray staticDigits("AliTOFdigit",10000);
255 staticDigits.Clear();
256 TClonesArray *digits = &staticDigits;
257 branch->SetAddress(&digits);
258 digitsTree->GetEvent(0);
259 AliDebug(1,Form("Number of TOF digits: %d", digits->GetEntriesFast()));
261 AliTOFdigit *tofDigit;
264 Int_t detectorIndex[5];
265 for (jj=0; jj<5; jj++) detectorIndex[jj] = -1;
267 for (jj=0; jj<4; jj++) info[jj] = -1;
273 Bool_t status = kTRUE;
275 AliDebug(1," Calibrating TOF Digits");
277 TString validity = (TString)fTOFcalib->GetOfflineValidity();
278 if (validity.CompareTo("valid")==0) {
279 AliInfo(Form(" validity = %s - Using offline calibration parameters", validity.Data()));
281 AliInfo(Form(" validity = %s - Using online calibration parameters", validity.Data()));
285 for (ii=0; ii<digits->GetEntriesFast(); ii++) {
286 tofDigit = (AliTOFdigit*)digits->UncheckedAt(ii);
287 detectorIndex[0] = tofDigit->GetSector();
288 detectorIndex[1] = tofDigit->GetPlate();
289 detectorIndex[2] = tofDigit->GetStrip();
290 detectorIndex[3] = tofDigit->GetPadz();
291 detectorIndex[4] = tofDigit->GetPadx();
293 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
294 if (detectorIndex[1]==2) { // plate with holes
300 tdcCorr = tofDigit->GetTdc();
301 status = MakeSlewingCorrection(detectorIndex, tofDigit->GetToT(), tofDigit->GetTdc(), tdcCorr);
303 for (jj=0; jj<4; jj++) info[jj] = -1;
304 info[0] = tdcCorr;//tofDigit->GetTdc();
305 info[1] = tofDigit->GetAdc();
306 info[2] = tofDigit->GetToT();
307 info[3] = tofDigit->GetTdcND();//tofDigit->GetTdc();//
308 tracks = tofDigit->GetTracks();
310 dummy = detectorIndex[3];
311 detectorIndex[3] = detectorIndex[4];//padx
312 detectorIndex[4] = dummy;//padz
313 last = fDigits->GetEntriesFast();
314 new (aDigits[last]) AliTOFdigit(tracks, detectorIndex, info);
315 if (status) fTOFdigitMap->AddDigit(detectorIndex, last);
317 AliDebug(2, Form(" Digits reading %2d -> %2d %1d %2d %1d %2d (%d, %d, %d)",
319 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[3], detectorIndex[4],
320 info[0], info[1], info[3]));
324 fNumberOfTofDigits = fDigits->GetEntriesFast();
328 Int_t bufsize = 32000;
329 clusterTree->Branch("TOF", &fRecPoints, bufsize);
334 AliDebug(1,Form("Number of found clusters: %d", fNumberOfTofClusters));
338 fTOFdigitMap->Clear();
342 AliDebug(1,Form("Execution time to read TOF digits and to write TOF clusters : R:%.4fs C:%.4fs",
343 stopwatch.RealTime(),stopwatch.CpuTime()));
345 if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
348 //_____________________________________________________________________________
350 void AliTOFClusterFinderV1::Digits2RecPoints(AliRawReader *rawReader, TTree *clustersTree)
353 // Converts raw data to recPoints for TOF
356 TStopwatch stopwatch;
360 AliDebug(2, "TreeD re-creation");
361 //TTree *digitsTree = new TTree();
362 //Raw2Digits(rawReader, digitsTree);
364 Raw2Digits(rawReader, fTOFdigits);
366 AliDebug(1,Form("Number of TOF digits: %d", fNumberOfTofDigits));
369 Int_t bufsize = 32000;
370 clustersTree->Branch("TOF", &fRecPoints, bufsize);
373 clustersTree->Fill();
375 AliDebug(1,Form("Number of found clusters: %d", fNumberOfTofClusters));
379 fTOFdigitMap->Clear();
383 AliDebug(1,Form("Execution time to read TOF raw data and to write TOF clusters : R:%.4fs C:%.4fs",
384 stopwatch.RealTime(),stopwatch.CpuTime()));
388 //_____________________________________________________________________________
390 void AliTOFClusterFinderV1::Raw2Digits(AliRawReader *rawReader, TTree* digitsTree)
393 // Converts raw data to digits for TOF
396 TStopwatch stopwatch;
401 const Int_t kMaxNumberOfTracksPerDigit = 3;
402 const Int_t kDDL = AliDAQ::NumberOfDdls("TOF");
404 digitsTree->Branch("TOF", &fDigits);
405 TClonesArray &aDigits = *fDigits;
407 fTOFRawStream.Clear();
408 fTOFRawStream.SetRawReader(rawReader);
411 if (fVerbose==2) ftxt.open("TOFdigitsRead.txt",ios::app);
413 TClonesArray staticRawData("AliTOFrawData",10000);
414 staticRawData.Clear();
415 TClonesArray * clonesRawData = &staticRawData;
418 Int_t detectorIndex[5] = {-1, -1, -1, -1, -1};
420 Int_t tracks[kMaxNumberOfTracksPerDigit];
421 for (Int_t ii=0; ii<kMaxNumberOfTracksPerDigit; ii++)
426 Bool_t status = kTRUE;
429 TString validity = (TString)fTOFcalib->GetOfflineValidity();
430 if (validity.CompareTo("valid")==0) {
431 AliInfo(Form(" validity = %s - Using offline calibration parameters", validity.Data()));
433 AliInfo(Form(" validity = %s - Using online calibration parameters", validity.Data()));
437 AliInfo("Using New Decoder");
441 for (indexDDL=0; indexDDL<kDDL; indexDDL++) {
445 fTOFRawStream.LoadRawDataBuffers(indexDDL,fVerbose);
446 else fTOFRawStream.LoadRawData(indexDDL);
448 clonesRawData = (TClonesArray*)fTOFRawStream.GetRawData();
449 if (clonesRawData->GetEntriesFast()!=0) AliDebug(2,Form(" TOF raw data number = %3d", clonesRawData->GetEntriesFast()));
450 for (iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
452 AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
454 //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
455 if (tofRawDatum->GetTOF()==-1) continue;
457 fTOFRawStream.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
458 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
461 dummy = detectorIndex[3];
462 detectorIndex[3] = detectorIndex[4];//padz
463 detectorIndex[4] = dummy;//padx
465 tdcCorr = tofRawDatum->GetTOF();
466 status = MakeSlewingCorrection(detectorIndex, tofRawDatum->GetTOT(), tofRawDatum->GetTOF(), tdcCorr);
469 digit[1] = tofRawDatum->GetTOT();
470 digit[2] = tofRawDatum->GetTOT();
471 digit[3] = -1;//tofRawDatum->GetTOF(); //tofND
473 dummy = detectorIndex[3];
474 detectorIndex[3] = detectorIndex[4];//padx
475 detectorIndex[4] = dummy;//padz
477 /* check valid index */
478 if (detectorIndex[0]==-1||detectorIndex[1]==-1||detectorIndex[2]==-1||detectorIndex[3]==-1||detectorIndex[4]==-1) continue;
480 // Do not reconstruct anything in the holes
481 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
482 if (detectorIndex[1]==2) { // plate with holes
488 last = fDigits->GetEntriesFast();
489 new (aDigits[last]) AliTOFdigit(tracks, detectorIndex, digit);
490 if (status) fTOFdigitMap->AddDigit(detectorIndex, last);
493 if (indexDDL<10) ftxt << " " << indexDDL;
494 else ftxt << " " << indexDDL;
495 if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM();
496 else ftxt << " " << tofRawDatum->GetTRM();
497 ftxt << " " << tofRawDatum->GetTRMchain();
498 if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC();
499 else ftxt << " " << tofRawDatum->GetTDC();
500 ftxt << " " << tofRawDatum->GetTDCchannel();
502 if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0];
503 else ftxt << " -> " << detectorIndex[0];
504 ftxt << " " << detectorIndex[1];
505 if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2];
506 else ftxt << " " << detectorIndex[2];
507 ftxt << " " << detectorIndex[4];
508 if (detectorIndex[4]<10) ftxt << " " << detectorIndex[3];
509 else ftxt << " " << detectorIndex[3];
511 if (digit[1]<10)ftxt << " " << digit[1];
512 else if (digit[1]>=10 && digit[1]<100) ftxt << " " << digit[1];
513 else ftxt << " " << digit[1];
514 if (digit[0]<10) ftxt << " " << digit[0] << endl;
515 else if (digit[0]>=10 && digit[0]<100) ftxt << " " << digit[0] << endl;
516 else if (digit[0]>=100 && digit[0]<1000) ftxt << " " << digit[0] << endl;
517 else ftxt << " " << digit[3] << endl;
520 AliDebug(2, Form(" Raw data reading %2d -> %2d %1d %2d %1d %2d (%d, %d, %d)",
522 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[4], detectorIndex[3],
523 digit[0], digit[1], digit[3]));
527 clonesRawData->Clear();
531 if (fVerbose==2) ftxt.close();
535 fNumberOfTofDigits = fDigits->GetEntries();
537 AliDebug(1, Form("Got %d TOF digits", fNumberOfTofDigits));
538 AliDebug(1, Form("Execution time to read TOF raw data and fill TOF digit tree : R:%.2fs C:%.2fs",
539 stopwatch.RealTime(),stopwatch.CpuTime()));
541 if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
544 //_____________________________________________________________________________
546 void AliTOFClusterFinderV1::FillRecPoint()
549 // Fill the global TClonesArray of AliTOFcluster objects,
558 for(Int_t iPlate=AliTOFGeometry::NPlates()-1; iPlate>=0; iPlate--) {
559 for(Int_t iStrip=AliTOFGeometry::NStrip(iPlate)-1; iStrip>=0; iStrip--) {
560 //for (Int_t iSector=AliTOFGeometry::NSectors()-1; iSector>=0; iSector--) {
561 for (Int_t iSector=0; iSector<AliTOFGeometry::NSectors(); iSector++) {
564 if (fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))
565 AliDebug(1,Form(" Number of TOF digits in (%2d,%1d,%2d) -> %d",
566 iSector,iPlate,iStrip,fTOFdigitMap->FilledCellsInStrip(iSector,iPlate,iStrip)));
568 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
569 FindClustersWithoutTOT(iSector, iPlate, iStrip); // clusters coming from digits without TOT measurement
571 if (fMaxDeltaTime>0) {
573 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
574 //if (fTOFdigitMap->FilledCellsInStrip(iSector,iPlate,iStrip)>=4)
575 FindClustersPerStrip(iSector, iPlate, iStrip, 4); // 4 pads clusters
576 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
578 dummy4 = fNumberOfTofClusters;
579 FindClustersPerStrip(iSector, iPlate, iStrip, 4); // 4 pads clusters
580 if (fNumberOfTofClusters!=dummy4)
581 AliDebug(2, Form(" (4): n1= %5d, n2 = %5d", dummy4, fNumberOfTofClusters));
584 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
585 FindClustersPerStrip(iSector, iPlate, iStrip, 3); // 3 pads clusters
586 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
588 dummy3 = fNumberOfTofClusters;
589 FindClustersPerStrip(iSector, iPlate, iStrip, 3); // 3 pads clusters
590 if (fNumberOfTofClusters!=dummy3)
591 AliDebug(2, Form(" (3): n1= %5d, n2 = %5d", dummy3, fNumberOfTofClusters));
594 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
595 FindClustersPerStrip(iSector, iPlate, iStrip, 2); // 2 pads clusters
596 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
598 dummy2 = fNumberOfTofClusters;
599 FindClustersPerStrip(iSector, iPlate, iStrip, 2); // 2 pads clusters
600 if (fNumberOfTofClusters!=dummy2)
601 AliDebug(2, Form(" (2): n1= %5d, n2 =%5d", dummy2, fNumberOfTofClusters));
604 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
605 dummy = fNumberOfTofClusters;
606 FindClusters34(iSector, iPlate, iStrip); // 3 pads clusters between 4 hit pads
607 if (fNumberOfTofClusters!=dummy)
608 AliDebug(2, Form(" (3 between 4): n1 = %5d, n2 = %5d", fNumberOfTofClusters, dummy));
611 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
612 dummy = fNumberOfTofClusters;
613 FindClusters23(iSector, iPlate, iStrip); // 2 pads clusters between 3 hit pads
614 if (fNumberOfTofClusters!=dummy)
615 AliDebug(2, Form(" (2 between 3): n1 = %5d, n2 = %5d", fNumberOfTofClusters, dummy));
617 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
618 dummy = fNumberOfTofClusters;
619 FindClusters24(iSector, iPlate, iStrip); // 2 pads clusters between 4 hit pads
620 if (fNumberOfTofClusters!=dummy)
621 AliDebug(2, Form(" (2 between 4): n1 = %5d, n2 = %5d", fNumberOfTofClusters, dummy));
624 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
625 dummy = fNumberOfTofClusters;
626 FindOnePadClusterPerStrip(iSector, iPlate, iStrip); // 1 pad clusters
627 if (fNumberOfTofClusters!=dummy)
628 AliDebug(2,Form(" (1): n1 = %5d, n2 = %5d", fNumberOfTofClusters, dummy));
630 if (fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip)>0)
631 AliDebug(2, Form(" (1): number of clusters = %5d (remaining digit %2d), -%2d %1d %2d-",
632 fNumberOfTofClusters, fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip),
633 iSector, iPlate, iStrip));
637 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
638 dummy = fNumberOfTofClusters;
639 FindOnePadClusterPerStrip(iSector, iPlate, iStrip); // 1 pad clusters
640 if (fNumberOfTofClusters!=dummy)
641 AliDebug(2,Form(" (1): n1 = %5d, n2 = %5d", fNumberOfTofClusters, dummy));
643 if (fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip)>0)
644 AliDebug(2, Form(" (1): number of clusters = %5d (remaining digit %2d), -%2d %1d %2d-",
645 fNumberOfTofClusters, fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip),
646 iSector, iPlate, iStrip));
656 TClonesArray &lRecPoints = *fRecPoints;
660 Int_t detectorIndex[5];
661 for (jj=0; jj<5; jj++) detectorIndex[jj] = -1;
663 for (jj=0; jj<5; jj++) parTOF[jj] = -1;
664 Int_t trackLabels[3];
665 for (jj=0; jj<3; jj++) trackLabels[jj] = -1;
666 Int_t digitIndex = -1;
667 Bool_t status = kTRUE;
669 for (ii=0; ii<3; ii++) posClus[ii] = 0.;
670 //Float_t covClus[6];
671 //for (ii=0; ii<6; ii++) covClus[ii] = 0.;
674 for (ii=0; ii<fNumberOfTofClusters; ii++) {
676 digitIndex = fTofClusters[ii]->GetIndex();
677 for(jj=0; jj<5; jj++) detectorIndex[jj] = fTofClusters[ii]->GetDetInd(jj);
678 volIdClus = fTOFGeometry->GetAliSensVolIndex(detectorIndex[0],detectorIndex[1],detectorIndex[2]);
679 //volIdClus = GetClusterVolIndex(detectorIndex);
680 for(jj=0; jj<3; jj++) trackLabels[jj] = fTofClusters[ii]->GetLabel(jj);
681 parTOF[0] = fTofClusters[ii]->GetTDC(); // TDC
682 parTOF[1] = fTofClusters[ii]->GetToT(); // TOT
683 parTOF[2] = fTofClusters[ii]->GetADC(); // ADC=TOT
684 parTOF[3] = fTofClusters[ii]->GetTDCND(); // TDCND
685 parTOF[4] = fTofClusters[ii]->GetTDCRAW();//RAW
686 status = fTofClusters[ii]->GetStatus();
688 posClus[0] = fTofClusters[ii]->GetX();
689 posClus[1] = fTofClusters[ii]->GetY();
690 posClus[2] = fTofClusters[ii]->GetZ();
692 //for (jj=0; jj<6; jj++) covClus[jj] = 0.;
693 //((AliCluster*)fTofClusters[ii])->GetGlobalCov(covClus);
695 new(lRecPoints[ii]) AliTOFcluster(volIdClus, (Double_t)posClus[0], (Double_t)posClus[1], (Double_t)posClus[2],
696 (Double_t)(fTofClusters[ii]->GetSigmaX2()),
697 (Double_t)(fTofClusters[ii]->GetSigmaXY()),
698 (Double_t)(fTofClusters[ii]->GetSigmaXZ()),
699 (Double_t)(fTofClusters[ii]->GetSigmaY2()),
700 (Double_t)(fTofClusters[ii]->GetSigmaYZ()),
701 (Double_t)(fTofClusters[ii]->GetSigmaZ2()),
702 //(Double_t)covClus[0], (Double_t)covClus[1], (Double_t)covClus[2],
703 //(Double_t)covClus[3], (Double_t)covClus[4], (Double_t)covClus[5],
704 trackLabels, detectorIndex, parTOF, status, digitIndex);
706 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",
707 ii, volIdClus, posClus[0], posClus[1], posClus[2],
708 fTofClusters[ii]->GetSigmaX2(),
709 fTofClusters[ii]->GetSigmaXY(),
710 fTofClusters[ii]->GetSigmaXZ(),
711 fTofClusters[ii]->GetSigmaY2(),
712 fTofClusters[ii]->GetSigmaYZ(),
713 fTofClusters[ii]->GetSigmaZ2(),
714 trackLabels[0], trackLabels[1], trackLabels[2],
715 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[3], detectorIndex[4],
716 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
717 status, digitIndex));
722 for (Int_t iSector=0; iSector<AliTOFGeometry::NSectors(); iSector++)
723 for(Int_t iPlate=0; iPlate<AliTOFGeometry::NPlates(); iPlate++) {
724 for(Int_t iStrip=0; iStrip<AliTOFGeometry::NStrip(iPlate); iStrip++) {
725 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
726 AliDebug(2, Form(" END %2d %1d %2d %5d",
727 iSector, iPlate, iStrip, fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip)));
732 //_____________________________________________________________________________
734 void AliTOFClusterFinderV1::FindOnePadClusterPerStrip(Int_t nSector,
739 // This function searches the isolated digits (stored in the fDigits object),
740 // to perform clusters (stored in the fTofClusters array).
741 // This research has been made by checking the fTOFdigitMap object,
742 // filled at digits/raw-data reading time.
745 const Int_t kMaxNumberOfTracksPerDigit = 3;
746 const Int_t kMaxNumberOfDigitsPerVolume = 10;
750 Int_t det[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padZ,padX
751 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padX,padZ
752 UShort_t volIdClus = 0;
755 for (jj=0; jj<3; jj++) pos[jj] = 0.;
757 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
760 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
763 for (jj=0; jj<5; jj++) parTOF[jj] = 0;
765 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
767 Int_t tracks[kMaxNumberOfTracksPerDigit];
768 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
770 Int_t dummyCounter=-1;
772 AliTOFdigit *digitInteresting;
776 for (iPadX=0; iPadX<AliTOFGeometry::NpadX(); iPadX++) {
777 for (iPadZ=0; iPadZ<AliTOFGeometry::NpadZ(); iPadZ++) {
778 vol[4] = iPadZ , vol[3] = iPadX;
780 AliDebug(3, Form(" %1d %2d\n", iPadZ, iPadX));
782 if (fTOFdigitMap->GetNumberOfDigits(vol)==0) continue;
784 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
785 if (fTOFdigitMap->GetDigitIndex(vol,digIndex)<0) continue;
786 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(fTOFdigitMap->GetDigitIndex(vol,digIndex));
788 AliDebug(2, Form(" %3d %5d %2d %1d %2d %1d %2d %d %d %d %5d %5d %5d %5d",
789 fTOFdigitMap->GetNumberOfDigits(vol), digIndex,
790 vol[0], vol[1], vol[2] ,vol[4], vol[3],
791 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
792 digitInteresting->GetToT(),
793 fTOFdigitMap->GetDigitIndex(vol,digIndex),
794 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
796 det[3] = vol[4]; // padz
797 det[4] = vol[3]; // padx
798 fTOFGeometry->GetPosPar(det,pos);
799 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
802 for (jj=0; jj<3; jj++) posClus[jj] = pos[jj];
804 parTOF[0] = Int_t(digitInteresting->GetTdc());
805 parTOF[1] = Int_t(digitInteresting->GetToT());
806 parTOF[2] = Int_t(digitInteresting->GetAdc());
807 parTOF[3] = Int_t(digitInteresting->GetTdcND());
808 parTOF[4] = Int_t(digitInteresting->GetTdc());
810 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
811 //volIdClus = GetClusterVolIndex(det);
813 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
814 GetClusterPars(det, posClus, covClus);
816 // To fill the track index array
818 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
819 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) { // three is the max number of tracks associated to one digit
820 if (digitInteresting->GetTrack(jj)==-1) continue;
823 tracks[dummyCounter] = digitInteresting->GetTrack(jj);
827 AliTOFcluster *tofCluster =
828 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
829 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
830 tracks, det, parTOF, status, fTOFdigitMap->GetDigitIndex(vol,digIndex));
831 InsertCluster(tofCluster);
833 AliDebug(2, Form(" %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",
834 volIdClus, posClus[0], posClus[1], posClus[2],
835 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
836 tracks[0], tracks[1], tracks[2],
837 det[0], det[1], det[2], det[3], det[4],
838 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
839 status, fTOFdigitMap->GetDigitIndex(vol,digIndex)));
841 AliDebug(2, Form(" %f %f %f", pos[0], pos[1], pos[2]));
842 AliDebug(2, Form(" %d %d", parTOF[0], parTOF[2]));
844 fTOFdigitMap->ResetDigit(vol, digIndex);
852 //_____________________________________________________________________________
854 void AliTOFClusterFinderV1::FindClustersWithoutTOT(Int_t nSector,
859 // This function searches the isolated digits without TOT
860 // measurement (stored in the fDigits object), to perform clusters
861 // (stored in the fTofClusters array). This research has been made
862 // by checking the fTOFdigitMap object, filled at digits/raw-data
866 const Int_t kMaxNumberOfTracksPerDigit = 3;
867 const Int_t kMaxNumberOfDigitsPerVolume = 10;
871 Int_t det[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padZ,padX
872 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padX,padZ
873 UShort_t volIdClus = 0;
876 for (jj=0; jj<3; jj++) pos[jj] = 0.;
878 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
881 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
884 for (jj=0; jj<5; jj++) parTOF[jj] = 0;
886 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
887 Int_t tracks[kMaxNumberOfTracksPerDigit];
888 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
890 Int_t dummyCounter=-1;
892 AliTOFdigit *digitInteresting;
896 for (iPadX=0; iPadX<AliTOFGeometry::NpadX(); iPadX++) {
897 for (iPadZ=0; iPadZ<AliTOFGeometry::NpadZ(); iPadZ++) {
898 vol[4] = iPadZ , vol[3] = iPadX;
900 AliDebug(3, Form(" %1d %2d\n", iPadZ, iPadX));
902 if (fTOFdigitMap->GetNumberOfDigits(vol)==0) continue;
904 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
905 if (fTOFdigitMap->GetDigitIndex(vol,digIndex)<0) continue;
906 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(fTOFdigitMap->GetDigitIndex(vol,digIndex));
907 if (digitInteresting->GetToT()>0) continue; // AdC
909 AliDebug(2, Form(" %3d %5d %2d %1d %2d %1d %2d %d %d %d %5d %5d %5d %5d",
910 fTOFdigitMap->GetNumberOfDigits(vol), digIndex,
911 vol[0], vol[1], vol[2] ,vol[4], vol[3],
912 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
913 digitInteresting->GetToT(),
914 fTOFdigitMap->GetDigitIndex(vol,digIndex),
915 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
917 det[3] = vol[4]; // padz
918 det[4] = vol[3]; // padx
919 fTOFGeometry->GetPosPar(det,pos);
920 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
923 for (jj=0; jj<3; jj++) posClus[jj] = pos[jj];
925 parTOF[0] = Int_t(digitInteresting->GetTdc());
926 parTOF[1] = Int_t(digitInteresting->GetToT());
927 parTOF[2] = Int_t(digitInteresting->GetAdc());
928 parTOF[3] = Int_t(digitInteresting->GetTdcND());
929 parTOF[4] = Int_t(digitInteresting->GetTdc());
931 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
932 //volIdClus = GetClusterVolIndex(det);
934 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
935 GetClusterPars(det, posClus, covClus);
937 // To fill the track index array
939 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
940 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) { // three is the max number of tracks associated to one digit
941 if (digitInteresting->GetTrack(jj)==-1) continue;
944 tracks[dummyCounter] = digitInteresting->GetTrack(jj);
948 AliTOFcluster *tofCluster =
949 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
950 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
951 tracks, det, parTOF, status, fTOFdigitMap->GetDigitIndex(vol,digIndex));
952 InsertCluster(tofCluster);
954 AliDebug(2, Form(" %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",
955 volIdClus, posClus[0], posClus[1], posClus[2],
956 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
957 tracks[0], tracks[1], tracks[2],
958 det[0], det[1], det[2], det[3], det[4],
959 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
960 status, fTOFdigitMap->GetDigitIndex(vol,digIndex)));
962 AliDebug(2, Form(" %f %f %f", pos[0], pos[1], pos[2]));
963 AliDebug(2, Form(" %d %d", parTOF[0], parTOF[2]));
965 fTOFdigitMap->ResetDigit(vol, digIndex);
973 //_____________________________________________________________________________
975 void AliTOFClusterFinderV1::FindClusters34(Int_t nSector,
980 // This function searches the neighbouring digits (stored in the fDigits object),
981 // to perform clusters (stored in the fTofClusters array).
983 // This research has been made by checking the fTOFdigitMap object,
984 // filled at digits/raw-data reading time.
987 const Int_t kMaxNumberOfInterestingPads = 4;
988 const Int_t kMaxNumberOfTracksPerDigit = 3;
989 const Int_t kMaxNumberOfDigitsPerVolume = 10;
993 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
994 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
995 digitsInVolumeIndices[ii] = -1;
997 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
999 Float_t pos[3] = {0.,0.,0.};
1002 Int_t interestingPadX[kMaxNumberOfInterestingPads];
1003 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
1004 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
1005 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
1006 Double_t interestingTOT[kMaxNumberOfInterestingPads];
1007 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
1008 Double_t interestingADC[kMaxNumberOfInterestingPads];
1009 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
1010 Double_t interestingTOF[kMaxNumberOfInterestingPads];
1011 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
1012 Double_t interestingWeight[kMaxNumberOfInterestingPads];
1013 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
1015 Float_t interestingX[kMaxNumberOfInterestingPads];
1016 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
1017 Float_t interestingY[kMaxNumberOfInterestingPads];
1018 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
1019 Float_t interestingZ[kMaxNumberOfInterestingPads];
1020 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
1022 Float_t interDigit[kMaxNumberOfInterestingPads];
1023 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
1025 Int_t padsCluster[11];
1026 padsCluster[0] = nSector;
1027 padsCluster[1] = nPlate;
1028 padsCluster[2] = nStrip;
1029 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1031 Int_t interestingCounter=-1;
1032 Int_t digitIndexLocal=-1; // AdC
1038 for (jj=0; jj<5; jj++) parTOF[jj] = 0;
1039 Double_t posClus[3];
1040 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
1042 for (jj=0; jj<5; jj++) det[jj] = -1;
1044 for (jj=0; jj<3; jj++) posF[jj] = 0.;
1045 UShort_t volIdClus = 0;
1046 Bool_t check = kFALSE;
1047 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
1048 Double_t covClus[6];
1049 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1050 Int_t tracks[kMaxNumberOfTracksPerDigit];
1051 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1052 Int_t dummyCounter=-1;
1053 Bool_t alreadyStored = kFALSE;
1055 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
1056 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1057 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
1059 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1060 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
1062 AliTOFdigit *digitInteresting;
1064 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
1066 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
1067 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
1069 AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
1076 interestingCounter=-1;
1078 vol[4] = iPadZ , vol[3] = iPadX;
1079 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1080 interestingCounter++;
1082 vol[4] = iPadZ, vol[3] = iPadX+1;
1083 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1084 interestingCounter++;
1086 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1087 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1088 interestingCounter++;
1090 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1091 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1092 interestingCounter++;
1094 if (interestingCounter+1!=4) continue; // the hit pads have to be 4
1095 else interestingCounter=-1;
1098 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1099 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1100 selectedDigit[ii][jj] = 0x0;
1103 vol[4] = iPadZ, vol[3] = iPadX;
1105 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1106 interestingCounter++;
1107 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1108 digitsInVolumeIndices[ii] = -1;
1109 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1110 digitIndexLocal=-1; // AdC
1111 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1112 if (digitsInVolumeIndices[digIndex]<0) continue;
1113 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1114 if (digitInteresting->GetToT()<=0) continue; // AdC
1115 digitIndexLocal++; // AdC
1117 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1118 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1119 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1120 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1121 digitsInVolumeIndices[digIndex],
1122 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1125 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1126 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1127 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1128 digitInteresting->GetToT()*digitInteresting->GetToT(),
1129 digitsInVolumeIndices[digIndex],
1130 digitInteresting->GetTracks());
1132 if (digitIndexLocal==-1) interestingCounter--; // AdC
1136 vol[4] = iPadZ, vol[3] = iPadX+1;
1138 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1139 interestingCounter++;
1140 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1141 digitsInVolumeIndices[ii] = -1;
1142 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1143 digitIndexLocal=-1; // AdC
1144 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1145 if (digitsInVolumeIndices[digIndex]<0) continue;
1146 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1147 if (digitInteresting->GetToT()<=0) continue; // AdC
1148 digitIndexLocal++; // AdC
1150 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1151 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1152 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1153 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1154 digitsInVolumeIndices[digIndex],
1155 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1158 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1159 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1160 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1161 digitInteresting->GetToT()*digitInteresting->GetToT(),
1162 digitsInVolumeIndices[digIndex],
1163 digitInteresting->GetTracks());
1165 if (digitIndexLocal==-1) interestingCounter--; // AdC
1169 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1171 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1172 interestingCounter++;
1173 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1174 digitsInVolumeIndices[ii] = -1;
1175 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1176 digitIndexLocal=-1; // AdC
1177 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1178 if (digitsInVolumeIndices[digIndex]<0) continue;
1179 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1180 if (digitInteresting->GetToT()<=0) continue; // AdC
1181 digitIndexLocal++; // AdC
1183 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1184 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1185 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1186 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1187 digitsInVolumeIndices[digIndex],
1188 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1191 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1192 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1193 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1194 digitInteresting->GetToT()*digitInteresting->GetToT(),
1195 digitsInVolumeIndices[digIndex],
1196 digitInteresting->GetTracks());
1198 if (digitIndexLocal==-1) interestingCounter--; // AdC
1202 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1204 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1205 interestingCounter++;
1206 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1207 digitsInVolumeIndices[ii] = -1;
1208 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1210 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1211 if (digitsInVolumeIndices[digIndex]<0) continue;
1212 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1213 if (digitInteresting->GetToT()<=0) continue; // AdC
1214 digitIndexLocal++; // AdC
1216 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1217 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1218 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1219 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1220 digitsInVolumeIndices[digIndex],
1221 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1223 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1224 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1225 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1226 digitInteresting->GetToT()*digitInteresting->GetToT(),
1227 digitsInVolumeIndices[digIndex],
1228 digitInteresting->GetTracks());
1230 if (digitIndexLocal==-1) interestingCounter--; // AdC
1233 AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
1235 for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
1236 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
1237 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
1239 for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
1240 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
1241 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
1243 for (Int_t adesso3=adesso2+1; adesso3<interestingCounter+1; adesso3++) {
1244 for (Int_t thirdIndex=0; thirdIndex<kMaxNumberOfDigitsPerVolume; thirdIndex++) {
1245 if (selectedDigit[adesso3][thirdIndex]==0x0) continue;
1248 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime
1250 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
1252 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime) continue;
1254 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
1255 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
1256 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
1257 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
1258 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
1259 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
1260 Int_t volDum = vol1[3];
1263 fTOFGeometry->GetPosPar(vol1,pos);
1264 interestingX[0] = pos[0];
1265 interestingY[0] = pos[1];
1266 interestingZ[0] = pos[2];
1268 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
1269 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
1270 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
1271 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
1272 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
1273 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
1277 fTOFGeometry->GetPosPar(vol2,pos);
1278 interestingX[1] = pos[0];
1279 interestingY[1] = pos[1];
1280 interestingZ[1] = pos[2];
1282 interestingTOF[2] = selectedDigit[adesso3][thirdIndex]->GetTDC();
1283 interestingTOT[2] = selectedDigit[adesso3][thirdIndex]->GetTOT();
1284 interestingADC[2] = selectedDigit[adesso3][thirdIndex]->GetADC();
1285 interestingWeight[2] = selectedDigit[adesso3][thirdIndex]->GetWeight();
1286 Int_t vol3[5]; for(jj=0; jj<5; jj++) vol3[jj] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(jj);
1287 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol3[0], vol3[1], vol3[2], vol3[4], vol3[3]));
1291 fTOFGeometry->GetPosPar(vol3,pos);
1292 interestingX[2] = pos[0];
1293 interestingY[2] = pos[1];
1294 interestingZ[2] = pos[2];
1297 AverageCalculations(3, interestingX, interestingY, interestingZ,
1298 interestingTOF, interestingTOT, interestingADC,
1300 parTOF, posClus, check);
1303 for (jj=0; jj<5; jj++) det[jj] = -1;
1304 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
1305 fTOFGeometry->GetDetID(posF, det);
1307 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
1308 //volIdClus = GetClusterVolIndex(det);
1310 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1311 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
1312 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
1313 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
1314 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
1315 padsCluster[7] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(4);
1316 padsCluster[8] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(3);
1318 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1319 Int_t ** indDet = new Int_t*[3];
1320 for (jj=0; jj<3; jj++) indDet[jj] = new Int_t [5];
1321 for (jj=0; jj<3; jj++) indDet[jj][0] = nSector;
1322 for (jj=0; jj<3; jj++) indDet[jj][1] = nPlate;
1323 for (jj=0; jj<3; jj++) indDet[jj][2] = nStrip;
1324 for (jj=0; jj<3; jj++) indDet[jj][3] = padsCluster[2*jj+3];
1325 for (jj=0; jj<3; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
1326 GetClusterPars(/*check,*/ 3, indDet, interestingWeight, posClus, covClus);
1327 for (jj=0; jj<3; jj++) delete [] indDet[jj];
1329 // To fill the track index array
1331 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1332 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1333 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
1336 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
1339 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1340 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
1343 alreadyStored = kFALSE;
1344 for (jj=0; jj<dummyCounter+1; jj++)
1345 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
1347 if (alreadyStored) continue;
1348 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
1349 AliWarning(" Siamo al limite!");
1354 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
1359 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1360 if (selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk)==-1) continue;
1363 alreadyStored = kFALSE;
1364 for (jj=0; jj<dummyCounter+1; jj++)
1365 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk));
1367 if (alreadyStored) continue;
1368 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
1369 AliWarning(" Siamo al limite!");
1374 tracks[dummyCounter] = selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk);
1381 AliTOFcluster *tofCluster =
1382 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
1383 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1384 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
1385 InsertCluster(tofCluster);
1387 AliDebug(2, Form(" %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",
1388 volIdClus, posClus[0], posClus[1], posClus[2],
1389 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1390 tracks[0], tracks[1], tracks[2],
1391 det[0], det[1], det[2], det[3], det[4],
1392 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
1393 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
1399 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
1403 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
1407 fTOFdigitMap->ResetDigitNumber(vol3,selectedDigit[adesso3][thirdIndex]->GetIndex());
1410 } // close loop on third digit
1411 } // close loop on adesso3
1413 } // close loop on second digit
1414 } // close loop on adesso2
1416 } // close loop on first digit
1417 } // close loop on adesso1
1419 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1420 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1421 selectedDigit[ii][jj] = 0x0;
1425 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++) {
1426 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
1427 delete [] selectedDigit[ii][jj];
1428 selectedDigit[ii][jj] = 0x0;
1430 delete [] selectedDigit[ii];
1431 selectedDigit[ii] = 0x0;
1433 delete [] selectedDigit;
1434 selectedDigit = 0x0;
1437 //_____________________________________________________________________________
1439 void AliTOFClusterFinderV1::FindClusters23(Int_t nSector,
1444 // This function searches the neighbouring digits (stored in the fDigits object),
1445 // to perform clusters (stored in the fTofClusters array).
1447 // This research has been made by checking the fTOFdigitMap object,
1448 // filled at digits/raw-data reading time.
1451 const Int_t kMaxNumberOfInterestingPads = 4;
1452 const Int_t kMaxNumberOfTracksPerDigit = 3;
1453 const Int_t kMaxNumberOfDigitsPerVolume = 10;
1457 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
1458 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1459 digitsInVolumeIndices[ii] = -1;
1461 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
1463 Float_t pos[3] = {0.,0.,0.};
1466 Int_t interestingPadX[kMaxNumberOfInterestingPads];
1467 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
1468 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
1469 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
1470 Double_t interestingTOT[kMaxNumberOfInterestingPads];
1471 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
1472 Double_t interestingADC[kMaxNumberOfInterestingPads];
1473 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
1474 Double_t interestingTOF[kMaxNumberOfInterestingPads];
1475 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
1476 Double_t interestingWeight[kMaxNumberOfInterestingPads];
1477 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
1479 Float_t interestingX[kMaxNumberOfInterestingPads];
1480 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
1481 Float_t interestingY[kMaxNumberOfInterestingPads];
1482 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
1483 Float_t interestingZ[kMaxNumberOfInterestingPads];
1484 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
1486 Float_t interDigit[kMaxNumberOfInterestingPads];
1487 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
1489 Int_t padsCluster[11];
1490 padsCluster[0] = nSector;
1491 padsCluster[1] = nPlate;
1492 padsCluster[2] = nStrip;
1493 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1495 Int_t interestingCounter=-1;
1496 Int_t digitIndexLocal = -1;
1501 Bool_t check = kFALSE;
1503 for (jj=0; jj<5; jj++) parTOF[jj] = 0;
1504 Double_t posClus[3];
1505 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
1507 for (jj=0; jj<5; jj++) det[jj] = -1;
1509 for (jj=0; jj<3; jj++) posF[jj] = 0.;
1510 UShort_t volIdClus = 0;
1511 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
1512 Double_t covClus[6];
1513 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1514 Int_t tracks[kMaxNumberOfTracksPerDigit];
1515 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1516 Int_t dummyCounter=-1;
1517 Bool_t alreadyStored = kFALSE;
1519 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
1520 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1521 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
1523 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1524 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
1526 AliTOFdigit *digitInteresting;
1528 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
1530 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
1531 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
1533 AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
1540 interestingCounter=-1;
1542 vol[4] = iPadZ , vol[3] = iPadX;
1543 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1544 interestingCounter++;
1546 vol[4] = iPadZ, vol[3] = iPadX+1;
1547 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1548 interestingCounter++;
1550 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1551 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1552 interestingCounter++;
1554 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1555 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1556 interestingCounter++;
1558 if (interestingCounter+1!=3) continue; // the hit pads have to be 3
1559 else interestingCounter=-1;
1562 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1563 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1564 selectedDigit[ii][jj] = 0x0;
1567 vol[4] = iPadZ, vol[3] = iPadX;
1569 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1570 interestingCounter++;
1571 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1572 digitsInVolumeIndices[ii] = -1;
1573 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1575 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1576 if (digitsInVolumeIndices[digIndex]<0) continue;
1577 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1578 if (digitInteresting->GetToT()<=0) continue; // AdC
1579 digitIndexLocal++; // AdC
1581 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1582 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1583 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1584 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1585 digitsInVolumeIndices[digIndex],
1586 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1588 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1589 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1590 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1591 digitInteresting->GetToT()*digitInteresting->GetToT(),
1592 digitsInVolumeIndices[digIndex],
1593 digitInteresting->GetTracks());
1595 if (digitIndexLocal==-1) interestingCounter--; // AdC
1599 vol[4] = iPadZ, vol[3] = iPadX+1;
1601 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1602 interestingCounter++;
1603 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1604 digitsInVolumeIndices[ii] = -1;
1605 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1606 digitIndexLocal=-1; // AdC
1607 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1608 if (digitsInVolumeIndices[digIndex]<0) continue;
1609 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1610 if (digitInteresting->GetToT()<=0) continue; // AdC
1611 digitIndexLocal++; // AdC
1613 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1614 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1615 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1616 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1617 digitsInVolumeIndices[digIndex],
1618 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1620 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1621 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1622 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1623 digitInteresting->GetToT()*digitInteresting->GetToT(),
1624 digitsInVolumeIndices[digIndex],
1625 digitInteresting->GetTracks());
1627 if (digitIndexLocal==-1) interestingCounter--; // AdC
1631 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1633 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1634 interestingCounter++;
1635 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1636 digitsInVolumeIndices[ii] = -1;
1637 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1638 digitIndexLocal=-1; // AdC
1639 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1640 if (digitsInVolumeIndices[digIndex]<0) continue;
1641 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1642 if (digitInteresting->GetToT()<=0) continue; // AdC
1643 digitIndexLocal++; // AdC
1645 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1646 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1647 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1648 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1649 digitsInVolumeIndices[digIndex],
1650 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1652 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1653 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1654 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1655 digitInteresting->GetToT()*digitInteresting->GetToT(),
1656 digitsInVolumeIndices[digIndex],
1657 digitInteresting->GetTracks());
1659 if (digitIndexLocal==-1) interestingCounter--; // AdC
1663 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1665 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1666 interestingCounter++;
1667 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1668 digitsInVolumeIndices[ii] = -1;
1669 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1670 digitIndexLocal=-1; // AdC
1671 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1672 if (digitsInVolumeIndices[digIndex]<0) continue;
1673 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1674 if (digitInteresting->GetToT()<=0) continue; // AdC
1675 digitIndexLocal++; // AdC
1677 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1678 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1679 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1680 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1681 digitsInVolumeIndices[digIndex],
1682 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1684 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1685 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1686 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1687 digitInteresting->GetToT()*digitInteresting->GetToT(),
1688 digitsInVolumeIndices[digIndex],
1689 digitInteresting->GetTracks());
1691 if (digitIndexLocal==-1) interestingCounter--; // AdC
1694 AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
1696 for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
1697 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
1698 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
1700 for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
1701 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
1702 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
1704 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime) continue;
1706 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
1707 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
1708 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
1709 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
1710 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
1711 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
1712 Int_t volDum = vol1[3];
1715 fTOFGeometry->GetPosPar(vol1,pos);
1716 interestingX[0] = pos[0];
1717 interestingY[0] = pos[1];
1718 interestingZ[0] = pos[2];
1720 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
1721 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
1722 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
1723 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
1724 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
1725 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
1729 fTOFGeometry->GetPosPar(vol2,pos);
1730 interestingX[1] = pos[0];
1731 interestingY[1] = pos[1];
1732 interestingZ[1] = pos[2];
1734 AverageCalculations(2, interestingX, interestingY, interestingZ,
1735 interestingTOF, interestingTOT, interestingADC,
1737 parTOF, posClus, check);
1739 for (jj=0; jj<5; jj++) det[jj] = -1;
1740 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
1741 fTOFGeometry->GetDetID(posF, det);
1743 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
1744 //volIdClus = GetClusterVolIndex(det);
1746 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1747 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
1748 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
1749 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
1750 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
1752 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1753 Int_t ** indDet = new Int_t*[2];
1754 for (jj=0; jj<2; jj++) indDet[jj] = new Int_t [5];
1755 for (jj=0; jj<2; jj++) indDet[jj][0] = nSector;
1756 for (jj=0; jj<2; jj++) indDet[jj][1] = nPlate;
1757 for (jj=0; jj<2; jj++) indDet[jj][2] = nStrip;
1758 for (jj=0; jj<2; jj++) indDet[jj][3] = padsCluster[2*jj+3];
1759 for (jj=0; jj<2; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
1760 GetClusterPars(/*check,*/ 2, indDet, interestingWeight, posClus, covClus);
1761 for (jj=0; jj<2; jj++) delete [] indDet[jj];
1763 // To fill the track index array
1765 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1766 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1767 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
1770 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
1773 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1774 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
1777 alreadyStored = kFALSE;
1778 for (jj=0; jj<dummyCounter+1; jj++)
1779 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
1781 if (alreadyStored) continue;
1782 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
1783 AliWarning(" Siamo al limite!");
1788 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
1795 AliTOFcluster *tofCluster =
1796 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
1797 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1798 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
1799 InsertCluster(tofCluster);
1801 AliDebug(2, Form(" %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",
1802 volIdClus, posClus[0], posClus[1], posClus[2],
1803 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1804 tracks[0], tracks[1], tracks[2],
1805 det[0], det[1], det[2], det[3], det[4],
1806 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
1807 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
1812 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
1816 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
1819 } // close loop on second digit
1820 } // close loop on adesso2
1822 } // close loop on first digit
1823 } // close loop on adesso1
1825 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1826 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1827 selectedDigit[ii][jj] = 0x0;
1831 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++) {
1832 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
1833 delete [] selectedDigit[ii][jj];
1834 selectedDigit[ii][jj] = 0x0;
1836 delete [] selectedDigit[ii];
1837 selectedDigit[ii] = 0x0;
1839 delete [] selectedDigit;
1840 selectedDigit = 0x0;
1843 //_____________________________________________________________________________
1845 void AliTOFClusterFinderV1::FindClusters24(Int_t nSector,
1850 // This function searches the neighbouring digits (stored in the fDigits object),
1851 // to perform clusters (stored in the fTofClusters array).
1853 // This research has been made by checking the fTOFdigitMap object,
1854 // filled at digits/raw-data reading time.
1857 const Int_t kMaxNumberOfInterestingPads = 4;
1858 const Int_t kMaxNumberOfTracksPerDigit = 3;
1859 const Int_t kMaxNumberOfDigitsPerVolume = 10;
1863 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
1864 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1865 digitsInVolumeIndices[ii] = -1;
1867 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
1869 Float_t pos[3] = {0.,0.,0.};
1872 Int_t interestingPadX[kMaxNumberOfInterestingPads];
1873 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
1874 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
1875 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
1876 Double_t interestingTOT[kMaxNumberOfInterestingPads];
1877 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
1878 Double_t interestingADC[kMaxNumberOfInterestingPads];
1879 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
1880 Double_t interestingTOF[kMaxNumberOfInterestingPads];
1881 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
1882 Double_t interestingWeight[kMaxNumberOfInterestingPads];
1883 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
1885 Float_t interestingX[kMaxNumberOfInterestingPads];
1886 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
1887 Float_t interestingY[kMaxNumberOfInterestingPads];
1888 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
1889 Float_t interestingZ[kMaxNumberOfInterestingPads];
1890 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
1892 Float_t interDigit[kMaxNumberOfInterestingPads];
1893 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
1895 Int_t padsCluster[11];
1896 padsCluster[0] = nSector;
1897 padsCluster[1] = nPlate;
1898 padsCluster[2] = nStrip;
1899 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1901 Int_t interestingCounter=-1;
1902 Int_t digitIndexLocal = -1;
1907 Bool_t check = kFALSE;
1909 for (jj=0; jj<5; jj++) parTOF[jj] = 0;
1910 Double_t posClus[3];
1911 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
1913 for (jj=0; jj<5; jj++) det[jj] = -1;
1915 for (jj=0; jj<3; jj++) posF[jj] = 0.;
1916 UShort_t volIdClus = 0;
1917 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
1918 Double_t covClus[6];
1919 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1920 Int_t tracks[kMaxNumberOfTracksPerDigit];
1921 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1922 Int_t dummyCounter=-1;
1923 Bool_t alreadyStored = kFALSE;
1925 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
1926 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1927 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
1929 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1930 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
1932 AliTOFdigit *digitInteresting;
1934 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
1936 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
1937 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
1939 AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
1946 interestingCounter=-1;
1948 vol[4] = iPadZ , vol[3] = iPadX;
1949 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1950 interestingCounter++;
1952 vol[4] = iPadZ, vol[3] = iPadX+1;
1953 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1954 interestingCounter++;
1956 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1957 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1958 interestingCounter++;
1960 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1961 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1962 interestingCounter++;
1964 if (interestingCounter+1!=4) continue; // the hit pads have to be 4
1965 else interestingCounter=-1;
1968 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1969 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1970 selectedDigit[ii][jj] = 0x0;
1973 vol[4] = iPadZ, vol[3] = iPadX;
1975 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1976 interestingCounter++;
1977 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1978 digitsInVolumeIndices[ii] = -1;
1979 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1980 digitIndexLocal=-1; // AdC
1981 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1982 if (digitsInVolumeIndices[digIndex]<0) continue;
1983 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1984 if (digitInteresting->GetToT()<=0) continue; // AdC
1985 digitIndexLocal++; // AdC
1987 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1988 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1989 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1990 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1991 digitsInVolumeIndices[digIndex],
1992 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1994 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1995 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1996 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1997 digitInteresting->GetToT()*digitInteresting->GetToT(),
1998 digitsInVolumeIndices[digIndex],
1999 digitInteresting->GetTracks());
2001 if (digitIndexLocal==-1) interestingCounter--; // AdC
2005 vol[4] = iPadZ, vol[3] = iPadX+1;
2007 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2008 interestingCounter++;
2009 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2010 digitsInVolumeIndices[ii] = -1;
2011 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2012 digitIndexLocal=-1; // AdC
2013 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2014 if (digitsInVolumeIndices[digIndex]<0) continue;
2015 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2016 if (digitInteresting->GetToT()<=0) continue; // AdC
2017 digitIndexLocal++; // AdC
2019 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2020 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2021 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2022 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2023 digitsInVolumeIndices[digIndex],
2024 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2026 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2027 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2028 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2029 digitInteresting->GetToT()*digitInteresting->GetToT(),
2030 digitsInVolumeIndices[digIndex],
2031 digitInteresting->GetTracks());
2033 if (digitIndexLocal==-1) interestingCounter--; // AdC
2037 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
2039 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2040 interestingCounter++;
2041 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2042 digitsInVolumeIndices[ii] = -1;
2043 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2044 digitIndexLocal=-1; // AdC
2045 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2046 if (digitsInVolumeIndices[digIndex]<0) continue;
2047 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2048 if (digitInteresting->GetToT()<=0) continue; // AdC
2049 digitIndexLocal++; // AdC
2051 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2052 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2053 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2054 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2055 digitsInVolumeIndices[digIndex],
2056 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2058 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2059 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2060 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2061 digitInteresting->GetToT()*digitInteresting->GetToT(),
2062 digitsInVolumeIndices[digIndex],
2063 digitInteresting->GetTracks());
2065 if (digitIndexLocal==-1) interestingCounter--; // AdC
2069 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
2071 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2072 interestingCounter++;
2073 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2074 digitsInVolumeIndices[ii] = -1;
2075 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2076 digitIndexLocal=-1; // AdC
2077 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2078 if (digitsInVolumeIndices[digIndex]<0) continue;
2079 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2080 if (digitInteresting->GetToT()<=0) continue; // AdC
2081 digitIndexLocal++; // AdC
2083 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2084 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2085 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2086 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2087 digitsInVolumeIndices[digIndex],
2088 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2090 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2091 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2092 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2093 digitInteresting->GetToT()*digitInteresting->GetToT(),
2094 digitsInVolumeIndices[digIndex],
2095 digitInteresting->GetTracks());
2097 if (digitIndexLocal==-1) interestingCounter--; // AdC
2100 AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
2102 for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
2103 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2104 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2106 for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
2107 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2108 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2110 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime) continue;
2112 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2113 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2114 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2115 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2116 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
2117 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
2118 Int_t volDum = vol1[3];
2121 fTOFGeometry->GetPosPar(vol1,pos);
2122 interestingX[0] = pos[0];
2123 interestingY[0] = pos[1];
2124 interestingZ[0] = pos[2];
2126 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2127 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2128 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2129 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2130 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
2131 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
2135 fTOFGeometry->GetPosPar(vol2,pos);
2136 interestingX[1] = pos[0];
2137 interestingY[1] = pos[1];
2138 interestingZ[1] = pos[2];
2141 AverageCalculations(2, interestingX, interestingY, interestingZ,
2142 interestingTOF, interestingTOT, interestingADC,
2144 parTOF, posClus, check);
2146 for (jj=0; jj<5; jj++) det[jj] = -1;
2147 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
2148 fTOFGeometry->GetDetID(posF, det);
2150 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
2151 //volIdClus = GetClusterVolIndex(det);
2153 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2154 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
2155 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
2156 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
2157 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
2159 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2160 Int_t ** indDet = new Int_t*[2];
2161 for (jj=0; jj<2; jj++) indDet[jj] = new Int_t [5];
2162 for (jj=0; jj<2; jj++) indDet[jj][0] = nSector;
2163 for (jj=0; jj<2; jj++) indDet[jj][1] = nPlate;
2164 for (jj=0; jj<2; jj++) indDet[jj][2] = nStrip;
2165 for (jj=0; jj<2; jj++) indDet[jj][3] = padsCluster[2*jj+3];
2166 for (jj=0; jj<2; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
2167 GetClusterPars(/*check,*/ 2, indDet, interestingWeight, posClus, covClus);
2168 for (jj=0; jj<2; jj++) delete [] indDet[jj];
2170 // To fill the track index array
2172 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2173 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2174 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
2177 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
2180 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2181 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
2184 alreadyStored = kFALSE;
2185 for (jj=0; jj<dummyCounter+1; jj++)
2186 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
2188 if (alreadyStored) continue;
2189 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2190 AliWarning(" Siamo al limite!");
2195 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
2202 AliTOFcluster *tofCluster =
2203 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
2204 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2205 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
2206 InsertCluster(tofCluster);
2208 AliDebug(2, Form(" %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",
2209 volIdClus, posClus[0], posClus[1], posClus[2],
2210 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2211 tracks[0], tracks[1], tracks[2],
2212 det[0], det[1], det[2], det[3], det[4],
2213 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
2214 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
2219 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
2223 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
2226 } // close loop on second digit
2227 } // close loop on adesso2
2229 } // close loop on first digit
2230 } // close loop on adesso1
2232 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2233 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
2234 selectedDigit[ii][jj] = 0x0;
2238 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++) {
2239 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
2240 delete [] selectedDigit[ii][jj];
2241 selectedDigit[ii][jj] = 0x0;
2243 delete [] selectedDigit[ii];
2244 selectedDigit[ii] = 0x0;
2246 delete [] selectedDigit;
2247 selectedDigit = 0x0;
2250 //_____________________________________________________________________________
2252 void AliTOFClusterFinderV1::FindClustersPerStrip(Int_t nSector,
2258 // This function searches the neighbouring digits (stored in the fDigits object),
2259 // to perform clusters (stored in the fTofClusters array).
2261 // Each strip is read four times:
2262 // - 1st time: it searches possible clusters formed by four
2263 // neighbouring digits;
2264 // - 2nd time: it searches possible clusters formed by three
2265 // neighbouring digits;
2266 // - 3rd time: it searches possible clusters formed by two
2267 // neighbouring digits;
2268 // - 4th time: the remaining isolated digits have been transformed
2270 // This research has been made by checking the fTOFdigitMap object,
2271 // filled at digits/raw-data reading time.
2274 const Int_t kMaxNumberOfInterestingPads = 4;
2275 const Int_t kMaxNumberOfTracksPerDigit = 3;
2276 const Int_t kMaxNumberOfDigitsPerVolume = 10;
2280 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
2281 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2282 digitsInVolumeIndices[ii] = -1;
2284 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
2286 Float_t pos[3] = {0.,0.,0.};
2289 Int_t interestingPadX[kMaxNumberOfInterestingPads];
2290 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
2291 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
2292 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
2293 Double_t interestingTOT[kMaxNumberOfInterestingPads];
2294 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
2295 Double_t interestingADC[kMaxNumberOfInterestingPads];
2296 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
2297 Double_t interestingTOF[kMaxNumberOfInterestingPads];
2298 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
2299 Double_t interestingWeight[kMaxNumberOfInterestingPads];
2300 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
2302 Float_t interestingX[kMaxNumberOfInterestingPads];
2303 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
2304 Float_t interestingY[kMaxNumberOfInterestingPads];
2305 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
2306 Float_t interestingZ[kMaxNumberOfInterestingPads];
2307 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
2309 Float_t interDigit[kMaxNumberOfInterestingPads];
2310 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
2312 Int_t padsCluster[11];
2313 padsCluster[0] = nSector;
2314 padsCluster[1] = nPlate;
2315 padsCluster[2] = nStrip;
2316 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2318 Int_t interestingCounter=-1;
2319 Int_t digitIndexLocal = -1;
2324 Bool_t check = kFALSE;
2326 for (jj=0; jj<5; jj++) parTOF[jj] = 0;
2327 Double_t posClus[3];
2328 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
2330 for (jj=0; jj<5; jj++) det[jj] = -1;
2332 for (jj=0; jj<3; jj++) posF[jj] = 0.;
2333 UShort_t volIdClus = 0;
2334 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
2335 Double_t covClus[6];
2336 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2337 Int_t tracks[kMaxNumberOfTracksPerDigit];
2338 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2339 Int_t dummyCounter=-1;
2340 Bool_t alreadyStored = kFALSE;
2342 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
2343 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2344 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
2346 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2347 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
2349 AliTOFdigit *digitInteresting;
2353 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
2355 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
2356 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
2358 AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
2365 interestingCounter=-1;
2367 vol[4] = iPadZ , vol[3] = iPadX;
2368 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2369 interestingCounter++;
2371 vol[4] = iPadZ, vol[3] = iPadX+1;
2372 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2373 interestingCounter++;
2375 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
2376 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2377 interestingCounter++;
2379 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
2380 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2381 interestingCounter++;
2383 if (interestingCounter!=group) continue;
2384 else interestingCounter=-1;
2387 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2388 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
2389 selectedDigit[ii][jj] = 0x0;
2392 vol[4] = iPadZ, vol[3] = iPadX;
2394 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2395 interestingCounter++;
2396 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2397 digitsInVolumeIndices[ii] = -1;
2398 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2399 digitIndexLocal=-1; // AdC
2400 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2401 if (digitsInVolumeIndices[digIndex]<0) continue;
2402 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2403 if (digitInteresting->GetToT()<=0) continue; // AdC
2404 digitIndexLocal++; // AdC
2406 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2407 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2408 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2409 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2410 digitsInVolumeIndices[digIndex],
2411 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2412 AliDebug(1,Form(" to try %d %d ",digIndex, interestingCounter));
2414 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2415 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2416 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2417 digitInteresting->GetToT()*digitInteresting->GetToT(),
2418 digitsInVolumeIndices[digIndex],
2419 digitInteresting->GetTracks());
2421 if (digitIndexLocal==-1) interestingCounter--; // AdC
2425 vol[4] = iPadZ, vol[3] = iPadX+1;
2427 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2428 interestingCounter++;
2429 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2430 digitsInVolumeIndices[ii] = -1;
2431 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2432 digitIndexLocal=-1; // AdC
2433 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2434 if (digitsInVolumeIndices[digIndex]<0) continue;
2435 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2436 if (digitInteresting->GetToT()<=0) continue; // AdC
2437 digitIndexLocal++; // AdC
2439 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2440 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2441 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2442 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2443 digitsInVolumeIndices[digIndex],
2444 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2445 AliDebug(1,Form(" to try %d %d ",digIndex, interestingCounter));
2447 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2448 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2449 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2450 digitInteresting->GetToT()*digitInteresting->GetToT(),
2451 digitsInVolumeIndices[digIndex],
2452 digitInteresting->GetTracks());
2454 if (digitIndexLocal==-1) interestingCounter--; // AdC
2458 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
2460 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2461 interestingCounter++;
2462 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2463 digitsInVolumeIndices[ii] = -1;
2464 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2465 digitIndexLocal=-1; // AdC
2466 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2467 if (digitsInVolumeIndices[digIndex]<0) continue;
2468 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2469 if (digitInteresting->GetToT()<=0) continue; // AdC
2470 digitIndexLocal++; // AdC
2472 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2473 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2474 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2475 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2476 digitsInVolumeIndices[digIndex],
2477 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2478 AliDebug(1,Form(" to try %d %d ",digIndex, interestingCounter));
2480 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2481 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2482 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2483 digitInteresting->GetToT()*digitInteresting->GetToT(),
2484 digitsInVolumeIndices[digIndex],
2485 digitInteresting->GetTracks());
2487 if (digitIndexLocal==-1) interestingCounter--; // AdC
2491 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
2493 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2494 interestingCounter++;
2495 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2496 digitsInVolumeIndices[ii] = -1;
2497 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2498 digitIndexLocal=-1; // AdC
2499 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2500 if (digitsInVolumeIndices[digIndex]<0) continue;
2501 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2502 if (digitInteresting->GetToT()<=0) continue; // AdC
2503 digitIndexLocal++; // AdC
2505 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2506 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2507 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2508 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2509 digitsInVolumeIndices[digIndex],
2510 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2511 AliDebug(1,Form(" to try %d %d ",digIndex, interestingCounter));
2513 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2514 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2515 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2516 digitInteresting->GetToT()*digitInteresting->GetToT(),
2517 digitsInVolumeIndices[digIndex],
2518 digitInteresting->GetTracks());
2520 if (digitIndexLocal==-1) interestingCounter--; // AdC
2523 AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
2530 switch(interestingCounter+1) {
2534 //for (adesso1=0; adesso1<interestingCounter+1; adesso1++) {
2536 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2537 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2539 //for (adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
2541 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2542 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2544 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime) {
2545 AliDebug(1,Form(" selD1[%d][%d]->GetTDC()=%d selD2[%d][%d]->GetTDC()=%d -- %d ",
2546 adesso1,firstIndex,(Int_t)selectedDigit[adesso1][firstIndex]->GetTDC(),
2547 adesso2,secondIndex,(Int_t)selectedDigit[adesso2][secondIndex]->GetTDC(),
2552 AliDebug(1, Form(" %1d %1d (0x%p) %1d %1d (0x%p)", adesso1, firstIndex,selectedDigit[adesso1][firstIndex],
2553 adesso2, secondIndex,selectedDigit[adesso2][secondIndex]));
2555 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2556 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2557 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2558 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2559 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
2560 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
2561 Int_t volDum = vol1[3];
2564 fTOFGeometry->GetPosPar(vol1,pos);
2565 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
2566 interestingX[0] = pos[0];
2567 interestingY[0] = pos[1];
2568 interestingZ[0] = pos[2];
2570 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2571 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2572 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2573 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2574 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
2575 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
2579 fTOFGeometry->GetPosPar(vol2,pos);
2580 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
2581 interestingX[1] = pos[0];
2582 interestingY[1] = pos[1];
2583 interestingZ[1] = pos[2];
2586 AverageCalculations(interestingCounter+1,
2587 interestingX, interestingY, interestingZ,
2588 interestingTOF, interestingTOT, interestingADC,
2590 parTOF, posClus, check);
2592 for (jj=0; jj<5; jj++) det[jj] = -1;
2593 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
2595 AliDebug(1,Form(" %f %f %f", posF[0], posF[1], posF[2]));
2596 fTOFGeometry->GetDetID(posF, det);
2597 AliDebug(1,Form(" %2d %1d %2d %1d %2d", det[0], det[1], det[2], det[3], det[4]));
2599 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
2600 //volIdClus = GetClusterVolIndex(det);
2602 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2603 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
2604 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
2605 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
2606 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
2608 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2609 Int_t ** indDet = new Int_t*[interestingCounter+1];
2610 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj] = new Int_t [5];
2611 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][0] = nSector;
2612 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][1] = nPlate;
2613 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][2] = nStrip;
2614 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][3] = padsCluster[2*jj+3];
2615 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
2616 GetClusterPars(/*check,*/ interestingCounter+1, indDet, interestingWeight, posClus, covClus);
2617 for (jj=0; jj<interestingCounter+1; jj++) delete [] indDet[jj];
2619 // To fill the track index array
2621 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2622 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2623 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
2626 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
2629 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2630 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
2633 alreadyStored = kFALSE;
2634 for (jj=0; jj<dummyCounter+1; jj++)
2635 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
2637 if (alreadyStored) continue;
2638 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2639 AliWarning(" Siamo al limite!");
2644 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
2651 AliTOFcluster *tofCluster =
2652 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
2653 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2654 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); //to updated
2655 InsertCluster(tofCluster);
2657 AliDebug(2, Form(" %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",
2658 volIdClus, posClus[0], posClus[1], posClus[2],
2659 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2660 tracks[0], tracks[1], tracks[2],
2661 det[0], det[1], det[2], det[3], det[4],
2662 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
2663 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
2668 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
2672 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
2675 } // close loop on second digit
2676 //} // close loop on adesso2
2678 } // close loop on first digit
2679 //} // close loop on adesso1
2686 //for (adesso1=0; adesso1<interestingCounter+1; adesso1++) {
2688 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2689 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2691 //for (adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
2693 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2694 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2696 //for (adesso3=adesso2+1; adesso3<interestingCounter+1; adesso3++) {
2698 for (Int_t thirdIndex=0; thirdIndex<kMaxNumberOfDigitsPerVolume; thirdIndex++) {
2699 if (selectedDigit[adesso3][thirdIndex]==0x0) continue;
2702 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime
2704 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
2706 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime) continue;
2708 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2709 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2710 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2711 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2712 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
2713 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
2714 Int_t volDum = vol1[3];
2717 fTOFGeometry->GetPosPar(vol1,pos);
2718 interestingX[0] = pos[0];
2719 interestingY[0] = pos[1];
2720 interestingZ[0] = pos[2];
2722 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2723 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2724 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2725 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2726 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
2727 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
2731 fTOFGeometry->GetPosPar(vol2,pos);
2732 interestingX[1] = pos[0];
2733 interestingY[1] = pos[1];
2734 interestingZ[1] = pos[2];
2736 interestingTOF[2] = selectedDigit[adesso3][thirdIndex]->GetTDC();
2737 interestingTOT[2] = selectedDigit[adesso3][thirdIndex]->GetTOT();
2738 interestingADC[2] = selectedDigit[adesso3][thirdIndex]->GetADC();
2739 interestingWeight[2] = selectedDigit[adesso3][thirdIndex]->GetWeight();
2740 Int_t vol3[5]; for(jj=0; jj<5; jj++) vol3[jj] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(jj);
2741 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol3[0], vol3[1], vol3[2], vol3[4], vol3[3]));
2745 fTOFGeometry->GetPosPar(vol3,pos);
2746 interestingX[2] = pos[0];
2747 interestingY[2] = pos[1];
2748 interestingZ[2] = pos[2];
2751 AverageCalculations(interestingCounter+1,
2752 interestingX, interestingY, interestingZ,
2753 interestingTOF, interestingTOT, interestingADC,
2755 parTOF, posClus, check);
2757 for (jj=0; jj<5; jj++) det[jj] = -1;
2758 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
2759 fTOFGeometry->GetDetID(posF, det);
2761 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
2762 //volIdClus = GetClusterVolIndex(det);
2764 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2765 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
2766 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
2767 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
2768 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
2769 padsCluster[7] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(4);
2770 padsCluster[8] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(3);
2772 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2773 Int_t ** indDet = new Int_t*[interestingCounter+1];
2774 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj] = new Int_t [5];
2775 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][0] = nSector;
2776 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][1] = nPlate;
2777 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][2] = nStrip;
2778 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][3] = padsCluster[2*jj+3];
2779 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
2780 GetClusterPars(/*check,*/ interestingCounter+1, indDet, interestingWeight, posClus, covClus);
2781 for (jj=0; jj<interestingCounter+1; jj++) delete [] indDet[jj];
2783 // To fill the track index array
2785 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2786 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2787 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
2790 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
2793 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2794 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
2797 alreadyStored = kFALSE;
2798 for (jj=0; jj<dummyCounter+1; jj++)
2799 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
2801 if (alreadyStored) continue;
2802 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2803 AliWarning(" Siamo al limite!");
2808 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
2813 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2814 if (selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk)==-1) continue;
2817 alreadyStored = kFALSE;
2818 for (jj=0; jj<dummyCounter+1; jj++)
2819 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk));
2821 if (alreadyStored) continue;
2822 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2823 AliWarning(" Siamo al limite!");
2828 tracks[dummyCounter] = selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk);
2835 AliTOFcluster *tofCluster =
2836 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
2837 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2838 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
2839 InsertCluster(tofCluster);
2841 AliDebug(2, Form(" %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",
2842 volIdClus, posClus[0], posClus[1], posClus[2],
2843 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2844 tracks[0], tracks[1], tracks[2],
2845 det[0], det[1], det[2], det[3], det[4],
2846 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
2847 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
2852 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
2856 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
2860 fTOFdigitMap->ResetDigitNumber(vol3,selectedDigit[adesso3][thirdIndex]->GetIndex());
2863 } // close loop on third digit
2864 //} // close loop on adesso3
2866 } // close loop on second digit
2867 //} // close loop on adesso2
2869 } // close loop on first digit
2870 //} // close loop on adesso1
2878 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2879 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2882 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2883 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2886 for (Int_t thirdIndex=0; thirdIndex<kMaxNumberOfDigitsPerVolume; thirdIndex++) {
2887 if (selectedDigit[adesso3][thirdIndex]==0x0) continue;
2890 for (Int_t fourthIndex=0; fourthIndex<kMaxNumberOfDigitsPerVolume; fourthIndex++) {
2891 if (selectedDigit[adesso4][fourthIndex]==0x0) continue;
2894 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime
2896 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
2898 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso4][fourthIndex]->GetTDC())>fMaxDeltaTime
2900 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
2902 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso4][fourthIndex]->GetTDC())>fMaxDeltaTime
2904 TMath::Abs(selectedDigit[adesso3][thirdIndex]->GetTDC()-selectedDigit[adesso4][fourthIndex]->GetTDC())>fMaxDeltaTime) continue;
2906 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2907 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2908 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2909 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2910 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
2911 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
2912 Int_t volDum = vol1[3];
2915 fTOFGeometry->GetPosPar(vol1,pos);
2916 interestingX[0] = pos[0];
2917 interestingY[0] = pos[1];
2918 interestingZ[0] = pos[2];
2920 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2921 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2922 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2923 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2924 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
2925 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
2929 fTOFGeometry->GetPosPar(vol2,pos);
2930 interestingX[1] = pos[0];
2931 interestingY[1] = pos[1];
2932 interestingZ[1] = pos[2];
2934 interestingTOF[2] = selectedDigit[adesso3][thirdIndex]->GetTDC();
2935 interestingTOT[2] = selectedDigit[adesso3][thirdIndex]->GetTOT();
2936 interestingADC[2] = selectedDigit[adesso3][thirdIndex]->GetADC();
2937 interestingWeight[2] = selectedDigit[adesso3][thirdIndex]->GetWeight();
2938 Int_t vol3[5]; for(jj=0; jj<5; jj++) vol3[jj] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(jj);
2939 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol3[0], vol3[1], vol3[2], vol3[4], vol3[3]));
2943 fTOFGeometry->GetPosPar(vol3,pos);
2944 interestingX[2] = pos[0];
2945 interestingY[2] = pos[1];
2946 interestingZ[2] = pos[2];
2948 interestingTOF[3] = selectedDigit[adesso4][fourthIndex]->GetTDC();
2949 interestingTOT[3] = selectedDigit[adesso4][fourthIndex]->GetTOT();
2950 interestingADC[3] = selectedDigit[adesso4][fourthIndex]->GetADC();
2951 interestingWeight[3] = selectedDigit[adesso4][fourthIndex]->GetWeight();
2952 Int_t vol4[5]; for(jj=0; jj<5; jj++) vol4[jj] = selectedDigit[adesso4][fourthIndex]->GetDetectorIndex(jj);
2953 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol4[0], vol4[1], vol4[2], vol4[4], vol4[3]));
2957 fTOFGeometry->GetPosPar(vol4,pos);
2958 interestingX[3] = pos[0];
2959 interestingY[3] = pos[1];
2960 interestingZ[3] = pos[2];
2963 AverageCalculations(interestingCounter+1,
2964 interestingX, interestingY, interestingZ,
2965 interestingTOF, interestingTOT, interestingADC,
2967 parTOF, posClus, check);
2969 for (jj=0; jj<5; jj++) det[jj] = -1;
2970 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
2971 fTOFGeometry->GetDetID(posF, det);
2973 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
2974 //volIdClus = GetClusterVolIndex(det);
2976 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2977 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
2978 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
2979 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
2980 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
2981 padsCluster[7] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(4);
2982 padsCluster[8] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(3);
2983 padsCluster[9] = selectedDigit[adesso4][fourthIndex]->GetDetectorIndex(4);
2984 padsCluster[10] = selectedDigit[adesso4][fourthIndex]->GetDetectorIndex(3);
2986 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2987 Int_t ** indDet = new Int_t*[interestingCounter+1];
2988 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj] = new Int_t [5];
2989 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][0] = nSector;
2990 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][1] = nPlate;
2991 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][2] = nStrip;
2992 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][3] = padsCluster[2*jj+3];
2993 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
2994 GetClusterPars(/*check,*/ interestingCounter+1, indDet, interestingWeight, posClus, covClus);
2995 for (jj=0; jj<interestingCounter+1; jj++) delete [] indDet[jj];
2997 // To fill the track index array
2999 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
3000 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
3001 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
3004 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
3007 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
3008 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
3011 alreadyStored = kFALSE;
3012 for (jj=0; jj<dummyCounter+1; jj++)
3013 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
3015 if (alreadyStored) continue;
3016 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
3017 AliWarning(" Siamo al limite!");
3022 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
3027 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
3028 if (selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk)==-1) continue;
3031 alreadyStored = kFALSE;
3032 for (jj=0; jj<dummyCounter+1; jj++)
3033 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk));
3035 if (alreadyStored) continue;
3036 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
3037 AliWarning(" Siamo al limite!");
3042 tracks[dummyCounter] = selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk);
3047 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
3048 if (selectedDigit[adesso4][fourthIndex]->GetTrackLabel(kk)==-1) continue;
3051 alreadyStored = kFALSE;
3052 for (jj=0; jj<dummyCounter+1; jj++)
3053 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso4][fourthIndex]->GetTrackLabel(kk));
3055 if (alreadyStored) continue;
3056 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
3057 AliWarning(" Siamo al limite!");
3062 tracks[dummyCounter] = selectedDigit[adesso4][fourthIndex]->GetTrackLabel(kk);
3069 AliTOFcluster *tofCluster =
3070 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
3071 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
3072 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
3073 InsertCluster(tofCluster);
3075 AliDebug(2, Form(" %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",
3076 volIdClus, posClus[0], posClus[1], posClus[2],
3077 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
3078 tracks[0], tracks[1], tracks[2],
3079 det[0], det[1], det[2], det[3], det[4],
3080 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
3081 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
3086 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
3090 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
3094 fTOFdigitMap->ResetDigitNumber(vol3,selectedDigit[adesso3][thirdIndex]->GetIndex());
3098 fTOFdigitMap->ResetDigitNumber(vol4,selectedDigit[adesso4][fourthIndex]->GetIndex());
3101 } // close loop on fourth digit
3103 } // close loop on third digit
3105 } // close loop on second digit
3107 } // close loop on first digit
3113 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
3114 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
3115 selectedDigit[ii][jj] = 0x0;
3119 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++) {
3120 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
3121 delete [] selectedDigit[ii][jj];
3122 selectedDigit[ii][jj] = 0x0;
3124 delete [] selectedDigit[ii];
3125 selectedDigit[ii] = 0x0;
3127 delete [] selectedDigit;
3128 selectedDigit = 0x0;
3131 //_____________________________________________________________________________
3133 Int_t AliTOFClusterFinderV1::InsertCluster(AliTOFcluster *tofCluster)
3136 // This function adds a TOF cluster to the array of TOF clusters
3137 // sorted in Z, i.e. fTofClusters
3140 if (fNumberOfTofClusters==kTofMaxCluster) {
3141 AliError("Too many clusters !");
3145 if (fNumberOfTofClusters==0) {
3146 fTofClusters[fNumberOfTofClusters++] = tofCluster;
3150 Int_t ii = FindClusterIndex(tofCluster->GetZ());
3151 memmove(fTofClusters+ii+1 ,fTofClusters+ii,(fNumberOfTofClusters-ii)*sizeof(AliTOFcluster*));
3152 fTofClusters[ii] = tofCluster;
3153 fNumberOfTofClusters++;
3158 //_____________________________________________________________________________
3160 Int_t AliTOFClusterFinderV1::FindClusterIndex(Double_t z) const
3163 // This function returns the index of the nearest cluster in z
3166 if (fNumberOfTofClusters==0) return 0;
3167 if (z <= fTofClusters[0]->GetZ()) return 0;
3168 if (z > fTofClusters[fNumberOfTofClusters-1]->GetZ()) return fNumberOfTofClusters;
3169 Int_t b = 0, e = fNumberOfTofClusters-1, m = (b+e)/2;
3170 for (; b<e; m=(b+e)/2) {
3171 if (z > fTofClusters[m]->GetZ()) b=m+1;
3178 //_____________________________________________________________________________
3180 void AliTOFClusterFinderV1::ResetRecpoint()
3183 // Clear the list of reconstructed points
3186 fNumberOfTofClusters = 0;
3187 if (fRecPoints) fRecPoints->Clear();
3190 //_____________________________________________________________________________
3192 void AliTOFClusterFinderV1::ResetDigits()
3195 // Clear the list of digits
3198 fNumberOfTofDigits = 0;
3199 if (fDigits) fDigits->Clear();
3202 //_____________________________________________________________________________
3203 //UShort_t AliTOFClusterFinderV1::GetClusterVolIndex(Int_t *ind) const
3206 // Get the volume ID to retrieve the l2t transformation
3209 // Detector numbering scheme
3211 Int_t nSector = AliTOFGeometry::NSectors();
3212 Int_t nPlate = AliTOFGeometry::NPlates();
3213 Int_t nStripA = AliTOFGeometry::NStripA();
3214 Int_t nStripB = AliTOFGeometry::NStripB();
3215 Int_t nStripC = AliTOFGeometry::NStripC();
3217 Int_t isector =ind[0];
3218 if (isector >= nSector)
3219 AliError(Form("Wrong sector number in TOF (%d) !", isector));
3220 Int_t iplate = ind[1];
3221 if (iplate >= nPlate)
3222 AliError(Form("Wrong plate number in TOF (%d) !", iplate));
3223 Int_t istrip = ind[2];
3225 Int_t stripOffset = 0;
3231 stripOffset = nStripC;
3234 stripOffset = nStripC+nStripB;
3237 stripOffset = nStripC+nStripB+nStripA;
3240 stripOffset = nStripC+nStripB+nStripA+nStripB;
3243 AliError(Form("Wrong plate number in TOF (%d) !", iplate));
3247 Int_t index= (2*(nStripC+nStripB)+nStripA)*isector +
3251 UShort_t volIndex = AliGeomManager::LayerToVolUID(AliGeomManager::kTOF, index);
3256 //_____________________________________________________________________________
3258 void AliTOFClusterFinderV1::GetClusterPars(Int_t *ind, Double_t* pos, Double_t* cov) const
3261 // Starting from the volume indices (ind[5]), for a cluster coming from
3262 // a isolated digits, this function returns:
3263 // the cluster position (pos),
3264 // the cluster covariance matrix elements (cov)
3268 //we now go in the system of the strip: determine the local coordinates
3271 // 47---------------------------------------------------0 ^ z
3272 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 1 |
3273 // ----------------------------------------------------- | y going outwards
3274 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 0 | par[0]=0;
3276 // ----------------------------------------------------- |
3277 // x <-----------------------------------------------------
3279 //move to the tracking ref system
3280 Double_t lpos[3] = { (ind[4]-23.5)*AliTOFGeometry::XPad(),
3282 (ind[3]- 0.5)*AliTOFGeometry::ZPad() };
3283 AliDebug(1, Form(" %f %f %f", lpos[0], lpos[1], lpos[2]));
3286 UShort_t volIndex = fTOFGeometry->GetAliSensVolIndex(ind[0],ind[1],ind[2]);
3287 //UShort_t volIndex = GetClusterVolIndex(ind);
3288 const TGeoHMatrix *l2t = AliGeomManager::GetTracking2LocalMatrix(volIndex);
3290 // Get the position in the track ref system
3292 l2t->MasterToLocal(lpos,tpos);
3297 //Get the cluster covariance in the track ref system
3299 for (Int_t ii=0; ii<9; ii++) lcov[ii] = 0.;
3301 //cluster covariance in the local system:
3306 lcov[4] = 0.42*0.42/3.;
3307 // = ( 5*0.025 (gas gaps thikness)
3308 // + 4*0.040 (internal glasses thickness)
3309 // + 0.5*0.160 (internl PCB)
3310 // + 1*0.055 (external red glass))
3313 lcov[0] = 0.499678;//AliTOFGeometry::XPad()*AliTOFGeometry::XPad()/12.;
3314 lcov[8] = 0.992429;//AliTOFGeometry::ZPad()*AliTOFGeometry::ZPad()/12.;
3316 //cluster covariance in the tracking system:
3318 m.SetRotation(lcov);
3320 m.MultiplyLeft(&l2t->Inverse());
3321 Double_t *tcov = m.GetRotationMatrix();
3322 cov[0] = tcov[0]; cov[1] = tcov[1]; cov[2] = tcov[2];
3323 cov[3] = tcov[4]; cov[4] = tcov[5]; cov[5] = tcov[8];
3328 //_____________________________________________________________________________
3330 void AliTOFClusterFinderV1::GetClusterPars(/*Bool_t check,*/ Int_t counter,
3331 Int_t **ind, Double_t *weight,
3332 Double_t *pos, Double_t *cov) const
3336 // the volumes indices (ind[counter][5]), for a
3337 // cluster coming from a collection of 'counter'
3339 // the volumes weights (weight[counter]), -controlled
3340 // by the 'check' variable control-, for a cluster
3341 // coming from a collection of 'counter' digits,
3342 // the cluster position (pos),
3343 // this function returns:
3344 // the covariance matrix elements (cov) for the found cluster
3348 // we now go in the system of the strip: determine the local coordinates
3350 // 47---------------------------------------------------0 ^ z
3351 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 1 |
3352 // ----------------------------------------------------- | y going outwards
3353 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 0 | par[0]=0;
3355 // ----------------------------------------------------- |
3356 // x <-----------------------------------------------------
3358 for (Int_t ii=0; ii<counter; ii++)
3359 AliDebug(1, Form(" %2d %2d %1d %2d %1d %2d ",
3360 ii, ind[ii][0], ind[ii][1], ind[ii][2], ind[ii][3], ind[ii][4]));
3362 Float_t posF[3]; for (Int_t ii=0; ii<3; ii++) posF[ii] = (Float_t)pos[ii];
3363 AliDebug(1, Form(" %f %f %f", pos[0], pos[1], pos[2]));
3365 Int_t detClus[5] = {-1, -1, -1, -1, -1};
3366 fTOFGeometry->GetDetID(posF, detClus);
3369 UShort_t volIndex = fTOFGeometry->GetAliSensVolIndex(detClus[0],detClus[1],detClus[2]);
3370 //UShort_t volIndex = GetClusterVolIndex(detClus);
3371 AliDebug(1, Form(" %2d %1d %2d %1d %2d %7i",
3372 detClus[0], detClus[1], detClus[2], detClus[3], detClus[4], volIndex));
3374 // Get the position in the TOF strip ref system
3375 const TGeoHMatrix *alice2strip = AliGeomManager::GetOrigGlobalMatrix(volIndex);
3376 Double_t ppos[3] = {-1, -1, -1};
3377 alice2strip->MasterToLocal(pos,ppos);
3378 AliDebug(1, Form(" %f %f %f", ppos[0], ppos[1], ppos[2]));
3381 // Get the position in the tracking ref system
3382 const TGeoHMatrix *g2l = AliGeomManager::GetTracking2LocalMatrix(volIndex);
3383 Double_t lpos[3] = {-1, -1, -1};
3384 g2l->MasterToLocal(ppos,lpos);
3385 AliDebug(1, Form(" %f %f %f", lpos[0], lpos[1], lpos[2]));
3386 for (Int_t ii=0; ii<3; ii++) pos[ii] = lpos[ii];
3388 //Get the cluster covariance in the track ref system
3390 for (Int_t ii=0; ii<9; ii++) lcov[ii] = 0.;
3392 //cluster covariance in the local system:
3397 // Evaluation of the ovariance matrix elements
3398 TOFclusterError(/*check,*/ counter, ind, weight, ppos, lcov);
3400 AliDebug(1, Form("lcov[0] = %f, lcov[8] = %f", lcov[0], lcov[8]));
3402 //cluster covariance in the tracking system:
3404 m.SetRotation(lcov);
3406 m.MultiplyLeft(&g2l->Inverse());
3407 Double_t *tcov = m.GetRotationMatrix();
3408 cov[0] = tcov[0]; cov[1] = tcov[1]; cov[2] = tcov[2];
3409 cov[3] = tcov[4]; cov[4] = tcov[5]; cov[5] = tcov[8];
3414 //_____________________________________________________________________________
3416 void AliTOFClusterFinderV1::TOFclusterError(/*Bool_t check,*/ Int_t counter,
3417 Int_t **ind, Double_t *weight,
3418 Double_t ppos[], Double_t lcov[]) const
3424 //lcov[4] = 0.42*0.42/3.; // cm2
3425 // = ( 5*0.025 (gas gaps thikness)
3426 // + 4*0.040 (internal glasses thickness)
3427 // + 0.5*0.160 (internl PCB)
3428 // + 1*0.055 (external red glass))
3431 Float_t *delta2X = new Float_t[counter];
3432 for (Int_t ii=0; ii<counter; ii++)
3434 ((ind[ii][4]-23.5)*AliTOFGeometry::XPad() - ppos[0])*((ind[ii][4]-23.5)*AliTOFGeometry::XPad() - ppos[0]);
3436 Float_t *delta2Z = new Float_t[counter];
3437 for (Int_t ii=0; ii<counter; ii++)
3439 ((ind[ii][3]- 0.5)*AliTOFGeometry::ZPad() - ppos[2])*((ind[ii][3]- 0.5)*AliTOFGeometry::ZPad() - ppos[2]);
3441 for (Int_t ii=0; ii<counter; ii++)
3442 AliDebug(1, Form("x[%d] = %f, z[%d] = %f, weight[%d] = %f",
3443 ii, (ind[ii][4]-23.5)*AliTOFGeometry::XPad(),
3444 ii, (ind[ii][3]- 0.5)*AliTOFGeometry::ZPad(),
3447 AliDebug(1, Form("xMean = %f, zMean = %f",ppos[0], ppos[2]));
3455 if (ind[0][3]==ind[1][3] && TMath::Abs(ind[0][4]-ind[1][4])==1) { //
3457 lcov[8] = 1.02039; // cm2
3458 lcov[0] = 0.0379409; // cm2
3461 lcov[0] = 0.5*0.5; // cm2
3463 if (weight[0]==weight[1])
3464 lcov[0] = 0.0379409; // cm2
3466 lcov[0] = TMath::Mean(counter, delta2X, weight); // cm2
3472 else if (ind[0][4]==ind[1][4] && TMath::Abs(ind[0][3]-ind[1][3])==1) {//
3474 lcov[0] = 0.505499; // cm2
3475 lcov[8] = 0.0422046; // cm2
3478 lcov[8] = 0.5*0.5; // cm2
3480 if (weight[0]==weight[1])
3481 lcov[8] = 0.0422046; // cm2
3483 lcov[8] = TMath::Mean(counter, delta2Z, weight); // cm2
3492 lcov[0] = 0.0290677; // cm2
3493 lcov[8] = 0.0569726; // cm2
3496 lcov[0] = 0.5*0.5; // cm2
3497 lcov[8] = 0.5*0.5; // cm2
3500 if (weight[0]==weight[1] && weight[0]==weight[2]) {
3501 lcov[0] = 0.0290677; // cm2
3502 lcov[8] = 0.0569726; // cm2
3505 lcov[0] = TMath::Mean(counter, delta2X, weight); // cm2
3506 lcov[8] = TMath::Mean(counter, delta2Z, weight); // cm2
3515 lcov[0] = 0.0223807; // cm2
3516 lcov[8] = 0.0438662; // cm2
3519 lcov[0] = 0.5*0.5; // cm2
3520 lcov[8] = 0.5*0.5; // cm2
3523 if (weight[0]==weight[1] && weight[0]==weight[2] && weight[0]==weight[3]) {
3524 lcov[0] = 0.0223807; // cm2
3525 lcov[8] = 0.0438662; // cm2
3528 lcov[0] = TMath::Mean(counter, delta2X, weight); // cm2
3529 lcov[8] = TMath::Mean(counter, delta2Z, weight); // cm2
3543 //_____________________________________________________________________________
3545 Bool_t AliTOFClusterFinderV1::MakeSlewingCorrection(Int_t *detectorIndex,
3551 // This funtion makes the following:
3553 // - if at least one of the three status (Pulser/Noise/HW) is
3554 // bad, is sets the status of electronic channel, corresponding to the
3555 // volume identified by detectorIndex, as kFALSE;
3556 // - if offline calibration is in the valid status, it performs the
3557 // slewing correction. In particular, by taking into account:
3558 // * the measured tot and tof values (tofDigitToT and tofDigitTdc,
3560 // * the six parameters of 5th order polynomial used
3561 // to fit the tofVStot scatter plot,
3562 // it returns the corrected tof value, i.e. tdcCorr value.
3565 Bool_t output = kTRUE;
3570 //AliInfo(" Calibrating TOF Digits: ");
3572 AliTOFChannelOnlineArray *calDelay = fTOFcalib->GetTOFOnlineDelay();
3573 AliTOFChannelOnlineStatusArray *calStatus = fTOFcalib->GetTOFOnlineStatus();
3575 TObjArray *calTOFArrayOffline = fTOFcalib->GetTOFCalArrayOffline();
3577 Int_t index = AliTOFGeometry::GetIndex(detectorIndex);
3579 UChar_t statusPulser = calStatus->GetPulserStatus(index);
3580 UChar_t statusNoise = calStatus->GetNoiseStatus(index);
3581 UChar_t statusHW = calStatus->GetHWStatus(index);
3582 UChar_t status = calStatus->GetStatus(index);
3584 //check the status, also unknown is fine!!!!!!!
3586 AliDebug(2, Form(" Status for channel %d = %d",index, (Int_t)status));
3587 if((statusPulser & AliTOFChannelOnlineStatusArray::kTOFPulserBad)==(AliTOFChannelOnlineStatusArray::kTOFPulserBad)||(statusNoise & AliTOFChannelOnlineStatusArray::kTOFNoiseBad)==(AliTOFChannelOnlineStatusArray::kTOFNoiseBad)||(statusHW & AliTOFChannelOnlineStatusArray::kTOFHWBad)==(AliTOFChannelOnlineStatusArray::kTOFHWBad)){
3588 AliDebug(2, Form(" Bad Status for channel %d",index));
3589 //fTofClusters[ii]->SetStatus(kFALSE); //odd convention, to avoid conflict with calibration objects currently in the db (temporary solution).
3593 AliDebug(2, Form(" Good Status for channel %d",index));
3596 if (fCalibrateTOFtimes) { // AdC
3598 // Get Rough channel online equalization
3599 Double_t roughDelay = (Double_t)calDelay->GetDelay(index); // in ns
3600 AliDebug(2,Form(" channel delay (ns) = %f", roughDelay));
3601 // Get Refined channel offline calibration parameters
3602 TString validity = (TString)fTOFcalib->GetOfflineValidity();
3603 if (validity.CompareTo("valid")==0) {
3604 AliTOFChannelOffline * calChannelOffline = (AliTOFChannelOffline*)calTOFArrayOffline->At(index);
3606 for (jj = 0; jj<6; jj++)
3607 par[jj] = (Double_t)calChannelOffline->GetSlewPar(jj);
3609 AliDebug(2,Form(" Calib Pars = %f, %f, %f, %f, %f, %f ",par[0],par[1],par[2],par[3],par[4],par[5]));
3610 AliDebug(2,Form(" The ToT and Time, uncorr (counts) = %d , %d", tofDigitToT, tofDigitTdc));
3611 Double_t tToT = (Double_t)(tofDigitToT*AliTOFGeometry::ToTBinWidth());
3612 tToT*=1.E-3; //ToT in ns
3613 AliDebug(2,Form(" The ToT and Time, uncorr (ns)= %e, %e",tofDigitTdc*AliTOFGeometry::TdcBinWidth()*1.E-3,tToT));
3614 timeCorr = par[0] + tToT*(par[1] + tToT*(par[2] + tToT*(par[3] + tToT*(par[4] + tToT*par[5])))); // the time correction (ns)
3617 timeCorr = roughDelay; // correction in ns
3619 AliDebug(2,Form(" The ToT and Time, uncorr (ns)= %e, %e",tofDigitTdc*AliTOFGeometry::TdcBinWidth()*1.E-3,tofDigitToT*AliTOFGeometry::ToTBinWidth()));
3620 AliDebug(2,Form(" The time correction (ns) = %f", timeCorr));
3621 timeCorr = (Double_t)(tofDigitTdc)*AliTOFGeometry::TdcBinWidth()*1.E-3-timeCorr;//redefine the time
3623 AliDebug(2,Form(" The channel time, corr (ps)= %e",timeCorr ));
3624 //tdcCorr = (Int_t)(timeCorr/AliTOFGeometry::TdcBinWidth()); //the corrected time (tdc counts)
3625 tdcCorr = TMath::Nint(timeCorr/AliTOFGeometry::TdcBinWidth()); //the corrected time (tdc counts)
3632 //______________________________________________________________________________
3634 void AliTOFClusterFinderV1::Digits2RecPoints(Int_t iEvent)
3637 // Converts digits to recpoints for TOF
3640 TStopwatch stopwatch;
3643 fRunLoader->GetEvent(iEvent);
3645 AliLoader *localTOFLoader = (AliLoader*)fRunLoader->GetLoader("TOFLoader");
3647 TTree * localTreeD = (TTree*)localTOFLoader->TreeD();
3648 if (localTreeD == 0x0)
3649 AliFatal("Can not get TreeD");
3651 TBranch *branch = localTreeD->GetBranch("TOF");
3653 AliError("Can't get the branch with the TOF digits !");
3657 TTree *localTreeR = (TTree*)localTOFLoader->TreeR();
3658 if (localTreeR == 0x0)
3660 localTOFLoader->MakeTree("R");
3661 localTreeR = localTOFLoader->TreeR();
3664 Digits2RecPoints(localTreeD, localTreeR);
3666 //localTOFLoader = fRunLoader->GetLoader("TOFLoader");
3667 localTOFLoader->WriteRecPoints("OVERWRITE");
3669 AliDebug(1, Form("Execution time to read TOF digits and to write TOF clusters for the event number %d: R:%.4fs C:%.4fs",
3670 iEvent, stopwatch.RealTime(),stopwatch.CpuTime()));
3673 //______________________________________________________________________________
3675 void AliTOFClusterFinderV1::Digits2RecPoints(Int_t iEvent, AliRawReader *rawReader)
3678 // Converts RAW data to recpoints for TOF
3681 TStopwatch stopwatch;
3684 fRunLoader->GetEvent(iEvent);
3686 AliDebug(2,Form(" Event number %2d ", iEvent));
3688 AliLoader *localTOFLoader = (AliLoader*)fRunLoader->GetLoader("TOFLoader");
3690 TTree *localTreeR = localTOFLoader->TreeR();
3692 if (localTreeR == 0x0){
3693 localTOFLoader->MakeTree("R");
3694 localTreeR = localTOFLoader->TreeR();
3697 Digits2RecPoints(rawReader, localTreeR);
3699 AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters for the event number %d: R:%.4fs C:%.4fs",
3700 iEvent, stopwatch.RealTime(),stopwatch.CpuTime()));
3703 //______________________________________________________________________________
3705 void AliTOFClusterFinderV1::Raw2Digits(Int_t iEvent, AliRawReader *rawReader)
3708 // Converts RAW data to MC digits for TOF
3712 TStopwatch stopwatch;
3715 fRunLoader->GetEvent(iEvent);
3717 AliDebug(2,Form(" Event number %2d ", iEvent));
3719 AliLoader *localTOFLoader = (AliLoader*)fRunLoader->GetLoader("TOFLoader");
3721 TTree *localTreeD = localTOFLoader->TreeD();
3723 if (localTreeD == 0x0){
3724 localTOFLoader->MakeTree("D");
3725 localTreeD = localTOFLoader->TreeD();
3728 Raw2Digits(rawReader, localTreeD);
3730 AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters for the event number %d: R:%.4fs C:%.4fs",
3731 iEvent, stopwatch.RealTime(),stopwatch.CpuTime()));
3734 //______________________________________________________________________________
3736 void AliTOFClusterFinderV1::AverageCalculations(Int_t number, Float_t *interestingX,
3737 Float_t *interestingY, Float_t *interestingZ,
3738 Double_t *interestingTOF, Double_t *interestingTOT,
3739 Double_t *interestingADC, Double_t *interestingWeight,
3740 Int_t *parTOF, Double_t *posClus, Bool_t &check)
3743 // Calculates the mean values for cluster position (x,y,z),
3744 // TOF charge and time
3747 Double_t tofAverage = 0.;
3748 Double_t totAverage = 0.;
3749 Double_t adcAverage = 0.;
3753 for (ii=number-1; ii>=0; ii--) check=check||(interestingWeight[ii]==0 || interestingWeight[ii]==-1);
3757 posClus[0] = TMath::Mean(number, interestingX);
3758 posClus[1] = TMath::Mean(number, interestingY);
3759 posClus[2] = TMath::Mean(number, interestingZ);
3760 tofAverage = TMath::Mean(number, interestingTOF);
3761 totAverage = TMath::Mean(number, interestingTOT);
3762 adcAverage = TMath::Mean(number, interestingADC);
3767 posClus[0] = TMath::Mean(number, interestingX, interestingWeight);
3768 posClus[1] = TMath::Mean(number, interestingY, interestingWeight);
3769 posClus[2] = TMath::Mean(number, interestingZ, interestingWeight);
3770 tofAverage = TMath::Mean(number, interestingTOF, interestingWeight);
3771 totAverage = TMath::Mean(number, interestingTOT, interestingWeight);
3772 adcAverage = TMath::Mean(number, interestingADC, interestingWeight);
3776 parTOF[0] = Int_t(tofAverage);
3777 parTOF[1] = Int_t(totAverage);
3778 parTOF[2] = Int_t(adcAverage);
3779 parTOF[3] = Int_t(tofAverage);//tofND
3780 parTOF[4] = Int_t(tofAverage);//tofRAW