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 Int_t interestingPadX[kMaxNumberOfInterestingPads];
1047 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
1048 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
1049 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
1050 Double_t interestingTOT[kMaxNumberOfInterestingPads];
1051 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
1052 Double_t interestingADC[kMaxNumberOfInterestingPads];
1053 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
1054 Double_t interestingTOF[kMaxNumberOfInterestingPads];
1055 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
1056 Double_t interestingWeight[kMaxNumberOfInterestingPads];
1057 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
1059 Float_t interestingX[kMaxNumberOfInterestingPads];
1060 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
1061 Float_t interestingY[kMaxNumberOfInterestingPads];
1062 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
1063 Float_t interestingZ[kMaxNumberOfInterestingPads];
1064 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
1066 Float_t interDigit[kMaxNumberOfInterestingPads];
1067 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
1069 Int_t padsCluster[11];
1070 padsCluster[0] = nSector;
1071 padsCluster[1] = nPlate;
1072 padsCluster[2] = nStrip;
1073 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1075 Int_t interestingCounter=-1;
1076 Int_t digitIndexLocal=-1; // AdC
1082 for (jj=0; jj<7; jj++) parTOF[jj] = 0;
1083 Double_t posClus[3];
1084 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
1086 for (jj=0; jj<5; jj++) det[jj] = -1;
1088 for (jj=0; jj<3; jj++) posF[jj] = 0.;
1089 UShort_t volIdClus = 0;
1090 Bool_t check = kFALSE;
1091 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
1092 Double_t covClus[6];
1093 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1094 Int_t tracks[kMaxNumberOfTracksPerDigit];
1095 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1096 Int_t dummyCounter=-1;
1097 Bool_t alreadyStored = kFALSE;
1099 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
1100 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1101 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
1103 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1104 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
1106 AliTOFdigit *digitInteresting;
1108 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
1110 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
1111 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
1113 AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
1120 interestingCounter=-1;
1122 vol[4] = iPadZ , vol[3] = iPadX;
1123 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1124 interestingCounter++;
1126 vol[4] = iPadZ, vol[3] = iPadX+1;
1127 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1128 interestingCounter++;
1130 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1131 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1132 interestingCounter++;
1134 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1135 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1136 interestingCounter++;
1138 if (interestingCounter+1!=4) continue; // the hit pads have to be 4
1139 else interestingCounter=-1;
1142 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1143 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1144 selectedDigit[ii][jj] = 0x0;
1147 vol[4] = iPadZ, vol[3] = iPadX;
1149 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1150 interestingCounter++;
1151 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1152 digitsInVolumeIndices[ii] = -1;
1153 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1154 digitIndexLocal=-1; // AdC
1155 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1156 if (digitsInVolumeIndices[digIndex]<0) continue;
1157 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1158 if (digitInteresting->GetToT()<=0) continue; // AdC
1159 digitIndexLocal++; // AdC
1161 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1162 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1163 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1164 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1165 digitsInVolumeIndices[digIndex],
1166 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1169 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1170 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1171 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1172 digitInteresting->GetToT()*digitInteresting->GetToT(),
1173 digitsInVolumeIndices[digIndex],
1174 digitInteresting->GetTracks());
1176 if (digitIndexLocal==-1) interestingCounter--; // AdC
1180 vol[4] = iPadZ, vol[3] = iPadX+1;
1182 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1183 interestingCounter++;
1184 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1185 digitsInVolumeIndices[ii] = -1;
1186 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1187 digitIndexLocal=-1; // AdC
1188 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1189 if (digitsInVolumeIndices[digIndex]<0) continue;
1190 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1191 if (digitInteresting->GetToT()<=0) continue; // AdC
1192 digitIndexLocal++; // AdC
1194 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1195 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1196 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1197 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1198 digitsInVolumeIndices[digIndex],
1199 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1202 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1203 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1204 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1205 digitInteresting->GetToT()*digitInteresting->GetToT(),
1206 digitsInVolumeIndices[digIndex],
1207 digitInteresting->GetTracks());
1209 if (digitIndexLocal==-1) interestingCounter--; // AdC
1213 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1215 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1216 interestingCounter++;
1217 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1218 digitsInVolumeIndices[ii] = -1;
1219 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1220 digitIndexLocal=-1; // AdC
1221 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1222 if (digitsInVolumeIndices[digIndex]<0) continue;
1223 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1224 if (digitInteresting->GetToT()<=0) continue; // AdC
1225 digitIndexLocal++; // AdC
1227 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1228 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1229 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1230 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1231 digitsInVolumeIndices[digIndex],
1232 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1235 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1236 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1237 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1238 digitInteresting->GetToT()*digitInteresting->GetToT(),
1239 digitsInVolumeIndices[digIndex],
1240 digitInteresting->GetTracks());
1242 if (digitIndexLocal==-1) interestingCounter--; // AdC
1246 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1248 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1249 interestingCounter++;
1250 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1251 digitsInVolumeIndices[ii] = -1;
1252 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1254 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1255 if (digitsInVolumeIndices[digIndex]<0) continue;
1256 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1257 if (digitInteresting->GetToT()<=0) continue; // AdC
1258 digitIndexLocal++; // AdC
1260 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1261 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1262 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1263 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1264 digitsInVolumeIndices[digIndex],
1265 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1267 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1268 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1269 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1270 digitInteresting->GetToT()*digitInteresting->GetToT(),
1271 digitsInVolumeIndices[digIndex],
1272 digitInteresting->GetTracks());
1274 if (digitIndexLocal==-1) interestingCounter--; // AdC
1277 AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
1279 for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
1280 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
1281 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
1283 for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
1284 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
1285 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
1287 for (Int_t adesso3=adesso2+1; adesso3<interestingCounter+1; adesso3++) {
1288 for (Int_t thirdIndex=0; thirdIndex<kMaxNumberOfDigitsPerVolume; thirdIndex++) {
1289 if (selectedDigit[adesso3][thirdIndex]==0x0) continue;
1292 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime
1294 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
1296 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime) continue;
1298 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
1299 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
1300 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
1301 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
1302 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
1303 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
1304 Int_t volDum = vol1[3];
1307 fTOFGeometry->GetPosPar(vol1,pos);
1308 interestingX[0] = pos[0];
1309 interestingY[0] = pos[1];
1310 interestingZ[0] = pos[2];
1312 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
1313 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
1314 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
1315 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
1316 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
1317 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
1321 fTOFGeometry->GetPosPar(vol2,pos);
1322 interestingX[1] = pos[0];
1323 interestingY[1] = pos[1];
1324 interestingZ[1] = pos[2];
1326 interestingTOF[2] = selectedDigit[adesso3][thirdIndex]->GetTDC();
1327 interestingTOT[2] = selectedDigit[adesso3][thirdIndex]->GetTOT();
1328 interestingADC[2] = selectedDigit[adesso3][thirdIndex]->GetADC();
1329 interestingWeight[2] = selectedDigit[adesso3][thirdIndex]->GetWeight();
1330 Int_t vol3[5]; for(jj=0; jj<5; jj++) vol3[jj] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(jj);
1331 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol3[0], vol3[1], vol3[2], vol3[4], vol3[3]));
1335 fTOFGeometry->GetPosPar(vol3,pos);
1336 interestingX[2] = pos[0];
1337 interestingY[2] = pos[1];
1338 interestingZ[2] = pos[2];
1341 AverageCalculations(3, interestingX, interestingY, interestingZ,
1342 interestingTOF, interestingTOT, interestingADC,
1344 parTOF, posClus, check);
1347 for (jj=0; jj<5; jj++) det[jj] = -1;
1348 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
1349 fTOFGeometry->GetDetID(posF, det);
1351 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
1352 //volIdClus = GetClusterVolIndex(det);
1354 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1355 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
1356 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
1357 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
1358 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
1359 padsCluster[7] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(4);
1360 padsCluster[8] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(3);
1362 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1363 Int_t ** indDet = new Int_t*[3];
1364 for (jj=0; jj<3; jj++) indDet[jj] = new Int_t [5];
1365 for (jj=0; jj<3; jj++) indDet[jj][0] = nSector;
1366 for (jj=0; jj<3; jj++) indDet[jj][1] = nPlate;
1367 for (jj=0; jj<3; jj++) indDet[jj][2] = nStrip;
1368 for (jj=0; jj<3; jj++) indDet[jj][3] = padsCluster[2*jj+3];
1369 for (jj=0; jj<3; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
1370 GetClusterPars(/*check,*/ 3, indDet, interestingWeight, posClus, covClus);
1371 for (jj=0; jj<3; jj++) delete [] indDet[jj];
1374 // To fill the track index array
1376 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1377 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1378 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
1381 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
1384 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1385 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
1388 alreadyStored = kFALSE;
1389 for (jj=0; jj<dummyCounter+1; jj++)
1390 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
1392 if (alreadyStored) continue;
1393 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
1394 AliWarning(" Siamo al limite!");
1399 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
1404 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1405 if (selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk)==-1) continue;
1408 alreadyStored = kFALSE;
1409 for (jj=0; jj<dummyCounter+1; jj++)
1410 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk));
1412 if (alreadyStored) continue;
1413 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
1414 AliWarning(" Siamo al limite!");
1419 tracks[dummyCounter] = selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk);
1426 AliTOFcluster *tofCluster =
1427 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
1428 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1429 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
1430 InsertCluster(tofCluster);
1432 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",
1433 volIdClus, posClus[0], posClus[1], posClus[2],
1434 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1435 tracks[0], tracks[1], tracks[2],
1436 det[0], det[1], det[2], det[3], det[4],
1437 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
1438 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
1444 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
1448 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
1452 fTOFdigitMap->ResetDigitNumber(vol3,selectedDigit[adesso3][thirdIndex]->GetIndex());
1455 } // close loop on third digit
1456 } // close loop on adesso3
1458 } // close loop on second digit
1459 } // close loop on adesso2
1461 } // close loop on first digit
1462 } // close loop on adesso1
1464 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1465 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1466 selectedDigit[ii][jj] = 0x0;
1470 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++) {
1471 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
1472 delete [] selectedDigit[ii][jj];
1473 selectedDigit[ii][jj] = 0x0;
1475 delete [] selectedDigit[ii];
1476 selectedDigit[ii] = 0x0;
1478 delete [] selectedDigit;
1479 selectedDigit = 0x0;
1482 //_____________________________________________________________________________
1484 void AliTOFClusterFinderV1::FindClusters23(Int_t nSector,
1489 // This function searches the neighbouring digits (stored in the fDigits object),
1490 // to perform clusters (stored in the fTofClusters array).
1492 // This research has been made by checking the fTOFdigitMap object,
1493 // filled at digits/raw-data reading time.
1496 const Int_t kMaxNumberOfInterestingPads = 4;
1497 const Int_t kMaxNumberOfTracksPerDigit = 3;
1498 const Int_t kMaxNumberOfDigitsPerVolume = 10;
1502 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
1503 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1504 digitsInVolumeIndices[ii] = -1;
1506 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
1508 Float_t pos[3] = {0.,0.,0.};
1511 Int_t interestingPadX[kMaxNumberOfInterestingPads];
1512 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
1513 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
1514 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
1515 Double_t interestingTOT[kMaxNumberOfInterestingPads];
1516 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
1517 Double_t interestingADC[kMaxNumberOfInterestingPads];
1518 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
1519 Double_t interestingTOF[kMaxNumberOfInterestingPads];
1520 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
1521 Double_t interestingWeight[kMaxNumberOfInterestingPads];
1522 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
1524 Float_t interestingX[kMaxNumberOfInterestingPads];
1525 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
1526 Float_t interestingY[kMaxNumberOfInterestingPads];
1527 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
1528 Float_t interestingZ[kMaxNumberOfInterestingPads];
1529 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
1531 Float_t interDigit[kMaxNumberOfInterestingPads];
1532 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
1534 Int_t padsCluster[11];
1535 padsCluster[0] = nSector;
1536 padsCluster[1] = nPlate;
1537 padsCluster[2] = nStrip;
1538 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1540 Int_t interestingCounter=-1;
1541 Int_t digitIndexLocal = -1;
1546 Bool_t check = kFALSE;
1548 for (jj=0; jj<7; jj++) parTOF[jj] = 0;
1549 Double_t posClus[3];
1550 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
1552 for (jj=0; jj<5; jj++) det[jj] = -1;
1554 for (jj=0; jj<3; jj++) posF[jj] = 0.;
1555 UShort_t volIdClus = 0;
1556 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
1557 Double_t covClus[6];
1558 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1559 Int_t tracks[kMaxNumberOfTracksPerDigit];
1560 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1561 Int_t dummyCounter=-1;
1562 Bool_t alreadyStored = kFALSE;
1564 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
1565 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1566 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
1568 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1569 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
1571 AliTOFdigit *digitInteresting;
1573 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
1575 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
1576 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
1578 AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
1585 interestingCounter=-1;
1587 vol[4] = iPadZ , vol[3] = iPadX;
1588 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1589 interestingCounter++;
1591 vol[4] = iPadZ, vol[3] = iPadX+1;
1592 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1593 interestingCounter++;
1595 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1596 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1597 interestingCounter++;
1599 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1600 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1601 interestingCounter++;
1603 if (interestingCounter+1!=3) continue; // the hit pads have to be 3
1604 else interestingCounter=-1;
1607 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1608 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1609 selectedDigit[ii][jj] = 0x0;
1612 vol[4] = iPadZ, vol[3] = iPadX;
1614 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1615 interestingCounter++;
1616 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1617 digitsInVolumeIndices[ii] = -1;
1618 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1620 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1621 if (digitsInVolumeIndices[digIndex]<0) continue;
1622 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1623 if (digitInteresting->GetToT()<=0) continue; // AdC
1624 digitIndexLocal++; // AdC
1626 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1627 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1628 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1629 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1630 digitsInVolumeIndices[digIndex],
1631 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1633 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1634 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1635 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1636 digitInteresting->GetToT()*digitInteresting->GetToT(),
1637 digitsInVolumeIndices[digIndex],
1638 digitInteresting->GetTracks());
1640 if (digitIndexLocal==-1) interestingCounter--; // AdC
1644 vol[4] = iPadZ, vol[3] = iPadX+1;
1646 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1647 interestingCounter++;
1648 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1649 digitsInVolumeIndices[ii] = -1;
1650 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1651 digitIndexLocal=-1; // AdC
1652 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1653 if (digitsInVolumeIndices[digIndex]<0) continue;
1654 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1655 if (digitInteresting->GetToT()<=0) continue; // AdC
1656 digitIndexLocal++; // AdC
1658 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1659 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1660 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1661 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1662 digitsInVolumeIndices[digIndex],
1663 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1665 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1666 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1667 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1668 digitInteresting->GetToT()*digitInteresting->GetToT(),
1669 digitsInVolumeIndices[digIndex],
1670 digitInteresting->GetTracks());
1672 if (digitIndexLocal==-1) interestingCounter--; // AdC
1676 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1678 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1679 interestingCounter++;
1680 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1681 digitsInVolumeIndices[ii] = -1;
1682 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1683 digitIndexLocal=-1; // AdC
1684 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1685 if (digitsInVolumeIndices[digIndex]<0) continue;
1686 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1687 if (digitInteresting->GetToT()<=0) continue; // AdC
1688 digitIndexLocal++; // AdC
1690 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1691 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1692 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1693 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1694 digitsInVolumeIndices[digIndex],
1695 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1697 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1698 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1699 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1700 digitInteresting->GetToT()*digitInteresting->GetToT(),
1701 digitsInVolumeIndices[digIndex],
1702 digitInteresting->GetTracks());
1704 if (digitIndexLocal==-1) interestingCounter--; // AdC
1708 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1710 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1711 interestingCounter++;
1712 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1713 digitsInVolumeIndices[ii] = -1;
1714 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1715 digitIndexLocal=-1; // AdC
1716 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1717 if (digitsInVolumeIndices[digIndex]<0) continue;
1718 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1719 if (digitInteresting->GetToT()<=0) continue; // AdC
1720 digitIndexLocal++; // AdC
1722 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1723 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1724 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1725 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1726 digitsInVolumeIndices[digIndex],
1727 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1729 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1730 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1731 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1732 digitInteresting->GetToT()*digitInteresting->GetToT(),
1733 digitsInVolumeIndices[digIndex],
1734 digitInteresting->GetTracks());
1736 if (digitIndexLocal==-1) interestingCounter--; // AdC
1739 AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
1741 for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
1742 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
1743 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
1745 for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
1746 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
1747 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
1749 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime) continue;
1751 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
1752 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
1753 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
1754 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
1755 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
1756 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
1757 Int_t volDum = vol1[3];
1760 fTOFGeometry->GetPosPar(vol1,pos);
1761 interestingX[0] = pos[0];
1762 interestingY[0] = pos[1];
1763 interestingZ[0] = pos[2];
1765 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
1766 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
1767 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
1768 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
1769 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
1770 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
1774 fTOFGeometry->GetPosPar(vol2,pos);
1775 interestingX[1] = pos[0];
1776 interestingY[1] = pos[1];
1777 interestingZ[1] = pos[2];
1779 AverageCalculations(2, interestingX, interestingY, interestingZ,
1780 interestingTOF, interestingTOT, interestingADC,
1782 parTOF, posClus, check);
1784 for (jj=0; jj<5; jj++) det[jj] = -1;
1785 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
1786 fTOFGeometry->GetDetID(posF, det);
1788 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
1789 //volIdClus = GetClusterVolIndex(det);
1791 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1792 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
1793 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
1794 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
1795 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
1797 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1798 Int_t ** indDet = new Int_t*[2];
1799 for (jj=0; jj<2; jj++) indDet[jj] = new Int_t [5];
1800 for (jj=0; jj<2; jj++) indDet[jj][0] = nSector;
1801 for (jj=0; jj<2; jj++) indDet[jj][1] = nPlate;
1802 for (jj=0; jj<2; jj++) indDet[jj][2] = nStrip;
1803 for (jj=0; jj<2; jj++) indDet[jj][3] = padsCluster[2*jj+3];
1804 for (jj=0; jj<2; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
1805 GetClusterPars(/*check,*/ 2, indDet, interestingWeight, posClus, covClus);
1806 for (jj=0; jj<2; jj++) delete [] indDet[jj];
1809 // To fill the track index array
1811 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1812 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1813 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
1816 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
1819 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1820 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
1823 alreadyStored = kFALSE;
1824 for (jj=0; jj<dummyCounter+1; jj++)
1825 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
1827 if (alreadyStored) continue;
1828 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
1829 AliWarning(" Siamo al limite!");
1834 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
1841 AliTOFcluster *tofCluster =
1842 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
1843 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1844 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
1845 InsertCluster(tofCluster);
1847 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",
1848 volIdClus, posClus[0], posClus[1], posClus[2],
1849 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1850 tracks[0], tracks[1], tracks[2],
1851 det[0], det[1], det[2], det[3], det[4],
1852 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
1853 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
1858 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
1862 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
1865 } // close loop on second digit
1866 } // close loop on adesso2
1868 } // close loop on first digit
1869 } // close loop on adesso1
1871 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1872 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1873 selectedDigit[ii][jj] = 0x0;
1877 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++) {
1878 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
1879 delete [] selectedDigit[ii][jj];
1880 selectedDigit[ii][jj] = 0x0;
1882 delete [] selectedDigit[ii];
1883 selectedDigit[ii] = 0x0;
1885 delete [] selectedDigit;
1886 selectedDigit = 0x0;
1889 //_____________________________________________________________________________
1891 void AliTOFClusterFinderV1::FindClusters24(Int_t nSector,
1896 // This function searches the neighbouring digits (stored in the fDigits object),
1897 // to perform clusters (stored in the fTofClusters array).
1899 // This research has been made by checking the fTOFdigitMap object,
1900 // filled at digits/raw-data reading time.
1903 const Int_t kMaxNumberOfInterestingPads = 4;
1904 const Int_t kMaxNumberOfTracksPerDigit = 3;
1905 const Int_t kMaxNumberOfDigitsPerVolume = 10;
1909 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
1910 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1911 digitsInVolumeIndices[ii] = -1;
1913 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
1915 Float_t pos[3] = {0.,0.,0.};
1918 Int_t interestingPadX[kMaxNumberOfInterestingPads];
1919 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
1920 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
1921 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
1922 Double_t interestingTOT[kMaxNumberOfInterestingPads];
1923 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
1924 Double_t interestingADC[kMaxNumberOfInterestingPads];
1925 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
1926 Double_t interestingTOF[kMaxNumberOfInterestingPads];
1927 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
1928 Double_t interestingWeight[kMaxNumberOfInterestingPads];
1929 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
1931 Float_t interestingX[kMaxNumberOfInterestingPads];
1932 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
1933 Float_t interestingY[kMaxNumberOfInterestingPads];
1934 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
1935 Float_t interestingZ[kMaxNumberOfInterestingPads];
1936 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
1938 Float_t interDigit[kMaxNumberOfInterestingPads];
1939 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
1941 Int_t padsCluster[11];
1942 padsCluster[0] = nSector;
1943 padsCluster[1] = nPlate;
1944 padsCluster[2] = nStrip;
1945 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1947 Int_t interestingCounter=-1;
1948 Int_t digitIndexLocal = -1;
1953 Bool_t check = kFALSE;
1955 for (jj=0; jj<7; jj++) parTOF[jj] = 0;
1956 Double_t posClus[3];
1957 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
1959 for (jj=0; jj<5; jj++) det[jj] = -1;
1961 for (jj=0; jj<3; jj++) posF[jj] = 0.;
1962 UShort_t volIdClus = 0;
1963 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
1964 Double_t covClus[6];
1965 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1966 Int_t tracks[kMaxNumberOfTracksPerDigit];
1967 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1968 Int_t dummyCounter=-1;
1969 Bool_t alreadyStored = kFALSE;
1971 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
1972 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1973 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
1975 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1976 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
1978 AliTOFdigit *digitInteresting;
1980 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
1982 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
1983 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
1985 AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
1992 interestingCounter=-1;
1994 vol[4] = iPadZ , vol[3] = iPadX;
1995 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1996 interestingCounter++;
1998 vol[4] = iPadZ, vol[3] = iPadX+1;
1999 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2000 interestingCounter++;
2002 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
2003 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2004 interestingCounter++;
2006 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
2007 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2008 interestingCounter++;
2010 if (interestingCounter+1!=4) continue; // the hit pads have to be 4
2011 else interestingCounter=-1;
2014 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2015 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
2016 selectedDigit[ii][jj] = 0x0;
2019 vol[4] = iPadZ, vol[3] = iPadX;
2021 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2022 interestingCounter++;
2023 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2024 digitsInVolumeIndices[ii] = -1;
2025 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2026 digitIndexLocal=-1; // AdC
2027 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2028 if (digitsInVolumeIndices[digIndex]<0) continue;
2029 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2030 if (digitInteresting->GetToT()<=0) continue; // AdC
2031 digitIndexLocal++; // AdC
2033 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2034 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2035 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2036 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2037 digitsInVolumeIndices[digIndex],
2038 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2040 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2041 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2042 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2043 digitInteresting->GetToT()*digitInteresting->GetToT(),
2044 digitsInVolumeIndices[digIndex],
2045 digitInteresting->GetTracks());
2047 if (digitIndexLocal==-1) interestingCounter--; // AdC
2051 vol[4] = iPadZ, vol[3] = iPadX+1;
2053 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2054 interestingCounter++;
2055 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2056 digitsInVolumeIndices[ii] = -1;
2057 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2058 digitIndexLocal=-1; // AdC
2059 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2060 if (digitsInVolumeIndices[digIndex]<0) continue;
2061 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2062 if (digitInteresting->GetToT()<=0) continue; // AdC
2063 digitIndexLocal++; // AdC
2065 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2066 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2067 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2068 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2069 digitsInVolumeIndices[digIndex],
2070 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2072 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2073 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2074 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2075 digitInteresting->GetToT()*digitInteresting->GetToT(),
2076 digitsInVolumeIndices[digIndex],
2077 digitInteresting->GetTracks());
2079 if (digitIndexLocal==-1) interestingCounter--; // AdC
2083 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
2085 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2086 interestingCounter++;
2087 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2088 digitsInVolumeIndices[ii] = -1;
2089 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2090 digitIndexLocal=-1; // AdC
2091 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2092 if (digitsInVolumeIndices[digIndex]<0) continue;
2093 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2094 if (digitInteresting->GetToT()<=0) continue; // AdC
2095 digitIndexLocal++; // AdC
2097 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2098 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2099 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2100 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2101 digitsInVolumeIndices[digIndex],
2102 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2104 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2105 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2106 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2107 digitInteresting->GetToT()*digitInteresting->GetToT(),
2108 digitsInVolumeIndices[digIndex],
2109 digitInteresting->GetTracks());
2111 if (digitIndexLocal==-1) interestingCounter--; // AdC
2115 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
2117 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2118 interestingCounter++;
2119 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2120 digitsInVolumeIndices[ii] = -1;
2121 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2122 digitIndexLocal=-1; // AdC
2123 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2124 if (digitsInVolumeIndices[digIndex]<0) continue;
2125 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2126 if (digitInteresting->GetToT()<=0) continue; // AdC
2127 digitIndexLocal++; // AdC
2129 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2130 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2131 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2132 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2133 digitsInVolumeIndices[digIndex],
2134 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2136 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2137 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2138 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2139 digitInteresting->GetToT()*digitInteresting->GetToT(),
2140 digitsInVolumeIndices[digIndex],
2141 digitInteresting->GetTracks());
2143 if (digitIndexLocal==-1) interestingCounter--; // AdC
2146 AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
2148 for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
2149 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2150 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2152 for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
2153 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2154 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2156 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime) continue;
2158 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2159 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2160 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2161 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2162 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
2163 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
2164 Int_t volDum = vol1[3];
2167 fTOFGeometry->GetPosPar(vol1,pos);
2168 interestingX[0] = pos[0];
2169 interestingY[0] = pos[1];
2170 interestingZ[0] = pos[2];
2172 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2173 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2174 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2175 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2176 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
2177 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
2181 fTOFGeometry->GetPosPar(vol2,pos);
2182 interestingX[1] = pos[0];
2183 interestingY[1] = pos[1];
2184 interestingZ[1] = pos[2];
2187 AverageCalculations(2, interestingX, interestingY, interestingZ,
2188 interestingTOF, interestingTOT, interestingADC,
2190 parTOF, posClus, check);
2192 for (jj=0; jj<5; jj++) det[jj] = -1;
2193 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
2194 fTOFGeometry->GetDetID(posF, det);
2196 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
2197 //volIdClus = GetClusterVolIndex(det);
2199 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2200 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
2201 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
2202 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
2203 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
2205 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2206 Int_t ** indDet = new Int_t*[2];
2207 for (jj=0; jj<2; jj++) indDet[jj] = new Int_t [5];
2208 for (jj=0; jj<2; jj++) indDet[jj][0] = nSector;
2209 for (jj=0; jj<2; jj++) indDet[jj][1] = nPlate;
2210 for (jj=0; jj<2; jj++) indDet[jj][2] = nStrip;
2211 for (jj=0; jj<2; jj++) indDet[jj][3] = padsCluster[2*jj+3];
2212 for (jj=0; jj<2; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
2213 GetClusterPars(/*check,*/ 2, indDet, interestingWeight, posClus, covClus);
2214 for (jj=0; jj<2; jj++) delete [] indDet[jj];
2217 // To fill the track index array
2219 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2220 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2221 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
2224 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
2227 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2228 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
2231 alreadyStored = kFALSE;
2232 for (jj=0; jj<dummyCounter+1; jj++)
2233 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
2235 if (alreadyStored) continue;
2236 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2237 AliWarning(" Siamo al limite!");
2242 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
2249 AliTOFcluster *tofCluster =
2250 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
2251 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2252 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
2253 InsertCluster(tofCluster);
2255 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",
2256 volIdClus, posClus[0], posClus[1], posClus[2],
2257 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2258 tracks[0], tracks[1], tracks[2],
2259 det[0], det[1], det[2], det[3], det[4],
2260 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
2261 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
2266 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
2270 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
2273 } // close loop on second digit
2274 } // close loop on adesso2
2276 } // close loop on first digit
2277 } // close loop on adesso1
2279 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2280 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
2281 selectedDigit[ii][jj] = 0x0;
2285 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++) {
2286 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
2287 delete [] selectedDigit[ii][jj];
2288 selectedDigit[ii][jj] = 0x0;
2290 delete [] selectedDigit[ii];
2291 selectedDigit[ii] = 0x0;
2293 delete [] selectedDigit;
2294 selectedDigit = 0x0;
2297 //_____________________________________________________________________________
2299 void AliTOFClusterFinderV1::FindClustersPerStrip(Int_t nSector,
2305 // This function searches the neighbouring digits (stored in the fDigits object),
2306 // to perform clusters (stored in the fTofClusters array).
2308 // Each strip is read four times:
2309 // - 1st time: it searches possible clusters formed by four
2310 // neighbouring digits;
2311 // - 2nd time: it searches possible clusters formed by three
2312 // neighbouring digits;
2313 // - 3rd time: it searches possible clusters formed by two
2314 // neighbouring digits;
2315 // - 4th time: the remaining isolated digits have been transformed
2317 // This research has been made by checking the fTOFdigitMap object,
2318 // filled at digits/raw-data reading time.
2321 const Int_t kMaxNumberOfInterestingPads = 4;
2322 const Int_t kMaxNumberOfTracksPerDigit = 3;
2323 const Int_t kMaxNumberOfDigitsPerVolume = 10;
2327 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
2328 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2329 digitsInVolumeIndices[ii] = -1;
2331 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
2333 Float_t pos[3] = {0.,0.,0.};
2336 Int_t interestingPadX[kMaxNumberOfInterestingPads];
2337 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
2338 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
2339 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
2340 Double_t interestingTOT[kMaxNumberOfInterestingPads];
2341 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
2342 Double_t interestingADC[kMaxNumberOfInterestingPads];
2343 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
2344 Double_t interestingTOF[kMaxNumberOfInterestingPads];
2345 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
2346 Double_t interestingWeight[kMaxNumberOfInterestingPads];
2347 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
2349 Float_t interestingX[kMaxNumberOfInterestingPads];
2350 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
2351 Float_t interestingY[kMaxNumberOfInterestingPads];
2352 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
2353 Float_t interestingZ[kMaxNumberOfInterestingPads];
2354 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
2356 Float_t interDigit[kMaxNumberOfInterestingPads];
2357 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
2359 Int_t padsCluster[11];
2360 padsCluster[0] = nSector;
2361 padsCluster[1] = nPlate;
2362 padsCluster[2] = nStrip;
2363 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2365 Int_t interestingCounter=-1;
2366 Int_t digitIndexLocal = -1;
2371 Bool_t check = kFALSE;
2373 for (jj=0; jj<7; jj++) parTOF[jj] = 0;
2374 Double_t posClus[3];
2375 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
2377 for (jj=0; jj<5; jj++) det[jj] = -1;
2379 for (jj=0; jj<3; jj++) posF[jj] = 0.;
2380 UShort_t volIdClus = 0;
2381 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
2382 Double_t covClus[6];
2383 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2384 Int_t tracks[kMaxNumberOfTracksPerDigit];
2385 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2386 Int_t dummyCounter=-1;
2387 Bool_t alreadyStored = kFALSE;
2389 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
2390 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2391 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
2393 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2394 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
2396 AliTOFdigit *digitInteresting;
2400 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
2402 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
2403 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
2405 AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
2412 interestingCounter=-1;
2414 vol[4] = iPadZ , vol[3] = iPadX;
2415 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2416 interestingCounter++;
2418 vol[4] = iPadZ, vol[3] = iPadX+1;
2419 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2420 interestingCounter++;
2422 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
2423 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2424 interestingCounter++;
2426 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
2427 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2428 interestingCounter++;
2430 if (interestingCounter!=group) continue;
2431 else interestingCounter=-1;
2434 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2435 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
2436 selectedDigit[ii][jj] = 0x0;
2439 vol[4] = iPadZ, vol[3] = iPadX;
2441 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2442 interestingCounter++;
2443 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2444 digitsInVolumeIndices[ii] = -1;
2445 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2446 digitIndexLocal=-1; // AdC
2447 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2448 if (digitsInVolumeIndices[digIndex]<0) continue;
2449 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2450 if (digitInteresting->GetToT()<=0) continue; // AdC
2451 digitIndexLocal++; // AdC
2453 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2454 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2455 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2456 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2457 digitsInVolumeIndices[digIndex],
2458 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2459 AliDebug(1,Form(" to try %d %d ",digIndex, interestingCounter));
2461 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2462 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2463 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2464 digitInteresting->GetToT()*digitInteresting->GetToT(),
2465 digitsInVolumeIndices[digIndex],
2466 digitInteresting->GetTracks());
2468 if (digitIndexLocal==-1) interestingCounter--; // AdC
2472 vol[4] = iPadZ, vol[3] = iPadX+1;
2474 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2475 interestingCounter++;
2476 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2477 digitsInVolumeIndices[ii] = -1;
2478 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2479 digitIndexLocal=-1; // AdC
2480 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2481 if (digitsInVolumeIndices[digIndex]<0) continue;
2482 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2483 if (digitInteresting->GetToT()<=0) continue; // AdC
2484 digitIndexLocal++; // AdC
2486 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2487 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2488 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2489 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2490 digitsInVolumeIndices[digIndex],
2491 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2492 AliDebug(1,Form(" to try %d %d ",digIndex, interestingCounter));
2494 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2495 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2496 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2497 digitInteresting->GetToT()*digitInteresting->GetToT(),
2498 digitsInVolumeIndices[digIndex],
2499 digitInteresting->GetTracks());
2501 if (digitIndexLocal==-1) interestingCounter--; // AdC
2505 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
2507 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2508 interestingCounter++;
2509 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2510 digitsInVolumeIndices[ii] = -1;
2511 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2512 digitIndexLocal=-1; // AdC
2513 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2514 if (digitsInVolumeIndices[digIndex]<0) continue;
2515 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2516 if (digitInteresting->GetToT()<=0) continue; // AdC
2517 digitIndexLocal++; // AdC
2519 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2520 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2521 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2522 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2523 digitsInVolumeIndices[digIndex],
2524 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2525 AliDebug(1,Form(" to try %d %d ",digIndex, interestingCounter));
2527 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2528 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2529 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2530 digitInteresting->GetToT()*digitInteresting->GetToT(),
2531 digitsInVolumeIndices[digIndex],
2532 digitInteresting->GetTracks());
2534 if (digitIndexLocal==-1) interestingCounter--; // AdC
2538 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
2540 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2541 interestingCounter++;
2542 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2543 digitsInVolumeIndices[ii] = -1;
2544 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2545 digitIndexLocal=-1; // AdC
2546 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2547 if (digitsInVolumeIndices[digIndex]<0) continue;
2548 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2549 if (digitInteresting->GetToT()<=0) continue; // AdC
2550 digitIndexLocal++; // AdC
2552 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2553 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2554 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2555 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2556 digitsInVolumeIndices[digIndex],
2557 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2558 AliDebug(1,Form(" to try %d %d ",digIndex, interestingCounter));
2560 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2561 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2562 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2563 digitInteresting->GetToT()*digitInteresting->GetToT(),
2564 digitsInVolumeIndices[digIndex],
2565 digitInteresting->GetTracks());
2567 if (digitIndexLocal==-1) interestingCounter--; // AdC
2570 AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
2577 switch(interestingCounter+1) {
2581 //for (adesso1=0; adesso1<interestingCounter+1; adesso1++) {
2583 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2584 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2586 //for (adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
2588 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2589 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2591 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime) {
2592 AliDebug(1,Form(" selD1[%d][%d]->GetTDC()=%d selD2[%d][%d]->GetTDC()=%d -- %d ",
2593 adesso1,firstIndex,(Int_t)selectedDigit[adesso1][firstIndex]->GetTDC(),
2594 adesso2,secondIndex,(Int_t)selectedDigit[adesso2][secondIndex]->GetTDC(),
2599 AliDebug(1, Form(" %1d %1d (0x%p) %1d %1d (0x%p)", adesso1, firstIndex,selectedDigit[adesso1][firstIndex],
2600 adesso2, secondIndex,selectedDigit[adesso2][secondIndex]));
2602 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2603 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2604 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2605 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2606 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
2607 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
2608 Int_t volDum = vol1[3];
2611 fTOFGeometry->GetPosPar(vol1,pos);
2612 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
2613 interestingX[0] = pos[0];
2614 interestingY[0] = pos[1];
2615 interestingZ[0] = pos[2];
2617 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2618 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2619 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2620 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2621 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
2622 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
2626 fTOFGeometry->GetPosPar(vol2,pos);
2627 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
2628 interestingX[1] = pos[0];
2629 interestingY[1] = pos[1];
2630 interestingZ[1] = pos[2];
2633 AverageCalculations(interestingCounter+1,
2634 interestingX, interestingY, interestingZ,
2635 interestingTOF, interestingTOT, interestingADC,
2637 parTOF, posClus, check);
2639 for (jj=0; jj<5; jj++) det[jj] = -1;
2640 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
2642 AliDebug(1,Form(" %f %f %f", posF[0], posF[1], posF[2]));
2643 fTOFGeometry->GetDetID(posF, det);
2644 AliDebug(1,Form(" %2d %1d %2d %1d %2d", det[0], det[1], det[2], det[3], det[4]));
2646 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
2647 //volIdClus = GetClusterVolIndex(det);
2649 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2650 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
2651 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
2652 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
2653 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
2655 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2656 Int_t ** indDet = new Int_t*[interestingCounter+1];
2657 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj] = new Int_t [5];
2658 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][0] = nSector;
2659 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][1] = nPlate;
2660 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][2] = nStrip;
2661 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][3] = padsCluster[2*jj+3];
2662 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
2663 GetClusterPars(/*check,*/ interestingCounter+1, indDet, interestingWeight, posClus, covClus);
2664 for (jj=0; jj<interestingCounter+1; jj++) delete [] indDet[jj];
2667 // To fill the track index array
2669 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2670 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2671 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
2674 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
2677 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2678 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
2681 alreadyStored = kFALSE;
2682 for (jj=0; jj<dummyCounter+1; jj++)
2683 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
2685 if (alreadyStored) continue;
2686 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2687 AliWarning(" Siamo al limite!");
2692 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
2699 AliTOFcluster *tofCluster =
2700 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
2701 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2702 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); //to updated
2703 InsertCluster(tofCluster);
2705 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",
2706 volIdClus, posClus[0], posClus[1], posClus[2],
2707 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2708 tracks[0], tracks[1], tracks[2],
2709 det[0], det[1], det[2], det[3], det[4],
2710 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
2711 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
2716 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
2720 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
2723 } // close loop on second digit
2724 //} // close loop on adesso2
2726 } // close loop on first digit
2727 //} // close loop on adesso1
2734 //for (adesso1=0; adesso1<interestingCounter+1; adesso1++) {
2736 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2737 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2739 //for (adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
2741 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2742 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2744 //for (adesso3=adesso2+1; adesso3<interestingCounter+1; adesso3++) {
2746 for (Int_t thirdIndex=0; thirdIndex<kMaxNumberOfDigitsPerVolume; thirdIndex++) {
2747 if (selectedDigit[adesso3][thirdIndex]==0x0) continue;
2750 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime
2752 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
2754 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime) continue;
2756 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2757 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2758 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2759 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2760 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
2761 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
2762 Int_t volDum = vol1[3];
2765 fTOFGeometry->GetPosPar(vol1,pos);
2766 interestingX[0] = pos[0];
2767 interestingY[0] = pos[1];
2768 interestingZ[0] = pos[2];
2770 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2771 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2772 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2773 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2774 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
2775 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
2779 fTOFGeometry->GetPosPar(vol2,pos);
2780 interestingX[1] = pos[0];
2781 interestingY[1] = pos[1];
2782 interestingZ[1] = pos[2];
2784 interestingTOF[2] = selectedDigit[adesso3][thirdIndex]->GetTDC();
2785 interestingTOT[2] = selectedDigit[adesso3][thirdIndex]->GetTOT();
2786 interestingADC[2] = selectedDigit[adesso3][thirdIndex]->GetADC();
2787 interestingWeight[2] = selectedDigit[adesso3][thirdIndex]->GetWeight();
2788 Int_t vol3[5]; for(jj=0; jj<5; jj++) vol3[jj] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(jj);
2789 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol3[0], vol3[1], vol3[2], vol3[4], vol3[3]));
2793 fTOFGeometry->GetPosPar(vol3,pos);
2794 interestingX[2] = pos[0];
2795 interestingY[2] = pos[1];
2796 interestingZ[2] = pos[2];
2799 AverageCalculations(interestingCounter+1,
2800 interestingX, interestingY, interestingZ,
2801 interestingTOF, interestingTOT, interestingADC,
2803 parTOF, posClus, check);
2805 for (jj=0; jj<5; jj++) det[jj] = -1;
2806 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
2807 fTOFGeometry->GetDetID(posF, det);
2809 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
2810 //volIdClus = GetClusterVolIndex(det);
2812 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2813 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
2814 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
2815 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
2816 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
2817 padsCluster[7] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(4);
2818 padsCluster[8] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(3);
2820 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2821 Int_t ** indDet = new Int_t*[interestingCounter+1];
2822 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj] = new Int_t [5];
2823 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][0] = nSector;
2824 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][1] = nPlate;
2825 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][2] = nStrip;
2826 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][3] = padsCluster[2*jj+3];
2827 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
2828 GetClusterPars(/*check,*/ interestingCounter+1, indDet, interestingWeight, posClus, covClus);
2829 for (jj=0; jj<interestingCounter+1; jj++) delete [] indDet[jj];
2833 // To fill the track index array
2835 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2836 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2837 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
2840 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
2843 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2844 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
2847 alreadyStored = kFALSE;
2848 for (jj=0; jj<dummyCounter+1; jj++)
2849 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
2851 if (alreadyStored) continue;
2852 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2853 AliWarning(" Siamo al limite!");
2858 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
2863 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2864 if (selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk)==-1) continue;
2867 alreadyStored = kFALSE;
2868 for (jj=0; jj<dummyCounter+1; jj++)
2869 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk));
2871 if (alreadyStored) continue;
2872 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2873 AliWarning(" Siamo al limite!");
2878 tracks[dummyCounter] = selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk);
2885 AliTOFcluster *tofCluster =
2886 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
2887 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2888 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
2889 InsertCluster(tofCluster);
2891 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",
2892 volIdClus, posClus[0], posClus[1], posClus[2],
2893 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2894 tracks[0], tracks[1], tracks[2],
2895 det[0], det[1], det[2], det[3], det[4],
2896 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
2897 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
2902 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
2906 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
2910 fTOFdigitMap->ResetDigitNumber(vol3,selectedDigit[adesso3][thirdIndex]->GetIndex());
2913 } // close loop on third digit
2914 //} // close loop on adesso3
2916 } // close loop on second digit
2917 //} // close loop on adesso2
2919 } // close loop on first digit
2920 //} // close loop on adesso1
2928 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2929 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2932 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2933 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2936 for (Int_t thirdIndex=0; thirdIndex<kMaxNumberOfDigitsPerVolume; thirdIndex++) {
2937 if (selectedDigit[adesso3][thirdIndex]==0x0) continue;
2940 for (Int_t fourthIndex=0; fourthIndex<kMaxNumberOfDigitsPerVolume; fourthIndex++) {
2941 if (selectedDigit[adesso4][fourthIndex]==0x0) continue;
2944 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime
2946 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
2948 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso4][fourthIndex]->GetTDC())>fMaxDeltaTime
2950 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
2952 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso4][fourthIndex]->GetTDC())>fMaxDeltaTime
2954 TMath::Abs(selectedDigit[adesso3][thirdIndex]->GetTDC()-selectedDigit[adesso4][fourthIndex]->GetTDC())>fMaxDeltaTime) continue;
2956 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2957 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2958 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2959 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2960 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
2961 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
2962 Int_t volDum = vol1[3];
2965 fTOFGeometry->GetPosPar(vol1,pos);
2966 interestingX[0] = pos[0];
2967 interestingY[0] = pos[1];
2968 interestingZ[0] = pos[2];
2970 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2971 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2972 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2973 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2974 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
2975 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
2979 fTOFGeometry->GetPosPar(vol2,pos);
2980 interestingX[1] = pos[0];
2981 interestingY[1] = pos[1];
2982 interestingZ[1] = pos[2];
2984 interestingTOF[2] = selectedDigit[adesso3][thirdIndex]->GetTDC();
2985 interestingTOT[2] = selectedDigit[adesso3][thirdIndex]->GetTOT();
2986 interestingADC[2] = selectedDigit[adesso3][thirdIndex]->GetADC();
2987 interestingWeight[2] = selectedDigit[adesso3][thirdIndex]->GetWeight();
2988 Int_t vol3[5]; for(jj=0; jj<5; jj++) vol3[jj] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(jj);
2989 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol3[0], vol3[1], vol3[2], vol3[4], vol3[3]));
2993 fTOFGeometry->GetPosPar(vol3,pos);
2994 interestingX[2] = pos[0];
2995 interestingY[2] = pos[1];
2996 interestingZ[2] = pos[2];
2998 interestingTOF[3] = selectedDigit[adesso4][fourthIndex]->GetTDC();
2999 interestingTOT[3] = selectedDigit[adesso4][fourthIndex]->GetTOT();
3000 interestingADC[3] = selectedDigit[adesso4][fourthIndex]->GetADC();
3001 interestingWeight[3] = selectedDigit[adesso4][fourthIndex]->GetWeight();
3002 Int_t vol4[5]; for(jj=0; jj<5; jj++) vol4[jj] = selectedDigit[adesso4][fourthIndex]->GetDetectorIndex(jj);
3003 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol4[0], vol4[1], vol4[2], vol4[4], vol4[3]));
3007 fTOFGeometry->GetPosPar(vol4,pos);
3008 interestingX[3] = pos[0];
3009 interestingY[3] = pos[1];
3010 interestingZ[3] = pos[2];
3013 AverageCalculations(interestingCounter+1,
3014 interestingX, interestingY, interestingZ,
3015 interestingTOF, interestingTOT, interestingADC,
3017 parTOF, posClus, check);
3019 for (jj=0; jj<5; jj++) det[jj] = -1;
3020 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
3021 fTOFGeometry->GetDetID(posF, det);
3023 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
3024 //volIdClus = GetClusterVolIndex(det);
3026 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
3027 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
3028 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
3029 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
3030 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
3031 padsCluster[7] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(4);
3032 padsCluster[8] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(3);
3033 padsCluster[9] = selectedDigit[adesso4][fourthIndex]->GetDetectorIndex(4);
3034 padsCluster[10] = selectedDigit[adesso4][fourthIndex]->GetDetectorIndex(3);
3036 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
3037 Int_t ** indDet = new Int_t*[interestingCounter+1];
3038 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj] = new Int_t [5];
3039 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][0] = nSector;
3040 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][1] = nPlate;
3041 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][2] = nStrip;
3042 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][3] = padsCluster[2*jj+3];
3043 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
3044 GetClusterPars(/*check,*/ interestingCounter+1, indDet, interestingWeight, posClus, covClus);
3045 for (jj=0; jj<interestingCounter+1; jj++) delete [] indDet[jj];
3048 // To fill the track index array
3050 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
3051 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
3052 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
3055 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
3058 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
3059 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
3062 alreadyStored = kFALSE;
3063 for (jj=0; jj<dummyCounter+1; jj++)
3064 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
3066 if (alreadyStored) continue;
3067 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
3068 AliWarning(" Siamo al limite!");
3073 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
3078 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
3079 if (selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk)==-1) continue;
3082 alreadyStored = kFALSE;
3083 for (jj=0; jj<dummyCounter+1; jj++)
3084 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk));
3086 if (alreadyStored) continue;
3087 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
3088 AliWarning(" Siamo al limite!");
3093 tracks[dummyCounter] = selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk);
3098 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
3099 if (selectedDigit[adesso4][fourthIndex]->GetTrackLabel(kk)==-1) continue;
3102 alreadyStored = kFALSE;
3103 for (jj=0; jj<dummyCounter+1; jj++)
3104 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso4][fourthIndex]->GetTrackLabel(kk));
3106 if (alreadyStored) continue;
3107 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
3108 AliWarning(" Siamo al limite!");
3113 tracks[dummyCounter] = selectedDigit[adesso4][fourthIndex]->GetTrackLabel(kk);
3120 AliTOFcluster *tofCluster =
3121 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
3122 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
3123 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
3124 InsertCluster(tofCluster);
3126 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",
3127 volIdClus, posClus[0], posClus[1], posClus[2],
3128 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
3129 tracks[0], tracks[1], tracks[2],
3130 det[0], det[1], det[2], det[3], det[4],
3131 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
3132 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
3137 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
3141 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
3145 fTOFdigitMap->ResetDigitNumber(vol3,selectedDigit[adesso3][thirdIndex]->GetIndex());
3149 fTOFdigitMap->ResetDigitNumber(vol4,selectedDigit[adesso4][fourthIndex]->GetIndex());
3152 } // close loop on fourth digit
3154 } // close loop on third digit
3156 } // close loop on second digit
3158 } // close loop on first digit
3164 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
3165 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
3166 selectedDigit[ii][jj] = 0x0;
3170 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++) {
3171 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
3172 delete [] selectedDigit[ii][jj];
3173 selectedDigit[ii][jj] = 0x0;
3175 delete [] selectedDigit[ii];
3176 selectedDigit[ii] = 0x0;
3178 delete [] selectedDigit;
3179 selectedDigit = 0x0;
3182 //_____________________________________________________________________________
3184 Int_t AliTOFClusterFinderV1::InsertCluster(AliTOFcluster *tofCluster)
3187 // This function adds a TOF cluster to the array of TOF clusters
3188 // sorted in Z, i.e. fTofClusters
3191 if (fNumberOfTofClusters==kTofMaxCluster) {
3192 AliError("Too many clusters !");
3196 if (fNumberOfTofClusters==0) {
3197 fTofClusters[fNumberOfTofClusters++] = tofCluster;
3201 Int_t ii = FindClusterIndex(tofCluster->GetZ());
3202 memmove(fTofClusters+ii+1 ,fTofClusters+ii,(fNumberOfTofClusters-ii)*sizeof(AliTOFcluster*));
3203 fTofClusters[ii] = tofCluster;
3204 fNumberOfTofClusters++;
3209 //_____________________________________________________________________________
3211 Int_t AliTOFClusterFinderV1::FindClusterIndex(Double_t z) const
3214 // This function returns the index of the nearest cluster in z
3217 if (fNumberOfTofClusters==0) return 0;
3218 if (z <= fTofClusters[0]->GetZ()) return 0;
3219 if (z > fTofClusters[fNumberOfTofClusters-1]->GetZ()) return fNumberOfTofClusters;
3220 Int_t b = 0, e = fNumberOfTofClusters-1, m = (b+e)/2;
3221 for (; b<e; m=(b+e)/2) {
3222 if (z > fTofClusters[m]->GetZ()) b=m+1;
3229 //_____________________________________________________________________________
3231 void AliTOFClusterFinderV1::ResetRecpoint()
3234 // Clear the list of reconstructed points
3237 fNumberOfTofClusters = 0;
3238 fNumberOfTofTrgPads = 0;
3239 if (fRecPoints) fRecPoints->Clear();
3242 //_____________________________________________________________________________
3244 void AliTOFClusterFinderV1::ResetDigits()
3247 // Clear the list of digits
3250 fNumberOfTofDigits = 0;
3251 fNumberOfTofTrgPads = 0;
3252 if (fDigits) fDigits->Clear();
3255 //_____________________________________________________________________________
3256 //UShort_t AliTOFClusterFinderV1::GetClusterVolIndex(Int_t *ind) const
3259 // Get the volume ID to retrieve the l2t transformation
3262 // Detector numbering scheme
3264 Int_t nSector = AliTOFGeometry::NSectors();
3265 Int_t nPlate = AliTOFGeometry::NPlates();
3266 Int_t nStripA = AliTOFGeometry::NStripA();
3267 Int_t nStripB = AliTOFGeometry::NStripB();
3268 Int_t nStripC = AliTOFGeometry::NStripC();
3270 Int_t isector =ind[0];
3271 if (isector >= nSector)
3272 AliError(Form("Wrong sector number in TOF (%d) !", isector));
3273 Int_t iplate = ind[1];
3274 if (iplate >= nPlate)
3275 AliError(Form("Wrong plate number in TOF (%d) !", iplate));
3276 Int_t istrip = ind[2];
3278 Int_t stripOffset = 0;
3284 stripOffset = nStripC;
3287 stripOffset = nStripC+nStripB;
3290 stripOffset = nStripC+nStripB+nStripA;
3293 stripOffset = nStripC+nStripB+nStripA+nStripB;
3296 AliError(Form("Wrong plate number in TOF (%d) !", iplate));
3300 Int_t index= (2*(nStripC+nStripB)+nStripA)*isector +
3304 UShort_t volIndex = AliGeomManager::LayerToVolUID(AliGeomManager::kTOF, index);
3309 //_____________________________________________________________________________
3311 void AliTOFClusterFinderV1::GetClusterPars(Int_t *ind, Double_t* pos, Double_t* cov) const
3314 // Starting from the volume indices (ind[5]), for a cluster coming from
3315 // a isolated digits, this function returns:
3316 // the cluster position (pos),
3317 // the cluster covariance matrix elements (cov)
3321 //we now go in the system of the strip: determine the local coordinates
3324 // 47---------------------------------------------------0 ^ z
3325 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 1 |
3326 // ----------------------------------------------------- | y going outwards
3327 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 0 | par[0]=0;
3329 // ----------------------------------------------------- |
3330 // x <-----------------------------------------------------
3332 //move to the tracking ref system
3333 Double_t lpos[3] = { (ind[4]-23.5)*AliTOFGeometry::XPad(),
3335 (ind[3]- 0.5)*AliTOFGeometry::ZPad() };
3336 AliDebug(1, Form(" %f %f %f", lpos[0], lpos[1], lpos[2]));
3339 UShort_t volIndex = fTOFGeometry->GetAliSensVolIndex(ind[0],ind[1],ind[2]);
3340 //UShort_t volIndex = GetClusterVolIndex(ind);
3341 const TGeoHMatrix *l2t = AliGeomManager::GetTracking2LocalMatrix(volIndex);
3343 // Get the position in the track ref system
3345 l2t->MasterToLocal(lpos,tpos);
3350 //Get the cluster covariance in the track ref system
3352 for (Int_t ii=0; ii<9; ii++) lcov[ii] = 0.;
3354 //cluster covariance in the local system:
3359 lcov[4] = 0.42*0.42/3.;
3360 // = ( 5*0.025 (gas gaps thikness)
3361 // + 4*0.040 (internal glasses thickness)
3362 // + 0.5*0.160 (internl PCB)
3363 // + 1*0.055 (external red glass))
3366 lcov[0] = 0.499678;//AliTOFGeometry::XPad()*AliTOFGeometry::XPad()/12.;
3367 lcov[8] = 0.992429;//AliTOFGeometry::ZPad()*AliTOFGeometry::ZPad()/12.;
3369 //cluster covariance in the tracking system:
3371 m.SetRotation(lcov);
3373 m.MultiplyLeft(&l2t->Inverse());
3374 Double_t *tcov = m.GetRotationMatrix();
3375 cov[0] = tcov[0]; cov[1] = tcov[1]; cov[2] = tcov[2];
3376 cov[3] = tcov[4]; cov[4] = tcov[5]; cov[5] = tcov[8];
3381 //_____________________________________________________________________________
3383 void AliTOFClusterFinderV1::GetClusterPars(/*Bool_t check,*/ Int_t counter,
3384 Int_t **ind, Double_t *weight,
3385 Double_t *pos, Double_t *cov) const
3389 // the volumes indices (ind[counter][5]), for a
3390 // cluster coming from a collection of 'counter'
3392 // the volumes weights (weight[counter]), -controlled
3393 // by the 'check' variable control-, for a cluster
3394 // coming from a collection of 'counter' digits,
3395 // the cluster position (pos),
3396 // this function returns:
3397 // the covariance matrix elements (cov) for the found cluster
3401 // we now go in the system of the strip: determine the local coordinates
3403 // 47---------------------------------------------------0 ^ z
3404 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 1 |
3405 // ----------------------------------------------------- | y going outwards
3406 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 0 | par[0]=0;
3408 // ----------------------------------------------------- |
3409 // x <-----------------------------------------------------
3411 for (Int_t ii=0; ii<counter; ii++)
3412 AliDebug(1, Form(" %2d %2d %1d %2d %1d %2d ",
3413 ii, ind[ii][0], ind[ii][1], ind[ii][2], ind[ii][3], ind[ii][4]));
3415 Float_t posF[3]; for (Int_t ii=0; ii<3; ii++) posF[ii] = (Float_t)pos[ii];
3416 AliDebug(1, Form(" %f %f %f", pos[0], pos[1], pos[2]));
3418 Int_t detClus[5] = {-1, -1, -1, -1, -1};
3419 fTOFGeometry->GetDetID(posF, detClus);
3422 UShort_t volIndex = fTOFGeometry->GetAliSensVolIndex(detClus[0],detClus[1],detClus[2]);
3423 //UShort_t volIndex = GetClusterVolIndex(detClus);
3424 AliDebug(1, Form(" %2d %1d %2d %1d %2d %7i",
3425 detClus[0], detClus[1], detClus[2], detClus[3], detClus[4], volIndex));
3427 // Get the position in the TOF strip ref system
3428 const TGeoHMatrix *alice2strip = AliGeomManager::GetOrigGlobalMatrix(volIndex);
3429 Double_t ppos[3] = {-1, -1, -1};
3430 alice2strip->MasterToLocal(pos,ppos);
3431 AliDebug(1, Form(" %f %f %f", ppos[0], ppos[1], ppos[2]));
3434 // Get the position in the tracking ref system
3435 const TGeoHMatrix *g2l = AliGeomManager::GetTracking2LocalMatrix(volIndex);
3436 Double_t lpos[3] = {-1, -1, -1};
3437 g2l->MasterToLocal(ppos,lpos);
3438 AliDebug(1, Form(" %f %f %f", lpos[0], lpos[1], lpos[2]));
3439 for (Int_t ii=0; ii<3; ii++) pos[ii] = lpos[ii];
3441 //Get the cluster covariance in the track ref system
3443 for (Int_t ii=0; ii<9; ii++) lcov[ii] = 0.;
3445 //cluster covariance in the local system:
3450 // Evaluation of the ovariance matrix elements
3451 TOFclusterError(/*check,*/ counter, ind, weight, ppos, lcov);
3453 AliDebug(1, Form("lcov[0] = %f, lcov[8] = %f", lcov[0], lcov[8]));
3455 //cluster covariance in the tracking system:
3457 m.SetRotation(lcov);
3459 m.MultiplyLeft(&g2l->Inverse());
3460 Double_t *tcov = m.GetRotationMatrix();
3461 cov[0] = tcov[0]; cov[1] = tcov[1]; cov[2] = tcov[2];
3462 cov[3] = tcov[4]; cov[4] = tcov[5]; cov[5] = tcov[8];
3467 //_____________________________________________________________________________
3469 void AliTOFClusterFinderV1::TOFclusterError(/*Bool_t check,*/ Int_t counter,
3470 Int_t **ind, Double_t *weight,
3471 Double_t ppos[], Double_t lcov[]) const
3477 //lcov[4] = 0.42*0.42/3.; // cm2
3478 // = ( 5*0.025 (gas gaps thikness)
3479 // + 4*0.040 (internal glasses thickness)
3480 // + 0.5*0.160 (internl PCB)
3481 // + 1*0.055 (external red glass))
3484 Float_t *delta2X = new Float_t[counter];
3485 for (Int_t ii=0; ii<counter; ii++)
3487 ((ind[ii][4]-23.5)*AliTOFGeometry::XPad() - ppos[0])*((ind[ii][4]-23.5)*AliTOFGeometry::XPad() - ppos[0]);
3489 Float_t *delta2Z = new Float_t[counter];
3490 for (Int_t ii=0; ii<counter; ii++)
3492 ((ind[ii][3]- 0.5)*AliTOFGeometry::ZPad() - ppos[2])*((ind[ii][3]- 0.5)*AliTOFGeometry::ZPad() - ppos[2]);
3494 for (Int_t ii=0; ii<counter; ii++)
3495 AliDebug(1, Form("x[%d] = %f, z[%d] = %f, weight[%d] = %f",
3496 ii, (ind[ii][4]-23.5)*AliTOFGeometry::XPad(),
3497 ii, (ind[ii][3]- 0.5)*AliTOFGeometry::ZPad(),
3500 AliDebug(1, Form("xMean = %f, zMean = %f",ppos[0], ppos[2]));
3508 if (ind[0][3]==ind[1][3] && TMath::Abs(ind[0][4]-ind[1][4])==1) { //
3510 lcov[8] = 1.02039; // cm2
3511 lcov[0] = 0.0379409; // cm2
3514 lcov[0] = 0.5*0.5; // cm2
3516 if (weight[0]==weight[1])
3517 lcov[0] = 0.0379409; // cm2
3519 lcov[0] = TMath::Mean(counter, delta2X, weight); // cm2
3525 else if (ind[0][4]==ind[1][4] && TMath::Abs(ind[0][3]-ind[1][3])==1) {//
3527 lcov[0] = 0.505499; // cm2
3528 lcov[8] = 0.0422046; // cm2
3531 lcov[8] = 0.5*0.5; // cm2
3533 if (weight[0]==weight[1])
3534 lcov[8] = 0.0422046; // cm2
3536 lcov[8] = TMath::Mean(counter, delta2Z, weight); // cm2
3545 lcov[0] = 0.0290677; // cm2
3546 lcov[8] = 0.0569726; // cm2
3549 lcov[0] = 0.5*0.5; // cm2
3550 lcov[8] = 0.5*0.5; // cm2
3553 if (weight[0]==weight[1] && weight[0]==weight[2]) {
3554 lcov[0] = 0.0290677; // cm2
3555 lcov[8] = 0.0569726; // cm2
3558 lcov[0] = TMath::Mean(counter, delta2X, weight); // cm2
3559 lcov[8] = TMath::Mean(counter, delta2Z, weight); // cm2
3568 lcov[0] = 0.0223807; // cm2
3569 lcov[8] = 0.0438662; // cm2
3572 lcov[0] = 0.5*0.5; // cm2
3573 lcov[8] = 0.5*0.5; // cm2
3576 if (weight[0]==weight[1] && weight[0]==weight[2] && weight[0]==weight[3]) {
3577 lcov[0] = 0.0223807; // cm2
3578 lcov[8] = 0.0438662; // cm2
3581 lcov[0] = TMath::Mean(counter, delta2X, weight); // cm2
3582 lcov[8] = TMath::Mean(counter, delta2Z, weight); // cm2
3596 //_____________________________________________________________________________
3598 Bool_t AliTOFClusterFinderV1::MakeSlewingCorrection(Int_t *detectorIndex,
3604 // This funtion makes the following:
3606 // - if at least one of the three status (Pulser/Noise/HW) is
3607 // bad, is sets the status of electronic channel, corresponding to the
3608 // volume identified by detectorIndex, as kFALSE;
3609 // - if offline calibration is in the valid status, it performs the
3610 // slewing correction. In particular, by taking into account:
3611 // * the measured tot and tof values (tofDigitToT and tofDigitTdc,
3613 // * the six parameters of 5th order polynomial used
3614 // to fit the tofVStot scatter plot,
3615 // it returns the corrected tof value, i.e. tdcCorr value.
3618 Bool_t output = kTRUE;
3623 //AliInfo(" Calibrating TOF Digits: ");
3625 AliTOFChannelOnlineArray *calDelay = fTOFcalib->GetTOFOnlineDelay();
3626 AliTOFChannelOnlineStatusArray *calStatus = fTOFcalib->GetTOFOnlineStatus();
3628 TObjArray *calTOFArrayOffline = fTOFcalib->GetTOFCalArrayOffline();
3630 Int_t index = AliTOFGeometry::GetIndex(detectorIndex);
3632 UChar_t statusPulser = calStatus->GetPulserStatus(index);
3633 UChar_t statusNoise = calStatus->GetNoiseStatus(index);
3634 UChar_t statusHW = calStatus->GetHWStatus(index);
3635 UChar_t status = calStatus->GetStatus(index);
3637 //check the status, also unknown is fine!!!!!!!
3639 AliDebug(2, Form(" Status for channel %d = %d",index, (Int_t)status));
3640 if((statusPulser & AliTOFChannelOnlineStatusArray::kTOFPulserBad)==(AliTOFChannelOnlineStatusArray::kTOFPulserBad)||(statusNoise & AliTOFChannelOnlineStatusArray::kTOFNoiseBad)==(AliTOFChannelOnlineStatusArray::kTOFNoiseBad)||(statusHW & AliTOFChannelOnlineStatusArray::kTOFHWBad)==(AliTOFChannelOnlineStatusArray::kTOFHWBad)){
3641 AliDebug(2, Form(" Bad Status for channel %d",index));
3642 //fTofClusters[ii]->SetStatus(kFALSE); //odd convention, to avoid conflict with calibration objects currently in the db (temporary solution).
3646 AliDebug(2, Form(" Good Status for channel %d",index));
3649 if (fCalibrateTOFtimes) { // AdC
3651 // Get Rough channel online equalization
3652 Double_t roughDelay = (Double_t)calDelay->GetDelay(index); // in ns
3653 AliDebug(2,Form(" channel delay (ns) = %f", roughDelay));
3654 // Get Refined channel offline calibration parameters
3655 TString validity = (TString)fTOFcalib->GetOfflineValidity();
3656 if (validity.CompareTo("valid")==0) {
3657 AliTOFChannelOffline * calChannelOffline = (AliTOFChannelOffline*)calTOFArrayOffline->At(index);
3659 for (jj = 0; jj<6; jj++)
3660 par[jj] = (Double_t)calChannelOffline->GetSlewPar(jj);
3662 AliDebug(2,Form(" Calib Pars = %f, %f, %f, %f, %f, %f ",par[0],par[1],par[2],par[3],par[4],par[5]));
3663 AliDebug(2,Form(" The ToT and Time, uncorr (counts) = %d , %d", tofDigitToT, tofDigitTdc));
3664 Double_t tToT = (Double_t)(tofDigitToT*AliTOFGeometry::ToTBinWidth());
3665 tToT*=1.E-3; //ToT in ns
3666 AliDebug(2,Form(" The ToT and Time, uncorr (ns)= %e, %e",tofDigitTdc*AliTOFGeometry::TdcBinWidth()*1.E-3,tToT));
3667 timeCorr = par[0] + tToT*(par[1] + tToT*(par[2] + tToT*(par[3] + tToT*(par[4] + tToT*par[5])))); // the time correction (ns)
3670 timeCorr = roughDelay; // correction in ns
3672 AliDebug(2,Form(" The ToT and Time, uncorr (ns)= %e, %e",tofDigitTdc*AliTOFGeometry::TdcBinWidth()*1.E-3,tofDigitToT*AliTOFGeometry::ToTBinWidth()));
3673 AliDebug(2,Form(" The time correction (ns) = %f", timeCorr));
3674 timeCorr = (Double_t)(tofDigitTdc)*AliTOFGeometry::TdcBinWidth()*1.E-3-timeCorr;//redefine the time
3676 AliDebug(2,Form(" The channel time, corr (ps)= %e",timeCorr ));
3677 //tdcCorr = (Int_t)(timeCorr/AliTOFGeometry::TdcBinWidth()); //the corrected time (tdc counts)
3678 tdcCorr = TMath::Nint(timeCorr/AliTOFGeometry::TdcBinWidth()); //the corrected time (tdc counts)
3685 //______________________________________________________________________________
3687 void AliTOFClusterFinderV1::Digits2RecPoints(Int_t iEvent)
3690 // Converts digits to recpoints for TOF
3693 TStopwatch stopwatch;
3696 fRunLoader->GetEvent(iEvent);
3698 AliLoader *localTOFLoader = (AliLoader*)fRunLoader->GetLoader("TOFLoader");
3700 TTree * localTreeD = (TTree*)localTOFLoader->TreeD();
3701 if (localTreeD == 0x0) {
3702 AliFatal("Can not get TreeD");
3706 TBranch *branch = localTreeD->GetBranch("TOF");
3708 AliError("Can't get the branch with the TOF digits !");
3712 TTree *localTreeR = (TTree*)localTOFLoader->TreeR();
3713 if (localTreeR == 0x0)
3715 localTOFLoader->MakeTree("R");
3716 localTreeR = localTOFLoader->TreeR();
3719 Digits2RecPoints(localTreeD, localTreeR);
3721 //localTOFLoader = fRunLoader->GetLoader("TOFLoader");
3722 localTOFLoader->WriteRecPoints("OVERWRITE");
3724 AliDebug(1, Form("Execution time to read TOF digits and to write TOF clusters for the event number %d: R:%.4fs C:%.4fs",
3725 iEvent, stopwatch.RealTime(),stopwatch.CpuTime()));
3728 //______________________________________________________________________________
3730 void AliTOFClusterFinderV1::Digits2RecPoints(Int_t iEvent, AliRawReader *rawReader)
3733 // Converts RAW data to recpoints for TOF
3736 TStopwatch stopwatch;
3739 fRunLoader->GetEvent(iEvent);
3741 AliDebug(2,Form(" Event number %2d ", iEvent));
3743 AliLoader *localTOFLoader = (AliLoader*)fRunLoader->GetLoader("TOFLoader");
3745 TTree *localTreeR = localTOFLoader->TreeR();
3747 if (localTreeR == 0x0){
3748 localTOFLoader->MakeTree("R");
3749 localTreeR = localTOFLoader->TreeR();
3752 Digits2RecPoints(rawReader, localTreeR);
3754 AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters for the event number %d: R:%.4fs C:%.4fs",
3755 iEvent, stopwatch.RealTime(),stopwatch.CpuTime()));
3758 //______________________________________________________________________________
3760 void AliTOFClusterFinderV1::Raw2Digits(Int_t iEvent, AliRawReader *rawReader)
3763 // Converts RAW data to MC digits for TOF
3767 TStopwatch stopwatch;
3770 fRunLoader->GetEvent(iEvent);
3772 AliDebug(2,Form(" Event number %2d ", iEvent));
3774 AliLoader *localTOFLoader = (AliLoader*)fRunLoader->GetLoader("TOFLoader");
3776 TTree *localTreeD = localTOFLoader->TreeD();
3778 if (localTreeD == 0x0){
3779 localTOFLoader->MakeTree("D");
3780 localTreeD = localTOFLoader->TreeD();
3783 Raw2Digits(rawReader, localTreeD);
3785 AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters for the event number %d: R:%.4fs C:%.4fs",
3786 iEvent, stopwatch.RealTime(),stopwatch.CpuTime()));
3789 //______________________________________________________________________________
3791 void AliTOFClusterFinderV1::AverageCalculations(Int_t number, Float_t *interestingX,
3792 Float_t *interestingY, Float_t *interestingZ,
3793 Double_t *interestingTOF, Double_t *interestingTOT,
3794 Double_t *interestingADC, Double_t *interestingWeight,
3795 Int_t *parTOF, Double_t *posClus, Bool_t &check)
3798 // Calculates the mean values for cluster position (x,y,z),
3799 // TOF charge and time
3802 Double_t tofAverage = 0.;
3803 Double_t totAverage = 0.;
3804 Double_t adcAverage = 0.;
3808 for (ii=number-1; ii>=0; ii--) check=check||(interestingWeight[ii]==0 || interestingWeight[ii]==-1);
3812 posClus[0] = TMath::Mean(number, interestingX);
3813 posClus[1] = TMath::Mean(number, interestingY);
3814 posClus[2] = TMath::Mean(number, interestingZ);
3815 tofAverage = TMath::Mean(number, interestingTOF);
3816 totAverage = TMath::Mean(number, interestingTOT);
3817 adcAverage = TMath::Mean(number, interestingADC);
3822 posClus[0] = TMath::Mean(number, interestingX, interestingWeight);
3823 posClus[1] = TMath::Mean(number, interestingY, interestingWeight);
3824 posClus[2] = TMath::Mean(number, interestingZ, interestingWeight);
3825 tofAverage = TMath::Mean(number, interestingTOF, interestingWeight);
3826 totAverage = TMath::Mean(number, interestingTOT, interestingWeight);
3827 adcAverage = TMath::Mean(number, interestingADC, interestingWeight);
3831 parTOF[0] = Int_t(tofAverage);
3832 parTOF[1] = Int_t(totAverage);
3833 parTOF[2] = Int_t(adcAverage);
3834 parTOF[3] = Int_t(tofAverage);//tofND
3835 parTOF[4] = Int_t(tofAverage);//tofRAW