1 /***************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
17 $Log: AliTOFClusterFinderV1.cxx,v $
18 Revision 2009/04/20 A. De Caro
19 - added two new global variables, called fTOFGeometry and fTOFdigits;
20 - added a new method, called FindClustersWithoutTOT,
21 to transform TOF digits with fTOT=0 in one pad clusters;
22 - update of the covariance matrix elements for the TOF clusters
24 Revision 0.01 2008/05/10 A. De Caro
27 /////////////////////////////////////////
29 // Class for TOF cluster finder (V1) //
31 // Input data: Raw Data or Digits; //
32 // Output data: Digits or Rec Points //
34 /////////////////////////////////////////
36 #include "Riostream.h"
38 #include "TClonesArray.h"
39 #include "TStopwatch.h"
41 #include "TGeoMatrix.h"
46 #include "AliRawReader.h"
47 #include "AliRunLoader.h"
48 #include "AliGeomManager.h"
50 #include "AliTOFcalib.h"
51 #include "AliTOFChannelOnlineArray.h"
52 #include "AliTOFChannelOnlineStatusArray.h"
53 #include "AliTOFChannelOffline.h"
54 #include "AliTOFClusterFinderV1.h"
55 #include "AliTOFcluster.h"
56 #include "AliTOFdigit.h"
57 #include "AliTOFDigitMap.h"
58 #include "AliTOFrawData.h"
59 #include "AliTOFReconstructor.h"
60 #include "AliTOFRecoParam.h"
62 ClassImp(AliTOFClusterFinderV1)
64 //_____________________________________________________________________________
65 AliTOFClusterFinderV1::AliTOFClusterFinderV1(AliTOFcalib *calib):
67 fDigits(new TClonesArray("AliTOFdigit", 4000)),
68 fRecPoints(new TClonesArray("AliTOFcluster", 4000)),
69 fNumberOfTofClusters(0),
70 fNumberOfTofDigits(0),
75 fTOFdigitMap(new AliTOFDigitMap()),
76 fTOFGeometry(new AliTOFGeometry()),
78 fTOFRawStream(AliTOFRawStream())
83 const AliTOFRecoParam *recoParam = AliTOFReconstructor::GetRecoParam(); // instantiate reco param from STEER...
84 fMaxDeltaTime = recoParam->GetMaxDeltaTime();
87 //_____________________________________________________________________________
88 AliTOFClusterFinderV1::AliTOFClusterFinderV1(AliRunLoader* runLoader, AliTOFcalib *calib):
89 fRunLoader(runLoader),
90 fDigits(new TClonesArray("AliTOFdigit", 4000)),
91 fRecPoints(new TClonesArray("AliTOFcluster", 4000)),
92 fNumberOfTofClusters(0),
93 fNumberOfTofDigits(0),
98 fTOFdigitMap(new AliTOFDigitMap()),
99 fTOFGeometry(new AliTOFGeometry()),
101 fTOFRawStream(AliTOFRawStream())
106 const AliTOFRecoParam *recoParam = AliTOFReconstructor::GetRecoParam(); // instantiate reco param from STEER...
107 fMaxDeltaTime = recoParam->GetMaxDeltaTime();
110 //_____________________________________________________________________________
112 AliTOFClusterFinderV1::AliTOFClusterFinderV1(const AliTOFClusterFinderV1 &source)
115 fDigits(source.fDigits),
116 fRecPoints(source.fRecPoints),
117 fNumberOfTofClusters(0),
118 fNumberOfTofDigits(0),
121 fDecoderVersion(source.fDecoderVersion),
122 fTOFcalib(source.fTOFcalib),
123 fTOFdigitMap(new AliTOFDigitMap()),
124 fTOFGeometry(new AliTOFGeometry()),
125 fTOFdigits(source.fTOFdigits),
126 fTOFRawStream(source.fTOFRawStream)
131 //_____________________________________________________________________________
133 AliTOFClusterFinderV1& AliTOFClusterFinderV1::operator=(const AliTOFClusterFinderV1 &source)
140 TObject::operator=(source);
141 fDigits=source.fDigits;
142 fRecPoints=source.fRecPoints;
143 fVerbose=source.fVerbose;
144 fDecoderVersion=source.fDecoderVersion;
145 fTOFcalib=source.fTOFcalib;
146 fTOFdigitMap=source.fTOFdigitMap;
147 fTOFGeometry=source.fTOFGeometry;
148 fTOFdigits=source.fTOFdigits;
149 fTOFRawStream=source.fTOFRawStream;
153 //_____________________________________________________________________________
155 AliTOFClusterFinderV1::~AliTOFClusterFinderV1()
170 fRecPoints->Delete();
182 //_____________________________________________________________________________
184 void AliTOFClusterFinderV1::Digits2RecPoints(TTree* digitsTree, TTree* clusterTree)
187 // Converts digits to recPoints for TOF
190 TStopwatch stopwatch;
195 TClonesArray &aDigits = *fDigits;
197 if (digitsTree == 0x0)
198 AliFatal("Can not get TreeD for TOF");
200 TBranch *branch = digitsTree->GetBranch("TOF");
202 AliError("Can not get branch with the TOF digits !");
206 TClonesArray staticDigits("AliTOFdigit",10000);
207 staticDigits.Clear();
208 TClonesArray *digits = &staticDigits;
209 branch->SetAddress(&digits);
210 digitsTree->GetEvent(0);
211 AliInfo(Form("Number of TOF digits: %d", digits->GetEntriesFast()));
213 AliTOFdigit *tofDigit;
216 Int_t detectorIndex[5];
217 for (jj=0; jj<5; jj++) detectorIndex[jj] = -1;
219 for (jj=0; jj<4; jj++) info[jj] = -1;
225 Bool_t status = kTRUE;
227 AliInfo(" Calibrating TOF Digits: ");
228 TString validity = (TString)fTOFcalib->GetOfflineValidity();
229 AliInfo(Form(" validity = %s", validity.Data()));
230 if (validity.CompareTo("valid")==0) {
231 AliInfo(" ...using offline calibration parameters");
234 AliInfo(" ...using online calibration parameters");
238 for (ii=0; ii<digits->GetEntriesFast(); ii++) {
239 tofDigit = (AliTOFdigit*)digits->UncheckedAt(ii);
240 detectorIndex[0] = tofDigit->GetSector();
241 detectorIndex[1] = tofDigit->GetPlate();
242 detectorIndex[2] = tofDigit->GetStrip();
243 detectorIndex[3] = tofDigit->GetPadz();
244 detectorIndex[4] = tofDigit->GetPadx();
246 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
247 if (detectorIndex[1]==2) { // plate with holes
253 status = MakeSlewingCorrection(detectorIndex, tofDigit->GetToT(), tofDigit->GetTdc(), tdcCorr);
255 for (jj=0; jj<4; jj++) info[jj] = -1;
256 info[0] = tdcCorr;//tofDigit->GetTdc();
257 info[1] = tofDigit->GetAdc();
258 info[2] = tofDigit->GetToT();
259 info[3] = tofDigit->GetTdcND();//tofDigit->GetTdc();//
260 tracks = tofDigit->GetTracks();
262 dummy = detectorIndex[3];
263 detectorIndex[3] = detectorIndex[4];//padx
264 detectorIndex[4] = dummy;//padz
265 last = fDigits->GetEntriesFast();
266 new (aDigits[last]) AliTOFdigit(tracks, detectorIndex, info);
267 if (status) fTOFdigitMap->AddDigit(detectorIndex, last);
269 AliDebug(2, Form(" Digits reading %2d -> %2d %1d %2d %1d %2d (%d, %d, %d)",
271 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[3], detectorIndex[4],
272 info[0], info[1], info[3]));
276 fNumberOfTofDigits = fDigits->GetEntriesFast();
280 Int_t bufsize = 32000;
281 clusterTree->Branch("TOF", &fRecPoints, bufsize);
286 AliInfo(Form("Number of found clusters: %d", fNumberOfTofClusters));
290 fTOFdigitMap->Clear();
294 AliInfo(Form("Execution time to read TOF digits and to write TOF clusters : R:%.4fs C:%.4fs",
295 stopwatch.RealTime(),stopwatch.CpuTime()));
297 if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
300 //_____________________________________________________________________________
302 void AliTOFClusterFinderV1::Digits2RecPoints(AliRawReader *rawReader, TTree *clustersTree)
305 // Converts raw data to recPoints for TOF
308 TStopwatch stopwatch;
312 AliDebug(2, "TreeD re-creation");
313 //TTree *digitsTree = new TTree();
314 //Raw2Digits(rawReader, digitsTree);
316 Raw2Digits(rawReader, fTOFdigits);
318 AliDebug(2,Form("Number of TOF digits: %d", fNumberOfTofDigits));
321 Int_t bufsize = 32000;
322 clustersTree->Branch("TOF", &fRecPoints, bufsize);
325 clustersTree->Fill();
327 AliInfo(Form("Number of found clusters: %d", fNumberOfTofClusters));
331 fTOFdigitMap->Clear();
335 AliInfo(Form("Execution time to read TOF raw data and to write TOF clusters : R:%.4fs C:%.4fs",
336 stopwatch.RealTime(),stopwatch.CpuTime()));
340 //_____________________________________________________________________________
342 void AliTOFClusterFinderV1::Raw2Digits(AliRawReader *rawReader, TTree* digitsTree)
345 // Converts raw data to digits for TOF
348 TStopwatch stopwatch;
353 const Int_t kMaxNumberOfTracksPerDigit = 3;
354 const Int_t kDDL = AliDAQ::NumberOfDdls("TOF");
356 digitsTree->Branch("TOF", &fDigits);
357 TClonesArray &aDigits = *fDigits;
359 fTOFRawStream.Clear();
360 fTOFRawStream.SetRawReader(rawReader);
363 if (fVerbose==2) ftxt.open("TOFdigitsRead.txt",ios::app);
365 TClonesArray staticRawData("AliTOFrawData",10000);
366 staticRawData.Clear();
367 TClonesArray * clonesRawData = &staticRawData;
370 Int_t detectorIndex[5] = {-1, -1, -1, -1, -1};
372 Int_t tracks[kMaxNumberOfTracksPerDigit];
373 for (Int_t ii=0; ii<kMaxNumberOfTracksPerDigit; ii++)
378 Bool_t status = kTRUE;
380 AliInfo(" Calibrating TOF Digits: ");
381 TString validity = (TString)fTOFcalib->GetOfflineValidity();
382 AliInfo(Form(" validity = %s", validity.Data()));
383 if (validity.CompareTo("valid")==0) {
384 AliInfo(" ...using offline calibration parameters");
387 AliInfo(" ...using online calibration parameters");
392 for (indexDDL=0; indexDDL<kDDL; indexDDL++) {
395 if (fDecoderVersion) {
396 AliInfo("Using New Decoder \n");
397 fTOFRawStream.LoadRawDataBuffers(indexDDL,fVerbose);
399 else fTOFRawStream.LoadRawData(indexDDL);
401 clonesRawData = (TClonesArray*)fTOFRawStream.GetRawData();
402 if (clonesRawData->GetEntriesFast()!=0) AliInfo(Form(" TOF raw data number = %3d", clonesRawData->GetEntriesFast()));
403 for (iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
405 AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
407 //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
408 if (tofRawDatum->GetTOF()==-1) continue;
410 fTOFRawStream.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
411 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
414 dummy = detectorIndex[3];
415 detectorIndex[3] = detectorIndex[4];//padz
416 detectorIndex[4] = dummy;//padx
417 status = MakeSlewingCorrection(detectorIndex, tofRawDatum->GetTOT(), tofRawDatum->GetTOF(), tdcCorr);
420 digit[1] = tofRawDatum->GetTOT();
421 digit[2] = tofRawDatum->GetTOT();
422 digit[3] = -1;//tofRawDatum->GetTOF(); //tofND
424 dummy = detectorIndex[3];
425 detectorIndex[3] = detectorIndex[4];//padx
426 detectorIndex[4] = dummy;//padz
428 /* check valid index */
429 if (detectorIndex[0]==-1||detectorIndex[1]==-1||detectorIndex[2]==-1||detectorIndex[3]==-1||detectorIndex[4]==-1) continue;
431 // Do not reconstruct anything in the holes
432 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
433 if (detectorIndex[1]==2) { // plate with holes
439 last = fDigits->GetEntriesFast();
440 new (aDigits[last]) AliTOFdigit(tracks, detectorIndex, digit);
441 if (status) fTOFdigitMap->AddDigit(detectorIndex, last);
444 if (indexDDL<10) ftxt << " " << indexDDL;
445 else ftxt << " " << indexDDL;
446 if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM();
447 else ftxt << " " << tofRawDatum->GetTRM();
448 ftxt << " " << tofRawDatum->GetTRMchain();
449 if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC();
450 else ftxt << " " << tofRawDatum->GetTDC();
451 ftxt << " " << tofRawDatum->GetTDCchannel();
453 if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0];
454 else ftxt << " -> " << detectorIndex[0];
455 ftxt << " " << detectorIndex[1];
456 if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2];
457 else ftxt << " " << detectorIndex[2];
458 ftxt << " " << detectorIndex[4];
459 if (detectorIndex[4]<10) ftxt << " " << detectorIndex[3];
460 else ftxt << " " << detectorIndex[3];
462 if (digit[1]<10)ftxt << " " << digit[1];
463 else if (digit[1]>=10 && digit[1]<100) ftxt << " " << digit[1];
464 else ftxt << " " << digit[1];
465 if (digit[0]<10) ftxt << " " << digit[0] << endl;
466 else if (digit[0]>=10 && digit[0]<100) ftxt << " " << digit[0] << endl;
467 else if (digit[0]>=100 && digit[0]<1000) ftxt << " " << digit[0] << endl;
468 else ftxt << " " << digit[3] << endl;
471 AliDebug(2, Form(" Raw data reading %2d -> %2d %1d %2d %1d %2d (%d, %d, %d)",
473 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[4], detectorIndex[3],
474 digit[0], digit[1], digit[3]));
478 clonesRawData->Clear();
482 if (fVerbose==2) ftxt.close();
486 fNumberOfTofDigits = fDigits->GetEntries();
488 AliDebug(1, Form("Got %d TOF digits", fNumberOfTofDigits));
489 AliDebug(1, Form("Execution time to read TOF raw data and fill TOF digit tree : R:%.2fs C:%.2fs",
490 stopwatch.RealTime(),stopwatch.CpuTime()));
492 if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
495 //_____________________________________________________________________________
497 void AliTOFClusterFinderV1::FillRecPoint()
500 // Fill the global TClonesArray of AliTOFcluster objects,
509 for(Int_t iPlate=AliTOFGeometry::NPlates()-1; iPlate>=0; iPlate--) {
510 for(Int_t iStrip=AliTOFGeometry::NStrip(iPlate)-1; iStrip>=0; iStrip--) {
511 //for (Int_t iSector=AliTOFGeometry::NSectors()-1; iSector>=0; iSector--) {
512 for (Int_t iSector=0; iSector<AliTOFGeometry::NSectors(); iSector++) {
514 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
515 FindClustersWithoutTOT(iSector, iPlate, iStrip); // clusters coming from digits without TOT measurement
518 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
519 FindClustersPerStrip(iSector, iPlate, iStrip, 4); // 4 pads clusters
520 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
522 dummy4_1 = fNumberOfTofClusters;
523 FindClustersPerStrip(iSector, iPlate, iStrip, 4); // 4 pads clusters
524 if (fNumberOfTofClusters!=dummy4_1)
525 AliDebug(2, Form(" (4): n1= %5d, n2 = %5", dummy4_1, fNumberOfTofClusters));
528 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
529 FindClustersPerStrip(iSector, iPlate, iStrip, 3); // 3 pads clusters
530 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
532 dummy3_1 = fNumberOfTofClusters;
533 FindClustersPerStrip(iSector, iPlate, iStrip, 3); // 3 pads clusters
534 if (fNumberOfTofClusters!=dummy3_1)
535 AliDebug(2, Form(" (3): n1= %5d, n2 = %5", dummy3_1, fNumberOfTofClusters));
538 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
539 FindClustersPerStrip(iSector, iPlate, iStrip, 2); // 2 pads clusters
540 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
542 dummy2_1 = fNumberOfTofClusters;
543 FindClustersPerStrip(iSector, iPlate, iStrip, 2); // 2 pads clusters
544 if (fNumberOfTofClusters!=dummy2_1)
545 AliDebug(2, Form(" (2): n1= %5d, n2 =%5", dummy2_1, fNumberOfTofClusters));
548 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
549 dummy = fNumberOfTofClusters;
550 FindClusters34(iSector, iPlate, iStrip); // 3 pads clusters between 4 hit pads
551 if (fNumberOfTofClusters!=dummy)
552 AliDebug(2, Form(" (3 between 4): n1 = %5d, n2 = %5d", fNumberOfTofClusters, dummy));
555 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
556 dummy = fNumberOfTofClusters;
557 FindClusters23(iSector, iPlate, iStrip); // 2 pads clusters between 3 hit pads
558 if (fNumberOfTofClusters!=dummy)
559 AliDebug(2, Form(" (2 between 3): n1 = %5d, n2 = %5d", fNumberOfTofClusters, dummy));
561 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
562 dummy = fNumberOfTofClusters;
563 FindClusters24(iSector, iPlate, iStrip); // 2 pads clusters between 4 hit pads
564 if (fNumberOfTofClusters!=dummy)
565 AliDebug(2, Form(" (2 between 4): n1 = %5d, n2 = %5d", fNumberOfTofClusters, dummy));
568 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
569 dummy = fNumberOfTofClusters;
570 FindOnePadClusterPerStrip(iSector, iPlate, iStrip); // 1 pad clusters
571 if (fNumberOfTofClusters!=dummy)
572 AliDebug(2,Form(" (1): n1 = %5d, n2 = %5d", fNumberOfTofClusters, dummy));
574 if (fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip)>0)
575 AliDebug(2, Form(" (1): number of clusters = %5d (remaining digit %2d), -%2d %1d %2d-",
576 fNumberOfTofClusters, fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip),
577 iSector, iPlate, iStrip));
584 TClonesArray &lRecPoints = *fRecPoints;
588 Int_t detectorIndex[5];
589 for (jj=0; jj<5; jj++) detectorIndex[jj] = -1;
591 for (jj=0; jj<5; jj++) parTOF[jj] = -1;
592 Int_t trackLabels[3];
593 for (jj=0; jj<3; jj++) trackLabels[jj] = -1;
594 Int_t digitIndex = -1;
595 Bool_t status = kTRUE;
597 for (ii=0; ii<3; ii++) posClus[ii] = 0.;
598 //Float_t covClus[6];
599 //for (ii=0; ii<6; ii++) covClus[ii] = 0.;
602 for (ii=0; ii<fNumberOfTofClusters; ii++) {
604 digitIndex = fTofClusters[ii]->GetIndex();
605 for(jj=0; jj<5; jj++) detectorIndex[jj] = fTofClusters[ii]->GetDetInd(jj);
606 volIdClus = fTOFGeometry->GetAliSensVolIndex(detectorIndex[0],detectorIndex[1],detectorIndex[2]);
607 //volIdClus = GetClusterVolIndex(detectorIndex);
608 for(jj=0; jj<3; jj++) trackLabels[jj] = fTofClusters[ii]->GetLabel(jj);
609 parTOF[0] = fTofClusters[ii]->GetTDC(); // TDC
610 parTOF[1] = fTofClusters[ii]->GetToT(); // TOT
611 parTOF[2] = fTofClusters[ii]->GetADC(); // ADC=TOT
612 parTOF[3] = fTofClusters[ii]->GetTDCND(); // TDCND
613 parTOF[4] = fTofClusters[ii]->GetTDCRAW();//RAW
614 status = fTofClusters[ii]->GetStatus();
616 posClus[0] = fTofClusters[ii]->GetX();
617 posClus[1] = fTofClusters[ii]->GetY();
618 posClus[2] = fTofClusters[ii]->GetZ();
620 //for (jj=0; jj<6; jj++) covClus[jj] = 0.;
621 //((AliCluster*)fTofClusters[ii])->GetGlobalCov(covClus);
623 new(lRecPoints[ii]) AliTOFcluster(volIdClus, (Double_t)posClus[0], (Double_t)posClus[1], (Double_t)posClus[2],
624 (Double_t)(fTofClusters[ii]->GetSigmaX2()),
625 (Double_t)(fTofClusters[ii]->GetSigmaXY()),
626 (Double_t)(fTofClusters[ii]->GetSigmaXZ()),
627 (Double_t)(fTofClusters[ii]->GetSigmaY2()),
628 (Double_t)(fTofClusters[ii]->GetSigmaYZ()),
629 (Double_t)(fTofClusters[ii]->GetSigmaZ2()),
630 //(Double_t)covClus[0], (Double_t)covClus[1], (Double_t)covClus[2],
631 //(Double_t)covClus[3], (Double_t)covClus[4], (Double_t)covClus[5],
632 trackLabels, detectorIndex, parTOF, status, digitIndex);
634 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",
635 ii, volIdClus, posClus[0], posClus[1], posClus[2],
636 fTofClusters[ii]->GetSigmaX2(),
637 fTofClusters[ii]->GetSigmaXY(),
638 fTofClusters[ii]->GetSigmaXZ(),
639 fTofClusters[ii]->GetSigmaY2(),
640 fTofClusters[ii]->GetSigmaYZ(),
641 fTofClusters[ii]->GetSigmaZ2(),
642 trackLabels[0], trackLabels[1], trackLabels[2],
643 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[3], detectorIndex[4],
644 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
645 status, digitIndex));
650 for (Int_t iSector=0; iSector<AliTOFGeometry::NSectors(); iSector++)
651 for(Int_t iPlate=0; iPlate<AliTOFGeometry::NPlates(); iPlate++) {
652 for(Int_t iStrip=0; iStrip<AliTOFGeometry::NStrip(iPlate); iStrip++) {
653 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
654 AliDebug(2, Form(" END %2d %1d %2d %5d",
655 iSector, iPlate, iStrip, fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip)));
660 //_____________________________________________________________________________
662 void AliTOFClusterFinderV1::FindOnePadClusterPerStrip(Int_t nSector,
667 // This function searches the isolated digits (stored in the fDigits object),
668 // to perform clusters (stored in the fTofClusters array).
669 // This research has been made by checking the fTOFdigitMap object,
670 // filled at digits/raw-data reading time.
673 const Int_t kMaxNumberOfTracksPerDigit = 3;
674 const Int_t kMaxNumberOfDigitsPerVolume = 10;
678 Int_t det[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padZ,padX
679 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padX,padZ
680 UShort_t volIdClus = 0;
683 for (jj=0; jj<3; jj++) pos[jj] = 0.;
685 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
688 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
691 for (jj=0; jj<5; jj++) parTOF[jj] = 0;
693 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
695 Int_t tracks[kMaxNumberOfTracksPerDigit];
696 for (jj=0; jj<3; jj++) tracks[jj] = -1;
698 Int_t dummyCounter=-1;
700 AliTOFdigit *digitInteresting;
704 for (iPadX=0; iPadX<AliTOFGeometry::NpadX(); iPadX++) {
705 for (iPadZ=0; iPadZ<AliTOFGeometry::NpadZ(); iPadZ++) {
706 vol[4] = iPadZ , vol[3] = iPadX;
708 AliDebug(3, Form(" %1d %2d\n", iPadZ, iPadX));
710 if (fTOFdigitMap->GetNumberOfDigits(vol)==0) continue;
712 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
713 if (fTOFdigitMap->GetDigitIndex(vol,digIndex)<0) continue;
714 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(fTOFdigitMap->GetDigitIndex(vol,digIndex));
716 AliDebug(2, Form(" %3d %5d %2d %1d %2d %1d %2d %d %d %d %5d %5d %5d %5d",
717 fTOFdigitMap->GetNumberOfDigits(vol), digIndex,
718 vol[0], vol[1], vol[2] ,vol[4], vol[3],
719 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
720 digitInteresting->GetToT(),
721 fTOFdigitMap->GetDigitIndex(vol,digIndex),
722 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
724 det[3] = vol[4]; // padz
725 det[4] = vol[3]; // padx
726 fTOFGeometry->GetPosPar(det,pos);
727 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
730 for (jj=0; jj<3; jj++) posClus[jj] = pos[jj];
732 parTOF[0] = Int_t(digitInteresting->GetTdc());
733 parTOF[1] = Int_t(digitInteresting->GetToT());
734 parTOF[2] = Int_t(digitInteresting->GetAdc());
735 parTOF[3] = Int_t(digitInteresting->GetTdcND());
736 parTOF[4] = Int_t(digitInteresting->GetTdc());
738 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
739 //volIdClus = GetClusterVolIndex(det);
741 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
742 GetClusterPars(det, posClus, covClus);
744 // To fill the track index array
746 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
747 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) { // three is the max number of tracks associated to one digit
748 if (digitInteresting->GetTrack(jj)==-1) continue;
751 tracks[dummyCounter] = digitInteresting->GetTrack(jj);
755 AliTOFcluster *tofCluster =
756 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
757 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
758 tracks, det, parTOF, status, fTOFdigitMap->GetDigitIndex(vol,digIndex));
759 InsertCluster(tofCluster);
761 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",
762 volIdClus, posClus[0], posClus[1], posClus[2],
763 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
764 tracks[0], tracks[1], tracks[2],
765 det[0], det[1], det[2], det[3], det[4],
766 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
767 status, fTOFdigitMap->GetDigitIndex(vol,digIndex)));
769 AliDebug(2, Form(" %f %f %f", pos[0], pos[1], pos[2]));
770 AliDebug(2, Form(" %d %d", parTOF[0], parTOF[2]));
772 fTOFdigitMap->ResetDigit(vol, digIndex);
780 //_____________________________________________________________________________
782 void AliTOFClusterFinderV1::FindClustersWithoutTOT(Int_t nSector,
787 // This function searches the isolated digits without TOT
788 // measurement (stored in the fDigits object), to perform clusters
789 // (stored in the fTofClusters array). This research has been made
790 // by checking the fTOFdigitMap object, filled at digits/raw-data
794 const Int_t kMaxNumberOfTracksPerDigit = 3;
795 const Int_t kMaxNumberOfDigitsPerVolume = 10;
799 Int_t det[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padZ,padX
800 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padX,padZ
801 UShort_t volIdClus = 0;
804 for (jj=0; jj<3; jj++) pos[jj] = 0.;
806 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
809 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
812 for (jj=0; jj<5; jj++) parTOF[jj] = 0;
814 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
815 Int_t tracks[kMaxNumberOfTracksPerDigit];
816 for (jj=0; jj<3; jj++) tracks[jj] = -1;
818 Int_t dummyCounter=-1;
820 AliTOFdigit *digitInteresting;
824 for (iPadX=0; iPadX<AliTOFGeometry::NpadX(); iPadX++) {
825 for (iPadZ=0; iPadZ<AliTOFGeometry::NpadZ(); iPadZ++) {
826 vol[4] = iPadZ , vol[3] = iPadX;
828 AliDebug(3, Form(" %1d %2d\n", iPadZ, iPadX));
830 if (fTOFdigitMap->GetNumberOfDigits(vol)==0) continue;
832 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
833 if (fTOFdigitMap->GetDigitIndex(vol,digIndex)<0) continue;
834 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(fTOFdigitMap->GetDigitIndex(vol,digIndex));
835 if (digitInteresting->GetToT()>0) continue; // AdC
837 AliDebug(2, Form(" %3d %5d %2d %1d %2d %1d %2d %d %d %d %5d %5d %5d %5d",
838 fTOFdigitMap->GetNumberOfDigits(vol), digIndex,
839 vol[0], vol[1], vol[2] ,vol[4], vol[3],
840 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
841 digitInteresting->GetToT(),
842 fTOFdigitMap->GetDigitIndex(vol,digIndex),
843 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
845 det[3] = vol[4]; // padz
846 det[4] = vol[3]; // padx
847 fTOFGeometry->GetPosPar(det,pos);
848 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
851 for (jj=0; jj<3; jj++) posClus[jj] = pos[jj];
853 parTOF[0] = Int_t(digitInteresting->GetTdc());
854 parTOF[1] = Int_t(digitInteresting->GetToT());
855 parTOF[2] = Int_t(digitInteresting->GetAdc());
856 parTOF[3] = Int_t(digitInteresting->GetTdcND());
857 parTOF[4] = Int_t(digitInteresting->GetTdc());
859 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
860 //volIdClus = GetClusterVolIndex(det);
862 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
863 GetClusterPars(det, posClus, covClus);
865 // To fill the track index array
867 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
868 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) { // three is the max number of tracks associated to one digit
869 if (digitInteresting->GetTrack(jj)==-1) continue;
872 tracks[dummyCounter] = digitInteresting->GetTrack(jj);
876 AliTOFcluster *tofCluster =
877 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
878 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
879 tracks, det, parTOF, status, fTOFdigitMap->GetDigitIndex(vol,digIndex));
880 InsertCluster(tofCluster);
882 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",
883 volIdClus, posClus[0], posClus[1], posClus[2],
884 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
885 tracks[0], tracks[1], tracks[2],
886 det[0], det[1], det[2], det[3], det[4],
887 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
888 status, fTOFdigitMap->GetDigitIndex(vol,digIndex)));
890 AliDebug(2, Form(" %f %f %f", pos[0], pos[1], pos[2]));
891 AliDebug(2, Form(" %d %d", parTOF[0], parTOF[2]));
893 fTOFdigitMap->ResetDigit(vol, digIndex);
901 //_____________________________________________________________________________
903 void AliTOFClusterFinderV1::FindClusters34(Int_t nSector,
908 // This function searches the neighbouring digits (stored in the fDigits object),
909 // to perform clusters (stored in the fTofClusters array).
911 // This research has been made by checking the fTOFdigitMap object,
912 // filled at digits/raw-data reading time.
915 const Int_t kMaxNumberOfInterestingPads = 4;
916 const Int_t kMaxNumberOfTracksPerDigit = 3;
917 const Int_t kMaxNumberOfDigitsPerVolume = 10;
921 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
922 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
923 digitsInVolumeIndices[ii] = -1;
925 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
927 Float_t pos[3] = {0.,0.,0.};
930 Int_t interestingPadX[kMaxNumberOfInterestingPads];
931 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
932 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
933 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
934 Double_t interestingTOT[kMaxNumberOfInterestingPads];
935 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
936 Double_t interestingADC[kMaxNumberOfInterestingPads];
937 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
938 Double_t interestingTOF[kMaxNumberOfInterestingPads];
939 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
940 Double_t interestingWeight[kMaxNumberOfInterestingPads];
941 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
943 Float_t interestingX[kMaxNumberOfInterestingPads];
944 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
945 Float_t interestingY[kMaxNumberOfInterestingPads];
946 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
947 Float_t interestingZ[kMaxNumberOfInterestingPads];
948 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
950 Float_t interDigit[kMaxNumberOfInterestingPads];
951 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
953 Int_t padsCluster[11];
954 padsCluster[0] = nSector;
955 padsCluster[1] = nPlate;
956 padsCluster[2] = nStrip;
957 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
959 Int_t interestingCounter=-1;
960 Int_t digitIndexLocal=-1; // AdC
966 for (jj=0; jj<5; jj++) parTOF[jj] = 0;
968 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
970 for (jj=0; jj<5; jj++) det[jj] = -1;
972 for (jj=0; jj<3; jj++) posF[jj] = 0.;
973 UShort_t volIdClus = 0;
974 Bool_t check = kFALSE;
975 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
977 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
978 Int_t tracks[kMaxNumberOfTracksPerDigit];
979 for (jj=0; jj<3; jj++) tracks[jj] = -1;
980 Int_t dummyCounter=-1;
981 Bool_t alreadyStored = kFALSE;
983 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
984 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
985 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
987 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
988 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
990 AliTOFdigit *digitInteresting;
992 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
994 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
995 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
997 AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
1004 interestingCounter=-1;
1006 vol[4] = iPadZ , vol[3] = iPadX;
1007 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1008 interestingCounter++;
1010 vol[4] = iPadZ, vol[3] = iPadX+1;
1011 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1012 interestingCounter++;
1014 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1015 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1016 interestingCounter++;
1018 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1019 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1020 interestingCounter++;
1022 if (interestingCounter+1!=4) continue; // the hit pads have to be 4
1023 else interestingCounter=-1;
1026 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1027 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1028 selectedDigit[ii][jj] = 0x0;
1031 vol[4] = iPadZ, vol[3] = iPadX;
1033 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1034 interestingCounter++;
1035 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1036 digitsInVolumeIndices[ii] = -1;
1037 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1038 digitIndexLocal=-1; // AdC
1039 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1040 if (digitsInVolumeIndices[digIndex]<0) continue;
1041 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1042 if (digitInteresting->GetToT()<=0) continue; // AdC
1043 digitIndexLocal++; // AdC
1045 AliDebug(1,Form(" %2d %1d %2d %1d %2d %f %f %f %f %5d %5d %5d %5d",
1046 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1047 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1048 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1049 digitsInVolumeIndices[digIndex],
1050 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1053 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1054 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1055 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1056 digitInteresting->GetToT()*digitInteresting->GetToT(),
1057 digitsInVolumeIndices[digIndex],
1058 digitInteresting->GetTracks());
1060 if (digitIndexLocal==-1) interestingCounter--; // AdC
1064 vol[4] = iPadZ, vol[3] = iPadX+1;
1066 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1067 interestingCounter++;
1068 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1069 digitsInVolumeIndices[ii] = -1;
1070 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1071 digitIndexLocal=-1; // AdC
1072 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1073 if (digitsInVolumeIndices[digIndex]<0) continue;
1074 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1075 if (digitInteresting->GetToT()<=0) continue; // AdC
1076 digitIndexLocal++; // AdC
1078 AliDebug(1,Form(" %2d %1d %2d %1d %2d %f %f %f %f %5d %5d %5d %5d",
1079 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1080 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1081 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1082 digitsInVolumeIndices[digIndex],
1083 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1086 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1087 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1088 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1089 digitInteresting->GetToT()*digitInteresting->GetToT(),
1090 digitsInVolumeIndices[digIndex],
1091 digitInteresting->GetTracks());
1093 if (digitIndexLocal==-1) interestingCounter--; // AdC
1097 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1099 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1100 interestingCounter++;
1101 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1102 digitsInVolumeIndices[ii] = -1;
1103 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1104 digitIndexLocal=-1; // AdC
1105 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1106 if (digitsInVolumeIndices[digIndex]<0) continue;
1107 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1108 if (digitInteresting->GetToT()<=0) continue; // AdC
1109 digitIndexLocal++; // AdC
1111 AliDebug(1,Form(" %2d %1d %2d %1d %2d %f %f %f %f %5d %5d %5d %5d",
1112 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1113 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1114 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1115 digitsInVolumeIndices[digIndex],
1116 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1119 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1120 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1121 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1122 digitInteresting->GetToT()*digitInteresting->GetToT(),
1123 digitsInVolumeIndices[digIndex],
1124 digitInteresting->GetTracks());
1126 if (digitIndexLocal==-1) interestingCounter--; // AdC
1130 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1132 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1133 interestingCounter++;
1134 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1135 digitsInVolumeIndices[ii] = -1;
1136 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1138 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1139 if (digitsInVolumeIndices[digIndex]<0) continue;
1140 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1141 if (digitInteresting->GetToT()<=0) continue; // AdC
1142 digitIndexLocal++; // AdC
1144 AliDebug(1,Form(" %2d %1d %2d %1d %2d %f %f %f %f %5d %5d %5d %5d",
1145 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1146 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1147 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1148 digitsInVolumeIndices[digIndex],
1149 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1151 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1152 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1153 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1154 digitInteresting->GetToT()*digitInteresting->GetToT(),
1155 digitsInVolumeIndices[digIndex],
1156 digitInteresting->GetTracks());
1158 if (digitIndexLocal==-1) interestingCounter--; // AdC
1161 AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
1163 for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
1164 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
1165 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
1167 for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
1168 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
1169 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
1171 for (Int_t adesso3=adesso2+1; adesso3<interestingCounter+1; adesso3++) {
1172 for (Int_t thirdIndex=0; thirdIndex<kMaxNumberOfDigitsPerVolume; thirdIndex++) {
1173 if (selectedDigit[adesso3][thirdIndex]==0x0) continue;
1176 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime
1178 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
1180 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime) continue;
1182 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
1183 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
1184 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
1185 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
1186 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
1187 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
1188 Int_t volDum = vol1[3];
1191 fTOFGeometry->GetPosPar(vol1,pos);
1192 interestingX[0] = pos[0];
1193 interestingY[0] = pos[1];
1194 interestingZ[0] = pos[2];
1196 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
1197 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
1198 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
1199 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
1200 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
1201 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
1205 fTOFGeometry->GetPosPar(vol2,pos);
1206 interestingX[1] = pos[0];
1207 interestingY[1] = pos[1];
1208 interestingZ[1] = pos[2];
1210 interestingTOF[2] = selectedDigit[adesso3][thirdIndex]->GetTDC();
1211 interestingTOT[2] = selectedDigit[adesso3][thirdIndex]->GetTOT();
1212 interestingADC[2] = selectedDigit[adesso3][thirdIndex]->GetADC();
1213 interestingWeight[2] = selectedDigit[adesso3][thirdIndex]->GetWeight();
1214 Int_t vol3[5]; for(jj=0; jj<5; jj++) vol3[jj] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(jj);
1215 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol3[0], vol3[1], vol3[2], vol3[4], vol3[3]));
1219 fTOFGeometry->GetPosPar(vol3,pos);
1220 interestingX[2] = pos[0];
1221 interestingY[2] = pos[1];
1222 interestingZ[2] = pos[2];
1225 AverageCalculations(3, interestingX, interestingY, interestingZ,
1226 interestingTOF, interestingTOT, interestingADC,
1228 parTOF, posClus, check);
1231 for (jj=0; jj<5; jj++) det[jj] = -1;
1232 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
1233 fTOFGeometry->GetDetID(posF, det);
1235 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
1236 //volIdClus = GetClusterVolIndex(det);
1238 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1239 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
1240 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
1241 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
1242 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
1243 padsCluster[7] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(4);
1244 padsCluster[8] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(3);
1246 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1247 Int_t ** indDet = new Int_t*[3];
1248 for (jj=0; jj<3; jj++) indDet[jj] = new Int_t [5];
1249 for (jj=0; jj<3; jj++) indDet[jj][0] = nSector;
1250 for (jj=0; jj<3; jj++) indDet[jj][1] = nPlate;
1251 for (jj=0; jj<3; jj++) indDet[jj][2] = nStrip;
1252 for (jj=0; jj<3; jj++) indDet[jj][3] = padsCluster[2*jj+3];
1253 for (jj=0; jj<3; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
1254 GetClusterPars(/*check,*/ 3, indDet, interestingWeight, posClus, covClus);
1255 for (jj=0; jj<3; jj++) delete [] indDet[jj];
1257 // To fill the track index array
1259 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1260 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1261 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
1264 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
1267 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1268 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
1271 alreadyStored = kFALSE;
1272 for (jj=0; jj<dummyCounter+1; jj++)
1273 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
1275 if (alreadyStored) continue;
1276 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
1277 AliWarning(" Siamo al limite!");
1282 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
1287 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1288 if (selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk)==-1) continue;
1291 alreadyStored = kFALSE;
1292 for (jj=0; jj<dummyCounter+1; jj++)
1293 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk));
1295 if (alreadyStored) continue;
1296 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
1297 AliWarning(" Siamo al limite!");
1302 tracks[dummyCounter] = selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk);
1309 AliTOFcluster *tofCluster =
1310 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
1311 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1312 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
1313 InsertCluster(tofCluster);
1315 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",
1316 volIdClus, posClus[0], posClus[1], posClus[2],
1317 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1318 tracks[0], tracks[1], tracks[2],
1319 det[0], det[1], det[2], det[3], det[4],
1320 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
1321 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
1327 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
1331 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
1335 fTOFdigitMap->ResetDigitNumber(vol3,selectedDigit[adesso3][thirdIndex]->GetIndex());
1338 } // close loop on third digit
1339 } // close loop on adesso3
1341 } // close loop on second digit
1342 } // close loop on adesso2
1344 } // close loop on first digit
1345 } // close loop on adesso1
1347 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1348 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1349 selectedDigit[ii][jj] = 0x0;
1353 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1354 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
1355 delete selectedDigit[ii][jj];
1356 selectedDigit[ii][jj] = 0x0;
1361 //_____________________________________________________________________________
1363 void AliTOFClusterFinderV1::FindClusters23(Int_t nSector,
1368 // This function searches the neighbouring digits (stored in the fDigits object),
1369 // to perform clusters (stored in the fTofClusters array).
1371 // This research has been made by checking the fTOFdigitMap object,
1372 // filled at digits/raw-data reading time.
1375 const Int_t kMaxNumberOfInterestingPads = 4;
1376 const Int_t kMaxNumberOfTracksPerDigit = 3;
1377 const Int_t kMaxNumberOfDigitsPerVolume = 10;
1381 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
1382 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1383 digitsInVolumeIndices[ii] = -1;
1385 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
1387 Float_t pos[3] = {0.,0.,0.};
1390 Int_t interestingPadX[kMaxNumberOfInterestingPads];
1391 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
1392 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
1393 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
1394 Double_t interestingTOT[kMaxNumberOfInterestingPads];
1395 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
1396 Double_t interestingADC[kMaxNumberOfInterestingPads];
1397 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
1398 Double_t interestingTOF[kMaxNumberOfInterestingPads];
1399 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
1400 Double_t interestingWeight[kMaxNumberOfInterestingPads];
1401 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
1403 Float_t interestingX[kMaxNumberOfInterestingPads];
1404 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
1405 Float_t interestingY[kMaxNumberOfInterestingPads];
1406 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
1407 Float_t interestingZ[kMaxNumberOfInterestingPads];
1408 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
1410 Float_t interDigit[kMaxNumberOfInterestingPads];
1411 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
1413 Int_t padsCluster[11];
1414 padsCluster[0] = nSector;
1415 padsCluster[1] = nPlate;
1416 padsCluster[2] = nStrip;
1417 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1419 Int_t interestingCounter=-1;
1420 Int_t digitIndexLocal = -1;
1425 Bool_t check = kFALSE;
1427 for (jj=0; jj<5; jj++) parTOF[jj] = 0;
1428 Double_t posClus[3];
1429 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
1431 for (jj=0; jj<5; jj++) det[jj] = -1;
1433 for (jj=0; jj<3; jj++) posF[jj] = 0.;
1434 UShort_t volIdClus = 0;
1435 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
1436 Double_t covClus[6];
1437 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1438 Int_t tracks[kMaxNumberOfTracksPerDigit];
1439 for (jj=0; jj<3; jj++) tracks[jj] = -1;
1440 Int_t dummyCounter=-1;
1441 Bool_t alreadyStored = kFALSE;
1443 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
1444 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1445 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
1447 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1448 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
1450 AliTOFdigit *digitInteresting;
1452 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
1454 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
1455 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
1457 AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
1464 interestingCounter=-1;
1466 vol[4] = iPadZ , vol[3] = iPadX;
1467 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1468 interestingCounter++;
1470 vol[4] = iPadZ, vol[3] = iPadX+1;
1471 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1472 interestingCounter++;
1474 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1475 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1476 interestingCounter++;
1478 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1479 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1480 interestingCounter++;
1482 if (interestingCounter+1!=3) continue; // the hit pads have to be 3
1483 else interestingCounter=-1;
1486 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1487 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1488 selectedDigit[ii][jj] = 0x0;
1491 vol[4] = iPadZ, vol[3] = iPadX;
1493 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1494 interestingCounter++;
1495 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1496 digitsInVolumeIndices[ii] = -1;
1497 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1499 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1500 if (digitsInVolumeIndices[digIndex]<0) continue;
1501 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1502 if (digitInteresting->GetToT()<=0) continue; // AdC
1503 digitIndexLocal++; // AdC
1505 AliDebug(1,Form(" %2d %1d %2d %1d %2d %f %f %f %f %5d %5d %5d %5d",
1506 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1507 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1508 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1509 digitsInVolumeIndices[digIndex],
1510 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1512 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1513 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1514 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1515 digitInteresting->GetToT()*digitInteresting->GetToT(),
1516 digitsInVolumeIndices[digIndex],
1517 digitInteresting->GetTracks());
1519 if (digitIndexLocal==-1) interestingCounter--; // AdC
1523 vol[4] = iPadZ, vol[3] = iPadX+1;
1525 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1526 interestingCounter++;
1527 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1528 digitsInVolumeIndices[ii] = -1;
1529 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1530 digitIndexLocal=-1; // AdC
1531 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1532 if (digitsInVolumeIndices[digIndex]<0) continue;
1533 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1534 if (digitInteresting->GetToT()<=0) continue; // AdC
1535 digitIndexLocal++; // AdC
1537 AliDebug(1,Form(" %2d %1d %2d %1d %2d %f %f %f %f %5d %5d %5d %5d",
1538 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1539 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1540 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1541 digitsInVolumeIndices[digIndex],
1542 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1544 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1545 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1546 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1547 digitInteresting->GetToT()*digitInteresting->GetToT(),
1548 digitsInVolumeIndices[digIndex],
1549 digitInteresting->GetTracks());
1551 if (digitIndexLocal==-1) interestingCounter--; // AdC
1555 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1557 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1558 interestingCounter++;
1559 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1560 digitsInVolumeIndices[ii] = -1;
1561 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1562 digitIndexLocal=-1; // AdC
1563 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1564 if (digitsInVolumeIndices[digIndex]<0) continue;
1565 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1566 if (digitInteresting->GetToT()<=0) continue; // AdC
1567 digitIndexLocal++; // AdC
1569 AliDebug(1,Form(" %2d %1d %2d %1d %2d %f %f %f %f %5d %5d %5d %5d",
1570 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1571 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1572 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1573 digitsInVolumeIndices[digIndex],
1574 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1576 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1577 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1578 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1579 digitInteresting->GetToT()*digitInteresting->GetToT(),
1580 digitsInVolumeIndices[digIndex],
1581 digitInteresting->GetTracks());
1583 if (digitIndexLocal==-1) interestingCounter--; // AdC
1587 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1589 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1590 interestingCounter++;
1591 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1592 digitsInVolumeIndices[ii] = -1;
1593 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1594 digitIndexLocal=-1; // AdC
1595 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1596 if (digitsInVolumeIndices[digIndex]<0) continue;
1597 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1598 if (digitInteresting->GetToT()<=0) continue; // AdC
1599 digitIndexLocal++; // AdC
1601 AliDebug(1,Form(" %2d %1d %2d %1d %2d %f %f %f %f %5d %5d %5d %5d",
1602 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1603 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1604 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1605 digitsInVolumeIndices[digIndex],
1606 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1608 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1609 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1610 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1611 digitInteresting->GetToT()*digitInteresting->GetToT(),
1612 digitsInVolumeIndices[digIndex],
1613 digitInteresting->GetTracks());
1615 if (digitIndexLocal==-1) interestingCounter--; // AdC
1618 AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
1620 for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
1621 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
1622 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
1624 for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
1625 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
1626 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
1628 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime) continue;
1630 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
1631 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
1632 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
1633 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
1634 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
1635 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
1636 Int_t volDum = vol1[3];
1639 fTOFGeometry->GetPosPar(vol1,pos);
1640 interestingX[0] = pos[0];
1641 interestingY[0] = pos[1];
1642 interestingZ[0] = pos[2];
1644 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
1645 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
1646 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
1647 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
1648 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
1649 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
1653 fTOFGeometry->GetPosPar(vol2,pos);
1654 interestingX[1] = pos[0];
1655 interestingY[1] = pos[1];
1656 interestingZ[1] = pos[2];
1658 AverageCalculations(2, interestingX, interestingY, interestingZ,
1659 interestingTOF, interestingTOT, interestingADC,
1661 parTOF, posClus, check);
1663 for (jj=0; jj<5; jj++) det[jj] = -1;
1664 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
1665 fTOFGeometry->GetDetID(posF, det);
1667 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
1668 //volIdClus = GetClusterVolIndex(det);
1670 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1671 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
1672 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
1673 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
1674 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
1676 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1677 Int_t ** indDet = new Int_t*[2];
1678 for (jj=0; jj<2; jj++) indDet[jj] = new Int_t [5];
1679 for (jj=0; jj<2; jj++) indDet[jj][0] = nSector;
1680 for (jj=0; jj<2; jj++) indDet[jj][1] = nPlate;
1681 for (jj=0; jj<2; jj++) indDet[jj][2] = nStrip;
1682 for (jj=0; jj<2; jj++) indDet[jj][3] = padsCluster[2*jj+3];
1683 for (jj=0; jj<2; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
1684 GetClusterPars(/*check,*/ 2, indDet, interestingWeight, posClus, covClus);
1685 for (jj=0; jj<2; jj++) delete [] indDet[jj];
1687 // To fill the track index array
1689 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1690 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1691 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
1694 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
1697 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1698 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
1701 alreadyStored = kFALSE;
1702 for (jj=0; jj<dummyCounter+1; jj++)
1703 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
1705 if (alreadyStored) continue;
1706 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
1707 AliWarning(" Siamo al limite!");
1712 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
1719 AliTOFcluster *tofCluster =
1720 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
1721 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1722 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
1723 InsertCluster(tofCluster);
1725 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",
1726 volIdClus, posClus[0], posClus[1], posClus[2],
1727 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1728 tracks[0], tracks[1], tracks[2],
1729 det[0], det[1], det[2], det[3], det[4],
1730 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
1731 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
1736 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
1740 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
1743 } // close loop on second digit
1744 } // close loop on adesso2
1746 } // close loop on first digit
1747 } // close loop on adesso1
1749 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1750 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1751 selectedDigit[ii][jj] = 0x0;
1755 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1756 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
1757 delete selectedDigit[ii][jj];
1758 selectedDigit[ii][jj] = 0x0;
1763 //_____________________________________________________________________________
1765 void AliTOFClusterFinderV1::FindClusters24(Int_t nSector,
1770 // This function searches the neighbouring digits (stored in the fDigits object),
1771 // to perform clusters (stored in the fTofClusters array).
1773 // This research has been made by checking the fTOFdigitMap object,
1774 // filled at digits/raw-data reading time.
1777 const Int_t kMaxNumberOfInterestingPads = 4;
1778 const Int_t kMaxNumberOfTracksPerDigit = 3;
1779 const Int_t kMaxNumberOfDigitsPerVolume = 10;
1783 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
1784 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1785 digitsInVolumeIndices[ii] = -1;
1787 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
1789 Float_t pos[3] = {0.,0.,0.};
1792 Int_t interestingPadX[kMaxNumberOfInterestingPads];
1793 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
1794 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
1795 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
1796 Double_t interestingTOT[kMaxNumberOfInterestingPads];
1797 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
1798 Double_t interestingADC[kMaxNumberOfInterestingPads];
1799 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
1800 Double_t interestingTOF[kMaxNumberOfInterestingPads];
1801 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
1802 Double_t interestingWeight[kMaxNumberOfInterestingPads];
1803 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
1805 Float_t interestingX[kMaxNumberOfInterestingPads];
1806 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
1807 Float_t interestingY[kMaxNumberOfInterestingPads];
1808 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
1809 Float_t interestingZ[kMaxNumberOfInterestingPads];
1810 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
1812 Float_t interDigit[kMaxNumberOfInterestingPads];
1813 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
1815 Int_t padsCluster[11];
1816 padsCluster[0] = nSector;
1817 padsCluster[1] = nPlate;
1818 padsCluster[2] = nStrip;
1819 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1821 Int_t interestingCounter=-1;
1822 Int_t digitIndexLocal = -1;
1827 Bool_t check = kFALSE;
1829 for (jj=0; jj<5; jj++) parTOF[jj] = 0;
1830 Double_t posClus[3];
1831 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
1833 for (jj=0; jj<5; jj++) det[jj] = -1;
1835 for (jj=0; jj<3; jj++) posF[jj] = 0.;
1836 UShort_t volIdClus = 0;
1837 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
1838 Double_t covClus[6];
1839 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1840 Int_t tracks[kMaxNumberOfTracksPerDigit];
1841 for (jj=0; jj<3; jj++) tracks[jj] = -1;
1842 Int_t dummyCounter=-1;
1843 Bool_t alreadyStored = kFALSE;
1845 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
1846 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1847 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
1849 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1850 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
1852 AliTOFdigit *digitInteresting;
1854 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
1856 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
1857 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
1859 AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
1866 interestingCounter=-1;
1868 vol[4] = iPadZ , vol[3] = iPadX;
1869 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1870 interestingCounter++;
1872 vol[4] = iPadZ, vol[3] = iPadX+1;
1873 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1874 interestingCounter++;
1876 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1877 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1878 interestingCounter++;
1880 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1881 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1882 interestingCounter++;
1884 if (interestingCounter+1!=4) continue; // the hit pads have to be 4
1885 else interestingCounter=-1;
1888 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1889 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1890 selectedDigit[ii][jj] = 0x0;
1893 vol[4] = iPadZ, vol[3] = iPadX;
1895 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1896 interestingCounter++;
1897 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1898 digitsInVolumeIndices[ii] = -1;
1899 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1900 digitIndexLocal=-1; // AdC
1901 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1902 if (digitsInVolumeIndices[digIndex]<0) continue;
1903 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1904 if (digitInteresting->GetToT()<=0) continue; // AdC
1905 digitIndexLocal++; // AdC
1907 AliDebug(1,Form(" %2d %1d %2d %1d %2d %f %f %f %f %5d %5d %5d %5d",
1908 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1909 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1910 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1911 digitsInVolumeIndices[digIndex],
1912 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1914 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1915 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1916 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1917 digitInteresting->GetToT()*digitInteresting->GetToT(),
1918 digitsInVolumeIndices[digIndex],
1919 digitInteresting->GetTracks());
1921 if (digitIndexLocal==-1) interestingCounter--; // AdC
1925 vol[4] = iPadZ, vol[3] = iPadX+1;
1927 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1928 interestingCounter++;
1929 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1930 digitsInVolumeIndices[ii] = -1;
1931 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1932 digitIndexLocal=-1; // AdC
1933 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1934 if (digitsInVolumeIndices[digIndex]<0) continue;
1935 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1936 if (digitInteresting->GetToT()<=0) continue; // AdC
1937 digitIndexLocal++; // AdC
1939 AliDebug(1,Form(" %2d %1d %2d %1d %2d %f %f %f %f %5d %5d %5d %5d",
1940 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1941 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1942 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1943 digitsInVolumeIndices[digIndex],
1944 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1946 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1947 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1948 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1949 digitInteresting->GetToT()*digitInteresting->GetToT(),
1950 digitsInVolumeIndices[digIndex],
1951 digitInteresting->GetTracks());
1953 if (digitIndexLocal==-1) interestingCounter--; // AdC
1957 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1959 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1960 interestingCounter++;
1961 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1962 digitsInVolumeIndices[ii] = -1;
1963 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1964 digitIndexLocal=-1; // AdC
1965 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1966 if (digitsInVolumeIndices[digIndex]<0) continue;
1967 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1968 if (digitInteresting->GetToT()<=0) continue; // AdC
1969 digitIndexLocal++; // AdC
1971 AliDebug(1,Form(" %2d %1d %2d %1d %2d %f %f %f %f %5d %5d %5d %5d",
1972 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1973 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1974 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1975 digitsInVolumeIndices[digIndex],
1976 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1978 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1979 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1980 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1981 digitInteresting->GetToT()*digitInteresting->GetToT(),
1982 digitsInVolumeIndices[digIndex],
1983 digitInteresting->GetTracks());
1985 if (digitIndexLocal==-1) interestingCounter--; // AdC
1989 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1991 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1992 interestingCounter++;
1993 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1994 digitsInVolumeIndices[ii] = -1;
1995 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1996 digitIndexLocal=-1; // AdC
1997 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1998 if (digitsInVolumeIndices[digIndex]<0) continue;
1999 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2000 if (digitInteresting->GetToT()<=0) continue; // AdC
2001 digitIndexLocal++; // AdC
2003 AliDebug(1,Form(" %2d %1d %2d %1d %2d %f %f %f %f %5d %5d %5d %5d",
2004 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2005 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2006 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2007 digitsInVolumeIndices[digIndex],
2008 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2010 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2011 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2012 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2013 digitInteresting->GetToT()*digitInteresting->GetToT(),
2014 digitsInVolumeIndices[digIndex],
2015 digitInteresting->GetTracks());
2017 if (digitIndexLocal==-1) interestingCounter--; // AdC
2020 AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
2022 for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
2023 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2024 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2026 for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
2027 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2028 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2030 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime) continue;
2032 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2033 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2034 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2035 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2036 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
2037 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
2038 Int_t volDum = vol1[3];
2041 fTOFGeometry->GetPosPar(vol1,pos);
2042 interestingX[0] = pos[0];
2043 interestingY[0] = pos[1];
2044 interestingZ[0] = pos[2];
2046 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2047 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2048 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2049 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2050 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
2051 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
2055 fTOFGeometry->GetPosPar(vol2,pos);
2056 interestingX[1] = pos[0];
2057 interestingY[1] = pos[1];
2058 interestingZ[1] = pos[2];
2061 AverageCalculations(2, interestingX, interestingY, interestingZ,
2062 interestingTOF, interestingTOT, interestingADC,
2064 parTOF, posClus, check);
2066 for (jj=0; jj<5; jj++) det[jj] = -1;
2067 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
2068 fTOFGeometry->GetDetID(posF, det);
2070 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
2071 //volIdClus = GetClusterVolIndex(det);
2073 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2074 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
2075 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
2076 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
2077 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
2079 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2080 Int_t ** indDet = new Int_t*[2];
2081 for (jj=0; jj<2; jj++) indDet[jj] = new Int_t [5];
2082 for (jj=0; jj<2; jj++) indDet[jj][0] = nSector;
2083 for (jj=0; jj<2; jj++) indDet[jj][1] = nPlate;
2084 for (jj=0; jj<2; jj++) indDet[jj][2] = nStrip;
2085 for (jj=0; jj<2; jj++) indDet[jj][3] = padsCluster[2*jj+3];
2086 for (jj=0; jj<2; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
2087 GetClusterPars(/*check,*/ 2, indDet, interestingWeight, posClus, covClus);
2088 for (jj=0; jj<2; jj++) delete [] indDet[jj];
2090 // To fill the track index array
2092 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2093 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2094 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
2097 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
2100 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2101 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
2104 alreadyStored = kFALSE;
2105 for (jj=0; jj<dummyCounter+1; jj++)
2106 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
2108 if (alreadyStored) continue;
2109 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2110 AliWarning(" Siamo al limite!");
2115 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
2122 AliTOFcluster *tofCluster =
2123 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
2124 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2125 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
2126 InsertCluster(tofCluster);
2128 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",
2129 volIdClus, posClus[0], posClus[1], posClus[2],
2130 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2131 tracks[0], tracks[1], tracks[2],
2132 det[0], det[1], det[2], det[3], det[4],
2133 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
2134 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
2139 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
2143 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
2146 } // close loop on second digit
2147 } // close loop on adesso2
2149 } // close loop on first digit
2150 } // close loop on adesso1
2152 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2153 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
2154 selectedDigit[ii][jj] = 0x0;
2158 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2159 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
2160 delete selectedDigit[ii][jj];
2161 selectedDigit[ii][jj] = 0x0;
2166 //_____________________________________________________________________________
2168 void AliTOFClusterFinderV1::FindClustersPerStrip(Int_t nSector,
2174 // This function searches the neighbouring digits (stored in the fDigits object),
2175 // to perform clusters (stored in the fTofClusters array).
2177 // Each strip is read four times:
2178 // - 1st time: it searches possible clusters formed by four
2179 // neighbouring digits;
2180 // - 2nd time: it searches possible clusters formed by three
2181 // neighbouring digits;
2182 // - 3rd time: it searches possible clusters formed by two
2183 // neighbouring digits;
2184 // - 4th time: the remaining isolated digits have been transformed
2186 // This research has been made by checking the fTOFdigitMap object,
2187 // filled at digits/raw-data reading time.
2190 const Int_t kMaxNumberOfInterestingPads = 4;
2191 const Int_t kMaxNumberOfTracksPerDigit = 3;
2192 const Int_t kMaxNumberOfDigitsPerVolume = 10;
2196 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
2197 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2198 digitsInVolumeIndices[ii] = -1;
2200 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
2202 Float_t pos[3] = {0.,0.,0.};
2205 Int_t interestingPadX[kMaxNumberOfInterestingPads];
2206 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
2207 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
2208 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
2209 Double_t interestingTOT[kMaxNumberOfInterestingPads];
2210 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
2211 Double_t interestingADC[kMaxNumberOfInterestingPads];
2212 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
2213 Double_t interestingTOF[kMaxNumberOfInterestingPads];
2214 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
2215 Double_t interestingWeight[kMaxNumberOfInterestingPads];
2216 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
2218 Float_t interestingX[kMaxNumberOfInterestingPads];
2219 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
2220 Float_t interestingY[kMaxNumberOfInterestingPads];
2221 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
2222 Float_t interestingZ[kMaxNumberOfInterestingPads];
2223 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
2225 Float_t interDigit[kMaxNumberOfInterestingPads];
2226 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
2228 Int_t padsCluster[11];
2229 padsCluster[0] = nSector;
2230 padsCluster[1] = nPlate;
2231 padsCluster[2] = nStrip;
2232 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2234 Int_t interestingCounter=-1;
2235 Int_t digitIndexLocal = -1;
2240 Bool_t check = kFALSE;
2242 for (jj=0; jj<5; jj++) parTOF[jj] = 0;
2243 Double_t posClus[3];
2244 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
2246 for (jj=0; jj<5; jj++) det[jj] = -1;
2248 for (jj=0; jj<3; jj++) posF[jj] = 0.;
2249 UShort_t volIdClus = 0;
2250 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
2251 Double_t covClus[6];
2252 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2253 Int_t tracks[kMaxNumberOfTracksPerDigit];
2254 for (jj=0; jj<3; jj++) tracks[jj] = -1;
2255 Int_t dummyCounter=-1;
2256 Bool_t alreadyStored = kFALSE;
2258 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
2259 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2260 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
2262 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2263 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
2265 AliTOFdigit *digitInteresting;
2269 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
2271 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
2272 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
2274 AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
2281 interestingCounter=-1;
2283 vol[4] = iPadZ , vol[3] = iPadX;
2284 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2285 interestingCounter++;
2287 vol[4] = iPadZ, vol[3] = iPadX+1;
2288 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2289 interestingCounter++;
2291 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
2292 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2293 interestingCounter++;
2295 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
2296 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2297 interestingCounter++;
2299 if (interestingCounter!=group) continue;
2300 else interestingCounter=-1;
2303 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2304 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
2305 selectedDigit[ii][jj] = 0x0;
2308 vol[4] = iPadZ, vol[3] = iPadX;
2310 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2311 interestingCounter++;
2312 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2313 digitsInVolumeIndices[ii] = -1;
2314 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2315 digitIndexLocal=-1; // AdC
2316 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2317 if (digitsInVolumeIndices[digIndex]<0) continue;
2318 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2319 if (digitInteresting->GetToT()<=0) continue; // AdC
2320 digitIndexLocal++; // AdC
2322 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2323 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2324 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2325 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2326 digitsInVolumeIndices[digIndex],
2327 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2328 AliDebug(1,Form(" to try %d %d ",digIndex, interestingCounter));
2330 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2331 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2332 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2333 digitInteresting->GetToT()*digitInteresting->GetToT(),
2334 digitsInVolumeIndices[digIndex],
2335 digitInteresting->GetTracks());
2337 if (digitIndexLocal==-1) interestingCounter--; // AdC
2341 vol[4] = iPadZ, vol[3] = iPadX+1;
2343 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2344 interestingCounter++;
2345 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2346 digitsInVolumeIndices[ii] = -1;
2347 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2348 digitIndexLocal=-1; // AdC
2349 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2350 if (digitsInVolumeIndices[digIndex]<0) continue;
2351 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2352 if (digitInteresting->GetToT()<=0) continue; // AdC
2353 digitIndexLocal++; // AdC
2355 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2356 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2357 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2358 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2359 digitsInVolumeIndices[digIndex],
2360 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2361 AliDebug(1,Form(" to try %d %d ",digIndex, interestingCounter));
2363 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2364 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2365 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2366 digitInteresting->GetToT()*digitInteresting->GetToT(),
2367 digitsInVolumeIndices[digIndex],
2368 digitInteresting->GetTracks());
2370 if (digitIndexLocal==-1) interestingCounter--; // AdC
2374 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
2376 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2377 interestingCounter++;
2378 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2379 digitsInVolumeIndices[ii] = -1;
2380 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2381 digitIndexLocal=-1; // AdC
2382 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2383 if (digitsInVolumeIndices[digIndex]<0) continue;
2384 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2385 if (digitInteresting->GetToT()<=0) continue; // AdC
2386 digitIndexLocal++; // AdC
2388 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2389 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2390 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2391 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2392 digitsInVolumeIndices[digIndex],
2393 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2394 AliDebug(1,Form(" to try %d %d ",digIndex, interestingCounter));
2396 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2397 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2398 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2399 digitInteresting->GetToT()*digitInteresting->GetToT(),
2400 digitsInVolumeIndices[digIndex],
2401 digitInteresting->GetTracks());
2403 if (digitIndexLocal==-1) interestingCounter--; // AdC
2407 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
2409 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2410 interestingCounter++;
2411 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2412 digitsInVolumeIndices[ii] = -1;
2413 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2414 digitIndexLocal=-1; // AdC
2415 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2416 if (digitsInVolumeIndices[digIndex]<0) continue;
2417 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2418 if (digitInteresting->GetToT()<=0) continue; // AdC
2419 digitIndexLocal++; // AdC
2421 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2422 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2423 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2424 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2425 digitsInVolumeIndices[digIndex],
2426 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2427 AliDebug(1,Form(" to try %d %d ",digIndex, interestingCounter));
2429 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2430 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2431 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2432 digitInteresting->GetToT()*digitInteresting->GetToT(),
2433 digitsInVolumeIndices[digIndex],
2434 digitInteresting->GetTracks());
2436 if (digitIndexLocal==-1) interestingCounter--; // AdC
2439 AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
2441 switch(interestingCounter+1) {
2445 for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
2446 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2447 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2449 for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
2450 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2451 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2453 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime) continue;
2455 AliDebug(1, Form(" %1d %1d (0x%x) %1d %1d (0x%x)", adesso1, firstIndex,selectedDigit[adesso1][firstIndex],
2456 adesso2, secondIndex,selectedDigit[adesso2][secondIndex]));
2458 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2459 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2460 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2461 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2462 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
2463 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
2464 Int_t volDum = vol1[3];
2467 fTOFGeometry->GetPosPar(vol1,pos);
2468 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
2469 interestingX[0] = pos[0];
2470 interestingY[0] = pos[1];
2471 interestingZ[0] = pos[2];
2473 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2474 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2475 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2476 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2477 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
2478 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
2482 fTOFGeometry->GetPosPar(vol2,pos);
2483 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
2484 interestingX[1] = pos[0];
2485 interestingY[1] = pos[1];
2486 interestingZ[1] = pos[2];
2489 AverageCalculations(interestingCounter+1,
2490 interestingX, interestingY, interestingZ,
2491 interestingTOF, interestingTOT, interestingADC,
2493 parTOF, posClus, check);
2495 for (jj=0; jj<5; jj++) det[jj] = -1;
2496 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
2498 AliDebug(1,Form(" %f %f %f", posF[0], posF[1], posF[2]));
2499 fTOFGeometry->GetDetID(posF, det);
2500 AliDebug(1,Form(" %2d %1d %2d %1d %2d", det[0], det[1], det[2], det[3], det[4]));
2502 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
2503 //volIdClus = GetClusterVolIndex(det);
2505 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2506 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
2507 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
2508 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
2509 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
2511 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2512 Int_t ** indDet = new Int_t*[interestingCounter+1];
2513 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj] = new Int_t [5];
2514 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][0] = nSector;
2515 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][1] = nPlate;
2516 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][2] = nStrip;
2517 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][3] = padsCluster[2*jj+3];
2518 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
2519 GetClusterPars(/*check,*/ interestingCounter+1, indDet, interestingWeight, posClus, covClus);
2520 for (jj=0; jj<interestingCounter+1; jj++) delete [] indDet[jj];
2522 // To fill the track index array
2524 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2525 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2526 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
2529 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
2532 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2533 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
2536 alreadyStored = kFALSE;
2537 for (jj=0; jj<dummyCounter+1; jj++)
2538 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
2540 if (alreadyStored) continue;
2541 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2542 AliWarning(" Siamo al limite!");
2547 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
2554 AliTOFcluster *tofCluster =
2555 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
2556 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2557 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); //to updated
2558 InsertCluster(tofCluster);
2560 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",
2561 volIdClus, posClus[0], posClus[1], posClus[2],
2562 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2563 tracks[0], tracks[1], tracks[2],
2564 det[0], det[1], det[2], det[3], det[4],
2565 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
2566 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
2571 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
2575 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
2578 } // close loop on second digit
2579 } // close loop on adesso2
2581 } // close loop on first digit
2582 } // close loop on adesso1
2589 for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
2590 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2591 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2593 for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
2594 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2595 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2597 for (Int_t adesso3=adesso2+1; adesso3<interestingCounter+1; adesso3++) {
2598 for (Int_t thirdIndex=0; thirdIndex<kMaxNumberOfDigitsPerVolume; thirdIndex++) {
2599 if (selectedDigit[adesso3][thirdIndex]==0x0) continue;
2602 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime
2604 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
2606 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime) continue;
2608 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2609 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2610 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2611 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2612 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
2613 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
2614 Int_t volDum = vol1[3];
2617 fTOFGeometry->GetPosPar(vol1,pos);
2618 interestingX[0] = pos[0];
2619 interestingY[0] = pos[1];
2620 interestingZ[0] = pos[2];
2622 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2623 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2624 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2625 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2626 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
2627 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
2631 fTOFGeometry->GetPosPar(vol2,pos);
2632 interestingX[1] = pos[0];
2633 interestingY[1] = pos[1];
2634 interestingZ[1] = pos[2];
2636 interestingTOF[2] = selectedDigit[adesso3][thirdIndex]->GetTDC();
2637 interestingTOT[2] = selectedDigit[adesso3][thirdIndex]->GetTOT();
2638 interestingADC[2] = selectedDigit[adesso3][thirdIndex]->GetADC();
2639 interestingWeight[2] = selectedDigit[adesso3][thirdIndex]->GetWeight();
2640 Int_t vol3[5]; for(jj=0; jj<5; jj++) vol3[jj] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(jj);
2641 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol3[0], vol3[1], vol3[2], vol3[4], vol3[3]));
2645 fTOFGeometry->GetPosPar(vol3,pos);
2646 interestingX[2] = pos[0];
2647 interestingY[2] = pos[1];
2648 interestingZ[2] = pos[2];
2651 AverageCalculations(interestingCounter+1,
2652 interestingX, interestingY, interestingZ,
2653 interestingTOF, interestingTOT, interestingADC,
2655 parTOF, posClus, check);
2657 for (jj=0; jj<5; jj++) det[jj] = -1;
2658 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
2659 fTOFGeometry->GetDetID(posF, det);
2661 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
2662 //volIdClus = GetClusterVolIndex(det);
2664 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2665 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
2666 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
2667 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
2668 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
2669 padsCluster[7] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(4);
2670 padsCluster[8] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(3);
2672 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2673 Int_t ** indDet = new Int_t*[interestingCounter+1];
2674 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj] = new Int_t [5];
2675 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][0] = nSector;
2676 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][1] = nPlate;
2677 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][2] = nStrip;
2678 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][3] = padsCluster[2*jj+3];
2679 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
2680 GetClusterPars(/*check,*/ interestingCounter+1, indDet, interestingWeight, posClus, covClus);
2681 for (jj=0; jj<interestingCounter+1; jj++) delete [] indDet[jj];
2683 // To fill the track index array
2685 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2686 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2687 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
2690 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
2693 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2694 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
2697 alreadyStored = kFALSE;
2698 for (jj=0; jj<dummyCounter+1; jj++)
2699 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
2701 if (alreadyStored) continue;
2702 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2703 AliWarning(" Siamo al limite!");
2708 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
2713 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2714 if (selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk)==-1) continue;
2717 alreadyStored = kFALSE;
2718 for (jj=0; jj<dummyCounter+1; jj++)
2719 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk));
2721 if (alreadyStored) continue;
2722 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2723 AliWarning(" Siamo al limite!");
2728 tracks[dummyCounter] = selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk);
2735 AliTOFcluster *tofCluster =
2736 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
2737 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2738 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
2739 InsertCluster(tofCluster);
2741 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",
2742 volIdClus, posClus[0], posClus[1], posClus[2],
2743 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2744 tracks[0], tracks[1], tracks[2],
2745 det[0], det[1], det[2], det[3], det[4],
2746 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
2747 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
2752 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
2756 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
2760 fTOFdigitMap->ResetDigitNumber(vol3,selectedDigit[adesso3][thirdIndex]->GetIndex());
2763 } // close loop on third digit
2764 } // close loop on adesso3
2766 } // close loop on second digit
2767 } // close loop on adesso2
2769 } // close loop on first digit
2770 } // close loop on adesso1
2778 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2779 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2782 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2783 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2786 for (Int_t thirdIndex=0; thirdIndex<kMaxNumberOfDigitsPerVolume; thirdIndex++) {
2787 if (selectedDigit[adesso3][thirdIndex]==0x0) continue;
2790 for (Int_t fourthIndex=0; fourthIndex<kMaxNumberOfDigitsPerVolume; fourthIndex++) {
2791 if (selectedDigit[adesso4][fourthIndex]==0x0) continue;
2794 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime
2796 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
2798 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso4][fourthIndex]->GetTDC())>fMaxDeltaTime
2800 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
2802 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso4][fourthIndex]->GetTDC())>fMaxDeltaTime
2804 TMath::Abs(selectedDigit[adesso3][thirdIndex]->GetTDC()-selectedDigit[adesso4][fourthIndex]->GetTDC())>fMaxDeltaTime) continue;
2806 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2807 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2808 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2809 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2810 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
2811 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
2812 Int_t volDum = vol1[3];
2815 fTOFGeometry->GetPosPar(vol1,pos);
2816 interestingX[0] = pos[0];
2817 interestingY[0] = pos[1];
2818 interestingZ[0] = pos[2];
2820 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2821 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2822 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2823 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2824 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
2825 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
2829 fTOFGeometry->GetPosPar(vol2,pos);
2830 interestingX[1] = pos[0];
2831 interestingY[1] = pos[1];
2832 interestingZ[1] = pos[2];
2834 interestingTOF[2] = selectedDigit[adesso3][thirdIndex]->GetTDC();
2835 interestingTOT[2] = selectedDigit[adesso3][thirdIndex]->GetTOT();
2836 interestingADC[2] = selectedDigit[adesso3][thirdIndex]->GetADC();
2837 interestingWeight[2] = selectedDigit[adesso3][thirdIndex]->GetWeight();
2838 Int_t vol3[5]; for(jj=0; jj<5; jj++) vol3[jj] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(jj);
2839 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol3[0], vol3[1], vol3[2], vol3[4], vol3[3]));
2843 fTOFGeometry->GetPosPar(vol3,pos);
2844 interestingX[2] = pos[0];
2845 interestingY[2] = pos[1];
2846 interestingZ[2] = pos[2];
2848 interestingTOF[3] = selectedDigit[adesso4][fourthIndex]->GetTDC();
2849 interestingTOT[3] = selectedDigit[adesso4][fourthIndex]->GetTOT();
2850 interestingADC[3] = selectedDigit[adesso4][fourthIndex]->GetADC();
2851 interestingWeight[3] = selectedDigit[adesso4][fourthIndex]->GetWeight();
2852 Int_t vol4[5]; for(jj=0; jj<5; jj++) vol4[jj] = selectedDigit[adesso4][fourthIndex]->GetDetectorIndex(jj);
2853 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol4[0], vol4[1], vol4[2], vol4[4], vol4[3]));
2857 fTOFGeometry->GetPosPar(vol4,pos);
2858 interestingX[3] = pos[0];
2859 interestingY[3] = pos[1];
2860 interestingZ[3] = pos[2];
2863 AverageCalculations(interestingCounter+1,
2864 interestingX, interestingY, interestingZ,
2865 interestingTOF, interestingTOT, interestingADC,
2867 parTOF, posClus, check);
2869 for (jj=0; jj<5; jj++) det[jj] = -1;
2870 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
2871 fTOFGeometry->GetDetID(posF, det);
2873 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
2874 //volIdClus = GetClusterVolIndex(det);
2876 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2877 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
2878 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
2879 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
2880 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
2881 padsCluster[7] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(4);
2882 padsCluster[8] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(3);
2883 padsCluster[9] = selectedDigit[adesso4][fourthIndex]->GetDetectorIndex(4);
2884 padsCluster[10] = selectedDigit[adesso4][fourthIndex]->GetDetectorIndex(3);
2886 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2887 Int_t ** indDet = new Int_t*[interestingCounter+1];
2888 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj] = new Int_t [5];
2889 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][0] = nSector;
2890 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][1] = nPlate;
2891 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][2] = nStrip;
2892 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][3] = padsCluster[2*jj+3];
2893 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
2894 GetClusterPars(/*check,*/ interestingCounter+1, indDet, interestingWeight, posClus, covClus);
2895 for (jj=0; jj<interestingCounter+1; jj++) delete [] indDet[jj];
2897 // To fill the track index array
2899 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2900 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2901 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
2904 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
2907 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2908 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
2911 alreadyStored = kFALSE;
2912 for (jj=0; jj<dummyCounter+1; jj++)
2913 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
2915 if (alreadyStored) continue;
2916 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2917 AliWarning(" Siamo al limite!");
2922 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
2927 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2928 if (selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk)==-1) continue;
2931 alreadyStored = kFALSE;
2932 for (jj=0; jj<dummyCounter+1; jj++)
2933 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk));
2935 if (alreadyStored) continue;
2936 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2937 AliWarning(" Siamo al limite!");
2942 tracks[dummyCounter] = selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk);
2947 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2948 if (selectedDigit[adesso4][fourthIndex]->GetTrackLabel(kk)==-1) continue;
2951 alreadyStored = kFALSE;
2952 for (jj=0; jj<dummyCounter+1; jj++)
2953 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso4][fourthIndex]->GetTrackLabel(kk));
2955 if (alreadyStored) continue;
2956 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2957 AliWarning(" Siamo al limite!");
2962 tracks[dummyCounter] = selectedDigit[adesso4][fourthIndex]->GetTrackLabel(kk);
2969 AliTOFcluster *tofCluster =
2970 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
2971 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2972 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
2973 InsertCluster(tofCluster);
2975 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",
2976 volIdClus, posClus[0], posClus[1], posClus[2],
2977 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2978 tracks[0], tracks[1], tracks[2],
2979 det[0], det[1], det[2], det[3], det[4],
2980 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
2981 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
2986 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
2990 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
2994 fTOFdigitMap->ResetDigitNumber(vol3,selectedDigit[adesso3][thirdIndex]->GetIndex());
2998 fTOFdigitMap->ResetDigitNumber(vol4,selectedDigit[adesso4][fourthIndex]->GetIndex());
3001 } // close loop on fourth digit
3003 } // close loop on third digit
3005 } // close loop on second digit
3007 } // close loop on first digit
3013 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
3014 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
3015 selectedDigit[ii][jj] = 0x0;
3019 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
3020 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
3021 delete selectedDigit[ii][jj];
3022 selectedDigit[ii][jj] = 0x0;
3026 //_____________________________________________________________________________
3028 Int_t AliTOFClusterFinderV1::InsertCluster(AliTOFcluster *tofCluster)
3031 // This function adds a TOF cluster to the array of TOF clusters
3032 // sorted in Z, i.e. fTofClusters
3035 if (fNumberOfTofClusters==kTofMaxCluster) {
3036 AliError("Too many clusters !");
3040 if (fNumberOfTofClusters==0) {
3041 fTofClusters[fNumberOfTofClusters++] = tofCluster;
3045 Int_t ii = FindClusterIndex(tofCluster->GetZ());
3046 memmove(fTofClusters+ii+1 ,fTofClusters+ii,(fNumberOfTofClusters-ii)*sizeof(AliTOFcluster*));
3047 fTofClusters[ii] = tofCluster;
3048 fNumberOfTofClusters++;
3053 //_____________________________________________________________________________
3055 Int_t AliTOFClusterFinderV1::FindClusterIndex(Double_t z) const
3058 // This function returns the index of the nearest cluster in z
3061 if (fNumberOfTofClusters==0) return 0;
3062 if (z <= fTofClusters[0]->GetZ()) return 0;
3063 if (z > fTofClusters[fNumberOfTofClusters-1]->GetZ()) return fNumberOfTofClusters;
3064 Int_t b = 0, e = fNumberOfTofClusters-1, m = (b+e)/2;
3065 for (; b<e; m=(b+e)/2) {
3066 if (z > fTofClusters[m]->GetZ()) b=m+1;
3073 //_____________________________________________________________________________
3075 void AliTOFClusterFinderV1::ResetRecpoint()
3078 // Clear the list of reconstructed points
3081 fNumberOfTofClusters = 0;
3082 if (fRecPoints) fRecPoints->Clear();
3085 //_____________________________________________________________________________
3087 void AliTOFClusterFinderV1::ResetDigits()
3090 // Clear the list of digits
3093 fNumberOfTofDigits = 0;
3094 if (fDigits) fDigits->Clear();
3097 //_____________________________________________________________________________
3098 //UShort_t AliTOFClusterFinderV1::GetClusterVolIndex(Int_t *ind) const
3101 // Get the volume ID to retrieve the l2t transformation
3104 // Detector numbering scheme
3106 Int_t nSector = AliTOFGeometry::NSectors();
3107 Int_t nPlate = AliTOFGeometry::NPlates();
3108 Int_t nStripA = AliTOFGeometry::NStripA();
3109 Int_t nStripB = AliTOFGeometry::NStripB();
3110 Int_t nStripC = AliTOFGeometry::NStripC();
3112 Int_t isector =ind[0];
3113 if (isector >= nSector)
3114 AliError(Form("Wrong sector number in TOF (%d) !", isector));
3115 Int_t iplate = ind[1];
3116 if (iplate >= nPlate)
3117 AliError(Form("Wrong plate number in TOF (%d) !", iplate));
3118 Int_t istrip = ind[2];
3120 Int_t stripOffset = 0;
3126 stripOffset = nStripC;
3129 stripOffset = nStripC+nStripB;
3132 stripOffset = nStripC+nStripB+nStripA;
3135 stripOffset = nStripC+nStripB+nStripA+nStripB;
3138 AliError(Form("Wrong plate number in TOF (%d) !", iplate));
3142 Int_t index= (2*(nStripC+nStripB)+nStripA)*isector +
3146 UShort_t volIndex = AliGeomManager::LayerToVolUID(AliGeomManager::kTOF, index);
3151 //_____________________________________________________________________________
3153 void AliTOFClusterFinderV1::GetClusterPars(Int_t *ind, Double_t* pos, Double_t* cov) const
3156 // Starting from the volume indices (ind[5]), for a cluster coming from
3157 // a isolated digits, this function returns:
3158 // the cluster position (pos),
3159 // the cluster covariance matrix elements (cov)
3163 //we now go in the system of the strip: determine the local coordinates
3166 // 47---------------------------------------------------0 ^ z
3167 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 1 |
3168 // ----------------------------------------------------- | y going outwards
3169 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 0 | par[0]=0;
3171 // ----------------------------------------------------- |
3172 // x <-----------------------------------------------------
3174 //move to the tracking ref system
3175 Double_t lpos[3] = { (ind[4]-23.5)*AliTOFGeometry::XPad(),
3177 (ind[3]- 0.5)*AliTOFGeometry::ZPad() };
3178 AliDebug(1, Form(" %f %f %f", lpos[0], lpos[1], lpos[2]));
3181 UShort_t volIndex = fTOFGeometry->GetAliSensVolIndex(ind[0],ind[1],ind[2]);
3182 //UShort_t volIndex = GetClusterVolIndex(ind);
3183 const TGeoHMatrix *l2t = AliGeomManager::GetTracking2LocalMatrix(volIndex);
3185 // Get the position in the track ref system
3187 l2t->MasterToLocal(lpos,tpos);
3192 //Get the cluster covariance in the track ref system
3194 for (Int_t ii=0; ii<9; ii++) lcov[ii] = 0.;
3196 //cluster covariance in the local system:
3201 lcov[4] = 0.42*0.42/3.;
3202 // = ( 5*0.025 (gas gaps thikness)
3203 // + 4*0.040 (internal glasses thickness)
3204 // + 0.5*0.160 (internl PCB)
3205 // + 1*0.055 (external red glass))
3208 lcov[0] = 0.499678;//AliTOFGeometry::XPad()*AliTOFGeometry::XPad()/12.;
3209 lcov[8] = 0.992429;//AliTOFGeometry::ZPad()*AliTOFGeometry::ZPad()/12.;
3211 //cluster covariance in the tracking system:
3213 m.SetRotation(lcov);
3215 m.MultiplyLeft(&l2t->Inverse());
3216 Double_t *tcov = m.GetRotationMatrix();
3217 cov[0] = tcov[0]; cov[1] = tcov[1]; cov[2] = tcov[2];
3218 cov[3] = tcov[4]; cov[4] = tcov[5]; cov[5] = tcov[8];
3223 //_____________________________________________________________________________
3225 void AliTOFClusterFinderV1::GetClusterPars(/*Bool_t check,*/ Int_t counter,
3226 Int_t **ind, Double_t *weight,
3227 Double_t *pos, Double_t *cov) const
3231 // the volumes indices (ind[counter][5]), for a
3232 // cluster coming from a collection of 'counter'
3234 // the volumes weights (weight[counter]), -controlled
3235 // by the 'check' variable control-, for a cluster
3236 // coming from a collection of 'counter' digits,
3237 // the cluster position (pos),
3238 // this function returns:
3239 // the covariance matrix elements (cov) for the found cluster
3243 // we now go in the system of the strip: determine the local coordinates
3245 // 47---------------------------------------------------0 ^ z
3246 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 1 |
3247 // ----------------------------------------------------- | y going outwards
3248 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 0 | par[0]=0;
3250 // ----------------------------------------------------- |
3251 // x <-----------------------------------------------------
3253 for (Int_t ii=0; ii<counter; ii++)
3254 AliDebug(1, Form(" %2d %2d %1d %2d %1d %2d ",
3255 ii, ind[ii][0], ind[ii][1], ind[ii][2], ind[ii][3], ind[ii][4]));
3257 Float_t posF[3]; for (Int_t ii=0; ii<3; ii++) posF[ii] = (Float_t)pos[ii];
3258 AliDebug(1, Form(" %f %f %f", pos[0], pos[1], pos[2]));
3260 Int_t detClus[5] = {-1, -1, -1, -1, -1};
3261 fTOFGeometry->GetDetID(posF, detClus);
3264 UShort_t volIndex = fTOFGeometry->GetAliSensVolIndex(detClus[0],detClus[1],detClus[2]);
3265 //UShort_t volIndex = GetClusterVolIndex(detClus);
3266 AliDebug(1, Form(" %2d %1d %2d %1d %2d %7i",
3267 detClus[0], detClus[1], detClus[2], detClus[3], detClus[4], volIndex));
3269 // Get the position in the TOF strip ref system
3270 const TGeoHMatrix *alice2strip = AliGeomManager::GetOrigGlobalMatrix(volIndex);
3271 Double_t ppos[3] = {-1, -1, -1};
3272 alice2strip->MasterToLocal(pos,ppos);
3273 AliDebug(1, Form(" %f %f %f", ppos[0], ppos[1], ppos[2]));
3276 // Get the position in the tracking ref system
3277 const TGeoHMatrix *g2l = AliGeomManager::GetTracking2LocalMatrix(volIndex);
3278 Double_t lpos[3] = {-1, -1, -1};
3279 g2l->MasterToLocal(ppos,lpos);
3280 AliDebug(1, Form(" %f %f %f", lpos[0], lpos[1], lpos[2]));
3281 for (Int_t ii=0; ii<3; ii++) pos[ii] = lpos[ii];
3283 //Get the cluster covariance in the track ref system
3285 for (Int_t ii=0; ii<9; ii++) lcov[ii] = 0.;
3287 //cluster covariance in the local system:
3292 // Evaluation of the ovariance matrix elements
3293 TOFclusterError(/*check,*/ counter, ind, weight, ppos, lcov);
3295 AliDebug(1, Form("lcov[0] = %f, lcov[8] = %f", lcov[0], lcov[8]));
3297 //cluster covariance in the tracking system:
3299 m.SetRotation(lcov);
3301 m.MultiplyLeft(&g2l->Inverse());
3302 Double_t *tcov = m.GetRotationMatrix();
3303 cov[0] = tcov[0]; cov[1] = tcov[1]; cov[2] = tcov[2];
3304 cov[3] = tcov[4]; cov[4] = tcov[5]; cov[5] = tcov[8];
3309 //_____________________________________________________________________________
3311 void AliTOFClusterFinderV1::TOFclusterError(/*Bool_t check,*/ Int_t counter,
3312 Int_t **ind, Double_t *weight,
3313 Double_t ppos[], Double_t lcov[]) const
3319 //lcov[4] = 0.42*0.42/3.; // cm2
3320 // = ( 5*0.025 (gas gaps thikness)
3321 // + 4*0.040 (internal glasses thickness)
3322 // + 0.5*0.160 (internl PCB)
3323 // + 1*0.055 (external red glass))
3326 Float_t *delta2X = new Float_t[counter];
3327 for (Int_t ii=0; ii<counter; ii++)
3329 ((ind[ii][4]-23.5)*AliTOFGeometry::XPad() - ppos[0])*((ind[ii][4]-23.5)*AliTOFGeometry::XPad() - ppos[0]);
3331 Float_t *delta2Z = new Float_t[counter];
3332 for (Int_t ii=0; ii<counter; ii++)
3334 ((ind[ii][3]- 0.5)*AliTOFGeometry::ZPad() - ppos[2])*((ind[ii][3]- 0.5)*AliTOFGeometry::ZPad() - ppos[2]);
3336 for (Int_t ii=0; ii<counter; ii++)
3337 AliDebug(1, Form("x[%d] = %f, z[%d] = %f, weight[%d] = %f",
3338 ii, (ind[ii][4]-23.5)*AliTOFGeometry::XPad(),
3339 ii, (ind[ii][3]- 0.5)*AliTOFGeometry::ZPad(),
3342 AliDebug(1, Form("xMean = %f, zMean = %f",ppos[0], ppos[2]));
3350 if (ind[0][3]==ind[1][3] && TMath::Abs(ind[0][4]-ind[1][4])==1) { //
3352 lcov[8] = 1.02039; // cm2
3353 lcov[0] = 0.0379409; // cm2
3356 lcov[0] = 0.5*0.5; // cm2
3358 if (weight[0]==weight[1])
3359 lcov[0] = 0.0379409; // cm2
3361 lcov[0] = TMath::Mean(counter, delta2X, weight); // cm2
3367 else if (ind[0][4]==ind[1][4] && TMath::Abs(ind[0][3]-ind[1][3])==1) {//
3369 lcov[0] = 0.505499; // cm2
3370 lcov[8] = 0.0422046; // cm2
3373 lcov[8] = 0.5*0.5; // cm2
3375 if (weight[0]==weight[1])
3376 lcov[8] = 0.0422046; // cm2
3378 lcov[8] = TMath::Mean(counter, delta2Z, weight); // cm2
3387 lcov[0] = 0.0290677; // cm2
3388 lcov[8] = 0.0569726; // cm2
3391 lcov[0] = 0.5*0.5; // cm2
3392 lcov[8] = 0.5*0.5; // cm2
3395 if (weight[0]==weight[1] && weight[0]==weight[2]) {
3396 lcov[0] = 0.0290677; // cm2
3397 lcov[8] = 0.0569726; // cm2
3400 lcov[0] = TMath::Mean(counter, delta2X, weight); // cm2
3401 lcov[8] = TMath::Mean(counter, delta2Z, weight); // cm2
3410 lcov[0] = 0.0223807; // cm2
3411 lcov[8] = 0.0438662; // cm2
3414 lcov[0] = 0.5*0.5; // cm2
3415 lcov[8] = 0.5*0.5; // cm2
3418 if (weight[0]==weight[1] && weight[0]==weight[2] && weight[0]==weight[3]) {
3419 lcov[0] = 0.0223807; // cm2
3420 lcov[8] = 0.0438662; // cm2
3423 lcov[0] = TMath::Mean(counter, delta2X, weight); // cm2
3424 lcov[8] = TMath::Mean(counter, delta2Z, weight); // cm2
3438 //_____________________________________________________________________________
3440 Bool_t AliTOFClusterFinderV1::MakeSlewingCorrection(Int_t *detectorIndex,
3446 // This funtion makes the following:
3448 // - if at least one of the three status (Pulser/Noise/HW) is
3449 // bad, is sets the status of electronic channel, corresponding to the
3450 // volume identified by detectorIndex, as kFALSE;
3451 // - if offline calibration is in the valid status, it performs the
3452 // slewing correction. In particular, by taking into account:
3453 // * the measured tot and tof values (tofDigitToT and tofDigitTdc,
3455 // * the six parameters of 5th order polynomial used
3456 // to fit the tofVStot scatter plot,
3457 // it returns the corrected tof value, i.e. tdcCorr value.
3460 Bool_t output = kTRUE;
3465 //AliInfo(" Calibrating TOF Digits: ");
3467 AliTOFChannelOnlineArray *calDelay = fTOFcalib->GetTOFOnlineDelay();
3468 AliTOFChannelOnlineStatusArray *calStatus = fTOFcalib->GetTOFOnlineStatus();
3470 TObjArray *calTOFArrayOffline = fTOFcalib->GetTOFCalArrayOffline();
3472 Int_t index = AliTOFGeometry::GetIndex(detectorIndex);
3474 UChar_t statusPulser = calStatus->GetPulserStatus(index);
3475 UChar_t statusNoise = calStatus->GetNoiseStatus(index);
3476 UChar_t statusHW = calStatus->GetHWStatus(index);
3477 UChar_t status = calStatus->GetStatus(index);
3479 //check the status, also unknown is fine!!!!!!!
3481 AliDebug(2, Form(" Status for channel %d = %d",index, (Int_t)status));
3482 if((statusPulser & AliTOFChannelOnlineStatusArray::kTOFPulserBad)==(AliTOFChannelOnlineStatusArray::kTOFPulserBad)||(statusNoise & AliTOFChannelOnlineStatusArray::kTOFNoiseBad)==(AliTOFChannelOnlineStatusArray::kTOFNoiseBad)||(statusHW & AliTOFChannelOnlineStatusArray::kTOFHWBad)==(AliTOFChannelOnlineStatusArray::kTOFHWBad)){
3483 AliDebug(2, Form(" Bad Status for channel %d",index));
3484 //fTofClusters[ii]->SetStatus(kFALSE); //odd convention, to avoid conflict with calibration objects currently in the db (temporary solution).
3488 AliDebug(2, Form(" Good Status for channel %d",index));
3490 // Get Rough channel online equalization
3491 Double_t roughDelay = (Double_t)calDelay->GetDelay(index); // in ns
3492 AliDebug(2,Form(" channel delay (ns) = %f", roughDelay));
3493 // Get Refined channel offline calibration parameters
3494 TString validity = (TString)fTOFcalib->GetOfflineValidity();
3495 if (validity.CompareTo("valid")==0) {
3496 AliTOFChannelOffline * calChannelOffline = (AliTOFChannelOffline*)calTOFArrayOffline->At(index);
3498 for (jj = 0; jj<6; jj++)
3499 par[jj] = (Double_t)calChannelOffline->GetSlewPar(jj);
3501 AliDebug(2,Form(" Calib Pars = %f, %f, %f, %f, %f, %f ",par[0],par[1],par[2],par[3],par[4],par[5]));
3502 AliDebug(2,Form(" The ToT and Time, uncorr (counts) = %d , %d", tofDigitToT, tofDigitTdc));
3503 Double_t tToT = (Double_t)(tofDigitToT*AliTOFGeometry::ToTBinWidth());
3504 tToT*=1.E-3; //ToT in ns
3505 AliDebug(2,Form(" The ToT and Time, uncorr (ns)= %e, %e",tofDigitTdc*AliTOFGeometry::TdcBinWidth()*1.E-3,tToT));
3506 timeCorr = par[0] + tToT*(par[1] + tToT*(par[2] + tToT*(par[3] + tToT*(par[4] + tToT*par[5])))); // the time correction (ns)
3509 timeCorr = roughDelay; // correction in ns
3511 AliDebug(2,Form(" The ToT and Time, uncorr (ns)= %e, %e",tofDigitTdc*AliTOFGeometry::TdcBinWidth()*1.E-3,tofDigitToT*AliTOFGeometry::ToTBinWidth()));
3512 AliDebug(2,Form(" The time correction (ns) = %f", timeCorr));
3513 timeCorr = (Double_t)(tofDigitTdc)*AliTOFGeometry::TdcBinWidth()*1.E-3-timeCorr;//redefine the time
3515 AliDebug(2,Form(" The channel time, corr (ps)= %e",timeCorr ));
3516 tdcCorr = (Int_t)(timeCorr/AliTOFGeometry::TdcBinWidth()); //the corrected time (tdc counts)
3521 //______________________________________________________________________________
3523 void AliTOFClusterFinderV1::Digits2RecPoints(Int_t iEvent)
3526 // Converts digits to recpoints for TOF
3529 TStopwatch stopwatch;
3532 fRunLoader->GetEvent(iEvent);
3534 AliLoader *localTOFLoader = (AliLoader*)fRunLoader->GetLoader("TOFLoader");
3536 TTree * localTreeD = (TTree*)localTOFLoader->TreeD();
3537 if (localTreeD == 0x0)
3538 AliFatal("Can not get TreeD");
3540 TBranch *branch = localTreeD->GetBranch("TOF");
3542 AliError("Can't get the branch with the TOF digits !");
3546 TTree *localTreeR = (TTree*)localTOFLoader->TreeR();
3547 if (localTreeR == 0x0)
3549 localTOFLoader->MakeTree("R");
3550 localTreeR = localTOFLoader->TreeR();
3553 Digits2RecPoints(localTreeD, localTreeR);
3555 //localTOFLoader = fRunLoader->GetLoader("TOFLoader");
3556 localTOFLoader->WriteRecPoints("OVERWRITE");
3558 AliDebug(1, Form("Execution time to read TOF digits and to write TOF clusters for the event number %d: R:%.4fs C:%.4fs",
3559 iEvent, stopwatch.RealTime(),stopwatch.CpuTime()));
3562 //______________________________________________________________________________
3564 void AliTOFClusterFinderV1::Digits2RecPoints(Int_t iEvent, AliRawReader *rawReader)
3567 // Converts RAW data to recpoints for TOF
3570 TStopwatch stopwatch;
3573 fRunLoader->GetEvent(iEvent);
3575 AliDebug(2,Form(" Event number %2d ", iEvent));
3577 AliLoader *localTOFLoader = (AliLoader*)fRunLoader->GetLoader("TOFLoader");
3579 TTree *localTreeR = localTOFLoader->TreeR();
3581 if (localTreeR == 0x0){
3582 localTOFLoader->MakeTree("R");
3583 localTreeR = localTOFLoader->TreeR();
3586 Digits2RecPoints(rawReader, localTreeR);
3588 AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters for the event number %d: R:%.4fs C:%.4fs",
3589 iEvent, stopwatch.RealTime(),stopwatch.CpuTime()));
3592 //______________________________________________________________________________
3594 void AliTOFClusterFinderV1::Raw2Digits(Int_t iEvent, AliRawReader *rawReader)
3597 // Converts RAW data to MC digits for TOF
3601 TStopwatch stopwatch;
3604 fRunLoader->GetEvent(iEvent);
3606 AliDebug(2,Form(" Event number %2d ", iEvent));
3608 AliLoader *localTOFLoader = (AliLoader*)fRunLoader->GetLoader("TOFLoader");
3610 TTree *localTreeD = localTOFLoader->TreeD();
3612 if (localTreeD == 0x0){
3613 localTOFLoader->MakeTree("D");
3614 localTreeD = localTOFLoader->TreeD();
3617 Raw2Digits(rawReader, localTreeD);
3619 AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters for the event number %d: R:%.4fs C:%.4fs",
3620 iEvent, stopwatch.RealTime(),stopwatch.CpuTime()));
3623 //______________________________________________________________________________
3625 void AliTOFClusterFinderV1::AverageCalculations(Int_t number, Float_t *interestingX,
3626 Float_t *interestingY, Float_t *interestingZ,
3627 Double_t *interestingTOF, Double_t *interestingTOT,
3628 Double_t *interestingADC, Double_t *interestingWeight,
3629 Int_t *parTOF, Double_t *posClus, Bool_t &check)
3635 Double_t tofAverage = 0.;
3636 Double_t totAverage = 0.;
3637 Double_t adcAverage = 0.;
3641 for (ii=number-1; ii>=0; ii--) check=check||(interestingWeight[ii]==0 || interestingWeight[ii]==-1);
3645 posClus[0] = TMath::Mean(number, interestingX);
3646 posClus[1] = TMath::Mean(number, interestingY);
3647 posClus[2] = TMath::Mean(number, interestingZ);
3648 tofAverage = TMath::Mean(number, interestingTOF);
3649 totAverage = TMath::Mean(number, interestingTOT);
3650 adcAverage = TMath::Mean(number, interestingADC);
3655 posClus[0] = TMath::Mean(number, interestingX, interestingWeight);
3656 posClus[1] = TMath::Mean(number, interestingY, interestingWeight);
3657 posClus[2] = TMath::Mean(number, interestingZ, interestingWeight);
3658 tofAverage = TMath::Mean(number, interestingTOF, interestingWeight);
3659 totAverage = TMath::Mean(number, interestingTOT, interestingWeight);
3660 adcAverage = TMath::Mean(number, interestingADC, interestingWeight);
3664 parTOF[0] = Int_t(tofAverage);
3665 parTOF[1] = Int_t(totAverage);
3666 parTOF[2] = Int_t(adcAverage);
3667 parTOF[3] = Int_t(tofAverage);//tofND
3668 parTOF[4] = Int_t(tofAverage);//tofRAW