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())
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())
97 //_____________________________________________________________________________
99 AliTOFClusterFinderV1::AliTOFClusterFinderV1(const AliTOFClusterFinderV1 &source)
102 fDigits(new TClonesArray("AliTOFdigit", 4000)),
103 fRecPoints(new TClonesArray("AliTOFcluster", 4000)),
104 fNumberOfTofClusters(0),
105 fNumberOfTofDigits(0),
110 fTOFdigitMap(new AliTOFDigitMap())
114 this->fDigits=source.fDigits;
115 this->fRecPoints=source.fRecPoints;
116 this->fDecoderVersion=source.fDecoderVersion;
117 this->fTOFcalib=source.fTOFcalib;
120 //_____________________________________________________________________________
122 AliTOFClusterFinderV1& AliTOFClusterFinderV1::operator=(const AliTOFClusterFinderV1 &source)
125 this->fDigits=source.fDigits;
126 this->fRecPoints=source.fRecPoints;
127 this->fVerbose=source.fVerbose;
128 this->fDecoderVersion=source.fDecoderVersion;
129 this->fTOFcalib=source.fTOFcalib;
130 this->fTOFdigitMap=source.fTOFdigitMap;
134 //_____________________________________________________________________________
136 AliTOFClusterFinderV1::~AliTOFClusterFinderV1()
151 fRecPoints->Delete();
159 //_____________________________________________________________________________
161 void AliTOFClusterFinderV1::Digits2RecPoints(TTree* digitsTree, TTree* clusterTree)
164 // Converts digits to recPoints for TOF
167 TStopwatch stopwatch;
172 TClonesArray &aDigits = *fDigits;
174 if (digitsTree == 0x0)
175 AliFatal("Can not get TreeD for TOF");
177 TBranch *branch = digitsTree->GetBranch("TOF");
179 AliError("Can not get branch with the TOF digits !");
183 TClonesArray staticDigits("AliTOFdigit",10000);
184 staticDigits.Clear();
185 TClonesArray *digits = &staticDigits;
186 branch->SetAddress(&digits);
187 digitsTree->GetEvent(0);
188 AliInfo(Form("Number of TOF digits: %d", digits->GetEntriesFast()));
190 AliTOFdigit *tofDigit;
193 Int_t detectorIndex[5];
194 for (jj=0; jj<5; jj++) detectorIndex[jj] = -1;
196 for (jj=0; jj<4; jj++) info[jj] = -1;
202 Bool_t status = kTRUE;
204 AliInfo(" Calibrating TOF Digits: ");
205 TString validity = (TString)fTOFcalib->GetOfflineValidity();
206 AliInfo(Form(" validity = %s", validity.Data()));
207 if (validity.CompareTo("valid")==0) {
208 AliInfo(" ...using offline calibration parameters");
211 AliInfo(" ...using online calibration parameters");
215 for (ii=0; ii<digits->GetEntriesFast(); ii++) {
216 tofDigit = (AliTOFdigit*)digits->UncheckedAt(ii);
217 detectorIndex[0] = tofDigit->GetSector();
218 detectorIndex[1] = tofDigit->GetPlate();
219 detectorIndex[2] = tofDigit->GetStrip();
220 detectorIndex[3] = tofDigit->GetPadz();
221 detectorIndex[4] = tofDigit->GetPadx();
223 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
224 if (detectorIndex[1]==2) { // plate with holes
230 status = MakeSlewingCorrection(detectorIndex, tofDigit->GetToT(), tofDigit->GetTdc(), tdcCorr);
232 for (jj=0; jj<4; jj++) info[jj] = -1;
233 info[0] = tdcCorr;//tofDigit->GetTdc();
234 info[1] = tofDigit->GetAdc();
235 info[2] = tofDigit->GetToT();
236 info[3] = tofDigit->GetTdcND();//tofDigit->GetTdc();//
237 tracks = tofDigit->GetTracks();
239 dummy = detectorIndex[3];
240 detectorIndex[3] = detectorIndex[4];//padx
241 detectorIndex[4] = dummy;//padz
242 last = fDigits->GetEntriesFast();
243 new (aDigits[last]) AliTOFdigit(tracks, detectorIndex, info);
244 if (status) fTOFdigitMap->AddDigit(detectorIndex, last);
246 AliDebug(2, Form(" Digits reading %2i -> %2i %1i %2i %1i %2i (%d, %d, %d)",
248 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[3], detectorIndex[4],
249 info[0], info[1], info[3]));
253 fNumberOfTofDigits = fDigits->GetEntriesFast();
257 Int_t bufsize = 32000;
258 clusterTree->Branch("TOF", &fRecPoints, bufsize);
263 AliInfo(Form("Number of found TOF clusters: %d", fNumberOfTofClusters));
267 fTOFdigitMap->Clear();
271 AliInfo(Form("Execution time to read TOF digits and to write TOF clusters : R:%.4fs C:%.4fs",
272 stopwatch.RealTime(),stopwatch.CpuTime()));
274 if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
277 //_____________________________________________________________________________
279 void AliTOFClusterFinderV1::Digits2RecPoints(AliRawReader *rawReader, TTree *clustersTree)
282 // Converts raw data to recPoints for TOF
285 TStopwatch stopwatch;
289 AliDebug(2, "TreeD re-creation");
290 TTree *digitsTree = new TTree();
292 Raw2Digits(rawReader, digitsTree);
294 AliDebug(2,Form("Number of TOF digits: %d", fNumberOfTofDigits));
297 Int_t bufsize = 32000;
298 clustersTree->Branch("TOF", &fRecPoints, bufsize);
301 clustersTree->Fill();
303 AliInfo(Form("Number of found clusters: %i", fNumberOfTofClusters));
307 fTOFdigitMap->Clear();
311 AliInfo(Form("Execution time to read TOF raw data and to write TOF clusters : R:%.4fs C:%.4fs",
312 stopwatch.RealTime(),stopwatch.CpuTime()));
316 //_____________________________________________________________________________
318 void AliTOFClusterFinderV1::Raw2Digits(AliRawReader *rawReader, TTree* digitsTree)
321 // Converts raw data to digits for TOF
324 TStopwatch stopwatch;
329 const Int_t kMaxNumberOfTracksPerDigit = 3;
330 const Int_t kDDL = AliDAQ::NumberOfDdls("TOF");
332 digitsTree->Branch("TOF", &fDigits);
333 TClonesArray &aDigits = *fDigits;
335 AliTOFRawStream tofInput(rawReader);
338 if (fVerbose==2) ftxt.open("TOFdigitsRead.txt",ios::app);
340 TClonesArray staticRawData("AliTOFrawData",10000);
341 staticRawData.Clear();
342 TClonesArray * clonesRawData = &staticRawData;
345 Int_t detectorIndex[5] = {-1, -1, -1, -1, -1};
347 Int_t tracks[kMaxNumberOfTracksPerDigit];
348 for (Int_t ii=0; ii<kMaxNumberOfTracksPerDigit; ii++)
353 Bool_t status = kTRUE;
355 AliInfo(" Calibrating TOF Digits: ");
356 TString validity = (TString)fTOFcalib->GetOfflineValidity();
357 AliInfo(Form(" validity = %s", validity.Data()));
358 if (validity.CompareTo("valid")==0) {
359 AliInfo(" ...using offline calibration parameters");
362 AliInfo(" ...using online calibration parameters");
367 for (indexDDL=0; indexDDL<kDDL; indexDDL++) {
370 if (fDecoderVersion) {
371 AliInfo("Using New Decoder \n");
372 tofInput.LoadRawDataBuffers(indexDDL,fVerbose);
374 else tofInput.LoadRawData(indexDDL);
376 clonesRawData = (TClonesArray*)tofInput.GetRawData();
377 if (clonesRawData->GetEntriesFast()!=0) AliInfo(Form(" TOF raw data number = %3i", clonesRawData->GetEntriesFast()));
378 for (iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
380 AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
382 //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
383 if (tofRawDatum->GetTOF()==-1) continue;
385 tofInput.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
386 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
389 dummy = detectorIndex[3];
390 detectorIndex[3] = detectorIndex[4];//padz
391 detectorIndex[4] = dummy;//padx
392 status = MakeSlewingCorrection(detectorIndex, tofRawDatum->GetTOT(), tofRawDatum->GetTOF(), tdcCorr);
395 digit[1] = tofRawDatum->GetTOT();
396 digit[2] = tofRawDatum->GetTOT();
397 digit[3] = tofRawDatum->GetTOF();
399 dummy = detectorIndex[3];
400 detectorIndex[3] = detectorIndex[4];//padx
401 detectorIndex[4] = dummy;//padz
403 // Do not reconstruct anything in the holes
404 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
405 if (detectorIndex[1]==2) { // plate with holes
411 last = fDigits->GetEntriesFast();
412 new (aDigits[last]) AliTOFdigit(tracks, detectorIndex, digit);
413 if (status) fTOFdigitMap->AddDigit(detectorIndex, last);
416 if (indexDDL<10) ftxt << " " << indexDDL;
417 else ftxt << " " << indexDDL;
418 if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM();
419 else ftxt << " " << tofRawDatum->GetTRM();
420 ftxt << " " << tofRawDatum->GetTRMchain();
421 if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC();
422 else ftxt << " " << tofRawDatum->GetTDC();
423 ftxt << " " << tofRawDatum->GetTDCchannel();
425 if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0];
426 else ftxt << " -> " << detectorIndex[0];
427 ftxt << " " << detectorIndex[1];
428 if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2];
429 else ftxt << " " << detectorIndex[2];
430 ftxt << " " << detectorIndex[4];
431 if (detectorIndex[4]<10) ftxt << " " << detectorIndex[3];
432 else ftxt << " " << detectorIndex[3];
434 if (digit[1]<10)ftxt << " " << digit[1];
435 else if (digit[1]>=10 && digit[1]<100) ftxt << " " << digit[1];
436 else ftxt << " " << digit[1];
437 if (digit[0]<10) ftxt << " " << digit[0] << endl;
438 else if (digit[0]>=10 && digit[0]<100) ftxt << " " << digit[0] << endl;
439 else if (digit[0]>=100 && digit[0]<1000) ftxt << " " << digit[0] << endl;
440 else ftxt << " " << digit[3] << endl;
443 AliDebug(2, Form(" Raw data reading %2i -> %2i %1i %2i %1i %2i (%d, %d, %d)",
445 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[4], detectorIndex[3],
446 digit[0], digit[1], digit[3]));
450 clonesRawData->Clear();
454 if (fVerbose==2) ftxt.close();
458 fNumberOfTofDigits = fDigits->GetEntries();
460 AliDebug(1, Form("Got %d TOF digits", fNumberOfTofDigits));
461 AliDebug(1, Form("Execution time to read TOF raw data and fill TOF digit tree : R:%.2fs C:%.2fs",
462 stopwatch.RealTime(),stopwatch.CpuTime()));
464 if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
467 //_____________________________________________________________________________
469 void AliTOFClusterFinderV1::FillRecPoint()
472 // Fill the global TClonesArray of AliTOFcluster objects,
476 //Int_t dummy4_1 = -1;
477 //Int_t dummy3_1 = -1;
478 //Int_t dummy2_1 = -1;
481 for(Int_t iPlate=0; iPlate<AliTOFGeometry::NPlates(); iPlate++) {
482 for(Int_t iStrip=0; iStrip<AliTOFGeometry::NStrip(iPlate); iStrip++) {
483 for (Int_t iSector=0; iSector<AliTOFGeometry::NSectors(); iSector++) {
485 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
486 FindClustersPerStrip(iSector, iPlate, iStrip, 4); // 4 pads clusters
487 dummy4_1 = fNumberOfTofClusters;
488 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
489 FindClustersPerStrip(iSector, iPlate, iStrip, 4); // 4 pads clusters
490 if (fNumberOfTofClusters!=dummy4_1)
491 AliDebug(2, Form(" (4): n1= %5i, n2 = %5", dummy4_1, fNumberOfTofClusters));
494 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
495 FindClustersPerStrip(iSector, iPlate, iStrip, 3); // 3 pads clusters
496 dummy3_1 = fNumberOfTofClusters;
497 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
498 FindClustersPerStrip(iSector, iPlate, iStrip, 3); // 3 pads clusters
499 if (fNumberOfTofClusters!=dummy3_1)
500 AliDebug(2, Form(" (3): n1= %5i, n2 = %5", dummy3_1, fNumberOfTofClusters));
503 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
504 FindClustersPerStrip(iSector, iPlate, iStrip, 2); // 2 pads clusters
505 dummy2_1 = fNumberOfTofClusters;
506 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
507 FindClustersPerStrip(iSector, iPlate, iStrip, 2); // 2 pads clusters
508 if (fNumberOfTofClusters!=dummy2_1)
509 AliDebug(2, Form(" (2): n1= %5i, n2 =%5", dummy2_1, fNumberOfTofClusters));
512 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
513 dummy = fNumberOfTofClusters;
514 FindClusters34(iSector, iPlate, iStrip); // 3 pads clusters between 4 hit pads
515 if (fNumberOfTofClusters!=dummy)
516 AliDebug(2, Form(" (3 between 4): n1 = %5i, n2 = %5i", fNumberOfTofClusters, dummy));
519 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
520 dummy = fNumberOfTofClusters;
521 FindClusters23(iSector, iPlate, iStrip); // 2 pads clusters between 3 hit pads
522 if (fNumberOfTofClusters!=dummy)
523 AliDebug(2, Form(" (2 between 3): n1 = %5i, n2 = %5i", fNumberOfTofClusters, dummy));
525 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
526 dummy = fNumberOfTofClusters;
527 FindClusters24(iSector, iPlate, iStrip); // 2 pads clusters between 4 hit pads
528 if (fNumberOfTofClusters!=dummy)
529 AliDebug(2, Form(" (2 between 4): n1 = %5i, n2 = %5i", fNumberOfTofClusters, dummy));
533 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
534 dummy = fNumberOfTofClusters;
535 FindOnePadClusterPerStrip(iSector, iPlate, iStrip); // 1 pad clusters
536 if (fNumberOfTofClusters!=dummy)
537 AliDebug(2,Form(" (1): n1 = %5i, n2 = %5i", fNumberOfTofClusters, dummy));
539 if (fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip)>0)
540 AliDebug(2, Form(" (1): numero di clusters = %5i (remaining digit %2i), -%2i %1i %2i-",
541 fNumberOfTofClusters, fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip),
542 iSector, iPlate, iStrip));
549 TClonesArray &lRecPoints = *fRecPoints;
553 Int_t detectorIndex[5];
555 Int_t trackLabels[3];
556 Int_t digitIndex = -1;
557 Bool_t status = kTRUE;
559 for (ii=0; ii<3; ii++) posClus[ii] = 0.;
560 //Float_t covClus[6];
561 //for (ii=0; ii<6; ii++) covClus[ii] = 0.;
564 for (ii=0; ii<fNumberOfTofClusters; ii++) {
566 digitIndex = fTofClusters[ii]->GetIndex();
567 for(jj=0; jj<5; jj++) detectorIndex[jj] = fTofClusters[ii]->GetDetInd(jj);
568 volIdClus = GetClusterVolIndex(detectorIndex);
569 for(jj=0; jj<3; jj++) trackLabels[jj] = fTofClusters[ii]->GetLabel(jj);
570 parTOF[0] = fTofClusters[ii]->GetTDC(); // TDC
571 parTOF[1] = fTofClusters[ii]->GetToT(); // TOT
572 parTOF[2] = fTofClusters[ii]->GetADC(); // ADC=TOT
573 parTOF[3] = fTofClusters[ii]->GetTDCND(); // TDCND
574 parTOF[4] = fTofClusters[ii]->GetTDCRAW();//RAW
575 status = fTofClusters[ii]->GetStatus();
577 posClus[0] = fTofClusters[ii]->GetX();
578 posClus[1] = fTofClusters[ii]->GetY();
579 posClus[2] = fTofClusters[ii]->GetZ();
581 //for (jj=0; jj<6; jj++) covClus[jj] = 0.;
582 //((AliCluster*)fTofClusters[ii])->GetGlobalCov(covClus);
584 new(lRecPoints[ii]) AliTOFcluster(volIdClus, (Double_t)posClus[0], (Double_t)posClus[1], (Double_t)posClus[2],
585 (Double_t)(fTofClusters[ii]->GetSigmaX2()),
586 (Double_t)(fTofClusters[ii]->GetSigmaXY()),
587 (Double_t)(fTofClusters[ii]->GetSigmaXZ()),
588 (Double_t)(fTofClusters[ii]->GetSigmaY2()),
589 (Double_t)(fTofClusters[ii]->GetSigmaYZ()),
590 (Double_t)(fTofClusters[ii]->GetSigmaZ2()),
591 //(Double_t)covClus[0], (Double_t)covClus[1], (Double_t)covClus[2],
592 //(Double_t)covClus[3], (Double_t)covClus[4], (Double_t)covClus[5],
593 trackLabels, detectorIndex, parTOF, status, digitIndex);
595 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",
596 ii, volIdClus, posClus[0], posClus[1], posClus[2],
597 fTofClusters[ii]->GetSigmaX2(),
598 fTofClusters[ii]->GetSigmaXY(),
599 fTofClusters[ii]->GetSigmaXZ(),
600 fTofClusters[ii]->GetSigmaY2(),
601 fTofClusters[ii]->GetSigmaYZ(),
602 fTofClusters[ii]->GetSigmaZ2(),
603 trackLabels[0], trackLabels[1], trackLabels[2],
604 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[3], detectorIndex[4],
605 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
606 status, digitIndex));
611 for (Int_t iSector=0; iSector<AliTOFGeometry::NSectors(); iSector++)
612 for(Int_t iPlate=0; iPlate<AliTOFGeometry::NPlates(); iPlate++) {
613 for(Int_t iStrip=0; iStrip<AliTOFGeometry::NStrip(iPlate); iStrip++) {
614 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
615 AliDebug(2, Form(" END %2i %1i %2i %5i",
616 iSector, iPlate, iStrip, fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip)));
621 //_____________________________________________________________________________
623 void AliTOFClusterFinderV1::FindOnePadClusterPerStrip(Int_t nSector,
628 // This function searches the isolated digits (stored in the fDigits object),
629 // to perform clusters (stored in the fTofClusters array).
630 // This research has been made by checking the fTOFdigitMap object,
631 // filled at digits/raw-data reading time.
634 const Int_t kMaxNumberOfTracksPerDigit = 3;
635 const Int_t kMaxNumberOfDigitsPerVolume = 3;
639 AliTOFGeometry *tofGeometry = new AliTOFGeometry();
641 Int_t det[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padZ,padX
642 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padX,padZ
643 UShort_t volIdClus = 0;
646 for (jj=0; jj<3; jj++) pos[jj] = 0.;
648 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
651 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
654 for (jj=0; jj<5; jj++) parTOF[jj] = 0;
656 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
658 Int_t tracks[kMaxNumberOfTracksPerDigit];
659 for (jj=0; jj<3; jj++) tracks[jj] = -1;
661 Int_t dummyCounter=-1;
664 AliTOFdigit *digitInteresting;
668 for (iPadX=0; iPadX<AliTOFGeometry::NpadX(); iPadX++) {
669 for (iPadZ=0; iPadZ<AliTOFGeometry::NpadZ(); iPadZ++) {
670 vol[4] = iPadZ , vol[3] = iPadX;
672 AliDebug(3, Form(" %1i %2i\n", iPadZ, iPadX));
674 if (fTOFdigitMap->GetNumberOfDigits(vol)==0) continue;
676 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
677 if (fTOFdigitMap->GetDigitIndex(vol,digIndex)<0) continue;
678 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(fTOFdigitMap->GetDigitIndex(vol,digIndex));
680 AliDebug(2, Form(" %2i %1i %2i %1i %2i %f %f %f %5i %5i %5i %5i",
681 vol[0], vol[1], vol[2] ,vol[4], vol[3],
682 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
683 digitInteresting->GetToT(),
684 fTOFdigitMap->GetDigitIndex(vol,digIndex),
685 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
692 tofGeometry->GetPosPar(det,pos);
693 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
696 for (jj=0; jj<3; jj++) posClus[jj] = pos[jj];
698 parTOF[0] = Int_t(digitInteresting->GetTdc());
699 parTOF[1] = Int_t(digitInteresting->GetAdc());
700 parTOF[2] = Int_t(digitInteresting->GetToT());
701 parTOF[3] = Int_t(digitInteresting->GetTdc());
702 parTOF[4] = Int_t(digitInteresting->GetTdc());
704 volIdClus = GetClusterVolIndex(det);
706 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
707 GetClusterPars(det, posClus, covClus);
709 // To fill the track index array
711 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
712 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) { // three is the max number of tracks associated to one digit
713 if (digitInteresting->GetTrack(jj)==-1) continue;
716 tracks[dummyCounter] = digitInteresting->GetTrack(jj);
720 AliTOFcluster *tofCluster =
721 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
722 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
723 tracks, det, parTOF, status, fTOFdigitMap->GetDigitIndex(vol,digIndex));
724 InsertCluster(tofCluster);
726 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",
727 volIdClus, posClus[0], posClus[1], posClus[2],
728 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
729 tracks[0], tracks[1], tracks[2],
730 det[0], det[1], det[2], det[3], det[4],
731 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
732 status, fTOFdigitMap->GetDigitIndex(vol,digIndex)));
734 AliDebug(2, Form(" %f %f %f", pos[0], pos[1], pos[2]));
735 AliDebug(2, Form(" %f %f", parTOF[0], parTOF[2]));
740 fTOFdigitMap->ResetDigit(vol, digIndex);
748 //_____________________________________________________________________________
750 void AliTOFClusterFinderV1::FindClusters34(Int_t nSector,
755 // This function searches the neighbouring digits (stored in the fDigits object),
756 // to perform clusters (stored in the fTofClusters array).
758 // This research has been made by checking the fTOFdigitMap object,
759 // filled at digits/raw-data reading time.
762 const Int_t kMaxNumberOfInterestingPads = 4;
763 const Int_t kMaxNumberOfTracksPerDigit = 3;
764 const Int_t kMaxNumberOfDigitsPerVolume = 3;
768 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
769 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
770 digitsInVolumeIndices[ii] = -1;
772 AliTOFGeometry *tofGeometry = new AliTOFGeometry();
773 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
775 Float_t pos[3] = {0.,0.,0.};
778 Int_t interestingPadX[kMaxNumberOfInterestingPads];
779 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
780 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
781 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
782 Double_t interestingTOT[kMaxNumberOfInterestingPads];
783 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
784 Double_t interestingADC[kMaxNumberOfInterestingPads];
785 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
786 Double_t interestingTOF[kMaxNumberOfInterestingPads];
787 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
788 Double_t interestingWeight[kMaxNumberOfInterestingPads];
789 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
791 Float_t interestingX[kMaxNumberOfInterestingPads];
792 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
793 Float_t interestingY[kMaxNumberOfInterestingPads];
794 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
795 Float_t interestingZ[kMaxNumberOfInterestingPads];
796 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
798 Float_t interDigit[kMaxNumberOfInterestingPads];
799 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
801 Int_t padsCluster[11];
802 padsCluster[0] = nSector;
803 padsCluster[1] = nPlate;
804 padsCluster[2] = nStrip;
805 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
807 Int_t interestingCounter=-1;
813 for (jj=0; jj<5; jj++) parTOF[jj] = 0;
815 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
817 for (jj=0; jj<5; jj++) det[jj] = -1;
819 for (jj=0; jj<3; jj++) posF[jj] = 0.;
820 UShort_t volIdClus = 0;
821 Bool_t check = kFALSE;
822 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
824 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
825 Int_t tracks[kMaxNumberOfTracksPerDigit];
826 for (jj=0; jj<3; jj++) tracks[jj] = -1;
827 Int_t dummyCounter=-1;
828 Bool_t alreadyStored = kFALSE;
830 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
831 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
832 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
834 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
835 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
837 AliTOFdigit *digitInteresting;
839 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
841 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
842 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
844 AliDebug(3, Form("%2i %1i %2i\n", iPad, iPadZ, iPadX));
851 interestingCounter=-1;
853 vol[4] = iPadZ , vol[3] = iPadX;
854 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
855 interestingCounter++;
857 vol[4] = iPadZ, vol[3] = iPadX+1;
858 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
859 interestingCounter++;
861 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
862 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
863 interestingCounter++;
865 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
866 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
867 interestingCounter++;
869 if (interestingCounter+1!=4) continue; // the hit pads have to be 4
870 else interestingCounter=-1;
873 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
874 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
875 selectedDigit[ii][jj] = 0x0;
878 vol[4] = iPadZ, vol[3] = iPadX;
880 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
881 interestingCounter++;
882 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
883 digitsInVolumeIndices[ii] = -1;
884 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
885 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
886 if (digitsInVolumeIndices[digIndex]<0) continue;
887 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
889 AliDebug(1,Form(" %2i %1i %2i %1i %2i %f %f %f %f %5i %5i %5i %5i",
890 vol[0], vol[1], vol[2] ,vol[4], vol[3],
891 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
892 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
893 digitsInVolumeIndices[digIndex],
894 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
897 selectedDigit[interestingCounter][digIndex] = new
898 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
899 digitInteresting->GetAdc(), digitInteresting->GetToT(),
900 digitInteresting->GetToT()*digitInteresting->GetToT(),
901 digitsInVolumeIndices[digIndex],
902 digitInteresting->GetTracks());
907 vol[4] = iPadZ, vol[3] = iPadX+1;
909 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
910 interestingCounter++;
911 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
912 digitsInVolumeIndices[ii] = -1;
913 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
914 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
915 if (digitsInVolumeIndices[digIndex]<0) continue;
916 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
918 AliDebug(1,Form(" %2i %1i %2i %1i %2i %f %f %f %f %5i %5i %5i %5i",
919 vol[0], vol[1], vol[2] ,vol[4], vol[3],
920 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
921 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
922 digitsInVolumeIndices[digIndex],
923 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
926 selectedDigit[interestingCounter][digIndex] = new
927 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
928 digitInteresting->GetAdc(), digitInteresting->GetToT(),
929 digitInteresting->GetToT()*digitInteresting->GetToT(),
930 digitsInVolumeIndices[digIndex],
931 digitInteresting->GetTracks());
936 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
938 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
939 interestingCounter++;
940 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
941 digitsInVolumeIndices[ii] = -1;
942 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
943 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
944 if (digitsInVolumeIndices[digIndex]<0) continue;
945 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
947 AliDebug(1,Form(" %2i %1i %2i %1i %2i %f %f %f %f %5i %5i %5i %5i",
948 vol[0], vol[1], vol[2] ,vol[4], vol[3],
949 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
950 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
951 digitsInVolumeIndices[digIndex],
952 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
955 selectedDigit[interestingCounter][digIndex] = new
956 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
957 digitInteresting->GetAdc(), digitInteresting->GetToT(),
958 digitInteresting->GetToT()*digitInteresting->GetToT(),
959 digitsInVolumeIndices[digIndex],
960 digitInteresting->GetTracks());
965 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
967 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
968 interestingCounter++;
969 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
970 digitsInVolumeIndices[ii] = -1;
971 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
972 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
973 if (digitsInVolumeIndices[digIndex]<0) continue;
974 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
976 AliDebug(1,Form(" %2i %1i %2i %1i %2i %f %f %f %f %5i %5i %5i %5i",
977 vol[0], vol[1], vol[2] ,vol[4], vol[3],
978 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
979 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
980 digitsInVolumeIndices[digIndex],
981 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
984 selectedDigit[interestingCounter][digIndex] = new
985 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
986 digitInteresting->GetAdc(), digitInteresting->GetToT(),
987 digitInteresting->GetToT()*digitInteresting->GetToT(),
988 digitsInVolumeIndices[digIndex],
989 digitInteresting->GetTracks());
993 AliDebug(1,Form(" e adesso %1i", interestingCounter+1));
995 for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
996 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
997 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
999 for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
1000 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
1001 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
1003 for (Int_t adesso3=adesso2+1; adesso3<interestingCounter+1; adesso3++) {
1004 for (Int_t thirdIndex=0; thirdIndex<kMaxNumberOfDigitsPerVolume; thirdIndex++) {
1005 if (selectedDigit[adesso3][thirdIndex]==0x0) continue;
1008 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime
1010 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
1012 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime) continue;
1014 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
1015 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
1016 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
1017 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
1018 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
1019 AliDebug(1,Form(" %2i %1i %2i %1i %2i", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
1020 Int_t volDum = vol1[3];
1023 tofGeometry->GetPosPar(vol1,pos);
1024 interestingX[0] = pos[0];
1025 interestingY[0] = pos[1];
1026 interestingZ[0] = pos[2];
1028 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
1029 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
1030 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
1031 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
1032 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
1033 AliDebug(1,Form(" %2i %1i %2i %1i %2i", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
1037 tofGeometry->GetPosPar(vol2,pos);
1038 interestingX[1] = pos[0];
1039 interestingY[1] = pos[1];
1040 interestingZ[1] = pos[2];
1042 interestingTOF[2] = selectedDigit[adesso3][thirdIndex]->GetTDC();
1043 interestingTOT[2] = selectedDigit[adesso3][thirdIndex]->GetTOT();
1044 interestingADC[2] = selectedDigit[adesso3][thirdIndex]->GetADC();
1045 interestingWeight[2] = selectedDigit[adesso3][thirdIndex]->GetWeight();
1046 Int_t vol3[5]; for(jj=0; jj<5; jj++) vol3[jj] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(jj);
1047 AliDebug(1,Form(" %2i %1i %2i %1i %2i", vol3[0], vol3[1], vol3[2], vol3[4], vol3[3]));
1051 tofGeometry->GetPosPar(vol3,pos);
1052 interestingX[2] = pos[0];
1053 interestingY[2] = pos[1];
1054 interestingZ[2] = pos[2];
1057 AverageCalculations(3, interestingX, interestingY, interestingZ,
1058 interestingTOF, interestingTOT, interestingADC,
1060 parTOF, posClus, check);
1063 for (jj=0; jj<5; jj++) det[jj] = -1;
1064 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
1065 tofGeometry->GetDetID(posF, det);
1067 volIdClus = GetClusterVolIndex(det);
1069 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1070 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
1071 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
1072 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
1073 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
1074 padsCluster[7] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(4);
1075 padsCluster[8] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(3);
1077 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1078 Int_t ** indDet = new Int_t*[3];
1079 for (jj=0; jj<3; jj++) indDet[jj] = new Int_t [5];
1080 for (jj=0; jj<3; jj++) indDet[jj][0] = nSector;
1081 for (jj=0; jj<3; jj++) indDet[jj][1] = nPlate;
1082 for (jj=0; jj<3; jj++) indDet[jj][2] = nStrip;
1083 for (jj=0; jj<3; jj++) indDet[jj][3] = padsCluster[2*jj+3];
1084 for (jj=0; jj<3; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
1085 GetClusterPars(check, 3, indDet, interestingWeight, posClus, covClus);
1086 for (jj=0; jj<3; jj++) delete [] indDet[jj];
1088 // To fill the track index array
1090 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1091 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1092 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
1095 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
1098 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1099 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
1102 alreadyStored = kFALSE;
1103 for (jj=0; jj<dummyCounter+1; jj++)
1104 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
1106 if (alreadyStored) continue;
1107 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
1108 AliWarning(" Siamo al limite!");
1113 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
1118 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1119 if (selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk)==-1) continue;
1122 alreadyStored = kFALSE;
1123 for (jj=0; jj<dummyCounter+1; jj++)
1124 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk));
1126 if (alreadyStored) continue;
1127 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
1128 AliWarning(" Siamo al limite!");
1133 tracks[dummyCounter] = selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk);
1140 AliTOFcluster *tofCluster =
1141 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
1142 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1143 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
1144 InsertCluster(tofCluster);
1146 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",
1147 volIdClus, posClus[0], posClus[1], posClus[2],
1148 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1149 tracks[0], tracks[1], tracks[2],
1150 det[0], det[1], det[2], det[3], det[4],
1151 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
1152 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
1158 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
1162 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
1166 fTOFdigitMap->ResetDigitNumber(vol3,selectedDigit[adesso3][thirdIndex]->GetIndex());
1169 } // close loop on third digit
1170 } // close loop on adesso3
1172 } // close loop on second digit
1173 } // close loop on adesso2
1175 } // close loop on first digit
1176 } // close loop on adesso1
1178 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1179 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1180 selectedDigit[ii][jj] = 0x0;
1184 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1185 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
1186 delete selectedDigit[ii][jj];
1187 selectedDigit[ii][jj] = 0x0;
1192 //_____________________________________________________________________________
1194 void AliTOFClusterFinderV1::FindClusters23(Int_t nSector,
1199 // This function searches the neighbouring digits (stored in the fDigits object),
1200 // to perform clusters (stored in the fTofClusters array).
1202 // This research has been made by checking the fTOFdigitMap object,
1203 // filled at digits/raw-data reading time.
1206 const Int_t kMaxNumberOfInterestingPads = 4;
1207 const Int_t kMaxNumberOfTracksPerDigit = 3;
1208 const Int_t kMaxNumberOfDigitsPerVolume = 3;
1212 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
1213 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1214 digitsInVolumeIndices[ii] = -1;
1216 AliTOFGeometry *tofGeometry = new AliTOFGeometry();
1217 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
1219 Float_t pos[3] = {0.,0.,0.};
1222 Int_t interestingPadX[kMaxNumberOfInterestingPads];
1223 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
1224 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
1225 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
1226 Double_t interestingTOT[kMaxNumberOfInterestingPads];
1227 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
1228 Double_t interestingADC[kMaxNumberOfInterestingPads];
1229 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
1230 Double_t interestingTOF[kMaxNumberOfInterestingPads];
1231 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
1232 Double_t interestingWeight[kMaxNumberOfInterestingPads];
1233 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
1235 Float_t interestingX[kMaxNumberOfInterestingPads];
1236 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
1237 Float_t interestingY[kMaxNumberOfInterestingPads];
1238 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
1239 Float_t interestingZ[kMaxNumberOfInterestingPads];
1240 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
1242 Float_t interDigit[kMaxNumberOfInterestingPads];
1243 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
1245 Int_t padsCluster[11];
1246 padsCluster[0] = nSector;
1247 padsCluster[1] = nPlate;
1248 padsCluster[2] = nStrip;
1249 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1251 Int_t interestingCounter=-1;
1256 Bool_t check = kFALSE;
1258 for (jj=0; jj<5; jj++) parTOF[jj] = 0;
1259 Double_t posClus[3];
1260 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
1262 for (jj=0; jj<5; jj++) det[jj] = -1;
1264 for (jj=0; jj<3; jj++) posF[jj] = 0.;
1265 UShort_t volIdClus = 0;
1266 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
1267 Double_t covClus[6];
1268 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1269 Int_t tracks[kMaxNumberOfTracksPerDigit];
1270 for (jj=0; jj<3; jj++) tracks[jj] = -1;
1271 Int_t dummyCounter=-1;
1272 Bool_t alreadyStored = kFALSE;
1274 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
1275 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1276 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
1278 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1279 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
1281 AliTOFdigit *digitInteresting;
1283 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
1285 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
1286 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
1288 AliDebug(3, Form("%2i %1i %2i\n", iPad, iPadZ, iPadX));
1295 interestingCounter=-1;
1297 vol[4] = iPadZ , vol[3] = iPadX;
1298 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1299 interestingCounter++;
1301 vol[4] = iPadZ, vol[3] = iPadX+1;
1302 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1303 interestingCounter++;
1305 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1306 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1307 interestingCounter++;
1309 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1310 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1311 interestingCounter++;
1313 if (interestingCounter+1!=3) continue; // the hit pads have to be 3
1314 else interestingCounter=-1;
1317 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1318 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1319 selectedDigit[ii][jj] = 0x0;
1322 vol[4] = iPadZ, vol[3] = iPadX;
1324 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1325 interestingCounter++;
1326 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1327 digitsInVolumeIndices[ii] = -1;
1328 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1329 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1330 if (digitsInVolumeIndices[digIndex]<0) continue;
1331 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1333 AliDebug(1,Form(" %2i %1i %2i %1i %2i %f %f %f %f %5i %5i %5i %5i",
1334 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1335 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1336 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1337 digitsInVolumeIndices[digIndex],
1338 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1341 selectedDigit[interestingCounter][digIndex] = new
1342 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1343 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1344 digitInteresting->GetToT()*digitInteresting->GetToT(),
1345 digitsInVolumeIndices[digIndex],
1346 digitInteresting->GetTracks());
1351 vol[4] = iPadZ, vol[3] = iPadX+1;
1353 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1354 interestingCounter++;
1355 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1356 digitsInVolumeIndices[ii] = -1;
1357 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1358 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1359 if (digitsInVolumeIndices[digIndex]<0) continue;
1360 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1362 AliDebug(1,Form(" %2i %1i %2i %1i %2i %f %f %f %f %5i %5i %5i %5i",
1363 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1364 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1365 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1366 digitsInVolumeIndices[digIndex],
1367 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1370 selectedDigit[interestingCounter][digIndex] = new
1371 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1372 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1373 digitInteresting->GetToT()*digitInteresting->GetToT(),
1374 digitsInVolumeIndices[digIndex],
1375 digitInteresting->GetTracks());
1380 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1382 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1383 interestingCounter++;
1384 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1385 digitsInVolumeIndices[ii] = -1;
1386 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1387 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1388 if (digitsInVolumeIndices[digIndex]<0) continue;
1389 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1391 AliDebug(1,Form(" %2i %1i %2i %1i %2i %f %f %f %f %5i %5i %5i %5i",
1392 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1393 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1394 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1395 digitsInVolumeIndices[digIndex],
1396 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1399 selectedDigit[interestingCounter][digIndex] = new
1400 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1401 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1402 digitInteresting->GetToT()*digitInteresting->GetToT(),
1403 digitsInVolumeIndices[digIndex],
1404 digitInteresting->GetTracks());
1409 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1411 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1412 interestingCounter++;
1413 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1414 digitsInVolumeIndices[ii] = -1;
1415 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1416 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1417 if (digitsInVolumeIndices[digIndex]<0) continue;
1418 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1420 AliDebug(1,Form(" %2i %1i %2i %1i %2i %f %f %f %f %5i %5i %5i %5i",
1421 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1422 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1423 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1424 digitsInVolumeIndices[digIndex],
1425 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1428 selectedDigit[interestingCounter][digIndex] = new
1429 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1430 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1431 digitInteresting->GetToT()*digitInteresting->GetToT(),
1432 digitsInVolumeIndices[digIndex],
1433 digitInteresting->GetTracks());
1437 AliDebug(1,Form(" e adesso %1i", interestingCounter+1));
1439 for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
1440 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
1441 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
1443 for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
1444 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
1445 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
1447 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime) continue;
1449 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
1450 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
1451 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
1452 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
1453 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
1454 AliDebug(1,Form(" %2i %1i %2i %1i %2i", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
1455 Int_t volDum = vol1[3];
1458 tofGeometry->GetPosPar(vol1,pos);
1459 interestingX[0] = pos[0];
1460 interestingY[0] = pos[1];
1461 interestingZ[0] = pos[2];
1463 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
1464 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
1465 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
1466 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
1467 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
1468 AliDebug(1,Form(" %2i %1i %2i %1i %2i", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
1472 tofGeometry->GetPosPar(vol2,pos);
1473 interestingX[1] = pos[0];
1474 interestingY[1] = pos[1];
1475 interestingZ[1] = pos[2];
1477 AverageCalculations(2, interestingX, interestingY, interestingZ,
1478 interestingTOF, interestingTOT, interestingADC,
1480 parTOF, posClus, check);
1482 for (jj=0; jj<5; jj++) det[jj] = -1;
1483 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
1484 tofGeometry->GetDetID(posF, det);
1486 volIdClus = GetClusterVolIndex(det);
1488 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1489 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
1490 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
1491 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
1492 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
1494 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1495 Int_t ** indDet = new Int_t*[2];
1496 for (jj=0; jj<2; jj++) indDet[jj] = new Int_t [5];
1497 for (jj=0; jj<2; jj++) indDet[jj][0] = nSector;
1498 for (jj=0; jj<2; jj++) indDet[jj][1] = nPlate;
1499 for (jj=0; jj<2; jj++) indDet[jj][2] = nStrip;
1500 for (jj=0; jj<2; jj++) indDet[jj][3] = padsCluster[2*jj+3];
1501 for (jj=0; jj<2; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
1502 GetClusterPars(check, 2, indDet, interestingWeight, posClus, covClus);
1503 for (jj=0; jj<2; jj++) delete [] indDet[jj];
1505 // To fill the track index array
1507 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1508 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1509 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
1512 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
1515 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1516 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
1519 alreadyStored = kFALSE;
1520 for (jj=0; jj<dummyCounter+1; jj++)
1521 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
1523 if (alreadyStored) continue;
1524 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
1525 AliWarning(" Siamo al limite!");
1530 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
1537 AliTOFcluster *tofCluster =
1538 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
1539 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1540 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
1541 InsertCluster(tofCluster);
1543 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",
1544 volIdClus, posClus[0], posClus[1], posClus[2],
1545 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1546 tracks[0], tracks[1], tracks[2],
1547 det[0], det[1], det[2], det[3], det[4],
1548 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
1549 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
1554 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
1558 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
1561 } // close loop on second digit
1562 } // close loop on adesso2
1564 } // close loop on first digit
1565 } // close loop on adesso1
1567 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1568 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1569 selectedDigit[ii][jj] = 0x0;
1573 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1574 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
1575 delete selectedDigit[ii][jj];
1576 selectedDigit[ii][jj] = 0x0;
1581 //_____________________________________________________________________________
1583 void AliTOFClusterFinderV1::FindClusters24(Int_t nSector,
1588 // This function searches the neighbouring digits (stored in the fDigits object),
1589 // to perform clusters (stored in the fTofClusters array).
1591 // This research has been made by checking the fTOFdigitMap object,
1592 // filled at digits/raw-data reading time.
1595 const Int_t kMaxNumberOfInterestingPads = 4;
1596 const Int_t kMaxNumberOfTracksPerDigit = 3;
1597 const Int_t kMaxNumberOfDigitsPerVolume = 3;
1601 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
1602 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1603 digitsInVolumeIndices[ii] = -1;
1605 AliTOFGeometry *tofGeometry = new AliTOFGeometry();
1606 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
1608 Float_t pos[3] = {0.,0.,0.};
1611 Int_t interestingPadX[kMaxNumberOfInterestingPads];
1612 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
1613 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
1614 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
1615 Double_t interestingTOT[kMaxNumberOfInterestingPads];
1616 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
1617 Double_t interestingADC[kMaxNumberOfInterestingPads];
1618 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
1619 Double_t interestingTOF[kMaxNumberOfInterestingPads];
1620 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
1621 Double_t interestingWeight[kMaxNumberOfInterestingPads];
1622 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
1624 Float_t interestingX[kMaxNumberOfInterestingPads];
1625 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
1626 Float_t interestingY[kMaxNumberOfInterestingPads];
1627 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
1628 Float_t interestingZ[kMaxNumberOfInterestingPads];
1629 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
1631 Float_t interDigit[kMaxNumberOfInterestingPads];
1632 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
1634 Int_t padsCluster[11];
1635 padsCluster[0] = nSector;
1636 padsCluster[1] = nPlate;
1637 padsCluster[2] = nStrip;
1638 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1640 Int_t interestingCounter=-1;
1645 Bool_t check = kFALSE;
1647 for (jj=0; jj<5; jj++) parTOF[jj] = 0;
1648 Double_t posClus[3];
1649 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
1651 for (jj=0; jj<5; jj++) det[jj] = -1;
1653 for (jj=0; jj<3; jj++) posF[jj] = 0.;
1654 UShort_t volIdClus = 0;
1655 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
1656 Double_t covClus[6];
1657 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1658 Int_t tracks[kMaxNumberOfTracksPerDigit];
1659 for (jj=0; jj<3; jj++) tracks[jj] = -1;
1660 Int_t dummyCounter=-1;
1661 Bool_t alreadyStored = kFALSE;
1663 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
1664 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1665 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
1667 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1668 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
1670 AliTOFdigit *digitInteresting;
1672 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
1674 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
1675 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
1677 AliDebug(3, Form("%2i %1i %2i\n", iPad, iPadZ, iPadX));
1684 interestingCounter=-1;
1686 vol[4] = iPadZ , vol[3] = iPadX;
1687 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1688 interestingCounter++;
1690 vol[4] = iPadZ, vol[3] = iPadX+1;
1691 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1692 interestingCounter++;
1694 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1695 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1696 interestingCounter++;
1698 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1699 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1700 interestingCounter++;
1702 if (interestingCounter+1!=4) continue; // the hit pads have to be 4
1703 else interestingCounter=-1;
1706 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1707 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1708 selectedDigit[ii][jj] = 0x0;
1711 vol[4] = iPadZ, vol[3] = iPadX;
1713 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1714 interestingCounter++;
1715 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1716 digitsInVolumeIndices[ii] = -1;
1717 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1718 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1719 if (digitsInVolumeIndices[digIndex]<0) continue;
1720 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1722 AliDebug(1,Form(" %2i %1i %2i %1i %2i %f %f %f %f %5i %5i %5i %5i",
1723 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1724 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1725 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1726 digitsInVolumeIndices[digIndex],
1727 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1730 selectedDigit[interestingCounter][digIndex] = new
1731 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1732 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1733 digitInteresting->GetToT()*digitInteresting->GetToT(),
1734 digitsInVolumeIndices[digIndex],
1735 digitInteresting->GetTracks());
1740 vol[4] = iPadZ, vol[3] = iPadX+1;
1742 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1743 interestingCounter++;
1744 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1745 digitsInVolumeIndices[ii] = -1;
1746 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1747 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1748 if (digitsInVolumeIndices[digIndex]<0) continue;
1749 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1751 AliDebug(1,Form(" %2i %1i %2i %1i %2i %f %f %f %f %5i %5i %5i %5i",
1752 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1753 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1754 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1755 digitsInVolumeIndices[digIndex],
1756 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1759 selectedDigit[interestingCounter][digIndex] = new
1760 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1761 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1762 digitInteresting->GetToT()*digitInteresting->GetToT(),
1763 digitsInVolumeIndices[digIndex],
1764 digitInteresting->GetTracks());
1769 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1771 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1772 interestingCounter++;
1773 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1774 digitsInVolumeIndices[ii] = -1;
1775 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1776 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1777 if (digitsInVolumeIndices[digIndex]<0) continue;
1778 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1780 AliDebug(1,Form(" %2i %1i %2i %1i %2i %f %f %f %f %5i %5i %5i %5i",
1781 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1782 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1783 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1784 digitsInVolumeIndices[digIndex],
1785 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1788 selectedDigit[interestingCounter][digIndex] = new
1789 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1790 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1791 digitInteresting->GetToT()*digitInteresting->GetToT(),
1792 digitsInVolumeIndices[digIndex],
1793 digitInteresting->GetTracks());
1798 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1800 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1801 interestingCounter++;
1802 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1803 digitsInVolumeIndices[ii] = -1;
1804 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1805 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1806 if (digitsInVolumeIndices[digIndex]<0) continue;
1807 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1809 AliDebug(1,Form(" %2i %1i %2i %1i %2i %f %f %f %f %5i %5i %5i %5i",
1810 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1811 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1812 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1813 digitsInVolumeIndices[digIndex],
1814 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1817 selectedDigit[interestingCounter][digIndex] = new
1818 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1819 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1820 digitInteresting->GetToT()*digitInteresting->GetToT(),
1821 digitsInVolumeIndices[digIndex],
1822 digitInteresting->GetTracks());
1826 AliDebug(1,Form(" e adesso %1i", interestingCounter+1));
1828 for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
1829 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
1830 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
1832 for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
1833 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
1834 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
1836 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime) continue;
1838 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
1839 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
1840 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
1841 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
1842 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
1843 AliDebug(1,Form(" %2i %1i %2i %1i %2i", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
1844 Int_t volDum = vol1[3];
1847 tofGeometry->GetPosPar(vol1,pos);
1848 interestingX[0] = pos[0];
1849 interestingY[0] = pos[1];
1850 interestingZ[0] = pos[2];
1852 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
1853 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
1854 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
1855 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
1856 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
1857 AliDebug(1,Form(" %2i %1i %2i %1i %2i", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
1861 tofGeometry->GetPosPar(vol2,pos);
1862 interestingX[1] = pos[0];
1863 interestingY[1] = pos[1];
1864 interestingZ[1] = pos[2];
1867 AverageCalculations(2, interestingX, interestingY, interestingZ,
1868 interestingTOF, interestingTOT, interestingADC,
1870 parTOF, posClus, check);
1872 for (jj=0; jj<5; jj++) det[jj] = -1;
1873 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
1874 tofGeometry->GetDetID(posF, det);
1876 volIdClus = GetClusterVolIndex(det);
1878 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1879 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
1880 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
1881 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
1882 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
1884 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1885 Int_t ** indDet = new Int_t*[2];
1886 for (jj=0; jj<2; jj++) indDet[jj] = new Int_t [5];
1887 for (jj=0; jj<2; jj++) indDet[jj][0] = nSector;
1888 for (jj=0; jj<2; jj++) indDet[jj][1] = nPlate;
1889 for (jj=0; jj<2; jj++) indDet[jj][2] = nStrip;
1890 for (jj=0; jj<2; jj++) indDet[jj][3] = padsCluster[2*jj+3];
1891 for (jj=0; jj<2; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
1892 GetClusterPars(check, 2, indDet, interestingWeight, posClus, covClus);
1893 for (jj=0; jj<2; jj++) delete [] indDet[jj];
1895 // To fill the track index array
1897 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1898 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1899 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
1902 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
1905 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1906 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
1909 alreadyStored = kFALSE;
1910 for (jj=0; jj<dummyCounter+1; jj++)
1911 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
1913 if (alreadyStored) continue;
1914 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
1915 AliWarning(" Siamo al limite!");
1920 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
1927 AliTOFcluster *tofCluster =
1928 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
1929 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1930 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
1931 InsertCluster(tofCluster);
1933 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",
1934 volIdClus, posClus[0], posClus[1], posClus[2],
1935 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1936 tracks[0], tracks[1], tracks[2],
1937 det[0], det[1], det[2], det[3], det[4],
1938 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
1939 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
1944 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
1948 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
1951 } // close loop on second digit
1952 } // close loop on adesso2
1954 } // close loop on first digit
1955 } // close loop on adesso1
1957 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1958 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1959 selectedDigit[ii][jj] = 0x0;
1963 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1964 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
1965 delete selectedDigit[ii][jj];
1966 selectedDigit[ii][jj] = 0x0;
1971 //_____________________________________________________________________________
1973 void AliTOFClusterFinderV1::FindClustersPerStrip(Int_t nSector,
1979 // This function searches the neighbouring digits (stored in the fDigits object),
1980 // to perform clusters (stored in the fTofClusters array).
1982 // Each strip is read four times:
1983 // - 1st time: it searches possible clusters formed by four
1984 // neighbouring digits;
1985 // - 2nd time: it searches possible clusters formed by three
1986 // neighbouring digits;
1987 // - 3rd time: it searches possible clusters formed by two
1988 // neighbouring digits;
1989 // - 4th time: the remaining isolated digits have been transformed
1991 // This research has been made by checking the fTOFdigitMap object,
1992 // filled at digits/raw-data reading time.
1995 const Int_t kMaxNumberOfInterestingPads = 4;
1996 const Int_t kMaxNumberOfTracksPerDigit = 3;
1997 const Int_t kMaxNumberOfDigitsPerVolume = 3;
2001 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
2002 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2003 digitsInVolumeIndices[ii] = -1;
2005 AliTOFGeometry *tofGeometry = new AliTOFGeometry();
2007 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
2009 Float_t pos[3] = {0.,0.,0.};
2012 Int_t interestingPadX[kMaxNumberOfInterestingPads];
2013 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
2014 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
2015 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
2016 Double_t interestingTOT[kMaxNumberOfInterestingPads];
2017 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
2018 Double_t interestingADC[kMaxNumberOfInterestingPads];
2019 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
2020 Double_t interestingTOF[kMaxNumberOfInterestingPads];
2021 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
2022 Double_t interestingWeight[kMaxNumberOfInterestingPads];
2023 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
2025 Float_t interestingX[kMaxNumberOfInterestingPads];
2026 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
2027 Float_t interestingY[kMaxNumberOfInterestingPads];
2028 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
2029 Float_t interestingZ[kMaxNumberOfInterestingPads];
2030 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
2032 Float_t interDigit[kMaxNumberOfInterestingPads];
2033 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
2035 Int_t padsCluster[11];
2036 padsCluster[0] = nSector;
2037 padsCluster[1] = nPlate;
2038 padsCluster[2] = nStrip;
2039 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2041 Int_t interestingCounter=-1;
2046 Bool_t check = kFALSE;
2048 for (jj=0; jj<5; jj++) parTOF[jj] = 0;
2049 Double_t posClus[3];
2050 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
2052 for (jj=0; jj<5; jj++) det[jj] = -1;
2054 for (jj=0; jj<3; jj++) posF[jj] = 0.;
2055 UShort_t volIdClus = 0;
2056 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
2057 Double_t covClus[6];
2058 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2059 Int_t tracks[kMaxNumberOfTracksPerDigit];
2060 for (jj=0; jj<3; jj++) tracks[jj] = -1;
2061 Int_t dummyCounter=-1;
2062 Bool_t alreadyStored = kFALSE;
2064 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
2065 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2066 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
2068 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2069 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
2071 AliTOFdigit *digitInteresting;
2075 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
2077 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
2078 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
2080 AliDebug(3, Form("%2i %1i %2i\n", iPad, iPadZ, iPadX));
2087 interestingCounter=-1;
2089 vol[4] = iPadZ , vol[3] = iPadX;
2090 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2091 interestingCounter++;
2093 vol[4] = iPadZ, vol[3] = iPadX+1;
2094 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2095 interestingCounter++;
2097 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
2098 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2099 interestingCounter++;
2101 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
2102 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2103 interestingCounter++;
2105 if (interestingCounter!=group) continue;
2106 else interestingCounter=-1;
2109 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2110 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
2111 selectedDigit[ii][jj] = 0x0;
2114 vol[4] = iPadZ, vol[3] = iPadX;
2116 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2117 interestingCounter++;
2118 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2119 digitsInVolumeIndices[ii] = -1;
2120 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2121 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2122 if (digitsInVolumeIndices[digIndex]<0) continue;
2123 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2125 AliDebug(1,Form(" %2i %1i %2i %1i %2i %f %f %f %f %5i %5i %5i %5i",
2126 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2127 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2128 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2129 digitsInVolumeIndices[digIndex],
2130 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2133 selectedDigit[interestingCounter][digIndex] = new
2134 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2135 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2136 digitInteresting->GetToT()*digitInteresting->GetToT(),
2137 digitsInVolumeIndices[digIndex],
2138 digitInteresting->GetTracks());
2143 vol[4] = iPadZ, vol[3] = iPadX+1;
2145 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2146 interestingCounter++;
2147 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2148 digitsInVolumeIndices[ii] = -1;
2149 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2150 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2151 if (digitsInVolumeIndices[digIndex]<0) continue;
2152 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2154 AliDebug(1,Form(" %2i %1i %2i %1i %2i %f %f %f %f %5i %5i %5i %5i",
2155 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2156 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2157 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2158 digitsInVolumeIndices[digIndex],
2159 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2162 selectedDigit[interestingCounter][digIndex] = new
2163 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2164 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2165 digitInteresting->GetToT()*digitInteresting->GetToT(),
2166 digitsInVolumeIndices[digIndex],
2167 digitInteresting->GetTracks());
2172 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
2174 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2175 interestingCounter++;
2176 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2177 digitsInVolumeIndices[ii] = -1;
2178 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2179 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2180 if (digitsInVolumeIndices[digIndex]<0) continue;
2181 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2183 AliDebug(1,Form(" %2i %1i %2i %1i %2i %f %f %f %f %5i %5i %5i %5i",
2184 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2185 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2186 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2187 digitsInVolumeIndices[digIndex],
2188 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2191 selectedDigit[interestingCounter][digIndex] = new
2192 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2193 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2194 digitInteresting->GetToT()*digitInteresting->GetToT(),
2195 digitsInVolumeIndices[digIndex],
2196 digitInteresting->GetTracks());
2201 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
2203 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2204 interestingCounter++;
2205 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2206 digitsInVolumeIndices[ii] = -1;
2207 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2208 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2209 if (digitsInVolumeIndices[digIndex]<0) continue;
2210 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2212 AliDebug(1,Form(" %2i %1i %2i %1i %2i %f %f %f %f %5i %5i %5i %5i",
2213 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2214 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2215 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2216 digitsInVolumeIndices[digIndex],
2217 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2220 selectedDigit[interestingCounter][digIndex] = new
2221 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2222 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2223 digitInteresting->GetToT()*digitInteresting->GetToT(),
2224 digitsInVolumeIndices[digIndex],
2225 digitInteresting->GetTracks());
2229 AliDebug(1,Form(" e adesso %1i", interestingCounter+1));
2231 switch(interestingCounter+1) {
2235 for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
2236 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2237 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2239 for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
2240 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2241 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2243 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime) continue;
2245 AliDebug(1, Form(" %1i %1i (0x%x) %1i %1i (0x%x)", adesso1, firstIndex,selectedDigit[adesso1][firstIndex],
2246 adesso2, secondIndex,selectedDigit[adesso2][secondIndex]));
2248 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2249 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2250 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2251 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2252 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
2253 AliDebug(1,Form(" %2i %1i %2i %1i %2i", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
2254 Int_t volDum = vol1[3];
2257 tofGeometry->GetPosPar(vol1,pos);
2258 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
2259 interestingX[0] = pos[0];
2260 interestingY[0] = pos[1];
2261 interestingZ[0] = pos[2];
2263 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2264 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2265 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2266 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2267 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
2268 AliDebug(1,Form(" %2i %1i %2i %1i %2i", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
2272 tofGeometry->GetPosPar(vol2,pos);
2273 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
2274 interestingX[1] = pos[0];
2275 interestingY[1] = pos[1];
2276 interestingZ[1] = pos[2];
2279 AverageCalculations(interestingCounter+1,
2280 interestingX, interestingY, interestingZ,
2281 interestingTOF, interestingTOT, interestingADC,
2283 parTOF, posClus, check);
2285 for (jj=0; jj<5; jj++) det[jj] = -1;
2286 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
2288 AliDebug(1,Form(" %f %f %f", posF[0], posF[1], posF[2]));
2289 tofGeometry->GetDetID(posF, det);
2290 AliDebug(1,Form(" %2i %1i %2i %1i %2i", det[0], det[1], det[2], det[3], det[4]));
2292 volIdClus = GetClusterVolIndex(det);
2294 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2295 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
2296 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
2297 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
2298 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
2300 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2301 Int_t ** indDet = new Int_t*[interestingCounter+1];
2302 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj] = new Int_t [5];
2303 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][0] = nSector;
2304 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][1] = nPlate;
2305 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][2] = nStrip;
2306 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][3] = padsCluster[2*jj+3];
2307 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
2308 GetClusterPars(check, interestingCounter+1, indDet, interestingWeight, posClus, covClus);
2309 for (jj=0; jj<interestingCounter+1; jj++) delete [] indDet[jj];
2311 // To fill the track index array
2313 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2314 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2315 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
2318 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
2321 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2322 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
2325 alreadyStored = kFALSE;
2326 for (jj=0; jj<dummyCounter+1; jj++)
2327 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
2329 if (alreadyStored) continue;
2330 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2331 AliWarning(" Siamo al limite!");
2336 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
2343 AliTOFcluster *tofCluster =
2344 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
2345 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2346 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); //to updated
2347 InsertCluster(tofCluster);
2349 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",
2350 volIdClus, posClus[0], posClus[1], posClus[2],
2351 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2352 tracks[0], tracks[1], tracks[2],
2353 det[0], det[1], det[2], det[3], det[4],
2354 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
2355 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
2360 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
2364 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
2367 } // close loop on second digit
2368 } // close loop on adesso2
2370 } // close loop on first digit
2371 } // close loop on adesso1
2378 for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
2379 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2380 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2382 for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
2383 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2384 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2386 for (Int_t adesso3=adesso2+1; adesso3<interestingCounter+1; adesso3++) {
2387 for (Int_t thirdIndex=0; thirdIndex<kMaxNumberOfDigitsPerVolume; thirdIndex++) {
2388 if (selectedDigit[adesso3][thirdIndex]==0x0) continue;
2391 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime
2393 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
2395 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime) continue;
2397 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2398 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2399 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2400 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2401 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
2402 AliDebug(1,Form(" %2i %1i %2i %1i %2i", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
2403 Int_t volDum = vol1[3];
2406 tofGeometry->GetPosPar(vol1,pos);
2407 interestingX[0] = pos[0];
2408 interestingY[0] = pos[1];
2409 interestingZ[0] = pos[2];
2411 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2412 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2413 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2414 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2415 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
2416 AliDebug(1,Form(" %2i %1i %2i %1i %2i", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
2420 tofGeometry->GetPosPar(vol2,pos);
2421 interestingX[1] = pos[0];
2422 interestingY[1] = pos[1];
2423 interestingZ[1] = pos[2];
2425 interestingTOF[2] = selectedDigit[adesso3][thirdIndex]->GetTDC();
2426 interestingTOT[2] = selectedDigit[adesso3][thirdIndex]->GetTOT();
2427 interestingADC[2] = selectedDigit[adesso3][thirdIndex]->GetADC();
2428 interestingWeight[2] = selectedDigit[adesso3][thirdIndex]->GetWeight();
2429 Int_t vol3[5]; for(jj=0; jj<5; jj++) vol3[jj] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(jj);
2430 AliDebug(1,Form(" %2i %1i %2i %1i %2i", vol3[0], vol3[1], vol3[2], vol3[4], vol3[3]));
2434 tofGeometry->GetPosPar(vol3,pos);
2435 interestingX[2] = pos[0];
2436 interestingY[2] = pos[1];
2437 interestingZ[2] = pos[2];
2440 AverageCalculations(interestingCounter+1,
2441 interestingX, interestingY, interestingZ,
2442 interestingTOF, interestingTOT, interestingADC,
2444 parTOF, posClus, check);
2446 for (jj=0; jj<5; jj++) det[jj] = -1;
2447 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
2448 tofGeometry->GetDetID(posF, det);
2450 volIdClus = GetClusterVolIndex(det);
2452 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2453 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
2454 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
2455 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
2456 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
2457 padsCluster[7] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(4);
2458 padsCluster[8] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(3);
2460 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2461 Int_t ** indDet = new Int_t*[interestingCounter+1];
2462 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj] = new Int_t [5];
2463 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][0] = nSector;
2464 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][1] = nPlate;
2465 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][2] = nStrip;
2466 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][3] = padsCluster[2*jj+3];
2467 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
2468 GetClusterPars(check, interestingCounter+1, indDet, interestingWeight, posClus, covClus);
2469 for (jj=0; jj<interestingCounter+1; jj++) delete [] indDet[jj];
2471 // To fill the track index array
2473 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2474 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2475 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
2478 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
2481 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2482 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
2485 alreadyStored = kFALSE;
2486 for (jj=0; jj<dummyCounter+1; jj++)
2487 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
2489 if (alreadyStored) continue;
2490 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2491 AliWarning(" Siamo al limite!");
2496 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
2501 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2502 if (selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk)==-1) continue;
2505 alreadyStored = kFALSE;
2506 for (jj=0; jj<dummyCounter+1; jj++)
2507 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk));
2509 if (alreadyStored) continue;
2510 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2511 AliWarning(" Siamo al limite!");
2516 tracks[dummyCounter] = selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk);
2523 AliTOFcluster *tofCluster =
2524 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
2525 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2526 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
2527 InsertCluster(tofCluster);
2529 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",
2530 volIdClus, posClus[0], posClus[1], posClus[2],
2531 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2532 tracks[0], tracks[1], tracks[2],
2533 det[0], det[1], det[2], det[3], det[4],
2534 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
2535 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
2540 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
2544 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
2548 fTOFdigitMap->ResetDigitNumber(vol3,selectedDigit[adesso3][thirdIndex]->GetIndex());
2551 } // close loop on third digit
2552 } // close loop on adesso3
2554 } // close loop on second digit
2555 } // close loop on adesso2
2557 } // close loop on first digit
2558 } // close loop on adesso1
2566 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2567 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2570 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2571 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2574 for (Int_t thirdIndex=0; thirdIndex<kMaxNumberOfDigitsPerVolume; thirdIndex++) {
2575 if (selectedDigit[adesso3][thirdIndex]==0x0) continue;
2578 for (Int_t fourthIndex=0; fourthIndex<kMaxNumberOfDigitsPerVolume; fourthIndex++) {
2579 if (selectedDigit[adesso4][fourthIndex]==0x0) continue;
2582 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime
2584 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
2586 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso4][fourthIndex]->GetTDC())>fMaxDeltaTime
2588 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
2590 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso4][fourthIndex]->GetTDC())>fMaxDeltaTime
2592 TMath::Abs(selectedDigit[adesso3][thirdIndex]->GetTDC()-selectedDigit[adesso4][fourthIndex]->GetTDC())>fMaxDeltaTime) continue;
2594 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2595 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2596 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2597 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2598 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
2599 AliDebug(1,Form(" %2i %1i %2i %1i %2i", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
2600 Int_t volDum = vol1[3];
2603 tofGeometry->GetPosPar(vol1,pos);
2604 interestingX[0] = pos[0];
2605 interestingY[0] = pos[1];
2606 interestingZ[0] = pos[2];
2608 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2609 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2610 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2611 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2612 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
2613 AliDebug(1,Form(" %2i %1i %2i %1i %2i", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
2617 tofGeometry->GetPosPar(vol2,pos);
2618 interestingX[1] = pos[0];
2619 interestingY[1] = pos[1];
2620 interestingZ[1] = pos[2];
2622 interestingTOF[2] = selectedDigit[adesso3][thirdIndex]->GetTDC();
2623 interestingTOT[2] = selectedDigit[adesso3][thirdIndex]->GetTOT();
2624 interestingADC[2] = selectedDigit[adesso3][thirdIndex]->GetADC();
2625 interestingWeight[2] = selectedDigit[adesso3][thirdIndex]->GetWeight();
2626 Int_t vol3[5]; for(jj=0; jj<5; jj++) vol3[jj] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(jj);
2627 AliDebug(1,Form(" %2i %1i %2i %1i %2i", vol3[0], vol3[1], vol3[2], vol3[4], vol3[3]));
2631 tofGeometry->GetPosPar(vol3,pos);
2632 interestingX[2] = pos[0];
2633 interestingY[2] = pos[1];
2634 interestingZ[2] = pos[2];
2636 interestingTOF[3] = selectedDigit[adesso4][fourthIndex]->GetTDC();
2637 interestingTOT[3] = selectedDigit[adesso4][fourthIndex]->GetTOT();
2638 interestingADC[3] = selectedDigit[adesso4][fourthIndex]->GetADC();
2639 interestingWeight[3] = selectedDigit[adesso4][fourthIndex]->GetWeight();
2640 Int_t vol4[5]; for(jj=0; jj<5; jj++) vol4[jj] = selectedDigit[adesso4][fourthIndex]->GetDetectorIndex(jj);
2641 AliDebug(1,Form(" %2i %1i %2i %1i %2i", vol4[0], vol4[1], vol4[2], vol4[4], vol4[3]));
2645 tofGeometry->GetPosPar(vol4,pos);
2646 interestingX[3] = pos[0];
2647 interestingY[3] = pos[1];
2648 interestingZ[3] = pos[2];
2651 AverageCalculations(interestingCounter+1,
2652 interestingX, interestingY, interestingZ,
2653 interestingTOF, interestingTOT, interestingADC,
2655 parTOF, posClus, check);
2657 for (jj=0; jj<5; jj++) det[jj] = -1;
2658 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
2659 tofGeometry->GetDetID(posF, det);
2661 volIdClus = GetClusterVolIndex(det);
2663 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2664 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
2665 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
2666 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
2667 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
2668 padsCluster[7] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(4);
2669 padsCluster[8] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(3);
2670 padsCluster[9] = selectedDigit[adesso4][fourthIndex]->GetDetectorIndex(4);
2671 padsCluster[10] = selectedDigit[adesso4][fourthIndex]->GetDetectorIndex(3);
2673 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2674 Int_t ** indDet = new Int_t*[interestingCounter+1];
2675 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj] = new Int_t [5];
2676 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][0] = nSector;
2677 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][1] = nPlate;
2678 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][2] = nStrip;
2679 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][3] = padsCluster[2*jj+3];
2680 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
2681 GetClusterPars(check, interestingCounter+1, indDet, interestingWeight, posClus, covClus);
2682 for (jj=0; jj<interestingCounter+1; jj++) delete [] indDet[jj];
2684 // To fill the track index array
2686 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2687 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2688 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
2691 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
2694 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2695 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
2698 alreadyStored = kFALSE;
2699 for (jj=0; jj<dummyCounter+1; jj++)
2700 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
2702 if (alreadyStored) continue;
2703 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2704 AliWarning(" Siamo al limite!");
2709 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
2714 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2715 if (selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk)==-1) continue;
2718 alreadyStored = kFALSE;
2719 for (jj=0; jj<dummyCounter+1; jj++)
2720 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk));
2722 if (alreadyStored) continue;
2723 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2724 AliWarning(" Siamo al limite!");
2729 tracks[dummyCounter] = selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk);
2734 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2735 if (selectedDigit[adesso4][fourthIndex]->GetTrackLabel(kk)==-1) continue;
2738 alreadyStored = kFALSE;
2739 for (jj=0; jj<dummyCounter+1; jj++)
2740 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso4][fourthIndex]->GetTrackLabel(kk));
2742 if (alreadyStored) continue;
2743 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2744 AliWarning(" Siamo al limite!");
2749 tracks[dummyCounter] = selectedDigit[adesso4][fourthIndex]->GetTrackLabel(kk);
2756 AliTOFcluster *tofCluster =
2757 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
2758 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2759 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
2760 InsertCluster(tofCluster);
2762 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",
2763 volIdClus, posClus[0], posClus[1], posClus[2],
2764 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2765 tracks[0], tracks[1], tracks[2],
2766 det[0], det[1], det[2], det[3], det[4],
2767 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
2768 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
2773 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
2777 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
2781 fTOFdigitMap->ResetDigitNumber(vol3,selectedDigit[adesso3][thirdIndex]->GetIndex());
2785 fTOFdigitMap->ResetDigitNumber(vol4,selectedDigit[adesso4][fourthIndex]->GetIndex());
2788 } // close loop on fourth digit
2790 } // close loop on third digit
2792 } // close loop on second digit
2794 } // close loop on first digit
2800 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2801 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
2802 selectedDigit[ii][jj] = 0x0;
2806 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2807 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
2808 delete selectedDigit[ii][jj];
2809 selectedDigit[ii][jj] = 0x0;
2813 //_____________________________________________________________________________
2815 Int_t AliTOFClusterFinderV1::InsertCluster(AliTOFcluster *tofCluster)
2818 // This function adds a TOF cluster to the array of TOF clusters
2819 // sorted in Z, i.e. fTofClusters
2822 if (fNumberOfTofClusters==kTofMaxCluster) {
2823 AliError("Too many clusters !");
2827 if (fNumberOfTofClusters==0) {
2828 fTofClusters[fNumberOfTofClusters++] = tofCluster;
2832 Int_t ii = FindClusterIndex(tofCluster->GetZ());
2833 memmove(fTofClusters+ii+1 ,fTofClusters+ii,(fNumberOfTofClusters-ii)*sizeof(AliTOFcluster*));
2834 fTofClusters[ii] = tofCluster;
2835 fNumberOfTofClusters++;
2840 //_____________________________________________________________________________
2842 Int_t AliTOFClusterFinderV1::FindClusterIndex(Double_t z) const
2845 // This function returns the index of the nearest cluster in z
2848 if (fNumberOfTofClusters==0) return 0;
2849 if (z <= fTofClusters[0]->GetZ()) return 0;
2850 if (z > fTofClusters[fNumberOfTofClusters-1]->GetZ()) return fNumberOfTofClusters;
2851 Int_t b = 0, e = fNumberOfTofClusters-1, m = (b+e)/2;
2852 for (; b<e; m=(b+e)/2) {
2853 if (z > fTofClusters[m]->GetZ()) b=m+1;
2860 //_____________________________________________________________________________
2862 void AliTOFClusterFinderV1::ResetRecpoint()
2865 // Clear the list of reconstructed points
2868 fNumberOfTofClusters = 0;
2869 if (fRecPoints) fRecPoints->Clear();
2872 //_____________________________________________________________________________
2874 void AliTOFClusterFinderV1::ResetDigits()
2877 // Clear the list of digits
2880 fNumberOfTofDigits = 0;
2881 if (fDigits) fDigits->Clear();
2884 //_____________________________________________________________________________
2886 UShort_t AliTOFClusterFinderV1::GetClusterVolIndex(Int_t *ind) const
2889 // Get the volume ID to retrieve the l2t transformation
2892 // Detector numbering scheme
2893 Int_t nSector = AliTOFGeometry::NSectors();
2894 Int_t nPlate = AliTOFGeometry::NPlates();
2895 Int_t nStripA = AliTOFGeometry::NStripA();
2896 Int_t nStripB = AliTOFGeometry::NStripB();
2897 Int_t nStripC = AliTOFGeometry::NStripC();
2899 Int_t isector =ind[0];
2900 if (isector >= nSector)
2901 AliError(Form("Wrong sector number in TOF (%d) !", isector));
2902 Int_t iplate = ind[1];
2903 if (iplate >= nPlate)
2904 AliError(Form("Wrong plate number in TOF (%d) !", iplate));
2905 Int_t istrip = ind[2];
2907 Int_t stripOffset = 0;
2913 stripOffset = nStripC;
2916 stripOffset = nStripC+nStripB;
2919 stripOffset = nStripC+nStripB+nStripA;
2922 stripOffset = nStripC+nStripB+nStripA+nStripB;
2925 AliError(Form("Wrong plate number in TOF (%d) !", iplate));
2929 Int_t index= (2*(nStripC+nStripB)+nStripA)*isector +
2933 UShort_t volIndex = AliGeomManager::LayerToVolUID(AliGeomManager::kTOF, index);
2937 //_____________________________________________________________________________
2939 void AliTOFClusterFinderV1::GetClusterPars(Int_t *ind, Double_t* pos, Double_t* cov) const
2942 // Starting from the volume indices (ind[5]), for a cluster coming from
2943 // a isolated digits, this function returns:
2944 // the cluster position (pos),
2945 // the cluster covariance matrix elements (cov)
2949 //we now go in the system of the strip: determine the local coordinates
2952 // 47---------------------------------------------------0 ^ z
2953 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 1 |
2954 // ----------------------------------------------------- | y going outwards
2955 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 0 | par[0]=0;
2957 // ----------------------------------------------------- |
2958 // x <-----------------------------------------------------
2960 //move to the tracking ref system
2961 Double_t lpos[3] = { (ind[4]-23.5)*AliTOFGeometry::XPad(),
2963 (ind[3]- 0.5)*AliTOFGeometry::ZPad() };
2964 AliDebug(1, Form(" %f %f %f", lpos[0], lpos[1], lpos[2]));
2967 UShort_t volIndex = GetClusterVolIndex(ind);
2968 const TGeoHMatrix *l2t = AliGeomManager::GetTracking2LocalMatrix(volIndex);
2970 // Get the position in the track ref system
2972 l2t->MasterToLocal(lpos,tpos);
2977 //Get the cluster covariance in the track ref system
2979 for (Int_t ii=0; ii<9; ii++) lcov[ii] = 0.;
2981 //cluster covariance in the local system:
2986 lcov[4] = 0.42*0.42/3.;
2987 // = ( 5*0.025 (gas gaps thikness)
2988 // + 4*0.040 (internal glasses thickness)
2989 // + 0.5*0.160 (internl PCB)
2990 // + 1*0.055 (external red glass))
2992 lcov[0] = 0.499678;//AliTOFGeometry::XPad()*AliTOFGeometry::XPad()/12.;
2993 lcov[8] = 0.992429;//AliTOFGeometry::ZPad()*AliTOFGeometry::ZPad()/12.;
2995 //cluster covariance in the tracking system:
2997 m.SetRotation(lcov);
2999 m.MultiplyLeft(&l2t->Inverse());
3000 Double_t *tcov = m.GetRotationMatrix();
3001 cov[0] = tcov[0]; cov[1] = tcov[1]; cov[2] = tcov[2];
3002 cov[3] = tcov[4]; cov[4] = tcov[5]; cov[5] = tcov[8];
3007 //_____________________________________________________________________________
3009 void AliTOFClusterFinderV1::GetClusterPars(Bool_t check, Int_t counter,
3010 Int_t **ind, Double_t *weight,
3011 Double_t *pos, Double_t *cov) const
3015 // the volumes indices (ind[counter][5]), for a
3016 // cluster coming from a collection of 'counter'
3018 // the volumes weights (weight[counter]), -controlled
3019 // by the 'check' variable control-, for a cluster
3020 // coming from a collection of 'counter' digits,
3021 // the cluster position (pos),
3022 // this function returns:
3023 // the covariance matrix elements (cov) for the found cluster
3027 // we now go in the system of the strip: determine the local coordinates
3029 // 47---------------------------------------------------0 ^ z
3030 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 1 |
3031 // ----------------------------------------------------- | y going outwards
3032 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 0 | par[0]=0;
3034 // ----------------------------------------------------- |
3035 // x <-----------------------------------------------------
3037 for (Int_t ii=0; ii<counter; ii++)
3038 AliDebug(1, Form(" %2i %2i %1i %2i %1i %2i ",
3039 ii, ind[ii][0], ind[ii][1], ind[ii][2], ind[ii][3], ind[ii][4]));
3041 Float_t posF[3]; for (Int_t ii=0; ii<3; ii++) posF[ii] = (Float_t)pos[ii];
3042 AliDebug(1, Form(" %f %f %f", pos[0], pos[1], pos[2]));
3043 AliTOFGeometry tofGeom;
3044 Int_t detClus[5] = {-1, -1, -1, -1, -1};
3045 tofGeom.GetDetID(posF, detClus);
3048 UShort_t volIndex = GetClusterVolIndex(detClus);
3049 AliDebug(1, Form(" %2i %1i %2i %1i %2i %7i",
3050 detClus[0], detClus[1], detClus[2], detClus[3], detClus[4], volIndex));
3052 // Get the position in the TOF strip ref system
3053 const TGeoHMatrix *alice2strip = AliGeomManager::GetOrigGlobalMatrix(volIndex);
3054 Double_t ppos[3] = {-1, -1, -1};
3055 alice2strip->MasterToLocal(pos,ppos);
3056 AliDebug(1, Form(" %f %f %f", ppos[0], ppos[1], ppos[2]));
3059 // Get the position in the tracking ref system
3060 const TGeoHMatrix *g2l = AliGeomManager::GetTracking2LocalMatrix(volIndex);
3061 Double_t lpos[3] = {-1, -1, -1};
3062 g2l->MasterToLocal(ppos,lpos);
3063 AliDebug(1, Form(" %f %f %f", lpos[0], lpos[1], lpos[2]));
3064 for (Int_t ii=0; ii<3; ii++) pos[ii] = lpos[ii];
3066 //Get the cluster covariance in the track ref system
3068 for (Int_t ii=0; ii<9; ii++) lcov[ii] = 0.;
3070 //cluster covariance in the local system:
3075 // Evaluation of the ovariance matrix elements
3076 TOFclusterError(check, counter, ind, weight, ppos, lcov);
3078 AliDebug(1, Form("lcov[0] = %f, lcov[8] = %f", lcov[0], lcov[8]));
3080 //cluster covariance in the tracking system:
3082 m.SetRotation(lcov);
3084 m.MultiplyLeft(&g2l->Inverse());
3085 Double_t *tcov = m.GetRotationMatrix();
3086 cov[0] = tcov[0]; cov[1] = tcov[1]; cov[2] = tcov[2];
3087 cov[3] = tcov[4]; cov[4] = tcov[5]; cov[5] = tcov[8];
3092 //_____________________________________________________________________________
3094 void AliTOFClusterFinderV1::TOFclusterError(Bool_t check, Int_t counter,
3095 Int_t **ind, Double_t *weight,
3096 Double_t ppos[], Double_t lcov[]) const
3102 //lcov[4] = 0.42*0.42/3.;
3103 // = ( 5*0.025 (gas gaps thikness)
3104 // + 4*0.040 (internal glasses thickness)
3105 // + 0.5*0.160 (internl PCB)
3106 // + 1*0.055 (external red glass))
3109 Float_t *delta2X = new Float_t[counter];
3110 for (Int_t ii=0; ii<counter; ii++)
3112 ((ind[ii][4]-23.5)*AliTOFGeometry::XPad() - ppos[0])*((ind[ii][4]-23.5)*AliTOFGeometry::XPad() - ppos[0]);
3114 Float_t *delta2Z = new Float_t[counter];
3115 for (Int_t ii=0; ii<counter; ii++)
3117 ((ind[ii][3]- 0.5)*AliTOFGeometry::ZPad() - ppos[2])*((ind[ii][3]- 0.5)*AliTOFGeometry::ZPad() - ppos[2]);
3119 for (Int_t ii=0; ii<counter; ii++)
3120 AliDebug(1, Form("x[%i] = %f, z[%i] = %f, weight[%i] = %f",
3121 ii, (ind[ii][4]-23.5)*AliTOFGeometry::XPad(),
3122 ii, (ind[ii][3]- 0.5)*AliTOFGeometry::ZPad(),
3125 AliDebug(1, Form("xMean = %f, zMean = %f",ppos[0], ppos[2]));
3133 if (ind[0][3]==ind[1][3] && TMath::Abs(ind[0][4]-ind[1][4])==1) { //
3140 if (weight[0]==weight[1])
3141 lcov[0] = 0.0379409;
3143 lcov[0] = TMath::Mean(counter, delta2X, weight);
3148 else if (ind[0][4]==ind[1][4] && TMath::Abs(ind[0][3]-ind[1][3])==1) {//
3155 if (weight[0]==weight[1])
3156 lcov[8] = 0.0422046;
3158 lcov[8] = TMath::Mean(counter, delta2Z, weight);
3172 if (weight[0]==weight[1] && weight[0]==weight[2]) {
3173 lcov[0] = 0.0290677;
3174 lcov[8] = 0.0569726;
3177 lcov[0] = TMath::Mean(counter, delta2X, weight);
3178 lcov[8] = TMath::Mean(counter, delta2Z, weight);
3192 if (weight[0]==weight[1] && weight[0]==weight[2] && weight[0]==weight[3]) {
3193 lcov[0] = 0.0223807;
3194 lcov[8] = 0.0438662;
3197 lcov[0] = TMath::Mean(counter, delta2X, weight);
3198 lcov[8] = TMath::Mean(counter, delta2Z, weight);
3208 //_____________________________________________________________________________
3210 Bool_t AliTOFClusterFinderV1::MakeSlewingCorrection(Int_t *detectorIndex,
3216 // This funtion makes the following:
3218 // - if at least one of the three status (Pulser/Noise/HW) is
3219 // bad, is sets the status of electronic channel, corresponding to the
3220 // volume identified by detectorIndex, as kFALSE;
3221 // - if offline calibration is in the valid status, it performs the
3222 // slewing correction. In particular, by taking into account:
3223 // * the measured tot and tof values (tofDigitToT and tofDigitTdc,
3225 // * the six parameters of 5th order polynomial used
3226 // to fit the tofVStot scatter plot,
3227 // it returns the corrected tof value, i.e. tdcCorr value.
3230 Bool_t output = kTRUE;
3235 //AliInfo(" Calibrating TOF Digits: ");
3237 AliTOFChannelOnlineArray *calDelay = fTOFcalib->GetTOFOnlineDelay();
3238 AliTOFChannelOnlineStatusArray *calStatus = fTOFcalib->GetTOFOnlineStatus();
3240 TObjArray *calTOFArrayOffline = fTOFcalib->GetTOFCalArrayOffline();
3242 Int_t index = AliTOFGeometry::GetIndex(detectorIndex);
3244 UChar_t statusPulser = calStatus->GetPulserStatus(index);
3245 UChar_t statusNoise = calStatus->GetNoiseStatus(index);
3246 UChar_t statusHW = calStatus->GetHWStatus(index);
3247 UChar_t status = calStatus->GetStatus(index);
3249 //check the status, also unknown is fine!!!!!!!
3251 AliDebug(2, Form(" Status for channel %i = %i",index, (Int_t)status));
3252 if((statusPulser & AliTOFChannelOnlineStatusArray::kTOFPulserBad)==(AliTOFChannelOnlineStatusArray::kTOFPulserBad)||(statusNoise & AliTOFChannelOnlineStatusArray::kTOFNoiseBad)==(AliTOFChannelOnlineStatusArray::kTOFNoiseBad)||(statusHW & AliTOFChannelOnlineStatusArray::kTOFHWBad)==(AliTOFChannelOnlineStatusArray::kTOFHWBad)){
3253 AliDebug(2, Form(" Bad Status for channel %i",index));
3254 //fTofClusters[ii]->SetStatus(kFALSE); //odd convention, to avoid conflict with calibration objects currently in the db (temporary solution).
3258 AliDebug(2, Form(" Good Status for channel %i",index));
3260 // Get Rough channel online equalization
3261 Double_t roughDelay = (Double_t)calDelay->GetDelay(index); // in ns
3262 AliDebug(2,Form(" channel delay (ns) = %f", roughDelay));
3263 // Get Refined channel offline calibration parameters
3264 TString validity = (TString)fTOFcalib->GetOfflineValidity();
3265 if (validity.CompareTo("valid")==0) {
3266 AliTOFChannelOffline * calChannelOffline = (AliTOFChannelOffline*)calTOFArrayOffline->At(index);
3268 for (jj = 0; jj<6; jj++)
3269 par[jj] = (Double_t)calChannelOffline->GetSlewPar(jj);
3271 AliDebug(2,Form(" Calib Pars = %f, %f, %f, %f, %f, %f ",par[0],par[1],par[2],par[3],par[4],par[5]));
3272 AliDebug(2,Form(" The ToT and Time, uncorr (counts) = %i , %i", tofDigitToT, tofDigitTdc));
3273 Double_t tToT = (Double_t)(tofDigitToT*AliTOFGeometry::ToTBinWidth());
3274 tToT*=1.E-3; //ToT in ns
3275 AliDebug(2,Form(" The ToT and Time, uncorr (ns)= %e, %e",tofDigitTdc*AliTOFGeometry::TdcBinWidth()*1.E-3,tToT));
3276 timeCorr = par[0] + tToT*(par[1] + tToT*(par[2] + tToT*(par[3] + tToT*(par[4] + tToT*par[5])))); // the time correction (ns)
3279 timeCorr = roughDelay; // correction in ns
3281 AliDebug(2,Form(" The ToT and Time, uncorr (ns)= %e, %e",tofDigitTdc*AliTOFGeometry::TdcBinWidth()*1.E-3,tofDigitToT*AliTOFGeometry::ToTBinWidth()));
3282 AliDebug(2,Form(" The time correction (ns) = %f", timeCorr));
3283 timeCorr = (Double_t)(tofDigitTdc)*AliTOFGeometry::TdcBinWidth()*1.E-3-timeCorr;//redefine the time
3285 AliDebug(2,Form(" The channel time, corr (ps)= %e",timeCorr ));
3286 tdcCorr = (Int_t)(timeCorr/AliTOFGeometry::TdcBinWidth()); //the corrected time (tdc counts)
3291 //______________________________________________________________________________
3293 void AliTOFClusterFinderV1::Digits2RecPoints(Int_t iEvent)
3296 // Converts digits to recpoints for TOF
3299 TStopwatch stopwatch;
3302 fRunLoader->GetEvent(iEvent);
3304 AliLoader *localTOFLoader = (AliLoader*)fRunLoader->GetLoader("TOFLoader");
3306 TTree * localTreeD = (TTree*)localTOFLoader->TreeD();
3307 if (localTreeD == 0x0)
3308 AliFatal("Can not get TreeD");
3310 TBranch *branch = localTreeD->GetBranch("TOF");
3312 AliError("Can't get the branch with the TOF digits !");
3316 TTree *localTreeR = (TTree*)localTOFLoader->TreeR();
3317 if (localTreeR == 0x0)
3319 localTOFLoader->MakeTree("R");
3320 localTreeR = localTOFLoader->TreeR();
3323 Digits2RecPoints(localTreeD, localTreeR);
3325 //localTOFLoader = fRunLoader->GetLoader("TOFLoader");
3326 localTOFLoader->WriteRecPoints("OVERWRITE");
3328 AliDebug(1, Form("Execution time to read TOF digits and to write TOF clusters for the event number %i: R:%.4fs C:%.4fs",
3329 iEvent, stopwatch.RealTime(),stopwatch.CpuTime()));
3332 //______________________________________________________________________________
3334 void AliTOFClusterFinderV1::Digits2RecPoints(Int_t iEvent, AliRawReader *rawReader)
3337 // Converts RAW data to recpoints for TOF
3340 TStopwatch stopwatch;
3343 fRunLoader->GetEvent(iEvent);
3345 AliDebug(2,Form(" Event number %2i ", iEvent));
3347 AliLoader *localTOFLoader = (AliLoader*)fRunLoader->GetLoader("TOFLoader");
3349 TTree *localTreeR = localTOFLoader->TreeR();
3351 if (localTreeR == 0x0){
3352 localTOFLoader->MakeTree("R");
3353 localTreeR = localTOFLoader->TreeR();
3356 Digits2RecPoints(rawReader, localTreeR);
3358 AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters for the event number %i: R:%.4fs C:%.4fs",
3359 iEvent, stopwatch.RealTime(),stopwatch.CpuTime()));
3362 //______________________________________________________________________________
3364 void AliTOFClusterFinderV1::Raw2Digits(Int_t iEvent, AliRawReader *rawReader)
3367 // Converts RAW data to MC digits for TOF
3371 TStopwatch stopwatch;
3374 fRunLoader->GetEvent(iEvent);
3376 AliDebug(2,Form(" Event number %2i ", iEvent));
3378 AliLoader *localTOFLoader = (AliLoader*)fRunLoader->GetLoader("TOFLoader");
3380 TTree *localTreeD = localTOFLoader->TreeD();
3382 if (localTreeD == 0x0){
3383 localTOFLoader->MakeTree("D");
3384 localTreeD = localTOFLoader->TreeD();
3387 Raw2Digits(rawReader, localTreeD);
3389 AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters for the event number %i: R:%.4fs C:%.4fs",
3390 iEvent, stopwatch.RealTime(),stopwatch.CpuTime()));
3393 //______________________________________________________________________________
3395 void AliTOFClusterFinderV1::AverageCalculations(Int_t number, Float_t *interestingX,
3396 Float_t *interestingY, Float_t *interestingZ,
3397 Double_t *interestingTOF, Double_t *interestingTOT,
3398 Double_t *interestingADC, Double_t *interestingWeight,
3399 Int_t *parTOF, Double_t *posClus, Bool_t &check)
3405 Double_t tofAverage = 0.;
3406 Double_t totAverage = 0.;
3407 Double_t adcAverage = 0.;
3411 for (ii=number-1; ii>=0; ii--) check=check||(interestingWeight[ii]==0 ||interestingWeight[ii]==-1);
3415 posClus[0] = TMath::Mean(number, interestingX);
3416 posClus[1] = TMath::Mean(number, interestingY);
3417 posClus[2] = TMath::Mean(number, interestingZ);
3418 tofAverage = TMath::Mean(number, interestingTOF);
3419 totAverage = TMath::Mean(number, interestingTOT);
3420 adcAverage = TMath::Mean(number, interestingADC);
3425 posClus[0] = TMath::Mean(number, interestingX, interestingWeight);
3426 posClus[1] = TMath::Mean(number, interestingY, interestingWeight);
3427 posClus[2] = TMath::Mean(number, interestingZ, interestingWeight);
3428 tofAverage = TMath::Mean(number, interestingTOF, interestingWeight);
3429 totAverage = TMath::Mean(number, interestingTOT, interestingWeight);
3430 adcAverage = TMath::Mean(number, interestingADC, interestingWeight);
3434 parTOF[0] = Int_t(tofAverage);
3435 parTOF[1] = Int_t(adcAverage);
3436 parTOF[2] = Int_t(totAverage);
3437 parTOF[3] = Int_t(tofAverage);
3438 parTOF[4] = Int_t(tofAverage);