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 "AliLoader.h"
48 #include "AliRunLoader.h"
49 #include "AliGeomManager.h"
51 #include "AliTOFcalib.h"
52 #include "AliTOFChannelOnlineArray.h"
53 #include "AliTOFChannelOnlineStatusArray.h"
54 #include "AliTOFChannelOffline.h"
55 #include "AliTOFClusterFinderV1.h"
56 #include "AliTOFcluster.h"
57 #include "AliTOFdigit.h"
58 #include "AliTOFDigitMap.h"
59 #include "AliTOFrawData.h"
60 #include "AliTOFReconstructor.h"
61 #include "AliTOFRecoParam.h"
67 ClassImp(AliTOFClusterFinderV1)
69 //_____________________________________________________________________________
70 AliTOFClusterFinderV1::AliTOFClusterFinderV1(AliTOFcalib *calib):
71 TNamed("AliTOFClusterFinderV1",""),
73 fDigits(new TClonesArray("AliTOFdigit", 4000)),
74 fRecPoints(new TClonesArray("AliTOFcluster", 4000)),
75 fNumberOfTofClusters(0),
76 fNumberOfTofDigits(0),
77 fkRecoParam(0),//AliTOFReconstructor::GetRecoParam()),
78 fMaxDeltaTime(0),//fkRecoParam->GetMaxDeltaTime()),
82 fTOFdigitMap(new AliTOFDigitMap()),
83 fTOFGeometry(new AliTOFGeometry()),
84 fTOFdigits(new TTree()),
85 fTOFRawStream(AliTOFRawStream()),
92 for (Int_t ii=0; ii<kTofMaxCluster; ii++) fTofClusters[ii]=0x0;
94 if (AliTOFReconstructor::GetRecoParam()) {
95 fkRecoParam = AliTOFReconstructor::GetRecoParam();
96 fMaxDeltaTime = fkRecoParam->GetMaxDeltaTime();
101 TString validity = (TString)fTOFcalib->GetOfflineValidity();
102 if (validity.CompareTo("valid")==0) {
103 AliInfo(Form(" validity = %s - Using offline calibration parameters", validity.Data()));
105 AliInfo(Form(" validity = %s - Using online calibration parameters", validity.Data()));
110 //_____________________________________________________________________________
111 AliTOFClusterFinderV1::AliTOFClusterFinderV1(AliRunLoader* runLoader, AliTOFcalib *calib):
112 TNamed("AliTOFClusterFinderV1",""),
113 fRunLoader(runLoader),
114 fDigits(new TClonesArray("AliTOFdigit", 4000)),
115 fRecPoints(new TClonesArray("AliTOFcluster", 4000)),
116 fNumberOfTofClusters(0),
117 fNumberOfTofDigits(0),
118 fkRecoParam(0),//AliTOFReconstructor::GetRecoParam()),
119 fMaxDeltaTime(0),//fkRecoParam->GetMaxDeltaTime()),
123 fTOFdigitMap(new AliTOFDigitMap()),
124 fTOFGeometry(new AliTOFGeometry()),
125 fTOFdigits(new TTree()),
126 fTOFRawStream(AliTOFRawStream()),
127 fCalibrateTOFtimes(1)
133 for (Int_t ii=0; ii<kTofMaxCluster; ii++) fTofClusters[ii]=0x0;
135 if (AliTOFReconstructor::GetRecoParam()) {
136 fkRecoParam = AliTOFReconstructor::GetRecoParam();
137 fMaxDeltaTime = fkRecoParam->GetMaxDeltaTime();
142 TString validity = (TString)fTOFcalib->GetOfflineValidity();
143 if (validity.CompareTo("valid")==0) {
144 AliInfo(Form(" validity = %s - Using offline calibration parameters", validity.Data()));
146 AliInfo(Form(" validity = %s - Using online calibration parameters", validity.Data()));
150 //_____________________________________________________________________________
152 AliTOFClusterFinderV1::AliTOFClusterFinderV1(const AliTOFClusterFinderV1 &source)
155 fDigits(source.fDigits),
156 fRecPoints(source.fRecPoints),
157 fNumberOfTofClusters(0),
158 fNumberOfTofDigits(0),
159 fkRecoParam(0),//AliTOFReconstructor::GetRecoParam()),
160 fMaxDeltaTime(0),//fkRecoParam->GetMaxDeltaTime()),
162 fDecoderVersion(source.fDecoderVersion),
163 fTOFcalib(source.fTOFcalib),
164 fTOFdigitMap(new AliTOFDigitMap()),
165 fTOFGeometry(new AliTOFGeometry()),
166 fTOFdigits(source.fTOFdigits),
167 fTOFRawStream(source.fTOFRawStream),
168 fCalibrateTOFtimes(1)
172 for (Int_t ii=0; ii<kTofMaxCluster; ii++) fTofClusters[ii]=source.fTofClusters[ii];
174 if (AliTOFReconstructor::GetRecoParam()) {
175 fkRecoParam = AliTOFReconstructor::GetRecoParam();
176 fMaxDeltaTime = fkRecoParam->GetMaxDeltaTime();
182 //_____________________________________________________________________________
184 AliTOFClusterFinderV1& AliTOFClusterFinderV1::operator=(const AliTOFClusterFinderV1 &source)
191 TObject::operator=(source);
192 for (Int_t ii=0; ii<kTofMaxCluster; ii++) fTofClusters[ii]=source.fTofClusters[ii];
193 fDigits=source.fDigits;
194 fRecPoints=source.fRecPoints;
195 fVerbose=source.fVerbose;
196 fDecoderVersion=source.fDecoderVersion;
197 fTOFcalib=source.fTOFcalib;
198 fTOFdigitMap=source.fTOFdigitMap;
199 fTOFGeometry=source.fTOFGeometry;
200 fTOFdigits=source.fTOFdigits;
201 fTOFRawStream=source.fTOFRawStream;
202 fCalibrateTOFtimes=source.fCalibrateTOFtimes;
206 //_____________________________________________________________________________
208 AliTOFClusterFinderV1::~AliTOFClusterFinderV1()
223 fRecPoints->Delete();
234 //if (fTofClusters || fNumberOfTofClusters) {
235 if (fNumberOfTofClusters) {
236 for (Int_t ii=0; ii<fNumberOfTofClusters; ii++)
237 if (fTofClusters[ii]) fTofClusters[ii]->Delete();
238 fNumberOfTofClusters = 0;
242 //_____________________________________________________________________________
244 void AliTOFClusterFinderV1::Digits2RecPoints(TTree* digitsTree, TTree* clusterTree)
247 // Converts digits to recPoints for TOF
250 TStopwatch stopwatch;
256 TClonesArray &aDigits = *fDigits;
258 if (digitsTree == 0x0) {
259 AliFatal("Can not get TreeD for TOF");
263 TBranch *branch = digitsTree->GetBranch("TOF");
265 AliError("Can not get branch with the TOF digits !");
269 TClonesArray staticDigits("AliTOFdigit",10000);
270 staticDigits.Clear();
271 TClonesArray *digits = &staticDigits;
272 branch->SetAddress(&digits);
273 digitsTree->GetEvent(0);
274 AliDebug(1,Form("Number of TOF digits: %d", digits->GetEntriesFast()));
276 AliTOFdigit *tofDigit;
279 Int_t detectorIndex[5];
280 for (jj=0; jj<5; jj++) detectorIndex[jj] = -1;
282 for (jj=0; jj<4; jj++) info[jj] = -1;
288 Bool_t status = kTRUE;
290 AliDebug(1," Calibrating TOF Digits");
292 TString validity = (TString)fTOFcalib->GetOfflineValidity();
293 if (validity.CompareTo("valid")==0) {
294 AliInfo(Form(" validity = %s - Using offline calibration parameters", validity.Data()));
296 AliInfo(Form(" validity = %s - Using online calibration parameters", validity.Data()));
300 for (ii=0; ii<digits->GetEntriesFast(); ii++) {
301 tofDigit = (AliTOFdigit*)digits->UncheckedAt(ii);
302 detectorIndex[0] = tofDigit->GetSector();
303 detectorIndex[1] = tofDigit->GetPlate();
304 detectorIndex[2] = tofDigit->GetStrip();
305 detectorIndex[3] = tofDigit->GetPadz();
306 detectorIndex[4] = tofDigit->GetPadx();
308 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
309 if (detectorIndex[1]==2) { // plate with holes
315 tdcCorr = tofDigit->GetTdc();
316 status = MakeSlewingCorrection(detectorIndex, tofDigit->GetToT(), tofDigit->GetTdc(), tdcCorr);
318 for (jj=0; jj<4; jj++) info[jj] = -1;
319 info[0] = tdcCorr;//tofDigit->GetTdc();
320 info[1] = tofDigit->GetAdc();
321 info[2] = tofDigit->GetToT();
322 info[3] = tofDigit->GetTdcND();//tofDigit->GetTdc();//
323 tracks = tofDigit->GetTracks();
325 dummy = detectorIndex[3];
326 detectorIndex[3] = detectorIndex[4];//padx
327 detectorIndex[4] = dummy;//padz
328 last = fDigits->GetEntriesFast();
329 new (aDigits[last]) AliTOFdigit(tracks, detectorIndex, info);
330 if (status) fTOFdigitMap->AddDigit(detectorIndex, last);
332 AliDebug(2, Form(" Digits reading %2d -> %2d %1d %2d %1d %2d (%d, %d, %d)",
334 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[3], detectorIndex[4],
335 info[0], info[1], info[3]));
339 fNumberOfTofDigits = fDigits->GetEntriesFast();
343 Int_t bufsize = 32000;
344 clusterTree->Branch("TOF", &fRecPoints, bufsize);
349 AliDebug(1,Form("Number of found clusters: %d", fNumberOfTofClusters));
353 fTOFdigitMap->Clear();
357 AliDebug(1,Form("Execution time to read TOF digits and to write TOF clusters : R:%.4fs C:%.4fs",
358 stopwatch.RealTime(),stopwatch.CpuTime()));
360 if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
363 //_____________________________________________________________________________
365 void AliTOFClusterFinderV1::Digits2RecPoints(AliRawReader *rawReader, TTree *clustersTree)
368 // Converts raw data to recPoints for TOF
371 TStopwatch stopwatch;
375 AliDebug(2, "TreeD re-creation");
376 //TTree *digitsTree = new TTree();
377 //Raw2Digits(rawReader, digitsTree);
379 Raw2Digits(rawReader, fTOFdigits);
381 AliDebug(1,Form("Number of TOF digits: %d", fNumberOfTofDigits));
384 Int_t bufsize = 32000;
385 clustersTree->Branch("TOF", &fRecPoints, bufsize);
388 clustersTree->Fill();
390 AliDebug(1,Form("Number of found clusters: %d", fNumberOfTofClusters));
394 fTOFdigitMap->Clear();
398 AliDebug(1,Form("Execution time to read TOF raw data and to write TOF clusters : R:%.4fs C:%.4fs",
399 stopwatch.RealTime(),stopwatch.CpuTime()));
403 //_____________________________________________________________________________
405 void AliTOFClusterFinderV1::Raw2Digits(AliRawReader *rawReader, TTree* digitsTree)
408 // Converts raw data to digits for TOF
411 TStopwatch stopwatch;
416 const Int_t kMaxNumberOfTracksPerDigit = 3;
417 const Int_t kDDL = AliDAQ::NumberOfDdls("TOF");
419 digitsTree->Branch("TOF", &fDigits);
420 TClonesArray &aDigits = *fDigits;
422 fTOFRawStream.Clear();
423 fTOFRawStream.SetRawReader(rawReader);
426 if (fVerbose==2) ftxt.open("TOFdigitsRead.txt",ios::app);
428 TClonesArray staticRawData("AliTOFrawData",10000);
429 staticRawData.Clear();
430 TClonesArray * clonesRawData = &staticRawData;
433 Int_t detectorIndex[5] = {-1, -1, -1, -1, -1};
435 Int_t tracks[kMaxNumberOfTracksPerDigit];
436 for (Int_t ii=0; ii<kMaxNumberOfTracksPerDigit; ii++)
441 Bool_t status = kTRUE;
444 TString validity = (TString)fTOFcalib->GetOfflineValidity();
445 if (validity.CompareTo("valid")==0) {
446 AliInfo(Form(" validity = %s - Using offline calibration parameters", validity.Data()));
448 AliInfo(Form(" validity = %s - Using online calibration parameters", validity.Data()));
452 AliInfo("Using New Decoder");
456 for (indexDDL=0; indexDDL<kDDL; indexDDL++) {
460 fTOFRawStream.LoadRawDataBuffers(indexDDL,fVerbose);
461 else fTOFRawStream.LoadRawData(indexDDL);
463 clonesRawData = (TClonesArray*)fTOFRawStream.GetRawData();
464 if (clonesRawData->GetEntriesFast()!=0) AliDebug(2,Form(" TOF raw data number = %3d", clonesRawData->GetEntriesFast()));
465 for (iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
467 AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
469 //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
470 if (tofRawDatum->GetTOF()==-1) continue;
472 fTOFRawStream.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
473 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
476 dummy = detectorIndex[3];
477 detectorIndex[3] = detectorIndex[4];//padz
478 detectorIndex[4] = dummy;//padx
480 tdcCorr = tofRawDatum->GetTOF();
481 status = MakeSlewingCorrection(detectorIndex, tofRawDatum->GetTOT(), tofRawDatum->GetTOF(), tdcCorr);
484 digit[1] = tofRawDatum->GetTOT();
485 digit[2] = tofRawDatum->GetTOT();
486 digit[3] = -1;//tofRawDatum->GetTOF(); //tofND
488 dummy = detectorIndex[3];
489 detectorIndex[3] = detectorIndex[4];//padx
490 detectorIndex[4] = dummy;//padz
492 /* check valid index */
493 if (detectorIndex[0]==-1||detectorIndex[1]==-1||detectorIndex[2]==-1||detectorIndex[3]==-1||detectorIndex[4]==-1) continue;
495 // Do not reconstruct anything in the holes
496 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
497 if (detectorIndex[1]==2) { // plate with holes
503 last = fDigits->GetEntriesFast();
504 new (aDigits[last]) AliTOFdigit(tracks, detectorIndex, digit);
505 if (status) fTOFdigitMap->AddDigit(detectorIndex, last);
508 if (indexDDL<10) ftxt << " " << indexDDL;
509 else ftxt << " " << indexDDL;
510 if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM();
511 else ftxt << " " << tofRawDatum->GetTRM();
512 ftxt << " " << tofRawDatum->GetTRMchain();
513 if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC();
514 else ftxt << " " << tofRawDatum->GetTDC();
515 ftxt << " " << tofRawDatum->GetTDCchannel();
517 if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0];
518 else ftxt << " -> " << detectorIndex[0];
519 ftxt << " " << detectorIndex[1];
520 if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2];
521 else ftxt << " " << detectorIndex[2];
522 ftxt << " " << detectorIndex[4];
523 if (detectorIndex[4]<10) ftxt << " " << detectorIndex[3];
524 else ftxt << " " << detectorIndex[3];
526 if (digit[1]<10)ftxt << " " << digit[1];
527 else if (digit[1]>=10 && digit[1]<100) ftxt << " " << digit[1];
528 else ftxt << " " << digit[1];
529 if (digit[0]<10) ftxt << " " << digit[0] << endl;
530 else if (digit[0]>=10 && digit[0]<100) ftxt << " " << digit[0] << endl;
531 else if (digit[0]>=100 && digit[0]<1000) ftxt << " " << digit[0] << endl;
532 else ftxt << " " << digit[3] << endl;
535 AliDebug(2, Form(" Raw data reading %2d -> %2d %1d %2d %1d %2d (%d, %d, %d)",
537 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[4], detectorIndex[3],
538 digit[0], digit[1], digit[3]));
542 clonesRawData->Clear();
546 if (fVerbose==2) ftxt.close();
550 fNumberOfTofDigits = fDigits->GetEntries();
552 AliDebug(1, Form("Got %d TOF digits", fNumberOfTofDigits));
553 AliDebug(1, Form("Execution time to read TOF raw data and fill TOF digit tree : R:%.2fs C:%.2fs",
554 stopwatch.RealTime(),stopwatch.CpuTime()));
556 if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
559 //_____________________________________________________________________________
561 void AliTOFClusterFinderV1::FillRecPoint()
564 // Fill the global TClonesArray of AliTOFcluster objects,
573 for(Int_t iPlate=AliTOFGeometry::NPlates()-1; iPlate>=0; iPlate--) {
574 for(Int_t iStrip=AliTOFGeometry::NStrip(iPlate)-1; iStrip>=0; iStrip--) {
575 //for (Int_t iSector=AliTOFGeometry::NSectors()-1; iSector>=0; iSector--) {
576 for (Int_t iSector=0; iSector<AliTOFGeometry::NSectors(); iSector++) {
579 if (fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))
580 AliDebug(1,Form(" Number of TOF digits in (%2d,%1d,%2d) -> %d",
581 iSector,iPlate,iStrip,fTOFdigitMap->FilledCellsInStrip(iSector,iPlate,iStrip)));
583 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
584 FindClustersWithoutTOT(iSector, iPlate, iStrip); // clusters coming from digits without TOT measurement
586 if (fMaxDeltaTime>0) {
588 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
589 //if (fTOFdigitMap->FilledCellsInStrip(iSector,iPlate,iStrip)>=4)
590 FindClustersPerStrip(iSector, iPlate, iStrip, 4); // 4 pads clusters
591 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
593 dummy4 = fNumberOfTofClusters;
594 FindClustersPerStrip(iSector, iPlate, iStrip, 4); // 4 pads clusters
595 if (fNumberOfTofClusters!=dummy4)
596 AliDebug(2, Form(" (4): n1= %5d, n2 = %5d", dummy4, fNumberOfTofClusters));
599 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
600 FindClustersPerStrip(iSector, iPlate, iStrip, 3); // 3 pads clusters
601 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
603 dummy3 = fNumberOfTofClusters;
604 FindClustersPerStrip(iSector, iPlate, iStrip, 3); // 3 pads clusters
605 if (fNumberOfTofClusters!=dummy3)
606 AliDebug(2, Form(" (3): n1= %5d, n2 = %5d", dummy3, fNumberOfTofClusters));
609 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
610 FindClustersPerStrip(iSector, iPlate, iStrip, 2); // 2 pads clusters
611 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
613 dummy2 = fNumberOfTofClusters;
614 FindClustersPerStrip(iSector, iPlate, iStrip, 2); // 2 pads clusters
615 if (fNumberOfTofClusters!=dummy2)
616 AliDebug(2, Form(" (2): n1= %5d, n2 =%5d", dummy2, fNumberOfTofClusters));
619 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
620 dummy = fNumberOfTofClusters;
621 FindClusters34(iSector, iPlate, iStrip); // 3 pads clusters between 4 hit pads
622 if (fNumberOfTofClusters!=dummy)
623 AliDebug(2, Form(" (3 between 4): n1 = %5d, n2 = %5d", fNumberOfTofClusters, dummy));
626 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
627 dummy = fNumberOfTofClusters;
628 FindClusters23(iSector, iPlate, iStrip); // 2 pads clusters between 3 hit pads
629 if (fNumberOfTofClusters!=dummy)
630 AliDebug(2, Form(" (2 between 3): n1 = %5d, n2 = %5d", fNumberOfTofClusters, dummy));
632 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
633 dummy = fNumberOfTofClusters;
634 FindClusters24(iSector, iPlate, iStrip); // 2 pads clusters between 4 hit pads
635 if (fNumberOfTofClusters!=dummy)
636 AliDebug(2, Form(" (2 between 4): n1 = %5d, n2 = %5d", fNumberOfTofClusters, dummy));
639 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
640 dummy = fNumberOfTofClusters;
641 FindOnePadClusterPerStrip(iSector, iPlate, iStrip); // 1 pad clusters
642 if (fNumberOfTofClusters!=dummy)
643 AliDebug(2,Form(" (1): n1 = %5d, n2 = %5d", fNumberOfTofClusters, dummy));
645 if (fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip)>0)
646 AliDebug(2, Form(" (1): number of clusters = %5d (remaining digit %2d), -%2d %1d %2d-",
647 fNumberOfTofClusters, fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip),
648 iSector, iPlate, iStrip));
652 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
653 dummy = fNumberOfTofClusters;
654 FindOnePadClusterPerStrip(iSector, iPlate, iStrip); // 1 pad clusters
655 if (fNumberOfTofClusters!=dummy)
656 AliDebug(2,Form(" (1): n1 = %5d, n2 = %5d", fNumberOfTofClusters, dummy));
658 if (fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip)>0)
659 AliDebug(2, Form(" (1): number of clusters = %5d (remaining digit %2d), -%2d %1d %2d-",
660 fNumberOfTofClusters, fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip),
661 iSector, iPlate, iStrip));
671 TClonesArray &lRecPoints = *fRecPoints;
675 Int_t detectorIndex[5];
676 for (jj=0; jj<5; jj++) detectorIndex[jj] = -1;
678 for (jj=0; jj<7; jj++) parTOF[jj] = -1;
679 Int_t trackLabels[3];
680 for (jj=0; jj<3; jj++) trackLabels[jj] = -1;
681 Int_t digitIndex = -1;
682 Bool_t status = kTRUE;
684 for (ii=0; ii<3; ii++) posClus[ii] = 0.;
685 //Float_t covClus[6];
686 //for (ii=0; ii<6; ii++) covClus[ii] = 0.;
689 for (ii=0; ii<fNumberOfTofClusters; ii++) {
691 digitIndex = fTofClusters[ii]->GetIndex();
692 for(jj=0; jj<5; jj++) detectorIndex[jj] = fTofClusters[ii]->GetDetInd(jj);
693 volIdClus = fTOFGeometry->GetAliSensVolIndex(detectorIndex[0],detectorIndex[1],detectorIndex[2]);
694 //volIdClus = GetClusterVolIndex(detectorIndex);
695 for(jj=0; jj<3; jj++) trackLabels[jj] = fTofClusters[ii]->GetLabel(jj);
696 parTOF[0] = fTofClusters[ii]->GetTDC(); // TDC
697 parTOF[1] = fTofClusters[ii]->GetToT(); // TOT
698 parTOF[2] = fTofClusters[ii]->GetADC(); // ADC=TOT
699 parTOF[3] = fTofClusters[ii]->GetTDCND(); // TDCND
700 parTOF[4] = fTofClusters[ii]->GetTDCRAW();//RAW
703 status = fTofClusters[ii]->GetStatus();
705 posClus[0] = fTofClusters[ii]->GetX();
706 posClus[1] = fTofClusters[ii]->GetY();
707 posClus[2] = fTofClusters[ii]->GetZ();
709 //for (jj=0; jj<6; jj++) covClus[jj] = 0.;
710 //((AliCluster*)fTofClusters[ii])->GetGlobalCov(covClus);
712 new(lRecPoints[ii]) AliTOFcluster(volIdClus, (Double_t)posClus[0], (Double_t)posClus[1], (Double_t)posClus[2],
713 (Double_t)(fTofClusters[ii]->GetSigmaX2()),
714 (Double_t)(fTofClusters[ii]->GetSigmaXY()),
715 (Double_t)(fTofClusters[ii]->GetSigmaXZ()),
716 (Double_t)(fTofClusters[ii]->GetSigmaY2()),
717 (Double_t)(fTofClusters[ii]->GetSigmaYZ()),
718 (Double_t)(fTofClusters[ii]->GetSigmaZ2()),
719 //(Double_t)covClus[0], (Double_t)covClus[1], (Double_t)covClus[2],
720 //(Double_t)covClus[3], (Double_t)covClus[4], (Double_t)covClus[5],
721 trackLabels, detectorIndex, parTOF, status, digitIndex);
723 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",
724 ii, volIdClus, posClus[0], posClus[1], posClus[2],
725 fTofClusters[ii]->GetSigmaX2(),
726 fTofClusters[ii]->GetSigmaXY(),
727 fTofClusters[ii]->GetSigmaXZ(),
728 fTofClusters[ii]->GetSigmaY2(),
729 fTofClusters[ii]->GetSigmaYZ(),
730 fTofClusters[ii]->GetSigmaZ2(),
731 trackLabels[0], trackLabels[1], trackLabels[2],
732 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[3], detectorIndex[4],
733 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
734 status, digitIndex));
739 for (Int_t iSector=0; iSector<AliTOFGeometry::NSectors(); iSector++)
740 for(Int_t iPlate=0; iPlate<AliTOFGeometry::NPlates(); iPlate++) {
741 for(Int_t iStrip=0; iStrip<AliTOFGeometry::NStrip(iPlate); iStrip++) {
742 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
743 AliDebug(2, Form(" END %2d %1d %2d %5d",
744 iSector, iPlate, iStrip, fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip)));
749 //_____________________________________________________________________________
751 void AliTOFClusterFinderV1::FindOnePadClusterPerStrip(Int_t nSector,
756 // This function searches the isolated digits (stored in the fDigits object),
757 // to perform clusters (stored in the fTofClusters array).
758 // This research has been made by checking the fTOFdigitMap object,
759 // filled at digits/raw-data reading time.
762 const Int_t kMaxNumberOfTracksPerDigit = 3;
763 const Int_t kMaxNumberOfDigitsPerVolume = 10;
767 Int_t det[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padZ,padX
768 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padX,padZ
769 UShort_t volIdClus = 0;
772 for (jj=0; jj<3; jj++) pos[jj] = 0.;
774 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
777 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
780 for (jj=0; jj<7; jj++) parTOF[jj] = 0;
782 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
784 Int_t tracks[kMaxNumberOfTracksPerDigit];
785 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
787 Int_t dummyCounter=-1;
789 AliTOFdigit *digitInteresting;
793 for (iPadX=0; iPadX<AliTOFGeometry::NpadX(); iPadX++) {
794 for (iPadZ=0; iPadZ<AliTOFGeometry::NpadZ(); iPadZ++) {
795 vol[4] = iPadZ , vol[3] = iPadX;
797 AliDebug(3, Form(" %1d %2d\n", iPadZ, iPadX));
799 if (fTOFdigitMap->GetNumberOfDigits(vol)==0) continue;
801 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
802 if (fTOFdigitMap->GetDigitIndex(vol,digIndex)<0) continue;
803 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(fTOFdigitMap->GetDigitIndex(vol,digIndex));
805 AliDebug(2, Form(" %3d %5d %2d %1d %2d %1d %2d %d %d %d %5d %5d %5d %5d",
806 fTOFdigitMap->GetNumberOfDigits(vol), digIndex,
807 vol[0], vol[1], vol[2] ,vol[4], vol[3],
808 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
809 digitInteresting->GetToT(),
810 fTOFdigitMap->GetDigitIndex(vol,digIndex),
811 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
813 det[3] = vol[4]; // padz
814 det[4] = vol[3]; // padx
815 fTOFGeometry->GetPosPar(det,pos);
816 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
819 for (jj=0; jj<3; jj++) posClus[jj] = pos[jj];
821 parTOF[0] = Int_t(digitInteresting->GetTdc());
822 parTOF[1] = Int_t(digitInteresting->GetToT());
823 parTOF[2] = Int_t(digitInteresting->GetAdc());
824 parTOF[3] = Int_t(digitInteresting->GetTdcND());
825 parTOF[4] = Int_t(digitInteresting->GetTdc());
829 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
830 //volIdClus = GetClusterVolIndex(det);
832 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
833 GetClusterPars(det, posClus, covClus);
835 // To fill the track index array
837 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
838 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) { // three is the max number of tracks associated to one digit
839 if (digitInteresting->GetTrack(jj)==-1) continue;
842 tracks[dummyCounter] = digitInteresting->GetTrack(jj);
846 AliTOFcluster *tofCluster =
847 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
848 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
849 tracks, det, parTOF, status, fTOFdigitMap->GetDigitIndex(vol,digIndex));
850 InsertCluster(tofCluster);
852 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",
853 volIdClus, posClus[0], posClus[1], posClus[2],
854 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
855 tracks[0], tracks[1], tracks[2],
856 det[0], det[1], det[2], det[3], det[4],
857 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
858 status, fTOFdigitMap->GetDigitIndex(vol,digIndex)));
860 AliDebug(2, Form(" %f %f %f", pos[0], pos[1], pos[2]));
861 AliDebug(2, Form(" %d %d", parTOF[0], parTOF[2]));
863 fTOFdigitMap->ResetDigit(vol, digIndex);
871 //_____________________________________________________________________________
873 void AliTOFClusterFinderV1::FindClustersWithoutTOT(Int_t nSector,
878 // This function searches the isolated digits without TOT
879 // measurement (stored in the fDigits object), to perform clusters
880 // (stored in the fTofClusters array). This research has been made
881 // by checking the fTOFdigitMap object, filled at digits/raw-data
885 const Int_t kMaxNumberOfTracksPerDigit = 3;
886 const Int_t kMaxNumberOfDigitsPerVolume = 10;
890 Int_t det[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padZ,padX
891 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padX,padZ
892 UShort_t volIdClus = 0;
895 for (jj=0; jj<3; jj++) pos[jj] = 0.;
897 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
900 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
903 for (jj=0; jj<7; jj++) parTOF[jj] = 0;
905 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
906 Int_t tracks[kMaxNumberOfTracksPerDigit];
907 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
909 Int_t dummyCounter=-1;
911 AliTOFdigit *digitInteresting;
915 for (iPadX=0; iPadX<AliTOFGeometry::NpadX(); iPadX++) {
916 for (iPadZ=0; iPadZ<AliTOFGeometry::NpadZ(); iPadZ++) {
917 vol[4] = iPadZ , vol[3] = iPadX;
919 AliDebug(3, Form(" %1d %2d\n", iPadZ, iPadX));
921 if (fTOFdigitMap->GetNumberOfDigits(vol)==0) continue;
923 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
924 if (fTOFdigitMap->GetDigitIndex(vol,digIndex)<0) continue;
925 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(fTOFdigitMap->GetDigitIndex(vol,digIndex));
926 if (digitInteresting->GetToT()>0) continue; // AdC
928 AliDebug(2, Form(" %3d %5d %2d %1d %2d %1d %2d %d %d %d %5d %5d %5d %5d",
929 fTOFdigitMap->GetNumberOfDigits(vol), digIndex,
930 vol[0], vol[1], vol[2] ,vol[4], vol[3],
931 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
932 digitInteresting->GetToT(),
933 fTOFdigitMap->GetDigitIndex(vol,digIndex),
934 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
936 det[3] = vol[4]; // padz
937 det[4] = vol[3]; // padx
938 fTOFGeometry->GetPosPar(det,pos);
939 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
942 for (jj=0; jj<3; jj++) posClus[jj] = pos[jj];
944 parTOF[0] = Int_t(digitInteresting->GetTdc());
945 parTOF[1] = Int_t(digitInteresting->GetToT());
946 parTOF[2] = Int_t(digitInteresting->GetAdc());
947 parTOF[3] = Int_t(digitInteresting->GetTdcND());
948 parTOF[4] = Int_t(digitInteresting->GetTdc());
952 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
953 //volIdClus = GetClusterVolIndex(det);
955 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
956 GetClusterPars(det, posClus, covClus);
958 // To fill the track index array
960 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
961 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) { // three is the max number of tracks associated to one digit
962 if (digitInteresting->GetTrack(jj)==-1) continue;
965 tracks[dummyCounter] = digitInteresting->GetTrack(jj);
969 AliTOFcluster *tofCluster =
970 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
971 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
972 tracks, det, parTOF, status, fTOFdigitMap->GetDigitIndex(vol,digIndex));
973 InsertCluster(tofCluster);
975 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",
976 volIdClus, posClus[0], posClus[1], posClus[2],
977 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
978 tracks[0], tracks[1], tracks[2],
979 det[0], det[1], det[2], det[3], det[4],
980 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
981 status, fTOFdigitMap->GetDigitIndex(vol,digIndex)));
983 AliDebug(2, Form(" %f %f %f", pos[0], pos[1], pos[2]));
984 AliDebug(2, Form(" %d %d", parTOF[0], parTOF[2]));
986 fTOFdigitMap->ResetDigit(vol, digIndex);
994 //_____________________________________________________________________________
996 void AliTOFClusterFinderV1::FindClusters34(Int_t nSector,
1001 // This function searches the neighbouring digits (stored in the fDigits object),
1002 // to perform clusters (stored in the fTofClusters array).
1004 // This research has been made by checking the fTOFdigitMap object,
1005 // filled at digits/raw-data reading time.
1008 const Int_t kMaxNumberOfInterestingPads = 4;
1009 const Int_t kMaxNumberOfTracksPerDigit = 3;
1010 const Int_t kMaxNumberOfDigitsPerVolume = 10;
1014 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
1015 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1016 digitsInVolumeIndices[ii] = -1;
1018 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
1020 Float_t pos[3] = {0.,0.,0.};
1023 Int_t interestingPadX[kMaxNumberOfInterestingPads];
1024 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
1025 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
1026 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
1027 Double_t interestingTOT[kMaxNumberOfInterestingPads];
1028 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
1029 Double_t interestingADC[kMaxNumberOfInterestingPads];
1030 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
1031 Double_t interestingTOF[kMaxNumberOfInterestingPads];
1032 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
1033 Double_t interestingWeight[kMaxNumberOfInterestingPads];
1034 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
1036 Float_t interestingX[kMaxNumberOfInterestingPads];
1037 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
1038 Float_t interestingY[kMaxNumberOfInterestingPads];
1039 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
1040 Float_t interestingZ[kMaxNumberOfInterestingPads];
1041 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
1043 Float_t interDigit[kMaxNumberOfInterestingPads];
1044 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
1046 Int_t padsCluster[11];
1047 padsCluster[0] = nSector;
1048 padsCluster[1] = nPlate;
1049 padsCluster[2] = nStrip;
1050 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1052 Int_t interestingCounter=-1;
1053 Int_t digitIndexLocal=-1; // AdC
1059 for (jj=0; jj<7; jj++) parTOF[jj] = 0;
1060 Double_t posClus[3];
1061 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
1063 for (jj=0; jj<5; jj++) det[jj] = -1;
1065 for (jj=0; jj<3; jj++) posF[jj] = 0.;
1066 UShort_t volIdClus = 0;
1067 Bool_t check = kFALSE;
1068 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
1069 Double_t covClus[6];
1070 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1071 Int_t tracks[kMaxNumberOfTracksPerDigit];
1072 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1073 Int_t dummyCounter=-1;
1074 Bool_t alreadyStored = kFALSE;
1076 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
1077 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1078 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
1080 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1081 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
1083 AliTOFdigit *digitInteresting;
1085 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
1087 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
1088 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
1090 AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
1097 interestingCounter=-1;
1099 vol[4] = iPadZ , vol[3] = iPadX;
1100 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1101 interestingCounter++;
1103 vol[4] = iPadZ, vol[3] = iPadX+1;
1104 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1105 interestingCounter++;
1107 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1108 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1109 interestingCounter++;
1111 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1112 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1113 interestingCounter++;
1115 if (interestingCounter+1!=4) continue; // the hit pads have to be 4
1116 else interestingCounter=-1;
1119 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1120 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1121 selectedDigit[ii][jj] = 0x0;
1124 vol[4] = iPadZ, vol[3] = iPadX;
1126 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1127 interestingCounter++;
1128 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1129 digitsInVolumeIndices[ii] = -1;
1130 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1131 digitIndexLocal=-1; // AdC
1132 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1133 if (digitsInVolumeIndices[digIndex]<0) continue;
1134 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1135 if (digitInteresting->GetToT()<=0) continue; // AdC
1136 digitIndexLocal++; // AdC
1138 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1139 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1140 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1141 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1142 digitsInVolumeIndices[digIndex],
1143 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1146 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1147 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1148 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1149 digitInteresting->GetToT()*digitInteresting->GetToT(),
1150 digitsInVolumeIndices[digIndex],
1151 digitInteresting->GetTracks());
1153 if (digitIndexLocal==-1) interestingCounter--; // AdC
1157 vol[4] = iPadZ, vol[3] = iPadX+1;
1159 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1160 interestingCounter++;
1161 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1162 digitsInVolumeIndices[ii] = -1;
1163 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1164 digitIndexLocal=-1; // AdC
1165 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1166 if (digitsInVolumeIndices[digIndex]<0) continue;
1167 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1168 if (digitInteresting->GetToT()<=0) continue; // AdC
1169 digitIndexLocal++; // AdC
1171 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1172 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1173 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1174 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1175 digitsInVolumeIndices[digIndex],
1176 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1179 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1180 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1181 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1182 digitInteresting->GetToT()*digitInteresting->GetToT(),
1183 digitsInVolumeIndices[digIndex],
1184 digitInteresting->GetTracks());
1186 if (digitIndexLocal==-1) interestingCounter--; // AdC
1190 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1192 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1193 interestingCounter++;
1194 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1195 digitsInVolumeIndices[ii] = -1;
1196 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1197 digitIndexLocal=-1; // AdC
1198 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1199 if (digitsInVolumeIndices[digIndex]<0) continue;
1200 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1201 if (digitInteresting->GetToT()<=0) continue; // AdC
1202 digitIndexLocal++; // AdC
1204 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1205 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1206 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1207 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1208 digitsInVolumeIndices[digIndex],
1209 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1212 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1213 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1214 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1215 digitInteresting->GetToT()*digitInteresting->GetToT(),
1216 digitsInVolumeIndices[digIndex],
1217 digitInteresting->GetTracks());
1219 if (digitIndexLocal==-1) interestingCounter--; // AdC
1223 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1225 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1226 interestingCounter++;
1227 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1228 digitsInVolumeIndices[ii] = -1;
1229 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1231 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1232 if (digitsInVolumeIndices[digIndex]<0) continue;
1233 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1234 if (digitInteresting->GetToT()<=0) continue; // AdC
1235 digitIndexLocal++; // AdC
1237 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1238 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1239 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1240 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1241 digitsInVolumeIndices[digIndex],
1242 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1244 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1245 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1246 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1247 digitInteresting->GetToT()*digitInteresting->GetToT(),
1248 digitsInVolumeIndices[digIndex],
1249 digitInteresting->GetTracks());
1251 if (digitIndexLocal==-1) interestingCounter--; // AdC
1254 AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
1256 for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
1257 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
1258 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
1260 for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
1261 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
1262 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
1264 for (Int_t adesso3=adesso2+1; adesso3<interestingCounter+1; adesso3++) {
1265 for (Int_t thirdIndex=0; thirdIndex<kMaxNumberOfDigitsPerVolume; thirdIndex++) {
1266 if (selectedDigit[adesso3][thirdIndex]==0x0) continue;
1269 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime
1271 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
1273 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime) continue;
1275 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
1276 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
1277 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
1278 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
1279 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
1280 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
1281 Int_t volDum = vol1[3];
1284 fTOFGeometry->GetPosPar(vol1,pos);
1285 interestingX[0] = pos[0];
1286 interestingY[0] = pos[1];
1287 interestingZ[0] = pos[2];
1289 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
1290 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
1291 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
1292 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
1293 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
1294 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
1298 fTOFGeometry->GetPosPar(vol2,pos);
1299 interestingX[1] = pos[0];
1300 interestingY[1] = pos[1];
1301 interestingZ[1] = pos[2];
1303 interestingTOF[2] = selectedDigit[adesso3][thirdIndex]->GetTDC();
1304 interestingTOT[2] = selectedDigit[adesso3][thirdIndex]->GetTOT();
1305 interestingADC[2] = selectedDigit[adesso3][thirdIndex]->GetADC();
1306 interestingWeight[2] = selectedDigit[adesso3][thirdIndex]->GetWeight();
1307 Int_t vol3[5]; for(jj=0; jj<5; jj++) vol3[jj] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(jj);
1308 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol3[0], vol3[1], vol3[2], vol3[4], vol3[3]));
1312 fTOFGeometry->GetPosPar(vol3,pos);
1313 interestingX[2] = pos[0];
1314 interestingY[2] = pos[1];
1315 interestingZ[2] = pos[2];
1318 AverageCalculations(3, interestingX, interestingY, interestingZ,
1319 interestingTOF, interestingTOT, interestingADC,
1321 parTOF, posClus, check);
1324 for (jj=0; jj<5; jj++) det[jj] = -1;
1325 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
1326 fTOFGeometry->GetDetID(posF, det);
1328 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
1329 //volIdClus = GetClusterVolIndex(det);
1331 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1332 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
1333 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
1334 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
1335 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
1336 padsCluster[7] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(4);
1337 padsCluster[8] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(3);
1339 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1340 Int_t ** indDet = new Int_t*[3];
1341 for (jj=0; jj<3; jj++) indDet[jj] = new Int_t [5];
1342 for (jj=0; jj<3; jj++) indDet[jj][0] = nSector;
1343 for (jj=0; jj<3; jj++) indDet[jj][1] = nPlate;
1344 for (jj=0; jj<3; jj++) indDet[jj][2] = nStrip;
1345 for (jj=0; jj<3; jj++) indDet[jj][3] = padsCluster[2*jj+3];
1346 for (jj=0; jj<3; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
1347 GetClusterPars(/*check,*/ 3, indDet, interestingWeight, posClus, covClus);
1348 for (jj=0; jj<3; jj++) delete [] indDet[jj];
1351 // To fill the track index array
1353 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1354 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1355 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
1358 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
1361 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1362 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
1365 alreadyStored = kFALSE;
1366 for (jj=0; jj<dummyCounter+1; jj++)
1367 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
1369 if (alreadyStored) continue;
1370 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
1371 AliWarning(" Siamo al limite!");
1376 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
1381 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1382 if (selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk)==-1) continue;
1385 alreadyStored = kFALSE;
1386 for (jj=0; jj<dummyCounter+1; jj++)
1387 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk));
1389 if (alreadyStored) continue;
1390 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
1391 AliWarning(" Siamo al limite!");
1396 tracks[dummyCounter] = selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk);
1403 AliTOFcluster *tofCluster =
1404 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
1405 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1406 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
1407 InsertCluster(tofCluster);
1409 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",
1410 volIdClus, posClus[0], posClus[1], posClus[2],
1411 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1412 tracks[0], tracks[1], tracks[2],
1413 det[0], det[1], det[2], det[3], det[4],
1414 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
1415 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
1421 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
1425 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
1429 fTOFdigitMap->ResetDigitNumber(vol3,selectedDigit[adesso3][thirdIndex]->GetIndex());
1432 } // close loop on third digit
1433 } // close loop on adesso3
1435 } // close loop on second digit
1436 } // close loop on adesso2
1438 } // close loop on first digit
1439 } // close loop on adesso1
1441 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1442 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1443 selectedDigit[ii][jj] = 0x0;
1447 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++) {
1448 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
1449 delete [] selectedDigit[ii][jj];
1450 selectedDigit[ii][jj] = 0x0;
1452 delete [] selectedDigit[ii];
1453 selectedDigit[ii] = 0x0;
1455 delete [] selectedDigit;
1456 selectedDigit = 0x0;
1459 //_____________________________________________________________________________
1461 void AliTOFClusterFinderV1::FindClusters23(Int_t nSector,
1466 // This function searches the neighbouring digits (stored in the fDigits object),
1467 // to perform clusters (stored in the fTofClusters array).
1469 // This research has been made by checking the fTOFdigitMap object,
1470 // filled at digits/raw-data reading time.
1473 const Int_t kMaxNumberOfInterestingPads = 4;
1474 const Int_t kMaxNumberOfTracksPerDigit = 3;
1475 const Int_t kMaxNumberOfDigitsPerVolume = 10;
1479 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
1480 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1481 digitsInVolumeIndices[ii] = -1;
1483 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
1485 Float_t pos[3] = {0.,0.,0.};
1488 Int_t interestingPadX[kMaxNumberOfInterestingPads];
1489 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
1490 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
1491 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
1492 Double_t interestingTOT[kMaxNumberOfInterestingPads];
1493 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
1494 Double_t interestingADC[kMaxNumberOfInterestingPads];
1495 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
1496 Double_t interestingTOF[kMaxNumberOfInterestingPads];
1497 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
1498 Double_t interestingWeight[kMaxNumberOfInterestingPads];
1499 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
1501 Float_t interestingX[kMaxNumberOfInterestingPads];
1502 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
1503 Float_t interestingY[kMaxNumberOfInterestingPads];
1504 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
1505 Float_t interestingZ[kMaxNumberOfInterestingPads];
1506 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
1508 Float_t interDigit[kMaxNumberOfInterestingPads];
1509 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
1511 Int_t padsCluster[11];
1512 padsCluster[0] = nSector;
1513 padsCluster[1] = nPlate;
1514 padsCluster[2] = nStrip;
1515 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1517 Int_t interestingCounter=-1;
1518 Int_t digitIndexLocal = -1;
1523 Bool_t check = kFALSE;
1525 for (jj=0; jj<7; jj++) parTOF[jj] = 0;
1526 Double_t posClus[3];
1527 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
1529 for (jj=0; jj<5; jj++) det[jj] = -1;
1531 for (jj=0; jj<3; jj++) posF[jj] = 0.;
1532 UShort_t volIdClus = 0;
1533 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
1534 Double_t covClus[6];
1535 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1536 Int_t tracks[kMaxNumberOfTracksPerDigit];
1537 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1538 Int_t dummyCounter=-1;
1539 Bool_t alreadyStored = kFALSE;
1541 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
1542 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1543 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
1545 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1546 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
1548 AliTOFdigit *digitInteresting;
1550 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
1552 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
1553 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
1555 AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
1562 interestingCounter=-1;
1564 vol[4] = iPadZ , vol[3] = iPadX;
1565 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1566 interestingCounter++;
1568 vol[4] = iPadZ, vol[3] = iPadX+1;
1569 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1570 interestingCounter++;
1572 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1573 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1574 interestingCounter++;
1576 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1577 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1578 interestingCounter++;
1580 if (interestingCounter+1!=3) continue; // the hit pads have to be 3
1581 else interestingCounter=-1;
1584 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1585 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1586 selectedDigit[ii][jj] = 0x0;
1589 vol[4] = iPadZ, vol[3] = iPadX;
1591 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1592 interestingCounter++;
1593 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1594 digitsInVolumeIndices[ii] = -1;
1595 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1597 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1598 if (digitsInVolumeIndices[digIndex]<0) continue;
1599 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1600 if (digitInteresting->GetToT()<=0) continue; // AdC
1601 digitIndexLocal++; // AdC
1603 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1604 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1605 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1606 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1607 digitsInVolumeIndices[digIndex],
1608 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1610 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1611 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1612 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1613 digitInteresting->GetToT()*digitInteresting->GetToT(),
1614 digitsInVolumeIndices[digIndex],
1615 digitInteresting->GetTracks());
1617 if (digitIndexLocal==-1) interestingCounter--; // AdC
1621 vol[4] = iPadZ, vol[3] = iPadX+1;
1623 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1624 interestingCounter++;
1625 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1626 digitsInVolumeIndices[ii] = -1;
1627 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1628 digitIndexLocal=-1; // AdC
1629 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1630 if (digitsInVolumeIndices[digIndex]<0) continue;
1631 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1632 if (digitInteresting->GetToT()<=0) continue; // AdC
1633 digitIndexLocal++; // AdC
1635 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1636 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1637 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1638 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1639 digitsInVolumeIndices[digIndex],
1640 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1642 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1643 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1644 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1645 digitInteresting->GetToT()*digitInteresting->GetToT(),
1646 digitsInVolumeIndices[digIndex],
1647 digitInteresting->GetTracks());
1649 if (digitIndexLocal==-1) interestingCounter--; // AdC
1653 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1655 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1656 interestingCounter++;
1657 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1658 digitsInVolumeIndices[ii] = -1;
1659 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1660 digitIndexLocal=-1; // AdC
1661 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1662 if (digitsInVolumeIndices[digIndex]<0) continue;
1663 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1664 if (digitInteresting->GetToT()<=0) continue; // AdC
1665 digitIndexLocal++; // AdC
1667 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1668 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1669 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1670 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1671 digitsInVolumeIndices[digIndex],
1672 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1674 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1675 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1676 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1677 digitInteresting->GetToT()*digitInteresting->GetToT(),
1678 digitsInVolumeIndices[digIndex],
1679 digitInteresting->GetTracks());
1681 if (digitIndexLocal==-1) interestingCounter--; // AdC
1685 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1687 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1688 interestingCounter++;
1689 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1690 digitsInVolumeIndices[ii] = -1;
1691 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1692 digitIndexLocal=-1; // AdC
1693 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1694 if (digitsInVolumeIndices[digIndex]<0) continue;
1695 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1696 if (digitInteresting->GetToT()<=0) continue; // AdC
1697 digitIndexLocal++; // AdC
1699 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1700 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1701 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1702 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1703 digitsInVolumeIndices[digIndex],
1704 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1706 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1707 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1708 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1709 digitInteresting->GetToT()*digitInteresting->GetToT(),
1710 digitsInVolumeIndices[digIndex],
1711 digitInteresting->GetTracks());
1713 if (digitIndexLocal==-1) interestingCounter--; // AdC
1716 AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
1718 for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
1719 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
1720 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
1722 for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
1723 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
1724 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
1726 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime) continue;
1728 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
1729 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
1730 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
1731 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
1732 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
1733 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
1734 Int_t volDum = vol1[3];
1737 fTOFGeometry->GetPosPar(vol1,pos);
1738 interestingX[0] = pos[0];
1739 interestingY[0] = pos[1];
1740 interestingZ[0] = pos[2];
1742 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
1743 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
1744 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
1745 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
1746 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
1747 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
1751 fTOFGeometry->GetPosPar(vol2,pos);
1752 interestingX[1] = pos[0];
1753 interestingY[1] = pos[1];
1754 interestingZ[1] = pos[2];
1756 AverageCalculations(2, interestingX, interestingY, interestingZ,
1757 interestingTOF, interestingTOT, interestingADC,
1759 parTOF, posClus, check);
1761 for (jj=0; jj<5; jj++) det[jj] = -1;
1762 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
1763 fTOFGeometry->GetDetID(posF, det);
1765 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
1766 //volIdClus = GetClusterVolIndex(det);
1768 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1769 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
1770 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
1771 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
1772 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
1774 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1775 Int_t ** indDet = new Int_t*[2];
1776 for (jj=0; jj<2; jj++) indDet[jj] = new Int_t [5];
1777 for (jj=0; jj<2; jj++) indDet[jj][0] = nSector;
1778 for (jj=0; jj<2; jj++) indDet[jj][1] = nPlate;
1779 for (jj=0; jj<2; jj++) indDet[jj][2] = nStrip;
1780 for (jj=0; jj<2; jj++) indDet[jj][3] = padsCluster[2*jj+3];
1781 for (jj=0; jj<2; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
1782 GetClusterPars(/*check,*/ 2, indDet, interestingWeight, posClus, covClus);
1783 for (jj=0; jj<2; jj++) delete [] indDet[jj];
1786 // To fill the track index array
1788 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1789 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1790 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
1793 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
1796 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1797 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
1800 alreadyStored = kFALSE;
1801 for (jj=0; jj<dummyCounter+1; jj++)
1802 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
1804 if (alreadyStored) continue;
1805 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
1806 AliWarning(" Siamo al limite!");
1811 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
1818 AliTOFcluster *tofCluster =
1819 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
1820 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1821 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
1822 InsertCluster(tofCluster);
1824 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",
1825 volIdClus, posClus[0], posClus[1], posClus[2],
1826 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1827 tracks[0], tracks[1], tracks[2],
1828 det[0], det[1], det[2], det[3], det[4],
1829 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
1830 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
1835 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
1839 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
1842 } // close loop on second digit
1843 } // close loop on adesso2
1845 } // close loop on first digit
1846 } // close loop on adesso1
1848 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1849 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1850 selectedDigit[ii][jj] = 0x0;
1854 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++) {
1855 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
1856 delete [] selectedDigit[ii][jj];
1857 selectedDigit[ii][jj] = 0x0;
1859 delete [] selectedDigit[ii];
1860 selectedDigit[ii] = 0x0;
1862 delete [] selectedDigit;
1863 selectedDigit = 0x0;
1866 //_____________________________________________________________________________
1868 void AliTOFClusterFinderV1::FindClusters24(Int_t nSector,
1873 // This function searches the neighbouring digits (stored in the fDigits object),
1874 // to perform clusters (stored in the fTofClusters array).
1876 // This research has been made by checking the fTOFdigitMap object,
1877 // filled at digits/raw-data reading time.
1880 const Int_t kMaxNumberOfInterestingPads = 4;
1881 const Int_t kMaxNumberOfTracksPerDigit = 3;
1882 const Int_t kMaxNumberOfDigitsPerVolume = 10;
1886 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
1887 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1888 digitsInVolumeIndices[ii] = -1;
1890 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
1892 Float_t pos[3] = {0.,0.,0.};
1895 Int_t interestingPadX[kMaxNumberOfInterestingPads];
1896 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
1897 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
1898 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
1899 Double_t interestingTOT[kMaxNumberOfInterestingPads];
1900 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
1901 Double_t interestingADC[kMaxNumberOfInterestingPads];
1902 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
1903 Double_t interestingTOF[kMaxNumberOfInterestingPads];
1904 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
1905 Double_t interestingWeight[kMaxNumberOfInterestingPads];
1906 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
1908 Float_t interestingX[kMaxNumberOfInterestingPads];
1909 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
1910 Float_t interestingY[kMaxNumberOfInterestingPads];
1911 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
1912 Float_t interestingZ[kMaxNumberOfInterestingPads];
1913 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
1915 Float_t interDigit[kMaxNumberOfInterestingPads];
1916 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
1918 Int_t padsCluster[11];
1919 padsCluster[0] = nSector;
1920 padsCluster[1] = nPlate;
1921 padsCluster[2] = nStrip;
1922 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1924 Int_t interestingCounter=-1;
1925 Int_t digitIndexLocal = -1;
1930 Bool_t check = kFALSE;
1932 for (jj=0; jj<7; jj++) parTOF[jj] = 0;
1933 Double_t posClus[3];
1934 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
1936 for (jj=0; jj<5; jj++) det[jj] = -1;
1938 for (jj=0; jj<3; jj++) posF[jj] = 0.;
1939 UShort_t volIdClus = 0;
1940 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
1941 Double_t covClus[6];
1942 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1943 Int_t tracks[kMaxNumberOfTracksPerDigit];
1944 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1945 Int_t dummyCounter=-1;
1946 Bool_t alreadyStored = kFALSE;
1948 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
1949 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1950 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
1952 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1953 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
1955 AliTOFdigit *digitInteresting;
1957 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
1959 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
1960 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
1962 AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
1969 interestingCounter=-1;
1971 vol[4] = iPadZ , vol[3] = iPadX;
1972 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1973 interestingCounter++;
1975 vol[4] = iPadZ, vol[3] = iPadX+1;
1976 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1977 interestingCounter++;
1979 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1980 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1981 interestingCounter++;
1983 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1984 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1985 interestingCounter++;
1987 if (interestingCounter+1!=4) continue; // the hit pads have to be 4
1988 else interestingCounter=-1;
1991 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1992 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1993 selectedDigit[ii][jj] = 0x0;
1996 vol[4] = iPadZ, vol[3] = iPadX;
1998 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1999 interestingCounter++;
2000 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2001 digitsInVolumeIndices[ii] = -1;
2002 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2003 digitIndexLocal=-1; // AdC
2004 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2005 if (digitsInVolumeIndices[digIndex]<0) continue;
2006 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2007 if (digitInteresting->GetToT()<=0) continue; // AdC
2008 digitIndexLocal++; // AdC
2010 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2011 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2012 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2013 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2014 digitsInVolumeIndices[digIndex],
2015 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2017 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2018 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2019 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2020 digitInteresting->GetToT()*digitInteresting->GetToT(),
2021 digitsInVolumeIndices[digIndex],
2022 digitInteresting->GetTracks());
2024 if (digitIndexLocal==-1) interestingCounter--; // AdC
2028 vol[4] = iPadZ, vol[3] = iPadX+1;
2030 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2031 interestingCounter++;
2032 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2033 digitsInVolumeIndices[ii] = -1;
2034 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2035 digitIndexLocal=-1; // AdC
2036 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2037 if (digitsInVolumeIndices[digIndex]<0) continue;
2038 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2039 if (digitInteresting->GetToT()<=0) continue; // AdC
2040 digitIndexLocal++; // AdC
2042 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2043 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2044 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2045 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2046 digitsInVolumeIndices[digIndex],
2047 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2049 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2050 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2051 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2052 digitInteresting->GetToT()*digitInteresting->GetToT(),
2053 digitsInVolumeIndices[digIndex],
2054 digitInteresting->GetTracks());
2056 if (digitIndexLocal==-1) interestingCounter--; // AdC
2060 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
2062 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2063 interestingCounter++;
2064 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2065 digitsInVolumeIndices[ii] = -1;
2066 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2067 digitIndexLocal=-1; // AdC
2068 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2069 if (digitsInVolumeIndices[digIndex]<0) continue;
2070 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2071 if (digitInteresting->GetToT()<=0) continue; // AdC
2072 digitIndexLocal++; // AdC
2074 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2075 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2076 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2077 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2078 digitsInVolumeIndices[digIndex],
2079 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2081 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2082 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2083 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2084 digitInteresting->GetToT()*digitInteresting->GetToT(),
2085 digitsInVolumeIndices[digIndex],
2086 digitInteresting->GetTracks());
2088 if (digitIndexLocal==-1) interestingCounter--; // AdC
2092 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
2094 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2095 interestingCounter++;
2096 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2097 digitsInVolumeIndices[ii] = -1;
2098 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2099 digitIndexLocal=-1; // AdC
2100 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2101 if (digitsInVolumeIndices[digIndex]<0) continue;
2102 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2103 if (digitInteresting->GetToT()<=0) continue; // AdC
2104 digitIndexLocal++; // AdC
2106 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2107 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2108 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2109 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2110 digitsInVolumeIndices[digIndex],
2111 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2113 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2114 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2115 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2116 digitInteresting->GetToT()*digitInteresting->GetToT(),
2117 digitsInVolumeIndices[digIndex],
2118 digitInteresting->GetTracks());
2120 if (digitIndexLocal==-1) interestingCounter--; // AdC
2123 AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
2125 for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
2126 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2127 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2129 for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
2130 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2131 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2133 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime) continue;
2135 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2136 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2137 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2138 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2139 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
2140 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
2141 Int_t volDum = vol1[3];
2144 fTOFGeometry->GetPosPar(vol1,pos);
2145 interestingX[0] = pos[0];
2146 interestingY[0] = pos[1];
2147 interestingZ[0] = pos[2];
2149 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2150 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2151 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2152 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2153 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
2154 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
2158 fTOFGeometry->GetPosPar(vol2,pos);
2159 interestingX[1] = pos[0];
2160 interestingY[1] = pos[1];
2161 interestingZ[1] = pos[2];
2164 AverageCalculations(2, interestingX, interestingY, interestingZ,
2165 interestingTOF, interestingTOT, interestingADC,
2167 parTOF, posClus, check);
2169 for (jj=0; jj<5; jj++) det[jj] = -1;
2170 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
2171 fTOFGeometry->GetDetID(posF, det);
2173 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
2174 //volIdClus = GetClusterVolIndex(det);
2176 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2177 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
2178 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
2179 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
2180 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
2182 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2183 Int_t ** indDet = new Int_t*[2];
2184 for (jj=0; jj<2; jj++) indDet[jj] = new Int_t [5];
2185 for (jj=0; jj<2; jj++) indDet[jj][0] = nSector;
2186 for (jj=0; jj<2; jj++) indDet[jj][1] = nPlate;
2187 for (jj=0; jj<2; jj++) indDet[jj][2] = nStrip;
2188 for (jj=0; jj<2; jj++) indDet[jj][3] = padsCluster[2*jj+3];
2189 for (jj=0; jj<2; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
2190 GetClusterPars(/*check,*/ 2, indDet, interestingWeight, posClus, covClus);
2191 for (jj=0; jj<2; jj++) delete [] indDet[jj];
2194 // To fill the track index array
2196 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2197 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2198 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
2201 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
2204 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2205 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
2208 alreadyStored = kFALSE;
2209 for (jj=0; jj<dummyCounter+1; jj++)
2210 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
2212 if (alreadyStored) continue;
2213 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2214 AliWarning(" Siamo al limite!");
2219 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
2226 AliTOFcluster *tofCluster =
2227 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
2228 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2229 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
2230 InsertCluster(tofCluster);
2232 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",
2233 volIdClus, posClus[0], posClus[1], posClus[2],
2234 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2235 tracks[0], tracks[1], tracks[2],
2236 det[0], det[1], det[2], det[3], det[4],
2237 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
2238 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
2243 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
2247 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
2250 } // close loop on second digit
2251 } // close loop on adesso2
2253 } // close loop on first digit
2254 } // close loop on adesso1
2256 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2257 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
2258 selectedDigit[ii][jj] = 0x0;
2262 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++) {
2263 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
2264 delete [] selectedDigit[ii][jj];
2265 selectedDigit[ii][jj] = 0x0;
2267 delete [] selectedDigit[ii];
2268 selectedDigit[ii] = 0x0;
2270 delete [] selectedDigit;
2271 selectedDigit = 0x0;
2274 //_____________________________________________________________________________
2276 void AliTOFClusterFinderV1::FindClustersPerStrip(Int_t nSector,
2282 // This function searches the neighbouring digits (stored in the fDigits object),
2283 // to perform clusters (stored in the fTofClusters array).
2285 // Each strip is read four times:
2286 // - 1st time: it searches possible clusters formed by four
2287 // neighbouring digits;
2288 // - 2nd time: it searches possible clusters formed by three
2289 // neighbouring digits;
2290 // - 3rd time: it searches possible clusters formed by two
2291 // neighbouring digits;
2292 // - 4th time: the remaining isolated digits have been transformed
2294 // This research has been made by checking the fTOFdigitMap object,
2295 // filled at digits/raw-data reading time.
2298 const Int_t kMaxNumberOfInterestingPads = 4;
2299 const Int_t kMaxNumberOfTracksPerDigit = 3;
2300 const Int_t kMaxNumberOfDigitsPerVolume = 10;
2304 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
2305 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2306 digitsInVolumeIndices[ii] = -1;
2308 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
2310 Float_t pos[3] = {0.,0.,0.};
2313 Int_t interestingPadX[kMaxNumberOfInterestingPads];
2314 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
2315 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
2316 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
2317 Double_t interestingTOT[kMaxNumberOfInterestingPads];
2318 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
2319 Double_t interestingADC[kMaxNumberOfInterestingPads];
2320 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
2321 Double_t interestingTOF[kMaxNumberOfInterestingPads];
2322 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
2323 Double_t interestingWeight[kMaxNumberOfInterestingPads];
2324 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
2326 Float_t interestingX[kMaxNumberOfInterestingPads];
2327 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
2328 Float_t interestingY[kMaxNumberOfInterestingPads];
2329 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
2330 Float_t interestingZ[kMaxNumberOfInterestingPads];
2331 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
2333 Float_t interDigit[kMaxNumberOfInterestingPads];
2334 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
2336 Int_t padsCluster[11];
2337 padsCluster[0] = nSector;
2338 padsCluster[1] = nPlate;
2339 padsCluster[2] = nStrip;
2340 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2342 Int_t interestingCounter=-1;
2343 Int_t digitIndexLocal = -1;
2348 Bool_t check = kFALSE;
2350 for (jj=0; jj<7; jj++) parTOF[jj] = 0;
2351 Double_t posClus[3];
2352 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
2354 for (jj=0; jj<5; jj++) det[jj] = -1;
2356 for (jj=0; jj<3; jj++) posF[jj] = 0.;
2357 UShort_t volIdClus = 0;
2358 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
2359 Double_t covClus[6];
2360 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2361 Int_t tracks[kMaxNumberOfTracksPerDigit];
2362 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2363 Int_t dummyCounter=-1;
2364 Bool_t alreadyStored = kFALSE;
2366 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
2367 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2368 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
2370 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2371 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
2373 AliTOFdigit *digitInteresting;
2377 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
2379 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
2380 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
2382 AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
2389 interestingCounter=-1;
2391 vol[4] = iPadZ , vol[3] = iPadX;
2392 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2393 interestingCounter++;
2395 vol[4] = iPadZ, vol[3] = iPadX+1;
2396 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2397 interestingCounter++;
2399 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
2400 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2401 interestingCounter++;
2403 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
2404 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2405 interestingCounter++;
2407 if (interestingCounter!=group) continue;
2408 else interestingCounter=-1;
2411 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2412 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
2413 selectedDigit[ii][jj] = 0x0;
2416 vol[4] = iPadZ, vol[3] = iPadX;
2418 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2419 interestingCounter++;
2420 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2421 digitsInVolumeIndices[ii] = -1;
2422 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2423 digitIndexLocal=-1; // AdC
2424 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2425 if (digitsInVolumeIndices[digIndex]<0) continue;
2426 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2427 if (digitInteresting->GetToT()<=0) continue; // AdC
2428 digitIndexLocal++; // AdC
2430 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2431 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2432 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2433 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2434 digitsInVolumeIndices[digIndex],
2435 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2436 AliDebug(1,Form(" to try %d %d ",digIndex, interestingCounter));
2438 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2439 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2440 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2441 digitInteresting->GetToT()*digitInteresting->GetToT(),
2442 digitsInVolumeIndices[digIndex],
2443 digitInteresting->GetTracks());
2445 if (digitIndexLocal==-1) interestingCounter--; // AdC
2449 vol[4] = iPadZ, vol[3] = iPadX+1;
2451 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2452 interestingCounter++;
2453 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2454 digitsInVolumeIndices[ii] = -1;
2455 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2456 digitIndexLocal=-1; // AdC
2457 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2458 if (digitsInVolumeIndices[digIndex]<0) continue;
2459 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2460 if (digitInteresting->GetToT()<=0) continue; // AdC
2461 digitIndexLocal++; // AdC
2463 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2464 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2465 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2466 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2467 digitsInVolumeIndices[digIndex],
2468 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2469 AliDebug(1,Form(" to try %d %d ",digIndex, interestingCounter));
2471 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2472 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2473 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2474 digitInteresting->GetToT()*digitInteresting->GetToT(),
2475 digitsInVolumeIndices[digIndex],
2476 digitInteresting->GetTracks());
2478 if (digitIndexLocal==-1) interestingCounter--; // AdC
2482 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
2484 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2485 interestingCounter++;
2486 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2487 digitsInVolumeIndices[ii] = -1;
2488 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2489 digitIndexLocal=-1; // AdC
2490 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2491 if (digitsInVolumeIndices[digIndex]<0) continue;
2492 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2493 if (digitInteresting->GetToT()<=0) continue; // AdC
2494 digitIndexLocal++; // AdC
2496 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2497 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2498 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2499 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2500 digitsInVolumeIndices[digIndex],
2501 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2502 AliDebug(1,Form(" to try %d %d ",digIndex, interestingCounter));
2504 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2505 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2506 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2507 digitInteresting->GetToT()*digitInteresting->GetToT(),
2508 digitsInVolumeIndices[digIndex],
2509 digitInteresting->GetTracks());
2511 if (digitIndexLocal==-1) interestingCounter--; // AdC
2515 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
2517 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2518 interestingCounter++;
2519 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2520 digitsInVolumeIndices[ii] = -1;
2521 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2522 digitIndexLocal=-1; // AdC
2523 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2524 if (digitsInVolumeIndices[digIndex]<0) continue;
2525 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2526 if (digitInteresting->GetToT()<=0) continue; // AdC
2527 digitIndexLocal++; // AdC
2529 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2530 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2531 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2532 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2533 digitsInVolumeIndices[digIndex],
2534 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2535 AliDebug(1,Form(" to try %d %d ",digIndex, interestingCounter));
2537 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2538 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2539 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2540 digitInteresting->GetToT()*digitInteresting->GetToT(),
2541 digitsInVolumeIndices[digIndex],
2542 digitInteresting->GetTracks());
2544 if (digitIndexLocal==-1) interestingCounter--; // AdC
2547 AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
2554 switch(interestingCounter+1) {
2558 //for (adesso1=0; adesso1<interestingCounter+1; adesso1++) {
2560 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2561 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2563 //for (adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
2565 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2566 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2568 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime) {
2569 AliDebug(1,Form(" selD1[%d][%d]->GetTDC()=%d selD2[%d][%d]->GetTDC()=%d -- %d ",
2570 adesso1,firstIndex,(Int_t)selectedDigit[adesso1][firstIndex]->GetTDC(),
2571 adesso2,secondIndex,(Int_t)selectedDigit[adesso2][secondIndex]->GetTDC(),
2576 AliDebug(1, Form(" %1d %1d (0x%p) %1d %1d (0x%p)", adesso1, firstIndex,selectedDigit[adesso1][firstIndex],
2577 adesso2, secondIndex,selectedDigit[adesso2][secondIndex]));
2579 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2580 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2581 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2582 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2583 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
2584 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
2585 Int_t volDum = vol1[3];
2588 fTOFGeometry->GetPosPar(vol1,pos);
2589 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
2590 interestingX[0] = pos[0];
2591 interestingY[0] = pos[1];
2592 interestingZ[0] = pos[2];
2594 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2595 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2596 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2597 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2598 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
2599 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
2603 fTOFGeometry->GetPosPar(vol2,pos);
2604 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
2605 interestingX[1] = pos[0];
2606 interestingY[1] = pos[1];
2607 interestingZ[1] = pos[2];
2610 AverageCalculations(interestingCounter+1,
2611 interestingX, interestingY, interestingZ,
2612 interestingTOF, interestingTOT, interestingADC,
2614 parTOF, posClus, check);
2616 for (jj=0; jj<5; jj++) det[jj] = -1;
2617 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
2619 AliDebug(1,Form(" %f %f %f", posF[0], posF[1], posF[2]));
2620 fTOFGeometry->GetDetID(posF, det);
2621 AliDebug(1,Form(" %2d %1d %2d %1d %2d", det[0], det[1], det[2], det[3], det[4]));
2623 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
2624 //volIdClus = GetClusterVolIndex(det);
2626 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2627 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
2628 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
2629 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
2630 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
2632 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2633 Int_t ** indDet = new Int_t*[interestingCounter+1];
2634 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj] = new Int_t [5];
2635 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][0] = nSector;
2636 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][1] = nPlate;
2637 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][2] = nStrip;
2638 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][3] = padsCluster[2*jj+3];
2639 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
2640 GetClusterPars(/*check,*/ interestingCounter+1, indDet, interestingWeight, posClus, covClus);
2641 for (jj=0; jj<interestingCounter+1; jj++) delete [] indDet[jj];
2644 // To fill the track index array
2646 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2647 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2648 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
2651 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
2654 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2655 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
2658 alreadyStored = kFALSE;
2659 for (jj=0; jj<dummyCounter+1; jj++)
2660 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
2662 if (alreadyStored) continue;
2663 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2664 AliWarning(" Siamo al limite!");
2669 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
2676 AliTOFcluster *tofCluster =
2677 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
2678 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2679 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); //to updated
2680 InsertCluster(tofCluster);
2682 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",
2683 volIdClus, posClus[0], posClus[1], posClus[2],
2684 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2685 tracks[0], tracks[1], tracks[2],
2686 det[0], det[1], det[2], det[3], det[4],
2687 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
2688 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
2693 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
2697 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
2700 } // close loop on second digit
2701 //} // close loop on adesso2
2703 } // close loop on first digit
2704 //} // close loop on adesso1
2711 //for (adesso1=0; adesso1<interestingCounter+1; adesso1++) {
2713 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2714 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2716 //for (adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
2718 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2719 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2721 //for (adesso3=adesso2+1; adesso3<interestingCounter+1; adesso3++) {
2723 for (Int_t thirdIndex=0; thirdIndex<kMaxNumberOfDigitsPerVolume; thirdIndex++) {
2724 if (selectedDigit[adesso3][thirdIndex]==0x0) continue;
2727 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime
2729 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
2731 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime) continue;
2733 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2734 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2735 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2736 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2737 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
2738 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
2739 Int_t volDum = vol1[3];
2742 fTOFGeometry->GetPosPar(vol1,pos);
2743 interestingX[0] = pos[0];
2744 interestingY[0] = pos[1];
2745 interestingZ[0] = pos[2];
2747 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2748 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2749 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2750 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2751 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
2752 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
2756 fTOFGeometry->GetPosPar(vol2,pos);
2757 interestingX[1] = pos[0];
2758 interestingY[1] = pos[1];
2759 interestingZ[1] = pos[2];
2761 interestingTOF[2] = selectedDigit[adesso3][thirdIndex]->GetTDC();
2762 interestingTOT[2] = selectedDigit[adesso3][thirdIndex]->GetTOT();
2763 interestingADC[2] = selectedDigit[adesso3][thirdIndex]->GetADC();
2764 interestingWeight[2] = selectedDigit[adesso3][thirdIndex]->GetWeight();
2765 Int_t vol3[5]; for(jj=0; jj<5; jj++) vol3[jj] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(jj);
2766 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol3[0], vol3[1], vol3[2], vol3[4], vol3[3]));
2770 fTOFGeometry->GetPosPar(vol3,pos);
2771 interestingX[2] = pos[0];
2772 interestingY[2] = pos[1];
2773 interestingZ[2] = pos[2];
2776 AverageCalculations(interestingCounter+1,
2777 interestingX, interestingY, interestingZ,
2778 interestingTOF, interestingTOT, interestingADC,
2780 parTOF, posClus, check);
2782 for (jj=0; jj<5; jj++) det[jj] = -1;
2783 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
2784 fTOFGeometry->GetDetID(posF, det);
2786 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
2787 //volIdClus = GetClusterVolIndex(det);
2789 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2790 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
2791 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
2792 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
2793 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
2794 padsCluster[7] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(4);
2795 padsCluster[8] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(3);
2797 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2798 Int_t ** indDet = new Int_t*[interestingCounter+1];
2799 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj] = new Int_t [5];
2800 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][0] = nSector;
2801 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][1] = nPlate;
2802 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][2] = nStrip;
2803 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][3] = padsCluster[2*jj+3];
2804 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
2805 GetClusterPars(/*check,*/ interestingCounter+1, indDet, interestingWeight, posClus, covClus);
2806 for (jj=0; jj<interestingCounter+1; jj++) delete [] indDet[jj];
2810 // To fill the track index array
2812 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2813 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2814 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
2817 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
2820 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2821 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
2824 alreadyStored = kFALSE;
2825 for (jj=0; jj<dummyCounter+1; jj++)
2826 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
2828 if (alreadyStored) continue;
2829 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2830 AliWarning(" Siamo al limite!");
2835 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
2840 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2841 if (selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk)==-1) continue;
2844 alreadyStored = kFALSE;
2845 for (jj=0; jj<dummyCounter+1; jj++)
2846 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk));
2848 if (alreadyStored) continue;
2849 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2850 AliWarning(" Siamo al limite!");
2855 tracks[dummyCounter] = selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk);
2862 AliTOFcluster *tofCluster =
2863 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
2864 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2865 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
2866 InsertCluster(tofCluster);
2868 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",
2869 volIdClus, posClus[0], posClus[1], posClus[2],
2870 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2871 tracks[0], tracks[1], tracks[2],
2872 det[0], det[1], det[2], det[3], det[4],
2873 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
2874 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
2879 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
2883 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
2887 fTOFdigitMap->ResetDigitNumber(vol3,selectedDigit[adesso3][thirdIndex]->GetIndex());
2890 } // close loop on third digit
2891 //} // close loop on adesso3
2893 } // close loop on second digit
2894 //} // close loop on adesso2
2896 } // close loop on first digit
2897 //} // close loop on adesso1
2905 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2906 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2909 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2910 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2913 for (Int_t thirdIndex=0; thirdIndex<kMaxNumberOfDigitsPerVolume; thirdIndex++) {
2914 if (selectedDigit[adesso3][thirdIndex]==0x0) continue;
2917 for (Int_t fourthIndex=0; fourthIndex<kMaxNumberOfDigitsPerVolume; fourthIndex++) {
2918 if (selectedDigit[adesso4][fourthIndex]==0x0) continue;
2921 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime
2923 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
2925 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso4][fourthIndex]->GetTDC())>fMaxDeltaTime
2927 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
2929 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso4][fourthIndex]->GetTDC())>fMaxDeltaTime
2931 TMath::Abs(selectedDigit[adesso3][thirdIndex]->GetTDC()-selectedDigit[adesso4][fourthIndex]->GetTDC())>fMaxDeltaTime) continue;
2933 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2934 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2935 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2936 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2937 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
2938 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
2939 Int_t volDum = vol1[3];
2942 fTOFGeometry->GetPosPar(vol1,pos);
2943 interestingX[0] = pos[0];
2944 interestingY[0] = pos[1];
2945 interestingZ[0] = pos[2];
2947 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2948 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2949 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2950 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2951 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
2952 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
2956 fTOFGeometry->GetPosPar(vol2,pos);
2957 interestingX[1] = pos[0];
2958 interestingY[1] = pos[1];
2959 interestingZ[1] = pos[2];
2961 interestingTOF[2] = selectedDigit[adesso3][thirdIndex]->GetTDC();
2962 interestingTOT[2] = selectedDigit[adesso3][thirdIndex]->GetTOT();
2963 interestingADC[2] = selectedDigit[adesso3][thirdIndex]->GetADC();
2964 interestingWeight[2] = selectedDigit[adesso3][thirdIndex]->GetWeight();
2965 Int_t vol3[5]; for(jj=0; jj<5; jj++) vol3[jj] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(jj);
2966 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol3[0], vol3[1], vol3[2], vol3[4], vol3[3]));
2970 fTOFGeometry->GetPosPar(vol3,pos);
2971 interestingX[2] = pos[0];
2972 interestingY[2] = pos[1];
2973 interestingZ[2] = pos[2];
2975 interestingTOF[3] = selectedDigit[adesso4][fourthIndex]->GetTDC();
2976 interestingTOT[3] = selectedDigit[adesso4][fourthIndex]->GetTOT();
2977 interestingADC[3] = selectedDigit[adesso4][fourthIndex]->GetADC();
2978 interestingWeight[3] = selectedDigit[adesso4][fourthIndex]->GetWeight();
2979 Int_t vol4[5]; for(jj=0; jj<5; jj++) vol4[jj] = selectedDigit[adesso4][fourthIndex]->GetDetectorIndex(jj);
2980 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol4[0], vol4[1], vol4[2], vol4[4], vol4[3]));
2984 fTOFGeometry->GetPosPar(vol4,pos);
2985 interestingX[3] = pos[0];
2986 interestingY[3] = pos[1];
2987 interestingZ[3] = pos[2];
2990 AverageCalculations(interestingCounter+1,
2991 interestingX, interestingY, interestingZ,
2992 interestingTOF, interestingTOT, interestingADC,
2994 parTOF, posClus, check);
2996 for (jj=0; jj<5; jj++) det[jj] = -1;
2997 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
2998 fTOFGeometry->GetDetID(posF, det);
3000 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
3001 //volIdClus = GetClusterVolIndex(det);
3003 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
3004 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
3005 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
3006 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
3007 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
3008 padsCluster[7] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(4);
3009 padsCluster[8] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(3);
3010 padsCluster[9] = selectedDigit[adesso4][fourthIndex]->GetDetectorIndex(4);
3011 padsCluster[10] = selectedDigit[adesso4][fourthIndex]->GetDetectorIndex(3);
3013 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
3014 Int_t ** indDet = new Int_t*[interestingCounter+1];
3015 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj] = new Int_t [5];
3016 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][0] = nSector;
3017 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][1] = nPlate;
3018 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][2] = nStrip;
3019 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][3] = padsCluster[2*jj+3];
3020 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
3021 GetClusterPars(/*check,*/ interestingCounter+1, indDet, interestingWeight, posClus, covClus);
3022 for (jj=0; jj<interestingCounter+1; jj++) delete [] indDet[jj];
3025 // To fill the track index array
3027 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
3028 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
3029 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
3032 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
3035 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
3036 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
3039 alreadyStored = kFALSE;
3040 for (jj=0; jj<dummyCounter+1; jj++)
3041 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
3043 if (alreadyStored) continue;
3044 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
3045 AliWarning(" Siamo al limite!");
3050 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
3055 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
3056 if (selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk)==-1) continue;
3059 alreadyStored = kFALSE;
3060 for (jj=0; jj<dummyCounter+1; jj++)
3061 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk));
3063 if (alreadyStored) continue;
3064 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
3065 AliWarning(" Siamo al limite!");
3070 tracks[dummyCounter] = selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk);
3075 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
3076 if (selectedDigit[adesso4][fourthIndex]->GetTrackLabel(kk)==-1) continue;
3079 alreadyStored = kFALSE;
3080 for (jj=0; jj<dummyCounter+1; jj++)
3081 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso4][fourthIndex]->GetTrackLabel(kk));
3083 if (alreadyStored) continue;
3084 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
3085 AliWarning(" Siamo al limite!");
3090 tracks[dummyCounter] = selectedDigit[adesso4][fourthIndex]->GetTrackLabel(kk);
3097 AliTOFcluster *tofCluster =
3098 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
3099 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
3100 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
3101 InsertCluster(tofCluster);
3103 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",
3104 volIdClus, posClus[0], posClus[1], posClus[2],
3105 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
3106 tracks[0], tracks[1], tracks[2],
3107 det[0], det[1], det[2], det[3], det[4],
3108 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
3109 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
3114 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
3118 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
3122 fTOFdigitMap->ResetDigitNumber(vol3,selectedDigit[adesso3][thirdIndex]->GetIndex());
3126 fTOFdigitMap->ResetDigitNumber(vol4,selectedDigit[adesso4][fourthIndex]->GetIndex());
3129 } // close loop on fourth digit
3131 } // close loop on third digit
3133 } // close loop on second digit
3135 } // close loop on first digit
3141 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
3142 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
3143 selectedDigit[ii][jj] = 0x0;
3147 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++) {
3148 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
3149 delete [] selectedDigit[ii][jj];
3150 selectedDigit[ii][jj] = 0x0;
3152 delete [] selectedDigit[ii];
3153 selectedDigit[ii] = 0x0;
3155 delete [] selectedDigit;
3156 selectedDigit = 0x0;
3159 //_____________________________________________________________________________
3161 Int_t AliTOFClusterFinderV1::InsertCluster(AliTOFcluster *tofCluster)
3164 // This function adds a TOF cluster to the array of TOF clusters
3165 // sorted in Z, i.e. fTofClusters
3168 if (fNumberOfTofClusters==kTofMaxCluster) {
3169 AliError("Too many clusters !");
3173 if (fNumberOfTofClusters==0) {
3174 fTofClusters[fNumberOfTofClusters++] = tofCluster;
3178 Int_t ii = FindClusterIndex(tofCluster->GetZ());
3179 memmove(fTofClusters+ii+1 ,fTofClusters+ii,(fNumberOfTofClusters-ii)*sizeof(AliTOFcluster*));
3180 fTofClusters[ii] = tofCluster;
3181 fNumberOfTofClusters++;
3186 //_____________________________________________________________________________
3188 Int_t AliTOFClusterFinderV1::FindClusterIndex(Double_t z) const
3191 // This function returns the index of the nearest cluster in z
3194 if (fNumberOfTofClusters==0) return 0;
3195 if (z <= fTofClusters[0]->GetZ()) return 0;
3196 if (z > fTofClusters[fNumberOfTofClusters-1]->GetZ()) return fNumberOfTofClusters;
3197 Int_t b = 0, e = fNumberOfTofClusters-1, m = (b+e)/2;
3198 for (; b<e; m=(b+e)/2) {
3199 if (z > fTofClusters[m]->GetZ()) b=m+1;
3206 //_____________________________________________________________________________
3208 void AliTOFClusterFinderV1::ResetRecpoint()
3211 // Clear the list of reconstructed points
3214 fNumberOfTofClusters = 0;
3215 if (fRecPoints) fRecPoints->Clear();
3218 //_____________________________________________________________________________
3220 void AliTOFClusterFinderV1::ResetDigits()
3223 // Clear the list of digits
3226 fNumberOfTofDigits = 0;
3227 if (fDigits) fDigits->Clear();
3230 //_____________________________________________________________________________
3231 //UShort_t AliTOFClusterFinderV1::GetClusterVolIndex(Int_t *ind) const
3234 // Get the volume ID to retrieve the l2t transformation
3237 // Detector numbering scheme
3239 Int_t nSector = AliTOFGeometry::NSectors();
3240 Int_t nPlate = AliTOFGeometry::NPlates();
3241 Int_t nStripA = AliTOFGeometry::NStripA();
3242 Int_t nStripB = AliTOFGeometry::NStripB();
3243 Int_t nStripC = AliTOFGeometry::NStripC();
3245 Int_t isector =ind[0];
3246 if (isector >= nSector)
3247 AliError(Form("Wrong sector number in TOF (%d) !", isector));
3248 Int_t iplate = ind[1];
3249 if (iplate >= nPlate)
3250 AliError(Form("Wrong plate number in TOF (%d) !", iplate));
3251 Int_t istrip = ind[2];
3253 Int_t stripOffset = 0;
3259 stripOffset = nStripC;
3262 stripOffset = nStripC+nStripB;
3265 stripOffset = nStripC+nStripB+nStripA;
3268 stripOffset = nStripC+nStripB+nStripA+nStripB;
3271 AliError(Form("Wrong plate number in TOF (%d) !", iplate));
3275 Int_t index= (2*(nStripC+nStripB)+nStripA)*isector +
3279 UShort_t volIndex = AliGeomManager::LayerToVolUID(AliGeomManager::kTOF, index);
3284 //_____________________________________________________________________________
3286 void AliTOFClusterFinderV1::GetClusterPars(Int_t *ind, Double_t* pos, Double_t* cov) const
3289 // Starting from the volume indices (ind[5]), for a cluster coming from
3290 // a isolated digits, this function returns:
3291 // the cluster position (pos),
3292 // the cluster covariance matrix elements (cov)
3296 //we now go in the system of the strip: determine the local coordinates
3299 // 47---------------------------------------------------0 ^ z
3300 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 1 |
3301 // ----------------------------------------------------- | y going outwards
3302 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 0 | par[0]=0;
3304 // ----------------------------------------------------- |
3305 // x <-----------------------------------------------------
3307 //move to the tracking ref system
3308 Double_t lpos[3] = { (ind[4]-23.5)*AliTOFGeometry::XPad(),
3310 (ind[3]- 0.5)*AliTOFGeometry::ZPad() };
3311 AliDebug(1, Form(" %f %f %f", lpos[0], lpos[1], lpos[2]));
3314 UShort_t volIndex = fTOFGeometry->GetAliSensVolIndex(ind[0],ind[1],ind[2]);
3315 //UShort_t volIndex = GetClusterVolIndex(ind);
3316 const TGeoHMatrix *l2t = AliGeomManager::GetTracking2LocalMatrix(volIndex);
3318 // Get the position in the track ref system
3320 l2t->MasterToLocal(lpos,tpos);
3325 //Get the cluster covariance in the track ref system
3327 for (Int_t ii=0; ii<9; ii++) lcov[ii] = 0.;
3329 //cluster covariance in the local system:
3334 lcov[4] = 0.42*0.42/3.;
3335 // = ( 5*0.025 (gas gaps thikness)
3336 // + 4*0.040 (internal glasses thickness)
3337 // + 0.5*0.160 (internl PCB)
3338 // + 1*0.055 (external red glass))
3341 lcov[0] = 0.499678;//AliTOFGeometry::XPad()*AliTOFGeometry::XPad()/12.;
3342 lcov[8] = 0.992429;//AliTOFGeometry::ZPad()*AliTOFGeometry::ZPad()/12.;
3344 //cluster covariance in the tracking system:
3346 m.SetRotation(lcov);
3348 m.MultiplyLeft(&l2t->Inverse());
3349 Double_t *tcov = m.GetRotationMatrix();
3350 cov[0] = tcov[0]; cov[1] = tcov[1]; cov[2] = tcov[2];
3351 cov[3] = tcov[4]; cov[4] = tcov[5]; cov[5] = tcov[8];
3356 //_____________________________________________________________________________
3358 void AliTOFClusterFinderV1::GetClusterPars(/*Bool_t check,*/ Int_t counter,
3359 Int_t **ind, Double_t *weight,
3360 Double_t *pos, Double_t *cov) const
3364 // the volumes indices (ind[counter][5]), for a
3365 // cluster coming from a collection of 'counter'
3367 // the volumes weights (weight[counter]), -controlled
3368 // by the 'check' variable control-, for a cluster
3369 // coming from a collection of 'counter' digits,
3370 // the cluster position (pos),
3371 // this function returns:
3372 // the covariance matrix elements (cov) for the found cluster
3376 // we now go in the system of the strip: determine the local coordinates
3378 // 47---------------------------------------------------0 ^ z
3379 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 1 |
3380 // ----------------------------------------------------- | y going outwards
3381 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 0 | par[0]=0;
3383 // ----------------------------------------------------- |
3384 // x <-----------------------------------------------------
3386 for (Int_t ii=0; ii<counter; ii++)
3387 AliDebug(1, Form(" %2d %2d %1d %2d %1d %2d ",
3388 ii, ind[ii][0], ind[ii][1], ind[ii][2], ind[ii][3], ind[ii][4]));
3390 Float_t posF[3]; for (Int_t ii=0; ii<3; ii++) posF[ii] = (Float_t)pos[ii];
3391 AliDebug(1, Form(" %f %f %f", pos[0], pos[1], pos[2]));
3393 Int_t detClus[5] = {-1, -1, -1, -1, -1};
3394 fTOFGeometry->GetDetID(posF, detClus);
3397 UShort_t volIndex = fTOFGeometry->GetAliSensVolIndex(detClus[0],detClus[1],detClus[2]);
3398 //UShort_t volIndex = GetClusterVolIndex(detClus);
3399 AliDebug(1, Form(" %2d %1d %2d %1d %2d %7i",
3400 detClus[0], detClus[1], detClus[2], detClus[3], detClus[4], volIndex));
3402 // Get the position in the TOF strip ref system
3403 const TGeoHMatrix *alice2strip = AliGeomManager::GetOrigGlobalMatrix(volIndex);
3404 Double_t ppos[3] = {-1, -1, -1};
3405 alice2strip->MasterToLocal(pos,ppos);
3406 AliDebug(1, Form(" %f %f %f", ppos[0], ppos[1], ppos[2]));
3409 // Get the position in the tracking ref system
3410 const TGeoHMatrix *g2l = AliGeomManager::GetTracking2LocalMatrix(volIndex);
3411 Double_t lpos[3] = {-1, -1, -1};
3412 g2l->MasterToLocal(ppos,lpos);
3413 AliDebug(1, Form(" %f %f %f", lpos[0], lpos[1], lpos[2]));
3414 for (Int_t ii=0; ii<3; ii++) pos[ii] = lpos[ii];
3416 //Get the cluster covariance in the track ref system
3418 for (Int_t ii=0; ii<9; ii++) lcov[ii] = 0.;
3420 //cluster covariance in the local system:
3425 // Evaluation of the ovariance matrix elements
3426 TOFclusterError(/*check,*/ counter, ind, weight, ppos, lcov);
3428 AliDebug(1, Form("lcov[0] = %f, lcov[8] = %f", lcov[0], lcov[8]));
3430 //cluster covariance in the tracking system:
3432 m.SetRotation(lcov);
3434 m.MultiplyLeft(&g2l->Inverse());
3435 Double_t *tcov = m.GetRotationMatrix();
3436 cov[0] = tcov[0]; cov[1] = tcov[1]; cov[2] = tcov[2];
3437 cov[3] = tcov[4]; cov[4] = tcov[5]; cov[5] = tcov[8];
3442 //_____________________________________________________________________________
3444 void AliTOFClusterFinderV1::TOFclusterError(/*Bool_t check,*/ Int_t counter,
3445 Int_t **ind, Double_t *weight,
3446 Double_t ppos[], Double_t lcov[]) const
3452 //lcov[4] = 0.42*0.42/3.; // cm2
3453 // = ( 5*0.025 (gas gaps thikness)
3454 // + 4*0.040 (internal glasses thickness)
3455 // + 0.5*0.160 (internl PCB)
3456 // + 1*0.055 (external red glass))
3459 Float_t *delta2X = new Float_t[counter];
3460 for (Int_t ii=0; ii<counter; ii++)
3462 ((ind[ii][4]-23.5)*AliTOFGeometry::XPad() - ppos[0])*((ind[ii][4]-23.5)*AliTOFGeometry::XPad() - ppos[0]);
3464 Float_t *delta2Z = new Float_t[counter];
3465 for (Int_t ii=0; ii<counter; ii++)
3467 ((ind[ii][3]- 0.5)*AliTOFGeometry::ZPad() - ppos[2])*((ind[ii][3]- 0.5)*AliTOFGeometry::ZPad() - ppos[2]);
3469 for (Int_t ii=0; ii<counter; ii++)
3470 AliDebug(1, Form("x[%d] = %f, z[%d] = %f, weight[%d] = %f",
3471 ii, (ind[ii][4]-23.5)*AliTOFGeometry::XPad(),
3472 ii, (ind[ii][3]- 0.5)*AliTOFGeometry::ZPad(),
3475 AliDebug(1, Form("xMean = %f, zMean = %f",ppos[0], ppos[2]));
3483 if (ind[0][3]==ind[1][3] && TMath::Abs(ind[0][4]-ind[1][4])==1) { //
3485 lcov[8] = 1.02039; // cm2
3486 lcov[0] = 0.0379409; // cm2
3489 lcov[0] = 0.5*0.5; // cm2
3491 if (weight[0]==weight[1])
3492 lcov[0] = 0.0379409; // cm2
3494 lcov[0] = TMath::Mean(counter, delta2X, weight); // cm2
3500 else if (ind[0][4]==ind[1][4] && TMath::Abs(ind[0][3]-ind[1][3])==1) {//
3502 lcov[0] = 0.505499; // cm2
3503 lcov[8] = 0.0422046; // cm2
3506 lcov[8] = 0.5*0.5; // cm2
3508 if (weight[0]==weight[1])
3509 lcov[8] = 0.0422046; // cm2
3511 lcov[8] = TMath::Mean(counter, delta2Z, weight); // cm2
3520 lcov[0] = 0.0290677; // cm2
3521 lcov[8] = 0.0569726; // cm2
3524 lcov[0] = 0.5*0.5; // cm2
3525 lcov[8] = 0.5*0.5; // cm2
3528 if (weight[0]==weight[1] && weight[0]==weight[2]) {
3529 lcov[0] = 0.0290677; // cm2
3530 lcov[8] = 0.0569726; // cm2
3533 lcov[0] = TMath::Mean(counter, delta2X, weight); // cm2
3534 lcov[8] = TMath::Mean(counter, delta2Z, weight); // cm2
3543 lcov[0] = 0.0223807; // cm2
3544 lcov[8] = 0.0438662; // cm2
3547 lcov[0] = 0.5*0.5; // cm2
3548 lcov[8] = 0.5*0.5; // cm2
3551 if (weight[0]==weight[1] && weight[0]==weight[2] && weight[0]==weight[3]) {
3552 lcov[0] = 0.0223807; // cm2
3553 lcov[8] = 0.0438662; // cm2
3556 lcov[0] = TMath::Mean(counter, delta2X, weight); // cm2
3557 lcov[8] = TMath::Mean(counter, delta2Z, weight); // cm2
3571 //_____________________________________________________________________________
3573 Bool_t AliTOFClusterFinderV1::MakeSlewingCorrection(Int_t *detectorIndex,
3579 // This funtion makes the following:
3581 // - if at least one of the three status (Pulser/Noise/HW) is
3582 // bad, is sets the status of electronic channel, corresponding to the
3583 // volume identified by detectorIndex, as kFALSE;
3584 // - if offline calibration is in the valid status, it performs the
3585 // slewing correction. In particular, by taking into account:
3586 // * the measured tot and tof values (tofDigitToT and tofDigitTdc,
3588 // * the six parameters of 5th order polynomial used
3589 // to fit the tofVStot scatter plot,
3590 // it returns the corrected tof value, i.e. tdcCorr value.
3593 Bool_t output = kTRUE;
3598 //AliInfo(" Calibrating TOF Digits: ");
3600 AliTOFChannelOnlineArray *calDelay = fTOFcalib->GetTOFOnlineDelay();
3601 AliTOFChannelOnlineStatusArray *calStatus = fTOFcalib->GetTOFOnlineStatus();
3603 TObjArray *calTOFArrayOffline = fTOFcalib->GetTOFCalArrayOffline();
3605 Int_t index = AliTOFGeometry::GetIndex(detectorIndex);
3607 UChar_t statusPulser = calStatus->GetPulserStatus(index);
3608 UChar_t statusNoise = calStatus->GetNoiseStatus(index);
3609 UChar_t statusHW = calStatus->GetHWStatus(index);
3610 UChar_t status = calStatus->GetStatus(index);
3612 //check the status, also unknown is fine!!!!!!!
3614 AliDebug(2, Form(" Status for channel %d = %d",index, (Int_t)status));
3615 if((statusPulser & AliTOFChannelOnlineStatusArray::kTOFPulserBad)==(AliTOFChannelOnlineStatusArray::kTOFPulserBad)||(statusNoise & AliTOFChannelOnlineStatusArray::kTOFNoiseBad)==(AliTOFChannelOnlineStatusArray::kTOFNoiseBad)||(statusHW & AliTOFChannelOnlineStatusArray::kTOFHWBad)==(AliTOFChannelOnlineStatusArray::kTOFHWBad)){
3616 AliDebug(2, Form(" Bad Status for channel %d",index));
3617 //fTofClusters[ii]->SetStatus(kFALSE); //odd convention, to avoid conflict with calibration objects currently in the db (temporary solution).
3621 AliDebug(2, Form(" Good Status for channel %d",index));
3624 if (fCalibrateTOFtimes) { // AdC
3626 // Get Rough channel online equalization
3627 Double_t roughDelay = (Double_t)calDelay->GetDelay(index); // in ns
3628 AliDebug(2,Form(" channel delay (ns) = %f", roughDelay));
3629 // Get Refined channel offline calibration parameters
3630 TString validity = (TString)fTOFcalib->GetOfflineValidity();
3631 if (validity.CompareTo("valid")==0) {
3632 AliTOFChannelOffline * calChannelOffline = (AliTOFChannelOffline*)calTOFArrayOffline->At(index);
3634 for (jj = 0; jj<6; jj++)
3635 par[jj] = (Double_t)calChannelOffline->GetSlewPar(jj);
3637 AliDebug(2,Form(" Calib Pars = %f, %f, %f, %f, %f, %f ",par[0],par[1],par[2],par[3],par[4],par[5]));
3638 AliDebug(2,Form(" The ToT and Time, uncorr (counts) = %d , %d", tofDigitToT, tofDigitTdc));
3639 Double_t tToT = (Double_t)(tofDigitToT*AliTOFGeometry::ToTBinWidth());
3640 tToT*=1.E-3; //ToT in ns
3641 AliDebug(2,Form(" The ToT and Time, uncorr (ns)= %e, %e",tofDigitTdc*AliTOFGeometry::TdcBinWidth()*1.E-3,tToT));
3642 timeCorr = par[0] + tToT*(par[1] + tToT*(par[2] + tToT*(par[3] + tToT*(par[4] + tToT*par[5])))); // the time correction (ns)
3645 timeCorr = roughDelay; // correction in ns
3647 AliDebug(2,Form(" The ToT and Time, uncorr (ns)= %e, %e",tofDigitTdc*AliTOFGeometry::TdcBinWidth()*1.E-3,tofDigitToT*AliTOFGeometry::ToTBinWidth()));
3648 AliDebug(2,Form(" The time correction (ns) = %f", timeCorr));
3649 timeCorr = (Double_t)(tofDigitTdc)*AliTOFGeometry::TdcBinWidth()*1.E-3-timeCorr;//redefine the time
3651 AliDebug(2,Form(" The channel time, corr (ps)= %e",timeCorr ));
3652 //tdcCorr = (Int_t)(timeCorr/AliTOFGeometry::TdcBinWidth()); //the corrected time (tdc counts)
3653 tdcCorr = TMath::Nint(timeCorr/AliTOFGeometry::TdcBinWidth()); //the corrected time (tdc counts)
3660 //______________________________________________________________________________
3662 void AliTOFClusterFinderV1::Digits2RecPoints(Int_t iEvent)
3665 // Converts digits to recpoints for TOF
3668 TStopwatch stopwatch;
3671 fRunLoader->GetEvent(iEvent);
3673 AliLoader *localTOFLoader = (AliLoader*)fRunLoader->GetLoader("TOFLoader");
3675 TTree * localTreeD = (TTree*)localTOFLoader->TreeD();
3676 if (localTreeD == 0x0) {
3677 AliFatal("Can not get TreeD");
3681 TBranch *branch = localTreeD->GetBranch("TOF");
3683 AliError("Can't get the branch with the TOF digits !");
3687 TTree *localTreeR = (TTree*)localTOFLoader->TreeR();
3688 if (localTreeR == 0x0)
3690 localTOFLoader->MakeTree("R");
3691 localTreeR = localTOFLoader->TreeR();
3694 Digits2RecPoints(localTreeD, localTreeR);
3696 //localTOFLoader = fRunLoader->GetLoader("TOFLoader");
3697 localTOFLoader->WriteRecPoints("OVERWRITE");
3699 AliDebug(1, Form("Execution time to read TOF digits and to write TOF clusters for the event number %d: R:%.4fs C:%.4fs",
3700 iEvent, stopwatch.RealTime(),stopwatch.CpuTime()));
3703 //______________________________________________________________________________
3705 void AliTOFClusterFinderV1::Digits2RecPoints(Int_t iEvent, AliRawReader *rawReader)
3708 // Converts RAW data to recpoints for TOF
3711 TStopwatch stopwatch;
3714 fRunLoader->GetEvent(iEvent);
3716 AliDebug(2,Form(" Event number %2d ", iEvent));
3718 AliLoader *localTOFLoader = (AliLoader*)fRunLoader->GetLoader("TOFLoader");
3720 TTree *localTreeR = localTOFLoader->TreeR();
3722 if (localTreeR == 0x0){
3723 localTOFLoader->MakeTree("R");
3724 localTreeR = localTOFLoader->TreeR();
3727 Digits2RecPoints(rawReader, localTreeR);
3729 AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters for the event number %d: R:%.4fs C:%.4fs",
3730 iEvent, stopwatch.RealTime(),stopwatch.CpuTime()));
3733 //______________________________________________________________________________
3735 void AliTOFClusterFinderV1::Raw2Digits(Int_t iEvent, AliRawReader *rawReader)
3738 // Converts RAW data to MC digits for TOF
3742 TStopwatch stopwatch;
3745 fRunLoader->GetEvent(iEvent);
3747 AliDebug(2,Form(" Event number %2d ", iEvent));
3749 AliLoader *localTOFLoader = (AliLoader*)fRunLoader->GetLoader("TOFLoader");
3751 TTree *localTreeD = localTOFLoader->TreeD();
3753 if (localTreeD == 0x0){
3754 localTOFLoader->MakeTree("D");
3755 localTreeD = localTOFLoader->TreeD();
3758 Raw2Digits(rawReader, localTreeD);
3760 AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters for the event number %d: R:%.4fs C:%.4fs",
3761 iEvent, stopwatch.RealTime(),stopwatch.CpuTime()));
3764 //______________________________________________________________________________
3766 void AliTOFClusterFinderV1::AverageCalculations(Int_t number, Float_t *interestingX,
3767 Float_t *interestingY, Float_t *interestingZ,
3768 Double_t *interestingTOF, Double_t *interestingTOT,
3769 Double_t *interestingADC, Double_t *interestingWeight,
3770 Int_t *parTOF, Double_t *posClus, Bool_t &check)
3773 // Calculates the mean values for cluster position (x,y,z),
3774 // TOF charge and time
3777 Double_t tofAverage = 0.;
3778 Double_t totAverage = 0.;
3779 Double_t adcAverage = 0.;
3783 for (ii=number-1; ii>=0; ii--) check=check||(interestingWeight[ii]==0 || interestingWeight[ii]==-1);
3787 posClus[0] = TMath::Mean(number, interestingX);
3788 posClus[1] = TMath::Mean(number, interestingY);
3789 posClus[2] = TMath::Mean(number, interestingZ);
3790 tofAverage = TMath::Mean(number, interestingTOF);
3791 totAverage = TMath::Mean(number, interestingTOT);
3792 adcAverage = TMath::Mean(number, interestingADC);
3797 posClus[0] = TMath::Mean(number, interestingX, interestingWeight);
3798 posClus[1] = TMath::Mean(number, interestingY, interestingWeight);
3799 posClus[2] = TMath::Mean(number, interestingZ, interestingWeight);
3800 tofAverage = TMath::Mean(number, interestingTOF, interestingWeight);
3801 totAverage = TMath::Mean(number, interestingTOT, interestingWeight);
3802 adcAverage = TMath::Mean(number, interestingADC, interestingWeight);
3806 parTOF[0] = Int_t(tofAverage);
3807 parTOF[1] = Int_t(totAverage);
3808 parTOF[2] = Int_t(adcAverage);
3809 parTOF[3] = Int_t(tofAverage);//tofND
3810 parTOF[4] = Int_t(tofAverage);//tofRAW