1 /***************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
17 $Log: AliTOFClusterFinderV1.cxx,v $
18 Revision 2009/04/20 A. De Caro
19 - added two new global variables, called fTOFGeometry and fTOFdigits;
20 - added a new method, called FindClustersWithoutTOT,
21 to transform TOF digits with fTOT=0 in one pad clusters;
22 - update of the covariance matrix elements for the TOF clusters
24 Revision 0.01 2008/05/10 A. De Caro
27 /////////////////////////////////////////
29 // Class for TOF cluster finder (V1) //
31 // Input data: Raw Data or Digits; //
32 // Output data: Digits or Rec Points //
34 /////////////////////////////////////////
36 #include "Riostream.h"
38 #include "TClonesArray.h"
39 #include "TStopwatch.h"
41 #include "TGeoMatrix.h"
46 #include "AliRawReader.h"
47 #include "AliLoader.h"
48 #include "AliRunLoader.h"
49 #include "AliGeomManager.h"
51 #include "AliTOFcalib.h"
52 #include "AliTOFChannelOnlineArray.h"
53 #include "AliTOFChannelOnlineStatusArray.h"
54 #include "AliTOFChannelOffline.h"
55 #include "AliTOFClusterFinderV1.h"
56 #include "AliTOFcluster.h"
57 #include "AliTOFdigit.h"
58 #include "AliTOFDigitMap.h"
59 #include "AliTOFrawData.h"
60 #include "AliTOFReconstructor.h"
61 #include "AliTOFRecoParam.h"
67 ClassImp(AliTOFClusterFinderV1)
69 //_____________________________________________________________________________
70 AliTOFClusterFinderV1::AliTOFClusterFinderV1(AliTOFcalib *calib):
71 TTask("AliTOFClusterFinderV1",""),
73 fDigits(new TClonesArray("AliTOFdigit", 4000)),
74 fRecPoints(new TClonesArray("AliTOFcluster", 4000)),
75 fNumberOfTofClusters(0),
76 fNumberOfTofDigits(0),
77 fNumberOfTofTrgPads(0),
78 fkRecoParam(0),//AliTOFReconstructor::GetRecoParam()),
79 fMaxDeltaTime(0),//fkRecoParam->GetMaxDeltaTime()),
83 fTOFdigitMap(new AliTOFDigitMap()),
84 fTOFGeometry(new AliTOFGeometry()),
85 fTOFdigits(new TTree()),
86 fTOFRawStream(AliTOFRawStream()),
93 for (Int_t ii=0; ii<kTofMaxCluster; ii++) fTofClusters[ii]=0x0;
95 if (AliTOFReconstructor::GetRecoParam()) {
96 fkRecoParam = AliTOFReconstructor::GetRecoParam();
97 fMaxDeltaTime = fkRecoParam->GetMaxDeltaTime();
102 TString validity = (TString)fTOFcalib->GetOfflineValidity();
103 if (validity.CompareTo("valid")==0) {
104 AliInfo(Form(" validity = %s - Using offline calibration parameters", validity.Data()));
106 AliInfo(Form(" validity = %s - Using online calibration parameters", validity.Data()));
111 //_____________________________________________________________________________
112 AliTOFClusterFinderV1::AliTOFClusterFinderV1(AliRunLoader* runLoader, AliTOFcalib *calib):
113 TTask("AliTOFClusterFinderV1",""),
114 fRunLoader(runLoader),
115 fDigits(new TClonesArray("AliTOFdigit", 4000)),
116 fRecPoints(new TClonesArray("AliTOFcluster", 4000)),
117 fNumberOfTofClusters(0),
118 fNumberOfTofDigits(0),
119 fNumberOfTofTrgPads(0),
120 fkRecoParam(0),//AliTOFReconstructor::GetRecoParam()),
121 fMaxDeltaTime(0),//fkRecoParam->GetMaxDeltaTime()),
125 fTOFdigitMap(new AliTOFDigitMap()),
126 fTOFGeometry(new AliTOFGeometry()),
127 fTOFdigits(new TTree()),
128 fTOFRawStream(AliTOFRawStream()),
129 fCalibrateTOFtimes(1)
135 for (Int_t ii=0; ii<kTofMaxCluster; ii++) fTofClusters[ii]=0x0;
137 if (AliTOFReconstructor::GetRecoParam()) {
138 fkRecoParam = AliTOFReconstructor::GetRecoParam();
139 fMaxDeltaTime = fkRecoParam->GetMaxDeltaTime();
144 TString validity = (TString)fTOFcalib->GetOfflineValidity();
145 if (validity.CompareTo("valid")==0) {
146 AliInfo(Form(" validity = %s - Using offline calibration parameters", validity.Data()));
148 AliInfo(Form(" validity = %s - Using online calibration parameters", validity.Data()));
152 //_____________________________________________________________________________
154 AliTOFClusterFinderV1::AliTOFClusterFinderV1(const AliTOFClusterFinderV1 &source)
157 fDigits(source.fDigits),
158 fRecPoints(source.fRecPoints),
159 fNumberOfTofClusters(0),
160 fNumberOfTofDigits(0),
161 fNumberOfTofTrgPads(0),
162 fkRecoParam(0),//AliTOFReconstructor::GetRecoParam()),
163 fMaxDeltaTime(0),//fkRecoParam->GetMaxDeltaTime()),
165 fDecoderVersion(source.fDecoderVersion),
166 fTOFcalib(source.fTOFcalib),
167 fTOFdigitMap(new AliTOFDigitMap()),
168 fTOFGeometry(new AliTOFGeometry()),
169 fTOFdigits(source.fTOFdigits),
170 fTOFRawStream(source.fTOFRawStream),
171 fCalibrateTOFtimes(1)
175 for (Int_t ii=0; ii<kTofMaxCluster; ii++) fTofClusters[ii]=source.fTofClusters[ii];
177 if (AliTOFReconstructor::GetRecoParam()) {
178 fkRecoParam = AliTOFReconstructor::GetRecoParam();
179 fMaxDeltaTime = fkRecoParam->GetMaxDeltaTime();
185 //_____________________________________________________________________________
187 AliTOFClusterFinderV1& AliTOFClusterFinderV1::operator=(const AliTOFClusterFinderV1 &source)
194 TObject::operator=(source);
195 for (Int_t ii=0; ii<kTofMaxCluster; ii++) fTofClusters[ii]=source.fTofClusters[ii];
196 fDigits=source.fDigits;
197 fRecPoints=source.fRecPoints;
198 fNumberOfTofClusters=source.fNumberOfTofClusters;
199 fNumberOfTofTrgPads=source.fNumberOfTofTrgPads;
200 fNumberOfTofDigits=source.fNumberOfTofDigits;
201 fVerbose=source.fVerbose;
202 fDecoderVersion=source.fDecoderVersion;
203 fTOFcalib=source.fTOFcalib;
204 fTOFdigitMap=source.fTOFdigitMap;
205 fTOFGeometry=source.fTOFGeometry;
206 fTOFdigits=source.fTOFdigits;
207 fTOFRawStream=source.fTOFRawStream;
208 fCalibrateTOFtimes=source.fCalibrateTOFtimes;
212 //_____________________________________________________________________________
214 AliTOFClusterFinderV1::~AliTOFClusterFinderV1()
229 fRecPoints->Delete();
240 //if (fTofClusters || fNumberOfTofClusters) {
241 if (fNumberOfTofClusters) {
242 for (Int_t ii=0; ii<fNumberOfTofClusters; ii++)
243 if (fTofClusters[ii]) fTofClusters[ii]->Delete();
244 fNumberOfTofClusters = 0;
248 //_____________________________________________________________________________
250 void AliTOFClusterFinderV1::Digits2RecPoints(TTree* digitsTree, TTree* clusterTree)
253 // Converts digits to recPoints for TOF
256 TStopwatch stopwatch;
264 TClonesArray &aDigits = *fDigits;
266 if (digitsTree == 0x0) {
267 AliFatal("Can not get TreeD for TOF");
271 TBranch *branch = digitsTree->GetBranch("TOF");
273 AliError("Can not get branch with the TOF digits !");
277 TClonesArray staticDigits("AliTOFdigit",10000);
278 staticDigits.Clear();
279 TClonesArray *digits = &staticDigits;
280 branch->SetAddress(&digits);
281 digitsTree->GetEvent(0);
282 AliDebug(1,Form("Number of TOF digits: %d", digits->GetEntriesFast()));
284 AliTOFdigit *tofDigit;
287 Int_t detectorIndex[5];
288 for (jj=0; jj<5; jj++) detectorIndex[jj] = -1;
290 for (jj=0; jj<4; jj++) info[jj] = -1;
296 Bool_t status = kTRUE;
298 AliDebug(1," Calibrating TOF Digits");
300 TString validity = (TString)fTOFcalib->GetOfflineValidity();
301 if (validity.CompareTo("valid")==0) {
302 AliInfo(Form(" validity = %s - Using offline calibration parameters", validity.Data()));
304 AliInfo(Form(" validity = %s - Using online calibration parameters", validity.Data()));
308 for (ii=0; ii<digits->GetEntriesFast(); ii++) {
309 tofDigit = (AliTOFdigit*)digits->UncheckedAt(ii);
310 detectorIndex[0] = tofDigit->GetSector();
311 detectorIndex[1] = tofDigit->GetPlate();
312 detectorIndex[2] = tofDigit->GetStrip();
313 detectorIndex[3] = tofDigit->GetPadz();
314 detectorIndex[4] = tofDigit->GetPadx();
316 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
317 if (detectorIndex[1]==2) { // plate with holes
323 tdcCorr = tofDigit->GetTdc();
324 status = MakeSlewingCorrection(detectorIndex, tofDigit->GetToT(), tofDigit->GetTdc(), tdcCorr);
326 for (jj=0; jj<4; jj++) info[jj] = -1;
327 info[0] = tdcCorr;//tofDigit->GetTdc();
328 info[1] = tofDigit->GetAdc();
329 info[2] = tofDigit->GetToT();
330 info[3] = tofDigit->GetTdcND();//tofDigit->GetTdc();//
331 tracks = tofDigit->GetTracks();
333 dummy = detectorIndex[3];
334 detectorIndex[3] = detectorIndex[4];//padx
335 detectorIndex[4] = dummy;//padz
336 last = fDigits->GetEntriesFast();
337 new (aDigits[last]) AliTOFdigit(tracks, detectorIndex, info);
338 if (status) fTOFdigitMap->AddDigit(detectorIndex, last);
340 AliDebug(2, Form(" Digits reading %2d -> %2d %1d %2d %1d %2d (%d, %d, %d)",
342 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[3], detectorIndex[4],
343 info[0], info[1], info[3]));
347 fNumberOfTofDigits = fDigits->GetEntriesFast();
351 Int_t bufsize = 32000;
352 clusterTree->Branch("TOF", &fRecPoints, bufsize);
357 AliDebug(1,Form("Number of found clusters: %d", fNumberOfTofClusters));
361 fTOFdigitMap->Clear();
365 AliDebug(1,Form("Execution time to read TOF digits and to write TOF clusters : R:%.4fs C:%.4fs",
366 stopwatch.RealTime(),stopwatch.CpuTime()));
368 if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
371 //_____________________________________________________________________________
373 void AliTOFClusterFinderV1::Digits2RecPoints(AliRawReader *rawReader, TTree *clustersTree)
376 // Converts raw data to recPoints for TOF
379 TStopwatch stopwatch;
384 AliDebug(2, "TreeD re-creation");
385 //TTree *digitsTree = new TTree();
386 //Raw2Digits(rawReader, digitsTree);
388 Raw2Digits(rawReader, fTOFdigits);
390 AliDebug(1,Form("Number of TOF digits: %d", fNumberOfTofDigits));
393 Int_t bufsize = 32000;
394 clustersTree->Branch("TOF", &fRecPoints, bufsize);
397 clustersTree->Fill();
399 AliDebug(1,Form("Number of found clusters: %d", fNumberOfTofClusters));
403 fTOFdigitMap->Clear();
407 AliDebug(1,Form("Execution time to read TOF raw data and to write TOF clusters : R:%.4fs C:%.4fs",
408 stopwatch.RealTime(),stopwatch.CpuTime()));
412 //_____________________________________________________________________________
414 void AliTOFClusterFinderV1::Raw2Digits(AliRawReader *rawReader, TTree* digitsTree)
417 // Converts raw data to digits for TOF
420 TStopwatch stopwatch;
425 const Int_t kMaxNumberOfTracksPerDigit = 3;
426 const Int_t kDDL = AliDAQ::NumberOfDdls("TOF");
428 digitsTree->Branch("TOF", &fDigits);
429 TClonesArray &aDigits = *fDigits;
431 fTOFRawStream.Clear();
432 fTOFRawStream.SetRawReader(rawReader);
435 if (fVerbose==2) ftxt.open("TOFdigitsRead.txt",ios::app);
437 TClonesArray staticRawData("AliTOFrawData",10000);
438 staticRawData.Clear();
439 TClonesArray * clonesRawData = &staticRawData;
442 Int_t detectorIndex[5] = {-1, -1, -1, -1, -1};
444 Int_t tracks[kMaxNumberOfTracksPerDigit];
445 for (Int_t ii=0; ii<kMaxNumberOfTracksPerDigit; ii++)
450 Bool_t status = kTRUE;
453 TString validity = (TString)fTOFcalib->GetOfflineValidity();
454 if (validity.CompareTo("valid")==0) {
455 AliInfo(Form(" validity = %s - Using offline calibration parameters", validity.Data()));
457 AliInfo(Form(" validity = %s - Using online calibration parameters", validity.Data()));
461 AliInfo("Using New Decoder");
465 for (indexDDL=0; indexDDL<kDDL; indexDDL++) {
469 fTOFRawStream.LoadRawDataBuffers(indexDDL,fVerbose);
470 else fTOFRawStream.LoadRawData(indexDDL);
472 clonesRawData = (TClonesArray*)fTOFRawStream.GetRawData();
473 if (clonesRawData->GetEntriesFast()!=0) AliDebug(2,Form(" TOF raw data number = %3d", clonesRawData->GetEntriesFast()));
474 for (iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
476 AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
478 //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
479 if (tofRawDatum->GetTOF()==-1) continue;
481 fTOFRawStream.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
482 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
485 dummy = detectorIndex[3];
486 detectorIndex[3] = detectorIndex[4];//padz
487 detectorIndex[4] = dummy;//padx
489 tdcCorr = tofRawDatum->GetTOF();
490 status = MakeSlewingCorrection(detectorIndex, tofRawDatum->GetTOT(), tofRawDatum->GetTOF(), tdcCorr);
493 digit[1] = tofRawDatum->GetTOT();
494 digit[2] = tofRawDatum->GetTOT();
495 digit[3] = -1;//tofRawDatum->GetTOF(); //tofND
499 AliTOFGeometry::GetPosPar(detectorIndex, pos);
501 for (Int_t ic = 0; ic < 3; ic++) length += pos[ic] * pos[ic];
502 length = TMath::Sqrt(length);
503 Float_t timealligned = tdcCorr*24.4 - length * 0.0333564095198152043; // subtract the minimal time in
505 if(status && timealligned > -1000 && timealligned < 24000){
506 fNumberOfTofTrgPads++;
509 dummy = detectorIndex[3];
510 detectorIndex[3] = detectorIndex[4];//padx
511 detectorIndex[4] = dummy;//padz
513 /* check valid index */
514 if (detectorIndex[0]==-1||detectorIndex[1]==-1||detectorIndex[2]==-1||detectorIndex[3]==-1||detectorIndex[4]==-1) continue;
516 // Do not reconstruct anything in the holes
517 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
518 if (detectorIndex[1]==2) { // plate with holes
524 last = fDigits->GetEntriesFast();
525 new (aDigits[last]) AliTOFdigit(tracks, detectorIndex, digit);
526 if (status) fTOFdigitMap->AddDigit(detectorIndex, last);
530 if (indexDDL<10) ftxt << " " << indexDDL;
531 else ftxt << " " << indexDDL;
532 if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM();
533 else ftxt << " " << tofRawDatum->GetTRM();
534 ftxt << " " << tofRawDatum->GetTRMchain();
535 if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC();
536 else ftxt << " " << tofRawDatum->GetTDC();
537 ftxt << " " << tofRawDatum->GetTDCchannel();
539 if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0];
540 else ftxt << " -> " << detectorIndex[0];
541 ftxt << " " << detectorIndex[1];
542 if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2];
543 else ftxt << " " << detectorIndex[2];
544 ftxt << " " << detectorIndex[4];
545 if (detectorIndex[4]<10) ftxt << " " << detectorIndex[3];
546 else ftxt << " " << detectorIndex[3];
548 if (digit[1]<10)ftxt << " " << digit[1];
549 else if (digit[1]>=10 && digit[1]<100) ftxt << " " << digit[1];
550 else ftxt << " " << digit[1];
551 if (digit[0]<10) ftxt << " " << digit[0] << endl;
552 else if (digit[0]>=10 && digit[0]<100) ftxt << " " << digit[0] << endl;
553 else if (digit[0]>=100 && digit[0]<1000) ftxt << " " << digit[0] << endl;
554 else ftxt << " " << digit[3] << endl;
557 AliDebug(2, Form(" Raw data reading %2d -> %2d %1d %2d %1d %2d (%d, %d, %d)",
559 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[4], detectorIndex[3],
560 digit[0], digit[1], digit[3]));
564 clonesRawData->Clear();
568 if (fVerbose==2) ftxt.close();
572 fNumberOfTofDigits = fDigits->GetEntries();
574 AliDebug(1, Form("Got %d TOF digits", fNumberOfTofDigits));
575 AliDebug(1, Form("Execution time to read TOF raw data and fill TOF digit tree : R:%.2fs C:%.2fs",
576 stopwatch.RealTime(),stopwatch.CpuTime()));
578 if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
581 //_____________________________________________________________________________
583 void AliTOFClusterFinderV1::FillRecPoint()
586 // Fill the global TClonesArray of AliTOFcluster objects,
595 for(Int_t iPlate=AliTOFGeometry::NPlates()-1; iPlate>=0; iPlate--) {
596 for(Int_t iStrip=AliTOFGeometry::NStrip(iPlate)-1; iStrip>=0; iStrip--) {
597 //for (Int_t iSector=AliTOFGeometry::NSectors()-1; iSector>=0; iSector--) {
598 for (Int_t iSector=0; iSector<AliTOFGeometry::NSectors(); iSector++) {
601 if (fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))
602 AliDebug(1,Form(" Number of TOF digits in (%2d,%1d,%2d) -> %d",
603 iSector,iPlate,iStrip,fTOFdigitMap->FilledCellsInStrip(iSector,iPlate,iStrip)));
605 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
606 FindClustersWithoutTOT(iSector, iPlate, iStrip); // clusters coming from digits without TOT measurement
608 if (fMaxDeltaTime>0) {
610 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
611 //if (fTOFdigitMap->FilledCellsInStrip(iSector,iPlate,iStrip)>=4)
612 FindClustersPerStrip(iSector, iPlate, iStrip, 4); // 4 pads clusters
613 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
615 dummy4 = fNumberOfTofClusters;
616 FindClustersPerStrip(iSector, iPlate, iStrip, 4); // 4 pads clusters
617 if (fNumberOfTofClusters!=dummy4)
618 AliDebug(2, Form(" (4): n1= %5d, n2 = %5d", dummy4, fNumberOfTofClusters));
621 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
622 FindClustersPerStrip(iSector, iPlate, iStrip, 3); // 3 pads clusters
623 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
625 dummy3 = fNumberOfTofClusters;
626 FindClustersPerStrip(iSector, iPlate, iStrip, 3); // 3 pads clusters
627 if (fNumberOfTofClusters!=dummy3)
628 AliDebug(2, Form(" (3): n1= %5d, n2 = %5d", dummy3, fNumberOfTofClusters));
631 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
632 FindClustersPerStrip(iSector, iPlate, iStrip, 2); // 2 pads clusters
633 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
635 dummy2 = fNumberOfTofClusters;
636 FindClustersPerStrip(iSector, iPlate, iStrip, 2); // 2 pads clusters
637 if (fNumberOfTofClusters!=dummy2)
638 AliDebug(2, Form(" (2): n1= %5d, n2 =%5d", dummy2, fNumberOfTofClusters));
641 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
642 dummy = fNumberOfTofClusters;
643 FindClusters34(iSector, iPlate, iStrip); // 3 pads clusters between 4 hit pads
644 if (fNumberOfTofClusters!=dummy)
645 AliDebug(2, Form(" (3 between 4): n1 = %5d, n2 = %5d", fNumberOfTofClusters, dummy));
648 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
649 dummy = fNumberOfTofClusters;
650 FindClusters23(iSector, iPlate, iStrip); // 2 pads clusters between 3 hit pads
651 if (fNumberOfTofClusters!=dummy)
652 AliDebug(2, Form(" (2 between 3): n1 = %5d, n2 = %5d", fNumberOfTofClusters, dummy));
654 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
655 dummy = fNumberOfTofClusters;
656 FindClusters24(iSector, iPlate, iStrip); // 2 pads clusters between 4 hit pads
657 if (fNumberOfTofClusters!=dummy)
658 AliDebug(2, Form(" (2 between 4): n1 = %5d, n2 = %5d", fNumberOfTofClusters, dummy));
661 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
662 dummy = fNumberOfTofClusters;
663 FindOnePadClusterPerStrip(iSector, iPlate, iStrip); // 1 pad clusters
664 if (fNumberOfTofClusters!=dummy)
665 AliDebug(2,Form(" (1): n1 = %5d, n2 = %5d", fNumberOfTofClusters, dummy));
667 if (fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip)>0)
668 AliDebug(2, Form(" (1): number of clusters = %5d (remaining digit %2d), -%2d %1d %2d-",
669 fNumberOfTofClusters, fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip),
670 iSector, iPlate, iStrip));
674 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
675 dummy = fNumberOfTofClusters;
676 FindOnePadClusterPerStrip(iSector, iPlate, iStrip); // 1 pad clusters
677 if (fNumberOfTofClusters!=dummy)
678 AliDebug(2,Form(" (1): n1 = %5d, n2 = %5d", fNumberOfTofClusters, dummy));
680 if (fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip)>0)
681 AliDebug(2, Form(" (1): number of clusters = %5d (remaining digit %2d), -%2d %1d %2d-",
682 fNumberOfTofClusters, fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip),
683 iSector, iPlate, iStrip));
693 TClonesArray &lRecPoints = *fRecPoints;
697 Int_t detectorIndex[5];
698 for (jj=0; jj<5; jj++) detectorIndex[jj] = -1;
700 for (jj=0; jj<7; jj++) parTOF[jj] = -1;
701 Int_t trackLabels[3];
702 for (jj=0; jj<3; jj++) trackLabels[jj] = -1;
703 Int_t digitIndex = -1;
704 Bool_t status = kTRUE;
706 for (ii=0; ii<3; ii++) posClus[ii] = 0.;
707 //Float_t covClus[6];
708 //for (ii=0; ii<6; ii++) covClus[ii] = 0.;
711 for (ii=0; ii<fNumberOfTofClusters; ii++) {
712 AliTOFcluster* clOr = fTofClusters[ii];
713 fTofClusters[ii] = 0;
714 digitIndex = clOr->GetIndex();
715 for(jj=0; jj<5; jj++) detectorIndex[jj] = clOr->GetDetInd(jj);
716 volIdClus = fTOFGeometry->GetAliSensVolIndex(detectorIndex[0],detectorIndex[1],detectorIndex[2]);
717 //volIdClus = GetClusterVolIndex(detectorIndex);
718 for(jj=0; jj<3; jj++) trackLabels[jj] = clOr->GetLabel(jj);
719 parTOF[0] = clOr->GetTDC(); // TDC
720 parTOF[1] = clOr->GetToT(); // TOT
721 parTOF[2] = clOr->GetADC(); // ADC=TOT
722 parTOF[3] = clOr->GetTDCND(); // TDCND
723 parTOF[4] = clOr->GetTDCRAW();//RAW
726 status = clOr->GetStatus();
728 posClus[0] = clOr->GetX();
729 posClus[1] = clOr->GetY();
730 posClus[2] = clOr->GetZ();
732 //for (jj=0; jj<6; jj++) covClus[jj] = 0.;
733 //((AliCluster*)clOr)->GetGlobalCov(covClus);
735 new(lRecPoints[ii]) AliTOFcluster(volIdClus, (Double_t)posClus[0], (Double_t)posClus[1], (Double_t)posClus[2],
736 (Double_t)(clOr->GetSigmaX2()),
737 (Double_t)(clOr->GetSigmaXY()),
738 (Double_t)(clOr->GetSigmaXZ()),
739 (Double_t)(clOr->GetSigmaY2()),
740 (Double_t)(clOr->GetSigmaYZ()),
741 (Double_t)(clOr->GetSigmaZ2()),
742 //(Double_t)covClus[0], (Double_t)covClus[1], (Double_t)covClus[2],
743 //(Double_t)covClus[3], (Double_t)covClus[4], (Double_t)covClus[5],
744 trackLabels, detectorIndex, parTOF, status, digitIndex);
746 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",
747 ii, volIdClus, posClus[0], posClus[1], posClus[2],
754 trackLabels[0], trackLabels[1], trackLabels[2],
755 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[3], detectorIndex[4],
756 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
757 status, digitIndex));
762 for (Int_t iSector=0; iSector<AliTOFGeometry::NSectors(); iSector++)
763 for(Int_t iPlate=0; iPlate<AliTOFGeometry::NPlates(); iPlate++) {
764 for(Int_t iStrip=0; iStrip<AliTOFGeometry::NStrip(iPlate); iStrip++) {
765 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
766 AliDebug(2, Form(" END %2d %1d %2d %5d",
767 iSector, iPlate, iStrip, fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip)));
772 //_____________________________________________________________________________
774 void AliTOFClusterFinderV1::FindOnePadClusterPerStrip(Int_t nSector,
779 // This function searches the isolated digits (stored in the fDigits object),
780 // to perform clusters (stored in the fTofClusters array).
781 // This research has been made by checking the fTOFdigitMap object,
782 // filled at digits/raw-data reading time.
785 const Int_t kMaxNumberOfTracksPerDigit = 3;
786 const Int_t kMaxNumberOfDigitsPerVolume = 10;
790 Int_t det[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padZ,padX
791 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padX,padZ
792 UShort_t volIdClus = 0;
795 for (jj=0; jj<3; jj++) pos[jj] = 0.;
797 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
800 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
803 for (jj=0; jj<7; jj++) parTOF[jj] = 0;
805 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
807 Int_t tracks[kMaxNumberOfTracksPerDigit];
808 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
810 Int_t dummyCounter=-1;
812 AliTOFdigit *digitInteresting;
816 for (iPadX=0; iPadX<AliTOFGeometry::NpadX(); iPadX++) {
817 for (iPadZ=0; iPadZ<AliTOFGeometry::NpadZ(); iPadZ++) {
818 vol[4] = iPadZ , vol[3] = iPadX;
820 AliDebug(3, Form(" %1d %2d\n", iPadZ, iPadX));
822 if (fTOFdigitMap->GetNumberOfDigits(vol)==0) continue;
824 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
825 if (fTOFdigitMap->GetDigitIndex(vol,digIndex)<0) continue;
826 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(fTOFdigitMap->GetDigitIndex(vol,digIndex));
828 AliDebug(2, Form(" %3d %5d %2d %1d %2d %1d %2d %d %d %d %5d %5d %5d %5d",
829 fTOFdigitMap->GetNumberOfDigits(vol), digIndex,
830 vol[0], vol[1], vol[2] ,vol[4], vol[3],
831 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
832 digitInteresting->GetToT(),
833 fTOFdigitMap->GetDigitIndex(vol,digIndex),
834 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
836 det[3] = vol[4]; // padz
837 det[4] = vol[3]; // padx
838 fTOFGeometry->GetPosPar(det,pos);
839 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
842 for (jj=0; jj<3; jj++) posClus[jj] = pos[jj];
844 parTOF[0] = Int_t(digitInteresting->GetTdc());
845 parTOF[1] = Int_t(digitInteresting->GetToT());
846 parTOF[2] = Int_t(digitInteresting->GetAdc());
847 parTOF[3] = Int_t(digitInteresting->GetTdcND());
848 parTOF[4] = Int_t(digitInteresting->GetTdc());
852 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
853 //volIdClus = GetClusterVolIndex(det);
855 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
856 GetClusterPars(det, posClus, covClus);
858 // To fill the track index array
860 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
861 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) { // three is the max number of tracks associated to one digit
862 if (digitInteresting->GetTrack(jj)==-1) continue;
865 tracks[dummyCounter] = digitInteresting->GetTrack(jj);
869 AliTOFcluster *tofCluster =
870 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
871 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
872 tracks, det, parTOF, status, fTOFdigitMap->GetDigitIndex(vol,digIndex));
873 InsertCluster(tofCluster);
875 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",
876 volIdClus, posClus[0], posClus[1], posClus[2],
877 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
878 tracks[0], tracks[1], tracks[2],
879 det[0], det[1], det[2], det[3], det[4],
880 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
881 status, fTOFdigitMap->GetDigitIndex(vol,digIndex)));
883 AliDebug(2, Form(" %f %f %f", pos[0], pos[1], pos[2]));
884 AliDebug(2, Form(" %d %d", parTOF[0], parTOF[2]));
886 fTOFdigitMap->ResetDigit(vol, digIndex);
894 //_____________________________________________________________________________
896 void AliTOFClusterFinderV1::FindClustersWithoutTOT(Int_t nSector,
901 // This function searches the isolated digits without TOT
902 // measurement (stored in the fDigits object), to perform clusters
903 // (stored in the fTofClusters array). This research has been made
904 // by checking the fTOFdigitMap object, filled at digits/raw-data
908 const Int_t kMaxNumberOfTracksPerDigit = 3;
909 const Int_t kMaxNumberOfDigitsPerVolume = 10;
913 Int_t det[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padZ,padX
914 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padX,padZ
915 UShort_t volIdClus = 0;
918 for (jj=0; jj<3; jj++) pos[jj] = 0.;
920 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
923 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
926 for (jj=0; jj<7; jj++) parTOF[jj] = 0;
928 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
929 Int_t tracks[kMaxNumberOfTracksPerDigit];
930 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
932 Int_t dummyCounter=-1;
934 AliTOFdigit *digitInteresting;
938 for (iPadX=0; iPadX<AliTOFGeometry::NpadX(); iPadX++) {
939 for (iPadZ=0; iPadZ<AliTOFGeometry::NpadZ(); iPadZ++) {
940 vol[4] = iPadZ , vol[3] = iPadX;
942 AliDebug(3, Form(" %1d %2d\n", iPadZ, iPadX));
944 if (fTOFdigitMap->GetNumberOfDigits(vol)==0) continue;
946 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
947 if (fTOFdigitMap->GetDigitIndex(vol,digIndex)<0) continue;
948 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(fTOFdigitMap->GetDigitIndex(vol,digIndex));
949 if (digitInteresting->GetToT()>0) continue; // AdC
951 AliDebug(2, Form(" %3d %5d %2d %1d %2d %1d %2d %d %d %d %5d %5d %5d %5d",
952 fTOFdigitMap->GetNumberOfDigits(vol), digIndex,
953 vol[0], vol[1], vol[2] ,vol[4], vol[3],
954 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
955 digitInteresting->GetToT(),
956 fTOFdigitMap->GetDigitIndex(vol,digIndex),
957 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
959 det[3] = vol[4]; // padz
960 det[4] = vol[3]; // padx
961 fTOFGeometry->GetPosPar(det,pos);
962 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
965 for (jj=0; jj<3; jj++) posClus[jj] = pos[jj];
967 parTOF[0] = Int_t(digitInteresting->GetTdc());
968 parTOF[1] = Int_t(digitInteresting->GetToT());
969 parTOF[2] = Int_t(digitInteresting->GetAdc());
970 parTOF[3] = Int_t(digitInteresting->GetTdcND());
971 parTOF[4] = Int_t(digitInteresting->GetTdc());
975 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
976 //volIdClus = GetClusterVolIndex(det);
978 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
979 GetClusterPars(det, posClus, covClus);
981 // To fill the track index array
983 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
984 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) { // three is the max number of tracks associated to one digit
985 if (digitInteresting->GetTrack(jj)==-1) continue;
988 tracks[dummyCounter] = digitInteresting->GetTrack(jj);
992 AliTOFcluster *tofCluster =
993 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
994 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
995 tracks, det, parTOF, status, fTOFdigitMap->GetDigitIndex(vol,digIndex));
996 InsertCluster(tofCluster);
998 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",
999 volIdClus, posClus[0], posClus[1], posClus[2],
1000 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1001 tracks[0], tracks[1], tracks[2],
1002 det[0], det[1], det[2], det[3], det[4],
1003 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
1004 status, fTOFdigitMap->GetDigitIndex(vol,digIndex)));
1006 AliDebug(2, Form(" %f %f %f", pos[0], pos[1], pos[2]));
1007 AliDebug(2, Form(" %d %d", parTOF[0], parTOF[2]));
1009 fTOFdigitMap->ResetDigit(vol, digIndex);
1017 //_____________________________________________________________________________
1019 void AliTOFClusterFinderV1::FindClusters34(Int_t nSector,
1024 // This function searches the neighbouring digits (stored in the fDigits object),
1025 // to perform clusters (stored in the fTofClusters array).
1027 // This research has been made by checking the fTOFdigitMap object,
1028 // filled at digits/raw-data reading time.
1031 const Int_t kMaxNumberOfInterestingPads = 4;
1032 const Int_t kMaxNumberOfTracksPerDigit = 3;
1033 const Int_t kMaxNumberOfDigitsPerVolume = 10;
1037 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
1038 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1039 digitsInVolumeIndices[ii] = -1;
1041 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
1043 Float_t pos[3] = {0.,0.,0.};
1046 Double_t interestingTOT[kMaxNumberOfInterestingPads];
1047 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
1048 Double_t interestingADC[kMaxNumberOfInterestingPads];
1049 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
1050 Double_t interestingTOF[kMaxNumberOfInterestingPads];
1051 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
1052 Double_t interestingWeight[kMaxNumberOfInterestingPads];
1053 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
1055 Float_t interestingX[kMaxNumberOfInterestingPads];
1056 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
1057 Float_t interestingY[kMaxNumberOfInterestingPads];
1058 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
1059 Float_t interestingZ[kMaxNumberOfInterestingPads];
1060 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
1062 Int_t padsCluster[11];
1063 padsCluster[0] = nSector;
1064 padsCluster[1] = nPlate;
1065 padsCluster[2] = nStrip;
1066 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1068 Int_t interestingCounter=-1;
1069 Int_t digitIndexLocal=-1; // AdC
1075 for (jj=0; jj<7; jj++) parTOF[jj] = 0;
1076 Double_t posClus[3];
1077 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
1079 for (jj=0; jj<5; jj++) det[jj] = -1;
1081 for (jj=0; jj<3; jj++) posF[jj] = 0.;
1082 UShort_t volIdClus = 0;
1083 Bool_t check = kFALSE;
1084 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
1085 Double_t covClus[6];
1086 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1087 Int_t tracks[kMaxNumberOfTracksPerDigit];
1088 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1089 Int_t dummyCounter=-1;
1090 Bool_t alreadyStored = kFALSE;
1092 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
1093 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1094 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
1096 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1097 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
1099 AliTOFdigit *digitInteresting;
1101 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
1103 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
1104 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
1106 AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
1113 interestingCounter=-1;
1115 vol[4] = iPadZ , vol[3] = iPadX;
1116 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1117 interestingCounter++;
1119 vol[4] = iPadZ, vol[3] = iPadX+1;
1120 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1121 interestingCounter++;
1123 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1124 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1125 interestingCounter++;
1127 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1128 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1129 interestingCounter++;
1131 if (interestingCounter+1!=4) continue; // the hit pads have to be 4
1132 else interestingCounter=-1;
1135 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1136 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1137 selectedDigit[ii][jj] = 0x0;
1140 vol[4] = iPadZ, vol[3] = iPadX;
1142 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1143 interestingCounter++;
1144 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1145 digitsInVolumeIndices[ii] = -1;
1146 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1147 digitIndexLocal=-1; // AdC
1148 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1149 if (digitsInVolumeIndices[digIndex]<0) continue;
1150 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1151 if (digitInteresting->GetToT()<=0) continue; // AdC
1152 digitIndexLocal++; // AdC
1154 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1155 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1156 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1157 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1158 digitsInVolumeIndices[digIndex],
1159 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1162 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1163 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1164 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1165 digitInteresting->GetToT()*digitInteresting->GetToT(),
1166 digitsInVolumeIndices[digIndex],
1167 digitInteresting->GetTracks());
1169 if (digitIndexLocal==-1) interestingCounter--; // AdC
1173 vol[4] = iPadZ, vol[3] = iPadX+1;
1175 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1176 interestingCounter++;
1177 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1178 digitsInVolumeIndices[ii] = -1;
1179 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1180 digitIndexLocal=-1; // AdC
1181 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1182 if (digitsInVolumeIndices[digIndex]<0) continue;
1183 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1184 if (digitInteresting->GetToT()<=0) continue; // AdC
1185 digitIndexLocal++; // AdC
1187 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1188 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1189 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1190 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1191 digitsInVolumeIndices[digIndex],
1192 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1195 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1196 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1197 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1198 digitInteresting->GetToT()*digitInteresting->GetToT(),
1199 digitsInVolumeIndices[digIndex],
1200 digitInteresting->GetTracks());
1202 if (digitIndexLocal==-1) interestingCounter--; // AdC
1206 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1208 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1209 interestingCounter++;
1210 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1211 digitsInVolumeIndices[ii] = -1;
1212 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1213 digitIndexLocal=-1; // AdC
1214 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1215 if (digitsInVolumeIndices[digIndex]<0) continue;
1216 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1217 if (digitInteresting->GetToT()<=0) continue; // AdC
1218 digitIndexLocal++; // AdC
1220 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1221 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1222 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1223 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1224 digitsInVolumeIndices[digIndex],
1225 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1228 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1229 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1230 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1231 digitInteresting->GetToT()*digitInteresting->GetToT(),
1232 digitsInVolumeIndices[digIndex],
1233 digitInteresting->GetTracks());
1235 if (digitIndexLocal==-1) interestingCounter--; // AdC
1239 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1241 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1242 interestingCounter++;
1243 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1244 digitsInVolumeIndices[ii] = -1;
1245 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1247 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1248 if (digitsInVolumeIndices[digIndex]<0) continue;
1249 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1250 if (digitInteresting->GetToT()<=0) continue; // AdC
1251 digitIndexLocal++; // AdC
1253 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1254 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1255 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1256 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1257 digitsInVolumeIndices[digIndex],
1258 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1260 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1261 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1262 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1263 digitInteresting->GetToT()*digitInteresting->GetToT(),
1264 digitsInVolumeIndices[digIndex],
1265 digitInteresting->GetTracks());
1267 if (digitIndexLocal==-1) interestingCounter--; // AdC
1270 AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
1272 for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
1273 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
1274 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
1276 for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
1277 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
1278 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
1280 for (Int_t adesso3=adesso2+1; adesso3<interestingCounter+1; adesso3++) {
1281 for (Int_t thirdIndex=0; thirdIndex<kMaxNumberOfDigitsPerVolume; thirdIndex++) {
1282 if (selectedDigit[adesso3][thirdIndex]==0x0) continue;
1285 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime
1287 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
1289 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime) continue;
1291 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
1292 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
1293 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
1294 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
1295 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
1296 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
1297 Int_t volDum = vol1[3];
1300 fTOFGeometry->GetPosPar(vol1,pos);
1301 interestingX[0] = pos[0];
1302 interestingY[0] = pos[1];
1303 interestingZ[0] = pos[2];
1305 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
1306 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
1307 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
1308 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
1309 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
1310 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
1314 fTOFGeometry->GetPosPar(vol2,pos);
1315 interestingX[1] = pos[0];
1316 interestingY[1] = pos[1];
1317 interestingZ[1] = pos[2];
1319 interestingTOF[2] = selectedDigit[adesso3][thirdIndex]->GetTDC();
1320 interestingTOT[2] = selectedDigit[adesso3][thirdIndex]->GetTOT();
1321 interestingADC[2] = selectedDigit[adesso3][thirdIndex]->GetADC();
1322 interestingWeight[2] = selectedDigit[adesso3][thirdIndex]->GetWeight();
1323 Int_t vol3[5]; for(jj=0; jj<5; jj++) vol3[jj] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(jj);
1324 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol3[0], vol3[1], vol3[2], vol3[4], vol3[3]));
1328 fTOFGeometry->GetPosPar(vol3,pos);
1329 interestingX[2] = pos[0];
1330 interestingY[2] = pos[1];
1331 interestingZ[2] = pos[2];
1334 AverageCalculations(3, interestingX, interestingY, interestingZ,
1335 interestingTOF, interestingTOT, interestingADC,
1337 parTOF, posClus, check);
1340 for (jj=0; jj<5; jj++) det[jj] = -1;
1341 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
1342 fTOFGeometry->GetDetID(posF, det);
1344 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
1345 //volIdClus = GetClusterVolIndex(det);
1347 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1348 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
1349 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
1350 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
1351 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
1352 padsCluster[7] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(4);
1353 padsCluster[8] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(3);
1355 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1356 Int_t ** indDet = new Int_t*[3];
1357 for (jj=0; jj<3; jj++) indDet[jj] = new Int_t [5];
1358 for (jj=0; jj<3; jj++) indDet[jj][0] = nSector;
1359 for (jj=0; jj<3; jj++) indDet[jj][1] = nPlate;
1360 for (jj=0; jj<3; jj++) indDet[jj][2] = nStrip;
1361 for (jj=0; jj<3; jj++) indDet[jj][3] = padsCluster[2*jj+3];
1362 for (jj=0; jj<3; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
1363 GetClusterPars(/*check,*/ 3, indDet, interestingWeight, posClus, covClus);
1364 for (jj=0; jj<3; jj++) delete [] indDet[jj];
1367 // To fill the track index array
1369 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1370 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1371 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
1374 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
1377 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1378 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
1381 alreadyStored = kFALSE;
1382 for (jj=0; jj<dummyCounter+1; jj++)
1383 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
1385 if (alreadyStored) continue;
1386 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
1387 AliWarning(" Siamo al limite!");
1392 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
1397 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1398 if (selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk)==-1) continue;
1401 alreadyStored = kFALSE;
1402 for (jj=0; jj<dummyCounter+1; jj++)
1403 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk));
1405 if (alreadyStored) continue;
1406 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
1407 AliWarning(" Siamo al limite!");
1412 tracks[dummyCounter] = selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk);
1419 AliTOFcluster *tofCluster =
1420 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
1421 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1422 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
1423 InsertCluster(tofCluster);
1425 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",
1426 volIdClus, posClus[0], posClus[1], posClus[2],
1427 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1428 tracks[0], tracks[1], tracks[2],
1429 det[0], det[1], det[2], det[3], det[4],
1430 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
1431 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
1437 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
1441 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
1445 fTOFdigitMap->ResetDigitNumber(vol3,selectedDigit[adesso3][thirdIndex]->GetIndex());
1448 } // close loop on third digit
1449 } // close loop on adesso3
1451 } // close loop on second digit
1452 } // close loop on adesso2
1454 } // close loop on first digit
1455 } // close loop on adesso1
1457 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1458 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1459 selectedDigit[ii][jj] = 0x0;
1463 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++) {
1464 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
1465 delete [] selectedDigit[ii][jj];
1466 selectedDigit[ii][jj] = 0x0;
1468 delete [] selectedDigit[ii];
1469 selectedDigit[ii] = 0x0;
1471 delete [] selectedDigit;
1472 selectedDigit = 0x0;
1475 //_____________________________________________________________________________
1477 void AliTOFClusterFinderV1::FindClusters23(Int_t nSector,
1482 // This function searches the neighbouring digits (stored in the fDigits object),
1483 // to perform clusters (stored in the fTofClusters array).
1485 // This research has been made by checking the fTOFdigitMap object,
1486 // filled at digits/raw-data reading time.
1489 const Int_t kMaxNumberOfInterestingPads = 4;
1490 const Int_t kMaxNumberOfTracksPerDigit = 3;
1491 const Int_t kMaxNumberOfDigitsPerVolume = 10;
1495 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
1496 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1497 digitsInVolumeIndices[ii] = -1;
1499 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
1501 Float_t pos[3] = {0.,0.,0.};
1504 Double_t interestingTOT[kMaxNumberOfInterestingPads];
1505 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
1506 Double_t interestingADC[kMaxNumberOfInterestingPads];
1507 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
1508 Double_t interestingTOF[kMaxNumberOfInterestingPads];
1509 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
1510 Double_t interestingWeight[kMaxNumberOfInterestingPads];
1511 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
1513 Float_t interestingX[kMaxNumberOfInterestingPads];
1514 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
1515 Float_t interestingY[kMaxNumberOfInterestingPads];
1516 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
1517 Float_t interestingZ[kMaxNumberOfInterestingPads];
1518 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
1520 Int_t padsCluster[11];
1521 padsCluster[0] = nSector;
1522 padsCluster[1] = nPlate;
1523 padsCluster[2] = nStrip;
1524 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1526 Int_t interestingCounter=-1;
1527 Int_t digitIndexLocal = -1;
1532 Bool_t check = kFALSE;
1534 for (jj=0; jj<7; jj++) parTOF[jj] = 0;
1535 Double_t posClus[3];
1536 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
1538 for (jj=0; jj<5; jj++) det[jj] = -1;
1540 for (jj=0; jj<3; jj++) posF[jj] = 0.;
1541 UShort_t volIdClus = 0;
1542 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
1543 Double_t covClus[6];
1544 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1545 Int_t tracks[kMaxNumberOfTracksPerDigit];
1546 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1547 Int_t dummyCounter=-1;
1548 Bool_t alreadyStored = kFALSE;
1550 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
1551 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1552 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
1554 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1555 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
1557 AliTOFdigit *digitInteresting;
1559 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
1561 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
1562 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
1564 AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
1571 interestingCounter=-1;
1573 vol[4] = iPadZ , vol[3] = iPadX;
1574 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1575 interestingCounter++;
1577 vol[4] = iPadZ, vol[3] = iPadX+1;
1578 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1579 interestingCounter++;
1581 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1582 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1583 interestingCounter++;
1585 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1586 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1587 interestingCounter++;
1589 if (interestingCounter+1!=3) continue; // the hit pads have to be 3
1590 else interestingCounter=-1;
1593 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1594 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1595 selectedDigit[ii][jj] = 0x0;
1598 vol[4] = iPadZ, vol[3] = iPadX;
1600 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1601 interestingCounter++;
1602 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1603 digitsInVolumeIndices[ii] = -1;
1604 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1606 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1607 if (digitsInVolumeIndices[digIndex]<0) continue;
1608 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1609 if (digitInteresting->GetToT()<=0) continue; // AdC
1610 digitIndexLocal++; // AdC
1612 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1613 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1614 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1615 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1616 digitsInVolumeIndices[digIndex],
1617 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1619 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1620 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1621 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1622 digitInteresting->GetToT()*digitInteresting->GetToT(),
1623 digitsInVolumeIndices[digIndex],
1624 digitInteresting->GetTracks());
1626 if (digitIndexLocal==-1) interestingCounter--; // AdC
1630 vol[4] = iPadZ, vol[3] = iPadX+1;
1632 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1633 interestingCounter++;
1634 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1635 digitsInVolumeIndices[ii] = -1;
1636 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1637 digitIndexLocal=-1; // AdC
1638 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1639 if (digitsInVolumeIndices[digIndex]<0) continue;
1640 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1641 if (digitInteresting->GetToT()<=0) continue; // AdC
1642 digitIndexLocal++; // AdC
1644 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1645 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1646 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1647 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1648 digitsInVolumeIndices[digIndex],
1649 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1651 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1652 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1653 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1654 digitInteresting->GetToT()*digitInteresting->GetToT(),
1655 digitsInVolumeIndices[digIndex],
1656 digitInteresting->GetTracks());
1658 if (digitIndexLocal==-1) interestingCounter--; // AdC
1662 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1664 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1665 interestingCounter++;
1666 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1667 digitsInVolumeIndices[ii] = -1;
1668 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1669 digitIndexLocal=-1; // AdC
1670 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1671 if (digitsInVolumeIndices[digIndex]<0) continue;
1672 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1673 if (digitInteresting->GetToT()<=0) continue; // AdC
1674 digitIndexLocal++; // AdC
1676 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1677 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1678 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1679 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1680 digitsInVolumeIndices[digIndex],
1681 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1683 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1684 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1685 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1686 digitInteresting->GetToT()*digitInteresting->GetToT(),
1687 digitsInVolumeIndices[digIndex],
1688 digitInteresting->GetTracks());
1690 if (digitIndexLocal==-1) interestingCounter--; // AdC
1694 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1696 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1697 interestingCounter++;
1698 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1699 digitsInVolumeIndices[ii] = -1;
1700 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1701 digitIndexLocal=-1; // AdC
1702 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1703 if (digitsInVolumeIndices[digIndex]<0) continue;
1704 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1705 if (digitInteresting->GetToT()<=0) continue; // AdC
1706 digitIndexLocal++; // AdC
1708 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1709 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1710 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1711 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1712 digitsInVolumeIndices[digIndex],
1713 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1715 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1716 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1717 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1718 digitInteresting->GetToT()*digitInteresting->GetToT(),
1719 digitsInVolumeIndices[digIndex],
1720 digitInteresting->GetTracks());
1722 if (digitIndexLocal==-1) interestingCounter--; // AdC
1725 AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
1727 for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
1728 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
1729 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
1731 for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
1732 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
1733 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
1735 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime) continue;
1737 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
1738 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
1739 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
1740 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
1741 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
1742 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
1743 Int_t volDum = vol1[3];
1746 fTOFGeometry->GetPosPar(vol1,pos);
1747 interestingX[0] = pos[0];
1748 interestingY[0] = pos[1];
1749 interestingZ[0] = pos[2];
1751 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
1752 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
1753 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
1754 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
1755 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
1756 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
1760 fTOFGeometry->GetPosPar(vol2,pos);
1761 interestingX[1] = pos[0];
1762 interestingY[1] = pos[1];
1763 interestingZ[1] = pos[2];
1765 AverageCalculations(2, interestingX, interestingY, interestingZ,
1766 interestingTOF, interestingTOT, interestingADC,
1768 parTOF, posClus, check);
1770 for (jj=0; jj<5; jj++) det[jj] = -1;
1771 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
1772 fTOFGeometry->GetDetID(posF, det);
1774 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
1775 //volIdClus = GetClusterVolIndex(det);
1777 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1778 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
1779 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
1780 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
1781 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
1783 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1784 Int_t ** indDet = new Int_t*[2];
1785 for (jj=0; jj<2; jj++) indDet[jj] = new Int_t [5];
1786 for (jj=0; jj<2; jj++) indDet[jj][0] = nSector;
1787 for (jj=0; jj<2; jj++) indDet[jj][1] = nPlate;
1788 for (jj=0; jj<2; jj++) indDet[jj][2] = nStrip;
1789 for (jj=0; jj<2; jj++) indDet[jj][3] = padsCluster[2*jj+3];
1790 for (jj=0; jj<2; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
1791 GetClusterPars(/*check,*/ 2, indDet, interestingWeight, posClus, covClus);
1792 for (jj=0; jj<2; jj++) delete [] indDet[jj];
1795 // To fill the track index array
1797 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1798 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1799 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
1802 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
1805 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1806 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
1809 alreadyStored = kFALSE;
1810 for (jj=0; jj<dummyCounter+1; jj++)
1811 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
1813 if (alreadyStored) continue;
1814 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
1815 AliWarning(" Siamo al limite!");
1820 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
1827 AliTOFcluster *tofCluster =
1828 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
1829 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1830 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
1831 InsertCluster(tofCluster);
1833 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",
1834 volIdClus, posClus[0], posClus[1], posClus[2],
1835 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1836 tracks[0], tracks[1], tracks[2],
1837 det[0], det[1], det[2], det[3], det[4],
1838 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
1839 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
1844 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
1848 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
1851 } // close loop on second digit
1852 } // close loop on adesso2
1854 } // close loop on first digit
1855 } // close loop on adesso1
1857 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1858 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1859 selectedDigit[ii][jj] = 0x0;
1863 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++) {
1864 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
1865 delete [] selectedDigit[ii][jj];
1866 selectedDigit[ii][jj] = 0x0;
1868 delete [] selectedDigit[ii];
1869 selectedDigit[ii] = 0x0;
1871 delete [] selectedDigit;
1872 selectedDigit = 0x0;
1875 //_____________________________________________________________________________
1877 void AliTOFClusterFinderV1::FindClusters24(Int_t nSector,
1882 // This function searches the neighbouring digits (stored in the fDigits object),
1883 // to perform clusters (stored in the fTofClusters array).
1885 // This research has been made by checking the fTOFdigitMap object,
1886 // filled at digits/raw-data reading time.
1889 const Int_t kMaxNumberOfInterestingPads = 4;
1890 const Int_t kMaxNumberOfTracksPerDigit = 3;
1891 const Int_t kMaxNumberOfDigitsPerVolume = 10;
1895 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
1896 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1897 digitsInVolumeIndices[ii] = -1;
1899 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
1901 Float_t pos[3] = {0.,0.,0.};
1904 Double_t interestingTOT[kMaxNumberOfInterestingPads];
1905 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
1906 Double_t interestingADC[kMaxNumberOfInterestingPads];
1907 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
1908 Double_t interestingTOF[kMaxNumberOfInterestingPads];
1909 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
1910 Double_t interestingWeight[kMaxNumberOfInterestingPads];
1911 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
1913 Float_t interestingX[kMaxNumberOfInterestingPads];
1914 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
1915 Float_t interestingY[kMaxNumberOfInterestingPads];
1916 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
1917 Float_t interestingZ[kMaxNumberOfInterestingPads];
1918 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
1920 Int_t padsCluster[11];
1921 padsCluster[0] = nSector;
1922 padsCluster[1] = nPlate;
1923 padsCluster[2] = nStrip;
1924 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1926 Int_t interestingCounter=-1;
1927 Int_t digitIndexLocal = -1;
1932 Bool_t check = kFALSE;
1934 for (jj=0; jj<7; jj++) parTOF[jj] = 0;
1935 Double_t posClus[3];
1936 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
1938 for (jj=0; jj<5; jj++) det[jj] = -1;
1940 for (jj=0; jj<3; jj++) posF[jj] = 0.;
1941 UShort_t volIdClus = 0;
1942 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
1943 Double_t covClus[6];
1944 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1945 Int_t tracks[kMaxNumberOfTracksPerDigit];
1946 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1947 Int_t dummyCounter=-1;
1948 Bool_t alreadyStored = kFALSE;
1950 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
1951 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1952 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
1954 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1955 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
1957 AliTOFdigit *digitInteresting;
1959 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
1961 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
1962 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
1964 AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
1971 interestingCounter=-1;
1973 vol[4] = iPadZ , vol[3] = iPadX;
1974 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1975 interestingCounter++;
1977 vol[4] = iPadZ, vol[3] = iPadX+1;
1978 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1979 interestingCounter++;
1981 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1982 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1983 interestingCounter++;
1985 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1986 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1987 interestingCounter++;
1989 if (interestingCounter+1!=4) continue; // the hit pads have to be 4
1990 else interestingCounter=-1;
1993 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1994 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1995 selectedDigit[ii][jj] = 0x0;
1998 vol[4] = iPadZ, vol[3] = iPadX;
2000 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2001 interestingCounter++;
2002 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2003 digitsInVolumeIndices[ii] = -1;
2004 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2005 digitIndexLocal=-1; // AdC
2006 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2007 if (digitsInVolumeIndices[digIndex]<0) continue;
2008 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2009 if (digitInteresting->GetToT()<=0) continue; // AdC
2010 digitIndexLocal++; // AdC
2012 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2013 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2014 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2015 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2016 digitsInVolumeIndices[digIndex],
2017 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2019 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2020 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2021 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2022 digitInteresting->GetToT()*digitInteresting->GetToT(),
2023 digitsInVolumeIndices[digIndex],
2024 digitInteresting->GetTracks());
2026 if (digitIndexLocal==-1) interestingCounter--; // AdC
2030 vol[4] = iPadZ, vol[3] = iPadX+1;
2032 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2033 interestingCounter++;
2034 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2035 digitsInVolumeIndices[ii] = -1;
2036 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2037 digitIndexLocal=-1; // AdC
2038 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2039 if (digitsInVolumeIndices[digIndex]<0) continue;
2040 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2041 if (digitInteresting->GetToT()<=0) continue; // AdC
2042 digitIndexLocal++; // AdC
2044 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2045 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2046 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2047 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2048 digitsInVolumeIndices[digIndex],
2049 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2051 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2052 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2053 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2054 digitInteresting->GetToT()*digitInteresting->GetToT(),
2055 digitsInVolumeIndices[digIndex],
2056 digitInteresting->GetTracks());
2058 if (digitIndexLocal==-1) interestingCounter--; // AdC
2062 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
2064 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2065 interestingCounter++;
2066 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2067 digitsInVolumeIndices[ii] = -1;
2068 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2069 digitIndexLocal=-1; // AdC
2070 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2071 if (digitsInVolumeIndices[digIndex]<0) continue;
2072 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2073 if (digitInteresting->GetToT()<=0) continue; // AdC
2074 digitIndexLocal++; // AdC
2076 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2077 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2078 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2079 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2080 digitsInVolumeIndices[digIndex],
2081 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2083 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2084 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2085 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2086 digitInteresting->GetToT()*digitInteresting->GetToT(),
2087 digitsInVolumeIndices[digIndex],
2088 digitInteresting->GetTracks());
2090 if (digitIndexLocal==-1) interestingCounter--; // AdC
2094 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
2096 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2097 interestingCounter++;
2098 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2099 digitsInVolumeIndices[ii] = -1;
2100 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2101 digitIndexLocal=-1; // AdC
2102 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2103 if (digitsInVolumeIndices[digIndex]<0) continue;
2104 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2105 if (digitInteresting->GetToT()<=0) continue; // AdC
2106 digitIndexLocal++; // AdC
2108 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2109 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2110 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2111 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2112 digitsInVolumeIndices[digIndex],
2113 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2115 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2116 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2117 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2118 digitInteresting->GetToT()*digitInteresting->GetToT(),
2119 digitsInVolumeIndices[digIndex],
2120 digitInteresting->GetTracks());
2122 if (digitIndexLocal==-1) interestingCounter--; // AdC
2125 AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
2127 for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
2128 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2129 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2131 for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
2132 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2133 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2135 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime) continue;
2137 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2138 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2139 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2140 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2141 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
2142 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
2143 Int_t volDum = vol1[3];
2146 fTOFGeometry->GetPosPar(vol1,pos);
2147 interestingX[0] = pos[0];
2148 interestingY[0] = pos[1];
2149 interestingZ[0] = pos[2];
2151 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2152 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2153 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2154 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2155 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
2156 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
2160 fTOFGeometry->GetPosPar(vol2,pos);
2161 interestingX[1] = pos[0];
2162 interestingY[1] = pos[1];
2163 interestingZ[1] = pos[2];
2166 AverageCalculations(2, interestingX, interestingY, interestingZ,
2167 interestingTOF, interestingTOT, interestingADC,
2169 parTOF, posClus, check);
2171 for (jj=0; jj<5; jj++) det[jj] = -1;
2172 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
2173 fTOFGeometry->GetDetID(posF, det);
2175 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
2176 //volIdClus = GetClusterVolIndex(det);
2178 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2179 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
2180 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
2181 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
2182 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
2184 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2185 Int_t ** indDet = new Int_t*[2];
2186 for (jj=0; jj<2; jj++) indDet[jj] = new Int_t [5];
2187 for (jj=0; jj<2; jj++) indDet[jj][0] = nSector;
2188 for (jj=0; jj<2; jj++) indDet[jj][1] = nPlate;
2189 for (jj=0; jj<2; jj++) indDet[jj][2] = nStrip;
2190 for (jj=0; jj<2; jj++) indDet[jj][3] = padsCluster[2*jj+3];
2191 for (jj=0; jj<2; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
2192 GetClusterPars(/*check,*/ 2, indDet, interestingWeight, posClus, covClus);
2193 for (jj=0; jj<2; jj++) delete [] indDet[jj];
2196 // To fill the track index array
2198 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2199 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2200 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
2203 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
2206 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2207 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
2210 alreadyStored = kFALSE;
2211 for (jj=0; jj<dummyCounter+1; jj++)
2212 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
2214 if (alreadyStored) continue;
2215 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2216 AliWarning(" Siamo al limite!");
2221 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
2228 AliTOFcluster *tofCluster =
2229 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
2230 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2231 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
2232 InsertCluster(tofCluster);
2234 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",
2235 volIdClus, posClus[0], posClus[1], posClus[2],
2236 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2237 tracks[0], tracks[1], tracks[2],
2238 det[0], det[1], det[2], det[3], det[4],
2239 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
2240 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
2245 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
2249 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
2252 } // close loop on second digit
2253 } // close loop on adesso2
2255 } // close loop on first digit
2256 } // close loop on adesso1
2258 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2259 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
2260 selectedDigit[ii][jj] = 0x0;
2264 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++) {
2265 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
2266 delete [] selectedDigit[ii][jj];
2267 selectedDigit[ii][jj] = 0x0;
2269 delete [] selectedDigit[ii];
2270 selectedDigit[ii] = 0x0;
2272 delete [] selectedDigit;
2273 selectedDigit = 0x0;
2276 //_____________________________________________________________________________
2278 void AliTOFClusterFinderV1::FindClustersPerStrip(Int_t nSector,
2284 // This function searches the neighbouring digits (stored in the fDigits object),
2285 // to perform clusters (stored in the fTofClusters array).
2287 // Each strip is read four times:
2288 // - 1st time: it searches possible clusters formed by four
2289 // neighbouring digits;
2290 // - 2nd time: it searches possible clusters formed by three
2291 // neighbouring digits;
2292 // - 3rd time: it searches possible clusters formed by two
2293 // neighbouring digits;
2294 // - 4th time: the remaining isolated digits have been transformed
2296 // This research has been made by checking the fTOFdigitMap object,
2297 // filled at digits/raw-data reading time.
2300 const Int_t kMaxNumberOfInterestingPads = 4;
2301 const Int_t kMaxNumberOfTracksPerDigit = 3;
2302 const Int_t kMaxNumberOfDigitsPerVolume = 10;
2306 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
2307 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2308 digitsInVolumeIndices[ii] = -1;
2310 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
2312 Float_t pos[3] = {0.,0.,0.};
2315 Double_t interestingTOT[kMaxNumberOfInterestingPads];
2316 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
2317 Double_t interestingADC[kMaxNumberOfInterestingPads];
2318 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
2319 Double_t interestingTOF[kMaxNumberOfInterestingPads];
2320 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
2321 Double_t interestingWeight[kMaxNumberOfInterestingPads];
2322 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
2324 Float_t interestingX[kMaxNumberOfInterestingPads];
2325 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
2326 Float_t interestingY[kMaxNumberOfInterestingPads];
2327 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
2328 Float_t interestingZ[kMaxNumberOfInterestingPads];
2329 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
2331 Int_t padsCluster[11];
2332 padsCluster[0] = nSector;
2333 padsCluster[1] = nPlate;
2334 padsCluster[2] = nStrip;
2335 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2337 Int_t interestingCounter=-1;
2338 Int_t digitIndexLocal = -1;
2343 Bool_t check = kFALSE;
2345 for (jj=0; jj<7; jj++) parTOF[jj] = 0;
2346 Double_t posClus[3];
2347 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
2349 for (jj=0; jj<5; jj++) det[jj] = -1;
2351 for (jj=0; jj<3; jj++) posF[jj] = 0.;
2352 UShort_t volIdClus = 0;
2353 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
2354 Double_t covClus[6];
2355 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2356 Int_t tracks[kMaxNumberOfTracksPerDigit];
2357 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2358 Int_t dummyCounter=-1;
2359 Bool_t alreadyStored = kFALSE;
2361 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
2362 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2363 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
2365 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2366 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
2368 AliTOFdigit *digitInteresting;
2372 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
2374 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
2375 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
2377 AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
2384 interestingCounter=-1;
2386 vol[4] = iPadZ , vol[3] = iPadX;
2387 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2388 interestingCounter++;
2390 vol[4] = iPadZ, vol[3] = iPadX+1;
2391 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2392 interestingCounter++;
2394 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
2395 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2396 interestingCounter++;
2398 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
2399 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2400 interestingCounter++;
2402 if (interestingCounter!=group) continue;
2403 else interestingCounter=-1;
2406 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2407 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
2408 selectedDigit[ii][jj] = 0x0;
2411 vol[4] = iPadZ, vol[3] = iPadX;
2413 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2414 interestingCounter++;
2415 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2416 digitsInVolumeIndices[ii] = -1;
2417 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2418 digitIndexLocal=-1; // AdC
2419 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2420 if (digitsInVolumeIndices[digIndex]<0) continue;
2421 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2422 if (digitInteresting->GetToT()<=0) continue; // AdC
2423 digitIndexLocal++; // AdC
2425 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2426 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2427 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2428 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2429 digitsInVolumeIndices[digIndex],
2430 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2431 AliDebug(1,Form(" to try %d %d ",digIndex, interestingCounter));
2433 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2434 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2435 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2436 digitInteresting->GetToT()*digitInteresting->GetToT(),
2437 digitsInVolumeIndices[digIndex],
2438 digitInteresting->GetTracks());
2440 if (digitIndexLocal==-1) interestingCounter--; // AdC
2444 vol[4] = iPadZ, vol[3] = iPadX+1;
2446 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2447 interestingCounter++;
2448 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2449 digitsInVolumeIndices[ii] = -1;
2450 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2451 digitIndexLocal=-1; // AdC
2452 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2453 if (digitsInVolumeIndices[digIndex]<0) continue;
2454 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2455 if (digitInteresting->GetToT()<=0) continue; // AdC
2456 digitIndexLocal++; // AdC
2458 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2459 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2460 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2461 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2462 digitsInVolumeIndices[digIndex],
2463 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2464 AliDebug(1,Form(" to try %d %d ",digIndex, interestingCounter));
2466 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2467 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2468 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2469 digitInteresting->GetToT()*digitInteresting->GetToT(),
2470 digitsInVolumeIndices[digIndex],
2471 digitInteresting->GetTracks());
2473 if (digitIndexLocal==-1) interestingCounter--; // AdC
2477 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
2479 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2480 interestingCounter++;
2481 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2482 digitsInVolumeIndices[ii] = -1;
2483 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2484 digitIndexLocal=-1; // AdC
2485 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2486 if (digitsInVolumeIndices[digIndex]<0) continue;
2487 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2488 if (digitInteresting->GetToT()<=0) continue; // AdC
2489 digitIndexLocal++; // AdC
2491 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2492 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2493 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2494 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2495 digitsInVolumeIndices[digIndex],
2496 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2497 AliDebug(1,Form(" to try %d %d ",digIndex, interestingCounter));
2499 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2500 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2501 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2502 digitInteresting->GetToT()*digitInteresting->GetToT(),
2503 digitsInVolumeIndices[digIndex],
2504 digitInteresting->GetTracks());
2506 if (digitIndexLocal==-1) interestingCounter--; // AdC
2510 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
2512 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2513 interestingCounter++;
2514 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2515 digitsInVolumeIndices[ii] = -1;
2516 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2517 digitIndexLocal=-1; // AdC
2518 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2519 if (digitsInVolumeIndices[digIndex]<0) continue;
2520 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2521 if (digitInteresting->GetToT()<=0) continue; // AdC
2522 digitIndexLocal++; // AdC
2524 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2525 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2526 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2527 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2528 digitsInVolumeIndices[digIndex],
2529 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2530 AliDebug(1,Form(" to try %d %d ",digIndex, interestingCounter));
2532 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2533 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2534 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2535 digitInteresting->GetToT()*digitInteresting->GetToT(),
2536 digitsInVolumeIndices[digIndex],
2537 digitInteresting->GetTracks());
2539 if (digitIndexLocal==-1) interestingCounter--; // AdC
2542 AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
2549 switch(interestingCounter+1) {
2553 //for (adesso1=0; adesso1<interestingCounter+1; adesso1++) {
2555 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2556 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2558 //for (adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
2560 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2561 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2563 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime) {
2564 AliDebug(1,Form(" selD1[%d][%d]->GetTDC()=%d selD2[%d][%d]->GetTDC()=%d -- %d ",
2565 adesso1,firstIndex,(Int_t)selectedDigit[adesso1][firstIndex]->GetTDC(),
2566 adesso2,secondIndex,(Int_t)selectedDigit[adesso2][secondIndex]->GetTDC(),
2571 AliDebug(1, Form(" %1d %1d (0x%p) %1d %1d (0x%p)", adesso1, firstIndex,selectedDigit[adesso1][firstIndex],
2572 adesso2, secondIndex,selectedDigit[adesso2][secondIndex]));
2574 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2575 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2576 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2577 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2578 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
2579 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
2580 Int_t volDum = vol1[3];
2583 fTOFGeometry->GetPosPar(vol1,pos);
2584 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
2585 interestingX[0] = pos[0];
2586 interestingY[0] = pos[1];
2587 interestingZ[0] = pos[2];
2589 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2590 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2591 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2592 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2593 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
2594 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
2598 fTOFGeometry->GetPosPar(vol2,pos);
2599 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
2600 interestingX[1] = pos[0];
2601 interestingY[1] = pos[1];
2602 interestingZ[1] = pos[2];
2605 AverageCalculations(interestingCounter+1,
2606 interestingX, interestingY, interestingZ,
2607 interestingTOF, interestingTOT, interestingADC,
2609 parTOF, posClus, check);
2611 for (jj=0; jj<5; jj++) det[jj] = -1;
2612 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
2614 AliDebug(1,Form(" %f %f %f", posF[0], posF[1], posF[2]));
2615 fTOFGeometry->GetDetID(posF, det);
2616 AliDebug(1,Form(" %2d %1d %2d %1d %2d", det[0], det[1], det[2], det[3], det[4]));
2618 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
2619 //volIdClus = GetClusterVolIndex(det);
2621 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2622 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
2623 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
2624 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
2625 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
2627 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2628 Int_t ** indDet = new Int_t*[interestingCounter+1];
2629 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj] = new Int_t [5];
2630 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][0] = nSector;
2631 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][1] = nPlate;
2632 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][2] = nStrip;
2633 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][3] = padsCluster[2*jj+3];
2634 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
2635 GetClusterPars(/*check,*/ interestingCounter+1, indDet, interestingWeight, posClus, covClus);
2636 for (jj=0; jj<interestingCounter+1; jj++) delete [] indDet[jj];
2639 // To fill the track index array
2641 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2642 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2643 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
2646 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
2649 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2650 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
2653 alreadyStored = kFALSE;
2654 for (jj=0; jj<dummyCounter+1; jj++)
2655 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
2657 if (alreadyStored) continue;
2658 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2659 AliWarning(" Siamo al limite!");
2664 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
2671 AliTOFcluster *tofCluster =
2672 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
2673 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2674 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); //to updated
2675 InsertCluster(tofCluster);
2677 AliDebug(2, Form(" %4d %f %f %f %f %f %f %f %f %f %3d %3d %3d %2d %1d %2d %1d %2d %4d %3d %3d %4d %4d %1d %4d",
2678 volIdClus, posClus[0], posClus[1], posClus[2],
2679 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2680 tracks[0], tracks[1], tracks[2],
2681 det[0], det[1], det[2], det[3], det[4],
2682 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
2683 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
2688 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
2692 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
2695 } // close loop on second digit
2696 //} // close loop on adesso2
2698 } // close loop on first digit
2699 //} // close loop on adesso1
2706 //for (adesso1=0; adesso1<interestingCounter+1; adesso1++) {
2708 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2709 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2711 //for (adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
2713 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2714 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2716 //for (adesso3=adesso2+1; adesso3<interestingCounter+1; adesso3++) {
2718 for (Int_t thirdIndex=0; thirdIndex<kMaxNumberOfDigitsPerVolume; thirdIndex++) {
2719 if (selectedDigit[adesso3][thirdIndex]==0x0) continue;
2722 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime
2724 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
2726 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime) continue;
2728 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2729 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2730 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2731 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2732 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
2733 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
2734 Int_t volDum = vol1[3];
2737 fTOFGeometry->GetPosPar(vol1,pos);
2738 interestingX[0] = pos[0];
2739 interestingY[0] = pos[1];
2740 interestingZ[0] = pos[2];
2742 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2743 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2744 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2745 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2746 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
2747 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
2751 fTOFGeometry->GetPosPar(vol2,pos);
2752 interestingX[1] = pos[0];
2753 interestingY[1] = pos[1];
2754 interestingZ[1] = pos[2];
2756 interestingTOF[2] = selectedDigit[adesso3][thirdIndex]->GetTDC();
2757 interestingTOT[2] = selectedDigit[adesso3][thirdIndex]->GetTOT();
2758 interestingADC[2] = selectedDigit[adesso3][thirdIndex]->GetADC();
2759 interestingWeight[2] = selectedDigit[adesso3][thirdIndex]->GetWeight();
2760 Int_t vol3[5]; for(jj=0; jj<5; jj++) vol3[jj] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(jj);
2761 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol3[0], vol3[1], vol3[2], vol3[4], vol3[3]));
2765 fTOFGeometry->GetPosPar(vol3,pos);
2766 interestingX[2] = pos[0];
2767 interestingY[2] = pos[1];
2768 interestingZ[2] = pos[2];
2771 AverageCalculations(interestingCounter+1,
2772 interestingX, interestingY, interestingZ,
2773 interestingTOF, interestingTOT, interestingADC,
2775 parTOF, posClus, check);
2777 for (jj=0; jj<5; jj++) det[jj] = -1;
2778 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
2779 fTOFGeometry->GetDetID(posF, det);
2781 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
2782 //volIdClus = GetClusterVolIndex(det);
2784 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2785 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
2786 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
2787 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
2788 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
2789 padsCluster[7] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(4);
2790 padsCluster[8] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(3);
2792 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2793 Int_t ** indDet = new Int_t*[interestingCounter+1];
2794 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj] = new Int_t [5];
2795 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][0] = nSector;
2796 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][1] = nPlate;
2797 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][2] = nStrip;
2798 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][3] = padsCluster[2*jj+3];
2799 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
2800 GetClusterPars(/*check,*/ interestingCounter+1, indDet, interestingWeight, posClus, covClus);
2801 for (jj=0; jj<interestingCounter+1; jj++) delete [] indDet[jj];
2805 // To fill the track index array
2807 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2808 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2809 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
2812 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
2815 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2816 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
2819 alreadyStored = kFALSE;
2820 for (jj=0; jj<dummyCounter+1; jj++)
2821 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
2823 if (alreadyStored) continue;
2824 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2825 AliWarning(" Siamo al limite!");
2830 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
2835 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2836 if (selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk)==-1) continue;
2839 alreadyStored = kFALSE;
2840 for (jj=0; jj<dummyCounter+1; jj++)
2841 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk));
2843 if (alreadyStored) continue;
2844 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2845 AliWarning(" Siamo al limite!");
2850 tracks[dummyCounter] = selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk);
2857 AliTOFcluster *tofCluster =
2858 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
2859 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2860 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
2861 InsertCluster(tofCluster);
2863 AliDebug(2, Form(" %4d %f %f %f %f %f %f %f %f %f %3d %3d %3d %2d %1d %2d %1d %2d %4d %3d %3d %4d %4d %1d %4d",
2864 volIdClus, posClus[0], posClus[1], posClus[2],
2865 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2866 tracks[0], tracks[1], tracks[2],
2867 det[0], det[1], det[2], det[3], det[4],
2868 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
2869 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
2874 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
2878 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
2882 fTOFdigitMap->ResetDigitNumber(vol3,selectedDigit[adesso3][thirdIndex]->GetIndex());
2885 } // close loop on third digit
2886 //} // close loop on adesso3
2888 } // close loop on second digit
2889 //} // close loop on adesso2
2891 } // close loop on first digit
2892 //} // close loop on adesso1
2900 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2901 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2904 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2905 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2908 for (Int_t thirdIndex=0; thirdIndex<kMaxNumberOfDigitsPerVolume; thirdIndex++) {
2909 if (selectedDigit[adesso3][thirdIndex]==0x0) continue;
2912 for (Int_t fourthIndex=0; fourthIndex<kMaxNumberOfDigitsPerVolume; fourthIndex++) {
2913 if (selectedDigit[adesso4][fourthIndex]==0x0) continue;
2916 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime
2918 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
2920 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso4][fourthIndex]->GetTDC())>fMaxDeltaTime
2922 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
2924 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso4][fourthIndex]->GetTDC())>fMaxDeltaTime
2926 TMath::Abs(selectedDigit[adesso3][thirdIndex]->GetTDC()-selectedDigit[adesso4][fourthIndex]->GetTDC())>fMaxDeltaTime) continue;
2928 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2929 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2930 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2931 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2932 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
2933 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
2934 Int_t volDum = vol1[3];
2937 fTOFGeometry->GetPosPar(vol1,pos);
2938 interestingX[0] = pos[0];
2939 interestingY[0] = pos[1];
2940 interestingZ[0] = pos[2];
2942 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2943 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2944 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2945 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2946 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
2947 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
2951 fTOFGeometry->GetPosPar(vol2,pos);
2952 interestingX[1] = pos[0];
2953 interestingY[1] = pos[1];
2954 interestingZ[1] = pos[2];
2956 interestingTOF[2] = selectedDigit[adesso3][thirdIndex]->GetTDC();
2957 interestingTOT[2] = selectedDigit[adesso3][thirdIndex]->GetTOT();
2958 interestingADC[2] = selectedDigit[adesso3][thirdIndex]->GetADC();
2959 interestingWeight[2] = selectedDigit[adesso3][thirdIndex]->GetWeight();
2960 Int_t vol3[5]; for(jj=0; jj<5; jj++) vol3[jj] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(jj);
2961 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol3[0], vol3[1], vol3[2], vol3[4], vol3[3]));
2965 fTOFGeometry->GetPosPar(vol3,pos);
2966 interestingX[2] = pos[0];
2967 interestingY[2] = pos[1];
2968 interestingZ[2] = pos[2];
2970 interestingTOF[3] = selectedDigit[adesso4][fourthIndex]->GetTDC();
2971 interestingTOT[3] = selectedDigit[adesso4][fourthIndex]->GetTOT();
2972 interestingADC[3] = selectedDigit[adesso4][fourthIndex]->GetADC();
2973 interestingWeight[3] = selectedDigit[adesso4][fourthIndex]->GetWeight();
2974 Int_t vol4[5]; for(jj=0; jj<5; jj++) vol4[jj] = selectedDigit[adesso4][fourthIndex]->GetDetectorIndex(jj);
2975 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol4[0], vol4[1], vol4[2], vol4[4], vol4[3]));
2979 fTOFGeometry->GetPosPar(vol4,pos);
2980 interestingX[3] = pos[0];
2981 interestingY[3] = pos[1];
2982 interestingZ[3] = pos[2];
2985 AverageCalculations(interestingCounter+1,
2986 interestingX, interestingY, interestingZ,
2987 interestingTOF, interestingTOT, interestingADC,
2989 parTOF, posClus, check);
2991 for (jj=0; jj<5; jj++) det[jj] = -1;
2992 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
2993 fTOFGeometry->GetDetID(posF, det);
2995 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
2996 //volIdClus = GetClusterVolIndex(det);
2998 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2999 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
3000 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
3001 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
3002 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
3003 padsCluster[7] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(4);
3004 padsCluster[8] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(3);
3005 padsCluster[9] = selectedDigit[adesso4][fourthIndex]->GetDetectorIndex(4);
3006 padsCluster[10] = selectedDigit[adesso4][fourthIndex]->GetDetectorIndex(3);
3008 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
3009 Int_t ** indDet = new Int_t*[interestingCounter+1];
3010 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj] = new Int_t [5];
3011 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][0] = nSector;
3012 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][1] = nPlate;
3013 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][2] = nStrip;
3014 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][3] = padsCluster[2*jj+3];
3015 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
3016 GetClusterPars(/*check,*/ interestingCounter+1, indDet, interestingWeight, posClus, covClus);
3017 for (jj=0; jj<interestingCounter+1; jj++) delete [] indDet[jj];
3020 // To fill the track index array
3022 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
3023 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
3024 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
3027 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
3030 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
3031 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
3034 alreadyStored = kFALSE;
3035 for (jj=0; jj<dummyCounter+1; jj++)
3036 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
3038 if (alreadyStored) continue;
3039 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
3040 AliWarning(" Siamo al limite!");
3045 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
3050 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
3051 if (selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk)==-1) continue;
3054 alreadyStored = kFALSE;
3055 for (jj=0; jj<dummyCounter+1; jj++)
3056 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk));
3058 if (alreadyStored) continue;
3059 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
3060 AliWarning(" Siamo al limite!");
3065 tracks[dummyCounter] = selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk);
3070 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
3071 if (selectedDigit[adesso4][fourthIndex]->GetTrackLabel(kk)==-1) continue;
3074 alreadyStored = kFALSE;
3075 for (jj=0; jj<dummyCounter+1; jj++)
3076 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso4][fourthIndex]->GetTrackLabel(kk));
3078 if (alreadyStored) continue;
3079 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
3080 AliWarning(" Siamo al limite!");
3085 tracks[dummyCounter] = selectedDigit[adesso4][fourthIndex]->GetTrackLabel(kk);
3092 AliTOFcluster *tofCluster =
3093 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
3094 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
3095 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
3096 InsertCluster(tofCluster);
3098 AliDebug(2, Form(" %4d %f %f %f %f %f %f %f %f %f %3d %3d %3d %2d %1d %2d %1d %2d %4d %3d %3d %4d %4d %1d %4d",
3099 volIdClus, posClus[0], posClus[1], posClus[2],
3100 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
3101 tracks[0], tracks[1], tracks[2],
3102 det[0], det[1], det[2], det[3], det[4],
3103 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
3104 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
3109 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
3113 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
3117 fTOFdigitMap->ResetDigitNumber(vol3,selectedDigit[adesso3][thirdIndex]->GetIndex());
3121 fTOFdigitMap->ResetDigitNumber(vol4,selectedDigit[adesso4][fourthIndex]->GetIndex());
3124 } // close loop on fourth digit
3126 } // close loop on third digit
3128 } // close loop on second digit
3130 } // close loop on first digit
3136 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
3137 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
3138 selectedDigit[ii][jj] = 0x0;
3142 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++) {
3143 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
3144 delete [] selectedDigit[ii][jj];
3145 selectedDigit[ii][jj] = 0x0;
3147 delete [] selectedDigit[ii];
3148 selectedDigit[ii] = 0x0;
3150 delete [] selectedDigit;
3151 selectedDigit = 0x0;
3154 //_____________________________________________________________________________
3156 Int_t AliTOFClusterFinderV1::InsertCluster(AliTOFcluster *tofCluster)
3159 // This function adds a TOF cluster to the array of TOF clusters
3160 // sorted in Z, i.e. fTofClusters
3163 if (fNumberOfTofClusters==kTofMaxCluster) {
3164 AliError("Too many clusters !");
3168 if (fNumberOfTofClusters==0) {
3169 fTofClusters[fNumberOfTofClusters++] = tofCluster;
3173 Int_t ii = FindClusterIndex(tofCluster->GetZ());
3174 memmove(fTofClusters+ii+1 ,fTofClusters+ii,(fNumberOfTofClusters-ii)*sizeof(AliTOFcluster*));
3175 fTofClusters[ii] = tofCluster;
3176 fNumberOfTofClusters++;
3181 //_____________________________________________________________________________
3183 Int_t AliTOFClusterFinderV1::FindClusterIndex(Double_t z) const
3186 // This function returns the index of the nearest cluster in z
3189 if (fNumberOfTofClusters==0) return 0;
3190 if (z <= fTofClusters[0]->GetZ()) return 0;
3191 if (z > fTofClusters[fNumberOfTofClusters-1]->GetZ()) return fNumberOfTofClusters;
3192 Int_t b = 0, e = fNumberOfTofClusters-1, m = (b+e)/2;
3193 for (; b<e; m=(b+e)/2) {
3194 if (z > fTofClusters[m]->GetZ()) b=m+1;
3201 //_____________________________________________________________________________
3203 void AliTOFClusterFinderV1::ResetRecpoint()
3206 // Clear the list of reconstructed points
3209 fNumberOfTofClusters = 0;
3210 fNumberOfTofTrgPads = 0;
3211 if (fRecPoints) fRecPoints->Clear();
3214 //_____________________________________________________________________________
3216 void AliTOFClusterFinderV1::ResetDigits()
3219 // Clear the list of digits
3222 fNumberOfTofDigits = 0;
3223 fNumberOfTofTrgPads = 0;
3224 if (fDigits) fDigits->Clear();
3227 //_____________________________________________________________________________
3228 //UShort_t AliTOFClusterFinderV1::GetClusterVolIndex(Int_t *ind) const
3231 // Get the volume ID to retrieve the l2t transformation
3234 // Detector numbering scheme
3236 Int_t nSector = AliTOFGeometry::NSectors();
3237 Int_t nPlate = AliTOFGeometry::NPlates();
3238 Int_t nStripA = AliTOFGeometry::NStripA();
3239 Int_t nStripB = AliTOFGeometry::NStripB();
3240 Int_t nStripC = AliTOFGeometry::NStripC();
3242 Int_t isector =ind[0];
3243 if (isector >= nSector)
3244 AliError(Form("Wrong sector number in TOF (%d) !", isector));
3245 Int_t iplate = ind[1];
3246 if (iplate >= nPlate)
3247 AliError(Form("Wrong plate number in TOF (%d) !", iplate));
3248 Int_t istrip = ind[2];
3250 Int_t stripOffset = 0;
3256 stripOffset = nStripC;
3259 stripOffset = nStripC+nStripB;
3262 stripOffset = nStripC+nStripB+nStripA;
3265 stripOffset = nStripC+nStripB+nStripA+nStripB;
3268 AliError(Form("Wrong plate number in TOF (%d) !", iplate));
3272 Int_t index= (2*(nStripC+nStripB)+nStripA)*isector +
3276 UShort_t volIndex = AliGeomManager::LayerToVolUID(AliGeomManager::kTOF, index);
3281 //_____________________________________________________________________________
3283 void AliTOFClusterFinderV1::GetClusterPars(Int_t *ind, Double_t* pos, Double_t* cov) const
3286 // Starting from the volume indices (ind[5]), for a cluster coming from
3287 // a isolated digits, this function returns:
3288 // the cluster position (pos),
3289 // the cluster covariance matrix elements (cov)
3293 //we now go in the system of the strip: determine the local coordinates
3296 // 47---------------------------------------------------0 ^ z
3297 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 1 |
3298 // ----------------------------------------------------- | y going outwards
3299 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 0 | par[0]=0;
3301 // ----------------------------------------------------- |
3302 // x <-----------------------------------------------------
3304 //move to the tracking ref system
3305 Double_t lpos[3] = { (ind[4]-23.5)*AliTOFGeometry::XPad(),
3307 (ind[3]- 0.5)*AliTOFGeometry::ZPad() };
3308 AliDebug(1, Form(" %f %f %f", lpos[0], lpos[1], lpos[2]));
3311 UShort_t volIndex = fTOFGeometry->GetAliSensVolIndex(ind[0],ind[1],ind[2]);
3312 //UShort_t volIndex = GetClusterVolIndex(ind);
3313 const TGeoHMatrix *l2t = AliGeomManager::GetTracking2LocalMatrix(volIndex);
3315 // Get the position in the track ref system
3317 l2t->MasterToLocal(lpos,tpos);
3322 //Get the cluster covariance in the track ref system
3324 for (Int_t ii=0; ii<9; ii++) lcov[ii] = 0.;
3326 //cluster covariance in the local system:
3331 lcov[4] = 0.42*0.42/3.;
3332 // = ( 5*0.025 (gas gaps thikness)
3333 // + 4*0.040 (internal glasses thickness)
3334 // + 0.5*0.160 (internl PCB)
3335 // + 1*0.055 (external red glass))
3338 lcov[0] = 0.499678;//AliTOFGeometry::XPad()*AliTOFGeometry::XPad()/12.;
3339 lcov[8] = 0.992429;//AliTOFGeometry::ZPad()*AliTOFGeometry::ZPad()/12.;
3341 //cluster covariance in the tracking system:
3343 m.SetRotation(lcov);
3345 m.MultiplyLeft(&l2t->Inverse());
3346 Double_t *tcov = m.GetRotationMatrix();
3347 cov[0] = tcov[0]; cov[1] = tcov[1]; cov[2] = tcov[2];
3348 cov[3] = tcov[4]; cov[4] = tcov[5]; cov[5] = tcov[8];
3353 //_____________________________________________________________________________
3355 void AliTOFClusterFinderV1::GetClusterPars(/*Bool_t check,*/ Int_t counter,
3356 Int_t **ind, Double_t *weight,
3357 Double_t *pos, Double_t *cov) const
3361 // the volumes indices (ind[counter][5]), for a
3362 // cluster coming from a collection of 'counter'
3364 // the volumes weights (weight[counter]), -controlled
3365 // by the 'check' variable control-, for a cluster
3366 // coming from a collection of 'counter' digits,
3367 // the cluster position (pos),
3368 // this function returns:
3369 // the covariance matrix elements (cov) for the found cluster
3373 // we now go in the system of the strip: determine the local coordinates
3375 // 47---------------------------------------------------0 ^ z
3376 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 1 |
3377 // ----------------------------------------------------- | y going outwards
3378 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 0 | par[0]=0;
3380 // ----------------------------------------------------- |
3381 // x <-----------------------------------------------------
3383 for (Int_t ii=0; ii<counter; ii++)
3384 AliDebug(1, Form(" %2d %2d %1d %2d %1d %2d ",
3385 ii, ind[ii][0], ind[ii][1], ind[ii][2], ind[ii][3], ind[ii][4]));
3387 Float_t posF[3]; for (Int_t ii=0; ii<3; ii++) posF[ii] = (Float_t)pos[ii];
3388 AliDebug(1, Form(" %f %f %f", pos[0], pos[1], pos[2]));
3390 Int_t detClus[5] = {-1, -1, -1, -1, -1};
3391 fTOFGeometry->GetDetID(posF, detClus);
3394 UShort_t volIndex = fTOFGeometry->GetAliSensVolIndex(detClus[0],detClus[1],detClus[2]);
3395 //UShort_t volIndex = GetClusterVolIndex(detClus);
3396 AliDebug(1, Form(" %2d %1d %2d %1d %2d %7i",
3397 detClus[0], detClus[1], detClus[2], detClus[3], detClus[4], volIndex));
3399 // Get the position in the TOF strip ref system
3400 const TGeoHMatrix *alice2strip = AliGeomManager::GetOrigGlobalMatrix(volIndex);
3401 Double_t ppos[3] = {-1, -1, -1};
3402 alice2strip->MasterToLocal(pos,ppos);
3403 AliDebug(1, Form(" %f %f %f", ppos[0], ppos[1], ppos[2]));
3406 // Get the position in the tracking ref system
3407 const TGeoHMatrix *g2l = AliGeomManager::GetTracking2LocalMatrix(volIndex);
3408 Double_t lpos[3] = {-1, -1, -1};
3409 g2l->MasterToLocal(ppos,lpos);
3410 AliDebug(1, Form(" %f %f %f", lpos[0], lpos[1], lpos[2]));
3411 for (Int_t ii=0; ii<3; ii++) pos[ii] = lpos[ii];
3413 //Get the cluster covariance in the track ref system
3415 for (Int_t ii=0; ii<9; ii++) lcov[ii] = 0.;
3417 //cluster covariance in the local system:
3422 // Evaluation of the ovariance matrix elements
3423 TOFclusterError(/*check,*/ counter, ind, weight, ppos, lcov);
3425 AliDebug(1, Form("lcov[0] = %f, lcov[8] = %f", lcov[0], lcov[8]));
3427 //cluster covariance in the tracking system:
3429 m.SetRotation(lcov);
3431 m.MultiplyLeft(&g2l->Inverse());
3432 Double_t *tcov = m.GetRotationMatrix();
3433 cov[0] = tcov[0]; cov[1] = tcov[1]; cov[2] = tcov[2];
3434 cov[3] = tcov[4]; cov[4] = tcov[5]; cov[5] = tcov[8];
3439 //_____________________________________________________________________________
3441 void AliTOFClusterFinderV1::TOFclusterError(/*Bool_t check,*/ Int_t counter,
3442 Int_t **ind, Double_t *weight,
3443 Double_t ppos[], Double_t lcov[]) const
3449 //lcov[4] = 0.42*0.42/3.; // cm2
3450 // = ( 5*0.025 (gas gaps thikness)
3451 // + 4*0.040 (internal glasses thickness)
3452 // + 0.5*0.160 (internl PCB)
3453 // + 1*0.055 (external red glass))
3456 Float_t *delta2X = new Float_t[counter];
3457 for (Int_t ii=0; ii<counter; ii++)
3459 ((ind[ii][4]-23.5)*AliTOFGeometry::XPad() - ppos[0])*((ind[ii][4]-23.5)*AliTOFGeometry::XPad() - ppos[0]);
3461 Float_t *delta2Z = new Float_t[counter];
3462 for (Int_t ii=0; ii<counter; ii++)
3464 ((ind[ii][3]- 0.5)*AliTOFGeometry::ZPad() - ppos[2])*((ind[ii][3]- 0.5)*AliTOFGeometry::ZPad() - ppos[2]);
3466 for (Int_t ii=0; ii<counter; ii++)
3467 AliDebug(1, Form("x[%d] = %f, z[%d] = %f, weight[%d] = %f",
3468 ii, (ind[ii][4]-23.5)*AliTOFGeometry::XPad(),
3469 ii, (ind[ii][3]- 0.5)*AliTOFGeometry::ZPad(),
3472 AliDebug(1, Form("xMean = %f, zMean = %f",ppos[0], ppos[2]));
3480 if (ind[0][3]==ind[1][3] && TMath::Abs(ind[0][4]-ind[1][4])==1) { //
3482 lcov[8] = 1.02039; // cm2
3483 lcov[0] = 0.0379409; // cm2
3486 lcov[0] = 0.5*0.5; // cm2
3488 if (weight[0]==weight[1])
3489 lcov[0] = 0.0379409; // cm2
3491 lcov[0] = TMath::Mean(counter, delta2X, weight); // cm2
3497 else if (ind[0][4]==ind[1][4] && TMath::Abs(ind[0][3]-ind[1][3])==1) {//
3499 lcov[0] = 0.505499; // cm2
3500 lcov[8] = 0.0422046; // cm2
3503 lcov[8] = 0.5*0.5; // cm2
3505 if (weight[0]==weight[1])
3506 lcov[8] = 0.0422046; // cm2
3508 lcov[8] = TMath::Mean(counter, delta2Z, weight); // cm2
3517 lcov[0] = 0.0290677; // cm2
3518 lcov[8] = 0.0569726; // cm2
3521 lcov[0] = 0.5*0.5; // cm2
3522 lcov[8] = 0.5*0.5; // cm2
3525 if (weight[0]==weight[1] && weight[0]==weight[2]) {
3526 lcov[0] = 0.0290677; // cm2
3527 lcov[8] = 0.0569726; // cm2
3530 lcov[0] = TMath::Mean(counter, delta2X, weight); // cm2
3531 lcov[8] = TMath::Mean(counter, delta2Z, weight); // cm2
3540 lcov[0] = 0.0223807; // cm2
3541 lcov[8] = 0.0438662; // cm2
3544 lcov[0] = 0.5*0.5; // cm2
3545 lcov[8] = 0.5*0.5; // cm2
3548 if (weight[0]==weight[1] && weight[0]==weight[2] && weight[0]==weight[3]) {
3549 lcov[0] = 0.0223807; // cm2
3550 lcov[8] = 0.0438662; // cm2
3553 lcov[0] = TMath::Mean(counter, delta2X, weight); // cm2
3554 lcov[8] = TMath::Mean(counter, delta2Z, weight); // cm2
3568 //_____________________________________________________________________________
3570 Bool_t AliTOFClusterFinderV1::MakeSlewingCorrection(Int_t *detectorIndex,
3576 // This funtion makes the following:
3578 // - if at least one of the three status (Pulser/Noise/HW) is
3579 // bad, is sets the status of electronic channel, corresponding to the
3580 // volume identified by detectorIndex, as kFALSE;
3581 // - if offline calibration is in the valid status, it performs the
3582 // slewing correction. In particular, by taking into account:
3583 // * the measured tot and tof values (tofDigitToT and tofDigitTdc,
3585 // * the six parameters of 5th order polynomial used
3586 // to fit the tofVStot scatter plot,
3587 // it returns the corrected tof value, i.e. tdcCorr value.
3590 Bool_t output = kTRUE;
3595 //AliInfo(" Calibrating TOF Digits: ");
3597 AliTOFChannelOnlineArray *calDelay = fTOFcalib->GetTOFOnlineDelay();
3598 AliTOFChannelOnlineStatusArray *calStatus = fTOFcalib->GetTOFOnlineStatus();
3600 TObjArray *calTOFArrayOffline = fTOFcalib->GetTOFCalArrayOffline();
3602 Int_t index = AliTOFGeometry::GetIndex(detectorIndex);
3604 UChar_t statusPulser = calStatus->GetPulserStatus(index);
3605 UChar_t statusNoise = calStatus->GetNoiseStatus(index);
3606 UChar_t statusHW = calStatus->GetHWStatus(index);
3607 UChar_t status = calStatus->GetStatus(index);
3609 //check the status, also unknown is fine!!!!!!!
3611 AliDebug(2, Form(" Status for channel %d = %d",index, (Int_t)status));
3612 if((statusPulser & AliTOFChannelOnlineStatusArray::kTOFPulserBad)==(AliTOFChannelOnlineStatusArray::kTOFPulserBad)||(statusNoise & AliTOFChannelOnlineStatusArray::kTOFNoiseBad)==(AliTOFChannelOnlineStatusArray::kTOFNoiseBad)||(statusHW & AliTOFChannelOnlineStatusArray::kTOFHWBad)==(AliTOFChannelOnlineStatusArray::kTOFHWBad)){
3613 AliDebug(2, Form(" Bad Status for channel %d",index));
3614 //fTofClusters[ii]->SetStatus(kFALSE); //odd convention, to avoid conflict with calibration objects currently in the db (temporary solution).
3618 AliDebug(2, Form(" Good Status for channel %d",index));
3621 if (fCalibrateTOFtimes) { // AdC
3623 // Get Rough channel online equalization
3624 Double_t roughDelay = (Double_t)calDelay->GetDelay(index); // in ns
3625 AliDebug(2,Form(" channel delay (ns) = %f", roughDelay));
3626 // Get Refined channel offline calibration parameters
3627 TString validity = (TString)fTOFcalib->GetOfflineValidity();
3628 if (validity.CompareTo("valid")==0) {
3629 AliTOFChannelOffline * calChannelOffline = (AliTOFChannelOffline*)calTOFArrayOffline->At(index);
3631 for (jj = 0; jj<6; jj++)
3632 par[jj] = (Double_t)calChannelOffline->GetSlewPar(jj);
3634 AliDebug(2,Form(" Calib Pars = %f, %f, %f, %f, %f, %f ",par[0],par[1],par[2],par[3],par[4],par[5]));
3635 AliDebug(2,Form(" The ToT and Time, uncorr (counts) = %d , %d", tofDigitToT, tofDigitTdc));
3636 Double_t tToT = (Double_t)(tofDigitToT*AliTOFGeometry::ToTBinWidth());
3637 tToT*=1.E-3; //ToT in ns
3638 AliDebug(2,Form(" The ToT and Time, uncorr (ns)= %e, %e",tofDigitTdc*AliTOFGeometry::TdcBinWidth()*1.E-3,tToT));
3639 timeCorr = par[0] + tToT*(par[1] + tToT*(par[2] + tToT*(par[3] + tToT*(par[4] + tToT*par[5])))); // the time correction (ns)
3642 timeCorr = roughDelay; // correction in ns
3644 AliDebug(2,Form(" The ToT and Time, uncorr (ns)= %e, %e",tofDigitTdc*AliTOFGeometry::TdcBinWidth()*1.E-3,tofDigitToT*AliTOFGeometry::ToTBinWidth()));
3645 AliDebug(2,Form(" The time correction (ns) = %f", timeCorr));
3646 timeCorr = (Double_t)(tofDigitTdc)*AliTOFGeometry::TdcBinWidth()*1.E-3-timeCorr;//redefine the time
3648 AliDebug(2,Form(" The channel time, corr (ps)= %e",timeCorr ));
3649 //tdcCorr = (Int_t)(timeCorr/AliTOFGeometry::TdcBinWidth()); //the corrected time (tdc counts)
3650 tdcCorr = TMath::Nint(timeCorr/AliTOFGeometry::TdcBinWidth()); //the corrected time (tdc counts)
3657 //______________________________________________________________________________
3659 void AliTOFClusterFinderV1::Digits2RecPoints(Int_t iEvent)
3662 // Converts digits to recpoints for TOF
3665 TStopwatch stopwatch;
3668 fRunLoader->GetEvent(iEvent);
3670 AliLoader *localTOFLoader = (AliLoader*)fRunLoader->GetLoader("TOFLoader");
3672 TTree * localTreeD = (TTree*)localTOFLoader->TreeD();
3673 if (localTreeD == 0x0) {
3674 AliFatal("Can not get TreeD");
3678 TBranch *branch = localTreeD->GetBranch("TOF");
3680 AliError("Can't get the branch with the TOF digits !");
3684 TTree *localTreeR = (TTree*)localTOFLoader->TreeR();
3685 if (localTreeR == 0x0)
3687 localTOFLoader->MakeTree("R");
3688 localTreeR = localTOFLoader->TreeR();
3691 Digits2RecPoints(localTreeD, localTreeR);
3693 //localTOFLoader = fRunLoader->GetLoader("TOFLoader");
3694 localTOFLoader->WriteRecPoints("OVERWRITE");
3696 AliDebug(1, Form("Execution time to read TOF digits and to write TOF clusters for the event number %d: R:%.4fs C:%.4fs",
3697 iEvent, stopwatch.RealTime(),stopwatch.CpuTime()));
3700 //______________________________________________________________________________
3702 void AliTOFClusterFinderV1::Digits2RecPoints(Int_t iEvent, AliRawReader *rawReader)
3705 // Converts RAW data to recpoints for TOF
3708 TStopwatch stopwatch;
3711 fRunLoader->GetEvent(iEvent);
3713 AliDebug(2,Form(" Event number %2d ", iEvent));
3715 AliLoader *localTOFLoader = (AliLoader*)fRunLoader->GetLoader("TOFLoader");
3717 TTree *localTreeR = localTOFLoader->TreeR();
3719 if (localTreeR == 0x0){
3720 localTOFLoader->MakeTree("R");
3721 localTreeR = localTOFLoader->TreeR();
3724 Digits2RecPoints(rawReader, localTreeR);
3726 AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters for the event number %d: R:%.4fs C:%.4fs",
3727 iEvent, stopwatch.RealTime(),stopwatch.CpuTime()));
3730 //______________________________________________________________________________
3732 void AliTOFClusterFinderV1::Raw2Digits(Int_t iEvent, AliRawReader *rawReader)
3735 // Converts RAW data to MC digits for TOF
3739 TStopwatch stopwatch;
3742 fRunLoader->GetEvent(iEvent);
3744 AliDebug(2,Form(" Event number %2d ", iEvent));
3746 AliLoader *localTOFLoader = (AliLoader*)fRunLoader->GetLoader("TOFLoader");
3748 TTree *localTreeD = localTOFLoader->TreeD();
3750 if (localTreeD == 0x0){
3751 localTOFLoader->MakeTree("D");
3752 localTreeD = localTOFLoader->TreeD();
3755 Raw2Digits(rawReader, localTreeD);
3757 AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters for the event number %d: R:%.4fs C:%.4fs",
3758 iEvent, stopwatch.RealTime(),stopwatch.CpuTime()));
3761 //______________________________________________________________________________
3763 void AliTOFClusterFinderV1::AverageCalculations(Int_t number, Float_t *interestingX,
3764 Float_t *interestingY, Float_t *interestingZ,
3765 Double_t *interestingTOF, Double_t *interestingTOT,
3766 Double_t *interestingADC, Double_t *interestingWeight,
3767 Int_t *parTOF, Double_t *posClus, Bool_t &check)
3770 // Calculates the mean values for cluster position (x,y,z),
3771 // TOF charge and time
3774 Double_t tofAverage = 0.;
3775 Double_t totAverage = 0.;
3776 Double_t adcAverage = 0.;
3780 for (ii=number-1; ii>=0; ii--) check=check||(interestingWeight[ii]==0 || interestingWeight[ii]==-1);
3784 posClus[0] = TMath::Mean(number, interestingX);
3785 posClus[1] = TMath::Mean(number, interestingY);
3786 posClus[2] = TMath::Mean(number, interestingZ);
3787 tofAverage = TMath::Mean(number, interestingTOF);
3788 totAverage = TMath::Mean(number, interestingTOT);
3789 adcAverage = TMath::Mean(number, interestingADC);
3794 posClus[0] = TMath::Mean(number, interestingX, interestingWeight);
3795 posClus[1] = TMath::Mean(number, interestingY, interestingWeight);
3796 posClus[2] = TMath::Mean(number, interestingZ, interestingWeight);
3797 tofAverage = TMath::Mean(number, interestingTOF, interestingWeight);
3798 totAverage = TMath::Mean(number, interestingTOT, interestingWeight);
3799 adcAverage = TMath::Mean(number, interestingADC, interestingWeight);
3803 parTOF[0] = Int_t(tofAverage);
3804 parTOF[1] = Int_t(totAverage);
3805 parTOF[2] = Int_t(adcAverage);
3806 parTOF[3] = Int_t(tofAverage);//tofND
3807 parTOF[4] = Int_t(tofAverage);//tofRAW