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 if (fNumberOfTofClusters) {
231 for (Int_t ii=0; ii<fNumberOfTofClusters; ii++)
232 if (fTofClusters[ii]) fTofClusters[ii]->Delete();
233 fNumberOfTofClusters = 0;
237 //_____________________________________________________________________________
239 void AliTOFClusterFinderV1::Digits2RecPoints(TTree* digitsTree, TTree* clusterTree)
242 // Converts digits to recPoints for TOF
245 TStopwatch stopwatch;
251 TClonesArray &aDigits = *fDigits;
253 if (digitsTree == 0x0) {
254 AliFatal("Can not get TreeD for TOF");
258 TBranch *branch = digitsTree->GetBranch("TOF");
260 AliError("Can not get branch with the TOF digits !");
264 TClonesArray staticDigits("AliTOFdigit",10000);
265 staticDigits.Clear();
266 TClonesArray *digits = &staticDigits;
267 branch->SetAddress(&digits);
268 digitsTree->GetEvent(0);
269 AliDebug(1,Form("Number of TOF digits: %d", digits->GetEntriesFast()));
271 AliTOFdigit *tofDigit;
274 Int_t detectorIndex[5];
275 for (jj=0; jj<5; jj++) detectorIndex[jj] = -1;
277 for (jj=0; jj<4; jj++) info[jj] = -1;
283 Bool_t status = kTRUE;
285 AliDebug(1," Calibrating TOF Digits");
287 TString validity = (TString)fTOFcalib->GetOfflineValidity();
288 if (validity.CompareTo("valid")==0) {
289 AliInfo(Form(" validity = %s - Using offline calibration parameters", validity.Data()));
291 AliInfo(Form(" validity = %s - Using online calibration parameters", validity.Data()));
295 for (ii=0; ii<digits->GetEntriesFast(); ii++) {
296 tofDigit = (AliTOFdigit*)digits->UncheckedAt(ii);
297 detectorIndex[0] = tofDigit->GetSector();
298 detectorIndex[1] = tofDigit->GetPlate();
299 detectorIndex[2] = tofDigit->GetStrip();
300 detectorIndex[3] = tofDigit->GetPadz();
301 detectorIndex[4] = tofDigit->GetPadx();
303 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
304 if (detectorIndex[1]==2) { // plate with holes
310 tdcCorr = tofDigit->GetTdc();
311 status = MakeSlewingCorrection(detectorIndex, tofDigit->GetToT(), tofDigit->GetTdc(), tdcCorr);
313 for (jj=0; jj<4; jj++) info[jj] = -1;
314 info[0] = tdcCorr;//tofDigit->GetTdc();
315 info[1] = tofDigit->GetAdc();
316 info[2] = tofDigit->GetToT();
317 info[3] = tofDigit->GetTdcND();//tofDigit->GetTdc();//
318 tracks = tofDigit->GetTracks();
320 dummy = detectorIndex[3];
321 detectorIndex[3] = detectorIndex[4];//padx
322 detectorIndex[4] = dummy;//padz
323 last = fDigits->GetEntriesFast();
324 new (aDigits[last]) AliTOFdigit(tracks, detectorIndex, info);
325 if (status) fTOFdigitMap->AddDigit(detectorIndex, last);
327 AliDebug(2, Form(" Digits reading %2d -> %2d %1d %2d %1d %2d (%d, %d, %d)",
329 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[3], detectorIndex[4],
330 info[0], info[1], info[3]));
334 fNumberOfTofDigits = fDigits->GetEntriesFast();
338 Int_t bufsize = 32000;
339 clusterTree->Branch("TOF", &fRecPoints, bufsize);
344 AliDebug(1,Form("Number of found clusters: %d", fNumberOfTofClusters));
348 fTOFdigitMap->Clear();
352 AliDebug(1,Form("Execution time to read TOF digits and to write TOF clusters : R:%.4fs C:%.4fs",
353 stopwatch.RealTime(),stopwatch.CpuTime()));
355 if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
358 //_____________________________________________________________________________
360 void AliTOFClusterFinderV1::Digits2RecPoints(AliRawReader *rawReader, TTree *clustersTree)
363 // Converts raw data to recPoints for TOF
366 TStopwatch stopwatch;
370 AliDebug(2, "TreeD re-creation");
371 //TTree *digitsTree = new TTree();
372 //Raw2Digits(rawReader, digitsTree);
374 Raw2Digits(rawReader, fTOFdigits);
376 AliDebug(1,Form("Number of TOF digits: %d", fNumberOfTofDigits));
379 Int_t bufsize = 32000;
380 clustersTree->Branch("TOF", &fRecPoints, bufsize);
383 clustersTree->Fill();
385 AliDebug(1,Form("Number of found clusters: %d", fNumberOfTofClusters));
389 fTOFdigitMap->Clear();
393 AliDebug(1,Form("Execution time to read TOF raw data and to write TOF clusters : R:%.4fs C:%.4fs",
394 stopwatch.RealTime(),stopwatch.CpuTime()));
398 //_____________________________________________________________________________
400 void AliTOFClusterFinderV1::Raw2Digits(AliRawReader *rawReader, TTree* digitsTree)
403 // Converts raw data to digits for TOF
406 TStopwatch stopwatch;
411 const Int_t kMaxNumberOfTracksPerDigit = 3;
412 const Int_t kDDL = AliDAQ::NumberOfDdls("TOF");
414 digitsTree->Branch("TOF", &fDigits);
415 TClonesArray &aDigits = *fDigits;
417 fTOFRawStream.Clear();
418 fTOFRawStream.SetRawReader(rawReader);
421 if (fVerbose==2) ftxt.open("TOFdigitsRead.txt",ios::app);
423 TClonesArray staticRawData("AliTOFrawData",10000);
424 staticRawData.Clear();
425 TClonesArray * clonesRawData = &staticRawData;
428 Int_t detectorIndex[5] = {-1, -1, -1, -1, -1};
430 Int_t tracks[kMaxNumberOfTracksPerDigit];
431 for (Int_t ii=0; ii<kMaxNumberOfTracksPerDigit; ii++)
436 Bool_t status = kTRUE;
439 TString validity = (TString)fTOFcalib->GetOfflineValidity();
440 if (validity.CompareTo("valid")==0) {
441 AliInfo(Form(" validity = %s - Using offline calibration parameters", validity.Data()));
443 AliInfo(Form(" validity = %s - Using online calibration parameters", validity.Data()));
447 AliInfo("Using New Decoder");
451 for (indexDDL=0; indexDDL<kDDL; indexDDL++) {
455 fTOFRawStream.LoadRawDataBuffers(indexDDL,fVerbose);
456 else fTOFRawStream.LoadRawData(indexDDL);
458 clonesRawData = (TClonesArray*)fTOFRawStream.GetRawData();
459 if (clonesRawData->GetEntriesFast()!=0) AliDebug(2,Form(" TOF raw data number = %3d", clonesRawData->GetEntriesFast()));
460 for (iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
462 AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
464 //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
465 if (tofRawDatum->GetTOF()==-1) continue;
467 fTOFRawStream.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
468 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
471 dummy = detectorIndex[3];
472 detectorIndex[3] = detectorIndex[4];//padz
473 detectorIndex[4] = dummy;//padx
475 tdcCorr = tofRawDatum->GetTOF();
476 status = MakeSlewingCorrection(detectorIndex, tofRawDatum->GetTOT(), tofRawDatum->GetTOF(), tdcCorr);
479 digit[1] = tofRawDatum->GetTOT();
480 digit[2] = tofRawDatum->GetTOT();
481 digit[3] = -1;//tofRawDatum->GetTOF(); //tofND
483 dummy = detectorIndex[3];
484 detectorIndex[3] = detectorIndex[4];//padx
485 detectorIndex[4] = dummy;//padz
487 /* check valid index */
488 if (detectorIndex[0]==-1||detectorIndex[1]==-1||detectorIndex[2]==-1||detectorIndex[3]==-1||detectorIndex[4]==-1) continue;
490 // Do not reconstruct anything in the holes
491 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
492 if (detectorIndex[1]==2) { // plate with holes
498 last = fDigits->GetEntriesFast();
499 new (aDigits[last]) AliTOFdigit(tracks, detectorIndex, digit);
500 if (status) fTOFdigitMap->AddDigit(detectorIndex, last);
503 if (indexDDL<10) ftxt << " " << indexDDL;
504 else ftxt << " " << indexDDL;
505 if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM();
506 else ftxt << " " << tofRawDatum->GetTRM();
507 ftxt << " " << tofRawDatum->GetTRMchain();
508 if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC();
509 else ftxt << " " << tofRawDatum->GetTDC();
510 ftxt << " " << tofRawDatum->GetTDCchannel();
512 if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0];
513 else ftxt << " -> " << detectorIndex[0];
514 ftxt << " " << detectorIndex[1];
515 if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2];
516 else ftxt << " " << detectorIndex[2];
517 ftxt << " " << detectorIndex[4];
518 if (detectorIndex[4]<10) ftxt << " " << detectorIndex[3];
519 else ftxt << " " << detectorIndex[3];
521 if (digit[1]<10)ftxt << " " << digit[1];
522 else if (digit[1]>=10 && digit[1]<100) ftxt << " " << digit[1];
523 else ftxt << " " << digit[1];
524 if (digit[0]<10) ftxt << " " << digit[0] << endl;
525 else if (digit[0]>=10 && digit[0]<100) ftxt << " " << digit[0] << endl;
526 else if (digit[0]>=100 && digit[0]<1000) ftxt << " " << digit[0] << endl;
527 else ftxt << " " << digit[3] << endl;
530 AliDebug(2, Form(" Raw data reading %2d -> %2d %1d %2d %1d %2d (%d, %d, %d)",
532 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[4], detectorIndex[3],
533 digit[0], digit[1], digit[3]));
537 clonesRawData->Clear();
541 if (fVerbose==2) ftxt.close();
545 fNumberOfTofDigits = fDigits->GetEntries();
547 AliDebug(1, Form("Got %d TOF digits", fNumberOfTofDigits));
548 AliDebug(1, Form("Execution time to read TOF raw data and fill TOF digit tree : R:%.2fs C:%.2fs",
549 stopwatch.RealTime(),stopwatch.CpuTime()));
551 if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
554 //_____________________________________________________________________________
556 void AliTOFClusterFinderV1::FillRecPoint()
559 // Fill the global TClonesArray of AliTOFcluster objects,
568 for(Int_t iPlate=AliTOFGeometry::NPlates()-1; iPlate>=0; iPlate--) {
569 for(Int_t iStrip=AliTOFGeometry::NStrip(iPlate)-1; iStrip>=0; iStrip--) {
570 //for (Int_t iSector=AliTOFGeometry::NSectors()-1; iSector>=0; iSector--) {
571 for (Int_t iSector=0; iSector<AliTOFGeometry::NSectors(); iSector++) {
574 if (fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))
575 AliDebug(1,Form(" Number of TOF digits in (%2d,%1d,%2d) -> %d",
576 iSector,iPlate,iStrip,fTOFdigitMap->FilledCellsInStrip(iSector,iPlate,iStrip)));
578 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
579 FindClustersWithoutTOT(iSector, iPlate, iStrip); // clusters coming from digits without TOT measurement
581 if (fMaxDeltaTime>0) {
583 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
584 //if (fTOFdigitMap->FilledCellsInStrip(iSector,iPlate,iStrip)>=4)
585 FindClustersPerStrip(iSector, iPlate, iStrip, 4); // 4 pads clusters
586 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
588 dummy4 = fNumberOfTofClusters;
589 FindClustersPerStrip(iSector, iPlate, iStrip, 4); // 4 pads clusters
590 if (fNumberOfTofClusters!=dummy4)
591 AliDebug(2, Form(" (4): n1= %5d, n2 = %5d", dummy4, fNumberOfTofClusters));
594 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
595 FindClustersPerStrip(iSector, iPlate, iStrip, 3); // 3 pads clusters
596 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
598 dummy3 = fNumberOfTofClusters;
599 FindClustersPerStrip(iSector, iPlate, iStrip, 3); // 3 pads clusters
600 if (fNumberOfTofClusters!=dummy3)
601 AliDebug(2, Form(" (3): n1= %5d, n2 = %5d", dummy3, fNumberOfTofClusters));
604 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
605 FindClustersPerStrip(iSector, iPlate, iStrip, 2); // 2 pads clusters
606 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
608 dummy2 = fNumberOfTofClusters;
609 FindClustersPerStrip(iSector, iPlate, iStrip, 2); // 2 pads clusters
610 if (fNumberOfTofClusters!=dummy2)
611 AliDebug(2, Form(" (2): n1= %5d, n2 =%5d", dummy2, fNumberOfTofClusters));
614 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
615 dummy = fNumberOfTofClusters;
616 FindClusters34(iSector, iPlate, iStrip); // 3 pads clusters between 4 hit pads
617 if (fNumberOfTofClusters!=dummy)
618 AliDebug(2, Form(" (3 between 4): n1 = %5d, n2 = %5d", fNumberOfTofClusters, dummy));
621 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
622 dummy = fNumberOfTofClusters;
623 FindClusters23(iSector, iPlate, iStrip); // 2 pads clusters between 3 hit pads
624 if (fNumberOfTofClusters!=dummy)
625 AliDebug(2, Form(" (2 between 3): n1 = %5d, n2 = %5d", fNumberOfTofClusters, dummy));
627 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
628 dummy = fNumberOfTofClusters;
629 FindClusters24(iSector, iPlate, iStrip); // 2 pads clusters between 4 hit pads
630 if (fNumberOfTofClusters!=dummy)
631 AliDebug(2, Form(" (2 between 4): n1 = %5d, n2 = %5d", fNumberOfTofClusters, dummy));
634 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
635 dummy = fNumberOfTofClusters;
636 FindOnePadClusterPerStrip(iSector, iPlate, iStrip); // 1 pad clusters
637 if (fNumberOfTofClusters!=dummy)
638 AliDebug(2,Form(" (1): n1 = %5d, n2 = %5d", fNumberOfTofClusters, dummy));
640 if (fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip)>0)
641 AliDebug(2, Form(" (1): number of clusters = %5d (remaining digit %2d), -%2d %1d %2d-",
642 fNumberOfTofClusters, fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip),
643 iSector, iPlate, iStrip));
647 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
648 dummy = fNumberOfTofClusters;
649 FindOnePadClusterPerStrip(iSector, iPlate, iStrip); // 1 pad clusters
650 if (fNumberOfTofClusters!=dummy)
651 AliDebug(2,Form(" (1): n1 = %5d, n2 = %5d", fNumberOfTofClusters, dummy));
653 if (fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip)>0)
654 AliDebug(2, Form(" (1): number of clusters = %5d (remaining digit %2d), -%2d %1d %2d-",
655 fNumberOfTofClusters, fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip),
656 iSector, iPlate, iStrip));
666 TClonesArray &lRecPoints = *fRecPoints;
670 Int_t detectorIndex[5];
671 for (jj=0; jj<5; jj++) detectorIndex[jj] = -1;
673 for (jj=0; jj<7; jj++) parTOF[jj] = -1;
674 Int_t trackLabels[3];
675 for (jj=0; jj<3; jj++) trackLabels[jj] = -1;
676 Int_t digitIndex = -1;
677 Bool_t status = kTRUE;
679 for (ii=0; ii<3; ii++) posClus[ii] = 0.;
680 //Float_t covClus[6];
681 //for (ii=0; ii<6; ii++) covClus[ii] = 0.;
684 for (ii=0; ii<fNumberOfTofClusters; ii++) {
686 digitIndex = fTofClusters[ii]->GetIndex();
687 for(jj=0; jj<5; jj++) detectorIndex[jj] = fTofClusters[ii]->GetDetInd(jj);
688 volIdClus = fTOFGeometry->GetAliSensVolIndex(detectorIndex[0],detectorIndex[1],detectorIndex[2]);
689 //volIdClus = GetClusterVolIndex(detectorIndex);
690 for(jj=0; jj<3; jj++) trackLabels[jj] = fTofClusters[ii]->GetLabel(jj);
691 parTOF[0] = fTofClusters[ii]->GetTDC(); // TDC
692 parTOF[1] = fTofClusters[ii]->GetToT(); // TOT
693 parTOF[2] = fTofClusters[ii]->GetADC(); // ADC=TOT
694 parTOF[3] = fTofClusters[ii]->GetTDCND(); // TDCND
695 parTOF[4] = fTofClusters[ii]->GetTDCRAW();//RAW
698 status = fTofClusters[ii]->GetStatus();
700 posClus[0] = fTofClusters[ii]->GetX();
701 posClus[1] = fTofClusters[ii]->GetY();
702 posClus[2] = fTofClusters[ii]->GetZ();
704 //for (jj=0; jj<6; jj++) covClus[jj] = 0.;
705 //((AliCluster*)fTofClusters[ii])->GetGlobalCov(covClus);
707 new(lRecPoints[ii]) AliTOFcluster(volIdClus, (Double_t)posClus[0], (Double_t)posClus[1], (Double_t)posClus[2],
708 (Double_t)(fTofClusters[ii]->GetSigmaX2()),
709 (Double_t)(fTofClusters[ii]->GetSigmaXY()),
710 (Double_t)(fTofClusters[ii]->GetSigmaXZ()),
711 (Double_t)(fTofClusters[ii]->GetSigmaY2()),
712 (Double_t)(fTofClusters[ii]->GetSigmaYZ()),
713 (Double_t)(fTofClusters[ii]->GetSigmaZ2()),
714 //(Double_t)covClus[0], (Double_t)covClus[1], (Double_t)covClus[2],
715 //(Double_t)covClus[3], (Double_t)covClus[4], (Double_t)covClus[5],
716 trackLabels, detectorIndex, parTOF, status, digitIndex);
718 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",
719 ii, volIdClus, posClus[0], posClus[1], posClus[2],
720 fTofClusters[ii]->GetSigmaX2(),
721 fTofClusters[ii]->GetSigmaXY(),
722 fTofClusters[ii]->GetSigmaXZ(),
723 fTofClusters[ii]->GetSigmaY2(),
724 fTofClusters[ii]->GetSigmaYZ(),
725 fTofClusters[ii]->GetSigmaZ2(),
726 trackLabels[0], trackLabels[1], trackLabels[2],
727 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[3], detectorIndex[4],
728 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
729 status, digitIndex));
734 for (Int_t iSector=0; iSector<AliTOFGeometry::NSectors(); iSector++)
735 for(Int_t iPlate=0; iPlate<AliTOFGeometry::NPlates(); iPlate++) {
736 for(Int_t iStrip=0; iStrip<AliTOFGeometry::NStrip(iPlate); iStrip++) {
737 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
738 AliDebug(2, Form(" END %2d %1d %2d %5d",
739 iSector, iPlate, iStrip, fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip)));
744 //_____________________________________________________________________________
746 void AliTOFClusterFinderV1::FindOnePadClusterPerStrip(Int_t nSector,
751 // This function searches the isolated digits (stored in the fDigits object),
752 // to perform clusters (stored in the fTofClusters array).
753 // This research has been made by checking the fTOFdigitMap object,
754 // filled at digits/raw-data reading time.
757 const Int_t kMaxNumberOfTracksPerDigit = 3;
758 const Int_t kMaxNumberOfDigitsPerVolume = 10;
762 Int_t det[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padZ,padX
763 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padX,padZ
764 UShort_t volIdClus = 0;
767 for (jj=0; jj<3; jj++) pos[jj] = 0.;
769 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
772 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
775 for (jj=0; jj<7; jj++) parTOF[jj] = 0;
777 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
779 Int_t tracks[kMaxNumberOfTracksPerDigit];
780 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
782 Int_t dummyCounter=-1;
784 AliTOFdigit *digitInteresting;
788 for (iPadX=0; iPadX<AliTOFGeometry::NpadX(); iPadX++) {
789 for (iPadZ=0; iPadZ<AliTOFGeometry::NpadZ(); iPadZ++) {
790 vol[4] = iPadZ , vol[3] = iPadX;
792 AliDebug(3, Form(" %1d %2d\n", iPadZ, iPadX));
794 if (fTOFdigitMap->GetNumberOfDigits(vol)==0) continue;
796 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
797 if (fTOFdigitMap->GetDigitIndex(vol,digIndex)<0) continue;
798 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(fTOFdigitMap->GetDigitIndex(vol,digIndex));
800 AliDebug(2, Form(" %3d %5d %2d %1d %2d %1d %2d %d %d %d %5d %5d %5d %5d",
801 fTOFdigitMap->GetNumberOfDigits(vol), digIndex,
802 vol[0], vol[1], vol[2] ,vol[4], vol[3],
803 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
804 digitInteresting->GetToT(),
805 fTOFdigitMap->GetDigitIndex(vol,digIndex),
806 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
808 det[3] = vol[4]; // padz
809 det[4] = vol[3]; // padx
810 fTOFGeometry->GetPosPar(det,pos);
811 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
814 for (jj=0; jj<3; jj++) posClus[jj] = pos[jj];
816 parTOF[0] = Int_t(digitInteresting->GetTdc());
817 parTOF[1] = Int_t(digitInteresting->GetToT());
818 parTOF[2] = Int_t(digitInteresting->GetAdc());
819 parTOF[3] = Int_t(digitInteresting->GetTdcND());
820 parTOF[4] = Int_t(digitInteresting->GetTdc());
824 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
825 //volIdClus = GetClusterVolIndex(det);
827 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
828 GetClusterPars(det, posClus, covClus);
830 // To fill the track index array
832 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
833 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) { // three is the max number of tracks associated to one digit
834 if (digitInteresting->GetTrack(jj)==-1) continue;
837 tracks[dummyCounter] = digitInteresting->GetTrack(jj);
841 AliTOFcluster *tofCluster =
842 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
843 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
844 tracks, det, parTOF, status, fTOFdigitMap->GetDigitIndex(vol,digIndex));
845 InsertCluster(tofCluster);
847 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",
848 volIdClus, posClus[0], posClus[1], posClus[2],
849 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
850 tracks[0], tracks[1], tracks[2],
851 det[0], det[1], det[2], det[3], det[4],
852 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
853 status, fTOFdigitMap->GetDigitIndex(vol,digIndex)));
855 AliDebug(2, Form(" %f %f %f", pos[0], pos[1], pos[2]));
856 AliDebug(2, Form(" %d %d", parTOF[0], parTOF[2]));
858 fTOFdigitMap->ResetDigit(vol, digIndex);
866 //_____________________________________________________________________________
868 void AliTOFClusterFinderV1::FindClustersWithoutTOT(Int_t nSector,
873 // This function searches the isolated digits without TOT
874 // measurement (stored in the fDigits object), to perform clusters
875 // (stored in the fTofClusters array). This research has been made
876 // by checking the fTOFdigitMap object, filled at digits/raw-data
880 const Int_t kMaxNumberOfTracksPerDigit = 3;
881 const Int_t kMaxNumberOfDigitsPerVolume = 10;
885 Int_t det[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padZ,padX
886 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padX,padZ
887 UShort_t volIdClus = 0;
890 for (jj=0; jj<3; jj++) pos[jj] = 0.;
892 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
895 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
898 for (jj=0; jj<7; jj++) parTOF[jj] = 0;
900 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
901 Int_t tracks[kMaxNumberOfTracksPerDigit];
902 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
904 Int_t dummyCounter=-1;
906 AliTOFdigit *digitInteresting;
910 for (iPadX=0; iPadX<AliTOFGeometry::NpadX(); iPadX++) {
911 for (iPadZ=0; iPadZ<AliTOFGeometry::NpadZ(); iPadZ++) {
912 vol[4] = iPadZ , vol[3] = iPadX;
914 AliDebug(3, Form(" %1d %2d\n", iPadZ, iPadX));
916 if (fTOFdigitMap->GetNumberOfDigits(vol)==0) continue;
918 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
919 if (fTOFdigitMap->GetDigitIndex(vol,digIndex)<0) continue;
920 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(fTOFdigitMap->GetDigitIndex(vol,digIndex));
921 if (digitInteresting->GetToT()>0) continue; // AdC
923 AliDebug(2, Form(" %3d %5d %2d %1d %2d %1d %2d %d %d %d %5d %5d %5d %5d",
924 fTOFdigitMap->GetNumberOfDigits(vol), digIndex,
925 vol[0], vol[1], vol[2] ,vol[4], vol[3],
926 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
927 digitInteresting->GetToT(),
928 fTOFdigitMap->GetDigitIndex(vol,digIndex),
929 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
931 det[3] = vol[4]; // padz
932 det[4] = vol[3]; // padx
933 fTOFGeometry->GetPosPar(det,pos);
934 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
937 for (jj=0; jj<3; jj++) posClus[jj] = pos[jj];
939 parTOF[0] = Int_t(digitInteresting->GetTdc());
940 parTOF[1] = Int_t(digitInteresting->GetToT());
941 parTOF[2] = Int_t(digitInteresting->GetAdc());
942 parTOF[3] = Int_t(digitInteresting->GetTdcND());
943 parTOF[4] = Int_t(digitInteresting->GetTdc());
947 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
948 //volIdClus = GetClusterVolIndex(det);
950 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
951 GetClusterPars(det, posClus, covClus);
953 // To fill the track index array
955 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
956 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) { // three is the max number of tracks associated to one digit
957 if (digitInteresting->GetTrack(jj)==-1) continue;
960 tracks[dummyCounter] = digitInteresting->GetTrack(jj);
964 AliTOFcluster *tofCluster =
965 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
966 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
967 tracks, det, parTOF, status, fTOFdigitMap->GetDigitIndex(vol,digIndex));
968 InsertCluster(tofCluster);
970 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",
971 volIdClus, posClus[0], posClus[1], posClus[2],
972 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
973 tracks[0], tracks[1], tracks[2],
974 det[0], det[1], det[2], det[3], det[4],
975 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
976 status, fTOFdigitMap->GetDigitIndex(vol,digIndex)));
978 AliDebug(2, Form(" %f %f %f", pos[0], pos[1], pos[2]));
979 AliDebug(2, Form(" %d %d", parTOF[0], parTOF[2]));
981 fTOFdigitMap->ResetDigit(vol, digIndex);
989 //_____________________________________________________________________________
991 void AliTOFClusterFinderV1::FindClusters34(Int_t nSector,
996 // This function searches the neighbouring digits (stored in the fDigits object),
997 // to perform clusters (stored in the fTofClusters array).
999 // This research has been made by checking the fTOFdigitMap object,
1000 // filled at digits/raw-data reading time.
1003 const Int_t kMaxNumberOfInterestingPads = 4;
1004 const Int_t kMaxNumberOfTracksPerDigit = 3;
1005 const Int_t kMaxNumberOfDigitsPerVolume = 10;
1009 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
1010 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1011 digitsInVolumeIndices[ii] = -1;
1013 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
1015 Float_t pos[3] = {0.,0.,0.};
1018 Int_t interestingPadX[kMaxNumberOfInterestingPads];
1019 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
1020 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
1021 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
1022 Double_t interestingTOT[kMaxNumberOfInterestingPads];
1023 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
1024 Double_t interestingADC[kMaxNumberOfInterestingPads];
1025 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
1026 Double_t interestingTOF[kMaxNumberOfInterestingPads];
1027 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
1028 Double_t interestingWeight[kMaxNumberOfInterestingPads];
1029 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
1031 Float_t interestingX[kMaxNumberOfInterestingPads];
1032 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
1033 Float_t interestingY[kMaxNumberOfInterestingPads];
1034 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
1035 Float_t interestingZ[kMaxNumberOfInterestingPads];
1036 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
1038 Float_t interDigit[kMaxNumberOfInterestingPads];
1039 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
1041 Int_t padsCluster[11];
1042 padsCluster[0] = nSector;
1043 padsCluster[1] = nPlate;
1044 padsCluster[2] = nStrip;
1045 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1047 Int_t interestingCounter=-1;
1048 Int_t digitIndexLocal=-1; // AdC
1054 for (jj=0; jj<7; jj++) parTOF[jj] = 0;
1055 Double_t posClus[3];
1056 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
1058 for (jj=0; jj<5; jj++) det[jj] = -1;
1060 for (jj=0; jj<3; jj++) posF[jj] = 0.;
1061 UShort_t volIdClus = 0;
1062 Bool_t check = kFALSE;
1063 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
1064 Double_t covClus[6];
1065 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1066 Int_t tracks[kMaxNumberOfTracksPerDigit];
1067 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1068 Int_t dummyCounter=-1;
1069 Bool_t alreadyStored = kFALSE;
1071 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
1072 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1073 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
1075 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1076 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
1078 AliTOFdigit *digitInteresting;
1080 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
1082 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
1083 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
1085 AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
1092 interestingCounter=-1;
1094 vol[4] = iPadZ , vol[3] = iPadX;
1095 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1096 interestingCounter++;
1098 vol[4] = iPadZ, vol[3] = iPadX+1;
1099 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1100 interestingCounter++;
1102 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1103 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1104 interestingCounter++;
1106 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1107 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1108 interestingCounter++;
1110 if (interestingCounter+1!=4) continue; // the hit pads have to be 4
1111 else interestingCounter=-1;
1114 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1115 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1116 selectedDigit[ii][jj] = 0x0;
1119 vol[4] = iPadZ, vol[3] = iPadX;
1121 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1122 interestingCounter++;
1123 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1124 digitsInVolumeIndices[ii] = -1;
1125 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1126 digitIndexLocal=-1; // AdC
1127 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1128 if (digitsInVolumeIndices[digIndex]<0) continue;
1129 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1130 if (digitInteresting->GetToT()<=0) continue; // AdC
1131 digitIndexLocal++; // AdC
1133 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1134 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1135 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1136 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1137 digitsInVolumeIndices[digIndex],
1138 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1141 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1142 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1143 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1144 digitInteresting->GetToT()*digitInteresting->GetToT(),
1145 digitsInVolumeIndices[digIndex],
1146 digitInteresting->GetTracks());
1148 if (digitIndexLocal==-1) interestingCounter--; // AdC
1152 vol[4] = iPadZ, vol[3] = iPadX+1;
1154 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1155 interestingCounter++;
1156 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1157 digitsInVolumeIndices[ii] = -1;
1158 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1159 digitIndexLocal=-1; // AdC
1160 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1161 if (digitsInVolumeIndices[digIndex]<0) continue;
1162 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1163 if (digitInteresting->GetToT()<=0) continue; // AdC
1164 digitIndexLocal++; // AdC
1166 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1167 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1168 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1169 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1170 digitsInVolumeIndices[digIndex],
1171 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1174 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1175 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1176 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1177 digitInteresting->GetToT()*digitInteresting->GetToT(),
1178 digitsInVolumeIndices[digIndex],
1179 digitInteresting->GetTracks());
1181 if (digitIndexLocal==-1) interestingCounter--; // AdC
1185 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1187 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1188 interestingCounter++;
1189 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1190 digitsInVolumeIndices[ii] = -1;
1191 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1192 digitIndexLocal=-1; // AdC
1193 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1194 if (digitsInVolumeIndices[digIndex]<0) continue;
1195 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1196 if (digitInteresting->GetToT()<=0) continue; // AdC
1197 digitIndexLocal++; // AdC
1199 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1200 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1201 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1202 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1203 digitsInVolumeIndices[digIndex],
1204 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1207 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1208 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1209 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1210 digitInteresting->GetToT()*digitInteresting->GetToT(),
1211 digitsInVolumeIndices[digIndex],
1212 digitInteresting->GetTracks());
1214 if (digitIndexLocal==-1) interestingCounter--; // AdC
1218 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1220 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1221 interestingCounter++;
1222 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1223 digitsInVolumeIndices[ii] = -1;
1224 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1226 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1227 if (digitsInVolumeIndices[digIndex]<0) continue;
1228 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1229 if (digitInteresting->GetToT()<=0) continue; // AdC
1230 digitIndexLocal++; // AdC
1232 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1233 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1234 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1235 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1236 digitsInVolumeIndices[digIndex],
1237 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1239 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1240 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1241 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1242 digitInteresting->GetToT()*digitInteresting->GetToT(),
1243 digitsInVolumeIndices[digIndex],
1244 digitInteresting->GetTracks());
1246 if (digitIndexLocal==-1) interestingCounter--; // AdC
1249 AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
1251 for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
1252 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
1253 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
1255 for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
1256 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
1257 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
1259 for (Int_t adesso3=adesso2+1; adesso3<interestingCounter+1; adesso3++) {
1260 for (Int_t thirdIndex=0; thirdIndex<kMaxNumberOfDigitsPerVolume; thirdIndex++) {
1261 if (selectedDigit[adesso3][thirdIndex]==0x0) continue;
1264 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime
1266 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
1268 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime) continue;
1270 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
1271 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
1272 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
1273 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
1274 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
1275 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
1276 Int_t volDum = vol1[3];
1279 fTOFGeometry->GetPosPar(vol1,pos);
1280 interestingX[0] = pos[0];
1281 interestingY[0] = pos[1];
1282 interestingZ[0] = pos[2];
1284 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
1285 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
1286 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
1287 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
1288 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
1289 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
1293 fTOFGeometry->GetPosPar(vol2,pos);
1294 interestingX[1] = pos[0];
1295 interestingY[1] = pos[1];
1296 interestingZ[1] = pos[2];
1298 interestingTOF[2] = selectedDigit[adesso3][thirdIndex]->GetTDC();
1299 interestingTOT[2] = selectedDigit[adesso3][thirdIndex]->GetTOT();
1300 interestingADC[2] = selectedDigit[adesso3][thirdIndex]->GetADC();
1301 interestingWeight[2] = selectedDigit[adesso3][thirdIndex]->GetWeight();
1302 Int_t vol3[5]; for(jj=0; jj<5; jj++) vol3[jj] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(jj);
1303 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol3[0], vol3[1], vol3[2], vol3[4], vol3[3]));
1307 fTOFGeometry->GetPosPar(vol3,pos);
1308 interestingX[2] = pos[0];
1309 interestingY[2] = pos[1];
1310 interestingZ[2] = pos[2];
1313 AverageCalculations(3, interestingX, interestingY, interestingZ,
1314 interestingTOF, interestingTOT, interestingADC,
1316 parTOF, posClus, check);
1319 for (jj=0; jj<5; jj++) det[jj] = -1;
1320 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
1321 fTOFGeometry->GetDetID(posF, det);
1323 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
1324 //volIdClus = GetClusterVolIndex(det);
1326 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1327 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
1328 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
1329 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
1330 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
1331 padsCluster[7] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(4);
1332 padsCluster[8] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(3);
1334 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1335 Int_t ** indDet = new Int_t*[3];
1336 for (jj=0; jj<3; jj++) indDet[jj] = new Int_t [5];
1337 for (jj=0; jj<3; jj++) indDet[jj][0] = nSector;
1338 for (jj=0; jj<3; jj++) indDet[jj][1] = nPlate;
1339 for (jj=0; jj<3; jj++) indDet[jj][2] = nStrip;
1340 for (jj=0; jj<3; jj++) indDet[jj][3] = padsCluster[2*jj+3];
1341 for (jj=0; jj<3; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
1342 GetClusterPars(/*check,*/ 3, indDet, interestingWeight, posClus, covClus);
1343 for (jj=0; jj<3; jj++) delete [] indDet[jj];
1346 // To fill the track index array
1348 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1349 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1350 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
1353 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
1356 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1357 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
1360 alreadyStored = kFALSE;
1361 for (jj=0; jj<dummyCounter+1; jj++)
1362 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
1364 if (alreadyStored) continue;
1365 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
1366 AliWarning(" Siamo al limite!");
1371 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
1376 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1377 if (selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk)==-1) continue;
1380 alreadyStored = kFALSE;
1381 for (jj=0; jj<dummyCounter+1; jj++)
1382 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk));
1384 if (alreadyStored) continue;
1385 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
1386 AliWarning(" Siamo al limite!");
1391 tracks[dummyCounter] = selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk);
1398 AliTOFcluster *tofCluster =
1399 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
1400 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1401 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
1402 InsertCluster(tofCluster);
1404 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",
1405 volIdClus, posClus[0], posClus[1], posClus[2],
1406 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1407 tracks[0], tracks[1], tracks[2],
1408 det[0], det[1], det[2], det[3], det[4],
1409 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
1410 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
1416 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
1420 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
1424 fTOFdigitMap->ResetDigitNumber(vol3,selectedDigit[adesso3][thirdIndex]->GetIndex());
1427 } // close loop on third digit
1428 } // close loop on adesso3
1430 } // close loop on second digit
1431 } // close loop on adesso2
1433 } // close loop on first digit
1434 } // close loop on adesso1
1436 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1437 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1438 selectedDigit[ii][jj] = 0x0;
1442 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++) {
1443 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
1444 delete [] selectedDigit[ii][jj];
1445 selectedDigit[ii][jj] = 0x0;
1447 delete [] selectedDigit[ii];
1448 selectedDigit[ii] = 0x0;
1450 delete [] selectedDigit;
1451 selectedDigit = 0x0;
1454 //_____________________________________________________________________________
1456 void AliTOFClusterFinderV1::FindClusters23(Int_t nSector,
1461 // This function searches the neighbouring digits (stored in the fDigits object),
1462 // to perform clusters (stored in the fTofClusters array).
1464 // This research has been made by checking the fTOFdigitMap object,
1465 // filled at digits/raw-data reading time.
1468 const Int_t kMaxNumberOfInterestingPads = 4;
1469 const Int_t kMaxNumberOfTracksPerDigit = 3;
1470 const Int_t kMaxNumberOfDigitsPerVolume = 10;
1474 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
1475 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1476 digitsInVolumeIndices[ii] = -1;
1478 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
1480 Float_t pos[3] = {0.,0.,0.};
1483 Int_t interestingPadX[kMaxNumberOfInterestingPads];
1484 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
1485 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
1486 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
1487 Double_t interestingTOT[kMaxNumberOfInterestingPads];
1488 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
1489 Double_t interestingADC[kMaxNumberOfInterestingPads];
1490 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
1491 Double_t interestingTOF[kMaxNumberOfInterestingPads];
1492 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
1493 Double_t interestingWeight[kMaxNumberOfInterestingPads];
1494 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
1496 Float_t interestingX[kMaxNumberOfInterestingPads];
1497 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
1498 Float_t interestingY[kMaxNumberOfInterestingPads];
1499 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
1500 Float_t interestingZ[kMaxNumberOfInterestingPads];
1501 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
1503 Float_t interDigit[kMaxNumberOfInterestingPads];
1504 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
1506 Int_t padsCluster[11];
1507 padsCluster[0] = nSector;
1508 padsCluster[1] = nPlate;
1509 padsCluster[2] = nStrip;
1510 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1512 Int_t interestingCounter=-1;
1513 Int_t digitIndexLocal = -1;
1518 Bool_t check = kFALSE;
1520 for (jj=0; jj<7; jj++) parTOF[jj] = 0;
1521 Double_t posClus[3];
1522 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
1524 for (jj=0; jj<5; jj++) det[jj] = -1;
1526 for (jj=0; jj<3; jj++) posF[jj] = 0.;
1527 UShort_t volIdClus = 0;
1528 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
1529 Double_t covClus[6];
1530 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1531 Int_t tracks[kMaxNumberOfTracksPerDigit];
1532 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1533 Int_t dummyCounter=-1;
1534 Bool_t alreadyStored = kFALSE;
1536 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
1537 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1538 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
1540 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1541 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
1543 AliTOFdigit *digitInteresting;
1545 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
1547 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
1548 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
1550 AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
1557 interestingCounter=-1;
1559 vol[4] = iPadZ , vol[3] = iPadX;
1560 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1561 interestingCounter++;
1563 vol[4] = iPadZ, vol[3] = iPadX+1;
1564 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1565 interestingCounter++;
1567 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1568 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1569 interestingCounter++;
1571 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1572 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1573 interestingCounter++;
1575 if (interestingCounter+1!=3) continue; // the hit pads have to be 3
1576 else interestingCounter=-1;
1579 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1580 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1581 selectedDigit[ii][jj] = 0x0;
1584 vol[4] = iPadZ, vol[3] = iPadX;
1586 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1587 interestingCounter++;
1588 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1589 digitsInVolumeIndices[ii] = -1;
1590 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1592 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1593 if (digitsInVolumeIndices[digIndex]<0) continue;
1594 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1595 if (digitInteresting->GetToT()<=0) continue; // AdC
1596 digitIndexLocal++; // AdC
1598 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1599 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1600 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1601 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1602 digitsInVolumeIndices[digIndex],
1603 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1605 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1606 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1607 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1608 digitInteresting->GetToT()*digitInteresting->GetToT(),
1609 digitsInVolumeIndices[digIndex],
1610 digitInteresting->GetTracks());
1612 if (digitIndexLocal==-1) interestingCounter--; // AdC
1616 vol[4] = iPadZ, vol[3] = iPadX+1;
1618 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1619 interestingCounter++;
1620 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1621 digitsInVolumeIndices[ii] = -1;
1622 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1623 digitIndexLocal=-1; // AdC
1624 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1625 if (digitsInVolumeIndices[digIndex]<0) continue;
1626 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1627 if (digitInteresting->GetToT()<=0) continue; // AdC
1628 digitIndexLocal++; // AdC
1630 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1631 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1632 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1633 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1634 digitsInVolumeIndices[digIndex],
1635 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1637 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1638 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1639 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1640 digitInteresting->GetToT()*digitInteresting->GetToT(),
1641 digitsInVolumeIndices[digIndex],
1642 digitInteresting->GetTracks());
1644 if (digitIndexLocal==-1) interestingCounter--; // AdC
1648 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1650 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1651 interestingCounter++;
1652 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1653 digitsInVolumeIndices[ii] = -1;
1654 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1655 digitIndexLocal=-1; // AdC
1656 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1657 if (digitsInVolumeIndices[digIndex]<0) continue;
1658 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1659 if (digitInteresting->GetToT()<=0) continue; // AdC
1660 digitIndexLocal++; // AdC
1662 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1663 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1664 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1665 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1666 digitsInVolumeIndices[digIndex],
1667 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1669 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1670 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1671 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1672 digitInteresting->GetToT()*digitInteresting->GetToT(),
1673 digitsInVolumeIndices[digIndex],
1674 digitInteresting->GetTracks());
1676 if (digitIndexLocal==-1) interestingCounter--; // AdC
1680 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1682 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1683 interestingCounter++;
1684 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1685 digitsInVolumeIndices[ii] = -1;
1686 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1687 digitIndexLocal=-1; // AdC
1688 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1689 if (digitsInVolumeIndices[digIndex]<0) continue;
1690 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1691 if (digitInteresting->GetToT()<=0) continue; // AdC
1692 digitIndexLocal++; // AdC
1694 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1695 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1696 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1697 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1698 digitsInVolumeIndices[digIndex],
1699 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1701 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1702 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1703 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1704 digitInteresting->GetToT()*digitInteresting->GetToT(),
1705 digitsInVolumeIndices[digIndex],
1706 digitInteresting->GetTracks());
1708 if (digitIndexLocal==-1) interestingCounter--; // AdC
1711 AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
1713 for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
1714 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
1715 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
1717 for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
1718 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
1719 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
1721 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime) continue;
1723 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
1724 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
1725 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
1726 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
1727 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
1728 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
1729 Int_t volDum = vol1[3];
1732 fTOFGeometry->GetPosPar(vol1,pos);
1733 interestingX[0] = pos[0];
1734 interestingY[0] = pos[1];
1735 interestingZ[0] = pos[2];
1737 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
1738 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
1739 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
1740 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
1741 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
1742 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
1746 fTOFGeometry->GetPosPar(vol2,pos);
1747 interestingX[1] = pos[0];
1748 interestingY[1] = pos[1];
1749 interestingZ[1] = pos[2];
1751 AverageCalculations(2, interestingX, interestingY, interestingZ,
1752 interestingTOF, interestingTOT, interestingADC,
1754 parTOF, posClus, check);
1756 for (jj=0; jj<5; jj++) det[jj] = -1;
1757 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
1758 fTOFGeometry->GetDetID(posF, det);
1760 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
1761 //volIdClus = GetClusterVolIndex(det);
1763 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1764 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
1765 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
1766 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
1767 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
1769 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1770 Int_t ** indDet = new Int_t*[2];
1771 for (jj=0; jj<2; jj++) indDet[jj] = new Int_t [5];
1772 for (jj=0; jj<2; jj++) indDet[jj][0] = nSector;
1773 for (jj=0; jj<2; jj++) indDet[jj][1] = nPlate;
1774 for (jj=0; jj<2; jj++) indDet[jj][2] = nStrip;
1775 for (jj=0; jj<2; jj++) indDet[jj][3] = padsCluster[2*jj+3];
1776 for (jj=0; jj<2; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
1777 GetClusterPars(/*check,*/ 2, indDet, interestingWeight, posClus, covClus);
1778 for (jj=0; jj<2; jj++) delete [] indDet[jj];
1781 // To fill the track index array
1783 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1784 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1785 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
1788 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
1791 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1792 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
1795 alreadyStored = kFALSE;
1796 for (jj=0; jj<dummyCounter+1; jj++)
1797 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
1799 if (alreadyStored) continue;
1800 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
1801 AliWarning(" Siamo al limite!");
1806 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
1813 AliTOFcluster *tofCluster =
1814 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
1815 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1816 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
1817 InsertCluster(tofCluster);
1819 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",
1820 volIdClus, posClus[0], posClus[1], posClus[2],
1821 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1822 tracks[0], tracks[1], tracks[2],
1823 det[0], det[1], det[2], det[3], det[4],
1824 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
1825 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
1830 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
1834 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
1837 } // close loop on second digit
1838 } // close loop on adesso2
1840 } // close loop on first digit
1841 } // close loop on adesso1
1843 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1844 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1845 selectedDigit[ii][jj] = 0x0;
1849 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++) {
1850 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
1851 delete [] selectedDigit[ii][jj];
1852 selectedDigit[ii][jj] = 0x0;
1854 delete [] selectedDigit[ii];
1855 selectedDigit[ii] = 0x0;
1857 delete [] selectedDigit;
1858 selectedDigit = 0x0;
1861 //_____________________________________________________________________________
1863 void AliTOFClusterFinderV1::FindClusters24(Int_t nSector,
1868 // This function searches the neighbouring digits (stored in the fDigits object),
1869 // to perform clusters (stored in the fTofClusters array).
1871 // This research has been made by checking the fTOFdigitMap object,
1872 // filled at digits/raw-data reading time.
1875 const Int_t kMaxNumberOfInterestingPads = 4;
1876 const Int_t kMaxNumberOfTracksPerDigit = 3;
1877 const Int_t kMaxNumberOfDigitsPerVolume = 10;
1881 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
1882 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1883 digitsInVolumeIndices[ii] = -1;
1885 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
1887 Float_t pos[3] = {0.,0.,0.};
1890 Int_t interestingPadX[kMaxNumberOfInterestingPads];
1891 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
1892 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
1893 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
1894 Double_t interestingTOT[kMaxNumberOfInterestingPads];
1895 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
1896 Double_t interestingADC[kMaxNumberOfInterestingPads];
1897 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
1898 Double_t interestingTOF[kMaxNumberOfInterestingPads];
1899 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
1900 Double_t interestingWeight[kMaxNumberOfInterestingPads];
1901 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
1903 Float_t interestingX[kMaxNumberOfInterestingPads];
1904 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
1905 Float_t interestingY[kMaxNumberOfInterestingPads];
1906 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
1907 Float_t interestingZ[kMaxNumberOfInterestingPads];
1908 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
1910 Float_t interDigit[kMaxNumberOfInterestingPads];
1911 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
1913 Int_t padsCluster[11];
1914 padsCluster[0] = nSector;
1915 padsCluster[1] = nPlate;
1916 padsCluster[2] = nStrip;
1917 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1919 Int_t interestingCounter=-1;
1920 Int_t digitIndexLocal = -1;
1925 Bool_t check = kFALSE;
1927 for (jj=0; jj<7; jj++) parTOF[jj] = 0;
1928 Double_t posClus[3];
1929 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
1931 for (jj=0; jj<5; jj++) det[jj] = -1;
1933 for (jj=0; jj<3; jj++) posF[jj] = 0.;
1934 UShort_t volIdClus = 0;
1935 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
1936 Double_t covClus[6];
1937 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1938 Int_t tracks[kMaxNumberOfTracksPerDigit];
1939 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1940 Int_t dummyCounter=-1;
1941 Bool_t alreadyStored = kFALSE;
1943 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
1944 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1945 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
1947 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1948 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
1950 AliTOFdigit *digitInteresting;
1952 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
1954 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
1955 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
1957 AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
1964 interestingCounter=-1;
1966 vol[4] = iPadZ , vol[3] = iPadX;
1967 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1968 interestingCounter++;
1970 vol[4] = iPadZ, vol[3] = iPadX+1;
1971 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1972 interestingCounter++;
1974 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1975 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1976 interestingCounter++;
1978 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1979 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1980 interestingCounter++;
1982 if (interestingCounter+1!=4) continue; // the hit pads have to be 4
1983 else interestingCounter=-1;
1986 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1987 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1988 selectedDigit[ii][jj] = 0x0;
1991 vol[4] = iPadZ, vol[3] = iPadX;
1993 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1994 interestingCounter++;
1995 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1996 digitsInVolumeIndices[ii] = -1;
1997 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1998 digitIndexLocal=-1; // AdC
1999 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2000 if (digitsInVolumeIndices[digIndex]<0) continue;
2001 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2002 if (digitInteresting->GetToT()<=0) continue; // AdC
2003 digitIndexLocal++; // AdC
2005 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2006 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2007 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2008 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2009 digitsInVolumeIndices[digIndex],
2010 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2012 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2013 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2014 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2015 digitInteresting->GetToT()*digitInteresting->GetToT(),
2016 digitsInVolumeIndices[digIndex],
2017 digitInteresting->GetTracks());
2019 if (digitIndexLocal==-1) interestingCounter--; // AdC
2023 vol[4] = iPadZ, vol[3] = iPadX+1;
2025 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2026 interestingCounter++;
2027 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2028 digitsInVolumeIndices[ii] = -1;
2029 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2030 digitIndexLocal=-1; // AdC
2031 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2032 if (digitsInVolumeIndices[digIndex]<0) continue;
2033 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2034 if (digitInteresting->GetToT()<=0) continue; // AdC
2035 digitIndexLocal++; // AdC
2037 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2038 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2039 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2040 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2041 digitsInVolumeIndices[digIndex],
2042 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2044 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2045 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2046 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2047 digitInteresting->GetToT()*digitInteresting->GetToT(),
2048 digitsInVolumeIndices[digIndex],
2049 digitInteresting->GetTracks());
2051 if (digitIndexLocal==-1) interestingCounter--; // AdC
2055 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
2057 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2058 interestingCounter++;
2059 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2060 digitsInVolumeIndices[ii] = -1;
2061 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2062 digitIndexLocal=-1; // AdC
2063 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2064 if (digitsInVolumeIndices[digIndex]<0) continue;
2065 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2066 if (digitInteresting->GetToT()<=0) continue; // AdC
2067 digitIndexLocal++; // AdC
2069 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2070 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2071 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2072 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2073 digitsInVolumeIndices[digIndex],
2074 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2076 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2077 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2078 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2079 digitInteresting->GetToT()*digitInteresting->GetToT(),
2080 digitsInVolumeIndices[digIndex],
2081 digitInteresting->GetTracks());
2083 if (digitIndexLocal==-1) interestingCounter--; // AdC
2087 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
2089 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2090 interestingCounter++;
2091 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2092 digitsInVolumeIndices[ii] = -1;
2093 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2094 digitIndexLocal=-1; // AdC
2095 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2096 if (digitsInVolumeIndices[digIndex]<0) continue;
2097 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2098 if (digitInteresting->GetToT()<=0) continue; // AdC
2099 digitIndexLocal++; // AdC
2101 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2102 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2103 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2104 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2105 digitsInVolumeIndices[digIndex],
2106 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2108 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2109 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2110 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2111 digitInteresting->GetToT()*digitInteresting->GetToT(),
2112 digitsInVolumeIndices[digIndex],
2113 digitInteresting->GetTracks());
2115 if (digitIndexLocal==-1) interestingCounter--; // AdC
2118 AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
2120 for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
2121 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2122 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2124 for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
2125 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2126 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2128 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime) continue;
2130 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2131 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2132 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2133 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2134 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
2135 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
2136 Int_t volDum = vol1[3];
2139 fTOFGeometry->GetPosPar(vol1,pos);
2140 interestingX[0] = pos[0];
2141 interestingY[0] = pos[1];
2142 interestingZ[0] = pos[2];
2144 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2145 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2146 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2147 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2148 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
2149 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
2153 fTOFGeometry->GetPosPar(vol2,pos);
2154 interestingX[1] = pos[0];
2155 interestingY[1] = pos[1];
2156 interestingZ[1] = pos[2];
2159 AverageCalculations(2, interestingX, interestingY, interestingZ,
2160 interestingTOF, interestingTOT, interestingADC,
2162 parTOF, posClus, check);
2164 for (jj=0; jj<5; jj++) det[jj] = -1;
2165 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
2166 fTOFGeometry->GetDetID(posF, det);
2168 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
2169 //volIdClus = GetClusterVolIndex(det);
2171 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2172 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
2173 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
2174 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
2175 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
2177 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2178 Int_t ** indDet = new Int_t*[2];
2179 for (jj=0; jj<2; jj++) indDet[jj] = new Int_t [5];
2180 for (jj=0; jj<2; jj++) indDet[jj][0] = nSector;
2181 for (jj=0; jj<2; jj++) indDet[jj][1] = nPlate;
2182 for (jj=0; jj<2; jj++) indDet[jj][2] = nStrip;
2183 for (jj=0; jj<2; jj++) indDet[jj][3] = padsCluster[2*jj+3];
2184 for (jj=0; jj<2; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
2185 GetClusterPars(/*check,*/ 2, indDet, interestingWeight, posClus, covClus);
2186 for (jj=0; jj<2; jj++) delete [] indDet[jj];
2189 // To fill the track index array
2191 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2192 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2193 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
2196 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
2199 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2200 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
2203 alreadyStored = kFALSE;
2204 for (jj=0; jj<dummyCounter+1; jj++)
2205 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
2207 if (alreadyStored) continue;
2208 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2209 AliWarning(" Siamo al limite!");
2214 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
2221 AliTOFcluster *tofCluster =
2222 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
2223 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2224 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
2225 InsertCluster(tofCluster);
2227 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",
2228 volIdClus, posClus[0], posClus[1], posClus[2],
2229 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2230 tracks[0], tracks[1], tracks[2],
2231 det[0], det[1], det[2], det[3], det[4],
2232 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
2233 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
2238 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
2242 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
2245 } // close loop on second digit
2246 } // close loop on adesso2
2248 } // close loop on first digit
2249 } // close loop on adesso1
2251 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2252 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
2253 selectedDigit[ii][jj] = 0x0;
2257 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++) {
2258 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
2259 delete [] selectedDigit[ii][jj];
2260 selectedDigit[ii][jj] = 0x0;
2262 delete [] selectedDigit[ii];
2263 selectedDigit[ii] = 0x0;
2265 delete [] selectedDigit;
2266 selectedDigit = 0x0;
2269 //_____________________________________________________________________________
2271 void AliTOFClusterFinderV1::FindClustersPerStrip(Int_t nSector,
2277 // This function searches the neighbouring digits (stored in the fDigits object),
2278 // to perform clusters (stored in the fTofClusters array).
2280 // Each strip is read four times:
2281 // - 1st time: it searches possible clusters formed by four
2282 // neighbouring digits;
2283 // - 2nd time: it searches possible clusters formed by three
2284 // neighbouring digits;
2285 // - 3rd time: it searches possible clusters formed by two
2286 // neighbouring digits;
2287 // - 4th time: the remaining isolated digits have been transformed
2289 // This research has been made by checking the fTOFdigitMap object,
2290 // filled at digits/raw-data reading time.
2293 const Int_t kMaxNumberOfInterestingPads = 4;
2294 const Int_t kMaxNumberOfTracksPerDigit = 3;
2295 const Int_t kMaxNumberOfDigitsPerVolume = 10;
2299 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
2300 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2301 digitsInVolumeIndices[ii] = -1;
2303 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
2305 Float_t pos[3] = {0.,0.,0.};
2308 Int_t interestingPadX[kMaxNumberOfInterestingPads];
2309 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
2310 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
2311 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
2312 Double_t interestingTOT[kMaxNumberOfInterestingPads];
2313 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
2314 Double_t interestingADC[kMaxNumberOfInterestingPads];
2315 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
2316 Double_t interestingTOF[kMaxNumberOfInterestingPads];
2317 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
2318 Double_t interestingWeight[kMaxNumberOfInterestingPads];
2319 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
2321 Float_t interestingX[kMaxNumberOfInterestingPads];
2322 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
2323 Float_t interestingY[kMaxNumberOfInterestingPads];
2324 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
2325 Float_t interestingZ[kMaxNumberOfInterestingPads];
2326 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
2328 Float_t interDigit[kMaxNumberOfInterestingPads];
2329 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
2331 Int_t padsCluster[11];
2332 padsCluster[0] = nSector;
2333 padsCluster[1] = nPlate;
2334 padsCluster[2] = nStrip;
2335 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2337 Int_t interestingCounter=-1;
2338 Int_t digitIndexLocal = -1;
2343 Bool_t check = kFALSE;
2345 for (jj=0; jj<7; jj++) parTOF[jj] = 0;
2346 Double_t posClus[3];
2347 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
2349 for (jj=0; jj<5; jj++) det[jj] = -1;
2351 for (jj=0; jj<3; jj++) posF[jj] = 0.;
2352 UShort_t volIdClus = 0;
2353 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
2354 Double_t covClus[6];
2355 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2356 Int_t tracks[kMaxNumberOfTracksPerDigit];
2357 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2358 Int_t dummyCounter=-1;
2359 Bool_t alreadyStored = kFALSE;
2361 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
2362 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2363 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
2365 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2366 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
2368 AliTOFdigit *digitInteresting;
2372 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
2374 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
2375 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
2377 AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
2384 interestingCounter=-1;
2386 vol[4] = iPadZ , vol[3] = iPadX;
2387 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2388 interestingCounter++;
2390 vol[4] = iPadZ, vol[3] = iPadX+1;
2391 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2392 interestingCounter++;
2394 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
2395 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2396 interestingCounter++;
2398 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
2399 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2400 interestingCounter++;
2402 if (interestingCounter!=group) continue;
2403 else interestingCounter=-1;
2406 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2407 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
2408 selectedDigit[ii][jj] = 0x0;
2411 vol[4] = iPadZ, vol[3] = iPadX;
2413 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2414 interestingCounter++;
2415 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2416 digitsInVolumeIndices[ii] = -1;
2417 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2418 digitIndexLocal=-1; // AdC
2419 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2420 if (digitsInVolumeIndices[digIndex]<0) continue;
2421 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2422 if (digitInteresting->GetToT()<=0) continue; // AdC
2423 digitIndexLocal++; // AdC
2425 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2426 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2427 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2428 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2429 digitsInVolumeIndices[digIndex],
2430 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2431 AliDebug(1,Form(" to try %d %d ",digIndex, interestingCounter));
2433 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2434 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2435 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2436 digitInteresting->GetToT()*digitInteresting->GetToT(),
2437 digitsInVolumeIndices[digIndex],
2438 digitInteresting->GetTracks());
2440 if (digitIndexLocal==-1) interestingCounter--; // AdC
2444 vol[4] = iPadZ, vol[3] = iPadX+1;
2446 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2447 interestingCounter++;
2448 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2449 digitsInVolumeIndices[ii] = -1;
2450 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2451 digitIndexLocal=-1; // AdC
2452 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2453 if (digitsInVolumeIndices[digIndex]<0) continue;
2454 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2455 if (digitInteresting->GetToT()<=0) continue; // AdC
2456 digitIndexLocal++; // AdC
2458 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2459 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2460 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2461 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2462 digitsInVolumeIndices[digIndex],
2463 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2464 AliDebug(1,Form(" to try %d %d ",digIndex, interestingCounter));
2466 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2467 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2468 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2469 digitInteresting->GetToT()*digitInteresting->GetToT(),
2470 digitsInVolumeIndices[digIndex],
2471 digitInteresting->GetTracks());
2473 if (digitIndexLocal==-1) interestingCounter--; // AdC
2477 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
2479 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2480 interestingCounter++;
2481 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2482 digitsInVolumeIndices[ii] = -1;
2483 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2484 digitIndexLocal=-1; // AdC
2485 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2486 if (digitsInVolumeIndices[digIndex]<0) continue;
2487 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2488 if (digitInteresting->GetToT()<=0) continue; // AdC
2489 digitIndexLocal++; // AdC
2491 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2492 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2493 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2494 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2495 digitsInVolumeIndices[digIndex],
2496 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2497 AliDebug(1,Form(" to try %d %d ",digIndex, interestingCounter));
2499 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2500 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2501 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2502 digitInteresting->GetToT()*digitInteresting->GetToT(),
2503 digitsInVolumeIndices[digIndex],
2504 digitInteresting->GetTracks());
2506 if (digitIndexLocal==-1) interestingCounter--; // AdC
2510 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
2512 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2513 interestingCounter++;
2514 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2515 digitsInVolumeIndices[ii] = -1;
2516 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2517 digitIndexLocal=-1; // AdC
2518 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2519 if (digitsInVolumeIndices[digIndex]<0) continue;
2520 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2521 if (digitInteresting->GetToT()<=0) continue; // AdC
2522 digitIndexLocal++; // AdC
2524 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2525 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2526 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2527 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2528 digitsInVolumeIndices[digIndex],
2529 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2530 AliDebug(1,Form(" to try %d %d ",digIndex, interestingCounter));
2532 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2533 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2534 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2535 digitInteresting->GetToT()*digitInteresting->GetToT(),
2536 digitsInVolumeIndices[digIndex],
2537 digitInteresting->GetTracks());
2539 if (digitIndexLocal==-1) interestingCounter--; // AdC
2542 AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
2549 switch(interestingCounter+1) {
2553 //for (adesso1=0; adesso1<interestingCounter+1; adesso1++) {
2555 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2556 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2558 //for (adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
2560 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2561 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2563 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime) {
2564 AliDebug(1,Form(" selD1[%d][%d]->GetTDC()=%d selD2[%d][%d]->GetTDC()=%d -- %d ",
2565 adesso1,firstIndex,(Int_t)selectedDigit[adesso1][firstIndex]->GetTDC(),
2566 adesso2,secondIndex,(Int_t)selectedDigit[adesso2][secondIndex]->GetTDC(),
2571 AliDebug(1, Form(" %1d %1d (0x%p) %1d %1d (0x%p)", adesso1, firstIndex,selectedDigit[adesso1][firstIndex],
2572 adesso2, secondIndex,selectedDigit[adesso2][secondIndex]));
2574 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2575 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2576 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2577 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2578 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
2579 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
2580 Int_t volDum = vol1[3];
2583 fTOFGeometry->GetPosPar(vol1,pos);
2584 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
2585 interestingX[0] = pos[0];
2586 interestingY[0] = pos[1];
2587 interestingZ[0] = pos[2];
2589 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2590 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2591 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2592 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2593 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
2594 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
2598 fTOFGeometry->GetPosPar(vol2,pos);
2599 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
2600 interestingX[1] = pos[0];
2601 interestingY[1] = pos[1];
2602 interestingZ[1] = pos[2];
2605 AverageCalculations(interestingCounter+1,
2606 interestingX, interestingY, interestingZ,
2607 interestingTOF, interestingTOT, interestingADC,
2609 parTOF, posClus, check);
2611 for (jj=0; jj<5; jj++) det[jj] = -1;
2612 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
2614 AliDebug(1,Form(" %f %f %f", posF[0], posF[1], posF[2]));
2615 fTOFGeometry->GetDetID(posF, det);
2616 AliDebug(1,Form(" %2d %1d %2d %1d %2d", det[0], det[1], det[2], det[3], det[4]));
2618 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
2619 //volIdClus = GetClusterVolIndex(det);
2621 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2622 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
2623 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
2624 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
2625 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
2627 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2628 Int_t ** indDet = new Int_t*[interestingCounter+1];
2629 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj] = new Int_t [5];
2630 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][0] = nSector;
2631 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][1] = nPlate;
2632 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][2] = nStrip;
2633 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][3] = padsCluster[2*jj+3];
2634 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
2635 GetClusterPars(/*check,*/ interestingCounter+1, indDet, interestingWeight, posClus, covClus);
2636 for (jj=0; jj<interestingCounter+1; jj++) delete [] indDet[jj];
2639 // To fill the track index array
2641 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2642 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2643 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
2646 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
2649 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2650 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
2653 alreadyStored = kFALSE;
2654 for (jj=0; jj<dummyCounter+1; jj++)
2655 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
2657 if (alreadyStored) continue;
2658 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2659 AliWarning(" Siamo al limite!");
2664 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
2671 AliTOFcluster *tofCluster =
2672 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
2673 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2674 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); //to updated
2675 InsertCluster(tofCluster);
2677 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",
2678 volIdClus, posClus[0], posClus[1], posClus[2],
2679 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2680 tracks[0], tracks[1], tracks[2],
2681 det[0], det[1], det[2], det[3], det[4],
2682 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
2683 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
2688 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
2692 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
2695 } // close loop on second digit
2696 //} // close loop on adesso2
2698 } // close loop on first digit
2699 //} // close loop on adesso1
2706 //for (adesso1=0; adesso1<interestingCounter+1; adesso1++) {
2708 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2709 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2711 //for (adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
2713 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2714 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2716 //for (adesso3=adesso2+1; adesso3<interestingCounter+1; adesso3++) {
2718 for (Int_t thirdIndex=0; thirdIndex<kMaxNumberOfDigitsPerVolume; thirdIndex++) {
2719 if (selectedDigit[adesso3][thirdIndex]==0x0) continue;
2722 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime
2724 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
2726 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime) continue;
2728 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2729 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2730 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2731 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2732 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
2733 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
2734 Int_t volDum = vol1[3];
2737 fTOFGeometry->GetPosPar(vol1,pos);
2738 interestingX[0] = pos[0];
2739 interestingY[0] = pos[1];
2740 interestingZ[0] = pos[2];
2742 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2743 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2744 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2745 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2746 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
2747 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
2751 fTOFGeometry->GetPosPar(vol2,pos);
2752 interestingX[1] = pos[0];
2753 interestingY[1] = pos[1];
2754 interestingZ[1] = pos[2];
2756 interestingTOF[2] = selectedDigit[adesso3][thirdIndex]->GetTDC();
2757 interestingTOT[2] = selectedDigit[adesso3][thirdIndex]->GetTOT();
2758 interestingADC[2] = selectedDigit[adesso3][thirdIndex]->GetADC();
2759 interestingWeight[2] = selectedDigit[adesso3][thirdIndex]->GetWeight();
2760 Int_t vol3[5]; for(jj=0; jj<5; jj++) vol3[jj] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(jj);
2761 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol3[0], vol3[1], vol3[2], vol3[4], vol3[3]));
2765 fTOFGeometry->GetPosPar(vol3,pos);
2766 interestingX[2] = pos[0];
2767 interestingY[2] = pos[1];
2768 interestingZ[2] = pos[2];
2771 AverageCalculations(interestingCounter+1,
2772 interestingX, interestingY, interestingZ,
2773 interestingTOF, interestingTOT, interestingADC,
2775 parTOF, posClus, check);
2777 for (jj=0; jj<5; jj++) det[jj] = -1;
2778 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
2779 fTOFGeometry->GetDetID(posF, det);
2781 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
2782 //volIdClus = GetClusterVolIndex(det);
2784 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2785 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
2786 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
2787 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
2788 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
2789 padsCluster[7] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(4);
2790 padsCluster[8] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(3);
2792 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2793 Int_t ** indDet = new Int_t*[interestingCounter+1];
2794 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj] = new Int_t [5];
2795 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][0] = nSector;
2796 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][1] = nPlate;
2797 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][2] = nStrip;
2798 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][3] = padsCluster[2*jj+3];
2799 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
2800 GetClusterPars(/*check,*/ interestingCounter+1, indDet, interestingWeight, posClus, covClus);
2801 for (jj=0; jj<interestingCounter+1; jj++) delete [] indDet[jj];
2805 // To fill the track index array
2807 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2808 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2809 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
2812 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
2815 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2816 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
2819 alreadyStored = kFALSE;
2820 for (jj=0; jj<dummyCounter+1; jj++)
2821 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
2823 if (alreadyStored) continue;
2824 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2825 AliWarning(" Siamo al limite!");
2830 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
2835 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2836 if (selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk)==-1) continue;
2839 alreadyStored = kFALSE;
2840 for (jj=0; jj<dummyCounter+1; jj++)
2841 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk));
2843 if (alreadyStored) continue;
2844 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2845 AliWarning(" Siamo al limite!");
2850 tracks[dummyCounter] = selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk);
2857 AliTOFcluster *tofCluster =
2858 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
2859 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2860 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
2861 InsertCluster(tofCluster);
2863 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",
2864 volIdClus, posClus[0], posClus[1], posClus[2],
2865 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2866 tracks[0], tracks[1], tracks[2],
2867 det[0], det[1], det[2], det[3], det[4],
2868 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
2869 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
2874 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
2878 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
2882 fTOFdigitMap->ResetDigitNumber(vol3,selectedDigit[adesso3][thirdIndex]->GetIndex());
2885 } // close loop on third digit
2886 //} // close loop on adesso3
2888 } // close loop on second digit
2889 //} // close loop on adesso2
2891 } // close loop on first digit
2892 //} // close loop on adesso1
2900 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2901 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2904 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2905 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2908 for (Int_t thirdIndex=0; thirdIndex<kMaxNumberOfDigitsPerVolume; thirdIndex++) {
2909 if (selectedDigit[adesso3][thirdIndex]==0x0) continue;
2912 for (Int_t fourthIndex=0; fourthIndex<kMaxNumberOfDigitsPerVolume; fourthIndex++) {
2913 if (selectedDigit[adesso4][fourthIndex]==0x0) continue;
2916 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime
2918 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
2920 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso4][fourthIndex]->GetTDC())>fMaxDeltaTime
2922 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
2924 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso4][fourthIndex]->GetTDC())>fMaxDeltaTime
2926 TMath::Abs(selectedDigit[adesso3][thirdIndex]->GetTDC()-selectedDigit[adesso4][fourthIndex]->GetTDC())>fMaxDeltaTime) continue;
2928 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2929 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2930 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2931 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2932 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
2933 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
2934 Int_t volDum = vol1[3];
2937 fTOFGeometry->GetPosPar(vol1,pos);
2938 interestingX[0] = pos[0];
2939 interestingY[0] = pos[1];
2940 interestingZ[0] = pos[2];
2942 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2943 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2944 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2945 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2946 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
2947 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
2951 fTOFGeometry->GetPosPar(vol2,pos);
2952 interestingX[1] = pos[0];
2953 interestingY[1] = pos[1];
2954 interestingZ[1] = pos[2];
2956 interestingTOF[2] = selectedDigit[adesso3][thirdIndex]->GetTDC();
2957 interestingTOT[2] = selectedDigit[adesso3][thirdIndex]->GetTOT();
2958 interestingADC[2] = selectedDigit[adesso3][thirdIndex]->GetADC();
2959 interestingWeight[2] = selectedDigit[adesso3][thirdIndex]->GetWeight();
2960 Int_t vol3[5]; for(jj=0; jj<5; jj++) vol3[jj] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(jj);
2961 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol3[0], vol3[1], vol3[2], vol3[4], vol3[3]));
2965 fTOFGeometry->GetPosPar(vol3,pos);
2966 interestingX[2] = pos[0];
2967 interestingY[2] = pos[1];
2968 interestingZ[2] = pos[2];
2970 interestingTOF[3] = selectedDigit[adesso4][fourthIndex]->GetTDC();
2971 interestingTOT[3] = selectedDigit[adesso4][fourthIndex]->GetTOT();
2972 interestingADC[3] = selectedDigit[adesso4][fourthIndex]->GetADC();
2973 interestingWeight[3] = selectedDigit[adesso4][fourthIndex]->GetWeight();
2974 Int_t vol4[5]; for(jj=0; jj<5; jj++) vol4[jj] = selectedDigit[adesso4][fourthIndex]->GetDetectorIndex(jj);
2975 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol4[0], vol4[1], vol4[2], vol4[4], vol4[3]));
2979 fTOFGeometry->GetPosPar(vol4,pos);
2980 interestingX[3] = pos[0];
2981 interestingY[3] = pos[1];
2982 interestingZ[3] = pos[2];
2985 AverageCalculations(interestingCounter+1,
2986 interestingX, interestingY, interestingZ,
2987 interestingTOF, interestingTOT, interestingADC,
2989 parTOF, posClus, check);
2991 for (jj=0; jj<5; jj++) det[jj] = -1;
2992 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
2993 fTOFGeometry->GetDetID(posF, det);
2995 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
2996 //volIdClus = GetClusterVolIndex(det);
2998 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2999 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
3000 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
3001 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
3002 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
3003 padsCluster[7] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(4);
3004 padsCluster[8] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(3);
3005 padsCluster[9] = selectedDigit[adesso4][fourthIndex]->GetDetectorIndex(4);
3006 padsCluster[10] = selectedDigit[adesso4][fourthIndex]->GetDetectorIndex(3);
3008 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
3009 Int_t ** indDet = new Int_t*[interestingCounter+1];
3010 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj] = new Int_t [5];
3011 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][0] = nSector;
3012 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][1] = nPlate;
3013 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][2] = nStrip;
3014 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][3] = padsCluster[2*jj+3];
3015 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
3016 GetClusterPars(/*check,*/ interestingCounter+1, indDet, interestingWeight, posClus, covClus);
3017 for (jj=0; jj<interestingCounter+1; jj++) delete [] indDet[jj];
3020 // To fill the track index array
3022 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
3023 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
3024 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
3027 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
3030 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
3031 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
3034 alreadyStored = kFALSE;
3035 for (jj=0; jj<dummyCounter+1; jj++)
3036 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
3038 if (alreadyStored) continue;
3039 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
3040 AliWarning(" Siamo al limite!");
3045 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
3050 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
3051 if (selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk)==-1) continue;
3054 alreadyStored = kFALSE;
3055 for (jj=0; jj<dummyCounter+1; jj++)
3056 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk));
3058 if (alreadyStored) continue;
3059 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
3060 AliWarning(" Siamo al limite!");
3065 tracks[dummyCounter] = selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk);
3070 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
3071 if (selectedDigit[adesso4][fourthIndex]->GetTrackLabel(kk)==-1) continue;
3074 alreadyStored = kFALSE;
3075 for (jj=0; jj<dummyCounter+1; jj++)
3076 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso4][fourthIndex]->GetTrackLabel(kk));
3078 if (alreadyStored) continue;
3079 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
3080 AliWarning(" Siamo al limite!");
3085 tracks[dummyCounter] = selectedDigit[adesso4][fourthIndex]->GetTrackLabel(kk);
3092 AliTOFcluster *tofCluster =
3093 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
3094 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
3095 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
3096 InsertCluster(tofCluster);
3098 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",
3099 volIdClus, posClus[0], posClus[1], posClus[2],
3100 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
3101 tracks[0], tracks[1], tracks[2],
3102 det[0], det[1], det[2], det[3], det[4],
3103 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
3104 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
3109 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
3113 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
3117 fTOFdigitMap->ResetDigitNumber(vol3,selectedDigit[adesso3][thirdIndex]->GetIndex());
3121 fTOFdigitMap->ResetDigitNumber(vol4,selectedDigit[adesso4][fourthIndex]->GetIndex());
3124 } // close loop on fourth digit
3126 } // close loop on third digit
3128 } // close loop on second digit
3130 } // close loop on first digit
3136 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
3137 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
3138 selectedDigit[ii][jj] = 0x0;
3142 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++) {
3143 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
3144 delete [] selectedDigit[ii][jj];
3145 selectedDigit[ii][jj] = 0x0;
3147 delete [] selectedDigit[ii];
3148 selectedDigit[ii] = 0x0;
3150 delete [] selectedDigit;
3151 selectedDigit = 0x0;
3154 //_____________________________________________________________________________
3156 Int_t AliTOFClusterFinderV1::InsertCluster(AliTOFcluster *tofCluster)
3159 // This function adds a TOF cluster to the array of TOF clusters
3160 // sorted in Z, i.e. fTofClusters
3163 if (fNumberOfTofClusters==kTofMaxCluster) {
3164 AliError("Too many clusters !");
3168 if (fNumberOfTofClusters==0) {
3169 fTofClusters[fNumberOfTofClusters++] = tofCluster;
3173 Int_t ii = FindClusterIndex(tofCluster->GetZ());
3174 memmove(fTofClusters+ii+1 ,fTofClusters+ii,(fNumberOfTofClusters-ii)*sizeof(AliTOFcluster*));
3175 fTofClusters[ii] = tofCluster;
3176 fNumberOfTofClusters++;
3181 //_____________________________________________________________________________
3183 Int_t AliTOFClusterFinderV1::FindClusterIndex(Double_t z) const
3186 // This function returns the index of the nearest cluster in z
3189 if (fNumberOfTofClusters==0) return 0;
3190 if (z <= fTofClusters[0]->GetZ()) return 0;
3191 if (z > fTofClusters[fNumberOfTofClusters-1]->GetZ()) return fNumberOfTofClusters;
3192 Int_t b = 0, e = fNumberOfTofClusters-1, m = (b+e)/2;
3193 for (; b<e; m=(b+e)/2) {
3194 if (z > fTofClusters[m]->GetZ()) b=m+1;
3201 //_____________________________________________________________________________
3203 void AliTOFClusterFinderV1::ResetRecpoint()
3206 // Clear the list of reconstructed points
3209 fNumberOfTofClusters = 0;
3210 if (fRecPoints) fRecPoints->Clear();
3213 //_____________________________________________________________________________
3215 void AliTOFClusterFinderV1::ResetDigits()
3218 // Clear the list of digits
3221 fNumberOfTofDigits = 0;
3222 if (fDigits) fDigits->Clear();
3225 //_____________________________________________________________________________
3226 //UShort_t AliTOFClusterFinderV1::GetClusterVolIndex(Int_t *ind) const
3229 // Get the volume ID to retrieve the l2t transformation
3232 // Detector numbering scheme
3234 Int_t nSector = AliTOFGeometry::NSectors();
3235 Int_t nPlate = AliTOFGeometry::NPlates();
3236 Int_t nStripA = AliTOFGeometry::NStripA();
3237 Int_t nStripB = AliTOFGeometry::NStripB();
3238 Int_t nStripC = AliTOFGeometry::NStripC();
3240 Int_t isector =ind[0];
3241 if (isector >= nSector)
3242 AliError(Form("Wrong sector number in TOF (%d) !", isector));
3243 Int_t iplate = ind[1];
3244 if (iplate >= nPlate)
3245 AliError(Form("Wrong plate number in TOF (%d) !", iplate));
3246 Int_t istrip = ind[2];
3248 Int_t stripOffset = 0;
3254 stripOffset = nStripC;
3257 stripOffset = nStripC+nStripB;
3260 stripOffset = nStripC+nStripB+nStripA;
3263 stripOffset = nStripC+nStripB+nStripA+nStripB;
3266 AliError(Form("Wrong plate number in TOF (%d) !", iplate));
3270 Int_t index= (2*(nStripC+nStripB)+nStripA)*isector +
3274 UShort_t volIndex = AliGeomManager::LayerToVolUID(AliGeomManager::kTOF, index);
3279 //_____________________________________________________________________________
3281 void AliTOFClusterFinderV1::GetClusterPars(Int_t *ind, Double_t* pos, Double_t* cov) const
3284 // Starting from the volume indices (ind[5]), for a cluster coming from
3285 // a isolated digits, this function returns:
3286 // the cluster position (pos),
3287 // the cluster covariance matrix elements (cov)
3291 //we now go in the system of the strip: determine the local coordinates
3294 // 47---------------------------------------------------0 ^ z
3295 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 1 |
3296 // ----------------------------------------------------- | y going outwards
3297 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 0 | par[0]=0;
3299 // ----------------------------------------------------- |
3300 // x <-----------------------------------------------------
3302 //move to the tracking ref system
3303 Double_t lpos[3] = { (ind[4]-23.5)*AliTOFGeometry::XPad(),
3305 (ind[3]- 0.5)*AliTOFGeometry::ZPad() };
3306 AliDebug(1, Form(" %f %f %f", lpos[0], lpos[1], lpos[2]));
3309 UShort_t volIndex = fTOFGeometry->GetAliSensVolIndex(ind[0],ind[1],ind[2]);
3310 //UShort_t volIndex = GetClusterVolIndex(ind);
3311 const TGeoHMatrix *l2t = AliGeomManager::GetTracking2LocalMatrix(volIndex);
3313 // Get the position in the track ref system
3315 l2t->MasterToLocal(lpos,tpos);
3320 //Get the cluster covariance in the track ref system
3322 for (Int_t ii=0; ii<9; ii++) lcov[ii] = 0.;
3324 //cluster covariance in the local system:
3329 lcov[4] = 0.42*0.42/3.;
3330 // = ( 5*0.025 (gas gaps thikness)
3331 // + 4*0.040 (internal glasses thickness)
3332 // + 0.5*0.160 (internl PCB)
3333 // + 1*0.055 (external red glass))
3336 lcov[0] = 0.499678;//AliTOFGeometry::XPad()*AliTOFGeometry::XPad()/12.;
3337 lcov[8] = 0.992429;//AliTOFGeometry::ZPad()*AliTOFGeometry::ZPad()/12.;
3339 //cluster covariance in the tracking system:
3341 m.SetRotation(lcov);
3343 m.MultiplyLeft(&l2t->Inverse());
3344 Double_t *tcov = m.GetRotationMatrix();
3345 cov[0] = tcov[0]; cov[1] = tcov[1]; cov[2] = tcov[2];
3346 cov[3] = tcov[4]; cov[4] = tcov[5]; cov[5] = tcov[8];
3351 //_____________________________________________________________________________
3353 void AliTOFClusterFinderV1::GetClusterPars(/*Bool_t check,*/ Int_t counter,
3354 Int_t **ind, Double_t *weight,
3355 Double_t *pos, Double_t *cov) const
3359 // the volumes indices (ind[counter][5]), for a
3360 // cluster coming from a collection of 'counter'
3362 // the volumes weights (weight[counter]), -controlled
3363 // by the 'check' variable control-, for a cluster
3364 // coming from a collection of 'counter' digits,
3365 // the cluster position (pos),
3366 // this function returns:
3367 // the covariance matrix elements (cov) for the found cluster
3371 // we now go in the system of the strip: determine the local coordinates
3373 // 47---------------------------------------------------0 ^ z
3374 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 1 |
3375 // ----------------------------------------------------- | y going outwards
3376 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 0 | par[0]=0;
3378 // ----------------------------------------------------- |
3379 // x <-----------------------------------------------------
3381 for (Int_t ii=0; ii<counter; ii++)
3382 AliDebug(1, Form(" %2d %2d %1d %2d %1d %2d ",
3383 ii, ind[ii][0], ind[ii][1], ind[ii][2], ind[ii][3], ind[ii][4]));
3385 Float_t posF[3]; for (Int_t ii=0; ii<3; ii++) posF[ii] = (Float_t)pos[ii];
3386 AliDebug(1, Form(" %f %f %f", pos[0], pos[1], pos[2]));
3388 Int_t detClus[5] = {-1, -1, -1, -1, -1};
3389 fTOFGeometry->GetDetID(posF, detClus);
3392 UShort_t volIndex = fTOFGeometry->GetAliSensVolIndex(detClus[0],detClus[1],detClus[2]);
3393 //UShort_t volIndex = GetClusterVolIndex(detClus);
3394 AliDebug(1, Form(" %2d %1d %2d %1d %2d %7i",
3395 detClus[0], detClus[1], detClus[2], detClus[3], detClus[4], volIndex));
3397 // Get the position in the TOF strip ref system
3398 const TGeoHMatrix *alice2strip = AliGeomManager::GetOrigGlobalMatrix(volIndex);
3399 Double_t ppos[3] = {-1, -1, -1};
3400 alice2strip->MasterToLocal(pos,ppos);
3401 AliDebug(1, Form(" %f %f %f", ppos[0], ppos[1], ppos[2]));
3404 // Get the position in the tracking ref system
3405 const TGeoHMatrix *g2l = AliGeomManager::GetTracking2LocalMatrix(volIndex);
3406 Double_t lpos[3] = {-1, -1, -1};
3407 g2l->MasterToLocal(ppos,lpos);
3408 AliDebug(1, Form(" %f %f %f", lpos[0], lpos[1], lpos[2]));
3409 for (Int_t ii=0; ii<3; ii++) pos[ii] = lpos[ii];
3411 //Get the cluster covariance in the track ref system
3413 for (Int_t ii=0; ii<9; ii++) lcov[ii] = 0.;
3415 //cluster covariance in the local system:
3420 // Evaluation of the ovariance matrix elements
3421 TOFclusterError(/*check,*/ counter, ind, weight, ppos, lcov);
3423 AliDebug(1, Form("lcov[0] = %f, lcov[8] = %f", lcov[0], lcov[8]));
3425 //cluster covariance in the tracking system:
3427 m.SetRotation(lcov);
3429 m.MultiplyLeft(&g2l->Inverse());
3430 Double_t *tcov = m.GetRotationMatrix();
3431 cov[0] = tcov[0]; cov[1] = tcov[1]; cov[2] = tcov[2];
3432 cov[3] = tcov[4]; cov[4] = tcov[5]; cov[5] = tcov[8];
3437 //_____________________________________________________________________________
3439 void AliTOFClusterFinderV1::TOFclusterError(/*Bool_t check,*/ Int_t counter,
3440 Int_t **ind, Double_t *weight,
3441 Double_t ppos[], Double_t lcov[]) const
3447 //lcov[4] = 0.42*0.42/3.; // cm2
3448 // = ( 5*0.025 (gas gaps thikness)
3449 // + 4*0.040 (internal glasses thickness)
3450 // + 0.5*0.160 (internl PCB)
3451 // + 1*0.055 (external red glass))
3454 Float_t *delta2X = new Float_t[counter];
3455 for (Int_t ii=0; ii<counter; ii++)
3457 ((ind[ii][4]-23.5)*AliTOFGeometry::XPad() - ppos[0])*((ind[ii][4]-23.5)*AliTOFGeometry::XPad() - ppos[0]);
3459 Float_t *delta2Z = new Float_t[counter];
3460 for (Int_t ii=0; ii<counter; ii++)
3462 ((ind[ii][3]- 0.5)*AliTOFGeometry::ZPad() - ppos[2])*((ind[ii][3]- 0.5)*AliTOFGeometry::ZPad() - ppos[2]);
3464 for (Int_t ii=0; ii<counter; ii++)
3465 AliDebug(1, Form("x[%d] = %f, z[%d] = %f, weight[%d] = %f",
3466 ii, (ind[ii][4]-23.5)*AliTOFGeometry::XPad(),
3467 ii, (ind[ii][3]- 0.5)*AliTOFGeometry::ZPad(),
3470 AliDebug(1, Form("xMean = %f, zMean = %f",ppos[0], ppos[2]));
3478 if (ind[0][3]==ind[1][3] && TMath::Abs(ind[0][4]-ind[1][4])==1) { //
3480 lcov[8] = 1.02039; // cm2
3481 lcov[0] = 0.0379409; // cm2
3484 lcov[0] = 0.5*0.5; // cm2
3486 if (weight[0]==weight[1])
3487 lcov[0] = 0.0379409; // cm2
3489 lcov[0] = TMath::Mean(counter, delta2X, weight); // cm2
3495 else if (ind[0][4]==ind[1][4] && TMath::Abs(ind[0][3]-ind[1][3])==1) {//
3497 lcov[0] = 0.505499; // cm2
3498 lcov[8] = 0.0422046; // cm2
3501 lcov[8] = 0.5*0.5; // cm2
3503 if (weight[0]==weight[1])
3504 lcov[8] = 0.0422046; // cm2
3506 lcov[8] = TMath::Mean(counter, delta2Z, weight); // cm2
3515 lcov[0] = 0.0290677; // cm2
3516 lcov[8] = 0.0569726; // cm2
3519 lcov[0] = 0.5*0.5; // cm2
3520 lcov[8] = 0.5*0.5; // cm2
3523 if (weight[0]==weight[1] && weight[0]==weight[2]) {
3524 lcov[0] = 0.0290677; // cm2
3525 lcov[8] = 0.0569726; // cm2
3528 lcov[0] = TMath::Mean(counter, delta2X, weight); // cm2
3529 lcov[8] = TMath::Mean(counter, delta2Z, weight); // cm2
3538 lcov[0] = 0.0223807; // cm2
3539 lcov[8] = 0.0438662; // cm2
3542 lcov[0] = 0.5*0.5; // cm2
3543 lcov[8] = 0.5*0.5; // cm2
3546 if (weight[0]==weight[1] && weight[0]==weight[2] && weight[0]==weight[3]) {
3547 lcov[0] = 0.0223807; // cm2
3548 lcov[8] = 0.0438662; // cm2
3551 lcov[0] = TMath::Mean(counter, delta2X, weight); // cm2
3552 lcov[8] = TMath::Mean(counter, delta2Z, weight); // cm2
3566 //_____________________________________________________________________________
3568 Bool_t AliTOFClusterFinderV1::MakeSlewingCorrection(Int_t *detectorIndex,
3574 // This funtion makes the following:
3576 // - if at least one of the three status (Pulser/Noise/HW) is
3577 // bad, is sets the status of electronic channel, corresponding to the
3578 // volume identified by detectorIndex, as kFALSE;
3579 // - if offline calibration is in the valid status, it performs the
3580 // slewing correction. In particular, by taking into account:
3581 // * the measured tot and tof values (tofDigitToT and tofDigitTdc,
3583 // * the six parameters of 5th order polynomial used
3584 // to fit the tofVStot scatter plot,
3585 // it returns the corrected tof value, i.e. tdcCorr value.
3588 Bool_t output = kTRUE;
3593 //AliInfo(" Calibrating TOF Digits: ");
3595 AliTOFChannelOnlineArray *calDelay = fTOFcalib->GetTOFOnlineDelay();
3596 AliTOFChannelOnlineStatusArray *calStatus = fTOFcalib->GetTOFOnlineStatus();
3598 TObjArray *calTOFArrayOffline = fTOFcalib->GetTOFCalArrayOffline();
3600 Int_t index = AliTOFGeometry::GetIndex(detectorIndex);
3602 UChar_t statusPulser = calStatus->GetPulserStatus(index);
3603 UChar_t statusNoise = calStatus->GetNoiseStatus(index);
3604 UChar_t statusHW = calStatus->GetHWStatus(index);
3605 UChar_t status = calStatus->GetStatus(index);
3607 //check the status, also unknown is fine!!!!!!!
3609 AliDebug(2, Form(" Status for channel %d = %d",index, (Int_t)status));
3610 if((statusPulser & AliTOFChannelOnlineStatusArray::kTOFPulserBad)==(AliTOFChannelOnlineStatusArray::kTOFPulserBad)||(statusNoise & AliTOFChannelOnlineStatusArray::kTOFNoiseBad)==(AliTOFChannelOnlineStatusArray::kTOFNoiseBad)||(statusHW & AliTOFChannelOnlineStatusArray::kTOFHWBad)==(AliTOFChannelOnlineStatusArray::kTOFHWBad)){
3611 AliDebug(2, Form(" Bad Status for channel %d",index));
3612 //fTofClusters[ii]->SetStatus(kFALSE); //odd convention, to avoid conflict with calibration objects currently in the db (temporary solution).
3616 AliDebug(2, Form(" Good Status for channel %d",index));
3619 if (fCalibrateTOFtimes) { // AdC
3621 // Get Rough channel online equalization
3622 Double_t roughDelay = (Double_t)calDelay->GetDelay(index); // in ns
3623 AliDebug(2,Form(" channel delay (ns) = %f", roughDelay));
3624 // Get Refined channel offline calibration parameters
3625 TString validity = (TString)fTOFcalib->GetOfflineValidity();
3626 if (validity.CompareTo("valid")==0) {
3627 AliTOFChannelOffline * calChannelOffline = (AliTOFChannelOffline*)calTOFArrayOffline->At(index);
3629 for (jj = 0; jj<6; jj++)
3630 par[jj] = (Double_t)calChannelOffline->GetSlewPar(jj);
3632 AliDebug(2,Form(" Calib Pars = %f, %f, %f, %f, %f, %f ",par[0],par[1],par[2],par[3],par[4],par[5]));
3633 AliDebug(2,Form(" The ToT and Time, uncorr (counts) = %d , %d", tofDigitToT, tofDigitTdc));
3634 Double_t tToT = (Double_t)(tofDigitToT*AliTOFGeometry::ToTBinWidth());
3635 tToT*=1.E-3; //ToT in ns
3636 AliDebug(2,Form(" The ToT and Time, uncorr (ns)= %e, %e",tofDigitTdc*AliTOFGeometry::TdcBinWidth()*1.E-3,tToT));
3637 timeCorr = par[0] + tToT*(par[1] + tToT*(par[2] + tToT*(par[3] + tToT*(par[4] + tToT*par[5])))); // the time correction (ns)
3640 timeCorr = roughDelay; // correction in ns
3642 AliDebug(2,Form(" The ToT and Time, uncorr (ns)= %e, %e",tofDigitTdc*AliTOFGeometry::TdcBinWidth()*1.E-3,tofDigitToT*AliTOFGeometry::ToTBinWidth()));
3643 AliDebug(2,Form(" The time correction (ns) = %f", timeCorr));
3644 timeCorr = (Double_t)(tofDigitTdc)*AliTOFGeometry::TdcBinWidth()*1.E-3-timeCorr;//redefine the time
3646 AliDebug(2,Form(" The channel time, corr (ps)= %e",timeCorr ));
3647 //tdcCorr = (Int_t)(timeCorr/AliTOFGeometry::TdcBinWidth()); //the corrected time (tdc counts)
3648 tdcCorr = TMath::Nint(timeCorr/AliTOFGeometry::TdcBinWidth()); //the corrected time (tdc counts)
3655 //______________________________________________________________________________
3657 void AliTOFClusterFinderV1::Digits2RecPoints(Int_t iEvent)
3660 // Converts digits to recpoints for TOF
3663 TStopwatch stopwatch;
3666 fRunLoader->GetEvent(iEvent);
3668 AliLoader *localTOFLoader = (AliLoader*)fRunLoader->GetLoader("TOFLoader");
3670 TTree * localTreeD = (TTree*)localTOFLoader->TreeD();
3671 if (localTreeD == 0x0) {
3672 AliFatal("Can not get TreeD");
3676 TBranch *branch = localTreeD->GetBranch("TOF");
3678 AliError("Can't get the branch with the TOF digits !");
3682 TTree *localTreeR = (TTree*)localTOFLoader->TreeR();
3683 if (localTreeR == 0x0)
3685 localTOFLoader->MakeTree("R");
3686 localTreeR = localTOFLoader->TreeR();
3689 Digits2RecPoints(localTreeD, localTreeR);
3691 //localTOFLoader = fRunLoader->GetLoader("TOFLoader");
3692 localTOFLoader->WriteRecPoints("OVERWRITE");
3694 AliDebug(1, Form("Execution time to read TOF digits and to write TOF clusters for the event number %d: R:%.4fs C:%.4fs",
3695 iEvent, stopwatch.RealTime(),stopwatch.CpuTime()));
3698 //______________________________________________________________________________
3700 void AliTOFClusterFinderV1::Digits2RecPoints(Int_t iEvent, AliRawReader *rawReader)
3703 // Converts RAW data to recpoints for TOF
3706 TStopwatch stopwatch;
3709 fRunLoader->GetEvent(iEvent);
3711 AliDebug(2,Form(" Event number %2d ", iEvent));
3713 AliLoader *localTOFLoader = (AliLoader*)fRunLoader->GetLoader("TOFLoader");
3715 TTree *localTreeR = localTOFLoader->TreeR();
3717 if (localTreeR == 0x0){
3718 localTOFLoader->MakeTree("R");
3719 localTreeR = localTOFLoader->TreeR();
3722 Digits2RecPoints(rawReader, localTreeR);
3724 AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters for the event number %d: R:%.4fs C:%.4fs",
3725 iEvent, stopwatch.RealTime(),stopwatch.CpuTime()));
3728 //______________________________________________________________________________
3730 void AliTOFClusterFinderV1::Raw2Digits(Int_t iEvent, AliRawReader *rawReader)
3733 // Converts RAW data to MC digits for TOF
3737 TStopwatch stopwatch;
3740 fRunLoader->GetEvent(iEvent);
3742 AliDebug(2,Form(" Event number %2d ", iEvent));
3744 AliLoader *localTOFLoader = (AliLoader*)fRunLoader->GetLoader("TOFLoader");
3746 TTree *localTreeD = localTOFLoader->TreeD();
3748 if (localTreeD == 0x0){
3749 localTOFLoader->MakeTree("D");
3750 localTreeD = localTOFLoader->TreeD();
3753 Raw2Digits(rawReader, localTreeD);
3755 AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters for the event number %d: R:%.4fs C:%.4fs",
3756 iEvent, stopwatch.RealTime(),stopwatch.CpuTime()));
3759 //______________________________________________________________________________
3761 void AliTOFClusterFinderV1::AverageCalculations(Int_t number, Float_t *interestingX,
3762 Float_t *interestingY, Float_t *interestingZ,
3763 Double_t *interestingTOF, Double_t *interestingTOT,
3764 Double_t *interestingADC, Double_t *interestingWeight,
3765 Int_t *parTOF, Double_t *posClus, Bool_t &check)
3768 // Calculates the mean values for cluster position (x,y,z),
3769 // TOF charge and time
3772 Double_t tofAverage = 0.;
3773 Double_t totAverage = 0.;
3774 Double_t adcAverage = 0.;
3778 for (ii=number-1; ii>=0; ii--) check=check||(interestingWeight[ii]==0 || interestingWeight[ii]==-1);
3782 posClus[0] = TMath::Mean(number, interestingX);
3783 posClus[1] = TMath::Mean(number, interestingY);
3784 posClus[2] = TMath::Mean(number, interestingZ);
3785 tofAverage = TMath::Mean(number, interestingTOF);
3786 totAverage = TMath::Mean(number, interestingTOT);
3787 adcAverage = TMath::Mean(number, interestingADC);
3792 posClus[0] = TMath::Mean(number, interestingX, interestingWeight);
3793 posClus[1] = TMath::Mean(number, interestingY, interestingWeight);
3794 posClus[2] = TMath::Mean(number, interestingZ, interestingWeight);
3795 tofAverage = TMath::Mean(number, interestingTOF, interestingWeight);
3796 totAverage = TMath::Mean(number, interestingTOT, interestingWeight);
3797 adcAverage = TMath::Mean(number, interestingADC, interestingWeight);
3801 parTOF[0] = Int_t(tofAverage);
3802 parTOF[1] = Int_t(totAverage);
3803 parTOF[2] = Int_t(adcAverage);
3804 parTOF[3] = Int_t(tofAverage);//tofND
3805 parTOF[4] = Int_t(tofAverage);//tofRAW