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"
63 ClassImp(AliTOFClusterFinderV1)
65 //_____________________________________________________________________________
66 AliTOFClusterFinderV1::AliTOFClusterFinderV1(AliTOFcalib *calib):
67 TNamed("AliTOFClusterFinderV1",""),
69 fDigits(new TClonesArray("AliTOFdigit", 4000)),
70 fRecPoints(new TClonesArray("AliTOFcluster", 4000)),
71 fNumberOfTofClusters(0),
72 fNumberOfTofDigits(0),
73 fkRecoParam(0),//AliTOFReconstructor::GetRecoParam()),
74 fMaxDeltaTime(0),//fkRecoParam->GetMaxDeltaTime()),
78 fTOFdigitMap(new AliTOFDigitMap()),
79 fTOFGeometry(new AliTOFGeometry()),
80 fTOFdigits(new TTree()),
81 fTOFRawStream(AliTOFRawStream()),
88 for (Int_t ii=0; ii<kTofMaxCluster; ii++) fTofClusters[ii]=0x0;
90 if (AliTOFReconstructor::GetRecoParam()) {
91 fkRecoParam = AliTOFReconstructor::GetRecoParam();
92 fMaxDeltaTime = fkRecoParam->GetMaxDeltaTime();
97 TString validity = (TString)fTOFcalib->GetOfflineValidity();
98 if (validity.CompareTo("valid")==0) {
99 AliInfo(Form(" validity = %s - Using offline calibration parameters", validity.Data()));
101 AliInfo(Form(" validity = %s - Using online calibration parameters", validity.Data()));
106 //_____________________________________________________________________________
107 AliTOFClusterFinderV1::AliTOFClusterFinderV1(AliRunLoader* runLoader, AliTOFcalib *calib):
108 TNamed("AliTOFClusterFinderV1",""),
109 fRunLoader(runLoader),
110 fDigits(new TClonesArray("AliTOFdigit", 4000)),
111 fRecPoints(new TClonesArray("AliTOFcluster", 4000)),
112 fNumberOfTofClusters(0),
113 fNumberOfTofDigits(0),
114 fkRecoParam(0),//AliTOFReconstructor::GetRecoParam()),
115 fMaxDeltaTime(0),//fkRecoParam->GetMaxDeltaTime()),
119 fTOFdigitMap(new AliTOFDigitMap()),
120 fTOFGeometry(new AliTOFGeometry()),
121 fTOFdigits(new TTree()),
122 fTOFRawStream(AliTOFRawStream()),
123 fCalibrateTOFtimes(1)
129 for (Int_t ii=0; ii<kTofMaxCluster; ii++) fTofClusters[ii]=0x0;
131 if (AliTOFReconstructor::GetRecoParam()) {
132 fkRecoParam = AliTOFReconstructor::GetRecoParam();
133 fMaxDeltaTime = fkRecoParam->GetMaxDeltaTime();
138 TString validity = (TString)fTOFcalib->GetOfflineValidity();
139 if (validity.CompareTo("valid")==0) {
140 AliInfo(Form(" validity = %s - Using offline calibration parameters", validity.Data()));
142 AliInfo(Form(" validity = %s - Using online calibration parameters", validity.Data()));
146 //_____________________________________________________________________________
148 AliTOFClusterFinderV1::AliTOFClusterFinderV1(const AliTOFClusterFinderV1 &source)
151 fDigits(source.fDigits),
152 fRecPoints(source.fRecPoints),
153 fNumberOfTofClusters(0),
154 fNumberOfTofDigits(0),
155 fkRecoParam(0),//AliTOFReconstructor::GetRecoParam()),
156 fMaxDeltaTime(0),//fkRecoParam->GetMaxDeltaTime()),
158 fDecoderVersion(source.fDecoderVersion),
159 fTOFcalib(source.fTOFcalib),
160 fTOFdigitMap(new AliTOFDigitMap()),
161 fTOFGeometry(new AliTOFGeometry()),
162 fTOFdigits(source.fTOFdigits),
163 fTOFRawStream(source.fTOFRawStream),
164 fCalibrateTOFtimes(1)
168 for (Int_t ii=0; ii<kTofMaxCluster; ii++) fTofClusters[ii]=source.fTofClusters[ii];
170 if (AliTOFReconstructor::GetRecoParam()) {
171 fkRecoParam = AliTOFReconstructor::GetRecoParam();
172 fMaxDeltaTime = fkRecoParam->GetMaxDeltaTime();
178 //_____________________________________________________________________________
180 AliTOFClusterFinderV1& AliTOFClusterFinderV1::operator=(const AliTOFClusterFinderV1 &source)
187 TObject::operator=(source);
188 for (Int_t ii=0; ii<kTofMaxCluster; ii++) fTofClusters[ii]=source.fTofClusters[ii];
189 fDigits=source.fDigits;
190 fRecPoints=source.fRecPoints;
191 fVerbose=source.fVerbose;
192 fDecoderVersion=source.fDecoderVersion;
193 fTOFcalib=source.fTOFcalib;
194 fTOFdigitMap=source.fTOFdigitMap;
195 fTOFGeometry=source.fTOFGeometry;
196 fTOFdigits=source.fTOFdigits;
197 fTOFRawStream=source.fTOFRawStream;
198 fCalibrateTOFtimes=source.fCalibrateTOFtimes;
202 //_____________________________________________________________________________
204 AliTOFClusterFinderV1::~AliTOFClusterFinderV1()
219 fRecPoints->Delete();
230 //if (fTofClusters || fNumberOfTofClusters) {
231 if (fNumberOfTofClusters) {
232 for (Int_t ii=0; ii<fNumberOfTofClusters; ii++)
233 if (fTofClusters[ii]) fTofClusters[ii]->Delete();
234 fNumberOfTofClusters = 0;
238 //_____________________________________________________________________________
240 void AliTOFClusterFinderV1::Digits2RecPoints(TTree* digitsTree, TTree* clusterTree)
243 // Converts digits to recPoints for TOF
246 TStopwatch stopwatch;
252 TClonesArray &aDigits = *fDigits;
254 if (digitsTree == 0x0) {
255 AliFatal("Can not get TreeD for TOF");
259 TBranch *branch = digitsTree->GetBranch("TOF");
261 AliError("Can not get branch with the TOF digits !");
265 TClonesArray staticDigits("AliTOFdigit",10000);
266 staticDigits.Clear();
267 TClonesArray *digits = &staticDigits;
268 branch->SetAddress(&digits);
269 digitsTree->GetEvent(0);
270 AliDebug(1,Form("Number of TOF digits: %d", digits->GetEntriesFast()));
272 AliTOFdigit *tofDigit;
275 Int_t detectorIndex[5];
276 for (jj=0; jj<5; jj++) detectorIndex[jj] = -1;
278 for (jj=0; jj<4; jj++) info[jj] = -1;
284 Bool_t status = kTRUE;
286 AliDebug(1," Calibrating TOF Digits");
288 TString validity = (TString)fTOFcalib->GetOfflineValidity();
289 if (validity.CompareTo("valid")==0) {
290 AliInfo(Form(" validity = %s - Using offline calibration parameters", validity.Data()));
292 AliInfo(Form(" validity = %s - Using online calibration parameters", validity.Data()));
296 for (ii=0; ii<digits->GetEntriesFast(); ii++) {
297 tofDigit = (AliTOFdigit*)digits->UncheckedAt(ii);
298 detectorIndex[0] = tofDigit->GetSector();
299 detectorIndex[1] = tofDigit->GetPlate();
300 detectorIndex[2] = tofDigit->GetStrip();
301 detectorIndex[3] = tofDigit->GetPadz();
302 detectorIndex[4] = tofDigit->GetPadx();
304 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
305 if (detectorIndex[1]==2) { // plate with holes
311 tdcCorr = tofDigit->GetTdc();
312 status = MakeSlewingCorrection(detectorIndex, tofDigit->GetToT(), tofDigit->GetTdc(), tdcCorr);
314 for (jj=0; jj<4; jj++) info[jj] = -1;
315 info[0] = tdcCorr;//tofDigit->GetTdc();
316 info[1] = tofDigit->GetAdc();
317 info[2] = tofDigit->GetToT();
318 info[3] = tofDigit->GetTdcND();//tofDigit->GetTdc();//
319 tracks = tofDigit->GetTracks();
321 dummy = detectorIndex[3];
322 detectorIndex[3] = detectorIndex[4];//padx
323 detectorIndex[4] = dummy;//padz
324 last = fDigits->GetEntriesFast();
325 new (aDigits[last]) AliTOFdigit(tracks, detectorIndex, info);
326 if (status) fTOFdigitMap->AddDigit(detectorIndex, last);
328 AliDebug(2, Form(" Digits reading %2d -> %2d %1d %2d %1d %2d (%d, %d, %d)",
330 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[3], detectorIndex[4],
331 info[0], info[1], info[3]));
335 fNumberOfTofDigits = fDigits->GetEntriesFast();
339 Int_t bufsize = 32000;
340 clusterTree->Branch("TOF", &fRecPoints, bufsize);
345 AliDebug(1,Form("Number of found clusters: %d", fNumberOfTofClusters));
349 fTOFdigitMap->Clear();
353 AliDebug(1,Form("Execution time to read TOF digits and to write TOF clusters : R:%.4fs C:%.4fs",
354 stopwatch.RealTime(),stopwatch.CpuTime()));
356 if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
359 //_____________________________________________________________________________
361 void AliTOFClusterFinderV1::Digits2RecPoints(AliRawReader *rawReader, TTree *clustersTree)
364 // Converts raw data to recPoints for TOF
367 TStopwatch stopwatch;
371 AliDebug(2, "TreeD re-creation");
372 //TTree *digitsTree = new TTree();
373 //Raw2Digits(rawReader, digitsTree);
375 Raw2Digits(rawReader, fTOFdigits);
377 AliDebug(1,Form("Number of TOF digits: %d", fNumberOfTofDigits));
380 Int_t bufsize = 32000;
381 clustersTree->Branch("TOF", &fRecPoints, bufsize);
384 clustersTree->Fill();
386 AliDebug(1,Form("Number of found clusters: %d", fNumberOfTofClusters));
390 fTOFdigitMap->Clear();
394 AliDebug(1,Form("Execution time to read TOF raw data and to write TOF clusters : R:%.4fs C:%.4fs",
395 stopwatch.RealTime(),stopwatch.CpuTime()));
399 //_____________________________________________________________________________
401 void AliTOFClusterFinderV1::Raw2Digits(AliRawReader *rawReader, TTree* digitsTree)
404 // Converts raw data to digits for TOF
407 TStopwatch stopwatch;
412 const Int_t kMaxNumberOfTracksPerDigit = 3;
413 const Int_t kDDL = AliDAQ::NumberOfDdls("TOF");
415 digitsTree->Branch("TOF", &fDigits);
416 TClonesArray &aDigits = *fDigits;
418 fTOFRawStream.Clear();
419 fTOFRawStream.SetRawReader(rawReader);
422 if (fVerbose==2) ftxt.open("TOFdigitsRead.txt",ios::app);
424 TClonesArray staticRawData("AliTOFrawData",10000);
425 staticRawData.Clear();
426 TClonesArray * clonesRawData = &staticRawData;
429 Int_t detectorIndex[5] = {-1, -1, -1, -1, -1};
431 Int_t tracks[kMaxNumberOfTracksPerDigit];
432 for (Int_t ii=0; ii<kMaxNumberOfTracksPerDigit; ii++)
437 Bool_t status = kTRUE;
440 TString validity = (TString)fTOFcalib->GetOfflineValidity();
441 if (validity.CompareTo("valid")==0) {
442 AliInfo(Form(" validity = %s - Using offline calibration parameters", validity.Data()));
444 AliInfo(Form(" validity = %s - Using online calibration parameters", validity.Data()));
448 AliInfo("Using New Decoder");
452 for (indexDDL=0; indexDDL<kDDL; indexDDL++) {
456 fTOFRawStream.LoadRawDataBuffers(indexDDL,fVerbose);
457 else fTOFRawStream.LoadRawData(indexDDL);
459 clonesRawData = (TClonesArray*)fTOFRawStream.GetRawData();
460 if (clonesRawData->GetEntriesFast()!=0) AliDebug(2,Form(" TOF raw data number = %3d", clonesRawData->GetEntriesFast()));
461 for (iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
463 AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
465 //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
466 if (tofRawDatum->GetTOF()==-1) continue;
468 fTOFRawStream.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
469 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
472 dummy = detectorIndex[3];
473 detectorIndex[3] = detectorIndex[4];//padz
474 detectorIndex[4] = dummy;//padx
476 tdcCorr = tofRawDatum->GetTOF();
477 status = MakeSlewingCorrection(detectorIndex, tofRawDatum->GetTOT(), tofRawDatum->GetTOF(), tdcCorr);
480 digit[1] = tofRawDatum->GetTOT();
481 digit[2] = tofRawDatum->GetTOT();
482 digit[3] = -1;//tofRawDatum->GetTOF(); //tofND
484 dummy = detectorIndex[3];
485 detectorIndex[3] = detectorIndex[4];//padx
486 detectorIndex[4] = dummy;//padz
488 /* check valid index */
489 if (detectorIndex[0]==-1||detectorIndex[1]==-1||detectorIndex[2]==-1||detectorIndex[3]==-1||detectorIndex[4]==-1) continue;
491 // Do not reconstruct anything in the holes
492 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
493 if (detectorIndex[1]==2) { // plate with holes
499 last = fDigits->GetEntriesFast();
500 new (aDigits[last]) AliTOFdigit(tracks, detectorIndex, digit);
501 if (status) fTOFdigitMap->AddDigit(detectorIndex, last);
504 if (indexDDL<10) ftxt << " " << indexDDL;
505 else ftxt << " " << indexDDL;
506 if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM();
507 else ftxt << " " << tofRawDatum->GetTRM();
508 ftxt << " " << tofRawDatum->GetTRMchain();
509 if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC();
510 else ftxt << " " << tofRawDatum->GetTDC();
511 ftxt << " " << tofRawDatum->GetTDCchannel();
513 if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0];
514 else ftxt << " -> " << detectorIndex[0];
515 ftxt << " " << detectorIndex[1];
516 if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2];
517 else ftxt << " " << detectorIndex[2];
518 ftxt << " " << detectorIndex[4];
519 if (detectorIndex[4]<10) ftxt << " " << detectorIndex[3];
520 else ftxt << " " << detectorIndex[3];
522 if (digit[1]<10)ftxt << " " << digit[1];
523 else if (digit[1]>=10 && digit[1]<100) ftxt << " " << digit[1];
524 else ftxt << " " << digit[1];
525 if (digit[0]<10) ftxt << " " << digit[0] << endl;
526 else if (digit[0]>=10 && digit[0]<100) ftxt << " " << digit[0] << endl;
527 else if (digit[0]>=100 && digit[0]<1000) ftxt << " " << digit[0] << endl;
528 else ftxt << " " << digit[3] << endl;
531 AliDebug(2, Form(" Raw data reading %2d -> %2d %1d %2d %1d %2d (%d, %d, %d)",
533 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[4], detectorIndex[3],
534 digit[0], digit[1], digit[3]));
538 clonesRawData->Clear();
542 if (fVerbose==2) ftxt.close();
546 fNumberOfTofDigits = fDigits->GetEntries();
548 AliDebug(1, Form("Got %d TOF digits", fNumberOfTofDigits));
549 AliDebug(1, Form("Execution time to read TOF raw data and fill TOF digit tree : R:%.2fs C:%.2fs",
550 stopwatch.RealTime(),stopwatch.CpuTime()));
552 if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
555 //_____________________________________________________________________________
557 void AliTOFClusterFinderV1::FillRecPoint()
560 // Fill the global TClonesArray of AliTOFcluster objects,
569 for(Int_t iPlate=AliTOFGeometry::NPlates()-1; iPlate>=0; iPlate--) {
570 for(Int_t iStrip=AliTOFGeometry::NStrip(iPlate)-1; iStrip>=0; iStrip--) {
571 //for (Int_t iSector=AliTOFGeometry::NSectors()-1; iSector>=0; iSector--) {
572 for (Int_t iSector=0; iSector<AliTOFGeometry::NSectors(); iSector++) {
575 if (fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))
576 AliDebug(1,Form(" Number of TOF digits in (%2d,%1d,%2d) -> %d",
577 iSector,iPlate,iStrip,fTOFdigitMap->FilledCellsInStrip(iSector,iPlate,iStrip)));
579 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
580 FindClustersWithoutTOT(iSector, iPlate, iStrip); // clusters coming from digits without TOT measurement
582 if (fMaxDeltaTime>0) {
584 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
585 //if (fTOFdigitMap->FilledCellsInStrip(iSector,iPlate,iStrip)>=4)
586 FindClustersPerStrip(iSector, iPlate, iStrip, 4); // 4 pads clusters
587 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
589 dummy4 = fNumberOfTofClusters;
590 FindClustersPerStrip(iSector, iPlate, iStrip, 4); // 4 pads clusters
591 if (fNumberOfTofClusters!=dummy4)
592 AliDebug(2, Form(" (4): n1= %5d, n2 = %5d", dummy4, fNumberOfTofClusters));
595 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
596 FindClustersPerStrip(iSector, iPlate, iStrip, 3); // 3 pads clusters
597 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
599 dummy3 = fNumberOfTofClusters;
600 FindClustersPerStrip(iSector, iPlate, iStrip, 3); // 3 pads clusters
601 if (fNumberOfTofClusters!=dummy3)
602 AliDebug(2, Form(" (3): n1= %5d, n2 = %5d", dummy3, fNumberOfTofClusters));
605 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
606 FindClustersPerStrip(iSector, iPlate, iStrip, 2); // 2 pads clusters
607 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
609 dummy2 = fNumberOfTofClusters;
610 FindClustersPerStrip(iSector, iPlate, iStrip, 2); // 2 pads clusters
611 if (fNumberOfTofClusters!=dummy2)
612 AliDebug(2, Form(" (2): n1= %5d, n2 =%5d", dummy2, fNumberOfTofClusters));
615 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
616 dummy = fNumberOfTofClusters;
617 FindClusters34(iSector, iPlate, iStrip); // 3 pads clusters between 4 hit pads
618 if (fNumberOfTofClusters!=dummy)
619 AliDebug(2, Form(" (3 between 4): n1 = %5d, n2 = %5d", fNumberOfTofClusters, dummy));
622 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
623 dummy = fNumberOfTofClusters;
624 FindClusters23(iSector, iPlate, iStrip); // 2 pads clusters between 3 hit pads
625 if (fNumberOfTofClusters!=dummy)
626 AliDebug(2, Form(" (2 between 3): n1 = %5d, n2 = %5d", fNumberOfTofClusters, dummy));
628 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
629 dummy = fNumberOfTofClusters;
630 FindClusters24(iSector, iPlate, iStrip); // 2 pads clusters between 4 hit pads
631 if (fNumberOfTofClusters!=dummy)
632 AliDebug(2, Form(" (2 between 4): n1 = %5d, n2 = %5d", fNumberOfTofClusters, dummy));
635 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
636 dummy = fNumberOfTofClusters;
637 FindOnePadClusterPerStrip(iSector, iPlate, iStrip); // 1 pad clusters
638 if (fNumberOfTofClusters!=dummy)
639 AliDebug(2,Form(" (1): n1 = %5d, n2 = %5d", fNumberOfTofClusters, dummy));
641 if (fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip)>0)
642 AliDebug(2, Form(" (1): number of clusters = %5d (remaining digit %2d), -%2d %1d %2d-",
643 fNumberOfTofClusters, fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip),
644 iSector, iPlate, iStrip));
648 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
649 dummy = fNumberOfTofClusters;
650 FindOnePadClusterPerStrip(iSector, iPlate, iStrip); // 1 pad clusters
651 if (fNumberOfTofClusters!=dummy)
652 AliDebug(2,Form(" (1): n1 = %5d, n2 = %5d", fNumberOfTofClusters, dummy));
654 if (fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip)>0)
655 AliDebug(2, Form(" (1): number of clusters = %5d (remaining digit %2d), -%2d %1d %2d-",
656 fNumberOfTofClusters, fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip),
657 iSector, iPlate, iStrip));
667 TClonesArray &lRecPoints = *fRecPoints;
671 Int_t detectorIndex[5];
672 for (jj=0; jj<5; jj++) detectorIndex[jj] = -1;
674 for (jj=0; jj<7; jj++) parTOF[jj] = -1;
675 Int_t trackLabels[3];
676 for (jj=0; jj<3; jj++) trackLabels[jj] = -1;
677 Int_t digitIndex = -1;
678 Bool_t status = kTRUE;
680 for (ii=0; ii<3; ii++) posClus[ii] = 0.;
681 //Float_t covClus[6];
682 //for (ii=0; ii<6; ii++) covClus[ii] = 0.;
685 for (ii=0; ii<fNumberOfTofClusters; ii++) {
687 digitIndex = fTofClusters[ii]->GetIndex();
688 for(jj=0; jj<5; jj++) detectorIndex[jj] = fTofClusters[ii]->GetDetInd(jj);
689 volIdClus = fTOFGeometry->GetAliSensVolIndex(detectorIndex[0],detectorIndex[1],detectorIndex[2]);
690 //volIdClus = GetClusterVolIndex(detectorIndex);
691 for(jj=0; jj<3; jj++) trackLabels[jj] = fTofClusters[ii]->GetLabel(jj);
692 parTOF[0] = fTofClusters[ii]->GetTDC(); // TDC
693 parTOF[1] = fTofClusters[ii]->GetToT(); // TOT
694 parTOF[2] = fTofClusters[ii]->GetADC(); // ADC=TOT
695 parTOF[3] = fTofClusters[ii]->GetTDCND(); // TDCND
696 parTOF[4] = fTofClusters[ii]->GetTDCRAW();//RAW
699 status = fTofClusters[ii]->GetStatus();
701 posClus[0] = fTofClusters[ii]->GetX();
702 posClus[1] = fTofClusters[ii]->GetY();
703 posClus[2] = fTofClusters[ii]->GetZ();
705 //for (jj=0; jj<6; jj++) covClus[jj] = 0.;
706 //((AliCluster*)fTofClusters[ii])->GetGlobalCov(covClus);
708 new(lRecPoints[ii]) AliTOFcluster(volIdClus, (Double_t)posClus[0], (Double_t)posClus[1], (Double_t)posClus[2],
709 (Double_t)(fTofClusters[ii]->GetSigmaX2()),
710 (Double_t)(fTofClusters[ii]->GetSigmaXY()),
711 (Double_t)(fTofClusters[ii]->GetSigmaXZ()),
712 (Double_t)(fTofClusters[ii]->GetSigmaY2()),
713 (Double_t)(fTofClusters[ii]->GetSigmaYZ()),
714 (Double_t)(fTofClusters[ii]->GetSigmaZ2()),
715 //(Double_t)covClus[0], (Double_t)covClus[1], (Double_t)covClus[2],
716 //(Double_t)covClus[3], (Double_t)covClus[4], (Double_t)covClus[5],
717 trackLabels, detectorIndex, parTOF, status, digitIndex);
719 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",
720 ii, volIdClus, posClus[0], posClus[1], posClus[2],
721 fTofClusters[ii]->GetSigmaX2(),
722 fTofClusters[ii]->GetSigmaXY(),
723 fTofClusters[ii]->GetSigmaXZ(),
724 fTofClusters[ii]->GetSigmaY2(),
725 fTofClusters[ii]->GetSigmaYZ(),
726 fTofClusters[ii]->GetSigmaZ2(),
727 trackLabels[0], trackLabels[1], trackLabels[2],
728 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[3], detectorIndex[4],
729 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
730 status, digitIndex));
735 for (Int_t iSector=0; iSector<AliTOFGeometry::NSectors(); iSector++)
736 for(Int_t iPlate=0; iPlate<AliTOFGeometry::NPlates(); iPlate++) {
737 for(Int_t iStrip=0; iStrip<AliTOFGeometry::NStrip(iPlate); iStrip++) {
738 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
739 AliDebug(2, Form(" END %2d %1d %2d %5d",
740 iSector, iPlate, iStrip, fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip)));
745 //_____________________________________________________________________________
747 void AliTOFClusterFinderV1::FindOnePadClusterPerStrip(Int_t nSector,
752 // This function searches the isolated digits (stored in the fDigits object),
753 // to perform clusters (stored in the fTofClusters array).
754 // This research has been made by checking the fTOFdigitMap object,
755 // filled at digits/raw-data reading time.
758 const Int_t kMaxNumberOfTracksPerDigit = 3;
759 const Int_t kMaxNumberOfDigitsPerVolume = 10;
763 Int_t det[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padZ,padX
764 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padX,padZ
765 UShort_t volIdClus = 0;
768 for (jj=0; jj<3; jj++) pos[jj] = 0.;
770 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
773 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
776 for (jj=0; jj<7; jj++) parTOF[jj] = 0;
778 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
780 Int_t tracks[kMaxNumberOfTracksPerDigit];
781 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
783 Int_t dummyCounter=-1;
785 AliTOFdigit *digitInteresting;
789 for (iPadX=0; iPadX<AliTOFGeometry::NpadX(); iPadX++) {
790 for (iPadZ=0; iPadZ<AliTOFGeometry::NpadZ(); iPadZ++) {
791 vol[4] = iPadZ , vol[3] = iPadX;
793 AliDebug(3, Form(" %1d %2d\n", iPadZ, iPadX));
795 if (fTOFdigitMap->GetNumberOfDigits(vol)==0) continue;
797 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
798 if (fTOFdigitMap->GetDigitIndex(vol,digIndex)<0) continue;
799 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(fTOFdigitMap->GetDigitIndex(vol,digIndex));
801 AliDebug(2, Form(" %3d %5d %2d %1d %2d %1d %2d %d %d %d %5d %5d %5d %5d",
802 fTOFdigitMap->GetNumberOfDigits(vol), digIndex,
803 vol[0], vol[1], vol[2] ,vol[4], vol[3],
804 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
805 digitInteresting->GetToT(),
806 fTOFdigitMap->GetDigitIndex(vol,digIndex),
807 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
809 det[3] = vol[4]; // padz
810 det[4] = vol[3]; // padx
811 fTOFGeometry->GetPosPar(det,pos);
812 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
815 for (jj=0; jj<3; jj++) posClus[jj] = pos[jj];
817 parTOF[0] = Int_t(digitInteresting->GetTdc());
818 parTOF[1] = Int_t(digitInteresting->GetToT());
819 parTOF[2] = Int_t(digitInteresting->GetAdc());
820 parTOF[3] = Int_t(digitInteresting->GetTdcND());
821 parTOF[4] = Int_t(digitInteresting->GetTdc());
825 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
826 //volIdClus = GetClusterVolIndex(det);
828 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
829 GetClusterPars(det, posClus, covClus);
831 // To fill the track index array
833 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
834 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) { // three is the max number of tracks associated to one digit
835 if (digitInteresting->GetTrack(jj)==-1) continue;
838 tracks[dummyCounter] = digitInteresting->GetTrack(jj);
842 AliTOFcluster *tofCluster =
843 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
844 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
845 tracks, det, parTOF, status, fTOFdigitMap->GetDigitIndex(vol,digIndex));
846 InsertCluster(tofCluster);
848 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",
849 volIdClus, posClus[0], posClus[1], posClus[2],
850 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
851 tracks[0], tracks[1], tracks[2],
852 det[0], det[1], det[2], det[3], det[4],
853 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
854 status, fTOFdigitMap->GetDigitIndex(vol,digIndex)));
856 AliDebug(2, Form(" %f %f %f", pos[0], pos[1], pos[2]));
857 AliDebug(2, Form(" %d %d", parTOF[0], parTOF[2]));
859 fTOFdigitMap->ResetDigit(vol, digIndex);
867 //_____________________________________________________________________________
869 void AliTOFClusterFinderV1::FindClustersWithoutTOT(Int_t nSector,
874 // This function searches the isolated digits without TOT
875 // measurement (stored in the fDigits object), to perform clusters
876 // (stored in the fTofClusters array). This research has been made
877 // by checking the fTOFdigitMap object, filled at digits/raw-data
881 const Int_t kMaxNumberOfTracksPerDigit = 3;
882 const Int_t kMaxNumberOfDigitsPerVolume = 10;
886 Int_t det[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padZ,padX
887 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padX,padZ
888 UShort_t volIdClus = 0;
891 for (jj=0; jj<3; jj++) pos[jj] = 0.;
893 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
896 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
899 for (jj=0; jj<7; jj++) parTOF[jj] = 0;
901 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
902 Int_t tracks[kMaxNumberOfTracksPerDigit];
903 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
905 Int_t dummyCounter=-1;
907 AliTOFdigit *digitInteresting;
911 for (iPadX=0; iPadX<AliTOFGeometry::NpadX(); iPadX++) {
912 for (iPadZ=0; iPadZ<AliTOFGeometry::NpadZ(); iPadZ++) {
913 vol[4] = iPadZ , vol[3] = iPadX;
915 AliDebug(3, Form(" %1d %2d\n", iPadZ, iPadX));
917 if (fTOFdigitMap->GetNumberOfDigits(vol)==0) continue;
919 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
920 if (fTOFdigitMap->GetDigitIndex(vol,digIndex)<0) continue;
921 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(fTOFdigitMap->GetDigitIndex(vol,digIndex));
922 if (digitInteresting->GetToT()>0) continue; // AdC
924 AliDebug(2, Form(" %3d %5d %2d %1d %2d %1d %2d %d %d %d %5d %5d %5d %5d",
925 fTOFdigitMap->GetNumberOfDigits(vol), digIndex,
926 vol[0], vol[1], vol[2] ,vol[4], vol[3],
927 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
928 digitInteresting->GetToT(),
929 fTOFdigitMap->GetDigitIndex(vol,digIndex),
930 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
932 det[3] = vol[4]; // padz
933 det[4] = vol[3]; // padx
934 fTOFGeometry->GetPosPar(det,pos);
935 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
938 for (jj=0; jj<3; jj++) posClus[jj] = pos[jj];
940 parTOF[0] = Int_t(digitInteresting->GetTdc());
941 parTOF[1] = Int_t(digitInteresting->GetToT());
942 parTOF[2] = Int_t(digitInteresting->GetAdc());
943 parTOF[3] = Int_t(digitInteresting->GetTdcND());
944 parTOF[4] = Int_t(digitInteresting->GetTdc());
948 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
949 //volIdClus = GetClusterVolIndex(det);
951 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
952 GetClusterPars(det, posClus, covClus);
954 // To fill the track index array
956 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
957 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) { // three is the max number of tracks associated to one digit
958 if (digitInteresting->GetTrack(jj)==-1) continue;
961 tracks[dummyCounter] = digitInteresting->GetTrack(jj);
965 AliTOFcluster *tofCluster =
966 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
967 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
968 tracks, det, parTOF, status, fTOFdigitMap->GetDigitIndex(vol,digIndex));
969 InsertCluster(tofCluster);
971 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",
972 volIdClus, posClus[0], posClus[1], posClus[2],
973 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
974 tracks[0], tracks[1], tracks[2],
975 det[0], det[1], det[2], det[3], det[4],
976 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
977 status, fTOFdigitMap->GetDigitIndex(vol,digIndex)));
979 AliDebug(2, Form(" %f %f %f", pos[0], pos[1], pos[2]));
980 AliDebug(2, Form(" %d %d", parTOF[0], parTOF[2]));
982 fTOFdigitMap->ResetDigit(vol, digIndex);
990 //_____________________________________________________________________________
992 void AliTOFClusterFinderV1::FindClusters34(Int_t nSector,
997 // This function searches the neighbouring digits (stored in the fDigits object),
998 // to perform clusters (stored in the fTofClusters array).
1000 // This research has been made by checking the fTOFdigitMap object,
1001 // filled at digits/raw-data reading time.
1004 const Int_t kMaxNumberOfInterestingPads = 4;
1005 const Int_t kMaxNumberOfTracksPerDigit = 3;
1006 const Int_t kMaxNumberOfDigitsPerVolume = 10;
1010 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
1011 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1012 digitsInVolumeIndices[ii] = -1;
1014 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
1016 Float_t pos[3] = {0.,0.,0.};
1019 Int_t interestingPadX[kMaxNumberOfInterestingPads];
1020 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
1021 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
1022 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
1023 Double_t interestingTOT[kMaxNumberOfInterestingPads];
1024 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
1025 Double_t interestingADC[kMaxNumberOfInterestingPads];
1026 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
1027 Double_t interestingTOF[kMaxNumberOfInterestingPads];
1028 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
1029 Double_t interestingWeight[kMaxNumberOfInterestingPads];
1030 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
1032 Float_t interestingX[kMaxNumberOfInterestingPads];
1033 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
1034 Float_t interestingY[kMaxNumberOfInterestingPads];
1035 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
1036 Float_t interestingZ[kMaxNumberOfInterestingPads];
1037 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
1039 Float_t interDigit[kMaxNumberOfInterestingPads];
1040 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
1042 Int_t padsCluster[11];
1043 padsCluster[0] = nSector;
1044 padsCluster[1] = nPlate;
1045 padsCluster[2] = nStrip;
1046 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1048 Int_t interestingCounter=-1;
1049 Int_t digitIndexLocal=-1; // AdC
1055 for (jj=0; jj<7; jj++) parTOF[jj] = 0;
1056 Double_t posClus[3];
1057 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
1059 for (jj=0; jj<5; jj++) det[jj] = -1;
1061 for (jj=0; jj<3; jj++) posF[jj] = 0.;
1062 UShort_t volIdClus = 0;
1063 Bool_t check = kFALSE;
1064 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
1065 Double_t covClus[6];
1066 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1067 Int_t tracks[kMaxNumberOfTracksPerDigit];
1068 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1069 Int_t dummyCounter=-1;
1070 Bool_t alreadyStored = kFALSE;
1072 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
1073 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1074 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
1076 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1077 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
1079 AliTOFdigit *digitInteresting;
1081 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
1083 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
1084 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
1086 AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
1093 interestingCounter=-1;
1095 vol[4] = iPadZ , vol[3] = iPadX;
1096 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1097 interestingCounter++;
1099 vol[4] = iPadZ, vol[3] = iPadX+1;
1100 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1101 interestingCounter++;
1103 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1104 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1105 interestingCounter++;
1107 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1108 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1109 interestingCounter++;
1111 if (interestingCounter+1!=4) continue; // the hit pads have to be 4
1112 else interestingCounter=-1;
1115 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1116 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1117 selectedDigit[ii][jj] = 0x0;
1120 vol[4] = iPadZ, vol[3] = iPadX;
1122 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1123 interestingCounter++;
1124 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1125 digitsInVolumeIndices[ii] = -1;
1126 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1127 digitIndexLocal=-1; // AdC
1128 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1129 if (digitsInVolumeIndices[digIndex]<0) continue;
1130 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1131 if (digitInteresting->GetToT()<=0) continue; // AdC
1132 digitIndexLocal++; // AdC
1134 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1135 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1136 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1137 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1138 digitsInVolumeIndices[digIndex],
1139 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1142 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1143 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1144 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1145 digitInteresting->GetToT()*digitInteresting->GetToT(),
1146 digitsInVolumeIndices[digIndex],
1147 digitInteresting->GetTracks());
1149 if (digitIndexLocal==-1) interestingCounter--; // AdC
1153 vol[4] = iPadZ, vol[3] = iPadX+1;
1155 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1156 interestingCounter++;
1157 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1158 digitsInVolumeIndices[ii] = -1;
1159 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1160 digitIndexLocal=-1; // AdC
1161 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1162 if (digitsInVolumeIndices[digIndex]<0) continue;
1163 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1164 if (digitInteresting->GetToT()<=0) continue; // AdC
1165 digitIndexLocal++; // AdC
1167 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1168 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1169 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1170 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1171 digitsInVolumeIndices[digIndex],
1172 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1175 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1176 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1177 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1178 digitInteresting->GetToT()*digitInteresting->GetToT(),
1179 digitsInVolumeIndices[digIndex],
1180 digitInteresting->GetTracks());
1182 if (digitIndexLocal==-1) interestingCounter--; // AdC
1186 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1188 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1189 interestingCounter++;
1190 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1191 digitsInVolumeIndices[ii] = -1;
1192 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1193 digitIndexLocal=-1; // AdC
1194 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1195 if (digitsInVolumeIndices[digIndex]<0) continue;
1196 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1197 if (digitInteresting->GetToT()<=0) continue; // AdC
1198 digitIndexLocal++; // AdC
1200 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1201 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1202 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1203 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1204 digitsInVolumeIndices[digIndex],
1205 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1208 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1209 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1210 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1211 digitInteresting->GetToT()*digitInteresting->GetToT(),
1212 digitsInVolumeIndices[digIndex],
1213 digitInteresting->GetTracks());
1215 if (digitIndexLocal==-1) interestingCounter--; // AdC
1219 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1221 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1222 interestingCounter++;
1223 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1224 digitsInVolumeIndices[ii] = -1;
1225 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1227 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1228 if (digitsInVolumeIndices[digIndex]<0) continue;
1229 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1230 if (digitInteresting->GetToT()<=0) continue; // AdC
1231 digitIndexLocal++; // AdC
1233 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1234 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1235 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1236 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1237 digitsInVolumeIndices[digIndex],
1238 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1240 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1241 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1242 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1243 digitInteresting->GetToT()*digitInteresting->GetToT(),
1244 digitsInVolumeIndices[digIndex],
1245 digitInteresting->GetTracks());
1247 if (digitIndexLocal==-1) interestingCounter--; // AdC
1250 AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
1252 for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
1253 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
1254 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
1256 for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
1257 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
1258 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
1260 for (Int_t adesso3=adesso2+1; adesso3<interestingCounter+1; adesso3++) {
1261 for (Int_t thirdIndex=0; thirdIndex<kMaxNumberOfDigitsPerVolume; thirdIndex++) {
1262 if (selectedDigit[adesso3][thirdIndex]==0x0) continue;
1265 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime
1267 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
1269 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime) continue;
1271 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
1272 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
1273 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
1274 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
1275 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
1276 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
1277 Int_t volDum = vol1[3];
1280 fTOFGeometry->GetPosPar(vol1,pos);
1281 interestingX[0] = pos[0];
1282 interestingY[0] = pos[1];
1283 interestingZ[0] = pos[2];
1285 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
1286 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
1287 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
1288 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
1289 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
1290 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
1294 fTOFGeometry->GetPosPar(vol2,pos);
1295 interestingX[1] = pos[0];
1296 interestingY[1] = pos[1];
1297 interestingZ[1] = pos[2];
1299 interestingTOF[2] = selectedDigit[adesso3][thirdIndex]->GetTDC();
1300 interestingTOT[2] = selectedDigit[adesso3][thirdIndex]->GetTOT();
1301 interestingADC[2] = selectedDigit[adesso3][thirdIndex]->GetADC();
1302 interestingWeight[2] = selectedDigit[adesso3][thirdIndex]->GetWeight();
1303 Int_t vol3[5]; for(jj=0; jj<5; jj++) vol3[jj] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(jj);
1304 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol3[0], vol3[1], vol3[2], vol3[4], vol3[3]));
1308 fTOFGeometry->GetPosPar(vol3,pos);
1309 interestingX[2] = pos[0];
1310 interestingY[2] = pos[1];
1311 interestingZ[2] = pos[2];
1314 AverageCalculations(3, interestingX, interestingY, interestingZ,
1315 interestingTOF, interestingTOT, interestingADC,
1317 parTOF, posClus, check);
1320 for (jj=0; jj<5; jj++) det[jj] = -1;
1321 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
1322 fTOFGeometry->GetDetID(posF, det);
1324 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
1325 //volIdClus = GetClusterVolIndex(det);
1327 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1328 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
1329 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
1330 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
1331 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
1332 padsCluster[7] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(4);
1333 padsCluster[8] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(3);
1335 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1336 Int_t ** indDet = new Int_t*[3];
1337 for (jj=0; jj<3; jj++) indDet[jj] = new Int_t [5];
1338 for (jj=0; jj<3; jj++) indDet[jj][0] = nSector;
1339 for (jj=0; jj<3; jj++) indDet[jj][1] = nPlate;
1340 for (jj=0; jj<3; jj++) indDet[jj][2] = nStrip;
1341 for (jj=0; jj<3; jj++) indDet[jj][3] = padsCluster[2*jj+3];
1342 for (jj=0; jj<3; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
1343 GetClusterPars(/*check,*/ 3, indDet, interestingWeight, posClus, covClus);
1344 for (jj=0; jj<3; jj++) delete [] indDet[jj];
1347 // To fill the track index array
1349 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1350 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1351 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
1354 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
1357 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1358 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
1361 alreadyStored = kFALSE;
1362 for (jj=0; jj<dummyCounter+1; jj++)
1363 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
1365 if (alreadyStored) continue;
1366 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
1367 AliWarning(" Siamo al limite!");
1372 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
1377 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1378 if (selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk)==-1) continue;
1381 alreadyStored = kFALSE;
1382 for (jj=0; jj<dummyCounter+1; jj++)
1383 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk));
1385 if (alreadyStored) continue;
1386 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
1387 AliWarning(" Siamo al limite!");
1392 tracks[dummyCounter] = selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk);
1399 AliTOFcluster *tofCluster =
1400 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
1401 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1402 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
1403 InsertCluster(tofCluster);
1405 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",
1406 volIdClus, posClus[0], posClus[1], posClus[2],
1407 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1408 tracks[0], tracks[1], tracks[2],
1409 det[0], det[1], det[2], det[3], det[4],
1410 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
1411 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
1417 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
1421 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
1425 fTOFdigitMap->ResetDigitNumber(vol3,selectedDigit[adesso3][thirdIndex]->GetIndex());
1428 } // close loop on third digit
1429 } // close loop on adesso3
1431 } // close loop on second digit
1432 } // close loop on adesso2
1434 } // close loop on first digit
1435 } // close loop on adesso1
1437 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1438 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1439 selectedDigit[ii][jj] = 0x0;
1443 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++) {
1444 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
1445 delete [] selectedDigit[ii][jj];
1446 selectedDigit[ii][jj] = 0x0;
1448 delete [] selectedDigit[ii];
1449 selectedDigit[ii] = 0x0;
1451 delete [] selectedDigit;
1452 selectedDigit = 0x0;
1455 //_____________________________________________________________________________
1457 void AliTOFClusterFinderV1::FindClusters23(Int_t nSector,
1462 // This function searches the neighbouring digits (stored in the fDigits object),
1463 // to perform clusters (stored in the fTofClusters array).
1465 // This research has been made by checking the fTOFdigitMap object,
1466 // filled at digits/raw-data reading time.
1469 const Int_t kMaxNumberOfInterestingPads = 4;
1470 const Int_t kMaxNumberOfTracksPerDigit = 3;
1471 const Int_t kMaxNumberOfDigitsPerVolume = 10;
1475 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
1476 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1477 digitsInVolumeIndices[ii] = -1;
1479 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
1481 Float_t pos[3] = {0.,0.,0.};
1484 Int_t interestingPadX[kMaxNumberOfInterestingPads];
1485 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
1486 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
1487 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
1488 Double_t interestingTOT[kMaxNumberOfInterestingPads];
1489 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
1490 Double_t interestingADC[kMaxNumberOfInterestingPads];
1491 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
1492 Double_t interestingTOF[kMaxNumberOfInterestingPads];
1493 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
1494 Double_t interestingWeight[kMaxNumberOfInterestingPads];
1495 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
1497 Float_t interestingX[kMaxNumberOfInterestingPads];
1498 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
1499 Float_t interestingY[kMaxNumberOfInterestingPads];
1500 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
1501 Float_t interestingZ[kMaxNumberOfInterestingPads];
1502 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
1504 Float_t interDigit[kMaxNumberOfInterestingPads];
1505 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
1507 Int_t padsCluster[11];
1508 padsCluster[0] = nSector;
1509 padsCluster[1] = nPlate;
1510 padsCluster[2] = nStrip;
1511 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1513 Int_t interestingCounter=-1;
1514 Int_t digitIndexLocal = -1;
1519 Bool_t check = kFALSE;
1521 for (jj=0; jj<7; jj++) parTOF[jj] = 0;
1522 Double_t posClus[3];
1523 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
1525 for (jj=0; jj<5; jj++) det[jj] = -1;
1527 for (jj=0; jj<3; jj++) posF[jj] = 0.;
1528 UShort_t volIdClus = 0;
1529 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
1530 Double_t covClus[6];
1531 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1532 Int_t tracks[kMaxNumberOfTracksPerDigit];
1533 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1534 Int_t dummyCounter=-1;
1535 Bool_t alreadyStored = kFALSE;
1537 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
1538 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1539 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
1541 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1542 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
1544 AliTOFdigit *digitInteresting;
1546 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
1548 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
1549 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
1551 AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
1558 interestingCounter=-1;
1560 vol[4] = iPadZ , vol[3] = iPadX;
1561 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1562 interestingCounter++;
1564 vol[4] = iPadZ, vol[3] = iPadX+1;
1565 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1566 interestingCounter++;
1568 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1569 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1570 interestingCounter++;
1572 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1573 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1574 interestingCounter++;
1576 if (interestingCounter+1!=3) continue; // the hit pads have to be 3
1577 else interestingCounter=-1;
1580 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1581 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1582 selectedDigit[ii][jj] = 0x0;
1585 vol[4] = iPadZ, vol[3] = iPadX;
1587 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1588 interestingCounter++;
1589 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1590 digitsInVolumeIndices[ii] = -1;
1591 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1593 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1594 if (digitsInVolumeIndices[digIndex]<0) continue;
1595 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1596 if (digitInteresting->GetToT()<=0) continue; // AdC
1597 digitIndexLocal++; // AdC
1599 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1600 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1601 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1602 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1603 digitsInVolumeIndices[digIndex],
1604 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1606 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1607 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1608 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1609 digitInteresting->GetToT()*digitInteresting->GetToT(),
1610 digitsInVolumeIndices[digIndex],
1611 digitInteresting->GetTracks());
1613 if (digitIndexLocal==-1) interestingCounter--; // AdC
1617 vol[4] = iPadZ, vol[3] = iPadX+1;
1619 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1620 interestingCounter++;
1621 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1622 digitsInVolumeIndices[ii] = -1;
1623 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1624 digitIndexLocal=-1; // AdC
1625 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1626 if (digitsInVolumeIndices[digIndex]<0) continue;
1627 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1628 if (digitInteresting->GetToT()<=0) continue; // AdC
1629 digitIndexLocal++; // AdC
1631 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1632 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1633 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1634 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1635 digitsInVolumeIndices[digIndex],
1636 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1638 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1639 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1640 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1641 digitInteresting->GetToT()*digitInteresting->GetToT(),
1642 digitsInVolumeIndices[digIndex],
1643 digitInteresting->GetTracks());
1645 if (digitIndexLocal==-1) interestingCounter--; // AdC
1649 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1651 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1652 interestingCounter++;
1653 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1654 digitsInVolumeIndices[ii] = -1;
1655 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1656 digitIndexLocal=-1; // AdC
1657 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1658 if (digitsInVolumeIndices[digIndex]<0) continue;
1659 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1660 if (digitInteresting->GetToT()<=0) continue; // AdC
1661 digitIndexLocal++; // AdC
1663 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1664 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1665 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1666 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1667 digitsInVolumeIndices[digIndex],
1668 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1670 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1671 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1672 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1673 digitInteresting->GetToT()*digitInteresting->GetToT(),
1674 digitsInVolumeIndices[digIndex],
1675 digitInteresting->GetTracks());
1677 if (digitIndexLocal==-1) interestingCounter--; // AdC
1681 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1683 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1684 interestingCounter++;
1685 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1686 digitsInVolumeIndices[ii] = -1;
1687 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1688 digitIndexLocal=-1; // AdC
1689 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1690 if (digitsInVolumeIndices[digIndex]<0) continue;
1691 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1692 if (digitInteresting->GetToT()<=0) continue; // AdC
1693 digitIndexLocal++; // AdC
1695 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1696 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1697 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1698 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1699 digitsInVolumeIndices[digIndex],
1700 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1702 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1703 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1704 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1705 digitInteresting->GetToT()*digitInteresting->GetToT(),
1706 digitsInVolumeIndices[digIndex],
1707 digitInteresting->GetTracks());
1709 if (digitIndexLocal==-1) interestingCounter--; // AdC
1712 AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
1714 for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
1715 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
1716 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
1718 for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
1719 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
1720 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
1722 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime) continue;
1724 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
1725 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
1726 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
1727 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
1728 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
1729 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
1730 Int_t volDum = vol1[3];
1733 fTOFGeometry->GetPosPar(vol1,pos);
1734 interestingX[0] = pos[0];
1735 interestingY[0] = pos[1];
1736 interestingZ[0] = pos[2];
1738 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
1739 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
1740 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
1741 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
1742 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
1743 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
1747 fTOFGeometry->GetPosPar(vol2,pos);
1748 interestingX[1] = pos[0];
1749 interestingY[1] = pos[1];
1750 interestingZ[1] = pos[2];
1752 AverageCalculations(2, interestingX, interestingY, interestingZ,
1753 interestingTOF, interestingTOT, interestingADC,
1755 parTOF, posClus, check);
1757 for (jj=0; jj<5; jj++) det[jj] = -1;
1758 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
1759 fTOFGeometry->GetDetID(posF, det);
1761 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
1762 //volIdClus = GetClusterVolIndex(det);
1764 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1765 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
1766 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
1767 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
1768 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
1770 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1771 Int_t ** indDet = new Int_t*[2];
1772 for (jj=0; jj<2; jj++) indDet[jj] = new Int_t [5];
1773 for (jj=0; jj<2; jj++) indDet[jj][0] = nSector;
1774 for (jj=0; jj<2; jj++) indDet[jj][1] = nPlate;
1775 for (jj=0; jj<2; jj++) indDet[jj][2] = nStrip;
1776 for (jj=0; jj<2; jj++) indDet[jj][3] = padsCluster[2*jj+3];
1777 for (jj=0; jj<2; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
1778 GetClusterPars(/*check,*/ 2, indDet, interestingWeight, posClus, covClus);
1779 for (jj=0; jj<2; jj++) delete [] indDet[jj];
1782 // To fill the track index array
1784 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1785 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1786 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
1789 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
1792 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1793 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
1796 alreadyStored = kFALSE;
1797 for (jj=0; jj<dummyCounter+1; jj++)
1798 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
1800 if (alreadyStored) continue;
1801 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
1802 AliWarning(" Siamo al limite!");
1807 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
1814 AliTOFcluster *tofCluster =
1815 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
1816 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1817 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
1818 InsertCluster(tofCluster);
1820 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",
1821 volIdClus, posClus[0], posClus[1], posClus[2],
1822 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1823 tracks[0], tracks[1], tracks[2],
1824 det[0], det[1], det[2], det[3], det[4],
1825 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
1826 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
1831 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
1835 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
1838 } // close loop on second digit
1839 } // close loop on adesso2
1841 } // close loop on first digit
1842 } // close loop on adesso1
1844 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1845 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1846 selectedDigit[ii][jj] = 0x0;
1850 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++) {
1851 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
1852 delete [] selectedDigit[ii][jj];
1853 selectedDigit[ii][jj] = 0x0;
1855 delete [] selectedDigit[ii];
1856 selectedDigit[ii] = 0x0;
1858 delete [] selectedDigit;
1859 selectedDigit = 0x0;
1862 //_____________________________________________________________________________
1864 void AliTOFClusterFinderV1::FindClusters24(Int_t nSector,
1869 // This function searches the neighbouring digits (stored in the fDigits object),
1870 // to perform clusters (stored in the fTofClusters array).
1872 // This research has been made by checking the fTOFdigitMap object,
1873 // filled at digits/raw-data reading time.
1876 const Int_t kMaxNumberOfInterestingPads = 4;
1877 const Int_t kMaxNumberOfTracksPerDigit = 3;
1878 const Int_t kMaxNumberOfDigitsPerVolume = 10;
1882 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
1883 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1884 digitsInVolumeIndices[ii] = -1;
1886 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
1888 Float_t pos[3] = {0.,0.,0.};
1891 Int_t interestingPadX[kMaxNumberOfInterestingPads];
1892 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
1893 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
1894 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
1895 Double_t interestingTOT[kMaxNumberOfInterestingPads];
1896 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
1897 Double_t interestingADC[kMaxNumberOfInterestingPads];
1898 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
1899 Double_t interestingTOF[kMaxNumberOfInterestingPads];
1900 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
1901 Double_t interestingWeight[kMaxNumberOfInterestingPads];
1902 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
1904 Float_t interestingX[kMaxNumberOfInterestingPads];
1905 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
1906 Float_t interestingY[kMaxNumberOfInterestingPads];
1907 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
1908 Float_t interestingZ[kMaxNumberOfInterestingPads];
1909 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
1911 Float_t interDigit[kMaxNumberOfInterestingPads];
1912 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
1914 Int_t padsCluster[11];
1915 padsCluster[0] = nSector;
1916 padsCluster[1] = nPlate;
1917 padsCluster[2] = nStrip;
1918 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1920 Int_t interestingCounter=-1;
1921 Int_t digitIndexLocal = -1;
1926 Bool_t check = kFALSE;
1928 for (jj=0; jj<7; jj++) parTOF[jj] = 0;
1929 Double_t posClus[3];
1930 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
1932 for (jj=0; jj<5; jj++) det[jj] = -1;
1934 for (jj=0; jj<3; jj++) posF[jj] = 0.;
1935 UShort_t volIdClus = 0;
1936 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
1937 Double_t covClus[6];
1938 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1939 Int_t tracks[kMaxNumberOfTracksPerDigit];
1940 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1941 Int_t dummyCounter=-1;
1942 Bool_t alreadyStored = kFALSE;
1944 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
1945 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1946 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
1948 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1949 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
1951 AliTOFdigit *digitInteresting;
1953 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
1955 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
1956 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
1958 AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
1965 interestingCounter=-1;
1967 vol[4] = iPadZ , vol[3] = iPadX;
1968 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1969 interestingCounter++;
1971 vol[4] = iPadZ, vol[3] = iPadX+1;
1972 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1973 interestingCounter++;
1975 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1976 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1977 interestingCounter++;
1979 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1980 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1981 interestingCounter++;
1983 if (interestingCounter+1!=4) continue; // the hit pads have to be 4
1984 else interestingCounter=-1;
1987 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1988 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1989 selectedDigit[ii][jj] = 0x0;
1992 vol[4] = iPadZ, vol[3] = iPadX;
1994 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1995 interestingCounter++;
1996 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1997 digitsInVolumeIndices[ii] = -1;
1998 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1999 digitIndexLocal=-1; // AdC
2000 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2001 if (digitsInVolumeIndices[digIndex]<0) continue;
2002 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2003 if (digitInteresting->GetToT()<=0) continue; // AdC
2004 digitIndexLocal++; // AdC
2006 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2007 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2008 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2009 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2010 digitsInVolumeIndices[digIndex],
2011 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2013 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2014 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2015 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2016 digitInteresting->GetToT()*digitInteresting->GetToT(),
2017 digitsInVolumeIndices[digIndex],
2018 digitInteresting->GetTracks());
2020 if (digitIndexLocal==-1) interestingCounter--; // AdC
2024 vol[4] = iPadZ, vol[3] = iPadX+1;
2026 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2027 interestingCounter++;
2028 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2029 digitsInVolumeIndices[ii] = -1;
2030 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2031 digitIndexLocal=-1; // AdC
2032 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2033 if (digitsInVolumeIndices[digIndex]<0) continue;
2034 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2035 if (digitInteresting->GetToT()<=0) continue; // AdC
2036 digitIndexLocal++; // AdC
2038 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2039 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2040 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2041 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2042 digitsInVolumeIndices[digIndex],
2043 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2045 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2046 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2047 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2048 digitInteresting->GetToT()*digitInteresting->GetToT(),
2049 digitsInVolumeIndices[digIndex],
2050 digitInteresting->GetTracks());
2052 if (digitIndexLocal==-1) interestingCounter--; // AdC
2056 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
2058 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2059 interestingCounter++;
2060 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2061 digitsInVolumeIndices[ii] = -1;
2062 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2063 digitIndexLocal=-1; // AdC
2064 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2065 if (digitsInVolumeIndices[digIndex]<0) continue;
2066 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2067 if (digitInteresting->GetToT()<=0) continue; // AdC
2068 digitIndexLocal++; // AdC
2070 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2071 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2072 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2073 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2074 digitsInVolumeIndices[digIndex],
2075 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2077 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2078 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2079 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2080 digitInteresting->GetToT()*digitInteresting->GetToT(),
2081 digitsInVolumeIndices[digIndex],
2082 digitInteresting->GetTracks());
2084 if (digitIndexLocal==-1) interestingCounter--; // AdC
2088 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
2090 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2091 interestingCounter++;
2092 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2093 digitsInVolumeIndices[ii] = -1;
2094 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2095 digitIndexLocal=-1; // AdC
2096 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2097 if (digitsInVolumeIndices[digIndex]<0) continue;
2098 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2099 if (digitInteresting->GetToT()<=0) continue; // AdC
2100 digitIndexLocal++; // AdC
2102 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2103 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2104 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2105 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2106 digitsInVolumeIndices[digIndex],
2107 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2109 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2110 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2111 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2112 digitInteresting->GetToT()*digitInteresting->GetToT(),
2113 digitsInVolumeIndices[digIndex],
2114 digitInteresting->GetTracks());
2116 if (digitIndexLocal==-1) interestingCounter--; // AdC
2119 AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
2121 for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
2122 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2123 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2125 for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
2126 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2127 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2129 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime) continue;
2131 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2132 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2133 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2134 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2135 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
2136 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
2137 Int_t volDum = vol1[3];
2140 fTOFGeometry->GetPosPar(vol1,pos);
2141 interestingX[0] = pos[0];
2142 interestingY[0] = pos[1];
2143 interestingZ[0] = pos[2];
2145 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2146 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2147 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2148 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2149 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
2150 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
2154 fTOFGeometry->GetPosPar(vol2,pos);
2155 interestingX[1] = pos[0];
2156 interestingY[1] = pos[1];
2157 interestingZ[1] = pos[2];
2160 AverageCalculations(2, interestingX, interestingY, interestingZ,
2161 interestingTOF, interestingTOT, interestingADC,
2163 parTOF, posClus, check);
2165 for (jj=0; jj<5; jj++) det[jj] = -1;
2166 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
2167 fTOFGeometry->GetDetID(posF, det);
2169 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
2170 //volIdClus = GetClusterVolIndex(det);
2172 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2173 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
2174 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
2175 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
2176 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
2178 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2179 Int_t ** indDet = new Int_t*[2];
2180 for (jj=0; jj<2; jj++) indDet[jj] = new Int_t [5];
2181 for (jj=0; jj<2; jj++) indDet[jj][0] = nSector;
2182 for (jj=0; jj<2; jj++) indDet[jj][1] = nPlate;
2183 for (jj=0; jj<2; jj++) indDet[jj][2] = nStrip;
2184 for (jj=0; jj<2; jj++) indDet[jj][3] = padsCluster[2*jj+3];
2185 for (jj=0; jj<2; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
2186 GetClusterPars(/*check,*/ 2, indDet, interestingWeight, posClus, covClus);
2187 for (jj=0; jj<2; jj++) delete [] indDet[jj];
2190 // To fill the track index array
2192 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2193 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2194 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
2197 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
2200 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2201 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
2204 alreadyStored = kFALSE;
2205 for (jj=0; jj<dummyCounter+1; jj++)
2206 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
2208 if (alreadyStored) continue;
2209 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2210 AliWarning(" Siamo al limite!");
2215 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
2222 AliTOFcluster *tofCluster =
2223 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
2224 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2225 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
2226 InsertCluster(tofCluster);
2228 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",
2229 volIdClus, posClus[0], posClus[1], posClus[2],
2230 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2231 tracks[0], tracks[1], tracks[2],
2232 det[0], det[1], det[2], det[3], det[4],
2233 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
2234 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
2239 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
2243 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
2246 } // close loop on second digit
2247 } // close loop on adesso2
2249 } // close loop on first digit
2250 } // close loop on adesso1
2252 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2253 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
2254 selectedDigit[ii][jj] = 0x0;
2258 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++) {
2259 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
2260 delete [] selectedDigit[ii][jj];
2261 selectedDigit[ii][jj] = 0x0;
2263 delete [] selectedDigit[ii];
2264 selectedDigit[ii] = 0x0;
2266 delete [] selectedDigit;
2267 selectedDigit = 0x0;
2270 //_____________________________________________________________________________
2272 void AliTOFClusterFinderV1::FindClustersPerStrip(Int_t nSector,
2278 // This function searches the neighbouring digits (stored in the fDigits object),
2279 // to perform clusters (stored in the fTofClusters array).
2281 // Each strip is read four times:
2282 // - 1st time: it searches possible clusters formed by four
2283 // neighbouring digits;
2284 // - 2nd time: it searches possible clusters formed by three
2285 // neighbouring digits;
2286 // - 3rd time: it searches possible clusters formed by two
2287 // neighbouring digits;
2288 // - 4th time: the remaining isolated digits have been transformed
2290 // This research has been made by checking the fTOFdigitMap object,
2291 // filled at digits/raw-data reading time.
2294 const Int_t kMaxNumberOfInterestingPads = 4;
2295 const Int_t kMaxNumberOfTracksPerDigit = 3;
2296 const Int_t kMaxNumberOfDigitsPerVolume = 10;
2300 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
2301 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2302 digitsInVolumeIndices[ii] = -1;
2304 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
2306 Float_t pos[3] = {0.,0.,0.};
2309 Int_t interestingPadX[kMaxNumberOfInterestingPads];
2310 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
2311 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
2312 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
2313 Double_t interestingTOT[kMaxNumberOfInterestingPads];
2314 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
2315 Double_t interestingADC[kMaxNumberOfInterestingPads];
2316 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
2317 Double_t interestingTOF[kMaxNumberOfInterestingPads];
2318 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
2319 Double_t interestingWeight[kMaxNumberOfInterestingPads];
2320 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
2322 Float_t interestingX[kMaxNumberOfInterestingPads];
2323 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
2324 Float_t interestingY[kMaxNumberOfInterestingPads];
2325 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
2326 Float_t interestingZ[kMaxNumberOfInterestingPads];
2327 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
2329 Float_t interDigit[kMaxNumberOfInterestingPads];
2330 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
2332 Int_t padsCluster[11];
2333 padsCluster[0] = nSector;
2334 padsCluster[1] = nPlate;
2335 padsCluster[2] = nStrip;
2336 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2338 Int_t interestingCounter=-1;
2339 Int_t digitIndexLocal = -1;
2344 Bool_t check = kFALSE;
2346 for (jj=0; jj<7; jj++) parTOF[jj] = 0;
2347 Double_t posClus[3];
2348 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
2350 for (jj=0; jj<5; jj++) det[jj] = -1;
2352 for (jj=0; jj<3; jj++) posF[jj] = 0.;
2353 UShort_t volIdClus = 0;
2354 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
2355 Double_t covClus[6];
2356 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2357 Int_t tracks[kMaxNumberOfTracksPerDigit];
2358 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2359 Int_t dummyCounter=-1;
2360 Bool_t alreadyStored = kFALSE;
2362 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
2363 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2364 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
2366 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2367 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
2369 AliTOFdigit *digitInteresting;
2373 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
2375 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
2376 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
2378 AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
2385 interestingCounter=-1;
2387 vol[4] = iPadZ , vol[3] = iPadX;
2388 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2389 interestingCounter++;
2391 vol[4] = iPadZ, vol[3] = iPadX+1;
2392 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2393 interestingCounter++;
2395 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
2396 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2397 interestingCounter++;
2399 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
2400 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2401 interestingCounter++;
2403 if (interestingCounter!=group) continue;
2404 else interestingCounter=-1;
2407 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2408 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
2409 selectedDigit[ii][jj] = 0x0;
2412 vol[4] = iPadZ, vol[3] = iPadX;
2414 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2415 interestingCounter++;
2416 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2417 digitsInVolumeIndices[ii] = -1;
2418 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2419 digitIndexLocal=-1; // AdC
2420 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2421 if (digitsInVolumeIndices[digIndex]<0) continue;
2422 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2423 if (digitInteresting->GetToT()<=0) continue; // AdC
2424 digitIndexLocal++; // AdC
2426 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2427 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2428 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2429 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2430 digitsInVolumeIndices[digIndex],
2431 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2432 AliDebug(1,Form(" to try %d %d ",digIndex, interestingCounter));
2434 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2435 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2436 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2437 digitInteresting->GetToT()*digitInteresting->GetToT(),
2438 digitsInVolumeIndices[digIndex],
2439 digitInteresting->GetTracks());
2441 if (digitIndexLocal==-1) interestingCounter--; // AdC
2445 vol[4] = iPadZ, vol[3] = iPadX+1;
2447 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2448 interestingCounter++;
2449 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2450 digitsInVolumeIndices[ii] = -1;
2451 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2452 digitIndexLocal=-1; // AdC
2453 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2454 if (digitsInVolumeIndices[digIndex]<0) continue;
2455 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2456 if (digitInteresting->GetToT()<=0) continue; // AdC
2457 digitIndexLocal++; // AdC
2459 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2460 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2461 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2462 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2463 digitsInVolumeIndices[digIndex],
2464 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2465 AliDebug(1,Form(" to try %d %d ",digIndex, interestingCounter));
2467 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2468 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2469 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2470 digitInteresting->GetToT()*digitInteresting->GetToT(),
2471 digitsInVolumeIndices[digIndex],
2472 digitInteresting->GetTracks());
2474 if (digitIndexLocal==-1) interestingCounter--; // AdC
2478 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
2480 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2481 interestingCounter++;
2482 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2483 digitsInVolumeIndices[ii] = -1;
2484 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2485 digitIndexLocal=-1; // AdC
2486 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2487 if (digitsInVolumeIndices[digIndex]<0) continue;
2488 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2489 if (digitInteresting->GetToT()<=0) continue; // AdC
2490 digitIndexLocal++; // AdC
2492 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2493 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2494 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2495 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2496 digitsInVolumeIndices[digIndex],
2497 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2498 AliDebug(1,Form(" to try %d %d ",digIndex, interestingCounter));
2500 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2501 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2502 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2503 digitInteresting->GetToT()*digitInteresting->GetToT(),
2504 digitsInVolumeIndices[digIndex],
2505 digitInteresting->GetTracks());
2507 if (digitIndexLocal==-1) interestingCounter--; // AdC
2511 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
2513 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2514 interestingCounter++;
2515 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2516 digitsInVolumeIndices[ii] = -1;
2517 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2518 digitIndexLocal=-1; // AdC
2519 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2520 if (digitsInVolumeIndices[digIndex]<0) continue;
2521 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2522 if (digitInteresting->GetToT()<=0) continue; // AdC
2523 digitIndexLocal++; // AdC
2525 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2526 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2527 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2528 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2529 digitsInVolumeIndices[digIndex],
2530 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2531 AliDebug(1,Form(" to try %d %d ",digIndex, interestingCounter));
2533 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2534 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2535 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2536 digitInteresting->GetToT()*digitInteresting->GetToT(),
2537 digitsInVolumeIndices[digIndex],
2538 digitInteresting->GetTracks());
2540 if (digitIndexLocal==-1) interestingCounter--; // AdC
2543 AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
2550 switch(interestingCounter+1) {
2554 //for (adesso1=0; adesso1<interestingCounter+1; adesso1++) {
2556 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2557 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2559 //for (adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
2561 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2562 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2564 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime) {
2565 AliDebug(1,Form(" selD1[%d][%d]->GetTDC()=%d selD2[%d][%d]->GetTDC()=%d -- %d ",
2566 adesso1,firstIndex,(Int_t)selectedDigit[adesso1][firstIndex]->GetTDC(),
2567 adesso2,secondIndex,(Int_t)selectedDigit[adesso2][secondIndex]->GetTDC(),
2572 AliDebug(1, Form(" %1d %1d (0x%p) %1d %1d (0x%p)", adesso1, firstIndex,selectedDigit[adesso1][firstIndex],
2573 adesso2, secondIndex,selectedDigit[adesso2][secondIndex]));
2575 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2576 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2577 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2578 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2579 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
2580 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
2581 Int_t volDum = vol1[3];
2584 fTOFGeometry->GetPosPar(vol1,pos);
2585 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
2586 interestingX[0] = pos[0];
2587 interestingY[0] = pos[1];
2588 interestingZ[0] = pos[2];
2590 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2591 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2592 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2593 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2594 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
2595 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
2599 fTOFGeometry->GetPosPar(vol2,pos);
2600 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
2601 interestingX[1] = pos[0];
2602 interestingY[1] = pos[1];
2603 interestingZ[1] = pos[2];
2606 AverageCalculations(interestingCounter+1,
2607 interestingX, interestingY, interestingZ,
2608 interestingTOF, interestingTOT, interestingADC,
2610 parTOF, posClus, check);
2612 for (jj=0; jj<5; jj++) det[jj] = -1;
2613 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
2615 AliDebug(1,Form(" %f %f %f", posF[0], posF[1], posF[2]));
2616 fTOFGeometry->GetDetID(posF, det);
2617 AliDebug(1,Form(" %2d %1d %2d %1d %2d", det[0], det[1], det[2], det[3], det[4]));
2619 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
2620 //volIdClus = GetClusterVolIndex(det);
2622 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2623 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
2624 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
2625 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
2626 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
2628 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2629 Int_t ** indDet = new Int_t*[interestingCounter+1];
2630 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj] = new Int_t [5];
2631 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][0] = nSector;
2632 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][1] = nPlate;
2633 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][2] = nStrip;
2634 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][3] = padsCluster[2*jj+3];
2635 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
2636 GetClusterPars(/*check,*/ interestingCounter+1, indDet, interestingWeight, posClus, covClus);
2637 for (jj=0; jj<interestingCounter+1; jj++) delete [] indDet[jj];
2640 // To fill the track index array
2642 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2643 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2644 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
2647 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
2650 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2651 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
2654 alreadyStored = kFALSE;
2655 for (jj=0; jj<dummyCounter+1; jj++)
2656 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
2658 if (alreadyStored) continue;
2659 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2660 AliWarning(" Siamo al limite!");
2665 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
2672 AliTOFcluster *tofCluster =
2673 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
2674 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2675 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); //to updated
2676 InsertCluster(tofCluster);
2678 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",
2679 volIdClus, posClus[0], posClus[1], posClus[2],
2680 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2681 tracks[0], tracks[1], tracks[2],
2682 det[0], det[1], det[2], det[3], det[4],
2683 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
2684 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
2689 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
2693 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
2696 } // close loop on second digit
2697 //} // close loop on adesso2
2699 } // close loop on first digit
2700 //} // close loop on adesso1
2707 //for (adesso1=0; adesso1<interestingCounter+1; adesso1++) {
2709 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2710 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2712 //for (adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
2714 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2715 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2717 //for (adesso3=adesso2+1; adesso3<interestingCounter+1; adesso3++) {
2719 for (Int_t thirdIndex=0; thirdIndex<kMaxNumberOfDigitsPerVolume; thirdIndex++) {
2720 if (selectedDigit[adesso3][thirdIndex]==0x0) continue;
2723 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime
2725 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
2727 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime) continue;
2729 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2730 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2731 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2732 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2733 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
2734 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
2735 Int_t volDum = vol1[3];
2738 fTOFGeometry->GetPosPar(vol1,pos);
2739 interestingX[0] = pos[0];
2740 interestingY[0] = pos[1];
2741 interestingZ[0] = pos[2];
2743 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2744 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2745 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2746 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2747 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
2748 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
2752 fTOFGeometry->GetPosPar(vol2,pos);
2753 interestingX[1] = pos[0];
2754 interestingY[1] = pos[1];
2755 interestingZ[1] = pos[2];
2757 interestingTOF[2] = selectedDigit[adesso3][thirdIndex]->GetTDC();
2758 interestingTOT[2] = selectedDigit[adesso3][thirdIndex]->GetTOT();
2759 interestingADC[2] = selectedDigit[adesso3][thirdIndex]->GetADC();
2760 interestingWeight[2] = selectedDigit[adesso3][thirdIndex]->GetWeight();
2761 Int_t vol3[5]; for(jj=0; jj<5; jj++) vol3[jj] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(jj);
2762 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol3[0], vol3[1], vol3[2], vol3[4], vol3[3]));
2766 fTOFGeometry->GetPosPar(vol3,pos);
2767 interestingX[2] = pos[0];
2768 interestingY[2] = pos[1];
2769 interestingZ[2] = pos[2];
2772 AverageCalculations(interestingCounter+1,
2773 interestingX, interestingY, interestingZ,
2774 interestingTOF, interestingTOT, interestingADC,
2776 parTOF, posClus, check);
2778 for (jj=0; jj<5; jj++) det[jj] = -1;
2779 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
2780 fTOFGeometry->GetDetID(posF, det);
2782 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
2783 //volIdClus = GetClusterVolIndex(det);
2785 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2786 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
2787 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
2788 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
2789 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
2790 padsCluster[7] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(4);
2791 padsCluster[8] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(3);
2793 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2794 Int_t ** indDet = new Int_t*[interestingCounter+1];
2795 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj] = new Int_t [5];
2796 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][0] = nSector;
2797 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][1] = nPlate;
2798 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][2] = nStrip;
2799 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][3] = padsCluster[2*jj+3];
2800 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
2801 GetClusterPars(/*check,*/ interestingCounter+1, indDet, interestingWeight, posClus, covClus);
2802 for (jj=0; jj<interestingCounter+1; jj++) delete [] indDet[jj];
2806 // To fill the track index array
2808 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2809 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2810 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
2813 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
2816 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2817 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
2820 alreadyStored = kFALSE;
2821 for (jj=0; jj<dummyCounter+1; jj++)
2822 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
2824 if (alreadyStored) continue;
2825 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2826 AliWarning(" Siamo al limite!");
2831 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
2836 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2837 if (selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk)==-1) continue;
2840 alreadyStored = kFALSE;
2841 for (jj=0; jj<dummyCounter+1; jj++)
2842 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk));
2844 if (alreadyStored) continue;
2845 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2846 AliWarning(" Siamo al limite!");
2851 tracks[dummyCounter] = selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk);
2858 AliTOFcluster *tofCluster =
2859 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
2860 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2861 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
2862 InsertCluster(tofCluster);
2864 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",
2865 volIdClus, posClus[0], posClus[1], posClus[2],
2866 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2867 tracks[0], tracks[1], tracks[2],
2868 det[0], det[1], det[2], det[3], det[4],
2869 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
2870 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
2875 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
2879 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
2883 fTOFdigitMap->ResetDigitNumber(vol3,selectedDigit[adesso3][thirdIndex]->GetIndex());
2886 } // close loop on third digit
2887 //} // close loop on adesso3
2889 } // close loop on second digit
2890 //} // close loop on adesso2
2892 } // close loop on first digit
2893 //} // close loop on adesso1
2901 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2902 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2905 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2906 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2909 for (Int_t thirdIndex=0; thirdIndex<kMaxNumberOfDigitsPerVolume; thirdIndex++) {
2910 if (selectedDigit[adesso3][thirdIndex]==0x0) continue;
2913 for (Int_t fourthIndex=0; fourthIndex<kMaxNumberOfDigitsPerVolume; fourthIndex++) {
2914 if (selectedDigit[adesso4][fourthIndex]==0x0) continue;
2917 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime
2919 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
2921 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso4][fourthIndex]->GetTDC())>fMaxDeltaTime
2923 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
2925 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso4][fourthIndex]->GetTDC())>fMaxDeltaTime
2927 TMath::Abs(selectedDigit[adesso3][thirdIndex]->GetTDC()-selectedDigit[adesso4][fourthIndex]->GetTDC())>fMaxDeltaTime) continue;
2929 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2930 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2931 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2932 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2933 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
2934 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
2935 Int_t volDum = vol1[3];
2938 fTOFGeometry->GetPosPar(vol1,pos);
2939 interestingX[0] = pos[0];
2940 interestingY[0] = pos[1];
2941 interestingZ[0] = pos[2];
2943 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2944 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2945 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2946 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2947 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
2948 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
2952 fTOFGeometry->GetPosPar(vol2,pos);
2953 interestingX[1] = pos[0];
2954 interestingY[1] = pos[1];
2955 interestingZ[1] = pos[2];
2957 interestingTOF[2] = selectedDigit[adesso3][thirdIndex]->GetTDC();
2958 interestingTOT[2] = selectedDigit[adesso3][thirdIndex]->GetTOT();
2959 interestingADC[2] = selectedDigit[adesso3][thirdIndex]->GetADC();
2960 interestingWeight[2] = selectedDigit[adesso3][thirdIndex]->GetWeight();
2961 Int_t vol3[5]; for(jj=0; jj<5; jj++) vol3[jj] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(jj);
2962 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol3[0], vol3[1], vol3[2], vol3[4], vol3[3]));
2966 fTOFGeometry->GetPosPar(vol3,pos);
2967 interestingX[2] = pos[0];
2968 interestingY[2] = pos[1];
2969 interestingZ[2] = pos[2];
2971 interestingTOF[3] = selectedDigit[adesso4][fourthIndex]->GetTDC();
2972 interestingTOT[3] = selectedDigit[adesso4][fourthIndex]->GetTOT();
2973 interestingADC[3] = selectedDigit[adesso4][fourthIndex]->GetADC();
2974 interestingWeight[3] = selectedDigit[adesso4][fourthIndex]->GetWeight();
2975 Int_t vol4[5]; for(jj=0; jj<5; jj++) vol4[jj] = selectedDigit[adesso4][fourthIndex]->GetDetectorIndex(jj);
2976 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol4[0], vol4[1], vol4[2], vol4[4], vol4[3]));
2980 fTOFGeometry->GetPosPar(vol4,pos);
2981 interestingX[3] = pos[0];
2982 interestingY[3] = pos[1];
2983 interestingZ[3] = pos[2];
2986 AverageCalculations(interestingCounter+1,
2987 interestingX, interestingY, interestingZ,
2988 interestingTOF, interestingTOT, interestingADC,
2990 parTOF, posClus, check);
2992 for (jj=0; jj<5; jj++) det[jj] = -1;
2993 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
2994 fTOFGeometry->GetDetID(posF, det);
2996 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
2997 //volIdClus = GetClusterVolIndex(det);
2999 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
3000 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
3001 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
3002 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
3003 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
3004 padsCluster[7] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(4);
3005 padsCluster[8] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(3);
3006 padsCluster[9] = selectedDigit[adesso4][fourthIndex]->GetDetectorIndex(4);
3007 padsCluster[10] = selectedDigit[adesso4][fourthIndex]->GetDetectorIndex(3);
3009 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
3010 Int_t ** indDet = new Int_t*[interestingCounter+1];
3011 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj] = new Int_t [5];
3012 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][0] = nSector;
3013 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][1] = nPlate;
3014 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][2] = nStrip;
3015 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][3] = padsCluster[2*jj+3];
3016 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
3017 GetClusterPars(/*check,*/ interestingCounter+1, indDet, interestingWeight, posClus, covClus);
3018 for (jj=0; jj<interestingCounter+1; jj++) delete [] indDet[jj];
3021 // To fill the track index array
3023 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
3024 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
3025 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
3028 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
3031 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
3032 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
3035 alreadyStored = kFALSE;
3036 for (jj=0; jj<dummyCounter+1; jj++)
3037 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
3039 if (alreadyStored) continue;
3040 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
3041 AliWarning(" Siamo al limite!");
3046 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
3051 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
3052 if (selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk)==-1) continue;
3055 alreadyStored = kFALSE;
3056 for (jj=0; jj<dummyCounter+1; jj++)
3057 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk));
3059 if (alreadyStored) continue;
3060 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
3061 AliWarning(" Siamo al limite!");
3066 tracks[dummyCounter] = selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk);
3071 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
3072 if (selectedDigit[adesso4][fourthIndex]->GetTrackLabel(kk)==-1) continue;
3075 alreadyStored = kFALSE;
3076 for (jj=0; jj<dummyCounter+1; jj++)
3077 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso4][fourthIndex]->GetTrackLabel(kk));
3079 if (alreadyStored) continue;
3080 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
3081 AliWarning(" Siamo al limite!");
3086 tracks[dummyCounter] = selectedDigit[adesso4][fourthIndex]->GetTrackLabel(kk);
3093 AliTOFcluster *tofCluster =
3094 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
3095 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
3096 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
3097 InsertCluster(tofCluster);
3099 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",
3100 volIdClus, posClus[0], posClus[1], posClus[2],
3101 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
3102 tracks[0], tracks[1], tracks[2],
3103 det[0], det[1], det[2], det[3], det[4],
3104 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
3105 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
3110 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
3114 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
3118 fTOFdigitMap->ResetDigitNumber(vol3,selectedDigit[adesso3][thirdIndex]->GetIndex());
3122 fTOFdigitMap->ResetDigitNumber(vol4,selectedDigit[adesso4][fourthIndex]->GetIndex());
3125 } // close loop on fourth digit
3127 } // close loop on third digit
3129 } // close loop on second digit
3131 } // close loop on first digit
3137 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
3138 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
3139 selectedDigit[ii][jj] = 0x0;
3143 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++) {
3144 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
3145 delete [] selectedDigit[ii][jj];
3146 selectedDigit[ii][jj] = 0x0;
3148 delete [] selectedDigit[ii];
3149 selectedDigit[ii] = 0x0;
3151 delete [] selectedDigit;
3152 selectedDigit = 0x0;
3155 //_____________________________________________________________________________
3157 Int_t AliTOFClusterFinderV1::InsertCluster(AliTOFcluster *tofCluster)
3160 // This function adds a TOF cluster to the array of TOF clusters
3161 // sorted in Z, i.e. fTofClusters
3164 if (fNumberOfTofClusters==kTofMaxCluster) {
3165 AliError("Too many clusters !");
3169 if (fNumberOfTofClusters==0) {
3170 fTofClusters[fNumberOfTofClusters++] = tofCluster;
3174 Int_t ii = FindClusterIndex(tofCluster->GetZ());
3175 memmove(fTofClusters+ii+1 ,fTofClusters+ii,(fNumberOfTofClusters-ii)*sizeof(AliTOFcluster*));
3176 fTofClusters[ii] = tofCluster;
3177 fNumberOfTofClusters++;
3182 //_____________________________________________________________________________
3184 Int_t AliTOFClusterFinderV1::FindClusterIndex(Double_t z) const
3187 // This function returns the index of the nearest cluster in z
3190 if (fNumberOfTofClusters==0) return 0;
3191 if (z <= fTofClusters[0]->GetZ()) return 0;
3192 if (z > fTofClusters[fNumberOfTofClusters-1]->GetZ()) return fNumberOfTofClusters;
3193 Int_t b = 0, e = fNumberOfTofClusters-1, m = (b+e)/2;
3194 for (; b<e; m=(b+e)/2) {
3195 if (z > fTofClusters[m]->GetZ()) b=m+1;
3202 //_____________________________________________________________________________
3204 void AliTOFClusterFinderV1::ResetRecpoint()
3207 // Clear the list of reconstructed points
3210 fNumberOfTofClusters = 0;
3211 if (fRecPoints) fRecPoints->Clear();
3214 //_____________________________________________________________________________
3216 void AliTOFClusterFinderV1::ResetDigits()
3219 // Clear the list of digits
3222 fNumberOfTofDigits = 0;
3223 if (fDigits) fDigits->Clear();
3226 //_____________________________________________________________________________
3227 //UShort_t AliTOFClusterFinderV1::GetClusterVolIndex(Int_t *ind) const
3230 // Get the volume ID to retrieve the l2t transformation
3233 // Detector numbering scheme
3235 Int_t nSector = AliTOFGeometry::NSectors();
3236 Int_t nPlate = AliTOFGeometry::NPlates();
3237 Int_t nStripA = AliTOFGeometry::NStripA();
3238 Int_t nStripB = AliTOFGeometry::NStripB();
3239 Int_t nStripC = AliTOFGeometry::NStripC();
3241 Int_t isector =ind[0];
3242 if (isector >= nSector)
3243 AliError(Form("Wrong sector number in TOF (%d) !", isector));
3244 Int_t iplate = ind[1];
3245 if (iplate >= nPlate)
3246 AliError(Form("Wrong plate number in TOF (%d) !", iplate));
3247 Int_t istrip = ind[2];
3249 Int_t stripOffset = 0;
3255 stripOffset = nStripC;
3258 stripOffset = nStripC+nStripB;
3261 stripOffset = nStripC+nStripB+nStripA;
3264 stripOffset = nStripC+nStripB+nStripA+nStripB;
3267 AliError(Form("Wrong plate number in TOF (%d) !", iplate));
3271 Int_t index= (2*(nStripC+nStripB)+nStripA)*isector +
3275 UShort_t volIndex = AliGeomManager::LayerToVolUID(AliGeomManager::kTOF, index);
3280 //_____________________________________________________________________________
3282 void AliTOFClusterFinderV1::GetClusterPars(Int_t *ind, Double_t* pos, Double_t* cov) const
3285 // Starting from the volume indices (ind[5]), for a cluster coming from
3286 // a isolated digits, this function returns:
3287 // the cluster position (pos),
3288 // the cluster covariance matrix elements (cov)
3292 //we now go in the system of the strip: determine the local coordinates
3295 // 47---------------------------------------------------0 ^ z
3296 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 1 |
3297 // ----------------------------------------------------- | y going outwards
3298 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 0 | par[0]=0;
3300 // ----------------------------------------------------- |
3301 // x <-----------------------------------------------------
3303 //move to the tracking ref system
3304 Double_t lpos[3] = { (ind[4]-23.5)*AliTOFGeometry::XPad(),
3306 (ind[3]- 0.5)*AliTOFGeometry::ZPad() };
3307 AliDebug(1, Form(" %f %f %f", lpos[0], lpos[1], lpos[2]));
3310 UShort_t volIndex = fTOFGeometry->GetAliSensVolIndex(ind[0],ind[1],ind[2]);
3311 //UShort_t volIndex = GetClusterVolIndex(ind);
3312 const TGeoHMatrix *l2t = AliGeomManager::GetTracking2LocalMatrix(volIndex);
3314 // Get the position in the track ref system
3316 l2t->MasterToLocal(lpos,tpos);
3321 //Get the cluster covariance in the track ref system
3323 for (Int_t ii=0; ii<9; ii++) lcov[ii] = 0.;
3325 //cluster covariance in the local system:
3330 lcov[4] = 0.42*0.42/3.;
3331 // = ( 5*0.025 (gas gaps thikness)
3332 // + 4*0.040 (internal glasses thickness)
3333 // + 0.5*0.160 (internl PCB)
3334 // + 1*0.055 (external red glass))
3337 lcov[0] = 0.499678;//AliTOFGeometry::XPad()*AliTOFGeometry::XPad()/12.;
3338 lcov[8] = 0.992429;//AliTOFGeometry::ZPad()*AliTOFGeometry::ZPad()/12.;
3340 //cluster covariance in the tracking system:
3342 m.SetRotation(lcov);
3344 m.MultiplyLeft(&l2t->Inverse());
3345 Double_t *tcov = m.GetRotationMatrix();
3346 cov[0] = tcov[0]; cov[1] = tcov[1]; cov[2] = tcov[2];
3347 cov[3] = tcov[4]; cov[4] = tcov[5]; cov[5] = tcov[8];
3352 //_____________________________________________________________________________
3354 void AliTOFClusterFinderV1::GetClusterPars(/*Bool_t check,*/ Int_t counter,
3355 Int_t **ind, Double_t *weight,
3356 Double_t *pos, Double_t *cov) const
3360 // the volumes indices (ind[counter][5]), for a
3361 // cluster coming from a collection of 'counter'
3363 // the volumes weights (weight[counter]), -controlled
3364 // by the 'check' variable control-, for a cluster
3365 // coming from a collection of 'counter' digits,
3366 // the cluster position (pos),
3367 // this function returns:
3368 // the covariance matrix elements (cov) for the found cluster
3372 // we now go in the system of the strip: determine the local coordinates
3374 // 47---------------------------------------------------0 ^ z
3375 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 1 |
3376 // ----------------------------------------------------- | y going outwards
3377 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 0 | par[0]=0;
3379 // ----------------------------------------------------- |
3380 // x <-----------------------------------------------------
3382 for (Int_t ii=0; ii<counter; ii++)
3383 AliDebug(1, Form(" %2d %2d %1d %2d %1d %2d ",
3384 ii, ind[ii][0], ind[ii][1], ind[ii][2], ind[ii][3], ind[ii][4]));
3386 Float_t posF[3]; for (Int_t ii=0; ii<3; ii++) posF[ii] = (Float_t)pos[ii];
3387 AliDebug(1, Form(" %f %f %f", pos[0], pos[1], pos[2]));
3389 Int_t detClus[5] = {-1, -1, -1, -1, -1};
3390 fTOFGeometry->GetDetID(posF, detClus);
3393 UShort_t volIndex = fTOFGeometry->GetAliSensVolIndex(detClus[0],detClus[1],detClus[2]);
3394 //UShort_t volIndex = GetClusterVolIndex(detClus);
3395 AliDebug(1, Form(" %2d %1d %2d %1d %2d %7i",
3396 detClus[0], detClus[1], detClus[2], detClus[3], detClus[4], volIndex));
3398 // Get the position in the TOF strip ref system
3399 const TGeoHMatrix *alice2strip = AliGeomManager::GetOrigGlobalMatrix(volIndex);
3400 Double_t ppos[3] = {-1, -1, -1};
3401 alice2strip->MasterToLocal(pos,ppos);
3402 AliDebug(1, Form(" %f %f %f", ppos[0], ppos[1], ppos[2]));
3405 // Get the position in the tracking ref system
3406 const TGeoHMatrix *g2l = AliGeomManager::GetTracking2LocalMatrix(volIndex);
3407 Double_t lpos[3] = {-1, -1, -1};
3408 g2l->MasterToLocal(ppos,lpos);
3409 AliDebug(1, Form(" %f %f %f", lpos[0], lpos[1], lpos[2]));
3410 for (Int_t ii=0; ii<3; ii++) pos[ii] = lpos[ii];
3412 //Get the cluster covariance in the track ref system
3414 for (Int_t ii=0; ii<9; ii++) lcov[ii] = 0.;
3416 //cluster covariance in the local system:
3421 // Evaluation of the ovariance matrix elements
3422 TOFclusterError(/*check,*/ counter, ind, weight, ppos, lcov);
3424 AliDebug(1, Form("lcov[0] = %f, lcov[8] = %f", lcov[0], lcov[8]));
3426 //cluster covariance in the tracking system:
3428 m.SetRotation(lcov);
3430 m.MultiplyLeft(&g2l->Inverse());
3431 Double_t *tcov = m.GetRotationMatrix();
3432 cov[0] = tcov[0]; cov[1] = tcov[1]; cov[2] = tcov[2];
3433 cov[3] = tcov[4]; cov[4] = tcov[5]; cov[5] = tcov[8];
3438 //_____________________________________________________________________________
3440 void AliTOFClusterFinderV1::TOFclusterError(/*Bool_t check,*/ Int_t counter,
3441 Int_t **ind, Double_t *weight,
3442 Double_t ppos[], Double_t lcov[]) const
3448 //lcov[4] = 0.42*0.42/3.; // cm2
3449 // = ( 5*0.025 (gas gaps thikness)
3450 // + 4*0.040 (internal glasses thickness)
3451 // + 0.5*0.160 (internl PCB)
3452 // + 1*0.055 (external red glass))
3455 Float_t *delta2X = new Float_t[counter];
3456 for (Int_t ii=0; ii<counter; ii++)
3458 ((ind[ii][4]-23.5)*AliTOFGeometry::XPad() - ppos[0])*((ind[ii][4]-23.5)*AliTOFGeometry::XPad() - ppos[0]);
3460 Float_t *delta2Z = new Float_t[counter];
3461 for (Int_t ii=0; ii<counter; ii++)
3463 ((ind[ii][3]- 0.5)*AliTOFGeometry::ZPad() - ppos[2])*((ind[ii][3]- 0.5)*AliTOFGeometry::ZPad() - ppos[2]);
3465 for (Int_t ii=0; ii<counter; ii++)
3466 AliDebug(1, Form("x[%d] = %f, z[%d] = %f, weight[%d] = %f",
3467 ii, (ind[ii][4]-23.5)*AliTOFGeometry::XPad(),
3468 ii, (ind[ii][3]- 0.5)*AliTOFGeometry::ZPad(),
3471 AliDebug(1, Form("xMean = %f, zMean = %f",ppos[0], ppos[2]));
3479 if (ind[0][3]==ind[1][3] && TMath::Abs(ind[0][4]-ind[1][4])==1) { //
3481 lcov[8] = 1.02039; // cm2
3482 lcov[0] = 0.0379409; // cm2
3485 lcov[0] = 0.5*0.5; // cm2
3487 if (weight[0]==weight[1])
3488 lcov[0] = 0.0379409; // cm2
3490 lcov[0] = TMath::Mean(counter, delta2X, weight); // cm2
3496 else if (ind[0][4]==ind[1][4] && TMath::Abs(ind[0][3]-ind[1][3])==1) {//
3498 lcov[0] = 0.505499; // cm2
3499 lcov[8] = 0.0422046; // cm2
3502 lcov[8] = 0.5*0.5; // cm2
3504 if (weight[0]==weight[1])
3505 lcov[8] = 0.0422046; // cm2
3507 lcov[8] = TMath::Mean(counter, delta2Z, weight); // cm2
3516 lcov[0] = 0.0290677; // cm2
3517 lcov[8] = 0.0569726; // cm2
3520 lcov[0] = 0.5*0.5; // cm2
3521 lcov[8] = 0.5*0.5; // cm2
3524 if (weight[0]==weight[1] && weight[0]==weight[2]) {
3525 lcov[0] = 0.0290677; // cm2
3526 lcov[8] = 0.0569726; // cm2
3529 lcov[0] = TMath::Mean(counter, delta2X, weight); // cm2
3530 lcov[8] = TMath::Mean(counter, delta2Z, weight); // cm2
3539 lcov[0] = 0.0223807; // cm2
3540 lcov[8] = 0.0438662; // cm2
3543 lcov[0] = 0.5*0.5; // cm2
3544 lcov[8] = 0.5*0.5; // cm2
3547 if (weight[0]==weight[1] && weight[0]==weight[2] && weight[0]==weight[3]) {
3548 lcov[0] = 0.0223807; // cm2
3549 lcov[8] = 0.0438662; // cm2
3552 lcov[0] = TMath::Mean(counter, delta2X, weight); // cm2
3553 lcov[8] = TMath::Mean(counter, delta2Z, weight); // cm2
3567 //_____________________________________________________________________________
3569 Bool_t AliTOFClusterFinderV1::MakeSlewingCorrection(Int_t *detectorIndex,
3575 // This funtion makes the following:
3577 // - if at least one of the three status (Pulser/Noise/HW) is
3578 // bad, is sets the status of electronic channel, corresponding to the
3579 // volume identified by detectorIndex, as kFALSE;
3580 // - if offline calibration is in the valid status, it performs the
3581 // slewing correction. In particular, by taking into account:
3582 // * the measured tot and tof values (tofDigitToT and tofDigitTdc,
3584 // * the six parameters of 5th order polynomial used
3585 // to fit the tofVStot scatter plot,
3586 // it returns the corrected tof value, i.e. tdcCorr value.
3589 Bool_t output = kTRUE;
3594 //AliInfo(" Calibrating TOF Digits: ");
3596 AliTOFChannelOnlineArray *calDelay = fTOFcalib->GetTOFOnlineDelay();
3597 AliTOFChannelOnlineStatusArray *calStatus = fTOFcalib->GetTOFOnlineStatus();
3599 TObjArray *calTOFArrayOffline = fTOFcalib->GetTOFCalArrayOffline();
3601 Int_t index = AliTOFGeometry::GetIndex(detectorIndex);
3603 UChar_t statusPulser = calStatus->GetPulserStatus(index);
3604 UChar_t statusNoise = calStatus->GetNoiseStatus(index);
3605 UChar_t statusHW = calStatus->GetHWStatus(index);
3606 UChar_t status = calStatus->GetStatus(index);
3608 //check the status, also unknown is fine!!!!!!!
3610 AliDebug(2, Form(" Status for channel %d = %d",index, (Int_t)status));
3611 if((statusPulser & AliTOFChannelOnlineStatusArray::kTOFPulserBad)==(AliTOFChannelOnlineStatusArray::kTOFPulserBad)||(statusNoise & AliTOFChannelOnlineStatusArray::kTOFNoiseBad)==(AliTOFChannelOnlineStatusArray::kTOFNoiseBad)||(statusHW & AliTOFChannelOnlineStatusArray::kTOFHWBad)==(AliTOFChannelOnlineStatusArray::kTOFHWBad)){
3612 AliDebug(2, Form(" Bad Status for channel %d",index));
3613 //fTofClusters[ii]->SetStatus(kFALSE); //odd convention, to avoid conflict with calibration objects currently in the db (temporary solution).
3617 AliDebug(2, Form(" Good Status for channel %d",index));
3620 if (fCalibrateTOFtimes) { // AdC
3622 // Get Rough channel online equalization
3623 Double_t roughDelay = (Double_t)calDelay->GetDelay(index); // in ns
3624 AliDebug(2,Form(" channel delay (ns) = %f", roughDelay));
3625 // Get Refined channel offline calibration parameters
3626 TString validity = (TString)fTOFcalib->GetOfflineValidity();
3627 if (validity.CompareTo("valid")==0) {
3628 AliTOFChannelOffline * calChannelOffline = (AliTOFChannelOffline*)calTOFArrayOffline->At(index);
3630 for (jj = 0; jj<6; jj++)
3631 par[jj] = (Double_t)calChannelOffline->GetSlewPar(jj);
3633 AliDebug(2,Form(" Calib Pars = %f, %f, %f, %f, %f, %f ",par[0],par[1],par[2],par[3],par[4],par[5]));
3634 AliDebug(2,Form(" The ToT and Time, uncorr (counts) = %d , %d", tofDigitToT, tofDigitTdc));
3635 Double_t tToT = (Double_t)(tofDigitToT*AliTOFGeometry::ToTBinWidth());
3636 tToT*=1.E-3; //ToT in ns
3637 AliDebug(2,Form(" The ToT and Time, uncorr (ns)= %e, %e",tofDigitTdc*AliTOFGeometry::TdcBinWidth()*1.E-3,tToT));
3638 timeCorr = par[0] + tToT*(par[1] + tToT*(par[2] + tToT*(par[3] + tToT*(par[4] + tToT*par[5])))); // the time correction (ns)
3641 timeCorr = roughDelay; // correction in ns
3643 AliDebug(2,Form(" The ToT and Time, uncorr (ns)= %e, %e",tofDigitTdc*AliTOFGeometry::TdcBinWidth()*1.E-3,tofDigitToT*AliTOFGeometry::ToTBinWidth()));
3644 AliDebug(2,Form(" The time correction (ns) = %f", timeCorr));
3645 timeCorr = (Double_t)(tofDigitTdc)*AliTOFGeometry::TdcBinWidth()*1.E-3-timeCorr;//redefine the time
3647 AliDebug(2,Form(" The channel time, corr (ps)= %e",timeCorr ));
3648 //tdcCorr = (Int_t)(timeCorr/AliTOFGeometry::TdcBinWidth()); //the corrected time (tdc counts)
3649 tdcCorr = TMath::Nint(timeCorr/AliTOFGeometry::TdcBinWidth()); //the corrected time (tdc counts)
3656 //______________________________________________________________________________
3658 void AliTOFClusterFinderV1::Digits2RecPoints(Int_t iEvent)
3661 // Converts digits to recpoints for TOF
3664 TStopwatch stopwatch;
3667 fRunLoader->GetEvent(iEvent);
3669 AliLoader *localTOFLoader = (AliLoader*)fRunLoader->GetLoader("TOFLoader");
3671 TTree * localTreeD = (TTree*)localTOFLoader->TreeD();
3672 if (localTreeD == 0x0) {
3673 AliFatal("Can not get TreeD");
3677 TBranch *branch = localTreeD->GetBranch("TOF");
3679 AliError("Can't get the branch with the TOF digits !");
3683 TTree *localTreeR = (TTree*)localTOFLoader->TreeR();
3684 if (localTreeR == 0x0)
3686 localTOFLoader->MakeTree("R");
3687 localTreeR = localTOFLoader->TreeR();
3690 Digits2RecPoints(localTreeD, localTreeR);
3692 //localTOFLoader = fRunLoader->GetLoader("TOFLoader");
3693 localTOFLoader->WriteRecPoints("OVERWRITE");
3695 AliDebug(1, Form("Execution time to read TOF digits and to write TOF clusters for the event number %d: R:%.4fs C:%.4fs",
3696 iEvent, stopwatch.RealTime(),stopwatch.CpuTime()));
3699 //______________________________________________________________________________
3701 void AliTOFClusterFinderV1::Digits2RecPoints(Int_t iEvent, AliRawReader *rawReader)
3704 // Converts RAW data to recpoints for TOF
3707 TStopwatch stopwatch;
3710 fRunLoader->GetEvent(iEvent);
3712 AliDebug(2,Form(" Event number %2d ", iEvent));
3714 AliLoader *localTOFLoader = (AliLoader*)fRunLoader->GetLoader("TOFLoader");
3716 TTree *localTreeR = localTOFLoader->TreeR();
3718 if (localTreeR == 0x0){
3719 localTOFLoader->MakeTree("R");
3720 localTreeR = localTOFLoader->TreeR();
3723 Digits2RecPoints(rawReader, localTreeR);
3725 AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters for the event number %d: R:%.4fs C:%.4fs",
3726 iEvent, stopwatch.RealTime(),stopwatch.CpuTime()));
3729 //______________________________________________________________________________
3731 void AliTOFClusterFinderV1::Raw2Digits(Int_t iEvent, AliRawReader *rawReader)
3734 // Converts RAW data to MC digits for TOF
3738 TStopwatch stopwatch;
3741 fRunLoader->GetEvent(iEvent);
3743 AliDebug(2,Form(" Event number %2d ", iEvent));
3745 AliLoader *localTOFLoader = (AliLoader*)fRunLoader->GetLoader("TOFLoader");
3747 TTree *localTreeD = localTOFLoader->TreeD();
3749 if (localTreeD == 0x0){
3750 localTOFLoader->MakeTree("D");
3751 localTreeD = localTOFLoader->TreeD();
3754 Raw2Digits(rawReader, localTreeD);
3756 AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters for the event number %d: R:%.4fs C:%.4fs",
3757 iEvent, stopwatch.RealTime(),stopwatch.CpuTime()));
3760 //______________________________________________________________________________
3762 void AliTOFClusterFinderV1::AverageCalculations(Int_t number, Float_t *interestingX,
3763 Float_t *interestingY, Float_t *interestingZ,
3764 Double_t *interestingTOF, Double_t *interestingTOT,
3765 Double_t *interestingADC, Double_t *interestingWeight,
3766 Int_t *parTOF, Double_t *posClus, Bool_t &check)
3769 // Calculates the mean values for cluster position (x,y,z),
3770 // TOF charge and time
3773 Double_t tofAverage = 0.;
3774 Double_t totAverage = 0.;
3775 Double_t adcAverage = 0.;
3779 for (ii=number-1; ii>=0; ii--) check=check||(interestingWeight[ii]==0 || interestingWeight[ii]==-1);
3783 posClus[0] = TMath::Mean(number, interestingX);
3784 posClus[1] = TMath::Mean(number, interestingY);
3785 posClus[2] = TMath::Mean(number, interestingZ);
3786 tofAverage = TMath::Mean(number, interestingTOF);
3787 totAverage = TMath::Mean(number, interestingTOT);
3788 adcAverage = TMath::Mean(number, interestingADC);
3793 posClus[0] = TMath::Mean(number, interestingX, interestingWeight);
3794 posClus[1] = TMath::Mean(number, interestingY, interestingWeight);
3795 posClus[2] = TMath::Mean(number, interestingZ, interestingWeight);
3796 tofAverage = TMath::Mean(number, interestingTOF, interestingWeight);
3797 totAverage = TMath::Mean(number, interestingTOT, interestingWeight);
3798 adcAverage = TMath::Mean(number, interestingADC, interestingWeight);
3802 parTOF[0] = Int_t(tofAverage);
3803 parTOF[1] = Int_t(totAverage);
3804 parTOF[2] = Int_t(adcAverage);
3805 parTOF[3] = Int_t(tofAverage);//tofND
3806 parTOF[4] = Int_t(tofAverage);//tofRAW