1 /***************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
17 $Log: AliTOFClusterFinderV1.cxx,v $
18 Revision 2009/04/20 A. De Caro
19 - added two new global variables, called fTOFGeometry and fTOFdigits;
20 - added a new method, called FindClustersWithoutTOT,
21 to transform TOF digits with fTOT=0 in one pad clusters;
22 - update of the covariance matrix elements for the TOF clusters
24 Revision 0.01 2008/05/10 A. De Caro
27 /////////////////////////////////////////
29 // Class for TOF cluster finder (V1) //
31 // Input data: Raw Data or Digits; //
32 // Output data: Digits or Rec Points //
34 /////////////////////////////////////////
36 #include "Riostream.h"
38 #include "TClonesArray.h"
39 #include "TStopwatch.h"
41 #include "TGeoMatrix.h"
46 #include "AliRawReader.h"
47 #include "AliRunLoader.h"
48 #include "AliGeomManager.h"
50 #include "AliTOFcalib.h"
51 #include "AliTOFChannelOnlineArray.h"
52 #include "AliTOFChannelOnlineStatusArray.h"
53 #include "AliTOFChannelOffline.h"
54 #include "AliTOFClusterFinderV1.h"
55 #include "AliTOFcluster.h"
56 #include "AliTOFdigit.h"
57 #include "AliTOFDigitMap.h"
58 #include "AliTOFrawData.h"
60 ClassImp(AliTOFClusterFinderV1)
62 //_____________________________________________________________________________
63 AliTOFClusterFinderV1::AliTOFClusterFinderV1(AliTOFcalib *calib):
65 fDigits(new TClonesArray("AliTOFdigit", 4000)),
66 fRecPoints(new TClonesArray("AliTOFcluster", 4000)),
67 fNumberOfTofClusters(0),
68 fNumberOfTofDigits(0),
73 fTOFdigitMap(new AliTOFDigitMap()),
74 fTOFGeometry(new AliTOFGeometry()),
76 fTOFRawStream(AliTOFRawStream())
84 //_____________________________________________________________________________
85 AliTOFClusterFinderV1::AliTOFClusterFinderV1(AliRunLoader* runLoader, AliTOFcalib *calib):
86 fRunLoader(runLoader),
87 fDigits(new TClonesArray("AliTOFdigit", 4000)),
88 fRecPoints(new TClonesArray("AliTOFcluster", 4000)),
89 fNumberOfTofClusters(0),
90 fNumberOfTofDigits(0),
95 fTOFdigitMap(new AliTOFDigitMap()),
96 fTOFGeometry(new AliTOFGeometry()),
98 fTOFRawStream(AliTOFRawStream())
105 //_____________________________________________________________________________
107 AliTOFClusterFinderV1::AliTOFClusterFinderV1(const AliTOFClusterFinderV1 &source)
110 fDigits(source.fDigits),
111 fRecPoints(source.fRecPoints),
112 fNumberOfTofClusters(0),
113 fNumberOfTofDigits(0),
116 fDecoderVersion(source.fDecoderVersion),
117 fTOFcalib(source.fTOFcalib),
118 fTOFdigitMap(new AliTOFDigitMap()),
119 fTOFGeometry(new AliTOFGeometry()),
120 fTOFdigits(source.fTOFdigits),
121 fTOFRawStream(source.fTOFRawStream)
126 //_____________________________________________________________________________
128 AliTOFClusterFinderV1& AliTOFClusterFinderV1::operator=(const AliTOFClusterFinderV1 &source)
135 TObject::operator=(source);
136 fDigits=source.fDigits;
137 fRecPoints=source.fRecPoints;
138 fVerbose=source.fVerbose;
139 fDecoderVersion=source.fDecoderVersion;
140 fTOFcalib=source.fTOFcalib;
141 fTOFdigitMap=source.fTOFdigitMap;
142 fTOFGeometry=source.fTOFGeometry;
143 fTOFdigits=source.fTOFdigits;
144 fTOFRawStream=source.fTOFRawStream;
148 //_____________________________________________________________________________
150 AliTOFClusterFinderV1::~AliTOFClusterFinderV1()
165 fRecPoints->Delete();
177 //_____________________________________________________________________________
179 void AliTOFClusterFinderV1::Digits2RecPoints(TTree* digitsTree, TTree* clusterTree)
182 // Converts digits to recPoints for TOF
185 TStopwatch stopwatch;
190 TClonesArray &aDigits = *fDigits;
192 if (digitsTree == 0x0)
193 AliFatal("Can not get TreeD for TOF");
195 TBranch *branch = digitsTree->GetBranch("TOF");
197 AliError("Can not get branch with the TOF digits !");
201 TClonesArray staticDigits("AliTOFdigit",10000);
202 staticDigits.Clear();
203 TClonesArray *digits = &staticDigits;
204 branch->SetAddress(&digits);
205 digitsTree->GetEvent(0);
206 AliInfo(Form("Number of TOF digits: %d", digits->GetEntriesFast()));
208 AliTOFdigit *tofDigit;
211 Int_t detectorIndex[5];
212 for (jj=0; jj<5; jj++) detectorIndex[jj] = -1;
214 for (jj=0; jj<4; jj++) info[jj] = -1;
220 Bool_t status = kTRUE;
222 AliInfo(" Calibrating TOF Digits: ");
223 TString validity = (TString)fTOFcalib->GetOfflineValidity();
224 AliInfo(Form(" validity = %s", validity.Data()));
225 if (validity.CompareTo("valid")==0) {
226 AliInfo(" ...using offline calibration parameters");
229 AliInfo(" ...using online calibration parameters");
233 for (ii=0; ii<digits->GetEntriesFast(); ii++) {
234 tofDigit = (AliTOFdigit*)digits->UncheckedAt(ii);
235 detectorIndex[0] = tofDigit->GetSector();
236 detectorIndex[1] = tofDigit->GetPlate();
237 detectorIndex[2] = tofDigit->GetStrip();
238 detectorIndex[3] = tofDigit->GetPadz();
239 detectorIndex[4] = tofDigit->GetPadx();
241 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
242 if (detectorIndex[1]==2) { // plate with holes
248 status = MakeSlewingCorrection(detectorIndex, tofDigit->GetToT(), tofDigit->GetTdc(), tdcCorr);
250 for (jj=0; jj<4; jj++) info[jj] = -1;
251 info[0] = tdcCorr;//tofDigit->GetTdc();
252 info[1] = tofDigit->GetAdc();
253 info[2] = tofDigit->GetToT();
254 info[3] = tofDigit->GetTdcND();//tofDigit->GetTdc();//
255 tracks = tofDigit->GetTracks();
257 dummy = detectorIndex[3];
258 detectorIndex[3] = detectorIndex[4];//padx
259 detectorIndex[4] = dummy;//padz
260 last = fDigits->GetEntriesFast();
261 new (aDigits[last]) AliTOFdigit(tracks, detectorIndex, info);
262 if (status) fTOFdigitMap->AddDigit(detectorIndex, last);
264 AliDebug(2, Form(" Digits reading %2d -> %2d %1d %2d %1d %2d (%d, %d, %d)",
266 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[3], detectorIndex[4],
267 info[0], info[1], info[3]));
271 fNumberOfTofDigits = fDigits->GetEntriesFast();
275 Int_t bufsize = 32000;
276 clusterTree->Branch("TOF", &fRecPoints, bufsize);
281 AliInfo(Form("Number of found TOF clusters: %d", fNumberOfTofClusters));
285 fTOFdigitMap->Clear();
289 AliInfo(Form("Execution time to read TOF digits and to write TOF clusters : R:%.4fs C:%.4fs",
290 stopwatch.RealTime(),stopwatch.CpuTime()));
292 if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
295 //_____________________________________________________________________________
297 void AliTOFClusterFinderV1::Digits2RecPoints(AliRawReader *rawReader, TTree *clustersTree)
300 // Converts raw data to recPoints for TOF
303 TStopwatch stopwatch;
307 AliDebug(2, "TreeD re-creation");
308 //TTree *digitsTree = new TTree();
309 //Raw2Digits(rawReader, digitsTree);
311 Raw2Digits(rawReader, fTOFdigits);
313 AliDebug(2,Form("Number of TOF digits: %d", fNumberOfTofDigits));
316 Int_t bufsize = 32000;
317 clustersTree->Branch("TOF", &fRecPoints, bufsize);
320 clustersTree->Fill();
322 AliInfo(Form("Number of found clusters: %d", fNumberOfTofClusters));
326 fTOFdigitMap->Clear();
330 AliInfo(Form("Execution time to read TOF raw data and to write TOF clusters : R:%.4fs C:%.4fs",
331 stopwatch.RealTime(),stopwatch.CpuTime()));
335 //_____________________________________________________________________________
337 void AliTOFClusterFinderV1::Raw2Digits(AliRawReader *rawReader, TTree* digitsTree)
340 // Converts raw data to digits for TOF
343 TStopwatch stopwatch;
348 const Int_t kMaxNumberOfTracksPerDigit = 3;
349 const Int_t kDDL = AliDAQ::NumberOfDdls("TOF");
351 digitsTree->Branch("TOF", &fDigits);
352 TClonesArray &aDigits = *fDigits;
354 fTOFRawStream.Clear();
355 fTOFRawStream.SetRawReader(rawReader);
358 if (fVerbose==2) ftxt.open("TOFdigitsRead.txt",ios::app);
360 TClonesArray staticRawData("AliTOFrawData",10000);
361 staticRawData.Clear();
362 TClonesArray * clonesRawData = &staticRawData;
365 Int_t detectorIndex[5] = {-1, -1, -1, -1, -1};
367 Int_t tracks[kMaxNumberOfTracksPerDigit];
368 for (Int_t ii=0; ii<kMaxNumberOfTracksPerDigit; ii++)
373 Bool_t status = kTRUE;
375 AliInfo(" Calibrating TOF Digits: ");
376 TString validity = (TString)fTOFcalib->GetOfflineValidity();
377 AliInfo(Form(" validity = %s", validity.Data()));
378 if (validity.CompareTo("valid")==0) {
379 AliInfo(" ...using offline calibration parameters");
382 AliInfo(" ...using online calibration parameters");
387 for (indexDDL=0; indexDDL<kDDL; indexDDL++) {
390 if (fDecoderVersion) {
391 AliInfo("Using New Decoder \n");
392 fTOFRawStream.LoadRawDataBuffers(indexDDL,fVerbose);
394 else fTOFRawStream.LoadRawData(indexDDL);
396 clonesRawData = (TClonesArray*)fTOFRawStream.GetRawData();
397 if (clonesRawData->GetEntriesFast()!=0) AliInfo(Form(" TOF raw data number = %3d", clonesRawData->GetEntriesFast()));
398 for (iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
400 AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
402 //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
403 if (tofRawDatum->GetTOF()==-1) continue;
405 fTOFRawStream.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
406 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
409 dummy = detectorIndex[3];
410 detectorIndex[3] = detectorIndex[4];//padz
411 detectorIndex[4] = dummy;//padx
412 status = MakeSlewingCorrection(detectorIndex, tofRawDatum->GetTOT(), tofRawDatum->GetTOF(), tdcCorr);
415 digit[1] = tofRawDatum->GetTOT();
416 digit[2] = tofRawDatum->GetTOT();
417 digit[3] = -1;//tofRawDatum->GetTOF(); //tofND
419 dummy = detectorIndex[3];
420 detectorIndex[3] = detectorIndex[4];//padx
421 detectorIndex[4] = dummy;//padz
423 // Do not reconstruct anything in the holes
424 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
425 if (detectorIndex[1]==2) { // plate with holes
431 last = fDigits->GetEntriesFast();
432 new (aDigits[last]) AliTOFdigit(tracks, detectorIndex, digit);
433 if (status) fTOFdigitMap->AddDigit(detectorIndex, last);
436 if (indexDDL<10) ftxt << " " << indexDDL;
437 else ftxt << " " << indexDDL;
438 if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM();
439 else ftxt << " " << tofRawDatum->GetTRM();
440 ftxt << " " << tofRawDatum->GetTRMchain();
441 if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC();
442 else ftxt << " " << tofRawDatum->GetTDC();
443 ftxt << " " << tofRawDatum->GetTDCchannel();
445 if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0];
446 else ftxt << " -> " << detectorIndex[0];
447 ftxt << " " << detectorIndex[1];
448 if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2];
449 else ftxt << " " << detectorIndex[2];
450 ftxt << " " << detectorIndex[4];
451 if (detectorIndex[4]<10) ftxt << " " << detectorIndex[3];
452 else ftxt << " " << detectorIndex[3];
454 if (digit[1]<10)ftxt << " " << digit[1];
455 else if (digit[1]>=10 && digit[1]<100) ftxt << " " << digit[1];
456 else ftxt << " " << digit[1];
457 if (digit[0]<10) ftxt << " " << digit[0] << endl;
458 else if (digit[0]>=10 && digit[0]<100) ftxt << " " << digit[0] << endl;
459 else if (digit[0]>=100 && digit[0]<1000) ftxt << " " << digit[0] << endl;
460 else ftxt << " " << digit[3] << endl;
463 AliDebug(2, Form(" Raw data reading %2d -> %2d %1d %2d %1d %2d (%d, %d, %d)",
465 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[4], detectorIndex[3],
466 digit[0], digit[1], digit[3]));
470 clonesRawData->Clear();
474 if (fVerbose==2) ftxt.close();
478 fNumberOfTofDigits = fDigits->GetEntries();
480 AliDebug(1, Form("Got %d TOF digits", fNumberOfTofDigits));
481 AliDebug(1, Form("Execution time to read TOF raw data and fill TOF digit tree : R:%.2fs C:%.2fs",
482 stopwatch.RealTime(),stopwatch.CpuTime()));
484 if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
487 //_____________________________________________________________________________
489 void AliTOFClusterFinderV1::FillRecPoint()
492 // Fill the global TClonesArray of AliTOFcluster objects,
501 for(Int_t iPlate=AliTOFGeometry::NPlates()-1; iPlate>=0; iPlate--) {
502 for(Int_t iStrip=AliTOFGeometry::NStrip(iPlate)-1; iStrip>=0; iStrip--) {
503 //for (Int_t iSector=AliTOFGeometry::NSectors()-1; iSector>=0; iSector--) {
504 for (Int_t iSector=0; iSector<AliTOFGeometry::NSectors(); iSector++) {
506 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
507 FindClustersWithoutTOT(iSector, iPlate, iStrip); // clusters coming from digits without TOT measurement
510 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
511 FindClustersPerStrip(iSector, iPlate, iStrip, 4); // 4 pads clusters
512 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
514 dummy4_1 = fNumberOfTofClusters;
515 FindClustersPerStrip(iSector, iPlate, iStrip, 4); // 4 pads clusters
516 if (fNumberOfTofClusters!=dummy4_1)
517 AliDebug(2, Form(" (4): n1= %5d, n2 = %5", dummy4_1, fNumberOfTofClusters));
520 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
521 FindClustersPerStrip(iSector, iPlate, iStrip, 3); // 3 pads clusters
522 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
524 dummy3_1 = fNumberOfTofClusters;
525 FindClustersPerStrip(iSector, iPlate, iStrip, 3); // 3 pads clusters
526 if (fNumberOfTofClusters!=dummy3_1)
527 AliDebug(2, Form(" (3): n1= %5d, n2 = %5", dummy3_1, fNumberOfTofClusters));
530 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
531 FindClustersPerStrip(iSector, iPlate, iStrip, 2); // 2 pads clusters
532 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
534 dummy2_1 = fNumberOfTofClusters;
535 FindClustersPerStrip(iSector, iPlate, iStrip, 2); // 2 pads clusters
536 if (fNumberOfTofClusters!=dummy2_1)
537 AliDebug(2, Form(" (2): n1= %5d, n2 =%5", dummy2_1, fNumberOfTofClusters));
540 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
541 dummy = fNumberOfTofClusters;
542 FindClusters34(iSector, iPlate, iStrip); // 3 pads clusters between 4 hit pads
543 if (fNumberOfTofClusters!=dummy)
544 AliDebug(2, Form(" (3 between 4): n1 = %5d, n2 = %5d", fNumberOfTofClusters, dummy));
547 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
548 dummy = fNumberOfTofClusters;
549 FindClusters23(iSector, iPlate, iStrip); // 2 pads clusters between 3 hit pads
550 if (fNumberOfTofClusters!=dummy)
551 AliDebug(2, Form(" (2 between 3): n1 = %5d, n2 = %5d", fNumberOfTofClusters, dummy));
553 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
554 dummy = fNumberOfTofClusters;
555 FindClusters24(iSector, iPlate, iStrip); // 2 pads clusters between 4 hit pads
556 if (fNumberOfTofClusters!=dummy)
557 AliDebug(2, Form(" (2 between 4): n1 = %5d, n2 = %5d", fNumberOfTofClusters, dummy));
560 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
561 dummy = fNumberOfTofClusters;
562 FindOnePadClusterPerStrip(iSector, iPlate, iStrip); // 1 pad clusters
563 if (fNumberOfTofClusters!=dummy)
564 AliDebug(2,Form(" (1): n1 = %5d, n2 = %5d", fNumberOfTofClusters, dummy));
566 if (fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip)>0)
567 AliDebug(2, Form(" (1): number of clusters = %5d (remaining digit %2d), -%2d %1d %2d-",
568 fNumberOfTofClusters, fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip),
569 iSector, iPlate, iStrip));
576 TClonesArray &lRecPoints = *fRecPoints;
580 Int_t detectorIndex[5];
581 for (jj=0; jj<5; jj++) detectorIndex[jj] = -1;
583 for (jj=0; jj<5; jj++) parTOF[jj] = -1;
584 Int_t trackLabels[3];
585 for (jj=0; jj<3; jj++) trackLabels[jj] = -1;
586 Int_t digitIndex = -1;
587 Bool_t status = kTRUE;
589 for (ii=0; ii<3; ii++) posClus[ii] = 0.;
590 //Float_t covClus[6];
591 //for (ii=0; ii<6; ii++) covClus[ii] = 0.;
594 for (ii=0; ii<fNumberOfTofClusters; ii++) {
596 digitIndex = fTofClusters[ii]->GetIndex();
597 for(jj=0; jj<5; jj++) detectorIndex[jj] = fTofClusters[ii]->GetDetInd(jj);
598 volIdClus = fTOFGeometry->GetAliSensVolIndex(detectorIndex[0],detectorIndex[1],detectorIndex[2]);
599 //volIdClus = GetClusterVolIndex(detectorIndex);
600 for(jj=0; jj<3; jj++) trackLabels[jj] = fTofClusters[ii]->GetLabel(jj);
601 parTOF[0] = fTofClusters[ii]->GetTDC(); // TDC
602 parTOF[1] = fTofClusters[ii]->GetToT(); // TOT
603 parTOF[2] = fTofClusters[ii]->GetADC(); // ADC=TOT
604 parTOF[3] = fTofClusters[ii]->GetTDCND(); // TDCND
605 parTOF[4] = fTofClusters[ii]->GetTDCRAW();//RAW
606 status = fTofClusters[ii]->GetStatus();
608 posClus[0] = fTofClusters[ii]->GetX();
609 posClus[1] = fTofClusters[ii]->GetY();
610 posClus[2] = fTofClusters[ii]->GetZ();
612 //for (jj=0; jj<6; jj++) covClus[jj] = 0.;
613 //((AliCluster*)fTofClusters[ii])->GetGlobalCov(covClus);
615 new(lRecPoints[ii]) AliTOFcluster(volIdClus, (Double_t)posClus[0], (Double_t)posClus[1], (Double_t)posClus[2],
616 (Double_t)(fTofClusters[ii]->GetSigmaX2()),
617 (Double_t)(fTofClusters[ii]->GetSigmaXY()),
618 (Double_t)(fTofClusters[ii]->GetSigmaXZ()),
619 (Double_t)(fTofClusters[ii]->GetSigmaY2()),
620 (Double_t)(fTofClusters[ii]->GetSigmaYZ()),
621 (Double_t)(fTofClusters[ii]->GetSigmaZ2()),
622 //(Double_t)covClus[0], (Double_t)covClus[1], (Double_t)covClus[2],
623 //(Double_t)covClus[3], (Double_t)covClus[4], (Double_t)covClus[5],
624 trackLabels, detectorIndex, parTOF, status, digitIndex);
626 AliDebug(2, Form(" %4d %4d %f %f %f %f %f %f %f %f %f %3d %3d %3d %2d %1d %2d %1d %2d %4d %3d %3d %4d %4d %1d %4d",
627 ii, volIdClus, posClus[0], posClus[1], posClus[2],
628 fTofClusters[ii]->GetSigmaX2(),
629 fTofClusters[ii]->GetSigmaXY(),
630 fTofClusters[ii]->GetSigmaXZ(),
631 fTofClusters[ii]->GetSigmaY2(),
632 fTofClusters[ii]->GetSigmaYZ(),
633 fTofClusters[ii]->GetSigmaZ2(),
634 trackLabels[0], trackLabels[1], trackLabels[2],
635 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[3], detectorIndex[4],
636 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
637 status, digitIndex));
642 for (Int_t iSector=0; iSector<AliTOFGeometry::NSectors(); iSector++)
643 for(Int_t iPlate=0; iPlate<AliTOFGeometry::NPlates(); iPlate++) {
644 for(Int_t iStrip=0; iStrip<AliTOFGeometry::NStrip(iPlate); iStrip++) {
645 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
646 AliDebug(2, Form(" END %2d %1d %2d %5d",
647 iSector, iPlate, iStrip, fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip)));
652 //_____________________________________________________________________________
654 void AliTOFClusterFinderV1::FindOnePadClusterPerStrip(Int_t nSector,
659 // This function searches the isolated digits (stored in the fDigits object),
660 // to perform clusters (stored in the fTofClusters array).
661 // This research has been made by checking the fTOFdigitMap object,
662 // filled at digits/raw-data reading time.
665 const Int_t kMaxNumberOfTracksPerDigit = 3;
666 const Int_t kMaxNumberOfDigitsPerVolume = 3;
670 Int_t det[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padZ,padX
671 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padX,padZ
672 UShort_t volIdClus = 0;
675 for (jj=0; jj<3; jj++) pos[jj] = 0.;
677 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
680 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
683 for (jj=0; jj<5; jj++) parTOF[jj] = 0;
685 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
687 Int_t tracks[kMaxNumberOfTracksPerDigit];
688 for (jj=0; jj<3; jj++) tracks[jj] = -1;
690 Int_t dummyCounter=-1;
692 AliTOFdigit *digitInteresting;
696 for (iPadX=0; iPadX<AliTOFGeometry::NpadX(); iPadX++) {
697 for (iPadZ=0; iPadZ<AliTOFGeometry::NpadZ(); iPadZ++) {
698 vol[4] = iPadZ , vol[3] = iPadX;
700 AliDebug(3, Form(" %1d %2d\n", iPadZ, iPadX));
702 if (fTOFdigitMap->GetNumberOfDigits(vol)==0) continue;
704 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
705 if (fTOFdigitMap->GetDigitIndex(vol,digIndex)<0) continue;
706 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(fTOFdigitMap->GetDigitIndex(vol,digIndex));
708 AliDebug(2, Form(" %3d %5d %2d %1d %2d %1d %2d %d %d %d %5d %5d %5d %5d",
709 fTOFdigitMap->GetNumberOfDigits(vol), digIndex,
710 vol[0], vol[1], vol[2] ,vol[4], vol[3],
711 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
712 digitInteresting->GetToT(),
713 fTOFdigitMap->GetDigitIndex(vol,digIndex),
714 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
716 det[3] = vol[4]; // padz
717 det[4] = vol[3]; // padx
718 fTOFGeometry->GetPosPar(det,pos);
719 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
722 for (jj=0; jj<3; jj++) posClus[jj] = pos[jj];
724 parTOF[0] = Int_t(digitInteresting->GetTdc());
725 parTOF[1] = Int_t(digitInteresting->GetToT());
726 parTOF[2] = Int_t(digitInteresting->GetAdc());
727 parTOF[3] = Int_t(digitInteresting->GetTdcND());
728 parTOF[4] = Int_t(digitInteresting->GetTdc());
730 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
731 //volIdClus = GetClusterVolIndex(det);
733 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
734 GetClusterPars(det, posClus, covClus);
736 // To fill the track index array
738 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
739 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) { // three is the max number of tracks associated to one digit
740 if (digitInteresting->GetTrack(jj)==-1) continue;
743 tracks[dummyCounter] = digitInteresting->GetTrack(jj);
747 AliTOFcluster *tofCluster =
748 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
749 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
750 tracks, det, parTOF, status, fTOFdigitMap->GetDigitIndex(vol,digIndex));
751 InsertCluster(tofCluster);
753 AliDebug(2, Form(" %4d %f %f %f %f %f %f %f %f %f %3d %3d %3d %2d %1d %2d %1d %2d %4d %3d %3d %4d %4d %1d %4d",
754 volIdClus, posClus[0], posClus[1], posClus[2],
755 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
756 tracks[0], tracks[1], tracks[2],
757 det[0], det[1], det[2], det[3], det[4],
758 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
759 status, fTOFdigitMap->GetDigitIndex(vol,digIndex)));
761 AliDebug(2, Form(" %f %f %f", pos[0], pos[1], pos[2]));
762 AliDebug(2, Form(" %d %d", parTOF[0], parTOF[2]));
764 fTOFdigitMap->ResetDigit(vol, digIndex);
772 //_____________________________________________________________________________
774 void AliTOFClusterFinderV1::FindClustersWithoutTOT(Int_t nSector,
779 // This function searches the isolated digits without TOT
780 // measurement (stored in the fDigits object), to perform clusters
781 // (stored in the fTofClusters array). This research has been made
782 // by checking the fTOFdigitMap object, filled at digits/raw-data
786 const Int_t kMaxNumberOfTracksPerDigit = 3;
787 const Int_t kMaxNumberOfDigitsPerVolume = 3;
791 Int_t det[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padZ,padX
792 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padX,padZ
793 UShort_t volIdClus = 0;
796 for (jj=0; jj<3; jj++) pos[jj] = 0.;
798 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
801 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
804 for (jj=0; jj<5; jj++) parTOF[jj] = 0;
806 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
807 Int_t tracks[kMaxNumberOfTracksPerDigit];
808 for (jj=0; jj<3; jj++) tracks[jj] = -1;
810 Int_t dummyCounter=-1;
812 AliTOFdigit *digitInteresting;
816 for (iPadX=0; iPadX<AliTOFGeometry::NpadX(); iPadX++) {
817 for (iPadZ=0; iPadZ<AliTOFGeometry::NpadZ(); iPadZ++) {
818 vol[4] = iPadZ , vol[3] = iPadX;
820 AliDebug(3, Form(" %1d %2d\n", iPadZ, iPadX));
822 if (fTOFdigitMap->GetNumberOfDigits(vol)==0) continue;
824 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
825 if (fTOFdigitMap->GetDigitIndex(vol,digIndex)<0) continue;
826 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(fTOFdigitMap->GetDigitIndex(vol,digIndex));
827 if (digitInteresting->GetToT()>0) continue; // AdC
829 AliDebug(2, Form(" %3d %5d %2d %1d %2d %1d %2d %d %d %d %5d %5d %5d %5d",
830 fTOFdigitMap->GetNumberOfDigits(vol), digIndex,
831 vol[0], vol[1], vol[2] ,vol[4], vol[3],
832 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
833 digitInteresting->GetToT(),
834 fTOFdigitMap->GetDigitIndex(vol,digIndex),
835 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
837 det[3] = vol[4]; // padz
838 det[4] = vol[3]; // padx
839 fTOFGeometry->GetPosPar(det,pos);
840 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
843 for (jj=0; jj<3; jj++) posClus[jj] = pos[jj];
845 parTOF[0] = Int_t(digitInteresting->GetTdc());
846 parTOF[1] = Int_t(digitInteresting->GetToT());
847 parTOF[2] = Int_t(digitInteresting->GetAdc());
848 parTOF[3] = Int_t(digitInteresting->GetTdcND());
849 parTOF[4] = Int_t(digitInteresting->GetTdc());
851 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
852 //volIdClus = GetClusterVolIndex(det);
854 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
855 GetClusterPars(det, posClus, covClus);
857 // To fill the track index array
859 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
860 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) { // three is the max number of tracks associated to one digit
861 if (digitInteresting->GetTrack(jj)==-1) continue;
864 tracks[dummyCounter] = digitInteresting->GetTrack(jj);
868 AliTOFcluster *tofCluster =
869 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
870 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
871 tracks, det, parTOF, status, fTOFdigitMap->GetDigitIndex(vol,digIndex));
872 InsertCluster(tofCluster);
874 AliDebug(2, Form(" %4d %f %f %f %f %f %f %f %f %f %3d %3d %3d %2d %1d %2d %1d %2d %4d %3d %3d %4d %4d %1d %4d",
875 volIdClus, posClus[0], posClus[1], posClus[2],
876 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
877 tracks[0], tracks[1], tracks[2],
878 det[0], det[1], det[2], det[3], det[4],
879 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
880 status, fTOFdigitMap->GetDigitIndex(vol,digIndex)));
882 AliDebug(2, Form(" %f %f %f", pos[0], pos[1], pos[2]));
883 AliDebug(2, Form(" %d %d", parTOF[0], parTOF[2]));
885 fTOFdigitMap->ResetDigit(vol, digIndex);
893 //_____________________________________________________________________________
895 void AliTOFClusterFinderV1::FindClusters34(Int_t nSector,
900 // This function searches the neighbouring digits (stored in the fDigits object),
901 // to perform clusters (stored in the fTofClusters array).
903 // This research has been made by checking the fTOFdigitMap object,
904 // filled at digits/raw-data reading time.
907 const Int_t kMaxNumberOfInterestingPads = 4;
908 const Int_t kMaxNumberOfTracksPerDigit = 3;
909 const Int_t kMaxNumberOfDigitsPerVolume = 3;
913 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
914 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
915 digitsInVolumeIndices[ii] = -1;
917 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
919 Float_t pos[3] = {0.,0.,0.};
922 Int_t interestingPadX[kMaxNumberOfInterestingPads];
923 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
924 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
925 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
926 Double_t interestingTOT[kMaxNumberOfInterestingPads];
927 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
928 Double_t interestingADC[kMaxNumberOfInterestingPads];
929 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
930 Double_t interestingTOF[kMaxNumberOfInterestingPads];
931 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
932 Double_t interestingWeight[kMaxNumberOfInterestingPads];
933 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
935 Float_t interestingX[kMaxNumberOfInterestingPads];
936 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
937 Float_t interestingY[kMaxNumberOfInterestingPads];
938 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
939 Float_t interestingZ[kMaxNumberOfInterestingPads];
940 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
942 Float_t interDigit[kMaxNumberOfInterestingPads];
943 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
945 Int_t padsCluster[11];
946 padsCluster[0] = nSector;
947 padsCluster[1] = nPlate;
948 padsCluster[2] = nStrip;
949 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
951 Int_t interestingCounter=-1;
952 Int_t digitIndexLocal=-1; // AdC
958 for (jj=0; jj<5; jj++) parTOF[jj] = 0;
960 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
962 for (jj=0; jj<5; jj++) det[jj] = -1;
964 for (jj=0; jj<3; jj++) posF[jj] = 0.;
965 UShort_t volIdClus = 0;
966 Bool_t check = kFALSE;
967 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
969 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
970 Int_t tracks[kMaxNumberOfTracksPerDigit];
971 for (jj=0; jj<3; jj++) tracks[jj] = -1;
972 Int_t dummyCounter=-1;
973 Bool_t alreadyStored = kFALSE;
975 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
976 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
977 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
979 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
980 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
982 AliTOFdigit *digitInteresting;
984 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
986 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
987 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
989 AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
996 interestingCounter=-1;
998 vol[4] = iPadZ , vol[3] = iPadX;
999 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1000 interestingCounter++;
1002 vol[4] = iPadZ, vol[3] = iPadX+1;
1003 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1004 interestingCounter++;
1006 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1007 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1008 interestingCounter++;
1010 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1011 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1012 interestingCounter++;
1014 if (interestingCounter+1!=4) continue; // the hit pads have to be 4
1015 else interestingCounter=-1;
1018 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1019 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1020 selectedDigit[ii][jj] = 0x0;
1023 vol[4] = iPadZ, vol[3] = iPadX;
1025 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1026 interestingCounter++;
1027 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1028 digitsInVolumeIndices[ii] = -1;
1029 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1030 digitIndexLocal=-1; // AdC
1031 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1032 if (digitsInVolumeIndices[digIndex]<0) continue;
1033 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1034 if (digitInteresting->GetToT()<=0) continue; // AdC
1035 digitIndexLocal++; // AdC
1037 AliDebug(1,Form(" %2d %1d %2d %1d %2d %f %f %f %f %5d %5d %5d %5d",
1038 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1039 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1040 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1041 digitsInVolumeIndices[digIndex],
1042 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1045 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1046 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1047 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1048 digitInteresting->GetToT()*digitInteresting->GetToT(),
1049 digitsInVolumeIndices[digIndex],
1050 digitInteresting->GetTracks());
1052 if (digitIndexLocal==-1) interestingCounter--; // AdC
1056 vol[4] = iPadZ, vol[3] = iPadX+1;
1058 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1059 interestingCounter++;
1060 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1061 digitsInVolumeIndices[ii] = -1;
1062 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1063 digitIndexLocal=-1; // AdC
1064 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1065 if (digitsInVolumeIndices[digIndex]<0) continue;
1066 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1067 if (digitInteresting->GetToT()<=0) continue; // AdC
1068 digitIndexLocal++; // AdC
1070 AliDebug(1,Form(" %2d %1d %2d %1d %2d %f %f %f %f %5d %5d %5d %5d",
1071 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1072 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1073 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1074 digitsInVolumeIndices[digIndex],
1075 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1078 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1079 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1080 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1081 digitInteresting->GetToT()*digitInteresting->GetToT(),
1082 digitsInVolumeIndices[digIndex],
1083 digitInteresting->GetTracks());
1085 if (digitIndexLocal==-1) interestingCounter--; // AdC
1089 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1091 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1092 interestingCounter++;
1093 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1094 digitsInVolumeIndices[ii] = -1;
1095 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1096 digitIndexLocal=-1; // AdC
1097 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1098 if (digitsInVolumeIndices[digIndex]<0) continue;
1099 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1100 if (digitInteresting->GetToT()<=0) continue; // AdC
1101 digitIndexLocal++; // AdC
1103 AliDebug(1,Form(" %2d %1d %2d %1d %2d %f %f %f %f %5d %5d %5d %5d",
1104 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1105 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1106 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1107 digitsInVolumeIndices[digIndex],
1108 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1111 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1112 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1113 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1114 digitInteresting->GetToT()*digitInteresting->GetToT(),
1115 digitsInVolumeIndices[digIndex],
1116 digitInteresting->GetTracks());
1118 if (digitIndexLocal==-1) interestingCounter--; // AdC
1122 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1124 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1125 interestingCounter++;
1126 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1127 digitsInVolumeIndices[ii] = -1;
1128 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1130 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1131 if (digitsInVolumeIndices[digIndex]<0) continue;
1132 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1133 if (digitInteresting->GetToT()<=0) continue; // AdC
1134 digitIndexLocal++; // AdC
1136 AliDebug(1,Form(" %2d %1d %2d %1d %2d %f %f %f %f %5d %5d %5d %5d",
1137 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1138 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1139 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1140 digitsInVolumeIndices[digIndex],
1141 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1143 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1144 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1145 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1146 digitInteresting->GetToT()*digitInteresting->GetToT(),
1147 digitsInVolumeIndices[digIndex],
1148 digitInteresting->GetTracks());
1150 if (digitIndexLocal==-1) interestingCounter--; // AdC
1153 AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
1155 for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
1156 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
1157 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
1159 for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
1160 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
1161 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
1163 for (Int_t adesso3=adesso2+1; adesso3<interestingCounter+1; adesso3++) {
1164 for (Int_t thirdIndex=0; thirdIndex<kMaxNumberOfDigitsPerVolume; thirdIndex++) {
1165 if (selectedDigit[adesso3][thirdIndex]==0x0) continue;
1168 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime
1170 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
1172 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime) continue;
1174 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
1175 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
1176 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
1177 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
1178 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
1179 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
1180 Int_t volDum = vol1[3];
1183 fTOFGeometry->GetPosPar(vol1,pos);
1184 interestingX[0] = pos[0];
1185 interestingY[0] = pos[1];
1186 interestingZ[0] = pos[2];
1188 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
1189 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
1190 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
1191 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
1192 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
1193 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
1197 fTOFGeometry->GetPosPar(vol2,pos);
1198 interestingX[1] = pos[0];
1199 interestingY[1] = pos[1];
1200 interestingZ[1] = pos[2];
1202 interestingTOF[2] = selectedDigit[adesso3][thirdIndex]->GetTDC();
1203 interestingTOT[2] = selectedDigit[adesso3][thirdIndex]->GetTOT();
1204 interestingADC[2] = selectedDigit[adesso3][thirdIndex]->GetADC();
1205 interestingWeight[2] = selectedDigit[adesso3][thirdIndex]->GetWeight();
1206 Int_t vol3[5]; for(jj=0; jj<5; jj++) vol3[jj] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(jj);
1207 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol3[0], vol3[1], vol3[2], vol3[4], vol3[3]));
1211 fTOFGeometry->GetPosPar(vol3,pos);
1212 interestingX[2] = pos[0];
1213 interestingY[2] = pos[1];
1214 interestingZ[2] = pos[2];
1217 AverageCalculations(3, interestingX, interestingY, interestingZ,
1218 interestingTOF, interestingTOT, interestingADC,
1220 parTOF, posClus, check);
1223 for (jj=0; jj<5; jj++) det[jj] = -1;
1224 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
1225 fTOFGeometry->GetDetID(posF, det);
1227 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
1228 //volIdClus = GetClusterVolIndex(det);
1230 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1231 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
1232 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
1233 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
1234 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
1235 padsCluster[7] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(4);
1236 padsCluster[8] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(3);
1238 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1239 Int_t ** indDet = new Int_t*[3];
1240 for (jj=0; jj<3; jj++) indDet[jj] = new Int_t [5];
1241 for (jj=0; jj<3; jj++) indDet[jj][0] = nSector;
1242 for (jj=0; jj<3; jj++) indDet[jj][1] = nPlate;
1243 for (jj=0; jj<3; jj++) indDet[jj][2] = nStrip;
1244 for (jj=0; jj<3; jj++) indDet[jj][3] = padsCluster[2*jj+3];
1245 for (jj=0; jj<3; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
1246 GetClusterPars(/*check,*/ 3, indDet, interestingWeight, posClus, covClus);
1247 for (jj=0; jj<3; jj++) delete [] indDet[jj];
1249 // To fill the track index array
1251 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1252 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1253 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
1256 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
1259 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1260 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
1263 alreadyStored = kFALSE;
1264 for (jj=0; jj<dummyCounter+1; jj++)
1265 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
1267 if (alreadyStored) continue;
1268 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
1269 AliWarning(" Siamo al limite!");
1274 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
1279 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1280 if (selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk)==-1) continue;
1283 alreadyStored = kFALSE;
1284 for (jj=0; jj<dummyCounter+1; jj++)
1285 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk));
1287 if (alreadyStored) continue;
1288 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
1289 AliWarning(" Siamo al limite!");
1294 tracks[dummyCounter] = selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk);
1301 AliTOFcluster *tofCluster =
1302 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
1303 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1304 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
1305 InsertCluster(tofCluster);
1307 AliDebug(2, Form(" %4d %f %f %f %f %f %f %f %f %f %3d %3d %3d %2d %1d %2d %1d %2d %4d %3d %3d %4d %4d %1d %4d",
1308 volIdClus, posClus[0], posClus[1], posClus[2],
1309 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1310 tracks[0], tracks[1], tracks[2],
1311 det[0], det[1], det[2], det[3], det[4],
1312 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
1313 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
1319 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
1323 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
1327 fTOFdigitMap->ResetDigitNumber(vol3,selectedDigit[adesso3][thirdIndex]->GetIndex());
1330 } // close loop on third digit
1331 } // close loop on adesso3
1333 } // close loop on second digit
1334 } // close loop on adesso2
1336 } // close loop on first digit
1337 } // close loop on adesso1
1339 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1340 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1341 selectedDigit[ii][jj] = 0x0;
1345 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1346 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
1347 delete selectedDigit[ii][jj];
1348 selectedDigit[ii][jj] = 0x0;
1353 //_____________________________________________________________________________
1355 void AliTOFClusterFinderV1::FindClusters23(Int_t nSector,
1360 // This function searches the neighbouring digits (stored in the fDigits object),
1361 // to perform clusters (stored in the fTofClusters array).
1363 // This research has been made by checking the fTOFdigitMap object,
1364 // filled at digits/raw-data reading time.
1367 const Int_t kMaxNumberOfInterestingPads = 4;
1368 const Int_t kMaxNumberOfTracksPerDigit = 3;
1369 const Int_t kMaxNumberOfDigitsPerVolume = 3;
1373 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
1374 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1375 digitsInVolumeIndices[ii] = -1;
1377 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
1379 Float_t pos[3] = {0.,0.,0.};
1382 Int_t interestingPadX[kMaxNumberOfInterestingPads];
1383 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
1384 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
1385 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
1386 Double_t interestingTOT[kMaxNumberOfInterestingPads];
1387 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
1388 Double_t interestingADC[kMaxNumberOfInterestingPads];
1389 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
1390 Double_t interestingTOF[kMaxNumberOfInterestingPads];
1391 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
1392 Double_t interestingWeight[kMaxNumberOfInterestingPads];
1393 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
1395 Float_t interestingX[kMaxNumberOfInterestingPads];
1396 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
1397 Float_t interestingY[kMaxNumberOfInterestingPads];
1398 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
1399 Float_t interestingZ[kMaxNumberOfInterestingPads];
1400 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
1402 Float_t interDigit[kMaxNumberOfInterestingPads];
1403 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
1405 Int_t padsCluster[11];
1406 padsCluster[0] = nSector;
1407 padsCluster[1] = nPlate;
1408 padsCluster[2] = nStrip;
1409 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1411 Int_t interestingCounter=-1;
1412 Int_t digitIndexLocal = -1;
1417 Bool_t check = kFALSE;
1419 for (jj=0; jj<5; jj++) parTOF[jj] = 0;
1420 Double_t posClus[3];
1421 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
1423 for (jj=0; jj<5; jj++) det[jj] = -1;
1425 for (jj=0; jj<3; jj++) posF[jj] = 0.;
1426 UShort_t volIdClus = 0;
1427 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
1428 Double_t covClus[6];
1429 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1430 Int_t tracks[kMaxNumberOfTracksPerDigit];
1431 for (jj=0; jj<3; jj++) tracks[jj] = -1;
1432 Int_t dummyCounter=-1;
1433 Bool_t alreadyStored = kFALSE;
1435 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
1436 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1437 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
1439 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1440 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
1442 AliTOFdigit *digitInteresting;
1444 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
1446 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
1447 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
1449 AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
1456 interestingCounter=-1;
1458 vol[4] = iPadZ , vol[3] = iPadX;
1459 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1460 interestingCounter++;
1462 vol[4] = iPadZ, vol[3] = iPadX+1;
1463 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1464 interestingCounter++;
1466 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1467 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1468 interestingCounter++;
1470 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1471 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1472 interestingCounter++;
1474 if (interestingCounter+1!=3) continue; // the hit pads have to be 3
1475 else interestingCounter=-1;
1478 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1479 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1480 selectedDigit[ii][jj] = 0x0;
1483 vol[4] = iPadZ, vol[3] = iPadX;
1485 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1486 interestingCounter++;
1487 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1488 digitsInVolumeIndices[ii] = -1;
1489 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1491 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1492 if (digitsInVolumeIndices[digIndex]<0) continue;
1493 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1494 if (digitInteresting->GetToT()<=0) continue; // AdC
1495 digitIndexLocal++; // AdC
1497 AliDebug(1,Form(" %2d %1d %2d %1d %2d %f %f %f %f %5d %5d %5d %5d",
1498 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1499 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1500 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1501 digitsInVolumeIndices[digIndex],
1502 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1504 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1505 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1506 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1507 digitInteresting->GetToT()*digitInteresting->GetToT(),
1508 digitsInVolumeIndices[digIndex],
1509 digitInteresting->GetTracks());
1511 if (digitIndexLocal==-1) interestingCounter--; // AdC
1515 vol[4] = iPadZ, vol[3] = iPadX+1;
1517 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1518 interestingCounter++;
1519 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1520 digitsInVolumeIndices[ii] = -1;
1521 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1522 digitIndexLocal=-1; // AdC
1523 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1524 if (digitsInVolumeIndices[digIndex]<0) continue;
1525 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1526 if (digitInteresting->GetToT()<=0) continue; // AdC
1527 digitIndexLocal++; // AdC
1529 AliDebug(1,Form(" %2d %1d %2d %1d %2d %f %f %f %f %5d %5d %5d %5d",
1530 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1531 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1532 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1533 digitsInVolumeIndices[digIndex],
1534 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1536 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1537 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1538 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1539 digitInteresting->GetToT()*digitInteresting->GetToT(),
1540 digitsInVolumeIndices[digIndex],
1541 digitInteresting->GetTracks());
1543 if (digitIndexLocal==-1) interestingCounter--; // AdC
1547 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1549 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1550 interestingCounter++;
1551 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1552 digitsInVolumeIndices[ii] = -1;
1553 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1554 digitIndexLocal=-1; // AdC
1555 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1556 if (digitsInVolumeIndices[digIndex]<0) continue;
1557 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1558 if (digitInteresting->GetToT()<=0) continue; // AdC
1559 digitIndexLocal++; // AdC
1561 AliDebug(1,Form(" %2d %1d %2d %1d %2d %f %f %f %f %5d %5d %5d %5d",
1562 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1563 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1564 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1565 digitsInVolumeIndices[digIndex],
1566 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1568 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1569 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1570 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1571 digitInteresting->GetToT()*digitInteresting->GetToT(),
1572 digitsInVolumeIndices[digIndex],
1573 digitInteresting->GetTracks());
1575 if (digitIndexLocal==-1) interestingCounter--; // AdC
1579 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1581 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1582 interestingCounter++;
1583 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1584 digitsInVolumeIndices[ii] = -1;
1585 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1586 digitIndexLocal=-1; // AdC
1587 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1588 if (digitsInVolumeIndices[digIndex]<0) continue;
1589 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1590 if (digitInteresting->GetToT()<=0) continue; // AdC
1591 digitIndexLocal++; // AdC
1593 AliDebug(1,Form(" %2d %1d %2d %1d %2d %f %f %f %f %5d %5d %5d %5d",
1594 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1595 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1596 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1597 digitsInVolumeIndices[digIndex],
1598 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1600 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1601 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1602 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1603 digitInteresting->GetToT()*digitInteresting->GetToT(),
1604 digitsInVolumeIndices[digIndex],
1605 digitInteresting->GetTracks());
1607 if (digitIndexLocal==-1) interestingCounter--; // AdC
1610 AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
1612 for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
1613 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
1614 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
1616 for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
1617 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
1618 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
1620 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime) continue;
1622 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
1623 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
1624 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
1625 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
1626 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
1627 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
1628 Int_t volDum = vol1[3];
1631 fTOFGeometry->GetPosPar(vol1,pos);
1632 interestingX[0] = pos[0];
1633 interestingY[0] = pos[1];
1634 interestingZ[0] = pos[2];
1636 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
1637 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
1638 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
1639 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
1640 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
1641 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
1645 fTOFGeometry->GetPosPar(vol2,pos);
1646 interestingX[1] = pos[0];
1647 interestingY[1] = pos[1];
1648 interestingZ[1] = pos[2];
1650 AverageCalculations(2, interestingX, interestingY, interestingZ,
1651 interestingTOF, interestingTOT, interestingADC,
1653 parTOF, posClus, check);
1655 for (jj=0; jj<5; jj++) det[jj] = -1;
1656 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
1657 fTOFGeometry->GetDetID(posF, det);
1659 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
1660 //volIdClus = GetClusterVolIndex(det);
1662 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1663 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
1664 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
1665 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
1666 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
1668 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1669 Int_t ** indDet = new Int_t*[2];
1670 for (jj=0; jj<2; jj++) indDet[jj] = new Int_t [5];
1671 for (jj=0; jj<2; jj++) indDet[jj][0] = nSector;
1672 for (jj=0; jj<2; jj++) indDet[jj][1] = nPlate;
1673 for (jj=0; jj<2; jj++) indDet[jj][2] = nStrip;
1674 for (jj=0; jj<2; jj++) indDet[jj][3] = padsCluster[2*jj+3];
1675 for (jj=0; jj<2; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
1676 GetClusterPars(/*check,*/ 2, indDet, interestingWeight, posClus, covClus);
1677 for (jj=0; jj<2; jj++) delete [] indDet[jj];
1679 // To fill the track index array
1681 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1682 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1683 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
1686 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
1689 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1690 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
1693 alreadyStored = kFALSE;
1694 for (jj=0; jj<dummyCounter+1; jj++)
1695 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
1697 if (alreadyStored) continue;
1698 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
1699 AliWarning(" Siamo al limite!");
1704 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
1711 AliTOFcluster *tofCluster =
1712 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
1713 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1714 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
1715 InsertCluster(tofCluster);
1717 AliDebug(2, Form(" %4d %f %f %f %f %f %f %f %f %f %3d %3d %3d %2d %1d %2d %1d %2d %4d %3d %3d %4d %4d %1d %4d",
1718 volIdClus, posClus[0], posClus[1], posClus[2],
1719 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1720 tracks[0], tracks[1], tracks[2],
1721 det[0], det[1], det[2], det[3], det[4],
1722 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
1723 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
1728 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
1732 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
1735 } // close loop on second digit
1736 } // close loop on adesso2
1738 } // close loop on first digit
1739 } // close loop on adesso1
1741 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1742 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1743 selectedDigit[ii][jj] = 0x0;
1747 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1748 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
1749 delete selectedDigit[ii][jj];
1750 selectedDigit[ii][jj] = 0x0;
1755 //_____________________________________________________________________________
1757 void AliTOFClusterFinderV1::FindClusters24(Int_t nSector,
1762 // This function searches the neighbouring digits (stored in the fDigits object),
1763 // to perform clusters (stored in the fTofClusters array).
1765 // This research has been made by checking the fTOFdigitMap object,
1766 // filled at digits/raw-data reading time.
1769 const Int_t kMaxNumberOfInterestingPads = 4;
1770 const Int_t kMaxNumberOfTracksPerDigit = 3;
1771 const Int_t kMaxNumberOfDigitsPerVolume = 3;
1775 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
1776 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1777 digitsInVolumeIndices[ii] = -1;
1779 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
1781 Float_t pos[3] = {0.,0.,0.};
1784 Int_t interestingPadX[kMaxNumberOfInterestingPads];
1785 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
1786 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
1787 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
1788 Double_t interestingTOT[kMaxNumberOfInterestingPads];
1789 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
1790 Double_t interestingADC[kMaxNumberOfInterestingPads];
1791 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
1792 Double_t interestingTOF[kMaxNumberOfInterestingPads];
1793 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
1794 Double_t interestingWeight[kMaxNumberOfInterestingPads];
1795 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
1797 Float_t interestingX[kMaxNumberOfInterestingPads];
1798 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
1799 Float_t interestingY[kMaxNumberOfInterestingPads];
1800 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
1801 Float_t interestingZ[kMaxNumberOfInterestingPads];
1802 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
1804 Float_t interDigit[kMaxNumberOfInterestingPads];
1805 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
1807 Int_t padsCluster[11];
1808 padsCluster[0] = nSector;
1809 padsCluster[1] = nPlate;
1810 padsCluster[2] = nStrip;
1811 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1813 Int_t interestingCounter=-1;
1814 Int_t digitIndexLocal = -1;
1819 Bool_t check = kFALSE;
1821 for (jj=0; jj<5; jj++) parTOF[jj] = 0;
1822 Double_t posClus[3];
1823 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
1825 for (jj=0; jj<5; jj++) det[jj] = -1;
1827 for (jj=0; jj<3; jj++) posF[jj] = 0.;
1828 UShort_t volIdClus = 0;
1829 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
1830 Double_t covClus[6];
1831 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1832 Int_t tracks[kMaxNumberOfTracksPerDigit];
1833 for (jj=0; jj<3; jj++) tracks[jj] = -1;
1834 Int_t dummyCounter=-1;
1835 Bool_t alreadyStored = kFALSE;
1837 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
1838 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1839 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
1841 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1842 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
1844 AliTOFdigit *digitInteresting;
1846 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
1848 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
1849 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
1851 AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
1858 interestingCounter=-1;
1860 vol[4] = iPadZ , vol[3] = iPadX;
1861 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1862 interestingCounter++;
1864 vol[4] = iPadZ, vol[3] = iPadX+1;
1865 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1866 interestingCounter++;
1868 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1869 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1870 interestingCounter++;
1872 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1873 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1874 interestingCounter++;
1876 if (interestingCounter+1!=4) continue; // the hit pads have to be 4
1877 else interestingCounter=-1;
1880 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1881 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1882 selectedDigit[ii][jj] = 0x0;
1885 vol[4] = iPadZ, vol[3] = iPadX;
1887 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1888 interestingCounter++;
1889 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1890 digitsInVolumeIndices[ii] = -1;
1891 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1892 digitIndexLocal=-1; // AdC
1893 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1894 if (digitsInVolumeIndices[digIndex]<0) continue;
1895 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1896 if (digitInteresting->GetToT()<=0) continue; // AdC
1897 digitIndexLocal++; // AdC
1899 AliDebug(1,Form(" %2d %1d %2d %1d %2d %f %f %f %f %5d %5d %5d %5d",
1900 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1901 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1902 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1903 digitsInVolumeIndices[digIndex],
1904 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1906 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1907 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1908 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1909 digitInteresting->GetToT()*digitInteresting->GetToT(),
1910 digitsInVolumeIndices[digIndex],
1911 digitInteresting->GetTracks());
1913 if (digitIndexLocal==-1) interestingCounter--; // AdC
1917 vol[4] = iPadZ, vol[3] = iPadX+1;
1919 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1920 interestingCounter++;
1921 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1922 digitsInVolumeIndices[ii] = -1;
1923 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1924 digitIndexLocal=-1; // AdC
1925 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1926 if (digitsInVolumeIndices[digIndex]<0) continue;
1927 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1928 if (digitInteresting->GetToT()<=0) continue; // AdC
1929 digitIndexLocal++; // AdC
1931 AliDebug(1,Form(" %2d %1d %2d %1d %2d %f %f %f %f %5d %5d %5d %5d",
1932 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1933 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1934 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1935 digitsInVolumeIndices[digIndex],
1936 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1938 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1939 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1940 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1941 digitInteresting->GetToT()*digitInteresting->GetToT(),
1942 digitsInVolumeIndices[digIndex],
1943 digitInteresting->GetTracks());
1945 if (digitIndexLocal==-1) interestingCounter--; // AdC
1949 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1951 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1952 interestingCounter++;
1953 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1954 digitsInVolumeIndices[ii] = -1;
1955 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1956 digitIndexLocal=-1; // AdC
1957 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1958 if (digitsInVolumeIndices[digIndex]<0) continue;
1959 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1960 if (digitInteresting->GetToT()<=0) continue; // AdC
1961 digitIndexLocal++; // AdC
1963 AliDebug(1,Form(" %2d %1d %2d %1d %2d %f %f %f %f %5d %5d %5d %5d",
1964 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1965 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1966 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1967 digitsInVolumeIndices[digIndex],
1968 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1970 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1971 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1972 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1973 digitInteresting->GetToT()*digitInteresting->GetToT(),
1974 digitsInVolumeIndices[digIndex],
1975 digitInteresting->GetTracks());
1977 if (digitIndexLocal==-1) interestingCounter--; // AdC
1981 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1983 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1984 interestingCounter++;
1985 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1986 digitsInVolumeIndices[ii] = -1;
1987 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1988 digitIndexLocal=-1; // AdC
1989 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1990 if (digitsInVolumeIndices[digIndex]<0) continue;
1991 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1992 if (digitInteresting->GetToT()<=0) continue; // AdC
1993 digitIndexLocal++; // AdC
1995 AliDebug(1,Form(" %2d %1d %2d %1d %2d %f %f %f %f %5d %5d %5d %5d",
1996 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1997 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1998 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1999 digitsInVolumeIndices[digIndex],
2000 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2002 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2003 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2004 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2005 digitInteresting->GetToT()*digitInteresting->GetToT(),
2006 digitsInVolumeIndices[digIndex],
2007 digitInteresting->GetTracks());
2009 if (digitIndexLocal==-1) interestingCounter--; // AdC
2012 AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
2014 for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
2015 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2016 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2018 for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
2019 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2020 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2022 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime) continue;
2024 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2025 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2026 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2027 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2028 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
2029 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
2030 Int_t volDum = vol1[3];
2033 fTOFGeometry->GetPosPar(vol1,pos);
2034 interestingX[0] = pos[0];
2035 interestingY[0] = pos[1];
2036 interestingZ[0] = pos[2];
2038 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2039 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2040 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2041 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2042 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
2043 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
2047 fTOFGeometry->GetPosPar(vol2,pos);
2048 interestingX[1] = pos[0];
2049 interestingY[1] = pos[1];
2050 interestingZ[1] = pos[2];
2053 AverageCalculations(2, interestingX, interestingY, interestingZ,
2054 interestingTOF, interestingTOT, interestingADC,
2056 parTOF, posClus, check);
2058 for (jj=0; jj<5; jj++) det[jj] = -1;
2059 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
2060 fTOFGeometry->GetDetID(posF, det);
2062 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
2063 //volIdClus = GetClusterVolIndex(det);
2065 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2066 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
2067 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
2068 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
2069 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
2071 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2072 Int_t ** indDet = new Int_t*[2];
2073 for (jj=0; jj<2; jj++) indDet[jj] = new Int_t [5];
2074 for (jj=0; jj<2; jj++) indDet[jj][0] = nSector;
2075 for (jj=0; jj<2; jj++) indDet[jj][1] = nPlate;
2076 for (jj=0; jj<2; jj++) indDet[jj][2] = nStrip;
2077 for (jj=0; jj<2; jj++) indDet[jj][3] = padsCluster[2*jj+3];
2078 for (jj=0; jj<2; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
2079 GetClusterPars(/*check,*/ 2, indDet, interestingWeight, posClus, covClus);
2080 for (jj=0; jj<2; jj++) delete [] indDet[jj];
2082 // To fill the track index array
2084 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2085 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2086 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
2089 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
2092 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2093 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
2096 alreadyStored = kFALSE;
2097 for (jj=0; jj<dummyCounter+1; jj++)
2098 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
2100 if (alreadyStored) continue;
2101 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2102 AliWarning(" Siamo al limite!");
2107 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
2114 AliTOFcluster *tofCluster =
2115 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
2116 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2117 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
2118 InsertCluster(tofCluster);
2120 AliDebug(2, Form(" %4d %f %f %f %f %f %f %f %f %f %3d %3d %3d %2d %1d %2d %1d %2d %4d %3d %3d %4d %4d %1d %4d",
2121 volIdClus, posClus[0], posClus[1], posClus[2],
2122 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2123 tracks[0], tracks[1], tracks[2],
2124 det[0], det[1], det[2], det[3], det[4],
2125 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
2126 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
2131 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
2135 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
2138 } // close loop on second digit
2139 } // close loop on adesso2
2141 } // close loop on first digit
2142 } // close loop on adesso1
2144 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2145 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
2146 selectedDigit[ii][jj] = 0x0;
2150 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2151 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
2152 delete selectedDigit[ii][jj];
2153 selectedDigit[ii][jj] = 0x0;
2158 //_____________________________________________________________________________
2160 void AliTOFClusterFinderV1::FindClustersPerStrip(Int_t nSector,
2166 // This function searches the neighbouring digits (stored in the fDigits object),
2167 // to perform clusters (stored in the fTofClusters array).
2169 // Each strip is read four times:
2170 // - 1st time: it searches possible clusters formed by four
2171 // neighbouring digits;
2172 // - 2nd time: it searches possible clusters formed by three
2173 // neighbouring digits;
2174 // - 3rd time: it searches possible clusters formed by two
2175 // neighbouring digits;
2176 // - 4th time: the remaining isolated digits have been transformed
2178 // This research has been made by checking the fTOFdigitMap object,
2179 // filled at digits/raw-data reading time.
2182 const Int_t kMaxNumberOfInterestingPads = 4;
2183 const Int_t kMaxNumberOfTracksPerDigit = 3;
2184 const Int_t kMaxNumberOfDigitsPerVolume = 3;
2188 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
2189 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2190 digitsInVolumeIndices[ii] = -1;
2192 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
2194 Float_t pos[3] = {0.,0.,0.};
2197 Int_t interestingPadX[kMaxNumberOfInterestingPads];
2198 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
2199 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
2200 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
2201 Double_t interestingTOT[kMaxNumberOfInterestingPads];
2202 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
2203 Double_t interestingADC[kMaxNumberOfInterestingPads];
2204 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
2205 Double_t interestingTOF[kMaxNumberOfInterestingPads];
2206 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
2207 Double_t interestingWeight[kMaxNumberOfInterestingPads];
2208 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
2210 Float_t interestingX[kMaxNumberOfInterestingPads];
2211 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
2212 Float_t interestingY[kMaxNumberOfInterestingPads];
2213 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
2214 Float_t interestingZ[kMaxNumberOfInterestingPads];
2215 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
2217 Float_t interDigit[kMaxNumberOfInterestingPads];
2218 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
2220 Int_t padsCluster[11];
2221 padsCluster[0] = nSector;
2222 padsCluster[1] = nPlate;
2223 padsCluster[2] = nStrip;
2224 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2226 Int_t interestingCounter=-1;
2227 Int_t digitIndexLocal = -1;
2232 Bool_t check = kFALSE;
2234 for (jj=0; jj<5; jj++) parTOF[jj] = 0;
2235 Double_t posClus[3];
2236 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
2238 for (jj=0; jj<5; jj++) det[jj] = -1;
2240 for (jj=0; jj<3; jj++) posF[jj] = 0.;
2241 UShort_t volIdClus = 0;
2242 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
2243 Double_t covClus[6];
2244 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2245 Int_t tracks[kMaxNumberOfTracksPerDigit];
2246 for (jj=0; jj<3; jj++) tracks[jj] = -1;
2247 Int_t dummyCounter=-1;
2248 Bool_t alreadyStored = kFALSE;
2250 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
2251 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2252 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
2254 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2255 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
2257 AliTOFdigit *digitInteresting;
2261 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
2263 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
2264 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
2266 AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
2273 interestingCounter=-1;
2275 vol[4] = iPadZ , vol[3] = iPadX;
2276 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2277 interestingCounter++;
2279 vol[4] = iPadZ, vol[3] = iPadX+1;
2280 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2281 interestingCounter++;
2283 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
2284 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2285 interestingCounter++;
2287 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
2288 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2289 interestingCounter++;
2291 if (interestingCounter!=group) continue;
2292 else interestingCounter=-1;
2295 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2296 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
2297 selectedDigit[ii][jj] = 0x0;
2300 vol[4] = iPadZ, vol[3] = iPadX;
2302 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2303 interestingCounter++;
2304 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2305 digitsInVolumeIndices[ii] = -1;
2306 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2307 digitIndexLocal=-1; // AdC
2308 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2309 if (digitsInVolumeIndices[digIndex]<0) continue;
2310 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2311 if (digitInteresting->GetToT()<=0) continue; // AdC
2312 digitIndexLocal++; // AdC
2314 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2315 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2316 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2317 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2318 digitsInVolumeIndices[digIndex],
2319 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2320 AliDebug(1,Form(" to try %d %d ",digIndex, interestingCounter));
2322 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2323 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2324 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2325 digitInteresting->GetToT()*digitInteresting->GetToT(),
2326 digitsInVolumeIndices[digIndex],
2327 digitInteresting->GetTracks());
2329 if (digitIndexLocal==-1) interestingCounter--; // AdC
2333 vol[4] = iPadZ, vol[3] = iPadX+1;
2335 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2336 interestingCounter++;
2337 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2338 digitsInVolumeIndices[ii] = -1;
2339 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2340 digitIndexLocal=-1; // AdC
2341 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2342 if (digitsInVolumeIndices[digIndex]<0) continue;
2343 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2344 if (digitInteresting->GetToT()<=0) continue; // AdC
2345 digitIndexLocal++; // AdC
2347 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2348 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2349 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2350 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2351 digitsInVolumeIndices[digIndex],
2352 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2353 AliDebug(1,Form(" to try %d %d ",digIndex, interestingCounter));
2355 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2356 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2357 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2358 digitInteresting->GetToT()*digitInteresting->GetToT(),
2359 digitsInVolumeIndices[digIndex],
2360 digitInteresting->GetTracks());
2362 if (digitIndexLocal==-1) interestingCounter--; // AdC
2366 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
2368 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2369 interestingCounter++;
2370 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2371 digitsInVolumeIndices[ii] = -1;
2372 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2373 digitIndexLocal=-1; // AdC
2374 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2375 if (digitsInVolumeIndices[digIndex]<0) continue;
2376 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2377 if (digitInteresting->GetToT()<=0) continue; // AdC
2378 digitIndexLocal++; // AdC
2380 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2381 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2382 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2383 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2384 digitsInVolumeIndices[digIndex],
2385 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2386 AliDebug(1,Form(" to try %d %d ",digIndex, interestingCounter));
2388 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2389 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2390 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2391 digitInteresting->GetToT()*digitInteresting->GetToT(),
2392 digitsInVolumeIndices[digIndex],
2393 digitInteresting->GetTracks());
2395 if (digitIndexLocal==-1) interestingCounter--; // AdC
2399 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
2401 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2402 interestingCounter++;
2403 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2404 digitsInVolumeIndices[ii] = -1;
2405 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2406 digitIndexLocal=-1; // AdC
2407 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2408 if (digitsInVolumeIndices[digIndex]<0) continue;
2409 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2410 if (digitInteresting->GetToT()<=0) continue; // AdC
2411 digitIndexLocal++; // AdC
2413 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2414 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2415 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2416 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2417 digitsInVolumeIndices[digIndex],
2418 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2419 AliDebug(1,Form(" to try %d %d ",digIndex, interestingCounter));
2421 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2422 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2423 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2424 digitInteresting->GetToT()*digitInteresting->GetToT(),
2425 digitsInVolumeIndices[digIndex],
2426 digitInteresting->GetTracks());
2428 if (digitIndexLocal==-1) interestingCounter--; // AdC
2431 AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
2433 switch(interestingCounter+1) {
2437 for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
2438 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2439 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2441 for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
2442 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2443 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2445 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime) continue;
2447 AliDebug(1, Form(" %1d %1d (0x%x) %1d %1d (0x%x)", adesso1, firstIndex,selectedDigit[adesso1][firstIndex],
2448 adesso2, secondIndex,selectedDigit[adesso2][secondIndex]));
2450 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2451 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2452 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2453 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2454 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
2455 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
2456 Int_t volDum = vol1[3];
2459 fTOFGeometry->GetPosPar(vol1,pos);
2460 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
2461 interestingX[0] = pos[0];
2462 interestingY[0] = pos[1];
2463 interestingZ[0] = pos[2];
2465 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2466 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2467 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2468 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2469 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
2470 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
2474 fTOFGeometry->GetPosPar(vol2,pos);
2475 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
2476 interestingX[1] = pos[0];
2477 interestingY[1] = pos[1];
2478 interestingZ[1] = pos[2];
2481 AverageCalculations(interestingCounter+1,
2482 interestingX, interestingY, interestingZ,
2483 interestingTOF, interestingTOT, interestingADC,
2485 parTOF, posClus, check);
2487 for (jj=0; jj<5; jj++) det[jj] = -1;
2488 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
2490 AliDebug(1,Form(" %f %f %f", posF[0], posF[1], posF[2]));
2491 fTOFGeometry->GetDetID(posF, det);
2492 AliDebug(1,Form(" %2d %1d %2d %1d %2d", det[0], det[1], det[2], det[3], det[4]));
2494 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
2495 //volIdClus = GetClusterVolIndex(det);
2497 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2498 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
2499 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
2500 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
2501 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
2503 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2504 Int_t ** indDet = new Int_t*[interestingCounter+1];
2505 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj] = new Int_t [5];
2506 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][0] = nSector;
2507 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][1] = nPlate;
2508 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][2] = nStrip;
2509 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][3] = padsCluster[2*jj+3];
2510 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
2511 GetClusterPars(/*check,*/ interestingCounter+1, indDet, interestingWeight, posClus, covClus);
2512 for (jj=0; jj<interestingCounter+1; jj++) delete [] indDet[jj];
2514 // To fill the track index array
2516 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2517 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2518 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
2521 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
2524 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2525 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
2528 alreadyStored = kFALSE;
2529 for (jj=0; jj<dummyCounter+1; jj++)
2530 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
2532 if (alreadyStored) continue;
2533 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2534 AliWarning(" Siamo al limite!");
2539 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
2546 AliTOFcluster *tofCluster =
2547 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
2548 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2549 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); //to updated
2550 InsertCluster(tofCluster);
2552 AliDebug(2, Form(" %4d %f %f %f %f %f %f %f %f %f %3d %3d %3d %2d %1d %2d %1d %2d %4d %3d %3d %4d %4d %1d %4d",
2553 volIdClus, posClus[0], posClus[1], posClus[2],
2554 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2555 tracks[0], tracks[1], tracks[2],
2556 det[0], det[1], det[2], det[3], det[4],
2557 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
2558 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
2563 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
2567 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
2570 } // close loop on second digit
2571 } // close loop on adesso2
2573 } // close loop on first digit
2574 } // close loop on adesso1
2581 for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
2582 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2583 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2585 for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
2586 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2587 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2589 for (Int_t adesso3=adesso2+1; adesso3<interestingCounter+1; adesso3++) {
2590 for (Int_t thirdIndex=0; thirdIndex<kMaxNumberOfDigitsPerVolume; thirdIndex++) {
2591 if (selectedDigit[adesso3][thirdIndex]==0x0) continue;
2594 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime
2596 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
2598 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime) continue;
2600 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2601 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2602 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2603 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2604 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
2605 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
2606 Int_t volDum = vol1[3];
2609 fTOFGeometry->GetPosPar(vol1,pos);
2610 interestingX[0] = pos[0];
2611 interestingY[0] = pos[1];
2612 interestingZ[0] = pos[2];
2614 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2615 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2616 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2617 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2618 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
2619 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
2623 fTOFGeometry->GetPosPar(vol2,pos);
2624 interestingX[1] = pos[0];
2625 interestingY[1] = pos[1];
2626 interestingZ[1] = pos[2];
2628 interestingTOF[2] = selectedDigit[adesso3][thirdIndex]->GetTDC();
2629 interestingTOT[2] = selectedDigit[adesso3][thirdIndex]->GetTOT();
2630 interestingADC[2] = selectedDigit[adesso3][thirdIndex]->GetADC();
2631 interestingWeight[2] = selectedDigit[adesso3][thirdIndex]->GetWeight();
2632 Int_t vol3[5]; for(jj=0; jj<5; jj++) vol3[jj] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(jj);
2633 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol3[0], vol3[1], vol3[2], vol3[4], vol3[3]));
2637 fTOFGeometry->GetPosPar(vol3,pos);
2638 interestingX[2] = pos[0];
2639 interestingY[2] = pos[1];
2640 interestingZ[2] = pos[2];
2643 AverageCalculations(interestingCounter+1,
2644 interestingX, interestingY, interestingZ,
2645 interestingTOF, interestingTOT, interestingADC,
2647 parTOF, posClus, check);
2649 for (jj=0; jj<5; jj++) det[jj] = -1;
2650 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
2651 fTOFGeometry->GetDetID(posF, det);
2653 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
2654 //volIdClus = GetClusterVolIndex(det);
2656 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2657 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
2658 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
2659 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
2660 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
2661 padsCluster[7] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(4);
2662 padsCluster[8] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(3);
2664 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2665 Int_t ** indDet = new Int_t*[interestingCounter+1];
2666 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj] = new Int_t [5];
2667 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][0] = nSector;
2668 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][1] = nPlate;
2669 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][2] = nStrip;
2670 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][3] = padsCluster[2*jj+3];
2671 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
2672 GetClusterPars(/*check,*/ interestingCounter+1, indDet, interestingWeight, posClus, covClus);
2673 for (jj=0; jj<interestingCounter+1; jj++) delete [] indDet[jj];
2675 // To fill the track index array
2677 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2678 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2679 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
2682 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
2685 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2686 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
2689 alreadyStored = kFALSE;
2690 for (jj=0; jj<dummyCounter+1; jj++)
2691 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
2693 if (alreadyStored) continue;
2694 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2695 AliWarning(" Siamo al limite!");
2700 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
2705 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2706 if (selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk)==-1) continue;
2709 alreadyStored = kFALSE;
2710 for (jj=0; jj<dummyCounter+1; jj++)
2711 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk));
2713 if (alreadyStored) continue;
2714 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2715 AliWarning(" Siamo al limite!");
2720 tracks[dummyCounter] = selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk);
2727 AliTOFcluster *tofCluster =
2728 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
2729 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2730 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
2731 InsertCluster(tofCluster);
2733 AliDebug(2, Form(" %4d %f %f %f %f %f %f %f %f %f %3d %3d %3d %2d %1d %2d %1d %2d %4d %3d %3d %4d %4d %1d %4d",
2734 volIdClus, posClus[0], posClus[1], posClus[2],
2735 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2736 tracks[0], tracks[1], tracks[2],
2737 det[0], det[1], det[2], det[3], det[4],
2738 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
2739 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
2744 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
2748 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
2752 fTOFdigitMap->ResetDigitNumber(vol3,selectedDigit[adesso3][thirdIndex]->GetIndex());
2755 } // close loop on third digit
2756 } // close loop on adesso3
2758 } // close loop on second digit
2759 } // close loop on adesso2
2761 } // close loop on first digit
2762 } // close loop on adesso1
2770 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2771 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2774 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2775 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2778 for (Int_t thirdIndex=0; thirdIndex<kMaxNumberOfDigitsPerVolume; thirdIndex++) {
2779 if (selectedDigit[adesso3][thirdIndex]==0x0) continue;
2782 for (Int_t fourthIndex=0; fourthIndex<kMaxNumberOfDigitsPerVolume; fourthIndex++) {
2783 if (selectedDigit[adesso4][fourthIndex]==0x0) continue;
2786 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime
2788 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
2790 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso4][fourthIndex]->GetTDC())>fMaxDeltaTime
2792 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
2794 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso4][fourthIndex]->GetTDC())>fMaxDeltaTime
2796 TMath::Abs(selectedDigit[adesso3][thirdIndex]->GetTDC()-selectedDigit[adesso4][fourthIndex]->GetTDC())>fMaxDeltaTime) continue;
2798 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2799 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2800 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2801 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2802 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
2803 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
2804 Int_t volDum = vol1[3];
2807 fTOFGeometry->GetPosPar(vol1,pos);
2808 interestingX[0] = pos[0];
2809 interestingY[0] = pos[1];
2810 interestingZ[0] = pos[2];
2812 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2813 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2814 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2815 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2816 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
2817 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
2821 fTOFGeometry->GetPosPar(vol2,pos);
2822 interestingX[1] = pos[0];
2823 interestingY[1] = pos[1];
2824 interestingZ[1] = pos[2];
2826 interestingTOF[2] = selectedDigit[adesso3][thirdIndex]->GetTDC();
2827 interestingTOT[2] = selectedDigit[adesso3][thirdIndex]->GetTOT();
2828 interestingADC[2] = selectedDigit[adesso3][thirdIndex]->GetADC();
2829 interestingWeight[2] = selectedDigit[adesso3][thirdIndex]->GetWeight();
2830 Int_t vol3[5]; for(jj=0; jj<5; jj++) vol3[jj] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(jj);
2831 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol3[0], vol3[1], vol3[2], vol3[4], vol3[3]));
2835 fTOFGeometry->GetPosPar(vol3,pos);
2836 interestingX[2] = pos[0];
2837 interestingY[2] = pos[1];
2838 interestingZ[2] = pos[2];
2840 interestingTOF[3] = selectedDigit[adesso4][fourthIndex]->GetTDC();
2841 interestingTOT[3] = selectedDigit[adesso4][fourthIndex]->GetTOT();
2842 interestingADC[3] = selectedDigit[adesso4][fourthIndex]->GetADC();
2843 interestingWeight[3] = selectedDigit[adesso4][fourthIndex]->GetWeight();
2844 Int_t vol4[5]; for(jj=0; jj<5; jj++) vol4[jj] = selectedDigit[adesso4][fourthIndex]->GetDetectorIndex(jj);
2845 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol4[0], vol4[1], vol4[2], vol4[4], vol4[3]));
2849 fTOFGeometry->GetPosPar(vol4,pos);
2850 interestingX[3] = pos[0];
2851 interestingY[3] = pos[1];
2852 interestingZ[3] = pos[2];
2855 AverageCalculations(interestingCounter+1,
2856 interestingX, interestingY, interestingZ,
2857 interestingTOF, interestingTOT, interestingADC,
2859 parTOF, posClus, check);
2861 for (jj=0; jj<5; jj++) det[jj] = -1;
2862 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
2863 fTOFGeometry->GetDetID(posF, det);
2865 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
2866 //volIdClus = GetClusterVolIndex(det);
2868 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2869 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
2870 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
2871 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
2872 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
2873 padsCluster[7] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(4);
2874 padsCluster[8] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(3);
2875 padsCluster[9] = selectedDigit[adesso4][fourthIndex]->GetDetectorIndex(4);
2876 padsCluster[10] = selectedDigit[adesso4][fourthIndex]->GetDetectorIndex(3);
2878 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2879 Int_t ** indDet = new Int_t*[interestingCounter+1];
2880 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj] = new Int_t [5];
2881 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][0] = nSector;
2882 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][1] = nPlate;
2883 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][2] = nStrip;
2884 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][3] = padsCluster[2*jj+3];
2885 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
2886 GetClusterPars(/*check,*/ interestingCounter+1, indDet, interestingWeight, posClus, covClus);
2887 for (jj=0; jj<interestingCounter+1; jj++) delete [] indDet[jj];
2889 // To fill the track index array
2891 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2892 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2893 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
2896 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
2899 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2900 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
2903 alreadyStored = kFALSE;
2904 for (jj=0; jj<dummyCounter+1; jj++)
2905 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
2907 if (alreadyStored) continue;
2908 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2909 AliWarning(" Siamo al limite!");
2914 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
2919 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2920 if (selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk)==-1) continue;
2923 alreadyStored = kFALSE;
2924 for (jj=0; jj<dummyCounter+1; jj++)
2925 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk));
2927 if (alreadyStored) continue;
2928 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2929 AliWarning(" Siamo al limite!");
2934 tracks[dummyCounter] = selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk);
2939 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2940 if (selectedDigit[adesso4][fourthIndex]->GetTrackLabel(kk)==-1) continue;
2943 alreadyStored = kFALSE;
2944 for (jj=0; jj<dummyCounter+1; jj++)
2945 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso4][fourthIndex]->GetTrackLabel(kk));
2947 if (alreadyStored) continue;
2948 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2949 AliWarning(" Siamo al limite!");
2954 tracks[dummyCounter] = selectedDigit[adesso4][fourthIndex]->GetTrackLabel(kk);
2961 AliTOFcluster *tofCluster =
2962 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
2963 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2964 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
2965 InsertCluster(tofCluster);
2967 AliDebug(2, Form(" %4d %f %f %f %f %f %f %f %f %f %3d %3d %3d %2d %1d %2d %1d %2d %4d %3d %3d %4d %4d %1d %4d",
2968 volIdClus, posClus[0], posClus[1], posClus[2],
2969 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2970 tracks[0], tracks[1], tracks[2],
2971 det[0], det[1], det[2], det[3], det[4],
2972 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
2973 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
2978 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
2982 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
2986 fTOFdigitMap->ResetDigitNumber(vol3,selectedDigit[adesso3][thirdIndex]->GetIndex());
2990 fTOFdigitMap->ResetDigitNumber(vol4,selectedDigit[adesso4][fourthIndex]->GetIndex());
2993 } // close loop on fourth digit
2995 } // close loop on third digit
2997 } // close loop on second digit
2999 } // close loop on first digit
3005 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
3006 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
3007 selectedDigit[ii][jj] = 0x0;
3011 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
3012 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
3013 delete selectedDigit[ii][jj];
3014 selectedDigit[ii][jj] = 0x0;
3018 //_____________________________________________________________________________
3020 Int_t AliTOFClusterFinderV1::InsertCluster(AliTOFcluster *tofCluster)
3023 // This function adds a TOF cluster to the array of TOF clusters
3024 // sorted in Z, i.e. fTofClusters
3027 if (fNumberOfTofClusters==kTofMaxCluster) {
3028 AliError("Too many clusters !");
3032 if (fNumberOfTofClusters==0) {
3033 fTofClusters[fNumberOfTofClusters++] = tofCluster;
3037 Int_t ii = FindClusterIndex(tofCluster->GetZ());
3038 memmove(fTofClusters+ii+1 ,fTofClusters+ii,(fNumberOfTofClusters-ii)*sizeof(AliTOFcluster*));
3039 fTofClusters[ii] = tofCluster;
3040 fNumberOfTofClusters++;
3045 //_____________________________________________________________________________
3047 Int_t AliTOFClusterFinderV1::FindClusterIndex(Double_t z) const
3050 // This function returns the index of the nearest cluster in z
3053 if (fNumberOfTofClusters==0) return 0;
3054 if (z <= fTofClusters[0]->GetZ()) return 0;
3055 if (z > fTofClusters[fNumberOfTofClusters-1]->GetZ()) return fNumberOfTofClusters;
3056 Int_t b = 0, e = fNumberOfTofClusters-1, m = (b+e)/2;
3057 for (; b<e; m=(b+e)/2) {
3058 if (z > fTofClusters[m]->GetZ()) b=m+1;
3065 //_____________________________________________________________________________
3067 void AliTOFClusterFinderV1::ResetRecpoint()
3070 // Clear the list of reconstructed points
3073 fNumberOfTofClusters = 0;
3074 if (fRecPoints) fRecPoints->Clear();
3077 //_____________________________________________________________________________
3079 void AliTOFClusterFinderV1::ResetDigits()
3082 // Clear the list of digits
3085 fNumberOfTofDigits = 0;
3086 if (fDigits) fDigits->Clear();
3089 //_____________________________________________________________________________
3090 //UShort_t AliTOFClusterFinderV1::GetClusterVolIndex(Int_t *ind) const
3093 // Get the volume ID to retrieve the l2t transformation
3096 // Detector numbering scheme
3098 Int_t nSector = AliTOFGeometry::NSectors();
3099 Int_t nPlate = AliTOFGeometry::NPlates();
3100 Int_t nStripA = AliTOFGeometry::NStripA();
3101 Int_t nStripB = AliTOFGeometry::NStripB();
3102 Int_t nStripC = AliTOFGeometry::NStripC();
3104 Int_t isector =ind[0];
3105 if (isector >= nSector)
3106 AliError(Form("Wrong sector number in TOF (%d) !", isector));
3107 Int_t iplate = ind[1];
3108 if (iplate >= nPlate)
3109 AliError(Form("Wrong plate number in TOF (%d) !", iplate));
3110 Int_t istrip = ind[2];
3112 Int_t stripOffset = 0;
3118 stripOffset = nStripC;
3121 stripOffset = nStripC+nStripB;
3124 stripOffset = nStripC+nStripB+nStripA;
3127 stripOffset = nStripC+nStripB+nStripA+nStripB;
3130 AliError(Form("Wrong plate number in TOF (%d) !", iplate));
3134 Int_t index= (2*(nStripC+nStripB)+nStripA)*isector +
3138 UShort_t volIndex = AliGeomManager::LayerToVolUID(AliGeomManager::kTOF, index);
3143 //_____________________________________________________________________________
3145 void AliTOFClusterFinderV1::GetClusterPars(Int_t *ind, Double_t* pos, Double_t* cov) const
3148 // Starting from the volume indices (ind[5]), for a cluster coming from
3149 // a isolated digits, this function returns:
3150 // the cluster position (pos),
3151 // the cluster covariance matrix elements (cov)
3155 //we now go in the system of the strip: determine the local coordinates
3158 // 47---------------------------------------------------0 ^ z
3159 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 1 |
3160 // ----------------------------------------------------- | y going outwards
3161 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 0 | par[0]=0;
3163 // ----------------------------------------------------- |
3164 // x <-----------------------------------------------------
3166 //move to the tracking ref system
3167 Double_t lpos[3] = { (ind[4]-23.5)*AliTOFGeometry::XPad(),
3169 (ind[3]- 0.5)*AliTOFGeometry::ZPad() };
3170 AliDebug(1, Form(" %f %f %f", lpos[0], lpos[1], lpos[2]));
3173 UShort_t volIndex = fTOFGeometry->GetAliSensVolIndex(ind[0],ind[1],ind[2]);
3174 //UShort_t volIndex = GetClusterVolIndex(ind);
3175 const TGeoHMatrix *l2t = AliGeomManager::GetTracking2LocalMatrix(volIndex);
3177 // Get the position in the track ref system
3179 l2t->MasterToLocal(lpos,tpos);
3184 //Get the cluster covariance in the track ref system
3186 for (Int_t ii=0; ii<9; ii++) lcov[ii] = 0.;
3188 //cluster covariance in the local system:
3193 lcov[4] = 0.42*0.42/3.;
3194 // = ( 5*0.025 (gas gaps thikness)
3195 // + 4*0.040 (internal glasses thickness)
3196 // + 0.5*0.160 (internl PCB)
3197 // + 1*0.055 (external red glass))
3200 lcov[0] = 0.499678;//AliTOFGeometry::XPad()*AliTOFGeometry::XPad()/12.;
3201 lcov[8] = 0.992429;//AliTOFGeometry::ZPad()*AliTOFGeometry::ZPad()/12.;
3203 //cluster covariance in the tracking system:
3205 m.SetRotation(lcov);
3207 m.MultiplyLeft(&l2t->Inverse());
3208 Double_t *tcov = m.GetRotationMatrix();
3209 cov[0] = tcov[0]; cov[1] = tcov[1]; cov[2] = tcov[2];
3210 cov[3] = tcov[4]; cov[4] = tcov[5]; cov[5] = tcov[8];
3215 //_____________________________________________________________________________
3217 void AliTOFClusterFinderV1::GetClusterPars(/*Bool_t check,*/ Int_t counter,
3218 Int_t **ind, Double_t *weight,
3219 Double_t *pos, Double_t *cov) const
3223 // the volumes indices (ind[counter][5]), for a
3224 // cluster coming from a collection of 'counter'
3226 // the volumes weights (weight[counter]), -controlled
3227 // by the 'check' variable control-, for a cluster
3228 // coming from a collection of 'counter' digits,
3229 // the cluster position (pos),
3230 // this function returns:
3231 // the covariance matrix elements (cov) for the found cluster
3235 // we now go in the system of the strip: determine the local coordinates
3237 // 47---------------------------------------------------0 ^ z
3238 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 1 |
3239 // ----------------------------------------------------- | y going outwards
3240 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 0 | par[0]=0;
3242 // ----------------------------------------------------- |
3243 // x <-----------------------------------------------------
3245 for (Int_t ii=0; ii<counter; ii++)
3246 AliDebug(1, Form(" %2d %2d %1d %2d %1d %2d ",
3247 ii, ind[ii][0], ind[ii][1], ind[ii][2], ind[ii][3], ind[ii][4]));
3249 Float_t posF[3]; for (Int_t ii=0; ii<3; ii++) posF[ii] = (Float_t)pos[ii];
3250 AliDebug(1, Form(" %f %f %f", pos[0], pos[1], pos[2]));
3252 Int_t detClus[5] = {-1, -1, -1, -1, -1};
3253 fTOFGeometry->GetDetID(posF, detClus);
3256 UShort_t volIndex = fTOFGeometry->GetAliSensVolIndex(detClus[0],detClus[1],detClus[2]);
3257 //UShort_t volIndex = GetClusterVolIndex(detClus);
3258 AliDebug(1, Form(" %2d %1d %2d %1d %2d %7i",
3259 detClus[0], detClus[1], detClus[2], detClus[3], detClus[4], volIndex));
3261 // Get the position in the TOF strip ref system
3262 const TGeoHMatrix *alice2strip = AliGeomManager::GetOrigGlobalMatrix(volIndex);
3263 Double_t ppos[3] = {-1, -1, -1};
3264 alice2strip->MasterToLocal(pos,ppos);
3265 AliDebug(1, Form(" %f %f %f", ppos[0], ppos[1], ppos[2]));
3268 // Get the position in the tracking ref system
3269 const TGeoHMatrix *g2l = AliGeomManager::GetTracking2LocalMatrix(volIndex);
3270 Double_t lpos[3] = {-1, -1, -1};
3271 g2l->MasterToLocal(ppos,lpos);
3272 AliDebug(1, Form(" %f %f %f", lpos[0], lpos[1], lpos[2]));
3273 for (Int_t ii=0; ii<3; ii++) pos[ii] = lpos[ii];
3275 //Get the cluster covariance in the track ref system
3277 for (Int_t ii=0; ii<9; ii++) lcov[ii] = 0.;
3279 //cluster covariance in the local system:
3284 // Evaluation of the ovariance matrix elements
3285 TOFclusterError(/*check,*/ counter, ind, weight, ppos, lcov);
3287 AliDebug(1, Form("lcov[0] = %f, lcov[8] = %f", lcov[0], lcov[8]));
3289 //cluster covariance in the tracking system:
3291 m.SetRotation(lcov);
3293 m.MultiplyLeft(&g2l->Inverse());
3294 Double_t *tcov = m.GetRotationMatrix();
3295 cov[0] = tcov[0]; cov[1] = tcov[1]; cov[2] = tcov[2];
3296 cov[3] = tcov[4]; cov[4] = tcov[5]; cov[5] = tcov[8];
3301 //_____________________________________________________________________________
3303 void AliTOFClusterFinderV1::TOFclusterError(/*Bool_t check,*/ Int_t counter,
3304 Int_t **ind, Double_t *weight,
3305 Double_t ppos[], Double_t lcov[]) const
3311 //lcov[4] = 0.42*0.42/3.; // cm2
3312 // = ( 5*0.025 (gas gaps thikness)
3313 // + 4*0.040 (internal glasses thickness)
3314 // + 0.5*0.160 (internl PCB)
3315 // + 1*0.055 (external red glass))
3318 Float_t *delta2X = new Float_t[counter];
3319 for (Int_t ii=0; ii<counter; ii++)
3321 ((ind[ii][4]-23.5)*AliTOFGeometry::XPad() - ppos[0])*((ind[ii][4]-23.5)*AliTOFGeometry::XPad() - ppos[0]);
3323 Float_t *delta2Z = new Float_t[counter];
3324 for (Int_t ii=0; ii<counter; ii++)
3326 ((ind[ii][3]- 0.5)*AliTOFGeometry::ZPad() - ppos[2])*((ind[ii][3]- 0.5)*AliTOFGeometry::ZPad() - ppos[2]);
3328 for (Int_t ii=0; ii<counter; ii++)
3329 AliDebug(1, Form("x[%d] = %f, z[%d] = %f, weight[%d] = %f",
3330 ii, (ind[ii][4]-23.5)*AliTOFGeometry::XPad(),
3331 ii, (ind[ii][3]- 0.5)*AliTOFGeometry::ZPad(),
3334 AliDebug(1, Form("xMean = %f, zMean = %f",ppos[0], ppos[2]));
3342 if (ind[0][3]==ind[1][3] && TMath::Abs(ind[0][4]-ind[1][4])==1) { //
3344 lcov[8] = 1.02039; // cm2
3345 lcov[0] = 0.0379409; // cm2
3348 lcov[0] = 0.5*0.5; // cm2
3350 if (weight[0]==weight[1])
3351 lcov[0] = 0.0379409; // cm2
3353 lcov[0] = TMath::Mean(counter, delta2X, weight); // cm2
3359 else if (ind[0][4]==ind[1][4] && TMath::Abs(ind[0][3]-ind[1][3])==1) {//
3361 lcov[0] = 0.505499; // cm2
3362 lcov[8] = 0.0422046; // cm2
3365 lcov[8] = 0.5*0.5; // cm2
3367 if (weight[0]==weight[1])
3368 lcov[8] = 0.0422046; // cm2
3370 lcov[8] = TMath::Mean(counter, delta2Z, weight); // cm2
3379 lcov[0] = 0.0290677; // cm2
3380 lcov[8] = 0.0569726; // cm2
3383 lcov[0] = 0.5*0.5; // cm2
3384 lcov[8] = 0.5*0.5; // cm2
3387 if (weight[0]==weight[1] && weight[0]==weight[2]) {
3388 lcov[0] = 0.0290677; // cm2
3389 lcov[8] = 0.0569726; // cm2
3392 lcov[0] = TMath::Mean(counter, delta2X, weight); // cm2
3393 lcov[8] = TMath::Mean(counter, delta2Z, weight); // cm2
3402 lcov[0] = 0.0223807; // cm2
3403 lcov[8] = 0.0438662; // cm2
3406 lcov[0] = 0.5*0.5; // cm2
3407 lcov[8] = 0.5*0.5; // cm2
3410 if (weight[0]==weight[1] && weight[0]==weight[2] && weight[0]==weight[3]) {
3411 lcov[0] = 0.0223807; // cm2
3412 lcov[8] = 0.0438662; // cm2
3415 lcov[0] = TMath::Mean(counter, delta2X, weight); // cm2
3416 lcov[8] = TMath::Mean(counter, delta2Z, weight); // cm2
3430 //_____________________________________________________________________________
3432 Bool_t AliTOFClusterFinderV1::MakeSlewingCorrection(Int_t *detectorIndex,
3438 // This funtion makes the following:
3440 // - if at least one of the three status (Pulser/Noise/HW) is
3441 // bad, is sets the status of electronic channel, corresponding to the
3442 // volume identified by detectorIndex, as kFALSE;
3443 // - if offline calibration is in the valid status, it performs the
3444 // slewing correction. In particular, by taking into account:
3445 // * the measured tot and tof values (tofDigitToT and tofDigitTdc,
3447 // * the six parameters of 5th order polynomial used
3448 // to fit the tofVStot scatter plot,
3449 // it returns the corrected tof value, i.e. tdcCorr value.
3452 Bool_t output = kTRUE;
3457 //AliInfo(" Calibrating TOF Digits: ");
3459 AliTOFChannelOnlineArray *calDelay = fTOFcalib->GetTOFOnlineDelay();
3460 AliTOFChannelOnlineStatusArray *calStatus = fTOFcalib->GetTOFOnlineStatus();
3462 TObjArray *calTOFArrayOffline = fTOFcalib->GetTOFCalArrayOffline();
3464 Int_t index = AliTOFGeometry::GetIndex(detectorIndex);
3466 UChar_t statusPulser = calStatus->GetPulserStatus(index);
3467 UChar_t statusNoise = calStatus->GetNoiseStatus(index);
3468 UChar_t statusHW = calStatus->GetHWStatus(index);
3469 UChar_t status = calStatus->GetStatus(index);
3471 //check the status, also unknown is fine!!!!!!!
3473 AliDebug(2, Form(" Status for channel %d = %d",index, (Int_t)status));
3474 if((statusPulser & AliTOFChannelOnlineStatusArray::kTOFPulserBad)==(AliTOFChannelOnlineStatusArray::kTOFPulserBad)||(statusNoise & AliTOFChannelOnlineStatusArray::kTOFNoiseBad)==(AliTOFChannelOnlineStatusArray::kTOFNoiseBad)||(statusHW & AliTOFChannelOnlineStatusArray::kTOFHWBad)==(AliTOFChannelOnlineStatusArray::kTOFHWBad)){
3475 AliDebug(2, Form(" Bad Status for channel %d",index));
3476 //fTofClusters[ii]->SetStatus(kFALSE); //odd convention, to avoid conflict with calibration objects currently in the db (temporary solution).
3480 AliDebug(2, Form(" Good Status for channel %d",index));
3482 // Get Rough channel online equalization
3483 Double_t roughDelay = (Double_t)calDelay->GetDelay(index); // in ns
3484 AliDebug(2,Form(" channel delay (ns) = %f", roughDelay));
3485 // Get Refined channel offline calibration parameters
3486 TString validity = (TString)fTOFcalib->GetOfflineValidity();
3487 if (validity.CompareTo("valid")==0) {
3488 AliTOFChannelOffline * calChannelOffline = (AliTOFChannelOffline*)calTOFArrayOffline->At(index);
3490 for (jj = 0; jj<6; jj++)
3491 par[jj] = (Double_t)calChannelOffline->GetSlewPar(jj);
3493 AliDebug(2,Form(" Calib Pars = %f, %f, %f, %f, %f, %f ",par[0],par[1],par[2],par[3],par[4],par[5]));
3494 AliDebug(2,Form(" The ToT and Time, uncorr (counts) = %d , %d", tofDigitToT, tofDigitTdc));
3495 Double_t tToT = (Double_t)(tofDigitToT*AliTOFGeometry::ToTBinWidth());
3496 tToT*=1.E-3; //ToT in ns
3497 AliDebug(2,Form(" The ToT and Time, uncorr (ns)= %e, %e",tofDigitTdc*AliTOFGeometry::TdcBinWidth()*1.E-3,tToT));
3498 timeCorr = par[0] + tToT*(par[1] + tToT*(par[2] + tToT*(par[3] + tToT*(par[4] + tToT*par[5])))); // the time correction (ns)
3501 timeCorr = roughDelay; // correction in ns
3503 AliDebug(2,Form(" The ToT and Time, uncorr (ns)= %e, %e",tofDigitTdc*AliTOFGeometry::TdcBinWidth()*1.E-3,tofDigitToT*AliTOFGeometry::ToTBinWidth()));
3504 AliDebug(2,Form(" The time correction (ns) = %f", timeCorr));
3505 timeCorr = (Double_t)(tofDigitTdc)*AliTOFGeometry::TdcBinWidth()*1.E-3-timeCorr;//redefine the time
3507 AliDebug(2,Form(" The channel time, corr (ps)= %e",timeCorr ));
3508 tdcCorr = (Int_t)(timeCorr/AliTOFGeometry::TdcBinWidth()); //the corrected time (tdc counts)
3513 //______________________________________________________________________________
3515 void AliTOFClusterFinderV1::Digits2RecPoints(Int_t iEvent)
3518 // Converts digits to recpoints for TOF
3521 TStopwatch stopwatch;
3524 fRunLoader->GetEvent(iEvent);
3526 AliLoader *localTOFLoader = (AliLoader*)fRunLoader->GetLoader("TOFLoader");
3528 TTree * localTreeD = (TTree*)localTOFLoader->TreeD();
3529 if (localTreeD == 0x0)
3530 AliFatal("Can not get TreeD");
3532 TBranch *branch = localTreeD->GetBranch("TOF");
3534 AliError("Can't get the branch with the TOF digits !");
3538 TTree *localTreeR = (TTree*)localTOFLoader->TreeR();
3539 if (localTreeR == 0x0)
3541 localTOFLoader->MakeTree("R");
3542 localTreeR = localTOFLoader->TreeR();
3545 Digits2RecPoints(localTreeD, localTreeR);
3547 //localTOFLoader = fRunLoader->GetLoader("TOFLoader");
3548 localTOFLoader->WriteRecPoints("OVERWRITE");
3550 AliDebug(1, Form("Execution time to read TOF digits and to write TOF clusters for the event number %d: R:%.4fs C:%.4fs",
3551 iEvent, stopwatch.RealTime(),stopwatch.CpuTime()));
3554 //______________________________________________________________________________
3556 void AliTOFClusterFinderV1::Digits2RecPoints(Int_t iEvent, AliRawReader *rawReader)
3559 // Converts RAW data to recpoints for TOF
3562 TStopwatch stopwatch;
3565 fRunLoader->GetEvent(iEvent);
3567 AliDebug(2,Form(" Event number %2d ", iEvent));
3569 AliLoader *localTOFLoader = (AliLoader*)fRunLoader->GetLoader("TOFLoader");
3571 TTree *localTreeR = localTOFLoader->TreeR();
3573 if (localTreeR == 0x0){
3574 localTOFLoader->MakeTree("R");
3575 localTreeR = localTOFLoader->TreeR();
3578 Digits2RecPoints(rawReader, localTreeR);
3580 AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters for the event number %d: R:%.4fs C:%.4fs",
3581 iEvent, stopwatch.RealTime(),stopwatch.CpuTime()));
3584 //______________________________________________________________________________
3586 void AliTOFClusterFinderV1::Raw2Digits(Int_t iEvent, AliRawReader *rawReader)
3589 // Converts RAW data to MC digits for TOF
3593 TStopwatch stopwatch;
3596 fRunLoader->GetEvent(iEvent);
3598 AliDebug(2,Form(" Event number %2d ", iEvent));
3600 AliLoader *localTOFLoader = (AliLoader*)fRunLoader->GetLoader("TOFLoader");
3602 TTree *localTreeD = localTOFLoader->TreeD();
3604 if (localTreeD == 0x0){
3605 localTOFLoader->MakeTree("D");
3606 localTreeD = localTOFLoader->TreeD();
3609 Raw2Digits(rawReader, localTreeD);
3611 AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters for the event number %d: R:%.4fs C:%.4fs",
3612 iEvent, stopwatch.RealTime(),stopwatch.CpuTime()));
3615 //______________________________________________________________________________
3617 void AliTOFClusterFinderV1::AverageCalculations(Int_t number, Float_t *interestingX,
3618 Float_t *interestingY, Float_t *interestingZ,
3619 Double_t *interestingTOF, Double_t *interestingTOT,
3620 Double_t *interestingADC, Double_t *interestingWeight,
3621 Int_t *parTOF, Double_t *posClus, Bool_t &check)
3627 Double_t tofAverage = 0.;
3628 Double_t totAverage = 0.;
3629 Double_t adcAverage = 0.;
3633 for (ii=number-1; ii>=0; ii--) check=check||(interestingWeight[ii]==0 || interestingWeight[ii]==-1);
3637 posClus[0] = TMath::Mean(number, interestingX);
3638 posClus[1] = TMath::Mean(number, interestingY);
3639 posClus[2] = TMath::Mean(number, interestingZ);
3640 tofAverage = TMath::Mean(number, interestingTOF);
3641 totAverage = TMath::Mean(number, interestingTOT);
3642 adcAverage = TMath::Mean(number, interestingADC);
3647 posClus[0] = TMath::Mean(number, interestingX, interestingWeight);
3648 posClus[1] = TMath::Mean(number, interestingY, interestingWeight);
3649 posClus[2] = TMath::Mean(number, interestingZ, interestingWeight);
3650 tofAverage = TMath::Mean(number, interestingTOF, interestingWeight);
3651 totAverage = TMath::Mean(number, interestingTOT, interestingWeight);
3652 adcAverage = TMath::Mean(number, interestingADC, interestingWeight);
3656 parTOF[0] = Int_t(tofAverage);
3657 parTOF[1] = Int_t(totAverage);
3658 parTOF[2] = Int_t(adcAverage);
3659 parTOF[3] = Int_t(tofAverage);//tofND
3660 parTOF[4] = Int_t(tofAverage);//tofRAW