1 /***************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
17 $Log: AliTOFClusterFinderV1.cxx,v $
18 Revision 2009/04/20 A. De Caro
19 - added two new global variables, called fTOFGeometry and fTOFdigits;
20 - added a new method, called FindClustersWithoutTOT,
21 to transform TOF digits with fTOT=0 in one pad clusters;
22 - update of the covariance matrix elements for the TOF clusters
24 Revision 0.01 2008/05/10 A. De Caro
27 /////////////////////////////////////////
29 // Class for TOF cluster finder (V1) //
31 // Input data: Raw Data or Digits; //
32 // Output data: Digits or Rec Points //
34 /////////////////////////////////////////
36 #include "Riostream.h"
38 #include "TClonesArray.h"
39 #include "TStopwatch.h"
41 #include "TGeoMatrix.h"
46 #include "AliRawReader.h"
47 #include "AliRunLoader.h"
48 #include "AliGeomManager.h"
50 #include "AliTOFcalib.h"
51 #include "AliTOFChannelOnlineArray.h"
52 #include "AliTOFChannelOnlineStatusArray.h"
53 #include "AliTOFChannelOffline.h"
54 #include "AliTOFClusterFinderV1.h"
55 #include "AliTOFcluster.h"
56 #include "AliTOFdigit.h"
57 #include "AliTOFDigitMap.h"
58 #include "AliTOFrawData.h"
59 #include "AliTOFReconstructor.h"
60 #include "AliTOFRecoParam.h"
62 ClassImp(AliTOFClusterFinderV1)
64 //_____________________________________________________________________________
65 AliTOFClusterFinderV1::AliTOFClusterFinderV1(AliTOFcalib *calib):
67 fDigits(new TClonesArray("AliTOFdigit", 4000)),
68 fRecPoints(new TClonesArray("AliTOFcluster", 4000)),
69 fNumberOfTofClusters(0),
70 fNumberOfTofDigits(0),
71 fkRecoParam(0),//AliTOFReconstructor::GetRecoParam()),
72 fMaxDeltaTime(0),//fkRecoParam->GetMaxDeltaTime()),
76 fTOFdigitMap(new AliTOFDigitMap()),
77 fTOFGeometry(new AliTOFGeometry()),
78 fTOFdigits(new TTree()),
79 fTOFRawStream(AliTOFRawStream()),
86 if (AliTOFReconstructor::GetRecoParam()) {
87 fkRecoParam = AliTOFReconstructor::GetRecoParam();
88 fMaxDeltaTime = fkRecoParam->GetMaxDeltaTime();
93 TString validity = (TString)fTOFcalib->GetOfflineValidity();
94 if (validity.CompareTo("valid")==0) {
95 AliInfo(Form(" validity = %s - Using offline calibration parameters", validity.Data()));
97 AliInfo(Form(" validity = %s - Using online calibration parameters", validity.Data()));
102 //_____________________________________________________________________________
103 AliTOFClusterFinderV1::AliTOFClusterFinderV1(AliRunLoader* runLoader, AliTOFcalib *calib):
104 fRunLoader(runLoader),
105 fDigits(new TClonesArray("AliTOFdigit", 4000)),
106 fRecPoints(new TClonesArray("AliTOFcluster", 4000)),
107 fNumberOfTofClusters(0),
108 fNumberOfTofDigits(0),
109 fkRecoParam(0),//AliTOFReconstructor::GetRecoParam()),
110 fMaxDeltaTime(0),//fkRecoParam->GetMaxDeltaTime()),
114 fTOFdigitMap(new AliTOFDigitMap()),
115 fTOFGeometry(new AliTOFGeometry()),
116 fTOFdigits(new TTree()),
117 fTOFRawStream(AliTOFRawStream()),
118 fCalibrateTOFtimes(1)
124 if (AliTOFReconstructor::GetRecoParam()) {
125 fkRecoParam = AliTOFReconstructor::GetRecoParam();
126 fMaxDeltaTime = fkRecoParam->GetMaxDeltaTime();
131 TString validity = (TString)fTOFcalib->GetOfflineValidity();
132 if (validity.CompareTo("valid")==0) {
133 AliInfo(Form(" validity = %s - Using offline calibration parameters", validity.Data()));
135 AliInfo(Form(" validity = %s - Using online calibration parameters", validity.Data()));
139 //_____________________________________________________________________________
141 AliTOFClusterFinderV1::AliTOFClusterFinderV1(const AliTOFClusterFinderV1 &source)
144 fDigits(source.fDigits),
145 fRecPoints(source.fRecPoints),
146 fNumberOfTofClusters(0),
147 fNumberOfTofDigits(0),
148 fkRecoParam(0),//AliTOFReconstructor::GetRecoParam()),
149 fMaxDeltaTime(0),//fkRecoParam->GetMaxDeltaTime()),
151 fDecoderVersion(source.fDecoderVersion),
152 fTOFcalib(source.fTOFcalib),
153 fTOFdigitMap(new AliTOFDigitMap()),
154 fTOFGeometry(new AliTOFGeometry()),
155 fTOFdigits(source.fTOFdigits),
156 fTOFRawStream(source.fTOFRawStream),
157 fCalibrateTOFtimes(1)
161 if (AliTOFReconstructor::GetRecoParam()) {
162 fkRecoParam = AliTOFReconstructor::GetRecoParam();
163 fMaxDeltaTime = fkRecoParam->GetMaxDeltaTime();
169 //_____________________________________________________________________________
171 AliTOFClusterFinderV1& AliTOFClusterFinderV1::operator=(const AliTOFClusterFinderV1 &source)
178 TObject::operator=(source);
179 fDigits=source.fDigits;
180 fRecPoints=source.fRecPoints;
181 fVerbose=source.fVerbose;
182 fDecoderVersion=source.fDecoderVersion;
183 fTOFcalib=source.fTOFcalib;
184 fTOFdigitMap=source.fTOFdigitMap;
185 fTOFGeometry=source.fTOFGeometry;
186 fTOFdigits=source.fTOFdigits;
187 fTOFRawStream=source.fTOFRawStream;
188 fCalibrateTOFtimes=source.fCalibrateTOFtimes;
192 //_____________________________________________________________________________
194 AliTOFClusterFinderV1::~AliTOFClusterFinderV1()
209 fRecPoints->Delete();
221 //_____________________________________________________________________________
223 void AliTOFClusterFinderV1::Digits2RecPoints(TTree* digitsTree, TTree* clusterTree)
226 // Converts digits to recPoints for TOF
229 TStopwatch stopwatch;
234 TClonesArray &aDigits = *fDigits;
236 if (digitsTree == 0x0)
237 AliFatal("Can not get TreeD for TOF");
239 TBranch *branch = digitsTree->GetBranch("TOF");
241 AliError("Can not get branch with the TOF digits !");
245 TClonesArray staticDigits("AliTOFdigit",10000);
246 staticDigits.Clear();
247 TClonesArray *digits = &staticDigits;
248 branch->SetAddress(&digits);
249 digitsTree->GetEvent(0);
250 AliDebug(1,Form("Number of TOF digits: %d", digits->GetEntriesFast()));
252 AliTOFdigit *tofDigit;
255 Int_t detectorIndex[5];
256 for (jj=0; jj<5; jj++) detectorIndex[jj] = -1;
258 for (jj=0; jj<4; jj++) info[jj] = -1;
264 Bool_t status = kTRUE;
266 AliDebug(1," Calibrating TOF Digits");
268 TString validity = (TString)fTOFcalib->GetOfflineValidity();
269 if (validity.CompareTo("valid")==0) {
270 AliInfo(Form(" validity = %s - Using offline calibration parameters", validity.Data()));
272 AliInfo(Form(" validity = %s - Using online calibration parameters", validity.Data()));
276 for (ii=0; ii<digits->GetEntriesFast(); ii++) {
277 tofDigit = (AliTOFdigit*)digits->UncheckedAt(ii);
278 detectorIndex[0] = tofDigit->GetSector();
279 detectorIndex[1] = tofDigit->GetPlate();
280 detectorIndex[2] = tofDigit->GetStrip();
281 detectorIndex[3] = tofDigit->GetPadz();
282 detectorIndex[4] = tofDigit->GetPadx();
284 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
285 if (detectorIndex[1]==2) { // plate with holes
291 tdcCorr = tofDigit->GetTdc();
292 status = MakeSlewingCorrection(detectorIndex, tofDigit->GetToT(), tofDigit->GetTdc(), tdcCorr);
294 for (jj=0; jj<4; jj++) info[jj] = -1;
295 info[0] = tdcCorr;//tofDigit->GetTdc();
296 info[1] = tofDigit->GetAdc();
297 info[2] = tofDigit->GetToT();
298 info[3] = tofDigit->GetTdcND();//tofDigit->GetTdc();//
299 tracks = tofDigit->GetTracks();
301 dummy = detectorIndex[3];
302 detectorIndex[3] = detectorIndex[4];//padx
303 detectorIndex[4] = dummy;//padz
304 last = fDigits->GetEntriesFast();
305 new (aDigits[last]) AliTOFdigit(tracks, detectorIndex, info);
306 if (status) fTOFdigitMap->AddDigit(detectorIndex, last);
308 AliDebug(2, Form(" Digits reading %2d -> %2d %1d %2d %1d %2d (%d, %d, %d)",
310 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[3], detectorIndex[4],
311 info[0], info[1], info[3]));
315 fNumberOfTofDigits = fDigits->GetEntriesFast();
319 Int_t bufsize = 32000;
320 clusterTree->Branch("TOF", &fRecPoints, bufsize);
325 AliDebug(1,Form("Number of found clusters: %d", fNumberOfTofClusters));
329 fTOFdigitMap->Clear();
333 AliDebug(1,Form("Execution time to read TOF digits and to write TOF clusters : R:%.4fs C:%.4fs",
334 stopwatch.RealTime(),stopwatch.CpuTime()));
336 if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
339 //_____________________________________________________________________________
341 void AliTOFClusterFinderV1::Digits2RecPoints(AliRawReader *rawReader, TTree *clustersTree)
344 // Converts raw data to recPoints for TOF
347 TStopwatch stopwatch;
351 AliDebug(2, "TreeD re-creation");
352 //TTree *digitsTree = new TTree();
353 //Raw2Digits(rawReader, digitsTree);
355 Raw2Digits(rawReader, fTOFdigits);
357 AliDebug(1,Form("Number of TOF digits: %d", fNumberOfTofDigits));
360 Int_t bufsize = 32000;
361 clustersTree->Branch("TOF", &fRecPoints, bufsize);
364 clustersTree->Fill();
366 AliDebug(1,Form("Number of found clusters: %d", fNumberOfTofClusters));
370 fTOFdigitMap->Clear();
374 AliDebug(1,Form("Execution time to read TOF raw data and to write TOF clusters : R:%.4fs C:%.4fs",
375 stopwatch.RealTime(),stopwatch.CpuTime()));
379 //_____________________________________________________________________________
381 void AliTOFClusterFinderV1::Raw2Digits(AliRawReader *rawReader, TTree* digitsTree)
384 // Converts raw data to digits for TOF
387 TStopwatch stopwatch;
392 const Int_t kMaxNumberOfTracksPerDigit = 3;
393 const Int_t kDDL = AliDAQ::NumberOfDdls("TOF");
395 digitsTree->Branch("TOF", &fDigits);
396 TClonesArray &aDigits = *fDigits;
398 fTOFRawStream.Clear();
399 fTOFRawStream.SetRawReader(rawReader);
402 if (fVerbose==2) ftxt.open("TOFdigitsRead.txt",ios::app);
404 TClonesArray staticRawData("AliTOFrawData",10000);
405 staticRawData.Clear();
406 TClonesArray * clonesRawData = &staticRawData;
409 Int_t detectorIndex[5] = {-1, -1, -1, -1, -1};
411 Int_t tracks[kMaxNumberOfTracksPerDigit];
412 for (Int_t ii=0; ii<kMaxNumberOfTracksPerDigit; ii++)
417 Bool_t status = kTRUE;
420 TString validity = (TString)fTOFcalib->GetOfflineValidity();
421 if (validity.CompareTo("valid")==0) {
422 AliInfo(Form(" validity = %s - Using offline calibration parameters", validity.Data()));
424 AliInfo(Form(" validity = %s - Using online calibration parameters", validity.Data()));
428 AliInfo("Using New Decoder");
432 for (indexDDL=0; indexDDL<kDDL; indexDDL++) {
436 fTOFRawStream.LoadRawDataBuffers(indexDDL,fVerbose);
437 else fTOFRawStream.LoadRawData(indexDDL);
439 clonesRawData = (TClonesArray*)fTOFRawStream.GetRawData();
440 if (clonesRawData->GetEntriesFast()!=0) AliDebug(2,Form(" TOF raw data number = %3d", clonesRawData->GetEntriesFast()));
441 for (iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
443 AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
445 //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
446 if (tofRawDatum->GetTOF()==-1) continue;
448 fTOFRawStream.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
449 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
452 dummy = detectorIndex[3];
453 detectorIndex[3] = detectorIndex[4];//padz
454 detectorIndex[4] = dummy;//padx
456 tdcCorr = tofRawDatum->GetTOF();
457 status = MakeSlewingCorrection(detectorIndex, tofRawDatum->GetTOT(), tofRawDatum->GetTOF(), tdcCorr);
460 digit[1] = tofRawDatum->GetTOT();
461 digit[2] = tofRawDatum->GetTOT();
462 digit[3] = -1;//tofRawDatum->GetTOF(); //tofND
464 dummy = detectorIndex[3];
465 detectorIndex[3] = detectorIndex[4];//padx
466 detectorIndex[4] = dummy;//padz
468 /* check valid index */
469 if (detectorIndex[0]==-1||detectorIndex[1]==-1||detectorIndex[2]==-1||detectorIndex[3]==-1||detectorIndex[4]==-1) continue;
471 // Do not reconstruct anything in the holes
472 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
473 if (detectorIndex[1]==2) { // plate with holes
479 last = fDigits->GetEntriesFast();
480 new (aDigits[last]) AliTOFdigit(tracks, detectorIndex, digit);
481 if (status) fTOFdigitMap->AddDigit(detectorIndex, last);
484 if (indexDDL<10) ftxt << " " << indexDDL;
485 else ftxt << " " << indexDDL;
486 if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM();
487 else ftxt << " " << tofRawDatum->GetTRM();
488 ftxt << " " << tofRawDatum->GetTRMchain();
489 if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC();
490 else ftxt << " " << tofRawDatum->GetTDC();
491 ftxt << " " << tofRawDatum->GetTDCchannel();
493 if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0];
494 else ftxt << " -> " << detectorIndex[0];
495 ftxt << " " << detectorIndex[1];
496 if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2];
497 else ftxt << " " << detectorIndex[2];
498 ftxt << " " << detectorIndex[4];
499 if (detectorIndex[4]<10) ftxt << " " << detectorIndex[3];
500 else ftxt << " " << detectorIndex[3];
502 if (digit[1]<10)ftxt << " " << digit[1];
503 else if (digit[1]>=10 && digit[1]<100) ftxt << " " << digit[1];
504 else ftxt << " " << digit[1];
505 if (digit[0]<10) ftxt << " " << digit[0] << endl;
506 else if (digit[0]>=10 && digit[0]<100) ftxt << " " << digit[0] << endl;
507 else if (digit[0]>=100 && digit[0]<1000) ftxt << " " << digit[0] << endl;
508 else ftxt << " " << digit[3] << endl;
511 AliDebug(2, Form(" Raw data reading %2d -> %2d %1d %2d %1d %2d (%d, %d, %d)",
513 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[4], detectorIndex[3],
514 digit[0], digit[1], digit[3]));
518 clonesRawData->Clear();
522 if (fVerbose==2) ftxt.close();
526 fNumberOfTofDigits = fDigits->GetEntries();
528 AliDebug(1, Form("Got %d TOF digits", fNumberOfTofDigits));
529 AliDebug(1, Form("Execution time to read TOF raw data and fill TOF digit tree : R:%.2fs C:%.2fs",
530 stopwatch.RealTime(),stopwatch.CpuTime()));
532 if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
535 //_____________________________________________________________________________
537 void AliTOFClusterFinderV1::FillRecPoint()
540 // Fill the global TClonesArray of AliTOFcluster objects,
549 for(Int_t iPlate=AliTOFGeometry::NPlates()-1; iPlate>=0; iPlate--) {
550 for(Int_t iStrip=AliTOFGeometry::NStrip(iPlate)-1; iStrip>=0; iStrip--) {
551 //for (Int_t iSector=AliTOFGeometry::NSectors()-1; iSector>=0; iSector--) {
552 for (Int_t iSector=0; iSector<AliTOFGeometry::NSectors(); iSector++) {
555 if (fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip)) AliDebug(1,Form(" Number of TOF digits in (%2d,%1d,%2d) -> %d",iSector,iPlate,iStrip,fTOFdigitMap->FilledCellsInStrip(iSector,iPlate,iStrip)));
557 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
558 FindClustersWithoutTOT(iSector, iPlate, iStrip); // clusters coming from digits without TOT measurement
561 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
562 //if (fTOFdigitMap->FilledCellsInStrip(iSector,iPlate,iStrip)>=4)
563 FindClustersPerStrip(iSector, iPlate, iStrip, 4); // 4 pads clusters
564 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
566 dummy4 = fNumberOfTofClusters;
567 FindClustersPerStrip(iSector, iPlate, iStrip, 4); // 4 pads clusters
568 if (fNumberOfTofClusters!=dummy4)
569 AliDebug(2, Form(" (4): n1= %5d, n2 = %5", dummy4, fNumberOfTofClusters));
572 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
573 FindClustersPerStrip(iSector, iPlate, iStrip, 3); // 3 pads clusters
574 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
576 dummy3 = fNumberOfTofClusters;
577 FindClustersPerStrip(iSector, iPlate, iStrip, 3); // 3 pads clusters
578 if (fNumberOfTofClusters!=dummy3)
579 AliDebug(2, Form(" (3): n1= %5d, n2 = %5", dummy3, fNumberOfTofClusters));
582 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
583 FindClustersPerStrip(iSector, iPlate, iStrip, 2); // 2 pads clusters
584 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
586 dummy2 = fNumberOfTofClusters;
587 FindClustersPerStrip(iSector, iPlate, iStrip, 2); // 2 pads clusters
588 if (fNumberOfTofClusters!=dummy2)
589 AliDebug(2, Form(" (2): n1= %5d, n2 =%5", dummy2, fNumberOfTofClusters));
592 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
593 dummy = fNumberOfTofClusters;
594 FindClusters34(iSector, iPlate, iStrip); // 3 pads clusters between 4 hit pads
595 if (fNumberOfTofClusters!=dummy)
596 AliDebug(2, Form(" (3 between 4): n1 = %5d, n2 = %5d", fNumberOfTofClusters, dummy));
599 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
600 dummy = fNumberOfTofClusters;
601 FindClusters23(iSector, iPlate, iStrip); // 2 pads clusters between 3 hit pads
602 if (fNumberOfTofClusters!=dummy)
603 AliDebug(2, Form(" (2 between 3): n1 = %5d, n2 = %5d", fNumberOfTofClusters, dummy));
605 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
606 dummy = fNumberOfTofClusters;
607 FindClusters24(iSector, iPlate, iStrip); // 2 pads clusters between 4 hit pads
608 if (fNumberOfTofClusters!=dummy)
609 AliDebug(2, Form(" (2 between 4): n1 = %5d, n2 = %5d", fNumberOfTofClusters, dummy));
612 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
613 dummy = fNumberOfTofClusters;
614 FindOnePadClusterPerStrip(iSector, iPlate, iStrip); // 1 pad clusters
615 if (fNumberOfTofClusters!=dummy)
616 AliDebug(2,Form(" (1): n1 = %5d, n2 = %5d", fNumberOfTofClusters, dummy));
618 if (fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip)>0)
619 AliDebug(2, Form(" (1): number of clusters = %5d (remaining digit %2d), -%2d %1d %2d-",
620 fNumberOfTofClusters, fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip),
621 iSector, iPlate, iStrip));
628 TClonesArray &lRecPoints = *fRecPoints;
632 Int_t detectorIndex[5];
633 for (jj=0; jj<5; jj++) detectorIndex[jj] = -1;
635 for (jj=0; jj<5; jj++) parTOF[jj] = -1;
636 Int_t trackLabels[3];
637 for (jj=0; jj<3; jj++) trackLabels[jj] = -1;
638 Int_t digitIndex = -1;
639 Bool_t status = kTRUE;
641 for (ii=0; ii<3; ii++) posClus[ii] = 0.;
642 //Float_t covClus[6];
643 //for (ii=0; ii<6; ii++) covClus[ii] = 0.;
646 for (ii=0; ii<fNumberOfTofClusters; ii++) {
648 digitIndex = fTofClusters[ii]->GetIndex();
649 for(jj=0; jj<5; jj++) detectorIndex[jj] = fTofClusters[ii]->GetDetInd(jj);
650 volIdClus = fTOFGeometry->GetAliSensVolIndex(detectorIndex[0],detectorIndex[1],detectorIndex[2]);
651 //volIdClus = GetClusterVolIndex(detectorIndex);
652 for(jj=0; jj<3; jj++) trackLabels[jj] = fTofClusters[ii]->GetLabel(jj);
653 parTOF[0] = fTofClusters[ii]->GetTDC(); // TDC
654 parTOF[1] = fTofClusters[ii]->GetToT(); // TOT
655 parTOF[2] = fTofClusters[ii]->GetADC(); // ADC=TOT
656 parTOF[3] = fTofClusters[ii]->GetTDCND(); // TDCND
657 parTOF[4] = fTofClusters[ii]->GetTDCRAW();//RAW
658 status = fTofClusters[ii]->GetStatus();
660 posClus[0] = fTofClusters[ii]->GetX();
661 posClus[1] = fTofClusters[ii]->GetY();
662 posClus[2] = fTofClusters[ii]->GetZ();
664 //for (jj=0; jj<6; jj++) covClus[jj] = 0.;
665 //((AliCluster*)fTofClusters[ii])->GetGlobalCov(covClus);
667 new(lRecPoints[ii]) AliTOFcluster(volIdClus, (Double_t)posClus[0], (Double_t)posClus[1], (Double_t)posClus[2],
668 (Double_t)(fTofClusters[ii]->GetSigmaX2()),
669 (Double_t)(fTofClusters[ii]->GetSigmaXY()),
670 (Double_t)(fTofClusters[ii]->GetSigmaXZ()),
671 (Double_t)(fTofClusters[ii]->GetSigmaY2()),
672 (Double_t)(fTofClusters[ii]->GetSigmaYZ()),
673 (Double_t)(fTofClusters[ii]->GetSigmaZ2()),
674 //(Double_t)covClus[0], (Double_t)covClus[1], (Double_t)covClus[2],
675 //(Double_t)covClus[3], (Double_t)covClus[4], (Double_t)covClus[5],
676 trackLabels, detectorIndex, parTOF, status, digitIndex);
678 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",
679 ii, volIdClus, posClus[0], posClus[1], posClus[2],
680 fTofClusters[ii]->GetSigmaX2(),
681 fTofClusters[ii]->GetSigmaXY(),
682 fTofClusters[ii]->GetSigmaXZ(),
683 fTofClusters[ii]->GetSigmaY2(),
684 fTofClusters[ii]->GetSigmaYZ(),
685 fTofClusters[ii]->GetSigmaZ2(),
686 trackLabels[0], trackLabels[1], trackLabels[2],
687 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[3], detectorIndex[4],
688 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
689 status, digitIndex));
694 for (Int_t iSector=0; iSector<AliTOFGeometry::NSectors(); iSector++)
695 for(Int_t iPlate=0; iPlate<AliTOFGeometry::NPlates(); iPlate++) {
696 for(Int_t iStrip=0; iStrip<AliTOFGeometry::NStrip(iPlate); iStrip++) {
697 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
698 AliDebug(2, Form(" END %2d %1d %2d %5d",
699 iSector, iPlate, iStrip, fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip)));
704 //_____________________________________________________________________________
706 void AliTOFClusterFinderV1::FindOnePadClusterPerStrip(Int_t nSector,
711 // This function searches the isolated digits (stored in the fDigits object),
712 // to perform clusters (stored in the fTofClusters array).
713 // This research has been made by checking the fTOFdigitMap object,
714 // filled at digits/raw-data reading time.
717 const Int_t kMaxNumberOfTracksPerDigit = 3;
718 const Int_t kMaxNumberOfDigitsPerVolume = 10;
722 Int_t det[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padZ,padX
723 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padX,padZ
724 UShort_t volIdClus = 0;
727 for (jj=0; jj<3; jj++) pos[jj] = 0.;
729 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
732 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
735 for (jj=0; jj<5; jj++) parTOF[jj] = 0;
737 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
739 Int_t tracks[kMaxNumberOfTracksPerDigit];
740 for (jj=0; jj<3; jj++) tracks[jj] = -1;
742 Int_t dummyCounter=-1;
744 AliTOFdigit *digitInteresting;
748 for (iPadX=0; iPadX<AliTOFGeometry::NpadX(); iPadX++) {
749 for (iPadZ=0; iPadZ<AliTOFGeometry::NpadZ(); iPadZ++) {
750 vol[4] = iPadZ , vol[3] = iPadX;
752 AliDebug(3, Form(" %1d %2d\n", iPadZ, iPadX));
754 if (fTOFdigitMap->GetNumberOfDigits(vol)==0) continue;
756 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
757 if (fTOFdigitMap->GetDigitIndex(vol,digIndex)<0) continue;
758 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(fTOFdigitMap->GetDigitIndex(vol,digIndex));
760 AliDebug(2, Form(" %3d %5d %2d %1d %2d %1d %2d %d %d %d %5d %5d %5d %5d",
761 fTOFdigitMap->GetNumberOfDigits(vol), digIndex,
762 vol[0], vol[1], vol[2] ,vol[4], vol[3],
763 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
764 digitInteresting->GetToT(),
765 fTOFdigitMap->GetDigitIndex(vol,digIndex),
766 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
768 det[3] = vol[4]; // padz
769 det[4] = vol[3]; // padx
770 fTOFGeometry->GetPosPar(det,pos);
771 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
774 for (jj=0; jj<3; jj++) posClus[jj] = pos[jj];
776 parTOF[0] = Int_t(digitInteresting->GetTdc());
777 parTOF[1] = Int_t(digitInteresting->GetToT());
778 parTOF[2] = Int_t(digitInteresting->GetAdc());
779 parTOF[3] = Int_t(digitInteresting->GetTdcND());
780 parTOF[4] = Int_t(digitInteresting->GetTdc());
782 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
783 //volIdClus = GetClusterVolIndex(det);
785 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
786 GetClusterPars(det, posClus, covClus);
788 // To fill the track index array
790 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
791 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) { // three is the max number of tracks associated to one digit
792 if (digitInteresting->GetTrack(jj)==-1) continue;
795 tracks[dummyCounter] = digitInteresting->GetTrack(jj);
799 AliTOFcluster *tofCluster =
800 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
801 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
802 tracks, det, parTOF, status, fTOFdigitMap->GetDigitIndex(vol,digIndex));
803 InsertCluster(tofCluster);
805 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",
806 volIdClus, posClus[0], posClus[1], posClus[2],
807 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
808 tracks[0], tracks[1], tracks[2],
809 det[0], det[1], det[2], det[3], det[4],
810 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
811 status, fTOFdigitMap->GetDigitIndex(vol,digIndex)));
813 AliDebug(2, Form(" %f %f %f", pos[0], pos[1], pos[2]));
814 AliDebug(2, Form(" %d %d", parTOF[0], parTOF[2]));
816 fTOFdigitMap->ResetDigit(vol, digIndex);
824 //_____________________________________________________________________________
826 void AliTOFClusterFinderV1::FindClustersWithoutTOT(Int_t nSector,
831 // This function searches the isolated digits without TOT
832 // measurement (stored in the fDigits object), to perform clusters
833 // (stored in the fTofClusters array). This research has been made
834 // by checking the fTOFdigitMap object, filled at digits/raw-data
838 const Int_t kMaxNumberOfTracksPerDigit = 3;
839 const Int_t kMaxNumberOfDigitsPerVolume = 10;
843 Int_t det[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padZ,padX
844 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padX,padZ
845 UShort_t volIdClus = 0;
848 for (jj=0; jj<3; jj++) pos[jj] = 0.;
850 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
853 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
856 for (jj=0; jj<5; jj++) parTOF[jj] = 0;
858 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
859 Int_t tracks[kMaxNumberOfTracksPerDigit];
860 for (jj=0; jj<3; jj++) tracks[jj] = -1;
862 Int_t dummyCounter=-1;
864 AliTOFdigit *digitInteresting;
868 for (iPadX=0; iPadX<AliTOFGeometry::NpadX(); iPadX++) {
869 for (iPadZ=0; iPadZ<AliTOFGeometry::NpadZ(); iPadZ++) {
870 vol[4] = iPadZ , vol[3] = iPadX;
872 AliDebug(3, Form(" %1d %2d\n", iPadZ, iPadX));
874 if (fTOFdigitMap->GetNumberOfDigits(vol)==0) continue;
876 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
877 if (fTOFdigitMap->GetDigitIndex(vol,digIndex)<0) continue;
878 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(fTOFdigitMap->GetDigitIndex(vol,digIndex));
879 if (digitInteresting->GetToT()>0) continue; // AdC
881 AliDebug(2, Form(" %3d %5d %2d %1d %2d %1d %2d %d %d %d %5d %5d %5d %5d",
882 fTOFdigitMap->GetNumberOfDigits(vol), digIndex,
883 vol[0], vol[1], vol[2] ,vol[4], vol[3],
884 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
885 digitInteresting->GetToT(),
886 fTOFdigitMap->GetDigitIndex(vol,digIndex),
887 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
889 det[3] = vol[4]; // padz
890 det[4] = vol[3]; // padx
891 fTOFGeometry->GetPosPar(det,pos);
892 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
895 for (jj=0; jj<3; jj++) posClus[jj] = pos[jj];
897 parTOF[0] = Int_t(digitInteresting->GetTdc());
898 parTOF[1] = Int_t(digitInteresting->GetToT());
899 parTOF[2] = Int_t(digitInteresting->GetAdc());
900 parTOF[3] = Int_t(digitInteresting->GetTdcND());
901 parTOF[4] = Int_t(digitInteresting->GetTdc());
903 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
904 //volIdClus = GetClusterVolIndex(det);
906 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
907 GetClusterPars(det, posClus, covClus);
909 // To fill the track index array
911 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
912 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) { // three is the max number of tracks associated to one digit
913 if (digitInteresting->GetTrack(jj)==-1) continue;
916 tracks[dummyCounter] = digitInteresting->GetTrack(jj);
920 AliTOFcluster *tofCluster =
921 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
922 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
923 tracks, det, parTOF, status, fTOFdigitMap->GetDigitIndex(vol,digIndex));
924 InsertCluster(tofCluster);
926 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",
927 volIdClus, posClus[0], posClus[1], posClus[2],
928 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
929 tracks[0], tracks[1], tracks[2],
930 det[0], det[1], det[2], det[3], det[4],
931 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
932 status, fTOFdigitMap->GetDigitIndex(vol,digIndex)));
934 AliDebug(2, Form(" %f %f %f", pos[0], pos[1], pos[2]));
935 AliDebug(2, Form(" %d %d", parTOF[0], parTOF[2]));
937 fTOFdigitMap->ResetDigit(vol, digIndex);
945 //_____________________________________________________________________________
947 void AliTOFClusterFinderV1::FindClusters34(Int_t nSector,
952 // This function searches the neighbouring digits (stored in the fDigits object),
953 // to perform clusters (stored in the fTofClusters array).
955 // This research has been made by checking the fTOFdigitMap object,
956 // filled at digits/raw-data reading time.
959 const Int_t kMaxNumberOfInterestingPads = 4;
960 const Int_t kMaxNumberOfTracksPerDigit = 3;
961 const Int_t kMaxNumberOfDigitsPerVolume = 10;
965 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
966 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
967 digitsInVolumeIndices[ii] = -1;
969 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
971 Float_t pos[3] = {0.,0.,0.};
974 Int_t interestingPadX[kMaxNumberOfInterestingPads];
975 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
976 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
977 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
978 Double_t interestingTOT[kMaxNumberOfInterestingPads];
979 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
980 Double_t interestingADC[kMaxNumberOfInterestingPads];
981 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
982 Double_t interestingTOF[kMaxNumberOfInterestingPads];
983 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
984 Double_t interestingWeight[kMaxNumberOfInterestingPads];
985 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
987 Float_t interestingX[kMaxNumberOfInterestingPads];
988 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
989 Float_t interestingY[kMaxNumberOfInterestingPads];
990 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
991 Float_t interestingZ[kMaxNumberOfInterestingPads];
992 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
994 Float_t interDigit[kMaxNumberOfInterestingPads];
995 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
997 Int_t padsCluster[11];
998 padsCluster[0] = nSector;
999 padsCluster[1] = nPlate;
1000 padsCluster[2] = nStrip;
1001 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1003 Int_t interestingCounter=-1;
1004 Int_t digitIndexLocal=-1; // AdC
1010 for (jj=0; jj<5; jj++) parTOF[jj] = 0;
1011 Double_t posClus[3];
1012 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
1014 for (jj=0; jj<5; jj++) det[jj] = -1;
1016 for (jj=0; jj<3; jj++) posF[jj] = 0.;
1017 UShort_t volIdClus = 0;
1018 Bool_t check = kFALSE;
1019 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
1020 Double_t covClus[6];
1021 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1022 Int_t tracks[kMaxNumberOfTracksPerDigit];
1023 for (jj=0; jj<3; jj++) tracks[jj] = -1;
1024 Int_t dummyCounter=-1;
1025 Bool_t alreadyStored = kFALSE;
1027 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
1028 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1029 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
1031 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1032 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
1034 AliTOFdigit *digitInteresting;
1036 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
1038 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
1039 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
1041 AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
1048 interestingCounter=-1;
1050 vol[4] = iPadZ , vol[3] = iPadX;
1051 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1052 interestingCounter++;
1054 vol[4] = iPadZ, vol[3] = iPadX+1;
1055 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1056 interestingCounter++;
1058 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1059 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1060 interestingCounter++;
1062 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1063 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1064 interestingCounter++;
1066 if (interestingCounter+1!=4) continue; // the hit pads have to be 4
1067 else interestingCounter=-1;
1070 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1071 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1072 selectedDigit[ii][jj] = 0x0;
1075 vol[4] = iPadZ, vol[3] = iPadX;
1077 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1078 interestingCounter++;
1079 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1080 digitsInVolumeIndices[ii] = -1;
1081 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1082 digitIndexLocal=-1; // AdC
1083 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1084 if (digitsInVolumeIndices[digIndex]<0) continue;
1085 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1086 if (digitInteresting->GetToT()<=0) continue; // AdC
1087 digitIndexLocal++; // AdC
1089 AliDebug(1,Form(" %2d %1d %2d %1d %2d %f %f %f %f %5d %5d %5d %5d",
1090 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1091 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1092 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1093 digitsInVolumeIndices[digIndex],
1094 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1097 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1098 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1099 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1100 digitInteresting->GetToT()*digitInteresting->GetToT(),
1101 digitsInVolumeIndices[digIndex],
1102 digitInteresting->GetTracks());
1104 if (digitIndexLocal==-1) interestingCounter--; // AdC
1108 vol[4] = iPadZ, vol[3] = iPadX+1;
1110 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1111 interestingCounter++;
1112 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1113 digitsInVolumeIndices[ii] = -1;
1114 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1115 digitIndexLocal=-1; // AdC
1116 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1117 if (digitsInVolumeIndices[digIndex]<0) continue;
1118 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1119 if (digitInteresting->GetToT()<=0) continue; // AdC
1120 digitIndexLocal++; // AdC
1122 AliDebug(1,Form(" %2d %1d %2d %1d %2d %f %f %f %f %5d %5d %5d %5d",
1123 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1124 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1125 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1126 digitsInVolumeIndices[digIndex],
1127 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1130 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1131 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1132 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1133 digitInteresting->GetToT()*digitInteresting->GetToT(),
1134 digitsInVolumeIndices[digIndex],
1135 digitInteresting->GetTracks());
1137 if (digitIndexLocal==-1) interestingCounter--; // AdC
1141 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1143 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1144 interestingCounter++;
1145 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1146 digitsInVolumeIndices[ii] = -1;
1147 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1148 digitIndexLocal=-1; // AdC
1149 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1150 if (digitsInVolumeIndices[digIndex]<0) continue;
1151 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1152 if (digitInteresting->GetToT()<=0) continue; // AdC
1153 digitIndexLocal++; // AdC
1155 AliDebug(1,Form(" %2d %1d %2d %1d %2d %f %f %f %f %5d %5d %5d %5d",
1156 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1157 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1158 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1159 digitsInVolumeIndices[digIndex],
1160 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1163 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1164 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1165 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1166 digitInteresting->GetToT()*digitInteresting->GetToT(),
1167 digitsInVolumeIndices[digIndex],
1168 digitInteresting->GetTracks());
1170 if (digitIndexLocal==-1) interestingCounter--; // AdC
1174 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1176 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1177 interestingCounter++;
1178 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1179 digitsInVolumeIndices[ii] = -1;
1180 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1182 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1183 if (digitsInVolumeIndices[digIndex]<0) continue;
1184 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1185 if (digitInteresting->GetToT()<=0) continue; // AdC
1186 digitIndexLocal++; // AdC
1188 AliDebug(1,Form(" %2d %1d %2d %1d %2d %f %f %f %f %5d %5d %5d %5d",
1189 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1190 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1191 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1192 digitsInVolumeIndices[digIndex],
1193 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1195 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1196 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1197 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1198 digitInteresting->GetToT()*digitInteresting->GetToT(),
1199 digitsInVolumeIndices[digIndex],
1200 digitInteresting->GetTracks());
1202 if (digitIndexLocal==-1) interestingCounter--; // AdC
1205 AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
1207 for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
1208 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
1209 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
1211 for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
1212 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
1213 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
1215 for (Int_t adesso3=adesso2+1; adesso3<interestingCounter+1; adesso3++) {
1216 for (Int_t thirdIndex=0; thirdIndex<kMaxNumberOfDigitsPerVolume; thirdIndex++) {
1217 if (selectedDigit[adesso3][thirdIndex]==0x0) continue;
1220 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime
1222 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
1224 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime) continue;
1226 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
1227 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
1228 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
1229 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
1230 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
1231 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
1232 Int_t volDum = vol1[3];
1235 fTOFGeometry->GetPosPar(vol1,pos);
1236 interestingX[0] = pos[0];
1237 interestingY[0] = pos[1];
1238 interestingZ[0] = pos[2];
1240 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
1241 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
1242 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
1243 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
1244 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
1245 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
1249 fTOFGeometry->GetPosPar(vol2,pos);
1250 interestingX[1] = pos[0];
1251 interestingY[1] = pos[1];
1252 interestingZ[1] = pos[2];
1254 interestingTOF[2] = selectedDigit[adesso3][thirdIndex]->GetTDC();
1255 interestingTOT[2] = selectedDigit[adesso3][thirdIndex]->GetTOT();
1256 interestingADC[2] = selectedDigit[adesso3][thirdIndex]->GetADC();
1257 interestingWeight[2] = selectedDigit[adesso3][thirdIndex]->GetWeight();
1258 Int_t vol3[5]; for(jj=0; jj<5; jj++) vol3[jj] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(jj);
1259 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol3[0], vol3[1], vol3[2], vol3[4], vol3[3]));
1263 fTOFGeometry->GetPosPar(vol3,pos);
1264 interestingX[2] = pos[0];
1265 interestingY[2] = pos[1];
1266 interestingZ[2] = pos[2];
1269 AverageCalculations(3, interestingX, interestingY, interestingZ,
1270 interestingTOF, interestingTOT, interestingADC,
1272 parTOF, posClus, check);
1275 for (jj=0; jj<5; jj++) det[jj] = -1;
1276 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
1277 fTOFGeometry->GetDetID(posF, det);
1279 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
1280 //volIdClus = GetClusterVolIndex(det);
1282 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1283 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
1284 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
1285 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
1286 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
1287 padsCluster[7] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(4);
1288 padsCluster[8] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(3);
1290 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1291 Int_t ** indDet = new Int_t*[3];
1292 for (jj=0; jj<3; jj++) indDet[jj] = new Int_t [5];
1293 for (jj=0; jj<3; jj++) indDet[jj][0] = nSector;
1294 for (jj=0; jj<3; jj++) indDet[jj][1] = nPlate;
1295 for (jj=0; jj<3; jj++) indDet[jj][2] = nStrip;
1296 for (jj=0; jj<3; jj++) indDet[jj][3] = padsCluster[2*jj+3];
1297 for (jj=0; jj<3; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
1298 GetClusterPars(/*check,*/ 3, indDet, interestingWeight, posClus, covClus);
1299 for (jj=0; jj<3; jj++) delete [] indDet[jj];
1301 // To fill the track index array
1303 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1304 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1305 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
1308 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
1311 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1312 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
1315 alreadyStored = kFALSE;
1316 for (jj=0; jj<dummyCounter+1; jj++)
1317 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
1319 if (alreadyStored) continue;
1320 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
1321 AliWarning(" Siamo al limite!");
1326 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
1331 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1332 if (selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk)==-1) continue;
1335 alreadyStored = kFALSE;
1336 for (jj=0; jj<dummyCounter+1; jj++)
1337 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk));
1339 if (alreadyStored) continue;
1340 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
1341 AliWarning(" Siamo al limite!");
1346 tracks[dummyCounter] = selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk);
1353 AliTOFcluster *tofCluster =
1354 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
1355 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1356 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
1357 InsertCluster(tofCluster);
1359 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",
1360 volIdClus, posClus[0], posClus[1], posClus[2],
1361 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1362 tracks[0], tracks[1], tracks[2],
1363 det[0], det[1], det[2], det[3], det[4],
1364 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
1365 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
1371 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
1375 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
1379 fTOFdigitMap->ResetDigitNumber(vol3,selectedDigit[adesso3][thirdIndex]->GetIndex());
1382 } // close loop on third digit
1383 } // close loop on adesso3
1385 } // close loop on second digit
1386 } // close loop on adesso2
1388 } // close loop on first digit
1389 } // close loop on adesso1
1391 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1392 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1393 selectedDigit[ii][jj] = 0x0;
1397 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1398 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
1399 delete selectedDigit[ii][jj];
1400 selectedDigit[ii][jj] = 0x0;
1405 //_____________________________________________________________________________
1407 void AliTOFClusterFinderV1::FindClusters23(Int_t nSector,
1412 // This function searches the neighbouring digits (stored in the fDigits object),
1413 // to perform clusters (stored in the fTofClusters array).
1415 // This research has been made by checking the fTOFdigitMap object,
1416 // filled at digits/raw-data reading time.
1419 const Int_t kMaxNumberOfInterestingPads = 4;
1420 const Int_t kMaxNumberOfTracksPerDigit = 3;
1421 const Int_t kMaxNumberOfDigitsPerVolume = 10;
1425 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
1426 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1427 digitsInVolumeIndices[ii] = -1;
1429 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
1431 Float_t pos[3] = {0.,0.,0.};
1434 Int_t interestingPadX[kMaxNumberOfInterestingPads];
1435 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
1436 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
1437 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
1438 Double_t interestingTOT[kMaxNumberOfInterestingPads];
1439 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
1440 Double_t interestingADC[kMaxNumberOfInterestingPads];
1441 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
1442 Double_t interestingTOF[kMaxNumberOfInterestingPads];
1443 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
1444 Double_t interestingWeight[kMaxNumberOfInterestingPads];
1445 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
1447 Float_t interestingX[kMaxNumberOfInterestingPads];
1448 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
1449 Float_t interestingY[kMaxNumberOfInterestingPads];
1450 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
1451 Float_t interestingZ[kMaxNumberOfInterestingPads];
1452 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
1454 Float_t interDigit[kMaxNumberOfInterestingPads];
1455 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
1457 Int_t padsCluster[11];
1458 padsCluster[0] = nSector;
1459 padsCluster[1] = nPlate;
1460 padsCluster[2] = nStrip;
1461 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1463 Int_t interestingCounter=-1;
1464 Int_t digitIndexLocal = -1;
1469 Bool_t check = kFALSE;
1471 for (jj=0; jj<5; jj++) parTOF[jj] = 0;
1472 Double_t posClus[3];
1473 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
1475 for (jj=0; jj<5; jj++) det[jj] = -1;
1477 for (jj=0; jj<3; jj++) posF[jj] = 0.;
1478 UShort_t volIdClus = 0;
1479 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
1480 Double_t covClus[6];
1481 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1482 Int_t tracks[kMaxNumberOfTracksPerDigit];
1483 for (jj=0; jj<3; jj++) tracks[jj] = -1;
1484 Int_t dummyCounter=-1;
1485 Bool_t alreadyStored = kFALSE;
1487 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
1488 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1489 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
1491 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1492 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
1494 AliTOFdigit *digitInteresting;
1496 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
1498 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
1499 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
1501 AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
1508 interestingCounter=-1;
1510 vol[4] = iPadZ , vol[3] = iPadX;
1511 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1512 interestingCounter++;
1514 vol[4] = iPadZ, vol[3] = iPadX+1;
1515 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1516 interestingCounter++;
1518 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1519 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1520 interestingCounter++;
1522 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1523 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1524 interestingCounter++;
1526 if (interestingCounter+1!=3) continue; // the hit pads have to be 3
1527 else interestingCounter=-1;
1530 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1531 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1532 selectedDigit[ii][jj] = 0x0;
1535 vol[4] = iPadZ, vol[3] = iPadX;
1537 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1538 interestingCounter++;
1539 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1540 digitsInVolumeIndices[ii] = -1;
1541 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1543 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1544 if (digitsInVolumeIndices[digIndex]<0) continue;
1545 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1546 if (digitInteresting->GetToT()<=0) continue; // AdC
1547 digitIndexLocal++; // AdC
1549 AliDebug(1,Form(" %2d %1d %2d %1d %2d %f %f %f %f %5d %5d %5d %5d",
1550 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1551 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1552 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1553 digitsInVolumeIndices[digIndex],
1554 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1556 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1557 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1558 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1559 digitInteresting->GetToT()*digitInteresting->GetToT(),
1560 digitsInVolumeIndices[digIndex],
1561 digitInteresting->GetTracks());
1563 if (digitIndexLocal==-1) interestingCounter--; // AdC
1567 vol[4] = iPadZ, vol[3] = iPadX+1;
1569 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1570 interestingCounter++;
1571 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1572 digitsInVolumeIndices[ii] = -1;
1573 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1574 digitIndexLocal=-1; // AdC
1575 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1576 if (digitsInVolumeIndices[digIndex]<0) continue;
1577 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1578 if (digitInteresting->GetToT()<=0) continue; // AdC
1579 digitIndexLocal++; // AdC
1581 AliDebug(1,Form(" %2d %1d %2d %1d %2d %f %f %f %f %5d %5d %5d %5d",
1582 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1583 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1584 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1585 digitsInVolumeIndices[digIndex],
1586 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1588 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1589 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1590 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1591 digitInteresting->GetToT()*digitInteresting->GetToT(),
1592 digitsInVolumeIndices[digIndex],
1593 digitInteresting->GetTracks());
1595 if (digitIndexLocal==-1) interestingCounter--; // AdC
1599 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1601 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1602 interestingCounter++;
1603 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1604 digitsInVolumeIndices[ii] = -1;
1605 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1606 digitIndexLocal=-1; // AdC
1607 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1608 if (digitsInVolumeIndices[digIndex]<0) continue;
1609 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1610 if (digitInteresting->GetToT()<=0) continue; // AdC
1611 digitIndexLocal++; // AdC
1613 AliDebug(1,Form(" %2d %1d %2d %1d %2d %f %f %f %f %5d %5d %5d %5d",
1614 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1615 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1616 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1617 digitsInVolumeIndices[digIndex],
1618 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1620 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1621 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1622 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1623 digitInteresting->GetToT()*digitInteresting->GetToT(),
1624 digitsInVolumeIndices[digIndex],
1625 digitInteresting->GetTracks());
1627 if (digitIndexLocal==-1) interestingCounter--; // AdC
1631 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1633 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1634 interestingCounter++;
1635 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1636 digitsInVolumeIndices[ii] = -1;
1637 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1638 digitIndexLocal=-1; // AdC
1639 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1640 if (digitsInVolumeIndices[digIndex]<0) continue;
1641 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1642 if (digitInteresting->GetToT()<=0) continue; // AdC
1643 digitIndexLocal++; // AdC
1645 AliDebug(1,Form(" %2d %1d %2d %1d %2d %f %f %f %f %5d %5d %5d %5d",
1646 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1647 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1648 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1649 digitsInVolumeIndices[digIndex],
1650 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1652 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1653 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1654 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1655 digitInteresting->GetToT()*digitInteresting->GetToT(),
1656 digitsInVolumeIndices[digIndex],
1657 digitInteresting->GetTracks());
1659 if (digitIndexLocal==-1) interestingCounter--; // AdC
1662 AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
1664 for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
1665 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
1666 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
1668 for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
1669 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
1670 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
1672 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime) continue;
1674 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
1675 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
1676 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
1677 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
1678 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
1679 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
1680 Int_t volDum = vol1[3];
1683 fTOFGeometry->GetPosPar(vol1,pos);
1684 interestingX[0] = pos[0];
1685 interestingY[0] = pos[1];
1686 interestingZ[0] = pos[2];
1688 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
1689 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
1690 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
1691 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
1692 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
1693 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
1697 fTOFGeometry->GetPosPar(vol2,pos);
1698 interestingX[1] = pos[0];
1699 interestingY[1] = pos[1];
1700 interestingZ[1] = pos[2];
1702 AverageCalculations(2, interestingX, interestingY, interestingZ,
1703 interestingTOF, interestingTOT, interestingADC,
1705 parTOF, posClus, check);
1707 for (jj=0; jj<5; jj++) det[jj] = -1;
1708 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
1709 fTOFGeometry->GetDetID(posF, det);
1711 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
1712 //volIdClus = GetClusterVolIndex(det);
1714 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1715 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
1716 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
1717 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
1718 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
1720 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1721 Int_t ** indDet = new Int_t*[2];
1722 for (jj=0; jj<2; jj++) indDet[jj] = new Int_t [5];
1723 for (jj=0; jj<2; jj++) indDet[jj][0] = nSector;
1724 for (jj=0; jj<2; jj++) indDet[jj][1] = nPlate;
1725 for (jj=0; jj<2; jj++) indDet[jj][2] = nStrip;
1726 for (jj=0; jj<2; jj++) indDet[jj][3] = padsCluster[2*jj+3];
1727 for (jj=0; jj<2; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
1728 GetClusterPars(/*check,*/ 2, indDet, interestingWeight, posClus, covClus);
1729 for (jj=0; jj<2; jj++) delete [] indDet[jj];
1731 // To fill the track index array
1733 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1734 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1735 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
1738 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
1741 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1742 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
1745 alreadyStored = kFALSE;
1746 for (jj=0; jj<dummyCounter+1; jj++)
1747 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
1749 if (alreadyStored) continue;
1750 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
1751 AliWarning(" Siamo al limite!");
1756 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
1763 AliTOFcluster *tofCluster =
1764 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
1765 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1766 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
1767 InsertCluster(tofCluster);
1769 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",
1770 volIdClus, posClus[0], posClus[1], posClus[2],
1771 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1772 tracks[0], tracks[1], tracks[2],
1773 det[0], det[1], det[2], det[3], det[4],
1774 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
1775 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
1780 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
1784 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
1787 } // close loop on second digit
1788 } // close loop on adesso2
1790 } // close loop on first digit
1791 } // close loop on adesso1
1793 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1794 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1795 selectedDigit[ii][jj] = 0x0;
1799 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1800 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
1801 delete selectedDigit[ii][jj];
1802 selectedDigit[ii][jj] = 0x0;
1807 //_____________________________________________________________________________
1809 void AliTOFClusterFinderV1::FindClusters24(Int_t nSector,
1814 // This function searches the neighbouring digits (stored in the fDigits object),
1815 // to perform clusters (stored in the fTofClusters array).
1817 // This research has been made by checking the fTOFdigitMap object,
1818 // filled at digits/raw-data reading time.
1821 const Int_t kMaxNumberOfInterestingPads = 4;
1822 const Int_t kMaxNumberOfTracksPerDigit = 3;
1823 const Int_t kMaxNumberOfDigitsPerVolume = 10;
1827 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
1828 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1829 digitsInVolumeIndices[ii] = -1;
1831 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
1833 Float_t pos[3] = {0.,0.,0.};
1836 Int_t interestingPadX[kMaxNumberOfInterestingPads];
1837 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
1838 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
1839 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
1840 Double_t interestingTOT[kMaxNumberOfInterestingPads];
1841 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
1842 Double_t interestingADC[kMaxNumberOfInterestingPads];
1843 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
1844 Double_t interestingTOF[kMaxNumberOfInterestingPads];
1845 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
1846 Double_t interestingWeight[kMaxNumberOfInterestingPads];
1847 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
1849 Float_t interestingX[kMaxNumberOfInterestingPads];
1850 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
1851 Float_t interestingY[kMaxNumberOfInterestingPads];
1852 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
1853 Float_t interestingZ[kMaxNumberOfInterestingPads];
1854 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
1856 Float_t interDigit[kMaxNumberOfInterestingPads];
1857 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
1859 Int_t padsCluster[11];
1860 padsCluster[0] = nSector;
1861 padsCluster[1] = nPlate;
1862 padsCluster[2] = nStrip;
1863 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1865 Int_t interestingCounter=-1;
1866 Int_t digitIndexLocal = -1;
1871 Bool_t check = kFALSE;
1873 for (jj=0; jj<5; jj++) parTOF[jj] = 0;
1874 Double_t posClus[3];
1875 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
1877 for (jj=0; jj<5; jj++) det[jj] = -1;
1879 for (jj=0; jj<3; jj++) posF[jj] = 0.;
1880 UShort_t volIdClus = 0;
1881 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
1882 Double_t covClus[6];
1883 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1884 Int_t tracks[kMaxNumberOfTracksPerDigit];
1885 for (jj=0; jj<3; jj++) tracks[jj] = -1;
1886 Int_t dummyCounter=-1;
1887 Bool_t alreadyStored = kFALSE;
1889 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
1890 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1891 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
1893 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1894 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
1896 AliTOFdigit *digitInteresting;
1898 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
1900 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
1901 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
1903 AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
1910 interestingCounter=-1;
1912 vol[4] = iPadZ , vol[3] = iPadX;
1913 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1914 interestingCounter++;
1916 vol[4] = iPadZ, vol[3] = iPadX+1;
1917 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1918 interestingCounter++;
1920 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1921 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1922 interestingCounter++;
1924 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1925 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1926 interestingCounter++;
1928 if (interestingCounter+1!=4) continue; // the hit pads have to be 4
1929 else interestingCounter=-1;
1932 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1933 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1934 selectedDigit[ii][jj] = 0x0;
1937 vol[4] = iPadZ, vol[3] = iPadX;
1939 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1940 interestingCounter++;
1941 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1942 digitsInVolumeIndices[ii] = -1;
1943 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1944 digitIndexLocal=-1; // AdC
1945 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1946 if (digitsInVolumeIndices[digIndex]<0) continue;
1947 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1948 if (digitInteresting->GetToT()<=0) continue; // AdC
1949 digitIndexLocal++; // AdC
1951 AliDebug(1,Form(" %2d %1d %2d %1d %2d %f %f %f %f %5d %5d %5d %5d",
1952 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1953 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1954 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1955 digitsInVolumeIndices[digIndex],
1956 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1958 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1959 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1960 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1961 digitInteresting->GetToT()*digitInteresting->GetToT(),
1962 digitsInVolumeIndices[digIndex],
1963 digitInteresting->GetTracks());
1965 if (digitIndexLocal==-1) interestingCounter--; // AdC
1969 vol[4] = iPadZ, vol[3] = iPadX+1;
1971 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1972 interestingCounter++;
1973 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1974 digitsInVolumeIndices[ii] = -1;
1975 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1976 digitIndexLocal=-1; // AdC
1977 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1978 if (digitsInVolumeIndices[digIndex]<0) continue;
1979 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1980 if (digitInteresting->GetToT()<=0) continue; // AdC
1981 digitIndexLocal++; // AdC
1983 AliDebug(1,Form(" %2d %1d %2d %1d %2d %f %f %f %f %5d %5d %5d %5d",
1984 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1985 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1986 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1987 digitsInVolumeIndices[digIndex],
1988 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1990 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1991 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1992 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1993 digitInteresting->GetToT()*digitInteresting->GetToT(),
1994 digitsInVolumeIndices[digIndex],
1995 digitInteresting->GetTracks());
1997 if (digitIndexLocal==-1) interestingCounter--; // AdC
2001 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
2003 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2004 interestingCounter++;
2005 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2006 digitsInVolumeIndices[ii] = -1;
2007 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2008 digitIndexLocal=-1; // AdC
2009 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2010 if (digitsInVolumeIndices[digIndex]<0) continue;
2011 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2012 if (digitInteresting->GetToT()<=0) continue; // AdC
2013 digitIndexLocal++; // AdC
2015 AliDebug(1,Form(" %2d %1d %2d %1d %2d %f %f %f %f %5d %5d %5d %5d",
2016 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2017 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2018 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2019 digitsInVolumeIndices[digIndex],
2020 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2022 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2023 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2024 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2025 digitInteresting->GetToT()*digitInteresting->GetToT(),
2026 digitsInVolumeIndices[digIndex],
2027 digitInteresting->GetTracks());
2029 if (digitIndexLocal==-1) interestingCounter--; // AdC
2033 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
2035 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2036 interestingCounter++;
2037 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2038 digitsInVolumeIndices[ii] = -1;
2039 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2040 digitIndexLocal=-1; // AdC
2041 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2042 if (digitsInVolumeIndices[digIndex]<0) continue;
2043 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2044 if (digitInteresting->GetToT()<=0) continue; // AdC
2045 digitIndexLocal++; // AdC
2047 AliDebug(1,Form(" %2d %1d %2d %1d %2d %f %f %f %f %5d %5d %5d %5d",
2048 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2049 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2050 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2051 digitsInVolumeIndices[digIndex],
2052 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2054 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2055 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2056 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2057 digitInteresting->GetToT()*digitInteresting->GetToT(),
2058 digitsInVolumeIndices[digIndex],
2059 digitInteresting->GetTracks());
2061 if (digitIndexLocal==-1) interestingCounter--; // AdC
2064 AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
2066 for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
2067 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2068 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2070 for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
2071 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2072 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2074 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime) continue;
2076 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2077 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2078 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2079 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2080 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
2081 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
2082 Int_t volDum = vol1[3];
2085 fTOFGeometry->GetPosPar(vol1,pos);
2086 interestingX[0] = pos[0];
2087 interestingY[0] = pos[1];
2088 interestingZ[0] = pos[2];
2090 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2091 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2092 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2093 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2094 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
2095 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
2099 fTOFGeometry->GetPosPar(vol2,pos);
2100 interestingX[1] = pos[0];
2101 interestingY[1] = pos[1];
2102 interestingZ[1] = pos[2];
2105 AverageCalculations(2, interestingX, interestingY, interestingZ,
2106 interestingTOF, interestingTOT, interestingADC,
2108 parTOF, posClus, check);
2110 for (jj=0; jj<5; jj++) det[jj] = -1;
2111 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
2112 fTOFGeometry->GetDetID(posF, det);
2114 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
2115 //volIdClus = GetClusterVolIndex(det);
2117 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2118 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
2119 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
2120 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
2121 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
2123 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2124 Int_t ** indDet = new Int_t*[2];
2125 for (jj=0; jj<2; jj++) indDet[jj] = new Int_t [5];
2126 for (jj=0; jj<2; jj++) indDet[jj][0] = nSector;
2127 for (jj=0; jj<2; jj++) indDet[jj][1] = nPlate;
2128 for (jj=0; jj<2; jj++) indDet[jj][2] = nStrip;
2129 for (jj=0; jj<2; jj++) indDet[jj][3] = padsCluster[2*jj+3];
2130 for (jj=0; jj<2; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
2131 GetClusterPars(/*check,*/ 2, indDet, interestingWeight, posClus, covClus);
2132 for (jj=0; jj<2; jj++) delete [] indDet[jj];
2134 // To fill the track index array
2136 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2137 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2138 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
2141 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
2144 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2145 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
2148 alreadyStored = kFALSE;
2149 for (jj=0; jj<dummyCounter+1; jj++)
2150 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
2152 if (alreadyStored) continue;
2153 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2154 AliWarning(" Siamo al limite!");
2159 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
2166 AliTOFcluster *tofCluster =
2167 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
2168 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2169 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
2170 InsertCluster(tofCluster);
2172 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",
2173 volIdClus, posClus[0], posClus[1], posClus[2],
2174 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2175 tracks[0], tracks[1], tracks[2],
2176 det[0], det[1], det[2], det[3], det[4],
2177 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
2178 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
2183 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
2187 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
2190 } // close loop on second digit
2191 } // close loop on adesso2
2193 } // close loop on first digit
2194 } // close loop on adesso1
2196 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2197 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
2198 selectedDigit[ii][jj] = 0x0;
2202 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2203 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
2204 delete selectedDigit[ii][jj];
2205 selectedDigit[ii][jj] = 0x0;
2210 //_____________________________________________________________________________
2212 void AliTOFClusterFinderV1::FindClustersPerStrip(Int_t nSector,
2218 // This function searches the neighbouring digits (stored in the fDigits object),
2219 // to perform clusters (stored in the fTofClusters array).
2221 // Each strip is read four times:
2222 // - 1st time: it searches possible clusters formed by four
2223 // neighbouring digits;
2224 // - 2nd time: it searches possible clusters formed by three
2225 // neighbouring digits;
2226 // - 3rd time: it searches possible clusters formed by two
2227 // neighbouring digits;
2228 // - 4th time: the remaining isolated digits have been transformed
2230 // This research has been made by checking the fTOFdigitMap object,
2231 // filled at digits/raw-data reading time.
2234 const Int_t kMaxNumberOfInterestingPads = 4;
2235 const Int_t kMaxNumberOfTracksPerDigit = 3;
2236 const Int_t kMaxNumberOfDigitsPerVolume = 10;
2240 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
2241 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2242 digitsInVolumeIndices[ii] = -1;
2244 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
2246 Float_t pos[3] = {0.,0.,0.};
2249 Int_t interestingPadX[kMaxNumberOfInterestingPads];
2250 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
2251 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
2252 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
2253 Double_t interestingTOT[kMaxNumberOfInterestingPads];
2254 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
2255 Double_t interestingADC[kMaxNumberOfInterestingPads];
2256 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
2257 Double_t interestingTOF[kMaxNumberOfInterestingPads];
2258 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
2259 Double_t interestingWeight[kMaxNumberOfInterestingPads];
2260 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
2262 Float_t interestingX[kMaxNumberOfInterestingPads];
2263 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
2264 Float_t interestingY[kMaxNumberOfInterestingPads];
2265 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
2266 Float_t interestingZ[kMaxNumberOfInterestingPads];
2267 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
2269 Float_t interDigit[kMaxNumberOfInterestingPads];
2270 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
2272 Int_t padsCluster[11];
2273 padsCluster[0] = nSector;
2274 padsCluster[1] = nPlate;
2275 padsCluster[2] = nStrip;
2276 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2278 Int_t interestingCounter=-1;
2279 Int_t digitIndexLocal = -1;
2284 Bool_t check = kFALSE;
2286 for (jj=0; jj<5; jj++) parTOF[jj] = 0;
2287 Double_t posClus[3];
2288 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
2290 for (jj=0; jj<5; jj++) det[jj] = -1;
2292 for (jj=0; jj<3; jj++) posF[jj] = 0.;
2293 UShort_t volIdClus = 0;
2294 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
2295 Double_t covClus[6];
2296 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2297 Int_t tracks[kMaxNumberOfTracksPerDigit];
2298 for (jj=0; jj<3; jj++) tracks[jj] = -1;
2299 Int_t dummyCounter=-1;
2300 Bool_t alreadyStored = kFALSE;
2302 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
2303 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2304 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
2306 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2307 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
2309 AliTOFdigit *digitInteresting;
2313 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
2315 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
2316 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
2318 AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
2325 interestingCounter=-1;
2327 vol[4] = iPadZ , vol[3] = iPadX;
2328 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2329 interestingCounter++;
2331 vol[4] = iPadZ, vol[3] = iPadX+1;
2332 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2333 interestingCounter++;
2335 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
2336 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2337 interestingCounter++;
2339 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
2340 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2341 interestingCounter++;
2343 if (interestingCounter!=group) continue;
2344 else interestingCounter=-1;
2347 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2348 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
2349 selectedDigit[ii][jj] = 0x0;
2352 vol[4] = iPadZ, vol[3] = iPadX;
2354 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2355 interestingCounter++;
2356 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2357 digitsInVolumeIndices[ii] = -1;
2358 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2359 digitIndexLocal=-1; // AdC
2360 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2361 if (digitsInVolumeIndices[digIndex]<0) continue;
2362 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2363 if (digitInteresting->GetToT()<=0) continue; // AdC
2364 digitIndexLocal++; // AdC
2366 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2367 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2368 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2369 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2370 digitsInVolumeIndices[digIndex],
2371 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2372 AliDebug(1,Form(" to try %d %d ",digIndex, interestingCounter));
2374 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2375 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2376 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2377 digitInteresting->GetToT()*digitInteresting->GetToT(),
2378 digitsInVolumeIndices[digIndex],
2379 digitInteresting->GetTracks());
2381 if (digitIndexLocal==-1) interestingCounter--; // AdC
2385 vol[4] = iPadZ, vol[3] = iPadX+1;
2387 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2388 interestingCounter++;
2389 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2390 digitsInVolumeIndices[ii] = -1;
2391 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2392 digitIndexLocal=-1; // AdC
2393 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2394 if (digitsInVolumeIndices[digIndex]<0) continue;
2395 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2396 if (digitInteresting->GetToT()<=0) continue; // AdC
2397 digitIndexLocal++; // AdC
2399 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2400 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2401 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2402 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2403 digitsInVolumeIndices[digIndex],
2404 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2405 AliDebug(1,Form(" to try %d %d ",digIndex, interestingCounter));
2407 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2408 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2409 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2410 digitInteresting->GetToT()*digitInteresting->GetToT(),
2411 digitsInVolumeIndices[digIndex],
2412 digitInteresting->GetTracks());
2414 if (digitIndexLocal==-1) interestingCounter--; // AdC
2418 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
2420 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2421 interestingCounter++;
2422 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2423 digitsInVolumeIndices[ii] = -1;
2424 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2425 digitIndexLocal=-1; // AdC
2426 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2427 if (digitsInVolumeIndices[digIndex]<0) continue;
2428 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2429 if (digitInteresting->GetToT()<=0) continue; // AdC
2430 digitIndexLocal++; // AdC
2432 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2433 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2434 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2435 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2436 digitsInVolumeIndices[digIndex],
2437 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2438 AliDebug(1,Form(" to try %d %d ",digIndex, interestingCounter));
2440 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2441 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2442 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2443 digitInteresting->GetToT()*digitInteresting->GetToT(),
2444 digitsInVolumeIndices[digIndex],
2445 digitInteresting->GetTracks());
2447 if (digitIndexLocal==-1) interestingCounter--; // AdC
2451 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
2453 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2454 interestingCounter++;
2455 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2456 digitsInVolumeIndices[ii] = -1;
2457 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2458 digitIndexLocal=-1; // AdC
2459 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2460 if (digitsInVolumeIndices[digIndex]<0) continue;
2461 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2462 if (digitInteresting->GetToT()<=0) continue; // AdC
2463 digitIndexLocal++; // AdC
2465 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2466 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2467 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2468 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2469 digitsInVolumeIndices[digIndex],
2470 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2471 AliDebug(1,Form(" to try %d %d ",digIndex, interestingCounter));
2473 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2474 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2475 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2476 digitInteresting->GetToT()*digitInteresting->GetToT(),
2477 digitsInVolumeIndices[digIndex],
2478 digitInteresting->GetTracks());
2480 if (digitIndexLocal==-1) interestingCounter--; // AdC
2483 AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
2490 switch(interestingCounter+1) {
2494 //for (adesso1=0; adesso1<interestingCounter+1; adesso1++) {
2496 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2497 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2499 //for (adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
2501 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2502 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2504 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime) {
2505 AliDebug(1,Form(" selD1[%d][%d]->GetTDC()=%d selD2[%d][%d]->GetTDC()=%d -- %d ",
2506 adesso1,firstIndex,selectedDigit[adesso1][firstIndex]->GetTDC(),
2507 adesso2,secondIndex,selectedDigit[adesso2][secondIndex]->GetTDC(),
2512 AliDebug(1, Form(" %1d %1d (0x%x) %1d %1d (0x%x)", adesso1, firstIndex,selectedDigit[adesso1][firstIndex],
2513 adesso2, secondIndex,selectedDigit[adesso2][secondIndex]));
2515 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2516 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2517 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2518 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2519 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
2520 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
2521 Int_t volDum = vol1[3];
2524 fTOFGeometry->GetPosPar(vol1,pos);
2525 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
2526 interestingX[0] = pos[0];
2527 interestingY[0] = pos[1];
2528 interestingZ[0] = pos[2];
2530 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2531 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2532 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2533 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2534 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
2535 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
2539 fTOFGeometry->GetPosPar(vol2,pos);
2540 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
2541 interestingX[1] = pos[0];
2542 interestingY[1] = pos[1];
2543 interestingZ[1] = pos[2];
2546 AverageCalculations(interestingCounter+1,
2547 interestingX, interestingY, interestingZ,
2548 interestingTOF, interestingTOT, interestingADC,
2550 parTOF, posClus, check);
2552 for (jj=0; jj<5; jj++) det[jj] = -1;
2553 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
2555 AliDebug(1,Form(" %f %f %f", posF[0], posF[1], posF[2]));
2556 fTOFGeometry->GetDetID(posF, det);
2557 AliDebug(1,Form(" %2d %1d %2d %1d %2d", det[0], det[1], det[2], det[3], det[4]));
2559 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
2560 //volIdClus = GetClusterVolIndex(det);
2562 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2563 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
2564 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
2565 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
2566 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
2568 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2569 Int_t ** indDet = new Int_t*[interestingCounter+1];
2570 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj] = new Int_t [5];
2571 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][0] = nSector;
2572 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][1] = nPlate;
2573 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][2] = nStrip;
2574 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][3] = padsCluster[2*jj+3];
2575 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
2576 GetClusterPars(/*check,*/ interestingCounter+1, indDet, interestingWeight, posClus, covClus);
2577 for (jj=0; jj<interestingCounter+1; jj++) delete [] indDet[jj];
2579 // To fill the track index array
2581 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2582 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2583 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
2586 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
2589 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2590 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
2593 alreadyStored = kFALSE;
2594 for (jj=0; jj<dummyCounter+1; jj++)
2595 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
2597 if (alreadyStored) continue;
2598 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2599 AliWarning(" Siamo al limite!");
2604 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
2611 AliTOFcluster *tofCluster =
2612 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
2613 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2614 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); //to updated
2615 InsertCluster(tofCluster);
2617 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",
2618 volIdClus, posClus[0], posClus[1], posClus[2],
2619 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2620 tracks[0], tracks[1], tracks[2],
2621 det[0], det[1], det[2], det[3], det[4],
2622 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
2623 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
2628 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
2632 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
2635 } // close loop on second digit
2636 //} // close loop on adesso2
2638 } // close loop on first digit
2639 //} // close loop on adesso1
2646 //for (adesso1=0; adesso1<interestingCounter+1; adesso1++) {
2648 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2649 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2651 //for (adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
2653 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2654 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2656 //for (adesso3=adesso2+1; adesso3<interestingCounter+1; adesso3++) {
2658 for (Int_t thirdIndex=0; thirdIndex<kMaxNumberOfDigitsPerVolume; thirdIndex++) {
2659 if (selectedDigit[adesso3][thirdIndex]==0x0) continue;
2662 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime
2664 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
2666 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime) continue;
2668 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2669 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2670 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2671 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2672 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
2673 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
2674 Int_t volDum = vol1[3];
2677 fTOFGeometry->GetPosPar(vol1,pos);
2678 interestingX[0] = pos[0];
2679 interestingY[0] = pos[1];
2680 interestingZ[0] = pos[2];
2682 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2683 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2684 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2685 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2686 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
2687 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
2691 fTOFGeometry->GetPosPar(vol2,pos);
2692 interestingX[1] = pos[0];
2693 interestingY[1] = pos[1];
2694 interestingZ[1] = pos[2];
2696 interestingTOF[2] = selectedDigit[adesso3][thirdIndex]->GetTDC();
2697 interestingTOT[2] = selectedDigit[adesso3][thirdIndex]->GetTOT();
2698 interestingADC[2] = selectedDigit[adesso3][thirdIndex]->GetADC();
2699 interestingWeight[2] = selectedDigit[adesso3][thirdIndex]->GetWeight();
2700 Int_t vol3[5]; for(jj=0; jj<5; jj++) vol3[jj] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(jj);
2701 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol3[0], vol3[1], vol3[2], vol3[4], vol3[3]));
2705 fTOFGeometry->GetPosPar(vol3,pos);
2706 interestingX[2] = pos[0];
2707 interestingY[2] = pos[1];
2708 interestingZ[2] = pos[2];
2711 AverageCalculations(interestingCounter+1,
2712 interestingX, interestingY, interestingZ,
2713 interestingTOF, interestingTOT, interestingADC,
2715 parTOF, posClus, check);
2717 for (jj=0; jj<5; jj++) det[jj] = -1;
2718 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
2719 fTOFGeometry->GetDetID(posF, det);
2721 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
2722 //volIdClus = GetClusterVolIndex(det);
2724 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2725 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
2726 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
2727 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
2728 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
2729 padsCluster[7] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(4);
2730 padsCluster[8] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(3);
2732 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2733 Int_t ** indDet = new Int_t*[interestingCounter+1];
2734 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj] = new Int_t [5];
2735 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][0] = nSector;
2736 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][1] = nPlate;
2737 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][2] = nStrip;
2738 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][3] = padsCluster[2*jj+3];
2739 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
2740 GetClusterPars(/*check,*/ interestingCounter+1, indDet, interestingWeight, posClus, covClus);
2741 for (jj=0; jj<interestingCounter+1; jj++) delete [] indDet[jj];
2743 // To fill the track index array
2745 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2746 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2747 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
2750 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
2753 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2754 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
2757 alreadyStored = kFALSE;
2758 for (jj=0; jj<dummyCounter+1; jj++)
2759 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
2761 if (alreadyStored) continue;
2762 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2763 AliWarning(" Siamo al limite!");
2768 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
2773 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2774 if (selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk)==-1) continue;
2777 alreadyStored = kFALSE;
2778 for (jj=0; jj<dummyCounter+1; jj++)
2779 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk));
2781 if (alreadyStored) continue;
2782 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2783 AliWarning(" Siamo al limite!");
2788 tracks[dummyCounter] = selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk);
2795 AliTOFcluster *tofCluster =
2796 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
2797 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2798 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
2799 InsertCluster(tofCluster);
2801 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",
2802 volIdClus, posClus[0], posClus[1], posClus[2],
2803 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2804 tracks[0], tracks[1], tracks[2],
2805 det[0], det[1], det[2], det[3], det[4],
2806 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
2807 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
2812 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
2816 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
2820 fTOFdigitMap->ResetDigitNumber(vol3,selectedDigit[adesso3][thirdIndex]->GetIndex());
2823 } // close loop on third digit
2824 //} // close loop on adesso3
2826 } // close loop on second digit
2827 //} // close loop on adesso2
2829 } // close loop on first digit
2830 //} // close loop on adesso1
2838 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2839 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2842 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2843 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2846 for (Int_t thirdIndex=0; thirdIndex<kMaxNumberOfDigitsPerVolume; thirdIndex++) {
2847 if (selectedDigit[adesso3][thirdIndex]==0x0) continue;
2850 for (Int_t fourthIndex=0; fourthIndex<kMaxNumberOfDigitsPerVolume; fourthIndex++) {
2851 if (selectedDigit[adesso4][fourthIndex]==0x0) continue;
2854 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime
2856 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
2858 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso4][fourthIndex]->GetTDC())>fMaxDeltaTime
2860 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
2862 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso4][fourthIndex]->GetTDC())>fMaxDeltaTime
2864 TMath::Abs(selectedDigit[adesso3][thirdIndex]->GetTDC()-selectedDigit[adesso4][fourthIndex]->GetTDC())>fMaxDeltaTime) continue;
2866 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2867 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2868 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2869 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2870 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
2871 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
2872 Int_t volDum = vol1[3];
2875 fTOFGeometry->GetPosPar(vol1,pos);
2876 interestingX[0] = pos[0];
2877 interestingY[0] = pos[1];
2878 interestingZ[0] = pos[2];
2880 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2881 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2882 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2883 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2884 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
2885 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
2889 fTOFGeometry->GetPosPar(vol2,pos);
2890 interestingX[1] = pos[0];
2891 interestingY[1] = pos[1];
2892 interestingZ[1] = pos[2];
2894 interestingTOF[2] = selectedDigit[adesso3][thirdIndex]->GetTDC();
2895 interestingTOT[2] = selectedDigit[adesso3][thirdIndex]->GetTOT();
2896 interestingADC[2] = selectedDigit[adesso3][thirdIndex]->GetADC();
2897 interestingWeight[2] = selectedDigit[adesso3][thirdIndex]->GetWeight();
2898 Int_t vol3[5]; for(jj=0; jj<5; jj++) vol3[jj] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(jj);
2899 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol3[0], vol3[1], vol3[2], vol3[4], vol3[3]));
2903 fTOFGeometry->GetPosPar(vol3,pos);
2904 interestingX[2] = pos[0];
2905 interestingY[2] = pos[1];
2906 interestingZ[2] = pos[2];
2908 interestingTOF[3] = selectedDigit[adesso4][fourthIndex]->GetTDC();
2909 interestingTOT[3] = selectedDigit[adesso4][fourthIndex]->GetTOT();
2910 interestingADC[3] = selectedDigit[adesso4][fourthIndex]->GetADC();
2911 interestingWeight[3] = selectedDigit[adesso4][fourthIndex]->GetWeight();
2912 Int_t vol4[5]; for(jj=0; jj<5; jj++) vol4[jj] = selectedDigit[adesso4][fourthIndex]->GetDetectorIndex(jj);
2913 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol4[0], vol4[1], vol4[2], vol4[4], vol4[3]));
2917 fTOFGeometry->GetPosPar(vol4,pos);
2918 interestingX[3] = pos[0];
2919 interestingY[3] = pos[1];
2920 interestingZ[3] = pos[2];
2923 AverageCalculations(interestingCounter+1,
2924 interestingX, interestingY, interestingZ,
2925 interestingTOF, interestingTOT, interestingADC,
2927 parTOF, posClus, check);
2929 for (jj=0; jj<5; jj++) det[jj] = -1;
2930 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
2931 fTOFGeometry->GetDetID(posF, det);
2933 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
2934 //volIdClus = GetClusterVolIndex(det);
2936 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2937 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
2938 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
2939 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
2940 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
2941 padsCluster[7] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(4);
2942 padsCluster[8] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(3);
2943 padsCluster[9] = selectedDigit[adesso4][fourthIndex]->GetDetectorIndex(4);
2944 padsCluster[10] = selectedDigit[adesso4][fourthIndex]->GetDetectorIndex(3);
2946 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2947 Int_t ** indDet = new Int_t*[interestingCounter+1];
2948 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj] = new Int_t [5];
2949 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][0] = nSector;
2950 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][1] = nPlate;
2951 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][2] = nStrip;
2952 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][3] = padsCluster[2*jj+3];
2953 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
2954 GetClusterPars(/*check,*/ interestingCounter+1, indDet, interestingWeight, posClus, covClus);
2955 for (jj=0; jj<interestingCounter+1; jj++) delete [] indDet[jj];
2957 // To fill the track index array
2959 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2960 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2961 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
2964 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
2967 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2968 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
2971 alreadyStored = kFALSE;
2972 for (jj=0; jj<dummyCounter+1; jj++)
2973 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
2975 if (alreadyStored) continue;
2976 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2977 AliWarning(" Siamo al limite!");
2982 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
2987 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2988 if (selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk)==-1) continue;
2991 alreadyStored = kFALSE;
2992 for (jj=0; jj<dummyCounter+1; jj++)
2993 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk));
2995 if (alreadyStored) continue;
2996 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2997 AliWarning(" Siamo al limite!");
3002 tracks[dummyCounter] = selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk);
3007 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
3008 if (selectedDigit[adesso4][fourthIndex]->GetTrackLabel(kk)==-1) continue;
3011 alreadyStored = kFALSE;
3012 for (jj=0; jj<dummyCounter+1; jj++)
3013 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso4][fourthIndex]->GetTrackLabel(kk));
3015 if (alreadyStored) continue;
3016 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
3017 AliWarning(" Siamo al limite!");
3022 tracks[dummyCounter] = selectedDigit[adesso4][fourthIndex]->GetTrackLabel(kk);
3029 AliTOFcluster *tofCluster =
3030 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
3031 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
3032 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
3033 InsertCluster(tofCluster);
3035 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",
3036 volIdClus, posClus[0], posClus[1], posClus[2],
3037 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
3038 tracks[0], tracks[1], tracks[2],
3039 det[0], det[1], det[2], det[3], det[4],
3040 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
3041 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
3046 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
3050 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
3054 fTOFdigitMap->ResetDigitNumber(vol3,selectedDigit[adesso3][thirdIndex]->GetIndex());
3058 fTOFdigitMap->ResetDigitNumber(vol4,selectedDigit[adesso4][fourthIndex]->GetIndex());
3061 } // close loop on fourth digit
3063 } // close loop on third digit
3065 } // close loop on second digit
3067 } // close loop on first digit
3073 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
3074 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
3075 selectedDigit[ii][jj] = 0x0;
3079 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
3080 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
3081 delete selectedDigit[ii][jj];
3082 selectedDigit[ii][jj] = 0x0;
3086 //_____________________________________________________________________________
3088 Int_t AliTOFClusterFinderV1::InsertCluster(AliTOFcluster *tofCluster)
3091 // This function adds a TOF cluster to the array of TOF clusters
3092 // sorted in Z, i.e. fTofClusters
3095 if (fNumberOfTofClusters==kTofMaxCluster) {
3096 AliError("Too many clusters !");
3100 if (fNumberOfTofClusters==0) {
3101 fTofClusters[fNumberOfTofClusters++] = tofCluster;
3105 Int_t ii = FindClusterIndex(tofCluster->GetZ());
3106 memmove(fTofClusters+ii+1 ,fTofClusters+ii,(fNumberOfTofClusters-ii)*sizeof(AliTOFcluster*));
3107 fTofClusters[ii] = tofCluster;
3108 fNumberOfTofClusters++;
3113 //_____________________________________________________________________________
3115 Int_t AliTOFClusterFinderV1::FindClusterIndex(Double_t z) const
3118 // This function returns the index of the nearest cluster in z
3121 if (fNumberOfTofClusters==0) return 0;
3122 if (z <= fTofClusters[0]->GetZ()) return 0;
3123 if (z > fTofClusters[fNumberOfTofClusters-1]->GetZ()) return fNumberOfTofClusters;
3124 Int_t b = 0, e = fNumberOfTofClusters-1, m = (b+e)/2;
3125 for (; b<e; m=(b+e)/2) {
3126 if (z > fTofClusters[m]->GetZ()) b=m+1;
3133 //_____________________________________________________________________________
3135 void AliTOFClusterFinderV1::ResetRecpoint()
3138 // Clear the list of reconstructed points
3141 fNumberOfTofClusters = 0;
3142 if (fRecPoints) fRecPoints->Clear();
3145 //_____________________________________________________________________________
3147 void AliTOFClusterFinderV1::ResetDigits()
3150 // Clear the list of digits
3153 fNumberOfTofDigits = 0;
3154 if (fDigits) fDigits->Clear();
3157 //_____________________________________________________________________________
3158 //UShort_t AliTOFClusterFinderV1::GetClusterVolIndex(Int_t *ind) const
3161 // Get the volume ID to retrieve the l2t transformation
3164 // Detector numbering scheme
3166 Int_t nSector = AliTOFGeometry::NSectors();
3167 Int_t nPlate = AliTOFGeometry::NPlates();
3168 Int_t nStripA = AliTOFGeometry::NStripA();
3169 Int_t nStripB = AliTOFGeometry::NStripB();
3170 Int_t nStripC = AliTOFGeometry::NStripC();
3172 Int_t isector =ind[0];
3173 if (isector >= nSector)
3174 AliError(Form("Wrong sector number in TOF (%d) !", isector));
3175 Int_t iplate = ind[1];
3176 if (iplate >= nPlate)
3177 AliError(Form("Wrong plate number in TOF (%d) !", iplate));
3178 Int_t istrip = ind[2];
3180 Int_t stripOffset = 0;
3186 stripOffset = nStripC;
3189 stripOffset = nStripC+nStripB;
3192 stripOffset = nStripC+nStripB+nStripA;
3195 stripOffset = nStripC+nStripB+nStripA+nStripB;
3198 AliError(Form("Wrong plate number in TOF (%d) !", iplate));
3202 Int_t index= (2*(nStripC+nStripB)+nStripA)*isector +
3206 UShort_t volIndex = AliGeomManager::LayerToVolUID(AliGeomManager::kTOF, index);
3211 //_____________________________________________________________________________
3213 void AliTOFClusterFinderV1::GetClusterPars(Int_t *ind, Double_t* pos, Double_t* cov) const
3216 // Starting from the volume indices (ind[5]), for a cluster coming from
3217 // a isolated digits, this function returns:
3218 // the cluster position (pos),
3219 // the cluster covariance matrix elements (cov)
3223 //we now go in the system of the strip: determine the local coordinates
3226 // 47---------------------------------------------------0 ^ z
3227 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 1 |
3228 // ----------------------------------------------------- | y going outwards
3229 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 0 | par[0]=0;
3231 // ----------------------------------------------------- |
3232 // x <-----------------------------------------------------
3234 //move to the tracking ref system
3235 Double_t lpos[3] = { (ind[4]-23.5)*AliTOFGeometry::XPad(),
3237 (ind[3]- 0.5)*AliTOFGeometry::ZPad() };
3238 AliDebug(1, Form(" %f %f %f", lpos[0], lpos[1], lpos[2]));
3241 UShort_t volIndex = fTOFGeometry->GetAliSensVolIndex(ind[0],ind[1],ind[2]);
3242 //UShort_t volIndex = GetClusterVolIndex(ind);
3243 const TGeoHMatrix *l2t = AliGeomManager::GetTracking2LocalMatrix(volIndex);
3245 // Get the position in the track ref system
3247 l2t->MasterToLocal(lpos,tpos);
3252 //Get the cluster covariance in the track ref system
3254 for (Int_t ii=0; ii<9; ii++) lcov[ii] = 0.;
3256 //cluster covariance in the local system:
3261 lcov[4] = 0.42*0.42/3.;
3262 // = ( 5*0.025 (gas gaps thikness)
3263 // + 4*0.040 (internal glasses thickness)
3264 // + 0.5*0.160 (internl PCB)
3265 // + 1*0.055 (external red glass))
3268 lcov[0] = 0.499678;//AliTOFGeometry::XPad()*AliTOFGeometry::XPad()/12.;
3269 lcov[8] = 0.992429;//AliTOFGeometry::ZPad()*AliTOFGeometry::ZPad()/12.;
3271 //cluster covariance in the tracking system:
3273 m.SetRotation(lcov);
3275 m.MultiplyLeft(&l2t->Inverse());
3276 Double_t *tcov = m.GetRotationMatrix();
3277 cov[0] = tcov[0]; cov[1] = tcov[1]; cov[2] = tcov[2];
3278 cov[3] = tcov[4]; cov[4] = tcov[5]; cov[5] = tcov[8];
3283 //_____________________________________________________________________________
3285 void AliTOFClusterFinderV1::GetClusterPars(/*Bool_t check,*/ Int_t counter,
3286 Int_t **ind, Double_t *weight,
3287 Double_t *pos, Double_t *cov) const
3291 // the volumes indices (ind[counter][5]), for a
3292 // cluster coming from a collection of 'counter'
3294 // the volumes weights (weight[counter]), -controlled
3295 // by the 'check' variable control-, for a cluster
3296 // coming from a collection of 'counter' digits,
3297 // the cluster position (pos),
3298 // this function returns:
3299 // the covariance matrix elements (cov) for the found cluster
3303 // we now go in the system of the strip: determine the local coordinates
3305 // 47---------------------------------------------------0 ^ z
3306 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 1 |
3307 // ----------------------------------------------------- | y going outwards
3308 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 0 | par[0]=0;
3310 // ----------------------------------------------------- |
3311 // x <-----------------------------------------------------
3313 for (Int_t ii=0; ii<counter; ii++)
3314 AliDebug(1, Form(" %2d %2d %1d %2d %1d %2d ",
3315 ii, ind[ii][0], ind[ii][1], ind[ii][2], ind[ii][3], ind[ii][4]));
3317 Float_t posF[3]; for (Int_t ii=0; ii<3; ii++) posF[ii] = (Float_t)pos[ii];
3318 AliDebug(1, Form(" %f %f %f", pos[0], pos[1], pos[2]));
3320 Int_t detClus[5] = {-1, -1, -1, -1, -1};
3321 fTOFGeometry->GetDetID(posF, detClus);
3324 UShort_t volIndex = fTOFGeometry->GetAliSensVolIndex(detClus[0],detClus[1],detClus[2]);
3325 //UShort_t volIndex = GetClusterVolIndex(detClus);
3326 AliDebug(1, Form(" %2d %1d %2d %1d %2d %7i",
3327 detClus[0], detClus[1], detClus[2], detClus[3], detClus[4], volIndex));
3329 // Get the position in the TOF strip ref system
3330 const TGeoHMatrix *alice2strip = AliGeomManager::GetOrigGlobalMatrix(volIndex);
3331 Double_t ppos[3] = {-1, -1, -1};
3332 alice2strip->MasterToLocal(pos,ppos);
3333 AliDebug(1, Form(" %f %f %f", ppos[0], ppos[1], ppos[2]));
3336 // Get the position in the tracking ref system
3337 const TGeoHMatrix *g2l = AliGeomManager::GetTracking2LocalMatrix(volIndex);
3338 Double_t lpos[3] = {-1, -1, -1};
3339 g2l->MasterToLocal(ppos,lpos);
3340 AliDebug(1, Form(" %f %f %f", lpos[0], lpos[1], lpos[2]));
3341 for (Int_t ii=0; ii<3; ii++) pos[ii] = lpos[ii];
3343 //Get the cluster covariance in the track ref system
3345 for (Int_t ii=0; ii<9; ii++) lcov[ii] = 0.;
3347 //cluster covariance in the local system:
3352 // Evaluation of the ovariance matrix elements
3353 TOFclusterError(/*check,*/ counter, ind, weight, ppos, lcov);
3355 AliDebug(1, Form("lcov[0] = %f, lcov[8] = %f", lcov[0], lcov[8]));
3357 //cluster covariance in the tracking system:
3359 m.SetRotation(lcov);
3361 m.MultiplyLeft(&g2l->Inverse());
3362 Double_t *tcov = m.GetRotationMatrix();
3363 cov[0] = tcov[0]; cov[1] = tcov[1]; cov[2] = tcov[2];
3364 cov[3] = tcov[4]; cov[4] = tcov[5]; cov[5] = tcov[8];
3369 //_____________________________________________________________________________
3371 void AliTOFClusterFinderV1::TOFclusterError(/*Bool_t check,*/ Int_t counter,
3372 Int_t **ind, Double_t *weight,
3373 Double_t ppos[], Double_t lcov[]) const
3379 //lcov[4] = 0.42*0.42/3.; // cm2
3380 // = ( 5*0.025 (gas gaps thikness)
3381 // + 4*0.040 (internal glasses thickness)
3382 // + 0.5*0.160 (internl PCB)
3383 // + 1*0.055 (external red glass))
3386 Float_t *delta2X = new Float_t[counter];
3387 for (Int_t ii=0; ii<counter; ii++)
3389 ((ind[ii][4]-23.5)*AliTOFGeometry::XPad() - ppos[0])*((ind[ii][4]-23.5)*AliTOFGeometry::XPad() - ppos[0]);
3391 Float_t *delta2Z = new Float_t[counter];
3392 for (Int_t ii=0; ii<counter; ii++)
3394 ((ind[ii][3]- 0.5)*AliTOFGeometry::ZPad() - ppos[2])*((ind[ii][3]- 0.5)*AliTOFGeometry::ZPad() - ppos[2]);
3396 for (Int_t ii=0; ii<counter; ii++)
3397 AliDebug(1, Form("x[%d] = %f, z[%d] = %f, weight[%d] = %f",
3398 ii, (ind[ii][4]-23.5)*AliTOFGeometry::XPad(),
3399 ii, (ind[ii][3]- 0.5)*AliTOFGeometry::ZPad(),
3402 AliDebug(1, Form("xMean = %f, zMean = %f",ppos[0], ppos[2]));
3410 if (ind[0][3]==ind[1][3] && TMath::Abs(ind[0][4]-ind[1][4])==1) { //
3412 lcov[8] = 1.02039; // cm2
3413 lcov[0] = 0.0379409; // cm2
3416 lcov[0] = 0.5*0.5; // cm2
3418 if (weight[0]==weight[1])
3419 lcov[0] = 0.0379409; // cm2
3421 lcov[0] = TMath::Mean(counter, delta2X, weight); // cm2
3427 else if (ind[0][4]==ind[1][4] && TMath::Abs(ind[0][3]-ind[1][3])==1) {//
3429 lcov[0] = 0.505499; // cm2
3430 lcov[8] = 0.0422046; // cm2
3433 lcov[8] = 0.5*0.5; // cm2
3435 if (weight[0]==weight[1])
3436 lcov[8] = 0.0422046; // cm2
3438 lcov[8] = TMath::Mean(counter, delta2Z, weight); // cm2
3447 lcov[0] = 0.0290677; // cm2
3448 lcov[8] = 0.0569726; // cm2
3451 lcov[0] = 0.5*0.5; // cm2
3452 lcov[8] = 0.5*0.5; // cm2
3455 if (weight[0]==weight[1] && weight[0]==weight[2]) {
3456 lcov[0] = 0.0290677; // cm2
3457 lcov[8] = 0.0569726; // cm2
3460 lcov[0] = TMath::Mean(counter, delta2X, weight); // cm2
3461 lcov[8] = TMath::Mean(counter, delta2Z, weight); // cm2
3470 lcov[0] = 0.0223807; // cm2
3471 lcov[8] = 0.0438662; // cm2
3474 lcov[0] = 0.5*0.5; // cm2
3475 lcov[8] = 0.5*0.5; // cm2
3478 if (weight[0]==weight[1] && weight[0]==weight[2] && weight[0]==weight[3]) {
3479 lcov[0] = 0.0223807; // cm2
3480 lcov[8] = 0.0438662; // cm2
3483 lcov[0] = TMath::Mean(counter, delta2X, weight); // cm2
3484 lcov[8] = TMath::Mean(counter, delta2Z, weight); // cm2
3498 //_____________________________________________________________________________
3500 Bool_t AliTOFClusterFinderV1::MakeSlewingCorrection(Int_t *detectorIndex,
3506 // This funtion makes the following:
3508 // - if at least one of the three status (Pulser/Noise/HW) is
3509 // bad, is sets the status of electronic channel, corresponding to the
3510 // volume identified by detectorIndex, as kFALSE;
3511 // - if offline calibration is in the valid status, it performs the
3512 // slewing correction. In particular, by taking into account:
3513 // * the measured tot and tof values (tofDigitToT and tofDigitTdc,
3515 // * the six parameters of 5th order polynomial used
3516 // to fit the tofVStot scatter plot,
3517 // it returns the corrected tof value, i.e. tdcCorr value.
3520 Bool_t output = kTRUE;
3525 //AliInfo(" Calibrating TOF Digits: ");
3527 AliTOFChannelOnlineArray *calDelay = fTOFcalib->GetTOFOnlineDelay();
3528 AliTOFChannelOnlineStatusArray *calStatus = fTOFcalib->GetTOFOnlineStatus();
3530 TObjArray *calTOFArrayOffline = fTOFcalib->GetTOFCalArrayOffline();
3532 Int_t index = AliTOFGeometry::GetIndex(detectorIndex);
3534 UChar_t statusPulser = calStatus->GetPulserStatus(index);
3535 UChar_t statusNoise = calStatus->GetNoiseStatus(index);
3536 UChar_t statusHW = calStatus->GetHWStatus(index);
3537 UChar_t status = calStatus->GetStatus(index);
3539 //check the status, also unknown is fine!!!!!!!
3541 AliDebug(2, Form(" Status for channel %d = %d",index, (Int_t)status));
3542 if((statusPulser & AliTOFChannelOnlineStatusArray::kTOFPulserBad)==(AliTOFChannelOnlineStatusArray::kTOFPulserBad)||(statusNoise & AliTOFChannelOnlineStatusArray::kTOFNoiseBad)==(AliTOFChannelOnlineStatusArray::kTOFNoiseBad)||(statusHW & AliTOFChannelOnlineStatusArray::kTOFHWBad)==(AliTOFChannelOnlineStatusArray::kTOFHWBad)){
3543 AliDebug(2, Form(" Bad Status for channel %d",index));
3544 //fTofClusters[ii]->SetStatus(kFALSE); //odd convention, to avoid conflict with calibration objects currently in the db (temporary solution).
3548 AliDebug(2, Form(" Good Status for channel %d",index));
3551 if (fCalibrateTOFtimes) { // AdC
3553 // Get Rough channel online equalization
3554 Double_t roughDelay = (Double_t)calDelay->GetDelay(index); // in ns
3555 AliDebug(2,Form(" channel delay (ns) = %f", roughDelay));
3556 // Get Refined channel offline calibration parameters
3557 TString validity = (TString)fTOFcalib->GetOfflineValidity();
3558 if (validity.CompareTo("valid")==0) {
3559 AliTOFChannelOffline * calChannelOffline = (AliTOFChannelOffline*)calTOFArrayOffline->At(index);
3561 for (jj = 0; jj<6; jj++)
3562 par[jj] = (Double_t)calChannelOffline->GetSlewPar(jj);
3564 AliDebug(2,Form(" Calib Pars = %f, %f, %f, %f, %f, %f ",par[0],par[1],par[2],par[3],par[4],par[5]));
3565 AliDebug(2,Form(" The ToT and Time, uncorr (counts) = %d , %d", tofDigitToT, tofDigitTdc));
3566 Double_t tToT = (Double_t)(tofDigitToT*AliTOFGeometry::ToTBinWidth());
3567 tToT*=1.E-3; //ToT in ns
3568 AliDebug(2,Form(" The ToT and Time, uncorr (ns)= %e, %e",tofDigitTdc*AliTOFGeometry::TdcBinWidth()*1.E-3,tToT));
3569 timeCorr = par[0] + tToT*(par[1] + tToT*(par[2] + tToT*(par[3] + tToT*(par[4] + tToT*par[5])))); // the time correction (ns)
3572 timeCorr = roughDelay; // correction in ns
3574 AliDebug(2,Form(" The ToT and Time, uncorr (ns)= %e, %e",tofDigitTdc*AliTOFGeometry::TdcBinWidth()*1.E-3,tofDigitToT*AliTOFGeometry::ToTBinWidth()));
3575 AliDebug(2,Form(" The time correction (ns) = %f", timeCorr));
3576 timeCorr = (Double_t)(tofDigitTdc)*AliTOFGeometry::TdcBinWidth()*1.E-3-timeCorr;//redefine the time
3578 AliDebug(2,Form(" The channel time, corr (ps)= %e",timeCorr ));
3579 tdcCorr = (Int_t)(timeCorr/AliTOFGeometry::TdcBinWidth()); //the corrected time (tdc counts)
3586 //______________________________________________________________________________
3588 void AliTOFClusterFinderV1::Digits2RecPoints(Int_t iEvent)
3591 // Converts digits to recpoints for TOF
3594 TStopwatch stopwatch;
3597 fRunLoader->GetEvent(iEvent);
3599 AliLoader *localTOFLoader = (AliLoader*)fRunLoader->GetLoader("TOFLoader");
3601 TTree * localTreeD = (TTree*)localTOFLoader->TreeD();
3602 if (localTreeD == 0x0)
3603 AliFatal("Can not get TreeD");
3605 TBranch *branch = localTreeD->GetBranch("TOF");
3607 AliError("Can't get the branch with the TOF digits !");
3611 TTree *localTreeR = (TTree*)localTOFLoader->TreeR();
3612 if (localTreeR == 0x0)
3614 localTOFLoader->MakeTree("R");
3615 localTreeR = localTOFLoader->TreeR();
3618 Digits2RecPoints(localTreeD, localTreeR);
3620 //localTOFLoader = fRunLoader->GetLoader("TOFLoader");
3621 localTOFLoader->WriteRecPoints("OVERWRITE");
3623 AliDebug(1, Form("Execution time to read TOF digits and to write TOF clusters for the event number %d: R:%.4fs C:%.4fs",
3624 iEvent, stopwatch.RealTime(),stopwatch.CpuTime()));
3627 //______________________________________________________________________________
3629 void AliTOFClusterFinderV1::Digits2RecPoints(Int_t iEvent, AliRawReader *rawReader)
3632 // Converts RAW data to recpoints for TOF
3635 TStopwatch stopwatch;
3638 fRunLoader->GetEvent(iEvent);
3640 AliDebug(2,Form(" Event number %2d ", iEvent));
3642 AliLoader *localTOFLoader = (AliLoader*)fRunLoader->GetLoader("TOFLoader");
3644 TTree *localTreeR = localTOFLoader->TreeR();
3646 if (localTreeR == 0x0){
3647 localTOFLoader->MakeTree("R");
3648 localTreeR = localTOFLoader->TreeR();
3651 Digits2RecPoints(rawReader, localTreeR);
3653 AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters for the event number %d: R:%.4fs C:%.4fs",
3654 iEvent, stopwatch.RealTime(),stopwatch.CpuTime()));
3657 //______________________________________________________________________________
3659 void AliTOFClusterFinderV1::Raw2Digits(Int_t iEvent, AliRawReader *rawReader)
3662 // Converts RAW data to MC digits for TOF
3666 TStopwatch stopwatch;
3669 fRunLoader->GetEvent(iEvent);
3671 AliDebug(2,Form(" Event number %2d ", iEvent));
3673 AliLoader *localTOFLoader = (AliLoader*)fRunLoader->GetLoader("TOFLoader");
3675 TTree *localTreeD = localTOFLoader->TreeD();
3677 if (localTreeD == 0x0){
3678 localTOFLoader->MakeTree("D");
3679 localTreeD = localTOFLoader->TreeD();
3682 Raw2Digits(rawReader, localTreeD);
3684 AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters for the event number %d: R:%.4fs C:%.4fs",
3685 iEvent, stopwatch.RealTime(),stopwatch.CpuTime()));
3688 //______________________________________________________________________________
3690 void AliTOFClusterFinderV1::AverageCalculations(Int_t number, Float_t *interestingX,
3691 Float_t *interestingY, Float_t *interestingZ,
3692 Double_t *interestingTOF, Double_t *interestingTOT,
3693 Double_t *interestingADC, Double_t *interestingWeight,
3694 Int_t *parTOF, Double_t *posClus, Bool_t &check)
3697 // Calculates the mean values for cluster position (x,y,z),
3698 // TOF charge and time
3701 Double_t tofAverage = 0.;
3702 Double_t totAverage = 0.;
3703 Double_t adcAverage = 0.;
3707 for (ii=number-1; ii>=0; ii--) check=check||(interestingWeight[ii]==0 || interestingWeight[ii]==-1);
3711 posClus[0] = TMath::Mean(number, interestingX);
3712 posClus[1] = TMath::Mean(number, interestingY);
3713 posClus[2] = TMath::Mean(number, interestingZ);
3714 tofAverage = TMath::Mean(number, interestingTOF);
3715 totAverage = TMath::Mean(number, interestingTOT);
3716 adcAverage = TMath::Mean(number, interestingADC);
3721 posClus[0] = TMath::Mean(number, interestingX, interestingWeight);
3722 posClus[1] = TMath::Mean(number, interestingY, interestingWeight);
3723 posClus[2] = TMath::Mean(number, interestingZ, interestingWeight);
3724 tofAverage = TMath::Mean(number, interestingTOF, interestingWeight);
3725 totAverage = TMath::Mean(number, interestingTOT, interestingWeight);
3726 adcAverage = TMath::Mean(number, interestingADC, interestingWeight);
3730 parTOF[0] = Int_t(tofAverage);
3731 parTOF[1] = Int_t(totAverage);
3732 parTOF[2] = Int_t(adcAverage);
3733 parTOF[3] = Int_t(tofAverage);//tofND
3734 parTOF[4] = Int_t(tofAverage);//tofRAW