1 /***************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
17 $Log: AliTOFClusterFinderV1.cxx,v $
18 Revision 2009/04/20 A. De Caro
19 - added two new global variables, called fTOFGeometry and fTOFdigits;
20 - added a new method, called FindClustersWithoutTOT,
21 to transform TOF digits with fTOT=0 in one pad clusters;
22 - update of the covariance matrix elements for the TOF clusters
24 Revision 0.01 2008/05/10 A. De Caro
27 /////////////////////////////////////////
29 // Class for TOF cluster finder (V1) //
31 // Input data: Raw Data or Digits; //
32 // Output data: Digits or Rec Points //
34 /////////////////////////////////////////
36 #include "Riostream.h"
38 #include "TClonesArray.h"
39 #include "TStopwatch.h"
41 #include "TGeoMatrix.h"
46 #include "AliRawReader.h"
47 #include "AliRunLoader.h"
48 #include "AliGeomManager.h"
50 #include "AliTOFcalib.h"
51 #include "AliTOFChannelOnlineArray.h"
52 #include "AliTOFChannelOnlineStatusArray.h"
53 #include "AliTOFChannelOffline.h"
54 #include "AliTOFClusterFinderV1.h"
55 #include "AliTOFcluster.h"
56 #include "AliTOFdigit.h"
57 #include "AliTOFDigitMap.h"
58 #include "AliTOFrawData.h"
59 #include "AliTOFReconstructor.h"
60 #include "AliTOFRecoParam.h"
62 ClassImp(AliTOFClusterFinderV1)
64 //_____________________________________________________________________________
65 AliTOFClusterFinderV1::AliTOFClusterFinderV1(AliTOFcalib *calib):
66 TTask("AliTOFClusterFinderV1",""),
68 fDigits(new TClonesArray("AliTOFdigit", 4000)),
69 fRecPoints(new TClonesArray("AliTOFcluster", 4000)),
70 fNumberOfTofClusters(0),
71 fNumberOfTofDigits(0),
72 fkRecoParam(0),//AliTOFReconstructor::GetRecoParam()),
73 fMaxDeltaTime(0),//fkRecoParam->GetMaxDeltaTime()),
77 fTOFdigitMap(new AliTOFDigitMap()),
78 fTOFGeometry(new AliTOFGeometry()),
79 fTOFdigits(new TTree()),
80 fTOFRawStream(AliTOFRawStream()),
87 for (Int_t ii=0; ii<kTofMaxCluster; ii++) fTofClusters[ii]=0x0;
89 if (AliTOFReconstructor::GetRecoParam()) {
90 fkRecoParam = AliTOFReconstructor::GetRecoParam();
91 fMaxDeltaTime = fkRecoParam->GetMaxDeltaTime();
96 TString validity = (TString)fTOFcalib->GetOfflineValidity();
97 if (validity.CompareTo("valid")==0) {
98 AliInfo(Form(" validity = %s - Using offline calibration parameters", validity.Data()));
100 AliInfo(Form(" validity = %s - Using online calibration parameters", validity.Data()));
105 //_____________________________________________________________________________
106 AliTOFClusterFinderV1::AliTOFClusterFinderV1(AliRunLoader* runLoader, AliTOFcalib *calib):
107 TTask("AliTOFClusterFinderV1",""),
108 fRunLoader(runLoader),
109 fDigits(new TClonesArray("AliTOFdigit", 4000)),
110 fRecPoints(new TClonesArray("AliTOFcluster", 4000)),
111 fNumberOfTofClusters(0),
112 fNumberOfTofDigits(0),
113 fkRecoParam(0),//AliTOFReconstructor::GetRecoParam()),
114 fMaxDeltaTime(0),//fkRecoParam->GetMaxDeltaTime()),
118 fTOFdigitMap(new AliTOFDigitMap()),
119 fTOFGeometry(new AliTOFGeometry()),
120 fTOFdigits(new TTree()),
121 fTOFRawStream(AliTOFRawStream()),
122 fCalibrateTOFtimes(1)
128 for (Int_t ii=0; ii<kTofMaxCluster; ii++) fTofClusters[ii]=0x0;
130 if (AliTOFReconstructor::GetRecoParam()) {
131 fkRecoParam = AliTOFReconstructor::GetRecoParam();
132 fMaxDeltaTime = fkRecoParam->GetMaxDeltaTime();
137 TString validity = (TString)fTOFcalib->GetOfflineValidity();
138 if (validity.CompareTo("valid")==0) {
139 AliInfo(Form(" validity = %s - Using offline calibration parameters", validity.Data()));
141 AliInfo(Form(" validity = %s - Using online calibration parameters", validity.Data()));
145 //_____________________________________________________________________________
147 AliTOFClusterFinderV1::AliTOFClusterFinderV1(const AliTOFClusterFinderV1 &source)
150 fDigits(source.fDigits),
151 fRecPoints(source.fRecPoints),
152 fNumberOfTofClusters(0),
153 fNumberOfTofDigits(0),
154 fkRecoParam(0),//AliTOFReconstructor::GetRecoParam()),
155 fMaxDeltaTime(0),//fkRecoParam->GetMaxDeltaTime()),
157 fDecoderVersion(source.fDecoderVersion),
158 fTOFcalib(source.fTOFcalib),
159 fTOFdigitMap(new AliTOFDigitMap()),
160 fTOFGeometry(new AliTOFGeometry()),
161 fTOFdigits(source.fTOFdigits),
162 fTOFRawStream(source.fTOFRawStream),
163 fCalibrateTOFtimes(1)
167 for (Int_t ii=0; ii<kTofMaxCluster; ii++) fTofClusters[ii]=source.fTofClusters[ii];
169 if (AliTOFReconstructor::GetRecoParam()) {
170 fkRecoParam = AliTOFReconstructor::GetRecoParam();
171 fMaxDeltaTime = fkRecoParam->GetMaxDeltaTime();
177 //_____________________________________________________________________________
179 AliTOFClusterFinderV1& AliTOFClusterFinderV1::operator=(const AliTOFClusterFinderV1 &source)
186 TObject::operator=(source);
187 for (Int_t ii=0; ii<kTofMaxCluster; ii++) fTofClusters[ii]=source.fTofClusters[ii];
188 fDigits=source.fDigits;
189 fRecPoints=source.fRecPoints;
190 fVerbose=source.fVerbose;
191 fDecoderVersion=source.fDecoderVersion;
192 fTOFcalib=source.fTOFcalib;
193 fTOFdigitMap=source.fTOFdigitMap;
194 fTOFGeometry=source.fTOFGeometry;
195 fTOFdigits=source.fTOFdigits;
196 fTOFRawStream=source.fTOFRawStream;
197 fCalibrateTOFtimes=source.fCalibrateTOFtimes;
201 //_____________________________________________________________________________
203 AliTOFClusterFinderV1::~AliTOFClusterFinderV1()
218 fRecPoints->Delete();
229 if (fTofClusters || fNumberOfTofClusters) {
230 for (Int_t ii=0; ii<fNumberOfTofClusters; ii++)
231 if (fTofClusters[ii]) fTofClusters[ii]->Delete();
232 fNumberOfTofClusters = 0;
236 //_____________________________________________________________________________
238 void AliTOFClusterFinderV1::Digits2RecPoints(TTree* digitsTree, TTree* clusterTree)
241 // Converts digits to recPoints for TOF
244 TStopwatch stopwatch;
250 TClonesArray &aDigits = *fDigits;
252 if (digitsTree == 0x0) {
253 AliFatal("Can not get TreeD for TOF");
257 TBranch *branch = digitsTree->GetBranch("TOF");
259 AliError("Can not get branch with the TOF digits !");
263 TClonesArray staticDigits("AliTOFdigit",10000);
264 staticDigits.Clear();
265 TClonesArray *digits = &staticDigits;
266 branch->SetAddress(&digits);
267 digitsTree->GetEvent(0);
268 AliDebug(1,Form("Number of TOF digits: %d", digits->GetEntriesFast()));
270 AliTOFdigit *tofDigit;
273 Int_t detectorIndex[5];
274 for (jj=0; jj<5; jj++) detectorIndex[jj] = -1;
276 for (jj=0; jj<4; jj++) info[jj] = -1;
282 Bool_t status = kTRUE;
284 AliDebug(1," Calibrating TOF Digits");
286 TString validity = (TString)fTOFcalib->GetOfflineValidity();
287 if (validity.CompareTo("valid")==0) {
288 AliInfo(Form(" validity = %s - Using offline calibration parameters", validity.Data()));
290 AliInfo(Form(" validity = %s - Using online calibration parameters", validity.Data()));
294 for (ii=0; ii<digits->GetEntriesFast(); ii++) {
295 tofDigit = (AliTOFdigit*)digits->UncheckedAt(ii);
296 detectorIndex[0] = tofDigit->GetSector();
297 detectorIndex[1] = tofDigit->GetPlate();
298 detectorIndex[2] = tofDigit->GetStrip();
299 detectorIndex[3] = tofDigit->GetPadz();
300 detectorIndex[4] = tofDigit->GetPadx();
302 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
303 if (detectorIndex[1]==2) { // plate with holes
309 tdcCorr = tofDigit->GetTdc();
310 status = MakeSlewingCorrection(detectorIndex, tofDigit->GetToT(), tofDigit->GetTdc(), tdcCorr);
312 for (jj=0; jj<4; jj++) info[jj] = -1;
313 info[0] = tdcCorr;//tofDigit->GetTdc();
314 info[1] = tofDigit->GetAdc();
315 info[2] = tofDigit->GetToT();
316 info[3] = tofDigit->GetTdcND();//tofDigit->GetTdc();//
317 tracks = tofDigit->GetTracks();
319 dummy = detectorIndex[3];
320 detectorIndex[3] = detectorIndex[4];//padx
321 detectorIndex[4] = dummy;//padz
322 last = fDigits->GetEntriesFast();
323 new (aDigits[last]) AliTOFdigit(tracks, detectorIndex, info);
324 if (status) fTOFdigitMap->AddDigit(detectorIndex, last);
326 AliDebug(2, Form(" Digits reading %2d -> %2d %1d %2d %1d %2d (%d, %d, %d)",
328 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[3], detectorIndex[4],
329 info[0], info[1], info[3]));
333 fNumberOfTofDigits = fDigits->GetEntriesFast();
337 Int_t bufsize = 32000;
338 clusterTree->Branch("TOF", &fRecPoints, bufsize);
343 AliDebug(1,Form("Number of found clusters: %d", fNumberOfTofClusters));
347 fTOFdigitMap->Clear();
351 AliDebug(1,Form("Execution time to read TOF digits and to write TOF clusters : R:%.4fs C:%.4fs",
352 stopwatch.RealTime(),stopwatch.CpuTime()));
354 if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
357 //_____________________________________________________________________________
359 void AliTOFClusterFinderV1::Digits2RecPoints(AliRawReader *rawReader, TTree *clustersTree)
362 // Converts raw data to recPoints for TOF
365 TStopwatch stopwatch;
369 AliDebug(2, "TreeD re-creation");
370 //TTree *digitsTree = new TTree();
371 //Raw2Digits(rawReader, digitsTree);
373 Raw2Digits(rawReader, fTOFdigits);
375 AliDebug(1,Form("Number of TOF digits: %d", fNumberOfTofDigits));
378 Int_t bufsize = 32000;
379 clustersTree->Branch("TOF", &fRecPoints, bufsize);
382 clustersTree->Fill();
384 AliDebug(1,Form("Number of found clusters: %d", fNumberOfTofClusters));
388 fTOFdigitMap->Clear();
392 AliDebug(1,Form("Execution time to read TOF raw data and to write TOF clusters : R:%.4fs C:%.4fs",
393 stopwatch.RealTime(),stopwatch.CpuTime()));
397 //_____________________________________________________________________________
399 void AliTOFClusterFinderV1::Raw2Digits(AliRawReader *rawReader, TTree* digitsTree)
402 // Converts raw data to digits for TOF
405 TStopwatch stopwatch;
410 const Int_t kMaxNumberOfTracksPerDigit = 3;
411 const Int_t kDDL = AliDAQ::NumberOfDdls("TOF");
413 digitsTree->Branch("TOF", &fDigits);
414 TClonesArray &aDigits = *fDigits;
416 fTOFRawStream.Clear();
417 fTOFRawStream.SetRawReader(rawReader);
420 if (fVerbose==2) ftxt.open("TOFdigitsRead.txt",ios::app);
422 TClonesArray staticRawData("AliTOFrawData",10000);
423 staticRawData.Clear();
424 TClonesArray * clonesRawData = &staticRawData;
427 Int_t detectorIndex[5] = {-1, -1, -1, -1, -1};
429 Int_t tracks[kMaxNumberOfTracksPerDigit];
430 for (Int_t ii=0; ii<kMaxNumberOfTracksPerDigit; ii++)
435 Bool_t status = kTRUE;
438 TString validity = (TString)fTOFcalib->GetOfflineValidity();
439 if (validity.CompareTo("valid")==0) {
440 AliInfo(Form(" validity = %s - Using offline calibration parameters", validity.Data()));
442 AliInfo(Form(" validity = %s - Using online calibration parameters", validity.Data()));
446 AliInfo("Using New Decoder");
450 for (indexDDL=0; indexDDL<kDDL; indexDDL++) {
454 fTOFRawStream.LoadRawDataBuffers(indexDDL,fVerbose);
455 else fTOFRawStream.LoadRawData(indexDDL);
457 clonesRawData = (TClonesArray*)fTOFRawStream.GetRawData();
458 if (clonesRawData->GetEntriesFast()!=0) AliDebug(2,Form(" TOF raw data number = %3d", clonesRawData->GetEntriesFast()));
459 for (iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
461 AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
463 //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
464 if (tofRawDatum->GetTOF()==-1) continue;
466 fTOFRawStream.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
467 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
470 dummy = detectorIndex[3];
471 detectorIndex[3] = detectorIndex[4];//padz
472 detectorIndex[4] = dummy;//padx
474 tdcCorr = tofRawDatum->GetTOF();
475 status = MakeSlewingCorrection(detectorIndex, tofRawDatum->GetTOT(), tofRawDatum->GetTOF(), tdcCorr);
478 digit[1] = tofRawDatum->GetTOT();
479 digit[2] = tofRawDatum->GetTOT();
480 digit[3] = -1;//tofRawDatum->GetTOF(); //tofND
482 dummy = detectorIndex[3];
483 detectorIndex[3] = detectorIndex[4];//padx
484 detectorIndex[4] = dummy;//padz
486 /* check valid index */
487 if (detectorIndex[0]==-1||detectorIndex[1]==-1||detectorIndex[2]==-1||detectorIndex[3]==-1||detectorIndex[4]==-1) continue;
489 // Do not reconstruct anything in the holes
490 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
491 if (detectorIndex[1]==2) { // plate with holes
497 last = fDigits->GetEntriesFast();
498 new (aDigits[last]) AliTOFdigit(tracks, detectorIndex, digit);
499 if (status) fTOFdigitMap->AddDigit(detectorIndex, last);
502 if (indexDDL<10) ftxt << " " << indexDDL;
503 else ftxt << " " << indexDDL;
504 if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM();
505 else ftxt << " " << tofRawDatum->GetTRM();
506 ftxt << " " << tofRawDatum->GetTRMchain();
507 if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC();
508 else ftxt << " " << tofRawDatum->GetTDC();
509 ftxt << " " << tofRawDatum->GetTDCchannel();
511 if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0];
512 else ftxt << " -> " << detectorIndex[0];
513 ftxt << " " << detectorIndex[1];
514 if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2];
515 else ftxt << " " << detectorIndex[2];
516 ftxt << " " << detectorIndex[4];
517 if (detectorIndex[4]<10) ftxt << " " << detectorIndex[3];
518 else ftxt << " " << detectorIndex[3];
520 if (digit[1]<10)ftxt << " " << digit[1];
521 else if (digit[1]>=10 && digit[1]<100) ftxt << " " << digit[1];
522 else ftxt << " " << digit[1];
523 if (digit[0]<10) ftxt << " " << digit[0] << endl;
524 else if (digit[0]>=10 && digit[0]<100) ftxt << " " << digit[0] << endl;
525 else if (digit[0]>=100 && digit[0]<1000) ftxt << " " << digit[0] << endl;
526 else ftxt << " " << digit[3] << endl;
529 AliDebug(2, Form(" Raw data reading %2d -> %2d %1d %2d %1d %2d (%d, %d, %d)",
531 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[4], detectorIndex[3],
532 digit[0], digit[1], digit[3]));
536 clonesRawData->Clear();
540 if (fVerbose==2) ftxt.close();
544 fNumberOfTofDigits = fDigits->GetEntries();
546 AliDebug(1, Form("Got %d TOF digits", fNumberOfTofDigits));
547 AliDebug(1, Form("Execution time to read TOF raw data and fill TOF digit tree : R:%.2fs C:%.2fs",
548 stopwatch.RealTime(),stopwatch.CpuTime()));
550 if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
553 //_____________________________________________________________________________
555 void AliTOFClusterFinderV1::FillRecPoint()
558 // Fill the global TClonesArray of AliTOFcluster objects,
567 for(Int_t iPlate=AliTOFGeometry::NPlates()-1; iPlate>=0; iPlate--) {
568 for(Int_t iStrip=AliTOFGeometry::NStrip(iPlate)-1; iStrip>=0; iStrip--) {
569 //for (Int_t iSector=AliTOFGeometry::NSectors()-1; iSector>=0; iSector--) {
570 for (Int_t iSector=0; iSector<AliTOFGeometry::NSectors(); iSector++) {
573 if (fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))
574 AliDebug(1,Form(" Number of TOF digits in (%2d,%1d,%2d) -> %d",
575 iSector,iPlate,iStrip,fTOFdigitMap->FilledCellsInStrip(iSector,iPlate,iStrip)));
577 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
578 FindClustersWithoutTOT(iSector, iPlate, iStrip); // clusters coming from digits without TOT measurement
580 if (fMaxDeltaTime>0) {
582 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
583 //if (fTOFdigitMap->FilledCellsInStrip(iSector,iPlate,iStrip)>=4)
584 FindClustersPerStrip(iSector, iPlate, iStrip, 4); // 4 pads clusters
585 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
587 dummy4 = fNumberOfTofClusters;
588 FindClustersPerStrip(iSector, iPlate, iStrip, 4); // 4 pads clusters
589 if (fNumberOfTofClusters!=dummy4)
590 AliDebug(2, Form(" (4): n1= %5d, n2 = %5d", dummy4, fNumberOfTofClusters));
593 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
594 FindClustersPerStrip(iSector, iPlate, iStrip, 3); // 3 pads clusters
595 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
597 dummy3 = fNumberOfTofClusters;
598 FindClustersPerStrip(iSector, iPlate, iStrip, 3); // 3 pads clusters
599 if (fNumberOfTofClusters!=dummy3)
600 AliDebug(2, Form(" (3): n1= %5d, n2 = %5d", dummy3, fNumberOfTofClusters));
603 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
604 FindClustersPerStrip(iSector, iPlate, iStrip, 2); // 2 pads clusters
605 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
607 dummy2 = fNumberOfTofClusters;
608 FindClustersPerStrip(iSector, iPlate, iStrip, 2); // 2 pads clusters
609 if (fNumberOfTofClusters!=dummy2)
610 AliDebug(2, Form(" (2): n1= %5d, n2 =%5d", dummy2, fNumberOfTofClusters));
613 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
614 dummy = fNumberOfTofClusters;
615 FindClusters34(iSector, iPlate, iStrip); // 3 pads clusters between 4 hit pads
616 if (fNumberOfTofClusters!=dummy)
617 AliDebug(2, Form(" (3 between 4): n1 = %5d, n2 = %5d", fNumberOfTofClusters, dummy));
620 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
621 dummy = fNumberOfTofClusters;
622 FindClusters23(iSector, iPlate, iStrip); // 2 pads clusters between 3 hit pads
623 if (fNumberOfTofClusters!=dummy)
624 AliDebug(2, Form(" (2 between 3): n1 = %5d, n2 = %5d", fNumberOfTofClusters, dummy));
626 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
627 dummy = fNumberOfTofClusters;
628 FindClusters24(iSector, iPlate, iStrip); // 2 pads clusters between 4 hit pads
629 if (fNumberOfTofClusters!=dummy)
630 AliDebug(2, Form(" (2 between 4): n1 = %5d, n2 = %5d", fNumberOfTofClusters, dummy));
633 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
634 dummy = fNumberOfTofClusters;
635 FindOnePadClusterPerStrip(iSector, iPlate, iStrip); // 1 pad clusters
636 if (fNumberOfTofClusters!=dummy)
637 AliDebug(2,Form(" (1): n1 = %5d, n2 = %5d", fNumberOfTofClusters, dummy));
639 if (fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip)>0)
640 AliDebug(2, Form(" (1): number of clusters = %5d (remaining digit %2d), -%2d %1d %2d-",
641 fNumberOfTofClusters, fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip),
642 iSector, iPlate, iStrip));
646 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
647 dummy = fNumberOfTofClusters;
648 FindOnePadClusterPerStrip(iSector, iPlate, iStrip); // 1 pad clusters
649 if (fNumberOfTofClusters!=dummy)
650 AliDebug(2,Form(" (1): n1 = %5d, n2 = %5d", fNumberOfTofClusters, dummy));
652 if (fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip)>0)
653 AliDebug(2, Form(" (1): number of clusters = %5d (remaining digit %2d), -%2d %1d %2d-",
654 fNumberOfTofClusters, fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip),
655 iSector, iPlate, iStrip));
665 TClonesArray &lRecPoints = *fRecPoints;
669 Int_t detectorIndex[5];
670 for (jj=0; jj<5; jj++) detectorIndex[jj] = -1;
672 for (jj=0; jj<7; jj++) parTOF[jj] = -1;
673 Int_t trackLabels[3];
674 for (jj=0; jj<3; jj++) trackLabels[jj] = -1;
675 Int_t digitIndex = -1;
676 Bool_t status = kTRUE;
678 for (ii=0; ii<3; ii++) posClus[ii] = 0.;
679 //Float_t covClus[6];
680 //for (ii=0; ii<6; ii++) covClus[ii] = 0.;
683 for (ii=0; ii<fNumberOfTofClusters; ii++) {
685 digitIndex = fTofClusters[ii]->GetIndex();
686 for(jj=0; jj<5; jj++) detectorIndex[jj] = fTofClusters[ii]->GetDetInd(jj);
687 volIdClus = fTOFGeometry->GetAliSensVolIndex(detectorIndex[0],detectorIndex[1],detectorIndex[2]);
688 //volIdClus = GetClusterVolIndex(detectorIndex);
689 for(jj=0; jj<3; jj++) trackLabels[jj] = fTofClusters[ii]->GetLabel(jj);
690 parTOF[0] = fTofClusters[ii]->GetTDC(); // TDC
691 parTOF[1] = fTofClusters[ii]->GetToT(); // TOT
692 parTOF[2] = fTofClusters[ii]->GetADC(); // ADC=TOT
693 parTOF[3] = fTofClusters[ii]->GetTDCND(); // TDCND
694 parTOF[4] = fTofClusters[ii]->GetTDCRAW();//RAW
697 status = fTofClusters[ii]->GetStatus();
699 posClus[0] = fTofClusters[ii]->GetX();
700 posClus[1] = fTofClusters[ii]->GetY();
701 posClus[2] = fTofClusters[ii]->GetZ();
703 //for (jj=0; jj<6; jj++) covClus[jj] = 0.;
704 //((AliCluster*)fTofClusters[ii])->GetGlobalCov(covClus);
706 new(lRecPoints[ii]) AliTOFcluster(volIdClus, (Double_t)posClus[0], (Double_t)posClus[1], (Double_t)posClus[2],
707 (Double_t)(fTofClusters[ii]->GetSigmaX2()),
708 (Double_t)(fTofClusters[ii]->GetSigmaXY()),
709 (Double_t)(fTofClusters[ii]->GetSigmaXZ()),
710 (Double_t)(fTofClusters[ii]->GetSigmaY2()),
711 (Double_t)(fTofClusters[ii]->GetSigmaYZ()),
712 (Double_t)(fTofClusters[ii]->GetSigmaZ2()),
713 //(Double_t)covClus[0], (Double_t)covClus[1], (Double_t)covClus[2],
714 //(Double_t)covClus[3], (Double_t)covClus[4], (Double_t)covClus[5],
715 trackLabels, detectorIndex, parTOF, status, digitIndex);
717 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",
718 ii, volIdClus, posClus[0], posClus[1], posClus[2],
719 fTofClusters[ii]->GetSigmaX2(),
720 fTofClusters[ii]->GetSigmaXY(),
721 fTofClusters[ii]->GetSigmaXZ(),
722 fTofClusters[ii]->GetSigmaY2(),
723 fTofClusters[ii]->GetSigmaYZ(),
724 fTofClusters[ii]->GetSigmaZ2(),
725 trackLabels[0], trackLabels[1], trackLabels[2],
726 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[3], detectorIndex[4],
727 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
728 status, digitIndex));
733 for (Int_t iSector=0; iSector<AliTOFGeometry::NSectors(); iSector++)
734 for(Int_t iPlate=0; iPlate<AliTOFGeometry::NPlates(); iPlate++) {
735 for(Int_t iStrip=0; iStrip<AliTOFGeometry::NStrip(iPlate); iStrip++) {
736 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
737 AliDebug(2, Form(" END %2d %1d %2d %5d",
738 iSector, iPlate, iStrip, fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip)));
743 //_____________________________________________________________________________
745 void AliTOFClusterFinderV1::FindOnePadClusterPerStrip(Int_t nSector,
750 // This function searches the isolated digits (stored in the fDigits object),
751 // to perform clusters (stored in the fTofClusters array).
752 // This research has been made by checking the fTOFdigitMap object,
753 // filled at digits/raw-data reading time.
756 const Int_t kMaxNumberOfTracksPerDigit = 3;
757 const Int_t kMaxNumberOfDigitsPerVolume = 10;
761 Int_t det[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padZ,padX
762 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padX,padZ
763 UShort_t volIdClus = 0;
766 for (jj=0; jj<3; jj++) pos[jj] = 0.;
768 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
771 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
774 for (jj=0; jj<7; jj++) parTOF[jj] = 0;
776 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
778 Int_t tracks[kMaxNumberOfTracksPerDigit];
779 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
781 Int_t dummyCounter=-1;
783 AliTOFdigit *digitInteresting;
787 for (iPadX=0; iPadX<AliTOFGeometry::NpadX(); iPadX++) {
788 for (iPadZ=0; iPadZ<AliTOFGeometry::NpadZ(); iPadZ++) {
789 vol[4] = iPadZ , vol[3] = iPadX;
791 AliDebug(3, Form(" %1d %2d\n", iPadZ, iPadX));
793 if (fTOFdigitMap->GetNumberOfDigits(vol)==0) continue;
795 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
796 if (fTOFdigitMap->GetDigitIndex(vol,digIndex)<0) continue;
797 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(fTOFdigitMap->GetDigitIndex(vol,digIndex));
799 AliDebug(2, Form(" %3d %5d %2d %1d %2d %1d %2d %d %d %d %5d %5d %5d %5d",
800 fTOFdigitMap->GetNumberOfDigits(vol), digIndex,
801 vol[0], vol[1], vol[2] ,vol[4], vol[3],
802 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
803 digitInteresting->GetToT(),
804 fTOFdigitMap->GetDigitIndex(vol,digIndex),
805 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
807 det[3] = vol[4]; // padz
808 det[4] = vol[3]; // padx
809 fTOFGeometry->GetPosPar(det,pos);
810 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
813 for (jj=0; jj<3; jj++) posClus[jj] = pos[jj];
815 parTOF[0] = Int_t(digitInteresting->GetTdc());
816 parTOF[1] = Int_t(digitInteresting->GetToT());
817 parTOF[2] = Int_t(digitInteresting->GetAdc());
818 parTOF[3] = Int_t(digitInteresting->GetTdcND());
819 parTOF[4] = Int_t(digitInteresting->GetTdc());
823 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
824 //volIdClus = GetClusterVolIndex(det);
826 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
827 GetClusterPars(det, posClus, covClus);
829 // To fill the track index array
831 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
832 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) { // three is the max number of tracks associated to one digit
833 if (digitInteresting->GetTrack(jj)==-1) continue;
836 tracks[dummyCounter] = digitInteresting->GetTrack(jj);
840 AliTOFcluster *tofCluster =
841 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
842 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
843 tracks, det, parTOF, status, fTOFdigitMap->GetDigitIndex(vol,digIndex));
844 InsertCluster(tofCluster);
846 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",
847 volIdClus, posClus[0], posClus[1], posClus[2],
848 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
849 tracks[0], tracks[1], tracks[2],
850 det[0], det[1], det[2], det[3], det[4],
851 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
852 status, fTOFdigitMap->GetDigitIndex(vol,digIndex)));
854 AliDebug(2, Form(" %f %f %f", pos[0], pos[1], pos[2]));
855 AliDebug(2, Form(" %d %d", parTOF[0], parTOF[2]));
857 fTOFdigitMap->ResetDigit(vol, digIndex);
865 //_____________________________________________________________________________
867 void AliTOFClusterFinderV1::FindClustersWithoutTOT(Int_t nSector,
872 // This function searches the isolated digits without TOT
873 // measurement (stored in the fDigits object), to perform clusters
874 // (stored in the fTofClusters array). This research has been made
875 // by checking the fTOFdigitMap object, filled at digits/raw-data
879 const Int_t kMaxNumberOfTracksPerDigit = 3;
880 const Int_t kMaxNumberOfDigitsPerVolume = 10;
884 Int_t det[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padZ,padX
885 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padX,padZ
886 UShort_t volIdClus = 0;
889 for (jj=0; jj<3; jj++) pos[jj] = 0.;
891 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
894 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
897 for (jj=0; jj<7; jj++) parTOF[jj] = 0;
899 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
900 Int_t tracks[kMaxNumberOfTracksPerDigit];
901 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
903 Int_t dummyCounter=-1;
905 AliTOFdigit *digitInteresting;
909 for (iPadX=0; iPadX<AliTOFGeometry::NpadX(); iPadX++) {
910 for (iPadZ=0; iPadZ<AliTOFGeometry::NpadZ(); iPadZ++) {
911 vol[4] = iPadZ , vol[3] = iPadX;
913 AliDebug(3, Form(" %1d %2d\n", iPadZ, iPadX));
915 if (fTOFdigitMap->GetNumberOfDigits(vol)==0) continue;
917 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
918 if (fTOFdigitMap->GetDigitIndex(vol,digIndex)<0) continue;
919 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(fTOFdigitMap->GetDigitIndex(vol,digIndex));
920 if (digitInteresting->GetToT()>0) continue; // AdC
922 AliDebug(2, Form(" %3d %5d %2d %1d %2d %1d %2d %d %d %d %5d %5d %5d %5d",
923 fTOFdigitMap->GetNumberOfDigits(vol), digIndex,
924 vol[0], vol[1], vol[2] ,vol[4], vol[3],
925 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
926 digitInteresting->GetToT(),
927 fTOFdigitMap->GetDigitIndex(vol,digIndex),
928 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
930 det[3] = vol[4]; // padz
931 det[4] = vol[3]; // padx
932 fTOFGeometry->GetPosPar(det,pos);
933 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
936 for (jj=0; jj<3; jj++) posClus[jj] = pos[jj];
938 parTOF[0] = Int_t(digitInteresting->GetTdc());
939 parTOF[1] = Int_t(digitInteresting->GetToT());
940 parTOF[2] = Int_t(digitInteresting->GetAdc());
941 parTOF[3] = Int_t(digitInteresting->GetTdcND());
942 parTOF[4] = Int_t(digitInteresting->GetTdc());
946 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
947 //volIdClus = GetClusterVolIndex(det);
949 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
950 GetClusterPars(det, posClus, covClus);
952 // To fill the track index array
954 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
955 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) { // three is the max number of tracks associated to one digit
956 if (digitInteresting->GetTrack(jj)==-1) continue;
959 tracks[dummyCounter] = digitInteresting->GetTrack(jj);
963 AliTOFcluster *tofCluster =
964 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
965 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
966 tracks, det, parTOF, status, fTOFdigitMap->GetDigitIndex(vol,digIndex));
967 InsertCluster(tofCluster);
969 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",
970 volIdClus, posClus[0], posClus[1], posClus[2],
971 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
972 tracks[0], tracks[1], tracks[2],
973 det[0], det[1], det[2], det[3], det[4],
974 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
975 status, fTOFdigitMap->GetDigitIndex(vol,digIndex)));
977 AliDebug(2, Form(" %f %f %f", pos[0], pos[1], pos[2]));
978 AliDebug(2, Form(" %d %d", parTOF[0], parTOF[2]));
980 fTOFdigitMap->ResetDigit(vol, digIndex);
988 //_____________________________________________________________________________
990 void AliTOFClusterFinderV1::FindClusters34(Int_t nSector,
995 // This function searches the neighbouring digits (stored in the fDigits object),
996 // to perform clusters (stored in the fTofClusters array).
998 // This research has been made by checking the fTOFdigitMap object,
999 // filled at digits/raw-data reading time.
1002 const Int_t kMaxNumberOfInterestingPads = 4;
1003 const Int_t kMaxNumberOfTracksPerDigit = 3;
1004 const Int_t kMaxNumberOfDigitsPerVolume = 10;
1008 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
1009 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1010 digitsInVolumeIndices[ii] = -1;
1012 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
1014 Float_t pos[3] = {0.,0.,0.};
1017 Int_t interestingPadX[kMaxNumberOfInterestingPads];
1018 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
1019 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
1020 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
1021 Double_t interestingTOT[kMaxNumberOfInterestingPads];
1022 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
1023 Double_t interestingADC[kMaxNumberOfInterestingPads];
1024 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
1025 Double_t interestingTOF[kMaxNumberOfInterestingPads];
1026 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
1027 Double_t interestingWeight[kMaxNumberOfInterestingPads];
1028 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
1030 Float_t interestingX[kMaxNumberOfInterestingPads];
1031 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
1032 Float_t interestingY[kMaxNumberOfInterestingPads];
1033 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
1034 Float_t interestingZ[kMaxNumberOfInterestingPads];
1035 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
1037 Float_t interDigit[kMaxNumberOfInterestingPads];
1038 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
1040 Int_t padsCluster[11];
1041 padsCluster[0] = nSector;
1042 padsCluster[1] = nPlate;
1043 padsCluster[2] = nStrip;
1044 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1046 Int_t interestingCounter=-1;
1047 Int_t digitIndexLocal=-1; // AdC
1053 for (jj=0; jj<7; jj++) parTOF[jj] = 0;
1054 Double_t posClus[3];
1055 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
1057 for (jj=0; jj<5; jj++) det[jj] = -1;
1059 for (jj=0; jj<3; jj++) posF[jj] = 0.;
1060 UShort_t volIdClus = 0;
1061 Bool_t check = kFALSE;
1062 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
1063 Double_t covClus[6];
1064 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1065 Int_t tracks[kMaxNumberOfTracksPerDigit];
1066 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1067 Int_t dummyCounter=-1;
1068 Bool_t alreadyStored = kFALSE;
1070 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
1071 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1072 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
1074 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1075 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
1077 AliTOFdigit *digitInteresting;
1079 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
1081 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
1082 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
1084 AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
1091 interestingCounter=-1;
1093 vol[4] = iPadZ , vol[3] = iPadX;
1094 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1095 interestingCounter++;
1097 vol[4] = iPadZ, vol[3] = iPadX+1;
1098 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1099 interestingCounter++;
1101 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1102 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1103 interestingCounter++;
1105 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1106 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1107 interestingCounter++;
1109 if (interestingCounter+1!=4) continue; // the hit pads have to be 4
1110 else interestingCounter=-1;
1113 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1114 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1115 selectedDigit[ii][jj] = 0x0;
1118 vol[4] = iPadZ, vol[3] = iPadX;
1120 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1121 interestingCounter++;
1122 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1123 digitsInVolumeIndices[ii] = -1;
1124 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1125 digitIndexLocal=-1; // AdC
1126 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1127 if (digitsInVolumeIndices[digIndex]<0) continue;
1128 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1129 if (digitInteresting->GetToT()<=0) continue; // AdC
1130 digitIndexLocal++; // AdC
1132 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1133 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1134 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1135 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1136 digitsInVolumeIndices[digIndex],
1137 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1140 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1141 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1142 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1143 digitInteresting->GetToT()*digitInteresting->GetToT(),
1144 digitsInVolumeIndices[digIndex],
1145 digitInteresting->GetTracks());
1147 if (digitIndexLocal==-1) interestingCounter--; // AdC
1151 vol[4] = iPadZ, vol[3] = iPadX+1;
1153 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1154 interestingCounter++;
1155 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1156 digitsInVolumeIndices[ii] = -1;
1157 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1158 digitIndexLocal=-1; // AdC
1159 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1160 if (digitsInVolumeIndices[digIndex]<0) continue;
1161 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1162 if (digitInteresting->GetToT()<=0) continue; // AdC
1163 digitIndexLocal++; // AdC
1165 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1166 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1167 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1168 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1169 digitsInVolumeIndices[digIndex],
1170 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1173 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1174 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1175 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1176 digitInteresting->GetToT()*digitInteresting->GetToT(),
1177 digitsInVolumeIndices[digIndex],
1178 digitInteresting->GetTracks());
1180 if (digitIndexLocal==-1) interestingCounter--; // AdC
1184 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1186 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1187 interestingCounter++;
1188 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1189 digitsInVolumeIndices[ii] = -1;
1190 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1191 digitIndexLocal=-1; // AdC
1192 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1193 if (digitsInVolumeIndices[digIndex]<0) continue;
1194 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1195 if (digitInteresting->GetToT()<=0) continue; // AdC
1196 digitIndexLocal++; // AdC
1198 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1199 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1200 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1201 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1202 digitsInVolumeIndices[digIndex],
1203 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1206 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1207 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1208 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1209 digitInteresting->GetToT()*digitInteresting->GetToT(),
1210 digitsInVolumeIndices[digIndex],
1211 digitInteresting->GetTracks());
1213 if (digitIndexLocal==-1) interestingCounter--; // AdC
1217 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1219 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1220 interestingCounter++;
1221 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1222 digitsInVolumeIndices[ii] = -1;
1223 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1225 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1226 if (digitsInVolumeIndices[digIndex]<0) continue;
1227 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1228 if (digitInteresting->GetToT()<=0) continue; // AdC
1229 digitIndexLocal++; // AdC
1231 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1232 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1233 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1234 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1235 digitsInVolumeIndices[digIndex],
1236 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1238 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1239 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1240 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1241 digitInteresting->GetToT()*digitInteresting->GetToT(),
1242 digitsInVolumeIndices[digIndex],
1243 digitInteresting->GetTracks());
1245 if (digitIndexLocal==-1) interestingCounter--; // AdC
1248 AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
1250 for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
1251 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
1252 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
1254 for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
1255 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
1256 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
1258 for (Int_t adesso3=adesso2+1; adesso3<interestingCounter+1; adesso3++) {
1259 for (Int_t thirdIndex=0; thirdIndex<kMaxNumberOfDigitsPerVolume; thirdIndex++) {
1260 if (selectedDigit[adesso3][thirdIndex]==0x0) continue;
1263 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime
1265 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
1267 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime) continue;
1269 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
1270 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
1271 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
1272 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
1273 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
1274 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
1275 Int_t volDum = vol1[3];
1278 fTOFGeometry->GetPosPar(vol1,pos);
1279 interestingX[0] = pos[0];
1280 interestingY[0] = pos[1];
1281 interestingZ[0] = pos[2];
1283 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
1284 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
1285 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
1286 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
1287 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
1288 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
1292 fTOFGeometry->GetPosPar(vol2,pos);
1293 interestingX[1] = pos[0];
1294 interestingY[1] = pos[1];
1295 interestingZ[1] = pos[2];
1297 interestingTOF[2] = selectedDigit[adesso3][thirdIndex]->GetTDC();
1298 interestingTOT[2] = selectedDigit[adesso3][thirdIndex]->GetTOT();
1299 interestingADC[2] = selectedDigit[adesso3][thirdIndex]->GetADC();
1300 interestingWeight[2] = selectedDigit[adesso3][thirdIndex]->GetWeight();
1301 Int_t vol3[5]; for(jj=0; jj<5; jj++) vol3[jj] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(jj);
1302 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol3[0], vol3[1], vol3[2], vol3[4], vol3[3]));
1306 fTOFGeometry->GetPosPar(vol3,pos);
1307 interestingX[2] = pos[0];
1308 interestingY[2] = pos[1];
1309 interestingZ[2] = pos[2];
1312 AverageCalculations(3, interestingX, interestingY, interestingZ,
1313 interestingTOF, interestingTOT, interestingADC,
1315 parTOF, posClus, check);
1318 for (jj=0; jj<5; jj++) det[jj] = -1;
1319 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
1320 fTOFGeometry->GetDetID(posF, det);
1322 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
1323 //volIdClus = GetClusterVolIndex(det);
1325 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1326 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
1327 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
1328 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
1329 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
1330 padsCluster[7] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(4);
1331 padsCluster[8] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(3);
1333 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1334 Int_t ** indDet = new Int_t*[3];
1335 for (jj=0; jj<3; jj++) indDet[jj] = new Int_t [5];
1336 for (jj=0; jj<3; jj++) indDet[jj][0] = nSector;
1337 for (jj=0; jj<3; jj++) indDet[jj][1] = nPlate;
1338 for (jj=0; jj<3; jj++) indDet[jj][2] = nStrip;
1339 for (jj=0; jj<3; jj++) indDet[jj][3] = padsCluster[2*jj+3];
1340 for (jj=0; jj<3; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
1341 GetClusterPars(/*check,*/ 3, indDet, interestingWeight, posClus, covClus);
1342 for (jj=0; jj<3; jj++) delete [] indDet[jj];
1345 // To fill the track index array
1347 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1348 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1349 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
1352 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
1355 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1356 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
1359 alreadyStored = kFALSE;
1360 for (jj=0; jj<dummyCounter+1; jj++)
1361 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
1363 if (alreadyStored) continue;
1364 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
1365 AliWarning(" Siamo al limite!");
1370 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
1375 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1376 if (selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk)==-1) continue;
1379 alreadyStored = kFALSE;
1380 for (jj=0; jj<dummyCounter+1; jj++)
1381 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk));
1383 if (alreadyStored) continue;
1384 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
1385 AliWarning(" Siamo al limite!");
1390 tracks[dummyCounter] = selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk);
1397 AliTOFcluster *tofCluster =
1398 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
1399 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1400 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
1401 InsertCluster(tofCluster);
1403 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",
1404 volIdClus, posClus[0], posClus[1], posClus[2],
1405 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1406 tracks[0], tracks[1], tracks[2],
1407 det[0], det[1], det[2], det[3], det[4],
1408 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
1409 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
1415 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
1419 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
1423 fTOFdigitMap->ResetDigitNumber(vol3,selectedDigit[adesso3][thirdIndex]->GetIndex());
1426 } // close loop on third digit
1427 } // close loop on adesso3
1429 } // close loop on second digit
1430 } // close loop on adesso2
1432 } // close loop on first digit
1433 } // close loop on adesso1
1435 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1436 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1437 selectedDigit[ii][jj] = 0x0;
1441 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++) {
1442 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
1443 delete [] selectedDigit[ii][jj];
1444 selectedDigit[ii][jj] = 0x0;
1446 delete [] selectedDigit[ii];
1447 selectedDigit[ii] = 0x0;
1449 delete [] selectedDigit;
1450 selectedDigit = 0x0;
1453 //_____________________________________________________________________________
1455 void AliTOFClusterFinderV1::FindClusters23(Int_t nSector,
1460 // This function searches the neighbouring digits (stored in the fDigits object),
1461 // to perform clusters (stored in the fTofClusters array).
1463 // This research has been made by checking the fTOFdigitMap object,
1464 // filled at digits/raw-data reading time.
1467 const Int_t kMaxNumberOfInterestingPads = 4;
1468 const Int_t kMaxNumberOfTracksPerDigit = 3;
1469 const Int_t kMaxNumberOfDigitsPerVolume = 10;
1473 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
1474 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1475 digitsInVolumeIndices[ii] = -1;
1477 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
1479 Float_t pos[3] = {0.,0.,0.};
1482 Int_t interestingPadX[kMaxNumberOfInterestingPads];
1483 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
1484 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
1485 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
1486 Double_t interestingTOT[kMaxNumberOfInterestingPads];
1487 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
1488 Double_t interestingADC[kMaxNumberOfInterestingPads];
1489 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
1490 Double_t interestingTOF[kMaxNumberOfInterestingPads];
1491 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
1492 Double_t interestingWeight[kMaxNumberOfInterestingPads];
1493 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
1495 Float_t interestingX[kMaxNumberOfInterestingPads];
1496 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
1497 Float_t interestingY[kMaxNumberOfInterestingPads];
1498 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
1499 Float_t interestingZ[kMaxNumberOfInterestingPads];
1500 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
1502 Float_t interDigit[kMaxNumberOfInterestingPads];
1503 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
1505 Int_t padsCluster[11];
1506 padsCluster[0] = nSector;
1507 padsCluster[1] = nPlate;
1508 padsCluster[2] = nStrip;
1509 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1511 Int_t interestingCounter=-1;
1512 Int_t digitIndexLocal = -1;
1517 Bool_t check = kFALSE;
1519 for (jj=0; jj<7; jj++) parTOF[jj] = 0;
1520 Double_t posClus[3];
1521 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
1523 for (jj=0; jj<5; jj++) det[jj] = -1;
1525 for (jj=0; jj<3; jj++) posF[jj] = 0.;
1526 UShort_t volIdClus = 0;
1527 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
1528 Double_t covClus[6];
1529 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1530 Int_t tracks[kMaxNumberOfTracksPerDigit];
1531 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1532 Int_t dummyCounter=-1;
1533 Bool_t alreadyStored = kFALSE;
1535 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
1536 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1537 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
1539 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1540 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
1542 AliTOFdigit *digitInteresting;
1544 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
1546 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
1547 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
1549 AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
1556 interestingCounter=-1;
1558 vol[4] = iPadZ , vol[3] = iPadX;
1559 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1560 interestingCounter++;
1562 vol[4] = iPadZ, vol[3] = iPadX+1;
1563 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1564 interestingCounter++;
1566 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1567 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1568 interestingCounter++;
1570 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1571 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1572 interestingCounter++;
1574 if (interestingCounter+1!=3) continue; // the hit pads have to be 3
1575 else interestingCounter=-1;
1578 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1579 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1580 selectedDigit[ii][jj] = 0x0;
1583 vol[4] = iPadZ, vol[3] = iPadX;
1585 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1586 interestingCounter++;
1587 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1588 digitsInVolumeIndices[ii] = -1;
1589 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1591 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1592 if (digitsInVolumeIndices[digIndex]<0) continue;
1593 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1594 if (digitInteresting->GetToT()<=0) continue; // AdC
1595 digitIndexLocal++; // AdC
1597 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1598 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1599 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1600 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1601 digitsInVolumeIndices[digIndex],
1602 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1604 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1605 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1606 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1607 digitInteresting->GetToT()*digitInteresting->GetToT(),
1608 digitsInVolumeIndices[digIndex],
1609 digitInteresting->GetTracks());
1611 if (digitIndexLocal==-1) interestingCounter--; // AdC
1615 vol[4] = iPadZ, vol[3] = iPadX+1;
1617 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1618 interestingCounter++;
1619 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1620 digitsInVolumeIndices[ii] = -1;
1621 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1622 digitIndexLocal=-1; // AdC
1623 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1624 if (digitsInVolumeIndices[digIndex]<0) continue;
1625 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1626 if (digitInteresting->GetToT()<=0) continue; // AdC
1627 digitIndexLocal++; // AdC
1629 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1630 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1631 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1632 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1633 digitsInVolumeIndices[digIndex],
1634 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1636 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1637 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1638 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1639 digitInteresting->GetToT()*digitInteresting->GetToT(),
1640 digitsInVolumeIndices[digIndex],
1641 digitInteresting->GetTracks());
1643 if (digitIndexLocal==-1) interestingCounter--; // AdC
1647 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1649 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1650 interestingCounter++;
1651 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1652 digitsInVolumeIndices[ii] = -1;
1653 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1654 digitIndexLocal=-1; // AdC
1655 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1656 if (digitsInVolumeIndices[digIndex]<0) continue;
1657 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1658 if (digitInteresting->GetToT()<=0) continue; // AdC
1659 digitIndexLocal++; // AdC
1661 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1662 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1663 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1664 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1665 digitsInVolumeIndices[digIndex],
1666 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1668 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1669 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1670 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1671 digitInteresting->GetToT()*digitInteresting->GetToT(),
1672 digitsInVolumeIndices[digIndex],
1673 digitInteresting->GetTracks());
1675 if (digitIndexLocal==-1) interestingCounter--; // AdC
1679 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1681 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1682 interestingCounter++;
1683 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1684 digitsInVolumeIndices[ii] = -1;
1685 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1686 digitIndexLocal=-1; // AdC
1687 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1688 if (digitsInVolumeIndices[digIndex]<0) continue;
1689 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1690 if (digitInteresting->GetToT()<=0) continue; // AdC
1691 digitIndexLocal++; // AdC
1693 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1694 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1695 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1696 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1697 digitsInVolumeIndices[digIndex],
1698 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1700 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1701 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1702 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1703 digitInteresting->GetToT()*digitInteresting->GetToT(),
1704 digitsInVolumeIndices[digIndex],
1705 digitInteresting->GetTracks());
1707 if (digitIndexLocal==-1) interestingCounter--; // AdC
1710 AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
1712 for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
1713 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
1714 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
1716 for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
1717 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
1718 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
1720 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime) continue;
1722 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
1723 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
1724 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
1725 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
1726 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
1727 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
1728 Int_t volDum = vol1[3];
1731 fTOFGeometry->GetPosPar(vol1,pos);
1732 interestingX[0] = pos[0];
1733 interestingY[0] = pos[1];
1734 interestingZ[0] = pos[2];
1736 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
1737 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
1738 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
1739 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
1740 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
1741 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
1745 fTOFGeometry->GetPosPar(vol2,pos);
1746 interestingX[1] = pos[0];
1747 interestingY[1] = pos[1];
1748 interestingZ[1] = pos[2];
1750 AverageCalculations(2, interestingX, interestingY, interestingZ,
1751 interestingTOF, interestingTOT, interestingADC,
1753 parTOF, posClus, check);
1755 for (jj=0; jj<5; jj++) det[jj] = -1;
1756 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
1757 fTOFGeometry->GetDetID(posF, det);
1759 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
1760 //volIdClus = GetClusterVolIndex(det);
1762 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1763 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
1764 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
1765 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
1766 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
1768 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1769 Int_t ** indDet = new Int_t*[2];
1770 for (jj=0; jj<2; jj++) indDet[jj] = new Int_t [5];
1771 for (jj=0; jj<2; jj++) indDet[jj][0] = nSector;
1772 for (jj=0; jj<2; jj++) indDet[jj][1] = nPlate;
1773 for (jj=0; jj<2; jj++) indDet[jj][2] = nStrip;
1774 for (jj=0; jj<2; jj++) indDet[jj][3] = padsCluster[2*jj+3];
1775 for (jj=0; jj<2; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
1776 GetClusterPars(/*check,*/ 2, indDet, interestingWeight, posClus, covClus);
1777 for (jj=0; jj<2; jj++) delete [] indDet[jj];
1780 // To fill the track index array
1782 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1783 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1784 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
1787 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
1790 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1791 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
1794 alreadyStored = kFALSE;
1795 for (jj=0; jj<dummyCounter+1; jj++)
1796 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
1798 if (alreadyStored) continue;
1799 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
1800 AliWarning(" Siamo al limite!");
1805 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
1812 AliTOFcluster *tofCluster =
1813 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
1814 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1815 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
1816 InsertCluster(tofCluster);
1818 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",
1819 volIdClus, posClus[0], posClus[1], posClus[2],
1820 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1821 tracks[0], tracks[1], tracks[2],
1822 det[0], det[1], det[2], det[3], det[4],
1823 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
1824 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
1829 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
1833 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
1836 } // close loop on second digit
1837 } // close loop on adesso2
1839 } // close loop on first digit
1840 } // close loop on adesso1
1842 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1843 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1844 selectedDigit[ii][jj] = 0x0;
1848 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++) {
1849 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
1850 delete [] selectedDigit[ii][jj];
1851 selectedDigit[ii][jj] = 0x0;
1853 delete [] selectedDigit[ii];
1854 selectedDigit[ii] = 0x0;
1856 delete [] selectedDigit;
1857 selectedDigit = 0x0;
1860 //_____________________________________________________________________________
1862 void AliTOFClusterFinderV1::FindClusters24(Int_t nSector,
1867 // This function searches the neighbouring digits (stored in the fDigits object),
1868 // to perform clusters (stored in the fTofClusters array).
1870 // This research has been made by checking the fTOFdigitMap object,
1871 // filled at digits/raw-data reading time.
1874 const Int_t kMaxNumberOfInterestingPads = 4;
1875 const Int_t kMaxNumberOfTracksPerDigit = 3;
1876 const Int_t kMaxNumberOfDigitsPerVolume = 10;
1880 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
1881 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1882 digitsInVolumeIndices[ii] = -1;
1884 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
1886 Float_t pos[3] = {0.,0.,0.};
1889 Int_t interestingPadX[kMaxNumberOfInterestingPads];
1890 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
1891 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
1892 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
1893 Double_t interestingTOT[kMaxNumberOfInterestingPads];
1894 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
1895 Double_t interestingADC[kMaxNumberOfInterestingPads];
1896 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
1897 Double_t interestingTOF[kMaxNumberOfInterestingPads];
1898 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
1899 Double_t interestingWeight[kMaxNumberOfInterestingPads];
1900 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
1902 Float_t interestingX[kMaxNumberOfInterestingPads];
1903 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
1904 Float_t interestingY[kMaxNumberOfInterestingPads];
1905 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
1906 Float_t interestingZ[kMaxNumberOfInterestingPads];
1907 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
1909 Float_t interDigit[kMaxNumberOfInterestingPads];
1910 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
1912 Int_t padsCluster[11];
1913 padsCluster[0] = nSector;
1914 padsCluster[1] = nPlate;
1915 padsCluster[2] = nStrip;
1916 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1918 Int_t interestingCounter=-1;
1919 Int_t digitIndexLocal = -1;
1924 Bool_t check = kFALSE;
1926 for (jj=0; jj<7; jj++) parTOF[jj] = 0;
1927 Double_t posClus[3];
1928 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
1930 for (jj=0; jj<5; jj++) det[jj] = -1;
1932 for (jj=0; jj<3; jj++) posF[jj] = 0.;
1933 UShort_t volIdClus = 0;
1934 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
1935 Double_t covClus[6];
1936 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1937 Int_t tracks[kMaxNumberOfTracksPerDigit];
1938 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1939 Int_t dummyCounter=-1;
1940 Bool_t alreadyStored = kFALSE;
1942 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
1943 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1944 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
1946 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1947 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
1949 AliTOFdigit *digitInteresting;
1951 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
1953 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
1954 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
1956 AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
1963 interestingCounter=-1;
1965 vol[4] = iPadZ , vol[3] = iPadX;
1966 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1967 interestingCounter++;
1969 vol[4] = iPadZ, vol[3] = iPadX+1;
1970 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1971 interestingCounter++;
1973 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1974 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1975 interestingCounter++;
1977 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1978 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1979 interestingCounter++;
1981 if (interestingCounter+1!=4) continue; // the hit pads have to be 4
1982 else interestingCounter=-1;
1985 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1986 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1987 selectedDigit[ii][jj] = 0x0;
1990 vol[4] = iPadZ, vol[3] = iPadX;
1992 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1993 interestingCounter++;
1994 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1995 digitsInVolumeIndices[ii] = -1;
1996 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1997 digitIndexLocal=-1; // AdC
1998 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1999 if (digitsInVolumeIndices[digIndex]<0) continue;
2000 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2001 if (digitInteresting->GetToT()<=0) continue; // AdC
2002 digitIndexLocal++; // AdC
2004 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2005 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2006 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2007 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2008 digitsInVolumeIndices[digIndex],
2009 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2011 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2012 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2013 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2014 digitInteresting->GetToT()*digitInteresting->GetToT(),
2015 digitsInVolumeIndices[digIndex],
2016 digitInteresting->GetTracks());
2018 if (digitIndexLocal==-1) interestingCounter--; // AdC
2022 vol[4] = iPadZ, vol[3] = iPadX+1;
2024 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2025 interestingCounter++;
2026 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2027 digitsInVolumeIndices[ii] = -1;
2028 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2029 digitIndexLocal=-1; // AdC
2030 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2031 if (digitsInVolumeIndices[digIndex]<0) continue;
2032 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2033 if (digitInteresting->GetToT()<=0) continue; // AdC
2034 digitIndexLocal++; // AdC
2036 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2037 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2038 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2039 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2040 digitsInVolumeIndices[digIndex],
2041 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2043 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2044 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2045 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2046 digitInteresting->GetToT()*digitInteresting->GetToT(),
2047 digitsInVolumeIndices[digIndex],
2048 digitInteresting->GetTracks());
2050 if (digitIndexLocal==-1) interestingCounter--; // AdC
2054 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
2056 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2057 interestingCounter++;
2058 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2059 digitsInVolumeIndices[ii] = -1;
2060 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2061 digitIndexLocal=-1; // AdC
2062 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2063 if (digitsInVolumeIndices[digIndex]<0) continue;
2064 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2065 if (digitInteresting->GetToT()<=0) continue; // AdC
2066 digitIndexLocal++; // AdC
2068 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2069 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2070 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2071 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2072 digitsInVolumeIndices[digIndex],
2073 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2075 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2076 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2077 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2078 digitInteresting->GetToT()*digitInteresting->GetToT(),
2079 digitsInVolumeIndices[digIndex],
2080 digitInteresting->GetTracks());
2082 if (digitIndexLocal==-1) interestingCounter--; // AdC
2086 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
2088 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2089 interestingCounter++;
2090 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2091 digitsInVolumeIndices[ii] = -1;
2092 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2093 digitIndexLocal=-1; // AdC
2094 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2095 if (digitsInVolumeIndices[digIndex]<0) continue;
2096 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2097 if (digitInteresting->GetToT()<=0) continue; // AdC
2098 digitIndexLocal++; // AdC
2100 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2101 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2102 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2103 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2104 digitsInVolumeIndices[digIndex],
2105 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2107 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2108 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2109 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2110 digitInteresting->GetToT()*digitInteresting->GetToT(),
2111 digitsInVolumeIndices[digIndex],
2112 digitInteresting->GetTracks());
2114 if (digitIndexLocal==-1) interestingCounter--; // AdC
2117 AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
2119 for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
2120 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2121 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2123 for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
2124 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2125 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2127 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime) continue;
2129 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2130 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2131 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2132 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2133 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
2134 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
2135 Int_t volDum = vol1[3];
2138 fTOFGeometry->GetPosPar(vol1,pos);
2139 interestingX[0] = pos[0];
2140 interestingY[0] = pos[1];
2141 interestingZ[0] = pos[2];
2143 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2144 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2145 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2146 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2147 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
2148 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
2152 fTOFGeometry->GetPosPar(vol2,pos);
2153 interestingX[1] = pos[0];
2154 interestingY[1] = pos[1];
2155 interestingZ[1] = pos[2];
2158 AverageCalculations(2, interestingX, interestingY, interestingZ,
2159 interestingTOF, interestingTOT, interestingADC,
2161 parTOF, posClus, check);
2163 for (jj=0; jj<5; jj++) det[jj] = -1;
2164 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
2165 fTOFGeometry->GetDetID(posF, det);
2167 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
2168 //volIdClus = GetClusterVolIndex(det);
2170 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2171 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
2172 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
2173 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
2174 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
2176 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2177 Int_t ** indDet = new Int_t*[2];
2178 for (jj=0; jj<2; jj++) indDet[jj] = new Int_t [5];
2179 for (jj=0; jj<2; jj++) indDet[jj][0] = nSector;
2180 for (jj=0; jj<2; jj++) indDet[jj][1] = nPlate;
2181 for (jj=0; jj<2; jj++) indDet[jj][2] = nStrip;
2182 for (jj=0; jj<2; jj++) indDet[jj][3] = padsCluster[2*jj+3];
2183 for (jj=0; jj<2; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
2184 GetClusterPars(/*check,*/ 2, indDet, interestingWeight, posClus, covClus);
2185 for (jj=0; jj<2; jj++) delete [] indDet[jj];
2188 // To fill the track index array
2190 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2191 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2192 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
2195 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
2198 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2199 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
2202 alreadyStored = kFALSE;
2203 for (jj=0; jj<dummyCounter+1; jj++)
2204 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
2206 if (alreadyStored) continue;
2207 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2208 AliWarning(" Siamo al limite!");
2213 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
2220 AliTOFcluster *tofCluster =
2221 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
2222 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2223 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
2224 InsertCluster(tofCluster);
2226 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",
2227 volIdClus, posClus[0], posClus[1], posClus[2],
2228 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2229 tracks[0], tracks[1], tracks[2],
2230 det[0], det[1], det[2], det[3], det[4],
2231 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
2232 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
2237 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
2241 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
2244 } // close loop on second digit
2245 } // close loop on adesso2
2247 } // close loop on first digit
2248 } // close loop on adesso1
2250 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2251 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
2252 selectedDigit[ii][jj] = 0x0;
2256 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++) {
2257 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
2258 delete [] selectedDigit[ii][jj];
2259 selectedDigit[ii][jj] = 0x0;
2261 delete [] selectedDigit[ii];
2262 selectedDigit[ii] = 0x0;
2264 delete [] selectedDigit;
2265 selectedDigit = 0x0;
2268 //_____________________________________________________________________________
2270 void AliTOFClusterFinderV1::FindClustersPerStrip(Int_t nSector,
2276 // This function searches the neighbouring digits (stored in the fDigits object),
2277 // to perform clusters (stored in the fTofClusters array).
2279 // Each strip is read four times:
2280 // - 1st time: it searches possible clusters formed by four
2281 // neighbouring digits;
2282 // - 2nd time: it searches possible clusters formed by three
2283 // neighbouring digits;
2284 // - 3rd time: it searches possible clusters formed by two
2285 // neighbouring digits;
2286 // - 4th time: the remaining isolated digits have been transformed
2288 // This research has been made by checking the fTOFdigitMap object,
2289 // filled at digits/raw-data reading time.
2292 const Int_t kMaxNumberOfInterestingPads = 4;
2293 const Int_t kMaxNumberOfTracksPerDigit = 3;
2294 const Int_t kMaxNumberOfDigitsPerVolume = 10;
2298 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
2299 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2300 digitsInVolumeIndices[ii] = -1;
2302 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
2304 Float_t pos[3] = {0.,0.,0.};
2307 Int_t interestingPadX[kMaxNumberOfInterestingPads];
2308 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
2309 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
2310 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
2311 Double_t interestingTOT[kMaxNumberOfInterestingPads];
2312 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
2313 Double_t interestingADC[kMaxNumberOfInterestingPads];
2314 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
2315 Double_t interestingTOF[kMaxNumberOfInterestingPads];
2316 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
2317 Double_t interestingWeight[kMaxNumberOfInterestingPads];
2318 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
2320 Float_t interestingX[kMaxNumberOfInterestingPads];
2321 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
2322 Float_t interestingY[kMaxNumberOfInterestingPads];
2323 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
2324 Float_t interestingZ[kMaxNumberOfInterestingPads];
2325 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
2327 Float_t interDigit[kMaxNumberOfInterestingPads];
2328 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
2330 Int_t padsCluster[11];
2331 padsCluster[0] = nSector;
2332 padsCluster[1] = nPlate;
2333 padsCluster[2] = nStrip;
2334 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2336 Int_t interestingCounter=-1;
2337 Int_t digitIndexLocal = -1;
2342 Bool_t check = kFALSE;
2344 for (jj=0; jj<7; jj++) parTOF[jj] = 0;
2345 Double_t posClus[3];
2346 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
2348 for (jj=0; jj<5; jj++) det[jj] = -1;
2350 for (jj=0; jj<3; jj++) posF[jj] = 0.;
2351 UShort_t volIdClus = 0;
2352 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
2353 Double_t covClus[6];
2354 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2355 Int_t tracks[kMaxNumberOfTracksPerDigit];
2356 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2357 Int_t dummyCounter=-1;
2358 Bool_t alreadyStored = kFALSE;
2360 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
2361 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2362 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
2364 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2365 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
2367 AliTOFdigit *digitInteresting;
2371 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
2373 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
2374 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
2376 AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
2383 interestingCounter=-1;
2385 vol[4] = iPadZ , vol[3] = iPadX;
2386 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2387 interestingCounter++;
2389 vol[4] = iPadZ, vol[3] = iPadX+1;
2390 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2391 interestingCounter++;
2393 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
2394 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2395 interestingCounter++;
2397 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
2398 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2399 interestingCounter++;
2401 if (interestingCounter!=group) continue;
2402 else interestingCounter=-1;
2405 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2406 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
2407 selectedDigit[ii][jj] = 0x0;
2410 vol[4] = iPadZ, vol[3] = iPadX;
2412 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2413 interestingCounter++;
2414 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2415 digitsInVolumeIndices[ii] = -1;
2416 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2417 digitIndexLocal=-1; // AdC
2418 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2419 if (digitsInVolumeIndices[digIndex]<0) continue;
2420 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2421 if (digitInteresting->GetToT()<=0) continue; // AdC
2422 digitIndexLocal++; // AdC
2424 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2425 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2426 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2427 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2428 digitsInVolumeIndices[digIndex],
2429 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2430 AliDebug(1,Form(" to try %d %d ",digIndex, interestingCounter));
2432 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2433 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2434 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2435 digitInteresting->GetToT()*digitInteresting->GetToT(),
2436 digitsInVolumeIndices[digIndex],
2437 digitInteresting->GetTracks());
2439 if (digitIndexLocal==-1) interestingCounter--; // AdC
2443 vol[4] = iPadZ, vol[3] = iPadX+1;
2445 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2446 interestingCounter++;
2447 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2448 digitsInVolumeIndices[ii] = -1;
2449 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2450 digitIndexLocal=-1; // AdC
2451 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2452 if (digitsInVolumeIndices[digIndex]<0) continue;
2453 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2454 if (digitInteresting->GetToT()<=0) continue; // AdC
2455 digitIndexLocal++; // AdC
2457 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2458 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2459 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2460 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2461 digitsInVolumeIndices[digIndex],
2462 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2463 AliDebug(1,Form(" to try %d %d ",digIndex, interestingCounter));
2465 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2466 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2467 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2468 digitInteresting->GetToT()*digitInteresting->GetToT(),
2469 digitsInVolumeIndices[digIndex],
2470 digitInteresting->GetTracks());
2472 if (digitIndexLocal==-1) interestingCounter--; // AdC
2476 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
2478 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2479 interestingCounter++;
2480 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2481 digitsInVolumeIndices[ii] = -1;
2482 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2483 digitIndexLocal=-1; // AdC
2484 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2485 if (digitsInVolumeIndices[digIndex]<0) continue;
2486 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2487 if (digitInteresting->GetToT()<=0) continue; // AdC
2488 digitIndexLocal++; // AdC
2490 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2491 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2492 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2493 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2494 digitsInVolumeIndices[digIndex],
2495 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2496 AliDebug(1,Form(" to try %d %d ",digIndex, interestingCounter));
2498 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2499 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2500 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2501 digitInteresting->GetToT()*digitInteresting->GetToT(),
2502 digitsInVolumeIndices[digIndex],
2503 digitInteresting->GetTracks());
2505 if (digitIndexLocal==-1) interestingCounter--; // AdC
2509 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
2511 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2512 interestingCounter++;
2513 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2514 digitsInVolumeIndices[ii] = -1;
2515 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2516 digitIndexLocal=-1; // AdC
2517 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2518 if (digitsInVolumeIndices[digIndex]<0) continue;
2519 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2520 if (digitInteresting->GetToT()<=0) continue; // AdC
2521 digitIndexLocal++; // AdC
2523 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2524 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2525 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2526 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2527 digitsInVolumeIndices[digIndex],
2528 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2529 AliDebug(1,Form(" to try %d %d ",digIndex, interestingCounter));
2531 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2532 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2533 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2534 digitInteresting->GetToT()*digitInteresting->GetToT(),
2535 digitsInVolumeIndices[digIndex],
2536 digitInteresting->GetTracks());
2538 if (digitIndexLocal==-1) interestingCounter--; // AdC
2541 AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
2548 switch(interestingCounter+1) {
2552 //for (adesso1=0; adesso1<interestingCounter+1; adesso1++) {
2554 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2555 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2557 //for (adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
2559 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2560 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2562 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime) {
2563 AliDebug(1,Form(" selD1[%d][%d]->GetTDC()=%d selD2[%d][%d]->GetTDC()=%d -- %d ",
2564 adesso1,firstIndex,(Int_t)selectedDigit[adesso1][firstIndex]->GetTDC(),
2565 adesso2,secondIndex,(Int_t)selectedDigit[adesso2][secondIndex]->GetTDC(),
2570 AliDebug(1, Form(" %1d %1d (0x%p) %1d %1d (0x%p)", adesso1, firstIndex,selectedDigit[adesso1][firstIndex],
2571 adesso2, secondIndex,selectedDigit[adesso2][secondIndex]));
2573 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2574 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2575 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2576 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2577 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
2578 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
2579 Int_t volDum = vol1[3];
2582 fTOFGeometry->GetPosPar(vol1,pos);
2583 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
2584 interestingX[0] = pos[0];
2585 interestingY[0] = pos[1];
2586 interestingZ[0] = pos[2];
2588 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2589 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2590 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2591 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2592 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
2593 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
2597 fTOFGeometry->GetPosPar(vol2,pos);
2598 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
2599 interestingX[1] = pos[0];
2600 interestingY[1] = pos[1];
2601 interestingZ[1] = pos[2];
2604 AverageCalculations(interestingCounter+1,
2605 interestingX, interestingY, interestingZ,
2606 interestingTOF, interestingTOT, interestingADC,
2608 parTOF, posClus, check);
2610 for (jj=0; jj<5; jj++) det[jj] = -1;
2611 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
2613 AliDebug(1,Form(" %f %f %f", posF[0], posF[1], posF[2]));
2614 fTOFGeometry->GetDetID(posF, det);
2615 AliDebug(1,Form(" %2d %1d %2d %1d %2d", det[0], det[1], det[2], det[3], det[4]));
2617 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
2618 //volIdClus = GetClusterVolIndex(det);
2620 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2621 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
2622 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
2623 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
2624 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
2626 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2627 Int_t ** indDet = new Int_t*[interestingCounter+1];
2628 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj] = new Int_t [5];
2629 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][0] = nSector;
2630 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][1] = nPlate;
2631 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][2] = nStrip;
2632 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][3] = padsCluster[2*jj+3];
2633 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
2634 GetClusterPars(/*check,*/ interestingCounter+1, indDet, interestingWeight, posClus, covClus);
2635 for (jj=0; jj<interestingCounter+1; jj++) delete [] indDet[jj];
2638 // To fill the track index array
2640 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2641 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2642 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
2645 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
2648 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2649 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
2652 alreadyStored = kFALSE;
2653 for (jj=0; jj<dummyCounter+1; jj++)
2654 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
2656 if (alreadyStored) continue;
2657 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2658 AliWarning(" Siamo al limite!");
2663 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
2670 AliTOFcluster *tofCluster =
2671 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
2672 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2673 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); //to updated
2674 InsertCluster(tofCluster);
2676 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",
2677 volIdClus, posClus[0], posClus[1], posClus[2],
2678 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2679 tracks[0], tracks[1], tracks[2],
2680 det[0], det[1], det[2], det[3], det[4],
2681 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
2682 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
2687 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
2691 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
2694 } // close loop on second digit
2695 //} // close loop on adesso2
2697 } // close loop on first digit
2698 //} // close loop on adesso1
2705 //for (adesso1=0; adesso1<interestingCounter+1; adesso1++) {
2707 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2708 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2710 //for (adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
2712 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2713 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2715 //for (adesso3=adesso2+1; adesso3<interestingCounter+1; adesso3++) {
2717 for (Int_t thirdIndex=0; thirdIndex<kMaxNumberOfDigitsPerVolume; thirdIndex++) {
2718 if (selectedDigit[adesso3][thirdIndex]==0x0) continue;
2721 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime
2723 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
2725 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime) continue;
2727 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2728 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2729 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2730 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2731 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
2732 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
2733 Int_t volDum = vol1[3];
2736 fTOFGeometry->GetPosPar(vol1,pos);
2737 interestingX[0] = pos[0];
2738 interestingY[0] = pos[1];
2739 interestingZ[0] = pos[2];
2741 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2742 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2743 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2744 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2745 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
2746 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
2750 fTOFGeometry->GetPosPar(vol2,pos);
2751 interestingX[1] = pos[0];
2752 interestingY[1] = pos[1];
2753 interestingZ[1] = pos[2];
2755 interestingTOF[2] = selectedDigit[adesso3][thirdIndex]->GetTDC();
2756 interestingTOT[2] = selectedDigit[adesso3][thirdIndex]->GetTOT();
2757 interestingADC[2] = selectedDigit[adesso3][thirdIndex]->GetADC();
2758 interestingWeight[2] = selectedDigit[adesso3][thirdIndex]->GetWeight();
2759 Int_t vol3[5]; for(jj=0; jj<5; jj++) vol3[jj] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(jj);
2760 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol3[0], vol3[1], vol3[2], vol3[4], vol3[3]));
2764 fTOFGeometry->GetPosPar(vol3,pos);
2765 interestingX[2] = pos[0];
2766 interestingY[2] = pos[1];
2767 interestingZ[2] = pos[2];
2770 AverageCalculations(interestingCounter+1,
2771 interestingX, interestingY, interestingZ,
2772 interestingTOF, interestingTOT, interestingADC,
2774 parTOF, posClus, check);
2776 for (jj=0; jj<5; jj++) det[jj] = -1;
2777 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
2778 fTOFGeometry->GetDetID(posF, det);
2780 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
2781 //volIdClus = GetClusterVolIndex(det);
2783 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2784 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
2785 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
2786 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
2787 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
2788 padsCluster[7] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(4);
2789 padsCluster[8] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(3);
2791 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2792 Int_t ** indDet = new Int_t*[interestingCounter+1];
2793 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj] = new Int_t [5];
2794 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][0] = nSector;
2795 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][1] = nPlate;
2796 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][2] = nStrip;
2797 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][3] = padsCluster[2*jj+3];
2798 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
2799 GetClusterPars(/*check,*/ interestingCounter+1, indDet, interestingWeight, posClus, covClus);
2800 for (jj=0; jj<interestingCounter+1; jj++) delete [] indDet[jj];
2804 // To fill the track index array
2806 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2807 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2808 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
2811 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
2814 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2815 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
2818 alreadyStored = kFALSE;
2819 for (jj=0; jj<dummyCounter+1; jj++)
2820 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
2822 if (alreadyStored) continue;
2823 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2824 AliWarning(" Siamo al limite!");
2829 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
2834 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2835 if (selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk)==-1) continue;
2838 alreadyStored = kFALSE;
2839 for (jj=0; jj<dummyCounter+1; jj++)
2840 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk));
2842 if (alreadyStored) continue;
2843 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2844 AliWarning(" Siamo al limite!");
2849 tracks[dummyCounter] = selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk);
2856 AliTOFcluster *tofCluster =
2857 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
2858 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2859 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
2860 InsertCluster(tofCluster);
2862 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",
2863 volIdClus, posClus[0], posClus[1], posClus[2],
2864 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2865 tracks[0], tracks[1], tracks[2],
2866 det[0], det[1], det[2], det[3], det[4],
2867 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
2868 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
2873 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
2877 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
2881 fTOFdigitMap->ResetDigitNumber(vol3,selectedDigit[adesso3][thirdIndex]->GetIndex());
2884 } // close loop on third digit
2885 //} // close loop on adesso3
2887 } // close loop on second digit
2888 //} // close loop on adesso2
2890 } // close loop on first digit
2891 //} // close loop on adesso1
2899 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2900 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2903 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2904 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2907 for (Int_t thirdIndex=0; thirdIndex<kMaxNumberOfDigitsPerVolume; thirdIndex++) {
2908 if (selectedDigit[adesso3][thirdIndex]==0x0) continue;
2911 for (Int_t fourthIndex=0; fourthIndex<kMaxNumberOfDigitsPerVolume; fourthIndex++) {
2912 if (selectedDigit[adesso4][fourthIndex]==0x0) continue;
2915 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime
2917 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
2919 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso4][fourthIndex]->GetTDC())>fMaxDeltaTime
2921 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
2923 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso4][fourthIndex]->GetTDC())>fMaxDeltaTime
2925 TMath::Abs(selectedDigit[adesso3][thirdIndex]->GetTDC()-selectedDigit[adesso4][fourthIndex]->GetTDC())>fMaxDeltaTime) continue;
2927 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2928 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2929 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2930 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2931 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
2932 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
2933 Int_t volDum = vol1[3];
2936 fTOFGeometry->GetPosPar(vol1,pos);
2937 interestingX[0] = pos[0];
2938 interestingY[0] = pos[1];
2939 interestingZ[0] = pos[2];
2941 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2942 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2943 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2944 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2945 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
2946 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
2950 fTOFGeometry->GetPosPar(vol2,pos);
2951 interestingX[1] = pos[0];
2952 interestingY[1] = pos[1];
2953 interestingZ[1] = pos[2];
2955 interestingTOF[2] = selectedDigit[adesso3][thirdIndex]->GetTDC();
2956 interestingTOT[2] = selectedDigit[adesso3][thirdIndex]->GetTOT();
2957 interestingADC[2] = selectedDigit[adesso3][thirdIndex]->GetADC();
2958 interestingWeight[2] = selectedDigit[adesso3][thirdIndex]->GetWeight();
2959 Int_t vol3[5]; for(jj=0; jj<5; jj++) vol3[jj] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(jj);
2960 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol3[0], vol3[1], vol3[2], vol3[4], vol3[3]));
2964 fTOFGeometry->GetPosPar(vol3,pos);
2965 interestingX[2] = pos[0];
2966 interestingY[2] = pos[1];
2967 interestingZ[2] = pos[2];
2969 interestingTOF[3] = selectedDigit[adesso4][fourthIndex]->GetTDC();
2970 interestingTOT[3] = selectedDigit[adesso4][fourthIndex]->GetTOT();
2971 interestingADC[3] = selectedDigit[adesso4][fourthIndex]->GetADC();
2972 interestingWeight[3] = selectedDigit[adesso4][fourthIndex]->GetWeight();
2973 Int_t vol4[5]; for(jj=0; jj<5; jj++) vol4[jj] = selectedDigit[adesso4][fourthIndex]->GetDetectorIndex(jj);
2974 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol4[0], vol4[1], vol4[2], vol4[4], vol4[3]));
2978 fTOFGeometry->GetPosPar(vol4,pos);
2979 interestingX[3] = pos[0];
2980 interestingY[3] = pos[1];
2981 interestingZ[3] = pos[2];
2984 AverageCalculations(interestingCounter+1,
2985 interestingX, interestingY, interestingZ,
2986 interestingTOF, interestingTOT, interestingADC,
2988 parTOF, posClus, check);
2990 for (jj=0; jj<5; jj++) det[jj] = -1;
2991 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
2992 fTOFGeometry->GetDetID(posF, det);
2994 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
2995 //volIdClus = GetClusterVolIndex(det);
2997 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2998 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
2999 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
3000 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
3001 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
3002 padsCluster[7] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(4);
3003 padsCluster[8] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(3);
3004 padsCluster[9] = selectedDigit[adesso4][fourthIndex]->GetDetectorIndex(4);
3005 padsCluster[10] = selectedDigit[adesso4][fourthIndex]->GetDetectorIndex(3);
3007 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
3008 Int_t ** indDet = new Int_t*[interestingCounter+1];
3009 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj] = new Int_t [5];
3010 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][0] = nSector;
3011 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][1] = nPlate;
3012 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][2] = nStrip;
3013 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][3] = padsCluster[2*jj+3];
3014 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
3015 GetClusterPars(/*check,*/ interestingCounter+1, indDet, interestingWeight, posClus, covClus);
3016 for (jj=0; jj<interestingCounter+1; jj++) delete [] indDet[jj];
3019 // To fill the track index array
3021 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
3022 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
3023 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
3026 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
3029 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
3030 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
3033 alreadyStored = kFALSE;
3034 for (jj=0; jj<dummyCounter+1; jj++)
3035 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
3037 if (alreadyStored) continue;
3038 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
3039 AliWarning(" Siamo al limite!");
3044 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
3049 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
3050 if (selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk)==-1) continue;
3053 alreadyStored = kFALSE;
3054 for (jj=0; jj<dummyCounter+1; jj++)
3055 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk));
3057 if (alreadyStored) continue;
3058 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
3059 AliWarning(" Siamo al limite!");
3064 tracks[dummyCounter] = selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk);
3069 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
3070 if (selectedDigit[adesso4][fourthIndex]->GetTrackLabel(kk)==-1) continue;
3073 alreadyStored = kFALSE;
3074 for (jj=0; jj<dummyCounter+1; jj++)
3075 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso4][fourthIndex]->GetTrackLabel(kk));
3077 if (alreadyStored) continue;
3078 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
3079 AliWarning(" Siamo al limite!");
3084 tracks[dummyCounter] = selectedDigit[adesso4][fourthIndex]->GetTrackLabel(kk);
3091 AliTOFcluster *tofCluster =
3092 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
3093 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
3094 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
3095 InsertCluster(tofCluster);
3097 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",
3098 volIdClus, posClus[0], posClus[1], posClus[2],
3099 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
3100 tracks[0], tracks[1], tracks[2],
3101 det[0], det[1], det[2], det[3], det[4],
3102 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
3103 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
3108 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
3112 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
3116 fTOFdigitMap->ResetDigitNumber(vol3,selectedDigit[adesso3][thirdIndex]->GetIndex());
3120 fTOFdigitMap->ResetDigitNumber(vol4,selectedDigit[adesso4][fourthIndex]->GetIndex());
3123 } // close loop on fourth digit
3125 } // close loop on third digit
3127 } // close loop on second digit
3129 } // close loop on first digit
3135 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
3136 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
3137 selectedDigit[ii][jj] = 0x0;
3141 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++) {
3142 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
3143 delete [] selectedDigit[ii][jj];
3144 selectedDigit[ii][jj] = 0x0;
3146 delete [] selectedDigit[ii];
3147 selectedDigit[ii] = 0x0;
3149 delete [] selectedDigit;
3150 selectedDigit = 0x0;
3153 //_____________________________________________________________________________
3155 Int_t AliTOFClusterFinderV1::InsertCluster(AliTOFcluster *tofCluster)
3158 // This function adds a TOF cluster to the array of TOF clusters
3159 // sorted in Z, i.e. fTofClusters
3162 if (fNumberOfTofClusters==kTofMaxCluster) {
3163 AliError("Too many clusters !");
3167 if (fNumberOfTofClusters==0) {
3168 fTofClusters[fNumberOfTofClusters++] = tofCluster;
3172 Int_t ii = FindClusterIndex(tofCluster->GetZ());
3173 memmove(fTofClusters+ii+1 ,fTofClusters+ii,(fNumberOfTofClusters-ii)*sizeof(AliTOFcluster*));
3174 fTofClusters[ii] = tofCluster;
3175 fNumberOfTofClusters++;
3180 //_____________________________________________________________________________
3182 Int_t AliTOFClusterFinderV1::FindClusterIndex(Double_t z) const
3185 // This function returns the index of the nearest cluster in z
3188 if (fNumberOfTofClusters==0) return 0;
3189 if (z <= fTofClusters[0]->GetZ()) return 0;
3190 if (z > fTofClusters[fNumberOfTofClusters-1]->GetZ()) return fNumberOfTofClusters;
3191 Int_t b = 0, e = fNumberOfTofClusters-1, m = (b+e)/2;
3192 for (; b<e; m=(b+e)/2) {
3193 if (z > fTofClusters[m]->GetZ()) b=m+1;
3200 //_____________________________________________________________________________
3202 void AliTOFClusterFinderV1::ResetRecpoint()
3205 // Clear the list of reconstructed points
3208 fNumberOfTofClusters = 0;
3209 if (fRecPoints) fRecPoints->Clear();
3212 //_____________________________________________________________________________
3214 void AliTOFClusterFinderV1::ResetDigits()
3217 // Clear the list of digits
3220 fNumberOfTofDigits = 0;
3221 if (fDigits) fDigits->Clear();
3224 //_____________________________________________________________________________
3225 //UShort_t AliTOFClusterFinderV1::GetClusterVolIndex(Int_t *ind) const
3228 // Get the volume ID to retrieve the l2t transformation
3231 // Detector numbering scheme
3233 Int_t nSector = AliTOFGeometry::NSectors();
3234 Int_t nPlate = AliTOFGeometry::NPlates();
3235 Int_t nStripA = AliTOFGeometry::NStripA();
3236 Int_t nStripB = AliTOFGeometry::NStripB();
3237 Int_t nStripC = AliTOFGeometry::NStripC();
3239 Int_t isector =ind[0];
3240 if (isector >= nSector)
3241 AliError(Form("Wrong sector number in TOF (%d) !", isector));
3242 Int_t iplate = ind[1];
3243 if (iplate >= nPlate)
3244 AliError(Form("Wrong plate number in TOF (%d) !", iplate));
3245 Int_t istrip = ind[2];
3247 Int_t stripOffset = 0;
3253 stripOffset = nStripC;
3256 stripOffset = nStripC+nStripB;
3259 stripOffset = nStripC+nStripB+nStripA;
3262 stripOffset = nStripC+nStripB+nStripA+nStripB;
3265 AliError(Form("Wrong plate number in TOF (%d) !", iplate));
3269 Int_t index= (2*(nStripC+nStripB)+nStripA)*isector +
3273 UShort_t volIndex = AliGeomManager::LayerToVolUID(AliGeomManager::kTOF, index);
3278 //_____________________________________________________________________________
3280 void AliTOFClusterFinderV1::GetClusterPars(Int_t *ind, Double_t* pos, Double_t* cov) const
3283 // Starting from the volume indices (ind[5]), for a cluster coming from
3284 // a isolated digits, this function returns:
3285 // the cluster position (pos),
3286 // the cluster covariance matrix elements (cov)
3290 //we now go in the system of the strip: determine the local coordinates
3293 // 47---------------------------------------------------0 ^ z
3294 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 1 |
3295 // ----------------------------------------------------- | y going outwards
3296 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 0 | par[0]=0;
3298 // ----------------------------------------------------- |
3299 // x <-----------------------------------------------------
3301 //move to the tracking ref system
3302 Double_t lpos[3] = { (ind[4]-23.5)*AliTOFGeometry::XPad(),
3304 (ind[3]- 0.5)*AliTOFGeometry::ZPad() };
3305 AliDebug(1, Form(" %f %f %f", lpos[0], lpos[1], lpos[2]));
3308 UShort_t volIndex = fTOFGeometry->GetAliSensVolIndex(ind[0],ind[1],ind[2]);
3309 //UShort_t volIndex = GetClusterVolIndex(ind);
3310 const TGeoHMatrix *l2t = AliGeomManager::GetTracking2LocalMatrix(volIndex);
3312 // Get the position in the track ref system
3314 l2t->MasterToLocal(lpos,tpos);
3319 //Get the cluster covariance in the track ref system
3321 for (Int_t ii=0; ii<9; ii++) lcov[ii] = 0.;
3323 //cluster covariance in the local system:
3328 lcov[4] = 0.42*0.42/3.;
3329 // = ( 5*0.025 (gas gaps thikness)
3330 // + 4*0.040 (internal glasses thickness)
3331 // + 0.5*0.160 (internl PCB)
3332 // + 1*0.055 (external red glass))
3335 lcov[0] = 0.499678;//AliTOFGeometry::XPad()*AliTOFGeometry::XPad()/12.;
3336 lcov[8] = 0.992429;//AliTOFGeometry::ZPad()*AliTOFGeometry::ZPad()/12.;
3338 //cluster covariance in the tracking system:
3340 m.SetRotation(lcov);
3342 m.MultiplyLeft(&l2t->Inverse());
3343 Double_t *tcov = m.GetRotationMatrix();
3344 cov[0] = tcov[0]; cov[1] = tcov[1]; cov[2] = tcov[2];
3345 cov[3] = tcov[4]; cov[4] = tcov[5]; cov[5] = tcov[8];
3350 //_____________________________________________________________________________
3352 void AliTOFClusterFinderV1::GetClusterPars(/*Bool_t check,*/ Int_t counter,
3353 Int_t **ind, Double_t *weight,
3354 Double_t *pos, Double_t *cov) const
3358 // the volumes indices (ind[counter][5]), for a
3359 // cluster coming from a collection of 'counter'
3361 // the volumes weights (weight[counter]), -controlled
3362 // by the 'check' variable control-, for a cluster
3363 // coming from a collection of 'counter' digits,
3364 // the cluster position (pos),
3365 // this function returns:
3366 // the covariance matrix elements (cov) for the found cluster
3370 // we now go in the system of the strip: determine the local coordinates
3372 // 47---------------------------------------------------0 ^ z
3373 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 1 |
3374 // ----------------------------------------------------- | y going outwards
3375 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 0 | par[0]=0;
3377 // ----------------------------------------------------- |
3378 // x <-----------------------------------------------------
3380 for (Int_t ii=0; ii<counter; ii++)
3381 AliDebug(1, Form(" %2d %2d %1d %2d %1d %2d ",
3382 ii, ind[ii][0], ind[ii][1], ind[ii][2], ind[ii][3], ind[ii][4]));
3384 Float_t posF[3]; for (Int_t ii=0; ii<3; ii++) posF[ii] = (Float_t)pos[ii];
3385 AliDebug(1, Form(" %f %f %f", pos[0], pos[1], pos[2]));
3387 Int_t detClus[5] = {-1, -1, -1, -1, -1};
3388 fTOFGeometry->GetDetID(posF, detClus);
3391 UShort_t volIndex = fTOFGeometry->GetAliSensVolIndex(detClus[0],detClus[1],detClus[2]);
3392 //UShort_t volIndex = GetClusterVolIndex(detClus);
3393 AliDebug(1, Form(" %2d %1d %2d %1d %2d %7i",
3394 detClus[0], detClus[1], detClus[2], detClus[3], detClus[4], volIndex));
3396 // Get the position in the TOF strip ref system
3397 const TGeoHMatrix *alice2strip = AliGeomManager::GetOrigGlobalMatrix(volIndex);
3398 Double_t ppos[3] = {-1, -1, -1};
3399 alice2strip->MasterToLocal(pos,ppos);
3400 AliDebug(1, Form(" %f %f %f", ppos[0], ppos[1], ppos[2]));
3403 // Get the position in the tracking ref system
3404 const TGeoHMatrix *g2l = AliGeomManager::GetTracking2LocalMatrix(volIndex);
3405 Double_t lpos[3] = {-1, -1, -1};
3406 g2l->MasterToLocal(ppos,lpos);
3407 AliDebug(1, Form(" %f %f %f", lpos[0], lpos[1], lpos[2]));
3408 for (Int_t ii=0; ii<3; ii++) pos[ii] = lpos[ii];
3410 //Get the cluster covariance in the track ref system
3412 for (Int_t ii=0; ii<9; ii++) lcov[ii] = 0.;
3414 //cluster covariance in the local system:
3419 // Evaluation of the ovariance matrix elements
3420 TOFclusterError(/*check,*/ counter, ind, weight, ppos, lcov);
3422 AliDebug(1, Form("lcov[0] = %f, lcov[8] = %f", lcov[0], lcov[8]));
3424 //cluster covariance in the tracking system:
3426 m.SetRotation(lcov);
3428 m.MultiplyLeft(&g2l->Inverse());
3429 Double_t *tcov = m.GetRotationMatrix();
3430 cov[0] = tcov[0]; cov[1] = tcov[1]; cov[2] = tcov[2];
3431 cov[3] = tcov[4]; cov[4] = tcov[5]; cov[5] = tcov[8];
3436 //_____________________________________________________________________________
3438 void AliTOFClusterFinderV1::TOFclusterError(/*Bool_t check,*/ Int_t counter,
3439 Int_t **ind, Double_t *weight,
3440 Double_t ppos[], Double_t lcov[]) const
3446 //lcov[4] = 0.42*0.42/3.; // cm2
3447 // = ( 5*0.025 (gas gaps thikness)
3448 // + 4*0.040 (internal glasses thickness)
3449 // + 0.5*0.160 (internl PCB)
3450 // + 1*0.055 (external red glass))
3453 Float_t *delta2X = new Float_t[counter];
3454 for (Int_t ii=0; ii<counter; ii++)
3456 ((ind[ii][4]-23.5)*AliTOFGeometry::XPad() - ppos[0])*((ind[ii][4]-23.5)*AliTOFGeometry::XPad() - ppos[0]);
3458 Float_t *delta2Z = new Float_t[counter];
3459 for (Int_t ii=0; ii<counter; ii++)
3461 ((ind[ii][3]- 0.5)*AliTOFGeometry::ZPad() - ppos[2])*((ind[ii][3]- 0.5)*AliTOFGeometry::ZPad() - ppos[2]);
3463 for (Int_t ii=0; ii<counter; ii++)
3464 AliDebug(1, Form("x[%d] = %f, z[%d] = %f, weight[%d] = %f",
3465 ii, (ind[ii][4]-23.5)*AliTOFGeometry::XPad(),
3466 ii, (ind[ii][3]- 0.5)*AliTOFGeometry::ZPad(),
3469 AliDebug(1, Form("xMean = %f, zMean = %f",ppos[0], ppos[2]));
3477 if (ind[0][3]==ind[1][3] && TMath::Abs(ind[0][4]-ind[1][4])==1) { //
3479 lcov[8] = 1.02039; // cm2
3480 lcov[0] = 0.0379409; // cm2
3483 lcov[0] = 0.5*0.5; // cm2
3485 if (weight[0]==weight[1])
3486 lcov[0] = 0.0379409; // cm2
3488 lcov[0] = TMath::Mean(counter, delta2X, weight); // cm2
3494 else if (ind[0][4]==ind[1][4] && TMath::Abs(ind[0][3]-ind[1][3])==1) {//
3496 lcov[0] = 0.505499; // cm2
3497 lcov[8] = 0.0422046; // cm2
3500 lcov[8] = 0.5*0.5; // cm2
3502 if (weight[0]==weight[1])
3503 lcov[8] = 0.0422046; // cm2
3505 lcov[8] = TMath::Mean(counter, delta2Z, weight); // cm2
3514 lcov[0] = 0.0290677; // cm2
3515 lcov[8] = 0.0569726; // cm2
3518 lcov[0] = 0.5*0.5; // cm2
3519 lcov[8] = 0.5*0.5; // cm2
3522 if (weight[0]==weight[1] && weight[0]==weight[2]) {
3523 lcov[0] = 0.0290677; // cm2
3524 lcov[8] = 0.0569726; // cm2
3527 lcov[0] = TMath::Mean(counter, delta2X, weight); // cm2
3528 lcov[8] = TMath::Mean(counter, delta2Z, weight); // cm2
3537 lcov[0] = 0.0223807; // cm2
3538 lcov[8] = 0.0438662; // cm2
3541 lcov[0] = 0.5*0.5; // cm2
3542 lcov[8] = 0.5*0.5; // cm2
3545 if (weight[0]==weight[1] && weight[0]==weight[2] && weight[0]==weight[3]) {
3546 lcov[0] = 0.0223807; // cm2
3547 lcov[8] = 0.0438662; // cm2
3550 lcov[0] = TMath::Mean(counter, delta2X, weight); // cm2
3551 lcov[8] = TMath::Mean(counter, delta2Z, weight); // cm2
3565 //_____________________________________________________________________________
3567 Bool_t AliTOFClusterFinderV1::MakeSlewingCorrection(Int_t *detectorIndex,
3573 // This funtion makes the following:
3575 // - if at least one of the three status (Pulser/Noise/HW) is
3576 // bad, is sets the status of electronic channel, corresponding to the
3577 // volume identified by detectorIndex, as kFALSE;
3578 // - if offline calibration is in the valid status, it performs the
3579 // slewing correction. In particular, by taking into account:
3580 // * the measured tot and tof values (tofDigitToT and tofDigitTdc,
3582 // * the six parameters of 5th order polynomial used
3583 // to fit the tofVStot scatter plot,
3584 // it returns the corrected tof value, i.e. tdcCorr value.
3587 Bool_t output = kTRUE;
3592 //AliInfo(" Calibrating TOF Digits: ");
3594 AliTOFChannelOnlineArray *calDelay = fTOFcalib->GetTOFOnlineDelay();
3595 AliTOFChannelOnlineStatusArray *calStatus = fTOFcalib->GetTOFOnlineStatus();
3597 TObjArray *calTOFArrayOffline = fTOFcalib->GetTOFCalArrayOffline();
3599 Int_t index = AliTOFGeometry::GetIndex(detectorIndex);
3601 UChar_t statusPulser = calStatus->GetPulserStatus(index);
3602 UChar_t statusNoise = calStatus->GetNoiseStatus(index);
3603 UChar_t statusHW = calStatus->GetHWStatus(index);
3604 UChar_t status = calStatus->GetStatus(index);
3606 //check the status, also unknown is fine!!!!!!!
3608 AliDebug(2, Form(" Status for channel %d = %d",index, (Int_t)status));
3609 if((statusPulser & AliTOFChannelOnlineStatusArray::kTOFPulserBad)==(AliTOFChannelOnlineStatusArray::kTOFPulserBad)||(statusNoise & AliTOFChannelOnlineStatusArray::kTOFNoiseBad)==(AliTOFChannelOnlineStatusArray::kTOFNoiseBad)||(statusHW & AliTOFChannelOnlineStatusArray::kTOFHWBad)==(AliTOFChannelOnlineStatusArray::kTOFHWBad)){
3610 AliDebug(2, Form(" Bad Status for channel %d",index));
3611 //fTofClusters[ii]->SetStatus(kFALSE); //odd convention, to avoid conflict with calibration objects currently in the db (temporary solution).
3615 AliDebug(2, Form(" Good Status for channel %d",index));
3618 if (fCalibrateTOFtimes) { // AdC
3620 // Get Rough channel online equalization
3621 Double_t roughDelay = (Double_t)calDelay->GetDelay(index); // in ns
3622 AliDebug(2,Form(" channel delay (ns) = %f", roughDelay));
3623 // Get Refined channel offline calibration parameters
3624 TString validity = (TString)fTOFcalib->GetOfflineValidity();
3625 if (validity.CompareTo("valid")==0) {
3626 AliTOFChannelOffline * calChannelOffline = (AliTOFChannelOffline*)calTOFArrayOffline->At(index);
3628 for (jj = 0; jj<6; jj++)
3629 par[jj] = (Double_t)calChannelOffline->GetSlewPar(jj);
3631 AliDebug(2,Form(" Calib Pars = %f, %f, %f, %f, %f, %f ",par[0],par[1],par[2],par[3],par[4],par[5]));
3632 AliDebug(2,Form(" The ToT and Time, uncorr (counts) = %d , %d", tofDigitToT, tofDigitTdc));
3633 Double_t tToT = (Double_t)(tofDigitToT*AliTOFGeometry::ToTBinWidth());
3634 tToT*=1.E-3; //ToT in ns
3635 AliDebug(2,Form(" The ToT and Time, uncorr (ns)= %e, %e",tofDigitTdc*AliTOFGeometry::TdcBinWidth()*1.E-3,tToT));
3636 timeCorr = par[0] + tToT*(par[1] + tToT*(par[2] + tToT*(par[3] + tToT*(par[4] + tToT*par[5])))); // the time correction (ns)
3639 timeCorr = roughDelay; // correction in ns
3641 AliDebug(2,Form(" The ToT and Time, uncorr (ns)= %e, %e",tofDigitTdc*AliTOFGeometry::TdcBinWidth()*1.E-3,tofDigitToT*AliTOFGeometry::ToTBinWidth()));
3642 AliDebug(2,Form(" The time correction (ns) = %f", timeCorr));
3643 timeCorr = (Double_t)(tofDigitTdc)*AliTOFGeometry::TdcBinWidth()*1.E-3-timeCorr;//redefine the time
3645 AliDebug(2,Form(" The channel time, corr (ps)= %e",timeCorr ));
3646 //tdcCorr = (Int_t)(timeCorr/AliTOFGeometry::TdcBinWidth()); //the corrected time (tdc counts)
3647 tdcCorr = TMath::Nint(timeCorr/AliTOFGeometry::TdcBinWidth()); //the corrected time (tdc counts)
3654 //______________________________________________________________________________
3656 void AliTOFClusterFinderV1::Digits2RecPoints(Int_t iEvent)
3659 // Converts digits to recpoints for TOF
3662 TStopwatch stopwatch;
3665 fRunLoader->GetEvent(iEvent);
3667 AliLoader *localTOFLoader = (AliLoader*)fRunLoader->GetLoader("TOFLoader");
3669 TTree * localTreeD = (TTree*)localTOFLoader->TreeD();
3670 if (localTreeD == 0x0) {
3671 AliFatal("Can not get TreeD");
3675 TBranch *branch = localTreeD->GetBranch("TOF");
3677 AliError("Can't get the branch with the TOF digits !");
3681 TTree *localTreeR = (TTree*)localTOFLoader->TreeR();
3682 if (localTreeR == 0x0)
3684 localTOFLoader->MakeTree("R");
3685 localTreeR = localTOFLoader->TreeR();
3688 Digits2RecPoints(localTreeD, localTreeR);
3690 //localTOFLoader = fRunLoader->GetLoader("TOFLoader");
3691 localTOFLoader->WriteRecPoints("OVERWRITE");
3693 AliDebug(1, Form("Execution time to read TOF digits and to write TOF clusters for the event number %d: R:%.4fs C:%.4fs",
3694 iEvent, stopwatch.RealTime(),stopwatch.CpuTime()));
3697 //______________________________________________________________________________
3699 void AliTOFClusterFinderV1::Digits2RecPoints(Int_t iEvent, AliRawReader *rawReader)
3702 // Converts RAW data to recpoints for TOF
3705 TStopwatch stopwatch;
3708 fRunLoader->GetEvent(iEvent);
3710 AliDebug(2,Form(" Event number %2d ", iEvent));
3712 AliLoader *localTOFLoader = (AliLoader*)fRunLoader->GetLoader("TOFLoader");
3714 TTree *localTreeR = localTOFLoader->TreeR();
3716 if (localTreeR == 0x0){
3717 localTOFLoader->MakeTree("R");
3718 localTreeR = localTOFLoader->TreeR();
3721 Digits2RecPoints(rawReader, localTreeR);
3723 AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters for the event number %d: R:%.4fs C:%.4fs",
3724 iEvent, stopwatch.RealTime(),stopwatch.CpuTime()));
3727 //______________________________________________________________________________
3729 void AliTOFClusterFinderV1::Raw2Digits(Int_t iEvent, AliRawReader *rawReader)
3732 // Converts RAW data to MC digits for TOF
3736 TStopwatch stopwatch;
3739 fRunLoader->GetEvent(iEvent);
3741 AliDebug(2,Form(" Event number %2d ", iEvent));
3743 AliLoader *localTOFLoader = (AliLoader*)fRunLoader->GetLoader("TOFLoader");
3745 TTree *localTreeD = localTOFLoader->TreeD();
3747 if (localTreeD == 0x0){
3748 localTOFLoader->MakeTree("D");
3749 localTreeD = localTOFLoader->TreeD();
3752 Raw2Digits(rawReader, localTreeD);
3754 AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters for the event number %d: R:%.4fs C:%.4fs",
3755 iEvent, stopwatch.RealTime(),stopwatch.CpuTime()));
3758 //______________________________________________________________________________
3760 void AliTOFClusterFinderV1::AverageCalculations(Int_t number, Float_t *interestingX,
3761 Float_t *interestingY, Float_t *interestingZ,
3762 Double_t *interestingTOF, Double_t *interestingTOT,
3763 Double_t *interestingADC, Double_t *interestingWeight,
3764 Int_t *parTOF, Double_t *posClus, Bool_t &check)
3767 // Calculates the mean values for cluster position (x,y,z),
3768 // TOF charge and time
3771 Double_t tofAverage = 0.;
3772 Double_t totAverage = 0.;
3773 Double_t adcAverage = 0.;
3777 for (ii=number-1; ii>=0; ii--) check=check||(interestingWeight[ii]==0 || interestingWeight[ii]==-1);
3781 posClus[0] = TMath::Mean(number, interestingX);
3782 posClus[1] = TMath::Mean(number, interestingY);
3783 posClus[2] = TMath::Mean(number, interestingZ);
3784 tofAverage = TMath::Mean(number, interestingTOF);
3785 totAverage = TMath::Mean(number, interestingTOT);
3786 adcAverage = TMath::Mean(number, interestingADC);
3791 posClus[0] = TMath::Mean(number, interestingX, interestingWeight);
3792 posClus[1] = TMath::Mean(number, interestingY, interestingWeight);
3793 posClus[2] = TMath::Mean(number, interestingZ, interestingWeight);
3794 tofAverage = TMath::Mean(number, interestingTOF, interestingWeight);
3795 totAverage = TMath::Mean(number, interestingTOT, interestingWeight);
3796 adcAverage = TMath::Mean(number, interestingADC, interestingWeight);
3800 parTOF[0] = Int_t(tofAverage);
3801 parTOF[1] = Int_t(totAverage);
3802 parTOF[2] = Int_t(adcAverage);
3803 parTOF[3] = Int_t(tofAverage);//tofND
3804 parTOF[4] = Int_t(tofAverage);//tofRAW