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 0.01 2008/05/10 A. De Caro
21 /////////////////////////////////////////
23 // Class for TOF cluster finder (V1) //
25 // Input data: Raw Data or Digits; //
26 // Output data: Digits or Rec Points //
28 /////////////////////////////////////////
30 #include "Riostream.h"
32 #include "TClonesArray.h"
33 #include "TStopwatch.h"
35 #include "TGeoMatrix.h"
40 #include "AliRawReader.h"
41 #include "AliRunLoader.h"
42 #include "AliGeomManager.h"
44 #include "AliTOFcalib.h"
45 #include "AliTOFChannelOnlineArray.h"
46 #include "AliTOFChannelOnlineStatusArray.h"
47 #include "AliTOFChannelOffline.h"
48 #include "AliTOFClusterFinderV1.h"
49 #include "AliTOFcluster.h"
50 #include "AliTOFdigit.h"
51 //#include "AliTOFselectedDigit.h"
52 #include "AliTOFDigitMap.h"
53 #include "AliTOFGeometry.h"
54 #include "AliTOFrawData.h"
55 //#include "AliTOFRawStream.h"
57 ClassImp(AliTOFClusterFinderV1)
59 AliTOFClusterFinderV1::AliTOFClusterFinderV1(AliTOFcalib *calib):
61 fDigits(new TClonesArray("AliTOFdigit", 4000)),
62 fRecPoints(new TClonesArray("AliTOFcluster", 4000)),
63 fNumberOfTofClusters(0),
64 fNumberOfTofDigits(0),
69 fTOFdigitMap(new AliTOFDigitMap()),
70 fTOFRawStream(AliTOFRawStream())
77 //_____________________________________________________________________________
79 AliTOFClusterFinderV1::AliTOFClusterFinderV1(AliRunLoader* runLoader, AliTOFcalib *calib):
80 fRunLoader(runLoader),
81 fDigits(new TClonesArray("AliTOFdigit", 4000)),
82 fRecPoints(new TClonesArray("AliTOFcluster", 4000)),
83 fNumberOfTofClusters(0),
84 fNumberOfTofDigits(0),
89 fTOFdigitMap(new AliTOFDigitMap()),
90 fTOFRawStream(AliTOFRawStream())
97 //_____________________________________________________________________________
99 AliTOFClusterFinderV1::AliTOFClusterFinderV1(const AliTOFClusterFinderV1 &source)
102 fDigits(source.fDigits),
103 fRecPoints(source.fRecPoints),
104 fNumberOfTofClusters(0),
105 fNumberOfTofDigits(0),
108 fDecoderVersion(source.fDecoderVersion),
109 fTOFcalib(source.fTOFcalib),
110 fTOFdigitMap(new AliTOFDigitMap()),
111 fTOFRawStream(source.fTOFRawStream)
115 //_____________________________________________________________________________
117 AliTOFClusterFinderV1& AliTOFClusterFinderV1::operator=(const AliTOFClusterFinderV1 &source)
124 TObject::operator=(source);
125 fDigits=source.fDigits;
126 fRecPoints=source.fRecPoints;
127 fVerbose=source.fVerbose;
128 fDecoderVersion=source.fDecoderVersion;
129 fTOFcalib=source.fTOFcalib;
130 fTOFdigitMap=source.fTOFdigitMap;
131 fTOFRawStream=source.fTOFRawStream;
135 //_____________________________________________________________________________
137 AliTOFClusterFinderV1::~AliTOFClusterFinderV1()
152 fRecPoints->Delete();
160 //_____________________________________________________________________________
162 void AliTOFClusterFinderV1::Digits2RecPoints(TTree* digitsTree, TTree* clusterTree)
165 // Converts digits to recPoints for TOF
168 TStopwatch stopwatch;
173 TClonesArray &aDigits = *fDigits;
175 if (digitsTree == 0x0)
176 AliFatal("Can not get TreeD for TOF");
178 TBranch *branch = digitsTree->GetBranch("TOF");
180 AliError("Can not get branch with the TOF digits !");
184 TClonesArray staticDigits("AliTOFdigit",10000);
185 staticDigits.Clear();
186 TClonesArray *digits = &staticDigits;
187 branch->SetAddress(&digits);
188 digitsTree->GetEvent(0);
189 AliInfo(Form("Number of TOF digits: %d", digits->GetEntriesFast()));
191 AliTOFdigit *tofDigit;
194 Int_t detectorIndex[5];
195 for (jj=0; jj<5; jj++) detectorIndex[jj] = -1;
197 for (jj=0; jj<4; jj++) info[jj] = -1;
203 Bool_t status = kTRUE;
205 AliInfo(" Calibrating TOF Digits: ");
206 TString validity = (TString)fTOFcalib->GetOfflineValidity();
207 AliInfo(Form(" validity = %s", validity.Data()));
208 if (validity.CompareTo("valid")==0) {
209 AliInfo(" ...using offline calibration parameters");
212 AliInfo(" ...using online calibration parameters");
216 for (ii=0; ii<digits->GetEntriesFast(); ii++) {
217 tofDigit = (AliTOFdigit*)digits->UncheckedAt(ii);
218 detectorIndex[0] = tofDigit->GetSector();
219 detectorIndex[1] = tofDigit->GetPlate();
220 detectorIndex[2] = tofDigit->GetStrip();
221 detectorIndex[3] = tofDigit->GetPadz();
222 detectorIndex[4] = tofDigit->GetPadx();
224 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
225 if (detectorIndex[1]==2) { // plate with holes
231 status = MakeSlewingCorrection(detectorIndex, tofDigit->GetToT(), tofDigit->GetTdc(), tdcCorr);
233 for (jj=0; jj<4; jj++) info[jj] = -1;
234 info[0] = tdcCorr;//tofDigit->GetTdc();
235 info[1] = tofDigit->GetAdc();
236 info[2] = tofDigit->GetToT();
237 info[3] = tofDigit->GetTdcND();//tofDigit->GetTdc();//
238 tracks = tofDigit->GetTracks();
240 dummy = detectorIndex[3];
241 detectorIndex[3] = detectorIndex[4];//padx
242 detectorIndex[4] = dummy;//padz
243 last = fDigits->GetEntriesFast();
244 new (aDigits[last]) AliTOFdigit(tracks, detectorIndex, info);
245 if (status) fTOFdigitMap->AddDigit(detectorIndex, last);
247 AliDebug(2, Form(" Digits reading %2i -> %2i %1i %2i %1i %2i (%d, %d, %d)",
249 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[3], detectorIndex[4],
250 info[0], info[1], info[3]));
254 fNumberOfTofDigits = fDigits->GetEntriesFast();
258 Int_t bufsize = 32000;
259 clusterTree->Branch("TOF", &fRecPoints, bufsize);
264 AliInfo(Form("Number of found TOF clusters: %d", fNumberOfTofClusters));
268 fTOFdigitMap->Clear();
272 AliInfo(Form("Execution time to read TOF digits and to write TOF clusters : R:%.4fs C:%.4fs",
273 stopwatch.RealTime(),stopwatch.CpuTime()));
275 if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
278 //_____________________________________________________________________________
280 void AliTOFClusterFinderV1::Digits2RecPoints(AliRawReader *rawReader, TTree *clustersTree)
283 // Converts raw data to recPoints for TOF
286 TStopwatch stopwatch;
290 AliDebug(2, "TreeD re-creation");
291 TTree *digitsTree = new TTree();
293 Raw2Digits(rawReader, digitsTree);
295 AliDebug(2,Form("Number of TOF digits: %d", fNumberOfTofDigits));
298 Int_t bufsize = 32000;
299 clustersTree->Branch("TOF", &fRecPoints, bufsize);
302 clustersTree->Fill();
304 AliInfo(Form("Number of found clusters: %i", fNumberOfTofClusters));
308 fTOFdigitMap->Clear();
312 AliInfo(Form("Execution time to read TOF raw data and to write TOF clusters : R:%.4fs C:%.4fs",
313 stopwatch.RealTime(),stopwatch.CpuTime()));
317 //_____________________________________________________________________________
319 void AliTOFClusterFinderV1::Raw2Digits(AliRawReader *rawReader, TTree* digitsTree)
322 // Converts raw data to digits for TOF
325 TStopwatch stopwatch;
330 const Int_t kMaxNumberOfTracksPerDigit = 3;
331 const Int_t kDDL = AliDAQ::NumberOfDdls("TOF");
333 digitsTree->Branch("TOF", &fDigits);
334 TClonesArray &aDigits = *fDigits;
336 //AliTOFRawStream tofInput(rawReader);
337 fTOFRawStream.Clear();
338 fTOFRawStream.SetRawReader(rawReader);
341 if (fVerbose==2) ftxt.open("TOFdigitsRead.txt",ios::app);
343 TClonesArray staticRawData("AliTOFrawData",10000);
344 staticRawData.Clear();
345 TClonesArray * clonesRawData = &staticRawData;
348 Int_t detectorIndex[5] = {-1, -1, -1, -1, -1};
350 Int_t tracks[kMaxNumberOfTracksPerDigit];
351 for (Int_t ii=0; ii<kMaxNumberOfTracksPerDigit; ii++)
356 Bool_t status = kTRUE;
358 AliInfo(" Calibrating TOF Digits: ");
359 TString validity = (TString)fTOFcalib->GetOfflineValidity();
360 AliInfo(Form(" validity = %s", validity.Data()));
361 if (validity.CompareTo("valid")==0) {
362 AliInfo(" ...using offline calibration parameters");
365 AliInfo(" ...using online calibration parameters");
370 for (indexDDL=0; indexDDL<kDDL; indexDDL++) {
373 if (fDecoderVersion) {
374 AliInfo("Using New Decoder \n");
375 fTOFRawStream.LoadRawDataBuffers(indexDDL,fVerbose);
377 else fTOFRawStream.LoadRawData(indexDDL);
379 clonesRawData = (TClonesArray*)fTOFRawStream.GetRawData();
380 if (clonesRawData->GetEntriesFast()!=0) AliInfo(Form(" TOF raw data number = %3i", clonesRawData->GetEntriesFast()));
381 for (iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
383 AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
385 //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
386 if (tofRawDatum->GetTOF()==-1) continue;
388 fTOFRawStream.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
389 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
392 dummy = detectorIndex[3];
393 detectorIndex[3] = detectorIndex[4];//padz
394 detectorIndex[4] = dummy;//padx
395 status = MakeSlewingCorrection(detectorIndex, tofRawDatum->GetTOT(), tofRawDatum->GetTOF(), tdcCorr);
398 digit[1] = tofRawDatum->GetTOT();
399 digit[2] = tofRawDatum->GetTOT();
400 digit[3] = tofRawDatum->GetTOF();
402 dummy = detectorIndex[3];
403 detectorIndex[3] = detectorIndex[4];//padx
404 detectorIndex[4] = dummy;//padz
406 // Do not reconstruct anything in the holes
407 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
408 if (detectorIndex[1]==2) { // plate with holes
414 last = fDigits->GetEntriesFast();
415 new (aDigits[last]) AliTOFdigit(tracks, detectorIndex, digit);
416 if (status) fTOFdigitMap->AddDigit(detectorIndex, last);
419 if (indexDDL<10) ftxt << " " << indexDDL;
420 else ftxt << " " << indexDDL;
421 if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM();
422 else ftxt << " " << tofRawDatum->GetTRM();
423 ftxt << " " << tofRawDatum->GetTRMchain();
424 if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC();
425 else ftxt << " " << tofRawDatum->GetTDC();
426 ftxt << " " << tofRawDatum->GetTDCchannel();
428 if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0];
429 else ftxt << " -> " << detectorIndex[0];
430 ftxt << " " << detectorIndex[1];
431 if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2];
432 else ftxt << " " << detectorIndex[2];
433 ftxt << " " << detectorIndex[4];
434 if (detectorIndex[4]<10) ftxt << " " << detectorIndex[3];
435 else ftxt << " " << detectorIndex[3];
437 if (digit[1]<10)ftxt << " " << digit[1];
438 else if (digit[1]>=10 && digit[1]<100) ftxt << " " << digit[1];
439 else ftxt << " " << digit[1];
440 if (digit[0]<10) ftxt << " " << digit[0] << endl;
441 else if (digit[0]>=10 && digit[0]<100) ftxt << " " << digit[0] << endl;
442 else if (digit[0]>=100 && digit[0]<1000) ftxt << " " << digit[0] << endl;
443 else ftxt << " " << digit[3] << endl;
446 AliDebug(2, Form(" Raw data reading %2i -> %2i %1i %2i %1i %2i (%d, %d, %d)",
448 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[4], detectorIndex[3],
449 digit[0], digit[1], digit[3]));
453 clonesRawData->Clear();
457 if (fVerbose==2) ftxt.close();
461 fNumberOfTofDigits = fDigits->GetEntries();
463 AliDebug(1, Form("Got %d TOF digits", fNumberOfTofDigits));
464 AliDebug(1, Form("Execution time to read TOF raw data and fill TOF digit tree : R:%.2fs C:%.2fs",
465 stopwatch.RealTime(),stopwatch.CpuTime()));
467 if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
470 //_____________________________________________________________________________
472 void AliTOFClusterFinderV1::FillRecPoint()
475 // Fill the global TClonesArray of AliTOFcluster objects,
479 //Int_t dummy4_1 = -1;
480 //Int_t dummy3_1 = -1;
481 //Int_t dummy2_1 = -1;
484 for(Int_t iPlate=0; iPlate<AliTOFGeometry::NPlates(); iPlate++) {
485 for(Int_t iStrip=0; iStrip<AliTOFGeometry::NStrip(iPlate); iStrip++) {
486 for (Int_t iSector=0; iSector<AliTOFGeometry::NSectors(); iSector++) {
488 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
489 FindClustersPerStrip(iSector, iPlate, iStrip, 4); // 4 pads clusters
490 dummy4_1 = fNumberOfTofClusters;
491 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
492 FindClustersPerStrip(iSector, iPlate, iStrip, 4); // 4 pads clusters
493 if (fNumberOfTofClusters!=dummy4_1)
494 AliDebug(2, Form(" (4): n1= %5i, n2 = %5", dummy4_1, fNumberOfTofClusters));
497 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
498 FindClustersPerStrip(iSector, iPlate, iStrip, 3); // 3 pads clusters
499 dummy3_1 = fNumberOfTofClusters;
500 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
501 FindClustersPerStrip(iSector, iPlate, iStrip, 3); // 3 pads clusters
502 if (fNumberOfTofClusters!=dummy3_1)
503 AliDebug(2, Form(" (3): n1= %5i, n2 = %5", dummy3_1, fNumberOfTofClusters));
506 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
507 FindClustersPerStrip(iSector, iPlate, iStrip, 2); // 2 pads clusters
508 dummy2_1 = fNumberOfTofClusters;
509 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
510 FindClustersPerStrip(iSector, iPlate, iStrip, 2); // 2 pads clusters
511 if (fNumberOfTofClusters!=dummy2_1)
512 AliDebug(2, Form(" (2): n1= %5i, n2 =%5", dummy2_1, fNumberOfTofClusters));
515 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
516 dummy = fNumberOfTofClusters;
517 FindClusters34(iSector, iPlate, iStrip); // 3 pads clusters between 4 hit pads
518 if (fNumberOfTofClusters!=dummy)
519 AliDebug(2, Form(" (3 between 4): n1 = %5i, n2 = %5i", fNumberOfTofClusters, dummy));
522 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
523 dummy = fNumberOfTofClusters;
524 FindClusters23(iSector, iPlate, iStrip); // 2 pads clusters between 3 hit pads
525 if (fNumberOfTofClusters!=dummy)
526 AliDebug(2, Form(" (2 between 3): n1 = %5i, n2 = %5i", fNumberOfTofClusters, dummy));
528 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
529 dummy = fNumberOfTofClusters;
530 FindClusters24(iSector, iPlate, iStrip); // 2 pads clusters between 4 hit pads
531 if (fNumberOfTofClusters!=dummy)
532 AliDebug(2, Form(" (2 between 4): n1 = %5i, n2 = %5i", fNumberOfTofClusters, dummy));
536 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
537 dummy = fNumberOfTofClusters;
538 FindOnePadClusterPerStrip(iSector, iPlate, iStrip); // 1 pad clusters
539 if (fNumberOfTofClusters!=dummy)
540 AliDebug(2,Form(" (1): n1 = %5i, n2 = %5i", fNumberOfTofClusters, dummy));
542 if (fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip)>0)
543 AliDebug(2, Form(" (1): numero di clusters = %5i (remaining digit %2i), -%2i %1i %2i-",
544 fNumberOfTofClusters, fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip),
545 iSector, iPlate, iStrip));
552 TClonesArray &lRecPoints = *fRecPoints;
556 Int_t detectorIndex[5];
558 Int_t trackLabels[3];
559 Int_t digitIndex = -1;
560 Bool_t status = kTRUE;
562 for (ii=0; ii<3; ii++) posClus[ii] = 0.;
563 //Float_t covClus[6];
564 //for (ii=0; ii<6; ii++) covClus[ii] = 0.;
567 for (ii=0; ii<fNumberOfTofClusters; ii++) {
569 digitIndex = fTofClusters[ii]->GetIndex();
570 for(jj=0; jj<5; jj++) detectorIndex[jj] = fTofClusters[ii]->GetDetInd(jj);
571 volIdClus = GetClusterVolIndex(detectorIndex);
572 for(jj=0; jj<3; jj++) trackLabels[jj] = fTofClusters[ii]->GetLabel(jj);
573 parTOF[0] = fTofClusters[ii]->GetTDC(); // TDC
574 parTOF[1] = fTofClusters[ii]->GetToT(); // TOT
575 parTOF[2] = fTofClusters[ii]->GetADC(); // ADC=TOT
576 parTOF[3] = fTofClusters[ii]->GetTDCND(); // TDCND
577 parTOF[4] = fTofClusters[ii]->GetTDCRAW();//RAW
578 status = fTofClusters[ii]->GetStatus();
580 posClus[0] = fTofClusters[ii]->GetX();
581 posClus[1] = fTofClusters[ii]->GetY();
582 posClus[2] = fTofClusters[ii]->GetZ();
584 //for (jj=0; jj<6; jj++) covClus[jj] = 0.;
585 //((AliCluster*)fTofClusters[ii])->GetGlobalCov(covClus);
587 new(lRecPoints[ii]) AliTOFcluster(volIdClus, (Double_t)posClus[0], (Double_t)posClus[1], (Double_t)posClus[2],
588 (Double_t)(fTofClusters[ii]->GetSigmaX2()),
589 (Double_t)(fTofClusters[ii]->GetSigmaXY()),
590 (Double_t)(fTofClusters[ii]->GetSigmaXZ()),
591 (Double_t)(fTofClusters[ii]->GetSigmaY2()),
592 (Double_t)(fTofClusters[ii]->GetSigmaYZ()),
593 (Double_t)(fTofClusters[ii]->GetSigmaZ2()),
594 //(Double_t)covClus[0], (Double_t)covClus[1], (Double_t)covClus[2],
595 //(Double_t)covClus[3], (Double_t)covClus[4], (Double_t)covClus[5],
596 trackLabels, detectorIndex, parTOF, status, digitIndex);
598 AliDebug(2, Form(" %4i %4i %f %f %f %f %f %f %f %f %f %3i %3i %3i %2i %1i %2i %1i %2i %4i %3i %3i %4i %4i %1i %4i",
599 ii, volIdClus, posClus[0], posClus[1], posClus[2],
600 fTofClusters[ii]->GetSigmaX2(),
601 fTofClusters[ii]->GetSigmaXY(),
602 fTofClusters[ii]->GetSigmaXZ(),
603 fTofClusters[ii]->GetSigmaY2(),
604 fTofClusters[ii]->GetSigmaYZ(),
605 fTofClusters[ii]->GetSigmaZ2(),
606 trackLabels[0], trackLabels[1], trackLabels[2],
607 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[3], detectorIndex[4],
608 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
609 status, digitIndex));
614 for (Int_t iSector=0; iSector<AliTOFGeometry::NSectors(); iSector++)
615 for(Int_t iPlate=0; iPlate<AliTOFGeometry::NPlates(); iPlate++) {
616 for(Int_t iStrip=0; iStrip<AliTOFGeometry::NStrip(iPlate); iStrip++) {
617 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
618 AliDebug(2, Form(" END %2i %1i %2i %5i",
619 iSector, iPlate, iStrip, fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip)));
624 //_____________________________________________________________________________
626 void AliTOFClusterFinderV1::FindOnePadClusterPerStrip(Int_t nSector,
631 // This function searches the isolated digits (stored in the fDigits object),
632 // to perform clusters (stored in the fTofClusters array).
633 // This research has been made by checking the fTOFdigitMap object,
634 // filled at digits/raw-data reading time.
637 const Int_t kMaxNumberOfTracksPerDigit = 3;
638 const Int_t kMaxNumberOfDigitsPerVolume = 3;
642 AliTOFGeometry *tofGeometry = new AliTOFGeometry();
644 Int_t det[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padZ,padX
645 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padX,padZ
646 UShort_t volIdClus = 0;
649 for (jj=0; jj<3; jj++) pos[jj] = 0.;
651 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
654 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
657 for (jj=0; jj<5; jj++) parTOF[jj] = 0;
659 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
661 Int_t tracks[kMaxNumberOfTracksPerDigit];
662 for (jj=0; jj<3; jj++) tracks[jj] = -1;
664 Int_t dummyCounter=-1;
667 AliTOFdigit *digitInteresting;
671 for (iPadX=0; iPadX<AliTOFGeometry::NpadX(); iPadX++) {
672 for (iPadZ=0; iPadZ<AliTOFGeometry::NpadZ(); iPadZ++) {
673 vol[4] = iPadZ , vol[3] = iPadX;
675 AliDebug(3, Form(" %1i %2i\n", iPadZ, iPadX));
677 if (fTOFdigitMap->GetNumberOfDigits(vol)==0) continue;
679 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
680 if (fTOFdigitMap->GetDigitIndex(vol,digIndex)<0) continue;
681 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(fTOFdigitMap->GetDigitIndex(vol,digIndex));
683 AliDebug(2, Form(" %2i %1i %2i %1i %2i %f %f %f %5i %5i %5i %5i",
684 vol[0], vol[1], vol[2] ,vol[4], vol[3],
685 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
686 digitInteresting->GetToT(),
687 fTOFdigitMap->GetDigitIndex(vol,digIndex),
688 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
695 tofGeometry->GetPosPar(det,pos);
696 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
699 for (jj=0; jj<3; jj++) posClus[jj] = pos[jj];
701 parTOF[0] = Int_t(digitInteresting->GetTdc());
702 parTOF[1] = Int_t(digitInteresting->GetAdc());
703 parTOF[2] = Int_t(digitInteresting->GetToT());
704 parTOF[3] = Int_t(digitInteresting->GetTdc());
705 parTOF[4] = Int_t(digitInteresting->GetTdc());
707 volIdClus = GetClusterVolIndex(det);
709 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
710 GetClusterPars(det, posClus, covClus);
712 // To fill the track index array
714 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
715 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) { // three is the max number of tracks associated to one digit
716 if (digitInteresting->GetTrack(jj)==-1) continue;
719 tracks[dummyCounter] = digitInteresting->GetTrack(jj);
723 AliTOFcluster *tofCluster =
724 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
725 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
726 tracks, det, parTOF, status, fTOFdigitMap->GetDigitIndex(vol,digIndex));
727 InsertCluster(tofCluster);
729 AliDebug(2, Form(" %4i %f %f %f %f %f %f %f %f %f %3i %3i %3i %2i %1i %2i %1i %2i %4i %3i %3i %4i %4i %1i %4i",
730 volIdClus, posClus[0], posClus[1], posClus[2],
731 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
732 tracks[0], tracks[1], tracks[2],
733 det[0], det[1], det[2], det[3], det[4],
734 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
735 status, fTOFdigitMap->GetDigitIndex(vol,digIndex)));
737 AliDebug(2, Form(" %f %f %f", pos[0], pos[1], pos[2]));
738 AliDebug(2, Form(" %f %f", parTOF[0], parTOF[2]));
743 fTOFdigitMap->ResetDigit(vol, digIndex);
751 //_____________________________________________________________________________
753 void AliTOFClusterFinderV1::FindClusters34(Int_t nSector,
758 // This function searches the neighbouring digits (stored in the fDigits object),
759 // to perform clusters (stored in the fTofClusters array).
761 // This research has been made by checking the fTOFdigitMap object,
762 // filled at digits/raw-data reading time.
765 const Int_t kMaxNumberOfInterestingPads = 4;
766 const Int_t kMaxNumberOfTracksPerDigit = 3;
767 const Int_t kMaxNumberOfDigitsPerVolume = 3;
771 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
772 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
773 digitsInVolumeIndices[ii] = -1;
775 AliTOFGeometry *tofGeometry = new AliTOFGeometry();
776 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
778 Float_t pos[3] = {0.,0.,0.};
781 Int_t interestingPadX[kMaxNumberOfInterestingPads];
782 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
783 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
784 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
785 Double_t interestingTOT[kMaxNumberOfInterestingPads];
786 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
787 Double_t interestingADC[kMaxNumberOfInterestingPads];
788 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
789 Double_t interestingTOF[kMaxNumberOfInterestingPads];
790 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
791 Double_t interestingWeight[kMaxNumberOfInterestingPads];
792 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
794 Float_t interestingX[kMaxNumberOfInterestingPads];
795 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
796 Float_t interestingY[kMaxNumberOfInterestingPads];
797 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
798 Float_t interestingZ[kMaxNumberOfInterestingPads];
799 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
801 Float_t interDigit[kMaxNumberOfInterestingPads];
802 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
804 Int_t padsCluster[11];
805 padsCluster[0] = nSector;
806 padsCluster[1] = nPlate;
807 padsCluster[2] = nStrip;
808 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
810 Int_t interestingCounter=-1;
816 for (jj=0; jj<5; jj++) parTOF[jj] = 0;
818 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
820 for (jj=0; jj<5; jj++) det[jj] = -1;
822 for (jj=0; jj<3; jj++) posF[jj] = 0.;
823 UShort_t volIdClus = 0;
824 Bool_t check = kFALSE;
825 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
827 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
828 Int_t tracks[kMaxNumberOfTracksPerDigit];
829 for (jj=0; jj<3; jj++) tracks[jj] = -1;
830 Int_t dummyCounter=-1;
831 Bool_t alreadyStored = kFALSE;
833 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
834 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
835 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
837 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
838 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
840 AliTOFdigit *digitInteresting;
842 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
844 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
845 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
847 AliDebug(3, Form("%2i %1i %2i\n", iPad, iPadZ, iPadX));
854 interestingCounter=-1;
856 vol[4] = iPadZ , vol[3] = iPadX;
857 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
858 interestingCounter++;
860 vol[4] = iPadZ, vol[3] = iPadX+1;
861 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
862 interestingCounter++;
864 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
865 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
866 interestingCounter++;
868 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
869 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
870 interestingCounter++;
872 if (interestingCounter+1!=4) continue; // the hit pads have to be 4
873 else interestingCounter=-1;
876 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
877 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
878 selectedDigit[ii][jj] = 0x0;
881 vol[4] = iPadZ, vol[3] = iPadX;
883 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
884 interestingCounter++;
885 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
886 digitsInVolumeIndices[ii] = -1;
887 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
888 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
889 if (digitsInVolumeIndices[digIndex]<0) continue;
890 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
892 AliDebug(1,Form(" %2i %1i %2i %1i %2i %f %f %f %f %5i %5i %5i %5i",
893 vol[0], vol[1], vol[2] ,vol[4], vol[3],
894 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
895 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
896 digitsInVolumeIndices[digIndex],
897 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
900 selectedDigit[interestingCounter][digIndex] = new
901 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
902 digitInteresting->GetAdc(), digitInteresting->GetToT(),
903 digitInteresting->GetToT()*digitInteresting->GetToT(),
904 digitsInVolumeIndices[digIndex],
905 digitInteresting->GetTracks());
910 vol[4] = iPadZ, vol[3] = iPadX+1;
912 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
913 interestingCounter++;
914 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
915 digitsInVolumeIndices[ii] = -1;
916 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
917 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
918 if (digitsInVolumeIndices[digIndex]<0) continue;
919 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
921 AliDebug(1,Form(" %2i %1i %2i %1i %2i %f %f %f %f %5i %5i %5i %5i",
922 vol[0], vol[1], vol[2] ,vol[4], vol[3],
923 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
924 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
925 digitsInVolumeIndices[digIndex],
926 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
929 selectedDigit[interestingCounter][digIndex] = new
930 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
931 digitInteresting->GetAdc(), digitInteresting->GetToT(),
932 digitInteresting->GetToT()*digitInteresting->GetToT(),
933 digitsInVolumeIndices[digIndex],
934 digitInteresting->GetTracks());
939 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
941 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
942 interestingCounter++;
943 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
944 digitsInVolumeIndices[ii] = -1;
945 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
946 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
947 if (digitsInVolumeIndices[digIndex]<0) continue;
948 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
950 AliDebug(1,Form(" %2i %1i %2i %1i %2i %f %f %f %f %5i %5i %5i %5i",
951 vol[0], vol[1], vol[2] ,vol[4], vol[3],
952 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
953 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
954 digitsInVolumeIndices[digIndex],
955 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
958 selectedDigit[interestingCounter][digIndex] = new
959 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
960 digitInteresting->GetAdc(), digitInteresting->GetToT(),
961 digitInteresting->GetToT()*digitInteresting->GetToT(),
962 digitsInVolumeIndices[digIndex],
963 digitInteresting->GetTracks());
968 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
970 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
971 interestingCounter++;
972 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
973 digitsInVolumeIndices[ii] = -1;
974 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
975 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
976 if (digitsInVolumeIndices[digIndex]<0) continue;
977 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
979 AliDebug(1,Form(" %2i %1i %2i %1i %2i %f %f %f %f %5i %5i %5i %5i",
980 vol[0], vol[1], vol[2] ,vol[4], vol[3],
981 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
982 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
983 digitsInVolumeIndices[digIndex],
984 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
987 selectedDigit[interestingCounter][digIndex] = new
988 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
989 digitInteresting->GetAdc(), digitInteresting->GetToT(),
990 digitInteresting->GetToT()*digitInteresting->GetToT(),
991 digitsInVolumeIndices[digIndex],
992 digitInteresting->GetTracks());
996 AliDebug(1,Form(" e adesso %1i", interestingCounter+1));
998 for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
999 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
1000 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
1002 for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
1003 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
1004 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
1006 for (Int_t adesso3=adesso2+1; adesso3<interestingCounter+1; adesso3++) {
1007 for (Int_t thirdIndex=0; thirdIndex<kMaxNumberOfDigitsPerVolume; thirdIndex++) {
1008 if (selectedDigit[adesso3][thirdIndex]==0x0) continue;
1011 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime
1013 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
1015 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime) continue;
1017 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
1018 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
1019 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
1020 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
1021 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
1022 AliDebug(1,Form(" %2i %1i %2i %1i %2i", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
1023 Int_t volDum = vol1[3];
1026 tofGeometry->GetPosPar(vol1,pos);
1027 interestingX[0] = pos[0];
1028 interestingY[0] = pos[1];
1029 interestingZ[0] = pos[2];
1031 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
1032 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
1033 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
1034 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
1035 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
1036 AliDebug(1,Form(" %2i %1i %2i %1i %2i", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
1040 tofGeometry->GetPosPar(vol2,pos);
1041 interestingX[1] = pos[0];
1042 interestingY[1] = pos[1];
1043 interestingZ[1] = pos[2];
1045 interestingTOF[2] = selectedDigit[adesso3][thirdIndex]->GetTDC();
1046 interestingTOT[2] = selectedDigit[adesso3][thirdIndex]->GetTOT();
1047 interestingADC[2] = selectedDigit[adesso3][thirdIndex]->GetADC();
1048 interestingWeight[2] = selectedDigit[adesso3][thirdIndex]->GetWeight();
1049 Int_t vol3[5]; for(jj=0; jj<5; jj++) vol3[jj] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(jj);
1050 AliDebug(1,Form(" %2i %1i %2i %1i %2i", vol3[0], vol3[1], vol3[2], vol3[4], vol3[3]));
1054 tofGeometry->GetPosPar(vol3,pos);
1055 interestingX[2] = pos[0];
1056 interestingY[2] = pos[1];
1057 interestingZ[2] = pos[2];
1060 AverageCalculations(3, interestingX, interestingY, interestingZ,
1061 interestingTOF, interestingTOT, interestingADC,
1063 parTOF, posClus, check);
1066 for (jj=0; jj<5; jj++) det[jj] = -1;
1067 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
1068 tofGeometry->GetDetID(posF, det);
1070 volIdClus = GetClusterVolIndex(det);
1072 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1073 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
1074 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
1075 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
1076 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
1077 padsCluster[7] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(4);
1078 padsCluster[8] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(3);
1080 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1081 Int_t ** indDet = new Int_t*[3];
1082 for (jj=0; jj<3; jj++) indDet[jj] = new Int_t [5];
1083 for (jj=0; jj<3; jj++) indDet[jj][0] = nSector;
1084 for (jj=0; jj<3; jj++) indDet[jj][1] = nPlate;
1085 for (jj=0; jj<3; jj++) indDet[jj][2] = nStrip;
1086 for (jj=0; jj<3; jj++) indDet[jj][3] = padsCluster[2*jj+3];
1087 for (jj=0; jj<3; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
1088 GetClusterPars(check, 3, indDet, interestingWeight, posClus, covClus);
1089 for (jj=0; jj<3; jj++) delete [] indDet[jj];
1091 // To fill the track index array
1093 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1094 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1095 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
1098 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
1101 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1102 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
1105 alreadyStored = kFALSE;
1106 for (jj=0; jj<dummyCounter+1; jj++)
1107 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
1109 if (alreadyStored) continue;
1110 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
1111 AliWarning(" Siamo al limite!");
1116 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
1121 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1122 if (selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk)==-1) continue;
1125 alreadyStored = kFALSE;
1126 for (jj=0; jj<dummyCounter+1; jj++)
1127 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk));
1129 if (alreadyStored) continue;
1130 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
1131 AliWarning(" Siamo al limite!");
1136 tracks[dummyCounter] = selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk);
1143 AliTOFcluster *tofCluster =
1144 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
1145 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1146 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
1147 InsertCluster(tofCluster);
1149 AliDebug(2, Form(" %4i %f %f %f %f %f %f %f %f %f %3i %3i %3i %2i %1i %2i %1i %2i %4i %3i %3i %4i %4i %1i %4i",
1150 volIdClus, posClus[0], posClus[1], posClus[2],
1151 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1152 tracks[0], tracks[1], tracks[2],
1153 det[0], det[1], det[2], det[3], det[4],
1154 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
1155 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
1161 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
1165 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
1169 fTOFdigitMap->ResetDigitNumber(vol3,selectedDigit[adesso3][thirdIndex]->GetIndex());
1172 } // close loop on third digit
1173 } // close loop on adesso3
1175 } // close loop on second digit
1176 } // close loop on adesso2
1178 } // close loop on first digit
1179 } // close loop on adesso1
1181 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1182 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1183 selectedDigit[ii][jj] = 0x0;
1187 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1188 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
1189 delete selectedDigit[ii][jj];
1190 selectedDigit[ii][jj] = 0x0;
1195 //_____________________________________________________________________________
1197 void AliTOFClusterFinderV1::FindClusters23(Int_t nSector,
1202 // This function searches the neighbouring digits (stored in the fDigits object),
1203 // to perform clusters (stored in the fTofClusters array).
1205 // This research has been made by checking the fTOFdigitMap object,
1206 // filled at digits/raw-data reading time.
1209 const Int_t kMaxNumberOfInterestingPads = 4;
1210 const Int_t kMaxNumberOfTracksPerDigit = 3;
1211 const Int_t kMaxNumberOfDigitsPerVolume = 3;
1215 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
1216 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1217 digitsInVolumeIndices[ii] = -1;
1219 AliTOFGeometry *tofGeometry = new AliTOFGeometry();
1220 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
1222 Float_t pos[3] = {0.,0.,0.};
1225 Int_t interestingPadX[kMaxNumberOfInterestingPads];
1226 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
1227 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
1228 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
1229 Double_t interestingTOT[kMaxNumberOfInterestingPads];
1230 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
1231 Double_t interestingADC[kMaxNumberOfInterestingPads];
1232 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
1233 Double_t interestingTOF[kMaxNumberOfInterestingPads];
1234 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
1235 Double_t interestingWeight[kMaxNumberOfInterestingPads];
1236 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
1238 Float_t interestingX[kMaxNumberOfInterestingPads];
1239 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
1240 Float_t interestingY[kMaxNumberOfInterestingPads];
1241 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
1242 Float_t interestingZ[kMaxNumberOfInterestingPads];
1243 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
1245 Float_t interDigit[kMaxNumberOfInterestingPads];
1246 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
1248 Int_t padsCluster[11];
1249 padsCluster[0] = nSector;
1250 padsCluster[1] = nPlate;
1251 padsCluster[2] = nStrip;
1252 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1254 Int_t interestingCounter=-1;
1259 Bool_t check = kFALSE;
1261 for (jj=0; jj<5; jj++) parTOF[jj] = 0;
1262 Double_t posClus[3];
1263 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
1265 for (jj=0; jj<5; jj++) det[jj] = -1;
1267 for (jj=0; jj<3; jj++) posF[jj] = 0.;
1268 UShort_t volIdClus = 0;
1269 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
1270 Double_t covClus[6];
1271 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1272 Int_t tracks[kMaxNumberOfTracksPerDigit];
1273 for (jj=0; jj<3; jj++) tracks[jj] = -1;
1274 Int_t dummyCounter=-1;
1275 Bool_t alreadyStored = kFALSE;
1277 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
1278 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1279 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
1281 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1282 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
1284 AliTOFdigit *digitInteresting;
1286 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
1288 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
1289 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
1291 AliDebug(3, Form("%2i %1i %2i\n", iPad, iPadZ, iPadX));
1298 interestingCounter=-1;
1300 vol[4] = iPadZ , vol[3] = iPadX;
1301 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1302 interestingCounter++;
1304 vol[4] = iPadZ, vol[3] = iPadX+1;
1305 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1306 interestingCounter++;
1308 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1309 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1310 interestingCounter++;
1312 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1313 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1314 interestingCounter++;
1316 if (interestingCounter+1!=3) continue; // the hit pads have to be 3
1317 else interestingCounter=-1;
1320 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1321 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1322 selectedDigit[ii][jj] = 0x0;
1325 vol[4] = iPadZ, vol[3] = iPadX;
1327 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1328 interestingCounter++;
1329 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1330 digitsInVolumeIndices[ii] = -1;
1331 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1332 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1333 if (digitsInVolumeIndices[digIndex]<0) continue;
1334 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1336 AliDebug(1,Form(" %2i %1i %2i %1i %2i %f %f %f %f %5i %5i %5i %5i",
1337 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1338 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1339 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1340 digitsInVolumeIndices[digIndex],
1341 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1344 selectedDigit[interestingCounter][digIndex] = new
1345 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1346 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1347 digitInteresting->GetToT()*digitInteresting->GetToT(),
1348 digitsInVolumeIndices[digIndex],
1349 digitInteresting->GetTracks());
1354 vol[4] = iPadZ, vol[3] = iPadX+1;
1356 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1357 interestingCounter++;
1358 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1359 digitsInVolumeIndices[ii] = -1;
1360 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1361 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1362 if (digitsInVolumeIndices[digIndex]<0) continue;
1363 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1365 AliDebug(1,Form(" %2i %1i %2i %1i %2i %f %f %f %f %5i %5i %5i %5i",
1366 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1367 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1368 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1369 digitsInVolumeIndices[digIndex],
1370 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1373 selectedDigit[interestingCounter][digIndex] = new
1374 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1375 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1376 digitInteresting->GetToT()*digitInteresting->GetToT(),
1377 digitsInVolumeIndices[digIndex],
1378 digitInteresting->GetTracks());
1383 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1385 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1386 interestingCounter++;
1387 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1388 digitsInVolumeIndices[ii] = -1;
1389 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1390 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1391 if (digitsInVolumeIndices[digIndex]<0) continue;
1392 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1394 AliDebug(1,Form(" %2i %1i %2i %1i %2i %f %f %f %f %5i %5i %5i %5i",
1395 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1396 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1397 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1398 digitsInVolumeIndices[digIndex],
1399 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1402 selectedDigit[interestingCounter][digIndex] = new
1403 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1404 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1405 digitInteresting->GetToT()*digitInteresting->GetToT(),
1406 digitsInVolumeIndices[digIndex],
1407 digitInteresting->GetTracks());
1412 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1414 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1415 interestingCounter++;
1416 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1417 digitsInVolumeIndices[ii] = -1;
1418 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1419 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1420 if (digitsInVolumeIndices[digIndex]<0) continue;
1421 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1423 AliDebug(1,Form(" %2i %1i %2i %1i %2i %f %f %f %f %5i %5i %5i %5i",
1424 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1425 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1426 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1427 digitsInVolumeIndices[digIndex],
1428 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1431 selectedDigit[interestingCounter][digIndex] = new
1432 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1433 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1434 digitInteresting->GetToT()*digitInteresting->GetToT(),
1435 digitsInVolumeIndices[digIndex],
1436 digitInteresting->GetTracks());
1440 AliDebug(1,Form(" e adesso %1i", interestingCounter+1));
1442 for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
1443 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
1444 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
1446 for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
1447 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
1448 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
1450 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime) continue;
1452 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
1453 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
1454 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
1455 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
1456 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
1457 AliDebug(1,Form(" %2i %1i %2i %1i %2i", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
1458 Int_t volDum = vol1[3];
1461 tofGeometry->GetPosPar(vol1,pos);
1462 interestingX[0] = pos[0];
1463 interestingY[0] = pos[1];
1464 interestingZ[0] = pos[2];
1466 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
1467 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
1468 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
1469 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
1470 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
1471 AliDebug(1,Form(" %2i %1i %2i %1i %2i", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
1475 tofGeometry->GetPosPar(vol2,pos);
1476 interestingX[1] = pos[0];
1477 interestingY[1] = pos[1];
1478 interestingZ[1] = pos[2];
1480 AverageCalculations(2, interestingX, interestingY, interestingZ,
1481 interestingTOF, interestingTOT, interestingADC,
1483 parTOF, posClus, check);
1485 for (jj=0; jj<5; jj++) det[jj] = -1;
1486 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
1487 tofGeometry->GetDetID(posF, det);
1489 volIdClus = GetClusterVolIndex(det);
1491 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1492 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
1493 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
1494 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
1495 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
1497 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1498 Int_t ** indDet = new Int_t*[2];
1499 for (jj=0; jj<2; jj++) indDet[jj] = new Int_t [5];
1500 for (jj=0; jj<2; jj++) indDet[jj][0] = nSector;
1501 for (jj=0; jj<2; jj++) indDet[jj][1] = nPlate;
1502 for (jj=0; jj<2; jj++) indDet[jj][2] = nStrip;
1503 for (jj=0; jj<2; jj++) indDet[jj][3] = padsCluster[2*jj+3];
1504 for (jj=0; jj<2; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
1505 GetClusterPars(check, 2, indDet, interestingWeight, posClus, covClus);
1506 for (jj=0; jj<2; jj++) delete [] indDet[jj];
1508 // To fill the track index array
1510 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1511 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1512 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
1515 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
1518 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1519 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
1522 alreadyStored = kFALSE;
1523 for (jj=0; jj<dummyCounter+1; jj++)
1524 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
1526 if (alreadyStored) continue;
1527 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
1528 AliWarning(" Siamo al limite!");
1533 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
1540 AliTOFcluster *tofCluster =
1541 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
1542 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1543 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
1544 InsertCluster(tofCluster);
1546 AliDebug(2, Form(" %4i %f %f %f %f %f %f %f %f %f %3i %3i %3i %2i %1i %2i %1i %2i %4i %3i %3i %4i %4i %1i %4i",
1547 volIdClus, posClus[0], posClus[1], posClus[2],
1548 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1549 tracks[0], tracks[1], tracks[2],
1550 det[0], det[1], det[2], det[3], det[4],
1551 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
1552 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
1557 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
1561 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
1564 } // close loop on second digit
1565 } // close loop on adesso2
1567 } // close loop on first digit
1568 } // close loop on adesso1
1570 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1571 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1572 selectedDigit[ii][jj] = 0x0;
1576 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1577 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
1578 delete selectedDigit[ii][jj];
1579 selectedDigit[ii][jj] = 0x0;
1584 //_____________________________________________________________________________
1586 void AliTOFClusterFinderV1::FindClusters24(Int_t nSector,
1591 // This function searches the neighbouring digits (stored in the fDigits object),
1592 // to perform clusters (stored in the fTofClusters array).
1594 // This research has been made by checking the fTOFdigitMap object,
1595 // filled at digits/raw-data reading time.
1598 const Int_t kMaxNumberOfInterestingPads = 4;
1599 const Int_t kMaxNumberOfTracksPerDigit = 3;
1600 const Int_t kMaxNumberOfDigitsPerVolume = 3;
1604 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
1605 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1606 digitsInVolumeIndices[ii] = -1;
1608 AliTOFGeometry *tofGeometry = new AliTOFGeometry();
1609 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
1611 Float_t pos[3] = {0.,0.,0.};
1614 Int_t interestingPadX[kMaxNumberOfInterestingPads];
1615 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
1616 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
1617 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
1618 Double_t interestingTOT[kMaxNumberOfInterestingPads];
1619 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
1620 Double_t interestingADC[kMaxNumberOfInterestingPads];
1621 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
1622 Double_t interestingTOF[kMaxNumberOfInterestingPads];
1623 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
1624 Double_t interestingWeight[kMaxNumberOfInterestingPads];
1625 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
1627 Float_t interestingX[kMaxNumberOfInterestingPads];
1628 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
1629 Float_t interestingY[kMaxNumberOfInterestingPads];
1630 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
1631 Float_t interestingZ[kMaxNumberOfInterestingPads];
1632 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
1634 Float_t interDigit[kMaxNumberOfInterestingPads];
1635 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
1637 Int_t padsCluster[11];
1638 padsCluster[0] = nSector;
1639 padsCluster[1] = nPlate;
1640 padsCluster[2] = nStrip;
1641 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1643 Int_t interestingCounter=-1;
1648 Bool_t check = kFALSE;
1650 for (jj=0; jj<5; jj++) parTOF[jj] = 0;
1651 Double_t posClus[3];
1652 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
1654 for (jj=0; jj<5; jj++) det[jj] = -1;
1656 for (jj=0; jj<3; jj++) posF[jj] = 0.;
1657 UShort_t volIdClus = 0;
1658 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
1659 Double_t covClus[6];
1660 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1661 Int_t tracks[kMaxNumberOfTracksPerDigit];
1662 for (jj=0; jj<3; jj++) tracks[jj] = -1;
1663 Int_t dummyCounter=-1;
1664 Bool_t alreadyStored = kFALSE;
1666 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
1667 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1668 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
1670 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1671 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
1673 AliTOFdigit *digitInteresting;
1675 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
1677 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
1678 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
1680 AliDebug(3, Form("%2i %1i %2i\n", iPad, iPadZ, iPadX));
1687 interestingCounter=-1;
1689 vol[4] = iPadZ , vol[3] = iPadX;
1690 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1691 interestingCounter++;
1693 vol[4] = iPadZ, vol[3] = iPadX+1;
1694 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1695 interestingCounter++;
1697 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1698 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1699 interestingCounter++;
1701 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1702 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1703 interestingCounter++;
1705 if (interestingCounter+1!=4) continue; // the hit pads have to be 4
1706 else interestingCounter=-1;
1709 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1710 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1711 selectedDigit[ii][jj] = 0x0;
1714 vol[4] = iPadZ, vol[3] = iPadX;
1716 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1717 interestingCounter++;
1718 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1719 digitsInVolumeIndices[ii] = -1;
1720 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1721 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1722 if (digitsInVolumeIndices[digIndex]<0) continue;
1723 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1725 AliDebug(1,Form(" %2i %1i %2i %1i %2i %f %f %f %f %5i %5i %5i %5i",
1726 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1727 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1728 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1729 digitsInVolumeIndices[digIndex],
1730 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1733 selectedDigit[interestingCounter][digIndex] = new
1734 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1735 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1736 digitInteresting->GetToT()*digitInteresting->GetToT(),
1737 digitsInVolumeIndices[digIndex],
1738 digitInteresting->GetTracks());
1743 vol[4] = iPadZ, vol[3] = iPadX+1;
1745 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1746 interestingCounter++;
1747 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1748 digitsInVolumeIndices[ii] = -1;
1749 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1750 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1751 if (digitsInVolumeIndices[digIndex]<0) continue;
1752 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1754 AliDebug(1,Form(" %2i %1i %2i %1i %2i %f %f %f %f %5i %5i %5i %5i",
1755 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1756 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1757 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1758 digitsInVolumeIndices[digIndex],
1759 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1762 selectedDigit[interestingCounter][digIndex] = new
1763 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1764 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1765 digitInteresting->GetToT()*digitInteresting->GetToT(),
1766 digitsInVolumeIndices[digIndex],
1767 digitInteresting->GetTracks());
1772 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1774 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1775 interestingCounter++;
1776 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1777 digitsInVolumeIndices[ii] = -1;
1778 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1779 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1780 if (digitsInVolumeIndices[digIndex]<0) continue;
1781 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1783 AliDebug(1,Form(" %2i %1i %2i %1i %2i %f %f %f %f %5i %5i %5i %5i",
1784 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1785 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1786 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1787 digitsInVolumeIndices[digIndex],
1788 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1791 selectedDigit[interestingCounter][digIndex] = new
1792 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1793 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1794 digitInteresting->GetToT()*digitInteresting->GetToT(),
1795 digitsInVolumeIndices[digIndex],
1796 digitInteresting->GetTracks());
1801 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1803 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1804 interestingCounter++;
1805 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1806 digitsInVolumeIndices[ii] = -1;
1807 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1808 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1809 if (digitsInVolumeIndices[digIndex]<0) continue;
1810 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1812 AliDebug(1,Form(" %2i %1i %2i %1i %2i %f %f %f %f %5i %5i %5i %5i",
1813 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1814 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1815 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1816 digitsInVolumeIndices[digIndex],
1817 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1820 selectedDigit[interestingCounter][digIndex] = new
1821 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1822 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1823 digitInteresting->GetToT()*digitInteresting->GetToT(),
1824 digitsInVolumeIndices[digIndex],
1825 digitInteresting->GetTracks());
1829 AliDebug(1,Form(" e adesso %1i", interestingCounter+1));
1831 for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
1832 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
1833 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
1835 for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
1836 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
1837 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
1839 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime) continue;
1841 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
1842 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
1843 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
1844 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
1845 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
1846 AliDebug(1,Form(" %2i %1i %2i %1i %2i", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
1847 Int_t volDum = vol1[3];
1850 tofGeometry->GetPosPar(vol1,pos);
1851 interestingX[0] = pos[0];
1852 interestingY[0] = pos[1];
1853 interestingZ[0] = pos[2];
1855 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
1856 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
1857 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
1858 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
1859 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
1860 AliDebug(1,Form(" %2i %1i %2i %1i %2i", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
1864 tofGeometry->GetPosPar(vol2,pos);
1865 interestingX[1] = pos[0];
1866 interestingY[1] = pos[1];
1867 interestingZ[1] = pos[2];
1870 AverageCalculations(2, interestingX, interestingY, interestingZ,
1871 interestingTOF, interestingTOT, interestingADC,
1873 parTOF, posClus, check);
1875 for (jj=0; jj<5; jj++) det[jj] = -1;
1876 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
1877 tofGeometry->GetDetID(posF, det);
1879 volIdClus = GetClusterVolIndex(det);
1881 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1882 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
1883 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
1884 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
1885 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
1887 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1888 Int_t ** indDet = new Int_t*[2];
1889 for (jj=0; jj<2; jj++) indDet[jj] = new Int_t [5];
1890 for (jj=0; jj<2; jj++) indDet[jj][0] = nSector;
1891 for (jj=0; jj<2; jj++) indDet[jj][1] = nPlate;
1892 for (jj=0; jj<2; jj++) indDet[jj][2] = nStrip;
1893 for (jj=0; jj<2; jj++) indDet[jj][3] = padsCluster[2*jj+3];
1894 for (jj=0; jj<2; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
1895 GetClusterPars(check, 2, indDet, interestingWeight, posClus, covClus);
1896 for (jj=0; jj<2; jj++) delete [] indDet[jj];
1898 // To fill the track index array
1900 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1901 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1902 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
1905 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
1908 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1909 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
1912 alreadyStored = kFALSE;
1913 for (jj=0; jj<dummyCounter+1; jj++)
1914 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
1916 if (alreadyStored) continue;
1917 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
1918 AliWarning(" Siamo al limite!");
1923 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
1930 AliTOFcluster *tofCluster =
1931 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
1932 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1933 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
1934 InsertCluster(tofCluster);
1936 AliDebug(2, Form(" %4i %f %f %f %f %f %f %f %f %f %3i %3i %3i %2i %1i %2i %1i %2i %4i %3i %3i %4i %4i %1i %4i",
1937 volIdClus, posClus[0], posClus[1], posClus[2],
1938 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1939 tracks[0], tracks[1], tracks[2],
1940 det[0], det[1], det[2], det[3], det[4],
1941 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
1942 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
1947 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
1951 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
1954 } // close loop on second digit
1955 } // close loop on adesso2
1957 } // close loop on first digit
1958 } // close loop on adesso1
1960 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1961 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1962 selectedDigit[ii][jj] = 0x0;
1966 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1967 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
1968 delete selectedDigit[ii][jj];
1969 selectedDigit[ii][jj] = 0x0;
1974 //_____________________________________________________________________________
1976 void AliTOFClusterFinderV1::FindClustersPerStrip(Int_t nSector,
1982 // This function searches the neighbouring digits (stored in the fDigits object),
1983 // to perform clusters (stored in the fTofClusters array).
1985 // Each strip is read four times:
1986 // - 1st time: it searches possible clusters formed by four
1987 // neighbouring digits;
1988 // - 2nd time: it searches possible clusters formed by three
1989 // neighbouring digits;
1990 // - 3rd time: it searches possible clusters formed by two
1991 // neighbouring digits;
1992 // - 4th time: the remaining isolated digits have been transformed
1994 // This research has been made by checking the fTOFdigitMap object,
1995 // filled at digits/raw-data reading time.
1998 const Int_t kMaxNumberOfInterestingPads = 4;
1999 const Int_t kMaxNumberOfTracksPerDigit = 3;
2000 const Int_t kMaxNumberOfDigitsPerVolume = 3;
2004 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
2005 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2006 digitsInVolumeIndices[ii] = -1;
2008 AliTOFGeometry *tofGeometry = new AliTOFGeometry();
2010 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
2012 Float_t pos[3] = {0.,0.,0.};
2015 Int_t interestingPadX[kMaxNumberOfInterestingPads];
2016 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
2017 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
2018 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
2019 Double_t interestingTOT[kMaxNumberOfInterestingPads];
2020 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
2021 Double_t interestingADC[kMaxNumberOfInterestingPads];
2022 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
2023 Double_t interestingTOF[kMaxNumberOfInterestingPads];
2024 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
2025 Double_t interestingWeight[kMaxNumberOfInterestingPads];
2026 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
2028 Float_t interestingX[kMaxNumberOfInterestingPads];
2029 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
2030 Float_t interestingY[kMaxNumberOfInterestingPads];
2031 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
2032 Float_t interestingZ[kMaxNumberOfInterestingPads];
2033 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
2035 Float_t interDigit[kMaxNumberOfInterestingPads];
2036 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
2038 Int_t padsCluster[11];
2039 padsCluster[0] = nSector;
2040 padsCluster[1] = nPlate;
2041 padsCluster[2] = nStrip;
2042 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2044 Int_t interestingCounter=-1;
2049 Bool_t check = kFALSE;
2051 for (jj=0; jj<5; jj++) parTOF[jj] = 0;
2052 Double_t posClus[3];
2053 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
2055 for (jj=0; jj<5; jj++) det[jj] = -1;
2057 for (jj=0; jj<3; jj++) posF[jj] = 0.;
2058 UShort_t volIdClus = 0;
2059 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
2060 Double_t covClus[6];
2061 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2062 Int_t tracks[kMaxNumberOfTracksPerDigit];
2063 for (jj=0; jj<3; jj++) tracks[jj] = -1;
2064 Int_t dummyCounter=-1;
2065 Bool_t alreadyStored = kFALSE;
2067 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
2068 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2069 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
2071 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2072 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
2074 AliTOFdigit *digitInteresting;
2078 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
2080 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
2081 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
2083 AliDebug(3, Form("%2i %1i %2i\n", iPad, iPadZ, iPadX));
2090 interestingCounter=-1;
2092 vol[4] = iPadZ , vol[3] = iPadX;
2093 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2094 interestingCounter++;
2096 vol[4] = iPadZ, vol[3] = iPadX+1;
2097 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2098 interestingCounter++;
2100 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
2101 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2102 interestingCounter++;
2104 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
2105 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2106 interestingCounter++;
2108 if (interestingCounter!=group) continue;
2109 else interestingCounter=-1;
2112 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2113 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
2114 selectedDigit[ii][jj] = 0x0;
2117 vol[4] = iPadZ, vol[3] = iPadX;
2119 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2120 interestingCounter++;
2121 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2122 digitsInVolumeIndices[ii] = -1;
2123 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2124 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2125 if (digitsInVolumeIndices[digIndex]<0) continue;
2126 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2128 AliDebug(1,Form(" %2i %1i %2i %1i %2i %f %f %f %f %5i %5i %5i %5i",
2129 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2130 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2131 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2132 digitsInVolumeIndices[digIndex],
2133 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2136 selectedDigit[interestingCounter][digIndex] = new
2137 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2138 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2139 digitInteresting->GetToT()*digitInteresting->GetToT(),
2140 digitsInVolumeIndices[digIndex],
2141 digitInteresting->GetTracks());
2146 vol[4] = iPadZ, vol[3] = iPadX+1;
2148 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2149 interestingCounter++;
2150 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2151 digitsInVolumeIndices[ii] = -1;
2152 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2153 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2154 if (digitsInVolumeIndices[digIndex]<0) continue;
2155 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2157 AliDebug(1,Form(" %2i %1i %2i %1i %2i %f %f %f %f %5i %5i %5i %5i",
2158 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2159 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2160 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2161 digitsInVolumeIndices[digIndex],
2162 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2165 selectedDigit[interestingCounter][digIndex] = new
2166 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2167 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2168 digitInteresting->GetToT()*digitInteresting->GetToT(),
2169 digitsInVolumeIndices[digIndex],
2170 digitInteresting->GetTracks());
2175 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
2177 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2178 interestingCounter++;
2179 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2180 digitsInVolumeIndices[ii] = -1;
2181 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2182 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2183 if (digitsInVolumeIndices[digIndex]<0) continue;
2184 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2186 AliDebug(1,Form(" %2i %1i %2i %1i %2i %f %f %f %f %5i %5i %5i %5i",
2187 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2188 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2189 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2190 digitsInVolumeIndices[digIndex],
2191 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2194 selectedDigit[interestingCounter][digIndex] = new
2195 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2196 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2197 digitInteresting->GetToT()*digitInteresting->GetToT(),
2198 digitsInVolumeIndices[digIndex],
2199 digitInteresting->GetTracks());
2204 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
2206 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2207 interestingCounter++;
2208 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2209 digitsInVolumeIndices[ii] = -1;
2210 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2211 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2212 if (digitsInVolumeIndices[digIndex]<0) continue;
2213 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2215 AliDebug(1,Form(" %2i %1i %2i %1i %2i %f %f %f %f %5i %5i %5i %5i",
2216 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2217 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2218 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2219 digitsInVolumeIndices[digIndex],
2220 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2223 selectedDigit[interestingCounter][digIndex] = new
2224 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2225 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2226 digitInteresting->GetToT()*digitInteresting->GetToT(),
2227 digitsInVolumeIndices[digIndex],
2228 digitInteresting->GetTracks());
2232 AliDebug(1,Form(" e adesso %1i", interestingCounter+1));
2234 switch(interestingCounter+1) {
2238 for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
2239 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2240 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2242 for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
2243 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2244 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2246 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime) continue;
2248 AliDebug(1, Form(" %1i %1i (0x%x) %1i %1i (0x%x)", adesso1, firstIndex,selectedDigit[adesso1][firstIndex],
2249 adesso2, secondIndex,selectedDigit[adesso2][secondIndex]));
2251 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2252 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2253 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2254 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2255 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
2256 AliDebug(1,Form(" %2i %1i %2i %1i %2i", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
2257 Int_t volDum = vol1[3];
2260 tofGeometry->GetPosPar(vol1,pos);
2261 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
2262 interestingX[0] = pos[0];
2263 interestingY[0] = pos[1];
2264 interestingZ[0] = pos[2];
2266 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2267 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2268 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2269 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2270 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
2271 AliDebug(1,Form(" %2i %1i %2i %1i %2i", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
2275 tofGeometry->GetPosPar(vol2,pos);
2276 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
2277 interestingX[1] = pos[0];
2278 interestingY[1] = pos[1];
2279 interestingZ[1] = pos[2];
2282 AverageCalculations(interestingCounter+1,
2283 interestingX, interestingY, interestingZ,
2284 interestingTOF, interestingTOT, interestingADC,
2286 parTOF, posClus, check);
2288 for (jj=0; jj<5; jj++) det[jj] = -1;
2289 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
2291 AliDebug(1,Form(" %f %f %f", posF[0], posF[1], posF[2]));
2292 tofGeometry->GetDetID(posF, det);
2293 AliDebug(1,Form(" %2i %1i %2i %1i %2i", det[0], det[1], det[2], det[3], det[4]));
2295 volIdClus = GetClusterVolIndex(det);
2297 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2298 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
2299 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
2300 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
2301 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
2303 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2304 Int_t ** indDet = new Int_t*[interestingCounter+1];
2305 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj] = new Int_t [5];
2306 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][0] = nSector;
2307 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][1] = nPlate;
2308 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][2] = nStrip;
2309 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][3] = padsCluster[2*jj+3];
2310 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
2311 GetClusterPars(check, interestingCounter+1, indDet, interestingWeight, posClus, covClus);
2312 for (jj=0; jj<interestingCounter+1; jj++) delete [] indDet[jj];
2314 // To fill the track index array
2316 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2317 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2318 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
2321 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
2324 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2325 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
2328 alreadyStored = kFALSE;
2329 for (jj=0; jj<dummyCounter+1; jj++)
2330 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
2332 if (alreadyStored) continue;
2333 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2334 AliWarning(" Siamo al limite!");
2339 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
2346 AliTOFcluster *tofCluster =
2347 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
2348 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2349 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); //to updated
2350 InsertCluster(tofCluster);
2352 AliDebug(2, Form(" %4i %f %f %f %f %f %f %f %f %f %3i %3i %3i %2i %1i %2i %1i %2i %4i %3i %3i %4i %4i %1i %4i",
2353 volIdClus, posClus[0], posClus[1], posClus[2],
2354 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2355 tracks[0], tracks[1], tracks[2],
2356 det[0], det[1], det[2], det[3], det[4],
2357 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
2358 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
2363 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
2367 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
2370 } // close loop on second digit
2371 } // close loop on adesso2
2373 } // close loop on first digit
2374 } // close loop on adesso1
2381 for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
2382 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2383 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2385 for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
2386 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2387 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2389 for (Int_t adesso3=adesso2+1; adesso3<interestingCounter+1; adesso3++) {
2390 for (Int_t thirdIndex=0; thirdIndex<kMaxNumberOfDigitsPerVolume; thirdIndex++) {
2391 if (selectedDigit[adesso3][thirdIndex]==0x0) continue;
2394 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime
2396 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
2398 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime) continue;
2400 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2401 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2402 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2403 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2404 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
2405 AliDebug(1,Form(" %2i %1i %2i %1i %2i", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
2406 Int_t volDum = vol1[3];
2409 tofGeometry->GetPosPar(vol1,pos);
2410 interestingX[0] = pos[0];
2411 interestingY[0] = pos[1];
2412 interestingZ[0] = pos[2];
2414 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2415 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2416 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2417 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2418 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
2419 AliDebug(1,Form(" %2i %1i %2i %1i %2i", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
2423 tofGeometry->GetPosPar(vol2,pos);
2424 interestingX[1] = pos[0];
2425 interestingY[1] = pos[1];
2426 interestingZ[1] = pos[2];
2428 interestingTOF[2] = selectedDigit[adesso3][thirdIndex]->GetTDC();
2429 interestingTOT[2] = selectedDigit[adesso3][thirdIndex]->GetTOT();
2430 interestingADC[2] = selectedDigit[adesso3][thirdIndex]->GetADC();
2431 interestingWeight[2] = selectedDigit[adesso3][thirdIndex]->GetWeight();
2432 Int_t vol3[5]; for(jj=0; jj<5; jj++) vol3[jj] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(jj);
2433 AliDebug(1,Form(" %2i %1i %2i %1i %2i", vol3[0], vol3[1], vol3[2], vol3[4], vol3[3]));
2437 tofGeometry->GetPosPar(vol3,pos);
2438 interestingX[2] = pos[0];
2439 interestingY[2] = pos[1];
2440 interestingZ[2] = pos[2];
2443 AverageCalculations(interestingCounter+1,
2444 interestingX, interestingY, interestingZ,
2445 interestingTOF, interestingTOT, interestingADC,
2447 parTOF, posClus, check);
2449 for (jj=0; jj<5; jj++) det[jj] = -1;
2450 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
2451 tofGeometry->GetDetID(posF, det);
2453 volIdClus = GetClusterVolIndex(det);
2455 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2456 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
2457 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
2458 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
2459 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
2460 padsCluster[7] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(4);
2461 padsCluster[8] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(3);
2463 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2464 Int_t ** indDet = new Int_t*[interestingCounter+1];
2465 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj] = new Int_t [5];
2466 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][0] = nSector;
2467 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][1] = nPlate;
2468 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][2] = nStrip;
2469 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][3] = padsCluster[2*jj+3];
2470 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
2471 GetClusterPars(check, interestingCounter+1, indDet, interestingWeight, posClus, covClus);
2472 for (jj=0; jj<interestingCounter+1; jj++) delete [] indDet[jj];
2474 // To fill the track index array
2476 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2477 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2478 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
2481 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
2484 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2485 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
2488 alreadyStored = kFALSE;
2489 for (jj=0; jj<dummyCounter+1; jj++)
2490 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
2492 if (alreadyStored) continue;
2493 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2494 AliWarning(" Siamo al limite!");
2499 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
2504 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2505 if (selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk)==-1) continue;
2508 alreadyStored = kFALSE;
2509 for (jj=0; jj<dummyCounter+1; jj++)
2510 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk));
2512 if (alreadyStored) continue;
2513 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2514 AliWarning(" Siamo al limite!");
2519 tracks[dummyCounter] = selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk);
2526 AliTOFcluster *tofCluster =
2527 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
2528 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2529 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
2530 InsertCluster(tofCluster);
2532 AliDebug(2, Form(" %4i %f %f %f %f %f %f %f %f %f %3i %3i %3i %2i %1i %2i %1i %2i %4i %3i %3i %4i %4i %1i %4i",
2533 volIdClus, posClus[0], posClus[1], posClus[2],
2534 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2535 tracks[0], tracks[1], tracks[2],
2536 det[0], det[1], det[2], det[3], det[4],
2537 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
2538 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
2543 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
2547 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
2551 fTOFdigitMap->ResetDigitNumber(vol3,selectedDigit[adesso3][thirdIndex]->GetIndex());
2554 } // close loop on third digit
2555 } // close loop on adesso3
2557 } // close loop on second digit
2558 } // close loop on adesso2
2560 } // close loop on first digit
2561 } // close loop on adesso1
2569 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2570 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2573 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2574 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2577 for (Int_t thirdIndex=0; thirdIndex<kMaxNumberOfDigitsPerVolume; thirdIndex++) {
2578 if (selectedDigit[adesso3][thirdIndex]==0x0) continue;
2581 for (Int_t fourthIndex=0; fourthIndex<kMaxNumberOfDigitsPerVolume; fourthIndex++) {
2582 if (selectedDigit[adesso4][fourthIndex]==0x0) continue;
2585 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime
2587 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
2589 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso4][fourthIndex]->GetTDC())>fMaxDeltaTime
2591 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
2593 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso4][fourthIndex]->GetTDC())>fMaxDeltaTime
2595 TMath::Abs(selectedDigit[adesso3][thirdIndex]->GetTDC()-selectedDigit[adesso4][fourthIndex]->GetTDC())>fMaxDeltaTime) continue;
2597 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2598 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2599 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2600 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2601 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
2602 AliDebug(1,Form(" %2i %1i %2i %1i %2i", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
2603 Int_t volDum = vol1[3];
2606 tofGeometry->GetPosPar(vol1,pos);
2607 interestingX[0] = pos[0];
2608 interestingY[0] = pos[1];
2609 interestingZ[0] = pos[2];
2611 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2612 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2613 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2614 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2615 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
2616 AliDebug(1,Form(" %2i %1i %2i %1i %2i", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
2620 tofGeometry->GetPosPar(vol2,pos);
2621 interestingX[1] = pos[0];
2622 interestingY[1] = pos[1];
2623 interestingZ[1] = pos[2];
2625 interestingTOF[2] = selectedDigit[adesso3][thirdIndex]->GetTDC();
2626 interestingTOT[2] = selectedDigit[adesso3][thirdIndex]->GetTOT();
2627 interestingADC[2] = selectedDigit[adesso3][thirdIndex]->GetADC();
2628 interestingWeight[2] = selectedDigit[adesso3][thirdIndex]->GetWeight();
2629 Int_t vol3[5]; for(jj=0; jj<5; jj++) vol3[jj] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(jj);
2630 AliDebug(1,Form(" %2i %1i %2i %1i %2i", vol3[0], vol3[1], vol3[2], vol3[4], vol3[3]));
2634 tofGeometry->GetPosPar(vol3,pos);
2635 interestingX[2] = pos[0];
2636 interestingY[2] = pos[1];
2637 interestingZ[2] = pos[2];
2639 interestingTOF[3] = selectedDigit[adesso4][fourthIndex]->GetTDC();
2640 interestingTOT[3] = selectedDigit[adesso4][fourthIndex]->GetTOT();
2641 interestingADC[3] = selectedDigit[adesso4][fourthIndex]->GetADC();
2642 interestingWeight[3] = selectedDigit[adesso4][fourthIndex]->GetWeight();
2643 Int_t vol4[5]; for(jj=0; jj<5; jj++) vol4[jj] = selectedDigit[adesso4][fourthIndex]->GetDetectorIndex(jj);
2644 AliDebug(1,Form(" %2i %1i %2i %1i %2i", vol4[0], vol4[1], vol4[2], vol4[4], vol4[3]));
2648 tofGeometry->GetPosPar(vol4,pos);
2649 interestingX[3] = pos[0];
2650 interestingY[3] = pos[1];
2651 interestingZ[3] = pos[2];
2654 AverageCalculations(interestingCounter+1,
2655 interestingX, interestingY, interestingZ,
2656 interestingTOF, interestingTOT, interestingADC,
2658 parTOF, posClus, check);
2660 for (jj=0; jj<5; jj++) det[jj] = -1;
2661 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
2662 tofGeometry->GetDetID(posF, det);
2664 volIdClus = GetClusterVolIndex(det);
2666 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2667 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
2668 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
2669 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
2670 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
2671 padsCluster[7] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(4);
2672 padsCluster[8] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(3);
2673 padsCluster[9] = selectedDigit[adesso4][fourthIndex]->GetDetectorIndex(4);
2674 padsCluster[10] = selectedDigit[adesso4][fourthIndex]->GetDetectorIndex(3);
2676 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2677 Int_t ** indDet = new Int_t*[interestingCounter+1];
2678 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj] = new Int_t [5];
2679 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][0] = nSector;
2680 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][1] = nPlate;
2681 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][2] = nStrip;
2682 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][3] = padsCluster[2*jj+3];
2683 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
2684 GetClusterPars(check, interestingCounter+1, indDet, interestingWeight, posClus, covClus);
2685 for (jj=0; jj<interestingCounter+1; jj++) delete [] indDet[jj];
2687 // To fill the track index array
2689 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2690 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2691 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
2694 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
2697 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2698 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
2701 alreadyStored = kFALSE;
2702 for (jj=0; jj<dummyCounter+1; jj++)
2703 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
2705 if (alreadyStored) continue;
2706 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2707 AliWarning(" Siamo al limite!");
2712 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
2717 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2718 if (selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk)==-1) continue;
2721 alreadyStored = kFALSE;
2722 for (jj=0; jj<dummyCounter+1; jj++)
2723 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk));
2725 if (alreadyStored) continue;
2726 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2727 AliWarning(" Siamo al limite!");
2732 tracks[dummyCounter] = selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk);
2737 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2738 if (selectedDigit[adesso4][fourthIndex]->GetTrackLabel(kk)==-1) continue;
2741 alreadyStored = kFALSE;
2742 for (jj=0; jj<dummyCounter+1; jj++)
2743 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso4][fourthIndex]->GetTrackLabel(kk));
2745 if (alreadyStored) continue;
2746 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2747 AliWarning(" Siamo al limite!");
2752 tracks[dummyCounter] = selectedDigit[adesso4][fourthIndex]->GetTrackLabel(kk);
2759 AliTOFcluster *tofCluster =
2760 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
2761 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2762 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
2763 InsertCluster(tofCluster);
2765 AliDebug(2, Form(" %4i %f %f %f %f %f %f %f %f %f %3i %3i %3i %2i %1i %2i %1i %2i %4i %3i %3i %4i %4i %1i %4i",
2766 volIdClus, posClus[0], posClus[1], posClus[2],
2767 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2768 tracks[0], tracks[1], tracks[2],
2769 det[0], det[1], det[2], det[3], det[4],
2770 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
2771 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
2776 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
2780 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
2784 fTOFdigitMap->ResetDigitNumber(vol3,selectedDigit[adesso3][thirdIndex]->GetIndex());
2788 fTOFdigitMap->ResetDigitNumber(vol4,selectedDigit[adesso4][fourthIndex]->GetIndex());
2791 } // close loop on fourth digit
2793 } // close loop on third digit
2795 } // close loop on second digit
2797 } // close loop on first digit
2803 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2804 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
2805 selectedDigit[ii][jj] = 0x0;
2809 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2810 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
2811 delete selectedDigit[ii][jj];
2812 selectedDigit[ii][jj] = 0x0;
2816 //_____________________________________________________________________________
2818 Int_t AliTOFClusterFinderV1::InsertCluster(AliTOFcluster *tofCluster)
2821 // This function adds a TOF cluster to the array of TOF clusters
2822 // sorted in Z, i.e. fTofClusters
2825 if (fNumberOfTofClusters==kTofMaxCluster) {
2826 AliError("Too many clusters !");
2830 if (fNumberOfTofClusters==0) {
2831 fTofClusters[fNumberOfTofClusters++] = tofCluster;
2835 Int_t ii = FindClusterIndex(tofCluster->GetZ());
2836 memmove(fTofClusters+ii+1 ,fTofClusters+ii,(fNumberOfTofClusters-ii)*sizeof(AliTOFcluster*));
2837 fTofClusters[ii] = tofCluster;
2838 fNumberOfTofClusters++;
2843 //_____________________________________________________________________________
2845 Int_t AliTOFClusterFinderV1::FindClusterIndex(Double_t z) const
2848 // This function returns the index of the nearest cluster in z
2851 if (fNumberOfTofClusters==0) return 0;
2852 if (z <= fTofClusters[0]->GetZ()) return 0;
2853 if (z > fTofClusters[fNumberOfTofClusters-1]->GetZ()) return fNumberOfTofClusters;
2854 Int_t b = 0, e = fNumberOfTofClusters-1, m = (b+e)/2;
2855 for (; b<e; m=(b+e)/2) {
2856 if (z > fTofClusters[m]->GetZ()) b=m+1;
2863 //_____________________________________________________________________________
2865 void AliTOFClusterFinderV1::ResetRecpoint()
2868 // Clear the list of reconstructed points
2871 fNumberOfTofClusters = 0;
2872 if (fRecPoints) fRecPoints->Clear();
2875 //_____________________________________________________________________________
2877 void AliTOFClusterFinderV1::ResetDigits()
2880 // Clear the list of digits
2883 fNumberOfTofDigits = 0;
2884 if (fDigits) fDigits->Clear();
2887 //_____________________________________________________________________________
2889 UShort_t AliTOFClusterFinderV1::GetClusterVolIndex(Int_t *ind) const
2892 // Get the volume ID to retrieve the l2t transformation
2895 // Detector numbering scheme
2896 Int_t nSector = AliTOFGeometry::NSectors();
2897 Int_t nPlate = AliTOFGeometry::NPlates();
2898 Int_t nStripA = AliTOFGeometry::NStripA();
2899 Int_t nStripB = AliTOFGeometry::NStripB();
2900 Int_t nStripC = AliTOFGeometry::NStripC();
2902 Int_t isector =ind[0];
2903 if (isector >= nSector)
2904 AliError(Form("Wrong sector number in TOF (%d) !", isector));
2905 Int_t iplate = ind[1];
2906 if (iplate >= nPlate)
2907 AliError(Form("Wrong plate number in TOF (%d) !", iplate));
2908 Int_t istrip = ind[2];
2910 Int_t stripOffset = 0;
2916 stripOffset = nStripC;
2919 stripOffset = nStripC+nStripB;
2922 stripOffset = nStripC+nStripB+nStripA;
2925 stripOffset = nStripC+nStripB+nStripA+nStripB;
2928 AliError(Form("Wrong plate number in TOF (%d) !", iplate));
2932 Int_t index= (2*(nStripC+nStripB)+nStripA)*isector +
2936 UShort_t volIndex = AliGeomManager::LayerToVolUID(AliGeomManager::kTOF, index);
2940 //_____________________________________________________________________________
2942 void AliTOFClusterFinderV1::GetClusterPars(Int_t *ind, Double_t* pos, Double_t* cov) const
2945 // Starting from the volume indices (ind[5]), for a cluster coming from
2946 // a isolated digits, this function returns:
2947 // the cluster position (pos),
2948 // the cluster covariance matrix elements (cov)
2952 //we now go in the system of the strip: determine the local coordinates
2955 // 47---------------------------------------------------0 ^ z
2956 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 1 |
2957 // ----------------------------------------------------- | y going outwards
2958 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 0 | par[0]=0;
2960 // ----------------------------------------------------- |
2961 // x <-----------------------------------------------------
2963 //move to the tracking ref system
2964 Double_t lpos[3] = { (ind[4]-23.5)*AliTOFGeometry::XPad(),
2966 (ind[3]- 0.5)*AliTOFGeometry::ZPad() };
2967 AliDebug(1, Form(" %f %f %f", lpos[0], lpos[1], lpos[2]));
2970 UShort_t volIndex = GetClusterVolIndex(ind);
2971 const TGeoHMatrix *l2t = AliGeomManager::GetTracking2LocalMatrix(volIndex);
2973 // Get the position in the track ref system
2975 l2t->MasterToLocal(lpos,tpos);
2980 //Get the cluster covariance in the track ref system
2982 for (Int_t ii=0; ii<9; ii++) lcov[ii] = 0.;
2984 //cluster covariance in the local system:
2989 lcov[4] = 0.42*0.42/3.;
2990 // = ( 5*0.025 (gas gaps thikness)
2991 // + 4*0.040 (internal glasses thickness)
2992 // + 0.5*0.160 (internl PCB)
2993 // + 1*0.055 (external red glass))
2995 lcov[0] = 0.499678;//AliTOFGeometry::XPad()*AliTOFGeometry::XPad()/12.;
2996 lcov[8] = 0.992429;//AliTOFGeometry::ZPad()*AliTOFGeometry::ZPad()/12.;
2998 //cluster covariance in the tracking system:
3000 m.SetRotation(lcov);
3002 m.MultiplyLeft(&l2t->Inverse());
3003 Double_t *tcov = m.GetRotationMatrix();
3004 cov[0] = tcov[0]; cov[1] = tcov[1]; cov[2] = tcov[2];
3005 cov[3] = tcov[4]; cov[4] = tcov[5]; cov[5] = tcov[8];
3010 //_____________________________________________________________________________
3012 void AliTOFClusterFinderV1::GetClusterPars(Bool_t check, Int_t counter,
3013 Int_t **ind, Double_t *weight,
3014 Double_t *pos, Double_t *cov) const
3018 // the volumes indices (ind[counter][5]), for a
3019 // cluster coming from a collection of 'counter'
3021 // the volumes weights (weight[counter]), -controlled
3022 // by the 'check' variable control-, for a cluster
3023 // coming from a collection of 'counter' digits,
3024 // the cluster position (pos),
3025 // this function returns:
3026 // the covariance matrix elements (cov) for the found cluster
3030 // we now go in the system of the strip: determine the local coordinates
3032 // 47---------------------------------------------------0 ^ z
3033 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 1 |
3034 // ----------------------------------------------------- | y going outwards
3035 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 0 | par[0]=0;
3037 // ----------------------------------------------------- |
3038 // x <-----------------------------------------------------
3040 for (Int_t ii=0; ii<counter; ii++)
3041 AliDebug(1, Form(" %2i %2i %1i %2i %1i %2i ",
3042 ii, ind[ii][0], ind[ii][1], ind[ii][2], ind[ii][3], ind[ii][4]));
3044 Float_t posF[3]; for (Int_t ii=0; ii<3; ii++) posF[ii] = (Float_t)pos[ii];
3045 AliDebug(1, Form(" %f %f %f", pos[0], pos[1], pos[2]));
3046 AliTOFGeometry tofGeom;
3047 Int_t detClus[5] = {-1, -1, -1, -1, -1};
3048 tofGeom.GetDetID(posF, detClus);
3051 UShort_t volIndex = GetClusterVolIndex(detClus);
3052 AliDebug(1, Form(" %2i %1i %2i %1i %2i %7i",
3053 detClus[0], detClus[1], detClus[2], detClus[3], detClus[4], volIndex));
3055 // Get the position in the TOF strip ref system
3056 const TGeoHMatrix *alice2strip = AliGeomManager::GetOrigGlobalMatrix(volIndex);
3057 Double_t ppos[3] = {-1, -1, -1};
3058 alice2strip->MasterToLocal(pos,ppos);
3059 AliDebug(1, Form(" %f %f %f", ppos[0], ppos[1], ppos[2]));
3062 // Get the position in the tracking ref system
3063 const TGeoHMatrix *g2l = AliGeomManager::GetTracking2LocalMatrix(volIndex);
3064 Double_t lpos[3] = {-1, -1, -1};
3065 g2l->MasterToLocal(ppos,lpos);
3066 AliDebug(1, Form(" %f %f %f", lpos[0], lpos[1], lpos[2]));
3067 for (Int_t ii=0; ii<3; ii++) pos[ii] = lpos[ii];
3069 //Get the cluster covariance in the track ref system
3071 for (Int_t ii=0; ii<9; ii++) lcov[ii] = 0.;
3073 //cluster covariance in the local system:
3078 // Evaluation of the ovariance matrix elements
3079 TOFclusterError(check, counter, ind, weight, ppos, lcov);
3081 AliDebug(1, Form("lcov[0] = %f, lcov[8] = %f", lcov[0], lcov[8]));
3083 //cluster covariance in the tracking system:
3085 m.SetRotation(lcov);
3087 m.MultiplyLeft(&g2l->Inverse());
3088 Double_t *tcov = m.GetRotationMatrix();
3089 cov[0] = tcov[0]; cov[1] = tcov[1]; cov[2] = tcov[2];
3090 cov[3] = tcov[4]; cov[4] = tcov[5]; cov[5] = tcov[8];
3095 //_____________________________________________________________________________
3097 void AliTOFClusterFinderV1::TOFclusterError(Bool_t check, Int_t counter,
3098 Int_t **ind, Double_t *weight,
3099 Double_t ppos[], Double_t lcov[]) const
3105 //lcov[4] = 0.42*0.42/3.;
3106 // = ( 5*0.025 (gas gaps thikness)
3107 // + 4*0.040 (internal glasses thickness)
3108 // + 0.5*0.160 (internl PCB)
3109 // + 1*0.055 (external red glass))
3112 Float_t *delta2X = new Float_t[counter];
3113 for (Int_t ii=0; ii<counter; ii++)
3115 ((ind[ii][4]-23.5)*AliTOFGeometry::XPad() - ppos[0])*((ind[ii][4]-23.5)*AliTOFGeometry::XPad() - ppos[0]);
3117 Float_t *delta2Z = new Float_t[counter];
3118 for (Int_t ii=0; ii<counter; ii++)
3120 ((ind[ii][3]- 0.5)*AliTOFGeometry::ZPad() - ppos[2])*((ind[ii][3]- 0.5)*AliTOFGeometry::ZPad() - ppos[2]);
3122 for (Int_t ii=0; ii<counter; ii++)
3123 AliDebug(1, Form("x[%i] = %f, z[%i] = %f, weight[%i] = %f",
3124 ii, (ind[ii][4]-23.5)*AliTOFGeometry::XPad(),
3125 ii, (ind[ii][3]- 0.5)*AliTOFGeometry::ZPad(),
3128 AliDebug(1, Form("xMean = %f, zMean = %f",ppos[0], ppos[2]));
3136 if (ind[0][3]==ind[1][3] && TMath::Abs(ind[0][4]-ind[1][4])==1) { //
3143 if (weight[0]==weight[1])
3144 lcov[0] = 0.0379409;
3146 lcov[0] = TMath::Mean(counter, delta2X, weight);
3151 else if (ind[0][4]==ind[1][4] && TMath::Abs(ind[0][3]-ind[1][3])==1) {//
3158 if (weight[0]==weight[1])
3159 lcov[8] = 0.0422046;
3161 lcov[8] = TMath::Mean(counter, delta2Z, weight);
3175 if (weight[0]==weight[1] && weight[0]==weight[2]) {
3176 lcov[0] = 0.0290677;
3177 lcov[8] = 0.0569726;
3180 lcov[0] = TMath::Mean(counter, delta2X, weight);
3181 lcov[8] = TMath::Mean(counter, delta2Z, weight);
3195 if (weight[0]==weight[1] && weight[0]==weight[2] && weight[0]==weight[3]) {
3196 lcov[0] = 0.0223807;
3197 lcov[8] = 0.0438662;
3200 lcov[0] = TMath::Mean(counter, delta2X, weight);
3201 lcov[8] = TMath::Mean(counter, delta2Z, weight);
3211 //_____________________________________________________________________________
3213 Bool_t AliTOFClusterFinderV1::MakeSlewingCorrection(Int_t *detectorIndex,
3219 // This funtion makes the following:
3221 // - if at least one of the three status (Pulser/Noise/HW) is
3222 // bad, is sets the status of electronic channel, corresponding to the
3223 // volume identified by detectorIndex, as kFALSE;
3224 // - if offline calibration is in the valid status, it performs the
3225 // slewing correction. In particular, by taking into account:
3226 // * the measured tot and tof values (tofDigitToT and tofDigitTdc,
3228 // * the six parameters of 5th order polynomial used
3229 // to fit the tofVStot scatter plot,
3230 // it returns the corrected tof value, i.e. tdcCorr value.
3233 Bool_t output = kTRUE;
3238 //AliInfo(" Calibrating TOF Digits: ");
3240 AliTOFChannelOnlineArray *calDelay = fTOFcalib->GetTOFOnlineDelay();
3241 AliTOFChannelOnlineStatusArray *calStatus = fTOFcalib->GetTOFOnlineStatus();
3243 TObjArray *calTOFArrayOffline = fTOFcalib->GetTOFCalArrayOffline();
3245 Int_t index = AliTOFGeometry::GetIndex(detectorIndex);
3247 UChar_t statusPulser = calStatus->GetPulserStatus(index);
3248 UChar_t statusNoise = calStatus->GetNoiseStatus(index);
3249 UChar_t statusHW = calStatus->GetHWStatus(index);
3250 UChar_t status = calStatus->GetStatus(index);
3252 //check the status, also unknown is fine!!!!!!!
3254 AliDebug(2, Form(" Status for channel %i = %i",index, (Int_t)status));
3255 if((statusPulser & AliTOFChannelOnlineStatusArray::kTOFPulserBad)==(AliTOFChannelOnlineStatusArray::kTOFPulserBad)||(statusNoise & AliTOFChannelOnlineStatusArray::kTOFNoiseBad)==(AliTOFChannelOnlineStatusArray::kTOFNoiseBad)||(statusHW & AliTOFChannelOnlineStatusArray::kTOFHWBad)==(AliTOFChannelOnlineStatusArray::kTOFHWBad)){
3256 AliDebug(2, Form(" Bad Status for channel %i",index));
3257 //fTofClusters[ii]->SetStatus(kFALSE); //odd convention, to avoid conflict with calibration objects currently in the db (temporary solution).
3261 AliDebug(2, Form(" Good Status for channel %i",index));
3263 // Get Rough channel online equalization
3264 Double_t roughDelay = (Double_t)calDelay->GetDelay(index); // in ns
3265 AliDebug(2,Form(" channel delay (ns) = %f", roughDelay));
3266 // Get Refined channel offline calibration parameters
3267 TString validity = (TString)fTOFcalib->GetOfflineValidity();
3268 if (validity.CompareTo("valid")==0) {
3269 AliTOFChannelOffline * calChannelOffline = (AliTOFChannelOffline*)calTOFArrayOffline->At(index);
3271 for (jj = 0; jj<6; jj++)
3272 par[jj] = (Double_t)calChannelOffline->GetSlewPar(jj);
3274 AliDebug(2,Form(" Calib Pars = %f, %f, %f, %f, %f, %f ",par[0],par[1],par[2],par[3],par[4],par[5]));
3275 AliDebug(2,Form(" The ToT and Time, uncorr (counts) = %i , %i", tofDigitToT, tofDigitTdc));
3276 Double_t tToT = (Double_t)(tofDigitToT*AliTOFGeometry::ToTBinWidth());
3277 tToT*=1.E-3; //ToT in ns
3278 AliDebug(2,Form(" The ToT and Time, uncorr (ns)= %e, %e",tofDigitTdc*AliTOFGeometry::TdcBinWidth()*1.E-3,tToT));
3279 timeCorr = par[0] + tToT*(par[1] + tToT*(par[2] + tToT*(par[3] + tToT*(par[4] + tToT*par[5])))); // the time correction (ns)
3282 timeCorr = roughDelay; // correction in ns
3284 AliDebug(2,Form(" The ToT and Time, uncorr (ns)= %e, %e",tofDigitTdc*AliTOFGeometry::TdcBinWidth()*1.E-3,tofDigitToT*AliTOFGeometry::ToTBinWidth()));
3285 AliDebug(2,Form(" The time correction (ns) = %f", timeCorr));
3286 timeCorr = (Double_t)(tofDigitTdc)*AliTOFGeometry::TdcBinWidth()*1.E-3-timeCorr;//redefine the time
3288 AliDebug(2,Form(" The channel time, corr (ps)= %e",timeCorr ));
3289 tdcCorr = (Int_t)(timeCorr/AliTOFGeometry::TdcBinWidth()); //the corrected time (tdc counts)
3294 //______________________________________________________________________________
3296 void AliTOFClusterFinderV1::Digits2RecPoints(Int_t iEvent)
3299 // Converts digits to recpoints for TOF
3302 TStopwatch stopwatch;
3305 fRunLoader->GetEvent(iEvent);
3307 AliLoader *localTOFLoader = (AliLoader*)fRunLoader->GetLoader("TOFLoader");
3309 TTree * localTreeD = (TTree*)localTOFLoader->TreeD();
3310 if (localTreeD == 0x0)
3311 AliFatal("Can not get TreeD");
3313 TBranch *branch = localTreeD->GetBranch("TOF");
3315 AliError("Can't get the branch with the TOF digits !");
3319 TTree *localTreeR = (TTree*)localTOFLoader->TreeR();
3320 if (localTreeR == 0x0)
3322 localTOFLoader->MakeTree("R");
3323 localTreeR = localTOFLoader->TreeR();
3326 Digits2RecPoints(localTreeD, localTreeR);
3328 //localTOFLoader = fRunLoader->GetLoader("TOFLoader");
3329 localTOFLoader->WriteRecPoints("OVERWRITE");
3331 AliDebug(1, Form("Execution time to read TOF digits and to write TOF clusters for the event number %i: R:%.4fs C:%.4fs",
3332 iEvent, stopwatch.RealTime(),stopwatch.CpuTime()));
3335 //______________________________________________________________________________
3337 void AliTOFClusterFinderV1::Digits2RecPoints(Int_t iEvent, AliRawReader *rawReader)
3340 // Converts RAW data to recpoints for TOF
3343 TStopwatch stopwatch;
3346 fRunLoader->GetEvent(iEvent);
3348 AliDebug(2,Form(" Event number %2i ", iEvent));
3350 AliLoader *localTOFLoader = (AliLoader*)fRunLoader->GetLoader("TOFLoader");
3352 TTree *localTreeR = localTOFLoader->TreeR();
3354 if (localTreeR == 0x0){
3355 localTOFLoader->MakeTree("R");
3356 localTreeR = localTOFLoader->TreeR();
3359 Digits2RecPoints(rawReader, localTreeR);
3361 AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters for the event number %i: R:%.4fs C:%.4fs",
3362 iEvent, stopwatch.RealTime(),stopwatch.CpuTime()));
3365 //______________________________________________________________________________
3367 void AliTOFClusterFinderV1::Raw2Digits(Int_t iEvent, AliRawReader *rawReader)
3370 // Converts RAW data to MC digits for TOF
3374 TStopwatch stopwatch;
3377 fRunLoader->GetEvent(iEvent);
3379 AliDebug(2,Form(" Event number %2i ", iEvent));
3381 AliLoader *localTOFLoader = (AliLoader*)fRunLoader->GetLoader("TOFLoader");
3383 TTree *localTreeD = localTOFLoader->TreeD();
3385 if (localTreeD == 0x0){
3386 localTOFLoader->MakeTree("D");
3387 localTreeD = localTOFLoader->TreeD();
3390 Raw2Digits(rawReader, localTreeD);
3392 AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters for the event number %i: R:%.4fs C:%.4fs",
3393 iEvent, stopwatch.RealTime(),stopwatch.CpuTime()));
3396 //______________________________________________________________________________
3398 void AliTOFClusterFinderV1::AverageCalculations(Int_t number, Float_t *interestingX,
3399 Float_t *interestingY, Float_t *interestingZ,
3400 Double_t *interestingTOF, Double_t *interestingTOT,
3401 Double_t *interestingADC, Double_t *interestingWeight,
3402 Int_t *parTOF, Double_t *posClus, Bool_t &check)
3408 Double_t tofAverage = 0.;
3409 Double_t totAverage = 0.;
3410 Double_t adcAverage = 0.;
3414 for (ii=number-1; ii>=0; ii--) check=check||(interestingWeight[ii]==0 ||interestingWeight[ii]==-1);
3418 posClus[0] = TMath::Mean(number, interestingX);
3419 posClus[1] = TMath::Mean(number, interestingY);
3420 posClus[2] = TMath::Mean(number, interestingZ);
3421 tofAverage = TMath::Mean(number, interestingTOF);
3422 totAverage = TMath::Mean(number, interestingTOT);
3423 adcAverage = TMath::Mean(number, interestingADC);
3428 posClus[0] = TMath::Mean(number, interestingX, interestingWeight);
3429 posClus[1] = TMath::Mean(number, interestingY, interestingWeight);
3430 posClus[2] = TMath::Mean(number, interestingZ, interestingWeight);
3431 tofAverage = TMath::Mean(number, interestingTOF, interestingWeight);
3432 totAverage = TMath::Mean(number, interestingTOT, interestingWeight);
3433 adcAverage = TMath::Mean(number, interestingADC, interestingWeight);
3437 parTOF[0] = Int_t(tofAverage);
3438 parTOF[1] = Int_t(adcAverage);
3439 parTOF[2] = Int_t(totAverage);
3440 parTOF[3] = Int_t(tofAverage);
3441 parTOF[4] = Int_t(tofAverage);