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++) {
713 digitIndex = fTofClusters[ii]->GetIndex();
714 for(jj=0; jj<5; jj++) detectorIndex[jj] = fTofClusters[ii]->GetDetInd(jj);
715 volIdClus = fTOFGeometry->GetAliSensVolIndex(detectorIndex[0],detectorIndex[1],detectorIndex[2]);
716 //volIdClus = GetClusterVolIndex(detectorIndex);
717 for(jj=0; jj<3; jj++) trackLabels[jj] = fTofClusters[ii]->GetLabel(jj);
718 parTOF[0] = fTofClusters[ii]->GetTDC(); // TDC
719 parTOF[1] = fTofClusters[ii]->GetToT(); // TOT
720 parTOF[2] = fTofClusters[ii]->GetADC(); // ADC=TOT
721 parTOF[3] = fTofClusters[ii]->GetTDCND(); // TDCND
722 parTOF[4] = fTofClusters[ii]->GetTDCRAW();//RAW
725 status = fTofClusters[ii]->GetStatus();
727 posClus[0] = fTofClusters[ii]->GetX();
728 posClus[1] = fTofClusters[ii]->GetY();
729 posClus[2] = fTofClusters[ii]->GetZ();
731 //for (jj=0; jj<6; jj++) covClus[jj] = 0.;
732 //((AliCluster*)fTofClusters[ii])->GetGlobalCov(covClus);
734 new(lRecPoints[ii]) AliTOFcluster(volIdClus, (Double_t)posClus[0], (Double_t)posClus[1], (Double_t)posClus[2],
735 (Double_t)(fTofClusters[ii]->GetSigmaX2()),
736 (Double_t)(fTofClusters[ii]->GetSigmaXY()),
737 (Double_t)(fTofClusters[ii]->GetSigmaXZ()),
738 (Double_t)(fTofClusters[ii]->GetSigmaY2()),
739 (Double_t)(fTofClusters[ii]->GetSigmaYZ()),
740 (Double_t)(fTofClusters[ii]->GetSigmaZ2()),
741 //(Double_t)covClus[0], (Double_t)covClus[1], (Double_t)covClus[2],
742 //(Double_t)covClus[3], (Double_t)covClus[4], (Double_t)covClus[5],
743 trackLabels, detectorIndex, parTOF, status, digitIndex);
745 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",
746 ii, volIdClus, posClus[0], posClus[1], posClus[2],
747 fTofClusters[ii]->GetSigmaX2(),
748 fTofClusters[ii]->GetSigmaXY(),
749 fTofClusters[ii]->GetSigmaXZ(),
750 fTofClusters[ii]->GetSigmaY2(),
751 fTofClusters[ii]->GetSigmaYZ(),
752 fTofClusters[ii]->GetSigmaZ2(),
753 trackLabels[0], trackLabels[1], trackLabels[2],
754 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[3], detectorIndex[4],
755 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
756 status, digitIndex));
761 for (Int_t iSector=0; iSector<AliTOFGeometry::NSectors(); iSector++)
762 for(Int_t iPlate=0; iPlate<AliTOFGeometry::NPlates(); iPlate++) {
763 for(Int_t iStrip=0; iStrip<AliTOFGeometry::NStrip(iPlate); iStrip++) {
764 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
765 AliDebug(2, Form(" END %2d %1d %2d %5d",
766 iSector, iPlate, iStrip, fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip)));
771 //_____________________________________________________________________________
773 void AliTOFClusterFinderV1::FindOnePadClusterPerStrip(Int_t nSector,
778 // This function searches the isolated digits (stored in the fDigits object),
779 // to perform clusters (stored in the fTofClusters array).
780 // This research has been made by checking the fTOFdigitMap object,
781 // filled at digits/raw-data reading time.
784 const Int_t kMaxNumberOfTracksPerDigit = 3;
785 const Int_t kMaxNumberOfDigitsPerVolume = 10;
789 Int_t det[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padZ,padX
790 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padX,padZ
791 UShort_t volIdClus = 0;
794 for (jj=0; jj<3; jj++) pos[jj] = 0.;
796 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
799 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
802 for (jj=0; jj<7; jj++) parTOF[jj] = 0;
804 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
806 Int_t tracks[kMaxNumberOfTracksPerDigit];
807 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
809 Int_t dummyCounter=-1;
811 AliTOFdigit *digitInteresting;
815 for (iPadX=0; iPadX<AliTOFGeometry::NpadX(); iPadX++) {
816 for (iPadZ=0; iPadZ<AliTOFGeometry::NpadZ(); iPadZ++) {
817 vol[4] = iPadZ , vol[3] = iPadX;
819 AliDebug(3, Form(" %1d %2d\n", iPadZ, iPadX));
821 if (fTOFdigitMap->GetNumberOfDigits(vol)==0) continue;
823 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
824 if (fTOFdigitMap->GetDigitIndex(vol,digIndex)<0) continue;
825 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(fTOFdigitMap->GetDigitIndex(vol,digIndex));
827 AliDebug(2, Form(" %3d %5d %2d %1d %2d %1d %2d %d %d %d %5d %5d %5d %5d",
828 fTOFdigitMap->GetNumberOfDigits(vol), digIndex,
829 vol[0], vol[1], vol[2] ,vol[4], vol[3],
830 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
831 digitInteresting->GetToT(),
832 fTOFdigitMap->GetDigitIndex(vol,digIndex),
833 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
835 det[3] = vol[4]; // padz
836 det[4] = vol[3]; // padx
837 fTOFGeometry->GetPosPar(det,pos);
838 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
841 for (jj=0; jj<3; jj++) posClus[jj] = pos[jj];
843 parTOF[0] = Int_t(digitInteresting->GetTdc());
844 parTOF[1] = Int_t(digitInteresting->GetToT());
845 parTOF[2] = Int_t(digitInteresting->GetAdc());
846 parTOF[3] = Int_t(digitInteresting->GetTdcND());
847 parTOF[4] = Int_t(digitInteresting->GetTdc());
851 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
852 //volIdClus = GetClusterVolIndex(det);
854 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
855 GetClusterPars(det, posClus, covClus);
857 // To fill the track index array
859 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
860 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) { // three is the max number of tracks associated to one digit
861 if (digitInteresting->GetTrack(jj)==-1) continue;
864 tracks[dummyCounter] = digitInteresting->GetTrack(jj);
868 AliTOFcluster *tofCluster =
869 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
870 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
871 tracks, det, parTOF, status, fTOFdigitMap->GetDigitIndex(vol,digIndex));
872 InsertCluster(tofCluster);
874 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",
875 volIdClus, posClus[0], posClus[1], posClus[2],
876 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
877 tracks[0], tracks[1], tracks[2],
878 det[0], det[1], det[2], det[3], det[4],
879 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
880 status, fTOFdigitMap->GetDigitIndex(vol,digIndex)));
882 AliDebug(2, Form(" %f %f %f", pos[0], pos[1], pos[2]));
883 AliDebug(2, Form(" %d %d", parTOF[0], parTOF[2]));
885 fTOFdigitMap->ResetDigit(vol, digIndex);
893 //_____________________________________________________________________________
895 void AliTOFClusterFinderV1::FindClustersWithoutTOT(Int_t nSector,
900 // This function searches the isolated digits without TOT
901 // measurement (stored in the fDigits object), to perform clusters
902 // (stored in the fTofClusters array). This research has been made
903 // by checking the fTOFdigitMap object, filled at digits/raw-data
907 const Int_t kMaxNumberOfTracksPerDigit = 3;
908 const Int_t kMaxNumberOfDigitsPerVolume = 10;
912 Int_t det[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padZ,padX
913 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padX,padZ
914 UShort_t volIdClus = 0;
917 for (jj=0; jj<3; jj++) pos[jj] = 0.;
919 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
922 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
925 for (jj=0; jj<7; jj++) parTOF[jj] = 0;
927 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
928 Int_t tracks[kMaxNumberOfTracksPerDigit];
929 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
931 Int_t dummyCounter=-1;
933 AliTOFdigit *digitInteresting;
937 for (iPadX=0; iPadX<AliTOFGeometry::NpadX(); iPadX++) {
938 for (iPadZ=0; iPadZ<AliTOFGeometry::NpadZ(); iPadZ++) {
939 vol[4] = iPadZ , vol[3] = iPadX;
941 AliDebug(3, Form(" %1d %2d\n", iPadZ, iPadX));
943 if (fTOFdigitMap->GetNumberOfDigits(vol)==0) continue;
945 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
946 if (fTOFdigitMap->GetDigitIndex(vol,digIndex)<0) continue;
947 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(fTOFdigitMap->GetDigitIndex(vol,digIndex));
948 if (digitInteresting->GetToT()>0) continue; // AdC
950 AliDebug(2, Form(" %3d %5d %2d %1d %2d %1d %2d %d %d %d %5d %5d %5d %5d",
951 fTOFdigitMap->GetNumberOfDigits(vol), digIndex,
952 vol[0], vol[1], vol[2] ,vol[4], vol[3],
953 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
954 digitInteresting->GetToT(),
955 fTOFdigitMap->GetDigitIndex(vol,digIndex),
956 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
958 det[3] = vol[4]; // padz
959 det[4] = vol[3]; // padx
960 fTOFGeometry->GetPosPar(det,pos);
961 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
964 for (jj=0; jj<3; jj++) posClus[jj] = pos[jj];
966 parTOF[0] = Int_t(digitInteresting->GetTdc());
967 parTOF[1] = Int_t(digitInteresting->GetToT());
968 parTOF[2] = Int_t(digitInteresting->GetAdc());
969 parTOF[3] = Int_t(digitInteresting->GetTdcND());
970 parTOF[4] = Int_t(digitInteresting->GetTdc());
974 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
975 //volIdClus = GetClusterVolIndex(det);
977 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
978 GetClusterPars(det, posClus, covClus);
980 // To fill the track index array
982 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
983 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) { // three is the max number of tracks associated to one digit
984 if (digitInteresting->GetTrack(jj)==-1) continue;
987 tracks[dummyCounter] = digitInteresting->GetTrack(jj);
991 AliTOFcluster *tofCluster =
992 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
993 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
994 tracks, det, parTOF, status, fTOFdigitMap->GetDigitIndex(vol,digIndex));
995 InsertCluster(tofCluster);
997 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",
998 volIdClus, posClus[0], posClus[1], posClus[2],
999 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1000 tracks[0], tracks[1], tracks[2],
1001 det[0], det[1], det[2], det[3], det[4],
1002 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
1003 status, fTOFdigitMap->GetDigitIndex(vol,digIndex)));
1005 AliDebug(2, Form(" %f %f %f", pos[0], pos[1], pos[2]));
1006 AliDebug(2, Form(" %d %d", parTOF[0], parTOF[2]));
1008 fTOFdigitMap->ResetDigit(vol, digIndex);
1016 //_____________________________________________________________________________
1018 void AliTOFClusterFinderV1::FindClusters34(Int_t nSector,
1023 // This function searches the neighbouring digits (stored in the fDigits object),
1024 // to perform clusters (stored in the fTofClusters array).
1026 // This research has been made by checking the fTOFdigitMap object,
1027 // filled at digits/raw-data reading time.
1030 const Int_t kMaxNumberOfInterestingPads = 4;
1031 const Int_t kMaxNumberOfTracksPerDigit = 3;
1032 const Int_t kMaxNumberOfDigitsPerVolume = 10;
1036 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
1037 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1038 digitsInVolumeIndices[ii] = -1;
1040 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
1042 Float_t pos[3] = {0.,0.,0.};
1045 Int_t interestingPadX[kMaxNumberOfInterestingPads];
1046 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
1047 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
1048 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
1049 Double_t interestingTOT[kMaxNumberOfInterestingPads];
1050 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
1051 Double_t interestingADC[kMaxNumberOfInterestingPads];
1052 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
1053 Double_t interestingTOF[kMaxNumberOfInterestingPads];
1054 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
1055 Double_t interestingWeight[kMaxNumberOfInterestingPads];
1056 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
1058 Float_t interestingX[kMaxNumberOfInterestingPads];
1059 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
1060 Float_t interestingY[kMaxNumberOfInterestingPads];
1061 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
1062 Float_t interestingZ[kMaxNumberOfInterestingPads];
1063 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
1065 Float_t interDigit[kMaxNumberOfInterestingPads];
1066 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
1068 Int_t padsCluster[11];
1069 padsCluster[0] = nSector;
1070 padsCluster[1] = nPlate;
1071 padsCluster[2] = nStrip;
1072 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1074 Int_t interestingCounter=-1;
1075 Int_t digitIndexLocal=-1; // AdC
1081 for (jj=0; jj<7; jj++) parTOF[jj] = 0;
1082 Double_t posClus[3];
1083 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
1085 for (jj=0; jj<5; jj++) det[jj] = -1;
1087 for (jj=0; jj<3; jj++) posF[jj] = 0.;
1088 UShort_t volIdClus = 0;
1089 Bool_t check = kFALSE;
1090 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
1091 Double_t covClus[6];
1092 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1093 Int_t tracks[kMaxNumberOfTracksPerDigit];
1094 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1095 Int_t dummyCounter=-1;
1096 Bool_t alreadyStored = kFALSE;
1098 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
1099 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1100 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
1102 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1103 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
1105 AliTOFdigit *digitInteresting;
1107 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
1109 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
1110 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
1112 AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
1119 interestingCounter=-1;
1121 vol[4] = iPadZ , vol[3] = iPadX;
1122 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1123 interestingCounter++;
1125 vol[4] = iPadZ, vol[3] = iPadX+1;
1126 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1127 interestingCounter++;
1129 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1130 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1131 interestingCounter++;
1133 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1134 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1135 interestingCounter++;
1137 if (interestingCounter+1!=4) continue; // the hit pads have to be 4
1138 else interestingCounter=-1;
1141 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1142 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1143 selectedDigit[ii][jj] = 0x0;
1146 vol[4] = iPadZ, vol[3] = iPadX;
1148 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1149 interestingCounter++;
1150 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1151 digitsInVolumeIndices[ii] = -1;
1152 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1153 digitIndexLocal=-1; // AdC
1154 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1155 if (digitsInVolumeIndices[digIndex]<0) continue;
1156 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1157 if (digitInteresting->GetToT()<=0) continue; // AdC
1158 digitIndexLocal++; // AdC
1160 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1161 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1162 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1163 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1164 digitsInVolumeIndices[digIndex],
1165 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1168 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1169 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1170 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1171 digitInteresting->GetToT()*digitInteresting->GetToT(),
1172 digitsInVolumeIndices[digIndex],
1173 digitInteresting->GetTracks());
1175 if (digitIndexLocal==-1) interestingCounter--; // AdC
1179 vol[4] = iPadZ, vol[3] = iPadX+1;
1181 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1182 interestingCounter++;
1183 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1184 digitsInVolumeIndices[ii] = -1;
1185 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1186 digitIndexLocal=-1; // AdC
1187 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1188 if (digitsInVolumeIndices[digIndex]<0) continue;
1189 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1190 if (digitInteresting->GetToT()<=0) continue; // AdC
1191 digitIndexLocal++; // AdC
1193 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1194 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1195 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1196 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1197 digitsInVolumeIndices[digIndex],
1198 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1201 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1202 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1203 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1204 digitInteresting->GetToT()*digitInteresting->GetToT(),
1205 digitsInVolumeIndices[digIndex],
1206 digitInteresting->GetTracks());
1208 if (digitIndexLocal==-1) interestingCounter--; // AdC
1212 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1214 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1215 interestingCounter++;
1216 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1217 digitsInVolumeIndices[ii] = -1;
1218 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1219 digitIndexLocal=-1; // AdC
1220 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1221 if (digitsInVolumeIndices[digIndex]<0) continue;
1222 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1223 if (digitInteresting->GetToT()<=0) continue; // AdC
1224 digitIndexLocal++; // AdC
1226 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1227 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1228 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1229 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1230 digitsInVolumeIndices[digIndex],
1231 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1234 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1235 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1236 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1237 digitInteresting->GetToT()*digitInteresting->GetToT(),
1238 digitsInVolumeIndices[digIndex],
1239 digitInteresting->GetTracks());
1241 if (digitIndexLocal==-1) interestingCounter--; // AdC
1245 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1247 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1248 interestingCounter++;
1249 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1250 digitsInVolumeIndices[ii] = -1;
1251 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1253 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1254 if (digitsInVolumeIndices[digIndex]<0) continue;
1255 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1256 if (digitInteresting->GetToT()<=0) continue; // AdC
1257 digitIndexLocal++; // AdC
1259 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1260 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1261 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1262 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1263 digitsInVolumeIndices[digIndex],
1264 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1266 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1267 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1268 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1269 digitInteresting->GetToT()*digitInteresting->GetToT(),
1270 digitsInVolumeIndices[digIndex],
1271 digitInteresting->GetTracks());
1273 if (digitIndexLocal==-1) interestingCounter--; // AdC
1276 AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
1278 for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
1279 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
1280 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
1282 for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
1283 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
1284 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
1286 for (Int_t adesso3=adesso2+1; adesso3<interestingCounter+1; adesso3++) {
1287 for (Int_t thirdIndex=0; thirdIndex<kMaxNumberOfDigitsPerVolume; thirdIndex++) {
1288 if (selectedDigit[adesso3][thirdIndex]==0x0) continue;
1291 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime
1293 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
1295 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime) continue;
1297 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
1298 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
1299 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
1300 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
1301 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
1302 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
1303 Int_t volDum = vol1[3];
1306 fTOFGeometry->GetPosPar(vol1,pos);
1307 interestingX[0] = pos[0];
1308 interestingY[0] = pos[1];
1309 interestingZ[0] = pos[2];
1311 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
1312 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
1313 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
1314 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
1315 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
1316 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
1320 fTOFGeometry->GetPosPar(vol2,pos);
1321 interestingX[1] = pos[0];
1322 interestingY[1] = pos[1];
1323 interestingZ[1] = pos[2];
1325 interestingTOF[2] = selectedDigit[adesso3][thirdIndex]->GetTDC();
1326 interestingTOT[2] = selectedDigit[adesso3][thirdIndex]->GetTOT();
1327 interestingADC[2] = selectedDigit[adesso3][thirdIndex]->GetADC();
1328 interestingWeight[2] = selectedDigit[adesso3][thirdIndex]->GetWeight();
1329 Int_t vol3[5]; for(jj=0; jj<5; jj++) vol3[jj] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(jj);
1330 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol3[0], vol3[1], vol3[2], vol3[4], vol3[3]));
1334 fTOFGeometry->GetPosPar(vol3,pos);
1335 interestingX[2] = pos[0];
1336 interestingY[2] = pos[1];
1337 interestingZ[2] = pos[2];
1340 AverageCalculations(3, interestingX, interestingY, interestingZ,
1341 interestingTOF, interestingTOT, interestingADC,
1343 parTOF, posClus, check);
1346 for (jj=0; jj<5; jj++) det[jj] = -1;
1347 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
1348 fTOFGeometry->GetDetID(posF, det);
1350 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
1351 //volIdClus = GetClusterVolIndex(det);
1353 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1354 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
1355 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
1356 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
1357 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
1358 padsCluster[7] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(4);
1359 padsCluster[8] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(3);
1361 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1362 Int_t ** indDet = new Int_t*[3];
1363 for (jj=0; jj<3; jj++) indDet[jj] = new Int_t [5];
1364 for (jj=0; jj<3; jj++) indDet[jj][0] = nSector;
1365 for (jj=0; jj<3; jj++) indDet[jj][1] = nPlate;
1366 for (jj=0; jj<3; jj++) indDet[jj][2] = nStrip;
1367 for (jj=0; jj<3; jj++) indDet[jj][3] = padsCluster[2*jj+3];
1368 for (jj=0; jj<3; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
1369 GetClusterPars(/*check,*/ 3, indDet, interestingWeight, posClus, covClus);
1370 for (jj=0; jj<3; jj++) delete [] indDet[jj];
1373 // To fill the track index array
1375 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1376 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1377 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
1380 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
1383 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1384 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
1387 alreadyStored = kFALSE;
1388 for (jj=0; jj<dummyCounter+1; jj++)
1389 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
1391 if (alreadyStored) continue;
1392 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
1393 AliWarning(" Siamo al limite!");
1398 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
1403 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1404 if (selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk)==-1) continue;
1407 alreadyStored = kFALSE;
1408 for (jj=0; jj<dummyCounter+1; jj++)
1409 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk));
1411 if (alreadyStored) continue;
1412 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
1413 AliWarning(" Siamo al limite!");
1418 tracks[dummyCounter] = selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk);
1425 AliTOFcluster *tofCluster =
1426 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
1427 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1428 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
1429 InsertCluster(tofCluster);
1431 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",
1432 volIdClus, posClus[0], posClus[1], posClus[2],
1433 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1434 tracks[0], tracks[1], tracks[2],
1435 det[0], det[1], det[2], det[3], det[4],
1436 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
1437 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
1443 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
1447 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
1451 fTOFdigitMap->ResetDigitNumber(vol3,selectedDigit[adesso3][thirdIndex]->GetIndex());
1454 } // close loop on third digit
1455 } // close loop on adesso3
1457 } // close loop on second digit
1458 } // close loop on adesso2
1460 } // close loop on first digit
1461 } // close loop on adesso1
1463 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1464 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1465 selectedDigit[ii][jj] = 0x0;
1469 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++) {
1470 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
1471 delete [] selectedDigit[ii][jj];
1472 selectedDigit[ii][jj] = 0x0;
1474 delete [] selectedDigit[ii];
1475 selectedDigit[ii] = 0x0;
1477 delete [] selectedDigit;
1478 selectedDigit = 0x0;
1481 //_____________________________________________________________________________
1483 void AliTOFClusterFinderV1::FindClusters23(Int_t nSector,
1488 // This function searches the neighbouring digits (stored in the fDigits object),
1489 // to perform clusters (stored in the fTofClusters array).
1491 // This research has been made by checking the fTOFdigitMap object,
1492 // filled at digits/raw-data reading time.
1495 const Int_t kMaxNumberOfInterestingPads = 4;
1496 const Int_t kMaxNumberOfTracksPerDigit = 3;
1497 const Int_t kMaxNumberOfDigitsPerVolume = 10;
1501 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
1502 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1503 digitsInVolumeIndices[ii] = -1;
1505 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
1507 Float_t pos[3] = {0.,0.,0.};
1510 Int_t interestingPadX[kMaxNumberOfInterestingPads];
1511 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
1512 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
1513 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
1514 Double_t interestingTOT[kMaxNumberOfInterestingPads];
1515 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
1516 Double_t interestingADC[kMaxNumberOfInterestingPads];
1517 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
1518 Double_t interestingTOF[kMaxNumberOfInterestingPads];
1519 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
1520 Double_t interestingWeight[kMaxNumberOfInterestingPads];
1521 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
1523 Float_t interestingX[kMaxNumberOfInterestingPads];
1524 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
1525 Float_t interestingY[kMaxNumberOfInterestingPads];
1526 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
1527 Float_t interestingZ[kMaxNumberOfInterestingPads];
1528 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
1530 Float_t interDigit[kMaxNumberOfInterestingPads];
1531 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
1533 Int_t padsCluster[11];
1534 padsCluster[0] = nSector;
1535 padsCluster[1] = nPlate;
1536 padsCluster[2] = nStrip;
1537 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1539 Int_t interestingCounter=-1;
1540 Int_t digitIndexLocal = -1;
1545 Bool_t check = kFALSE;
1547 for (jj=0; jj<7; jj++) parTOF[jj] = 0;
1548 Double_t posClus[3];
1549 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
1551 for (jj=0; jj<5; jj++) det[jj] = -1;
1553 for (jj=0; jj<3; jj++) posF[jj] = 0.;
1554 UShort_t volIdClus = 0;
1555 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
1556 Double_t covClus[6];
1557 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1558 Int_t tracks[kMaxNumberOfTracksPerDigit];
1559 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1560 Int_t dummyCounter=-1;
1561 Bool_t alreadyStored = kFALSE;
1563 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
1564 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1565 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
1567 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1568 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
1570 AliTOFdigit *digitInteresting;
1572 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
1574 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
1575 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
1577 AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
1584 interestingCounter=-1;
1586 vol[4] = iPadZ , vol[3] = iPadX;
1587 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1588 interestingCounter++;
1590 vol[4] = iPadZ, vol[3] = iPadX+1;
1591 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1592 interestingCounter++;
1594 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1595 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1596 interestingCounter++;
1598 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1599 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1600 interestingCounter++;
1602 if (interestingCounter+1!=3) continue; // the hit pads have to be 3
1603 else interestingCounter=-1;
1606 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1607 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1608 selectedDigit[ii][jj] = 0x0;
1611 vol[4] = iPadZ, vol[3] = iPadX;
1613 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1614 interestingCounter++;
1615 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1616 digitsInVolumeIndices[ii] = -1;
1617 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1619 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1620 if (digitsInVolumeIndices[digIndex]<0) continue;
1621 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1622 if (digitInteresting->GetToT()<=0) continue; // AdC
1623 digitIndexLocal++; // AdC
1625 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1626 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1627 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1628 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1629 digitsInVolumeIndices[digIndex],
1630 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1632 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1633 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1634 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1635 digitInteresting->GetToT()*digitInteresting->GetToT(),
1636 digitsInVolumeIndices[digIndex],
1637 digitInteresting->GetTracks());
1639 if (digitIndexLocal==-1) interestingCounter--; // AdC
1643 vol[4] = iPadZ, vol[3] = iPadX+1;
1645 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1646 interestingCounter++;
1647 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1648 digitsInVolumeIndices[ii] = -1;
1649 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1650 digitIndexLocal=-1; // AdC
1651 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1652 if (digitsInVolumeIndices[digIndex]<0) continue;
1653 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1654 if (digitInteresting->GetToT()<=0) continue; // AdC
1655 digitIndexLocal++; // AdC
1657 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1658 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1659 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1660 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1661 digitsInVolumeIndices[digIndex],
1662 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1664 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1665 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1666 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1667 digitInteresting->GetToT()*digitInteresting->GetToT(),
1668 digitsInVolumeIndices[digIndex],
1669 digitInteresting->GetTracks());
1671 if (digitIndexLocal==-1) interestingCounter--; // AdC
1675 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1677 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1678 interestingCounter++;
1679 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1680 digitsInVolumeIndices[ii] = -1;
1681 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1682 digitIndexLocal=-1; // AdC
1683 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1684 if (digitsInVolumeIndices[digIndex]<0) continue;
1685 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1686 if (digitInteresting->GetToT()<=0) continue; // AdC
1687 digitIndexLocal++; // AdC
1689 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1690 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1691 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1692 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1693 digitsInVolumeIndices[digIndex],
1694 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1696 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1697 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1698 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1699 digitInteresting->GetToT()*digitInteresting->GetToT(),
1700 digitsInVolumeIndices[digIndex],
1701 digitInteresting->GetTracks());
1703 if (digitIndexLocal==-1) interestingCounter--; // AdC
1707 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1709 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1710 interestingCounter++;
1711 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1712 digitsInVolumeIndices[ii] = -1;
1713 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
1714 digitIndexLocal=-1; // AdC
1715 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1716 if (digitsInVolumeIndices[digIndex]<0) continue;
1717 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
1718 if (digitInteresting->GetToT()<=0) continue; // AdC
1719 digitIndexLocal++; // AdC
1721 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
1722 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1723 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1724 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1725 digitsInVolumeIndices[digIndex],
1726 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1728 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
1729 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1730 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1731 digitInteresting->GetToT()*digitInteresting->GetToT(),
1732 digitsInVolumeIndices[digIndex],
1733 digitInteresting->GetTracks());
1735 if (digitIndexLocal==-1) interestingCounter--; // AdC
1738 AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
1740 for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
1741 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
1742 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
1744 for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
1745 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
1746 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
1748 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime) continue;
1750 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
1751 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
1752 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
1753 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
1754 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
1755 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
1756 Int_t volDum = vol1[3];
1759 fTOFGeometry->GetPosPar(vol1,pos);
1760 interestingX[0] = pos[0];
1761 interestingY[0] = pos[1];
1762 interestingZ[0] = pos[2];
1764 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
1765 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
1766 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
1767 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
1768 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
1769 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
1773 fTOFGeometry->GetPosPar(vol2,pos);
1774 interestingX[1] = pos[0];
1775 interestingY[1] = pos[1];
1776 interestingZ[1] = pos[2];
1778 AverageCalculations(2, interestingX, interestingY, interestingZ,
1779 interestingTOF, interestingTOT, interestingADC,
1781 parTOF, posClus, check);
1783 for (jj=0; jj<5; jj++) det[jj] = -1;
1784 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
1785 fTOFGeometry->GetDetID(posF, det);
1787 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
1788 //volIdClus = GetClusterVolIndex(det);
1790 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1791 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
1792 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
1793 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
1794 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
1796 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1797 Int_t ** indDet = new Int_t*[2];
1798 for (jj=0; jj<2; jj++) indDet[jj] = new Int_t [5];
1799 for (jj=0; jj<2; jj++) indDet[jj][0] = nSector;
1800 for (jj=0; jj<2; jj++) indDet[jj][1] = nPlate;
1801 for (jj=0; jj<2; jj++) indDet[jj][2] = nStrip;
1802 for (jj=0; jj<2; jj++) indDet[jj][3] = padsCluster[2*jj+3];
1803 for (jj=0; jj<2; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
1804 GetClusterPars(/*check,*/ 2, indDet, interestingWeight, posClus, covClus);
1805 for (jj=0; jj<2; jj++) delete [] indDet[jj];
1808 // To fill the track index array
1810 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1811 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1812 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
1815 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
1818 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1819 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
1822 alreadyStored = kFALSE;
1823 for (jj=0; jj<dummyCounter+1; jj++)
1824 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
1826 if (alreadyStored) continue;
1827 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
1828 AliWarning(" Siamo al limite!");
1833 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
1840 AliTOFcluster *tofCluster =
1841 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
1842 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1843 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
1844 InsertCluster(tofCluster);
1846 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",
1847 volIdClus, posClus[0], posClus[1], posClus[2],
1848 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1849 tracks[0], tracks[1], tracks[2],
1850 det[0], det[1], det[2], det[3], det[4],
1851 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
1852 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
1857 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
1861 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
1864 } // close loop on second digit
1865 } // close loop on adesso2
1867 } // close loop on first digit
1868 } // close loop on adesso1
1870 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1871 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1872 selectedDigit[ii][jj] = 0x0;
1876 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++) {
1877 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
1878 delete [] selectedDigit[ii][jj];
1879 selectedDigit[ii][jj] = 0x0;
1881 delete [] selectedDigit[ii];
1882 selectedDigit[ii] = 0x0;
1884 delete [] selectedDigit;
1885 selectedDigit = 0x0;
1888 //_____________________________________________________________________________
1890 void AliTOFClusterFinderV1::FindClusters24(Int_t nSector,
1895 // This function searches the neighbouring digits (stored in the fDigits object),
1896 // to perform clusters (stored in the fTofClusters array).
1898 // This research has been made by checking the fTOFdigitMap object,
1899 // filled at digits/raw-data reading time.
1902 const Int_t kMaxNumberOfInterestingPads = 4;
1903 const Int_t kMaxNumberOfTracksPerDigit = 3;
1904 const Int_t kMaxNumberOfDigitsPerVolume = 10;
1908 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
1909 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1910 digitsInVolumeIndices[ii] = -1;
1912 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
1914 Float_t pos[3] = {0.,0.,0.};
1917 Int_t interestingPadX[kMaxNumberOfInterestingPads];
1918 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
1919 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
1920 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
1921 Double_t interestingTOT[kMaxNumberOfInterestingPads];
1922 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
1923 Double_t interestingADC[kMaxNumberOfInterestingPads];
1924 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
1925 Double_t interestingTOF[kMaxNumberOfInterestingPads];
1926 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
1927 Double_t interestingWeight[kMaxNumberOfInterestingPads];
1928 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
1930 Float_t interestingX[kMaxNumberOfInterestingPads];
1931 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
1932 Float_t interestingY[kMaxNumberOfInterestingPads];
1933 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
1934 Float_t interestingZ[kMaxNumberOfInterestingPads];
1935 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
1937 Float_t interDigit[kMaxNumberOfInterestingPads];
1938 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
1940 Int_t padsCluster[11];
1941 padsCluster[0] = nSector;
1942 padsCluster[1] = nPlate;
1943 padsCluster[2] = nStrip;
1944 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1946 Int_t interestingCounter=-1;
1947 Int_t digitIndexLocal = -1;
1952 Bool_t check = kFALSE;
1954 for (jj=0; jj<7; jj++) parTOF[jj] = 0;
1955 Double_t posClus[3];
1956 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
1958 for (jj=0; jj<5; jj++) det[jj] = -1;
1960 for (jj=0; jj<3; jj++) posF[jj] = 0.;
1961 UShort_t volIdClus = 0;
1962 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
1963 Double_t covClus[6];
1964 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1965 Int_t tracks[kMaxNumberOfTracksPerDigit];
1966 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1967 Int_t dummyCounter=-1;
1968 Bool_t alreadyStored = kFALSE;
1970 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
1971 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1972 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
1974 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1975 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
1977 AliTOFdigit *digitInteresting;
1979 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
1981 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
1982 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
1984 AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
1991 interestingCounter=-1;
1993 vol[4] = iPadZ , vol[3] = iPadX;
1994 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1995 interestingCounter++;
1997 vol[4] = iPadZ, vol[3] = iPadX+1;
1998 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1999 interestingCounter++;
2001 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
2002 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2003 interestingCounter++;
2005 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
2006 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2007 interestingCounter++;
2009 if (interestingCounter+1!=4) continue; // the hit pads have to be 4
2010 else interestingCounter=-1;
2013 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2014 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
2015 selectedDigit[ii][jj] = 0x0;
2018 vol[4] = iPadZ, vol[3] = iPadX;
2020 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2021 interestingCounter++;
2022 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2023 digitsInVolumeIndices[ii] = -1;
2024 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2025 digitIndexLocal=-1; // AdC
2026 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2027 if (digitsInVolumeIndices[digIndex]<0) continue;
2028 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2029 if (digitInteresting->GetToT()<=0) continue; // AdC
2030 digitIndexLocal++; // AdC
2032 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2033 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2034 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2035 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2036 digitsInVolumeIndices[digIndex],
2037 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2039 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2040 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2041 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2042 digitInteresting->GetToT()*digitInteresting->GetToT(),
2043 digitsInVolumeIndices[digIndex],
2044 digitInteresting->GetTracks());
2046 if (digitIndexLocal==-1) interestingCounter--; // AdC
2050 vol[4] = iPadZ, vol[3] = iPadX+1;
2052 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2053 interestingCounter++;
2054 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2055 digitsInVolumeIndices[ii] = -1;
2056 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2057 digitIndexLocal=-1; // AdC
2058 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2059 if (digitsInVolumeIndices[digIndex]<0) continue;
2060 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2061 if (digitInteresting->GetToT()<=0) continue; // AdC
2062 digitIndexLocal++; // AdC
2064 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2065 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2066 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2067 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2068 digitsInVolumeIndices[digIndex],
2069 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2071 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2072 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2073 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2074 digitInteresting->GetToT()*digitInteresting->GetToT(),
2075 digitsInVolumeIndices[digIndex],
2076 digitInteresting->GetTracks());
2078 if (digitIndexLocal==-1) interestingCounter--; // AdC
2082 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
2084 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2085 interestingCounter++;
2086 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2087 digitsInVolumeIndices[ii] = -1;
2088 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2089 digitIndexLocal=-1; // AdC
2090 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2091 if (digitsInVolumeIndices[digIndex]<0) continue;
2092 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2093 if (digitInteresting->GetToT()<=0) continue; // AdC
2094 digitIndexLocal++; // AdC
2096 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2097 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2098 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2099 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2100 digitsInVolumeIndices[digIndex],
2101 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2103 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2104 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2105 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2106 digitInteresting->GetToT()*digitInteresting->GetToT(),
2107 digitsInVolumeIndices[digIndex],
2108 digitInteresting->GetTracks());
2110 if (digitIndexLocal==-1) interestingCounter--; // AdC
2114 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
2116 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2117 interestingCounter++;
2118 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2119 digitsInVolumeIndices[ii] = -1;
2120 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2121 digitIndexLocal=-1; // AdC
2122 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2123 if (digitsInVolumeIndices[digIndex]<0) continue;
2124 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2125 if (digitInteresting->GetToT()<=0) continue; // AdC
2126 digitIndexLocal++; // AdC
2128 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2129 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2130 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2131 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2132 digitsInVolumeIndices[digIndex],
2133 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2135 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2136 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2137 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2138 digitInteresting->GetToT()*digitInteresting->GetToT(),
2139 digitsInVolumeIndices[digIndex],
2140 digitInteresting->GetTracks());
2142 if (digitIndexLocal==-1) interestingCounter--; // AdC
2145 AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
2147 for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
2148 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2149 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2151 for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
2152 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2153 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2155 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime) continue;
2157 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2158 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2159 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2160 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2161 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
2162 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
2163 Int_t volDum = vol1[3];
2166 fTOFGeometry->GetPosPar(vol1,pos);
2167 interestingX[0] = pos[0];
2168 interestingY[0] = pos[1];
2169 interestingZ[0] = pos[2];
2171 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2172 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2173 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2174 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2175 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
2176 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
2180 fTOFGeometry->GetPosPar(vol2,pos);
2181 interestingX[1] = pos[0];
2182 interestingY[1] = pos[1];
2183 interestingZ[1] = pos[2];
2186 AverageCalculations(2, interestingX, interestingY, interestingZ,
2187 interestingTOF, interestingTOT, interestingADC,
2189 parTOF, posClus, check);
2191 for (jj=0; jj<5; jj++) det[jj] = -1;
2192 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
2193 fTOFGeometry->GetDetID(posF, det);
2195 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
2196 //volIdClus = GetClusterVolIndex(det);
2198 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2199 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
2200 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
2201 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
2202 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
2204 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2205 Int_t ** indDet = new Int_t*[2];
2206 for (jj=0; jj<2; jj++) indDet[jj] = new Int_t [5];
2207 for (jj=0; jj<2; jj++) indDet[jj][0] = nSector;
2208 for (jj=0; jj<2; jj++) indDet[jj][1] = nPlate;
2209 for (jj=0; jj<2; jj++) indDet[jj][2] = nStrip;
2210 for (jj=0; jj<2; jj++) indDet[jj][3] = padsCluster[2*jj+3];
2211 for (jj=0; jj<2; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
2212 GetClusterPars(/*check,*/ 2, indDet, interestingWeight, posClus, covClus);
2213 for (jj=0; jj<2; jj++) delete [] indDet[jj];
2216 // To fill the track index array
2218 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2219 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2220 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
2223 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
2226 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2227 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
2230 alreadyStored = kFALSE;
2231 for (jj=0; jj<dummyCounter+1; jj++)
2232 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
2234 if (alreadyStored) continue;
2235 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2236 AliWarning(" Siamo al limite!");
2241 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
2248 AliTOFcluster *tofCluster =
2249 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
2250 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2251 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
2252 InsertCluster(tofCluster);
2254 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",
2255 volIdClus, posClus[0], posClus[1], posClus[2],
2256 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2257 tracks[0], tracks[1], tracks[2],
2258 det[0], det[1], det[2], det[3], det[4],
2259 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
2260 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
2265 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
2269 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
2272 } // close loop on second digit
2273 } // close loop on adesso2
2275 } // close loop on first digit
2276 } // close loop on adesso1
2278 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2279 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
2280 selectedDigit[ii][jj] = 0x0;
2284 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++) {
2285 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
2286 delete [] selectedDigit[ii][jj];
2287 selectedDigit[ii][jj] = 0x0;
2289 delete [] selectedDigit[ii];
2290 selectedDigit[ii] = 0x0;
2292 delete [] selectedDigit;
2293 selectedDigit = 0x0;
2296 //_____________________________________________________________________________
2298 void AliTOFClusterFinderV1::FindClustersPerStrip(Int_t nSector,
2304 // This function searches the neighbouring digits (stored in the fDigits object),
2305 // to perform clusters (stored in the fTofClusters array).
2307 // Each strip is read four times:
2308 // - 1st time: it searches possible clusters formed by four
2309 // neighbouring digits;
2310 // - 2nd time: it searches possible clusters formed by three
2311 // neighbouring digits;
2312 // - 3rd time: it searches possible clusters formed by two
2313 // neighbouring digits;
2314 // - 4th time: the remaining isolated digits have been transformed
2316 // This research has been made by checking the fTOFdigitMap object,
2317 // filled at digits/raw-data reading time.
2320 const Int_t kMaxNumberOfInterestingPads = 4;
2321 const Int_t kMaxNumberOfTracksPerDigit = 3;
2322 const Int_t kMaxNumberOfDigitsPerVolume = 10;
2326 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
2327 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2328 digitsInVolumeIndices[ii] = -1;
2330 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
2332 Float_t pos[3] = {0.,0.,0.};
2335 Int_t interestingPadX[kMaxNumberOfInterestingPads];
2336 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
2337 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
2338 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
2339 Double_t interestingTOT[kMaxNumberOfInterestingPads];
2340 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
2341 Double_t interestingADC[kMaxNumberOfInterestingPads];
2342 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
2343 Double_t interestingTOF[kMaxNumberOfInterestingPads];
2344 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
2345 Double_t interestingWeight[kMaxNumberOfInterestingPads];
2346 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
2348 Float_t interestingX[kMaxNumberOfInterestingPads];
2349 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
2350 Float_t interestingY[kMaxNumberOfInterestingPads];
2351 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
2352 Float_t interestingZ[kMaxNumberOfInterestingPads];
2353 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
2355 Float_t interDigit[kMaxNumberOfInterestingPads];
2356 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
2358 Int_t padsCluster[11];
2359 padsCluster[0] = nSector;
2360 padsCluster[1] = nPlate;
2361 padsCluster[2] = nStrip;
2362 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2364 Int_t interestingCounter=-1;
2365 Int_t digitIndexLocal = -1;
2370 Bool_t check = kFALSE;
2372 for (jj=0; jj<7; jj++) parTOF[jj] = 0;
2373 Double_t posClus[3];
2374 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
2376 for (jj=0; jj<5; jj++) det[jj] = -1;
2378 for (jj=0; jj<3; jj++) posF[jj] = 0.;
2379 UShort_t volIdClus = 0;
2380 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
2381 Double_t covClus[6];
2382 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2383 Int_t tracks[kMaxNumberOfTracksPerDigit];
2384 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2385 Int_t dummyCounter=-1;
2386 Bool_t alreadyStored = kFALSE;
2388 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
2389 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2390 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
2392 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2393 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
2395 AliTOFdigit *digitInteresting;
2399 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
2401 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
2402 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
2404 AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
2411 interestingCounter=-1;
2413 vol[4] = iPadZ , vol[3] = iPadX;
2414 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2415 interestingCounter++;
2417 vol[4] = iPadZ, vol[3] = iPadX+1;
2418 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2419 interestingCounter++;
2421 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
2422 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2423 interestingCounter++;
2425 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
2426 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2427 interestingCounter++;
2429 if (interestingCounter!=group) continue;
2430 else interestingCounter=-1;
2433 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2434 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
2435 selectedDigit[ii][jj] = 0x0;
2438 vol[4] = iPadZ, vol[3] = iPadX;
2440 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2441 interestingCounter++;
2442 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2443 digitsInVolumeIndices[ii] = -1;
2444 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2445 digitIndexLocal=-1; // AdC
2446 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2447 if (digitsInVolumeIndices[digIndex]<0) continue;
2448 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2449 if (digitInteresting->GetToT()<=0) continue; // AdC
2450 digitIndexLocal++; // AdC
2452 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2453 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2454 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2455 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2456 digitsInVolumeIndices[digIndex],
2457 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2458 AliDebug(1,Form(" to try %d %d ",digIndex, interestingCounter));
2460 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2461 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2462 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2463 digitInteresting->GetToT()*digitInteresting->GetToT(),
2464 digitsInVolumeIndices[digIndex],
2465 digitInteresting->GetTracks());
2467 if (digitIndexLocal==-1) interestingCounter--; // AdC
2471 vol[4] = iPadZ, vol[3] = iPadX+1;
2473 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2474 interestingCounter++;
2475 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2476 digitsInVolumeIndices[ii] = -1;
2477 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2478 digitIndexLocal=-1; // AdC
2479 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2480 if (digitsInVolumeIndices[digIndex]<0) continue;
2481 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2482 if (digitInteresting->GetToT()<=0) continue; // AdC
2483 digitIndexLocal++; // AdC
2485 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2486 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2487 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2488 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2489 digitsInVolumeIndices[digIndex],
2490 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2491 AliDebug(1,Form(" to try %d %d ",digIndex, interestingCounter));
2493 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2494 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2495 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2496 digitInteresting->GetToT()*digitInteresting->GetToT(),
2497 digitsInVolumeIndices[digIndex],
2498 digitInteresting->GetTracks());
2500 if (digitIndexLocal==-1) interestingCounter--; // AdC
2504 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
2506 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2507 interestingCounter++;
2508 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2509 digitsInVolumeIndices[ii] = -1;
2510 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2511 digitIndexLocal=-1; // AdC
2512 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2513 if (digitsInVolumeIndices[digIndex]<0) continue;
2514 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2515 if (digitInteresting->GetToT()<=0) continue; // AdC
2516 digitIndexLocal++; // AdC
2518 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2519 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2520 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2521 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2522 digitsInVolumeIndices[digIndex],
2523 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2524 AliDebug(1,Form(" to try %d %d ",digIndex, interestingCounter));
2526 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2527 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2528 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2529 digitInteresting->GetToT()*digitInteresting->GetToT(),
2530 digitsInVolumeIndices[digIndex],
2531 digitInteresting->GetTracks());
2533 if (digitIndexLocal==-1) interestingCounter--; // AdC
2537 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
2539 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2540 interestingCounter++;
2541 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2542 digitsInVolumeIndices[ii] = -1;
2543 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
2544 digitIndexLocal=-1; // AdC
2545 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2546 if (digitsInVolumeIndices[digIndex]<0) continue;
2547 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
2548 if (digitInteresting->GetToT()<=0) continue; // AdC
2549 digitIndexLocal++; // AdC
2551 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
2552 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2553 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2554 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2555 digitsInVolumeIndices[digIndex],
2556 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2557 AliDebug(1,Form(" to try %d %d ",digIndex, interestingCounter));
2559 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
2560 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2561 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2562 digitInteresting->GetToT()*digitInteresting->GetToT(),
2563 digitsInVolumeIndices[digIndex],
2564 digitInteresting->GetTracks());
2566 if (digitIndexLocal==-1) interestingCounter--; // AdC
2569 AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
2576 switch(interestingCounter+1) {
2580 //for (adesso1=0; adesso1<interestingCounter+1; adesso1++) {
2582 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2583 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2585 //for (adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
2587 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2588 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2590 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime) {
2591 AliDebug(1,Form(" selD1[%d][%d]->GetTDC()=%d selD2[%d][%d]->GetTDC()=%d -- %d ",
2592 adesso1,firstIndex,(Int_t)selectedDigit[adesso1][firstIndex]->GetTDC(),
2593 adesso2,secondIndex,(Int_t)selectedDigit[adesso2][secondIndex]->GetTDC(),
2598 AliDebug(1, Form(" %1d %1d (0x%p) %1d %1d (0x%p)", adesso1, firstIndex,selectedDigit[adesso1][firstIndex],
2599 adesso2, secondIndex,selectedDigit[adesso2][secondIndex]));
2601 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2602 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2603 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2604 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2605 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
2606 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
2607 Int_t volDum = vol1[3];
2610 fTOFGeometry->GetPosPar(vol1,pos);
2611 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
2612 interestingX[0] = pos[0];
2613 interestingY[0] = pos[1];
2614 interestingZ[0] = pos[2];
2616 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2617 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2618 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2619 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2620 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
2621 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
2625 fTOFGeometry->GetPosPar(vol2,pos);
2626 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
2627 interestingX[1] = pos[0];
2628 interestingY[1] = pos[1];
2629 interestingZ[1] = pos[2];
2632 AverageCalculations(interestingCounter+1,
2633 interestingX, interestingY, interestingZ,
2634 interestingTOF, interestingTOT, interestingADC,
2636 parTOF, posClus, check);
2638 for (jj=0; jj<5; jj++) det[jj] = -1;
2639 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
2641 AliDebug(1,Form(" %f %f %f", posF[0], posF[1], posF[2]));
2642 fTOFGeometry->GetDetID(posF, det);
2643 AliDebug(1,Form(" %2d %1d %2d %1d %2d", det[0], det[1], det[2], det[3], det[4]));
2645 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
2646 //volIdClus = GetClusterVolIndex(det);
2648 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2649 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
2650 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
2651 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
2652 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
2654 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2655 Int_t ** indDet = new Int_t*[interestingCounter+1];
2656 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj] = new Int_t [5];
2657 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][0] = nSector;
2658 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][1] = nPlate;
2659 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][2] = nStrip;
2660 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][3] = padsCluster[2*jj+3];
2661 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
2662 GetClusterPars(/*check,*/ interestingCounter+1, indDet, interestingWeight, posClus, covClus);
2663 for (jj=0; jj<interestingCounter+1; jj++) delete [] indDet[jj];
2666 // To fill the track index array
2668 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2669 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2670 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
2673 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
2676 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2677 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
2680 alreadyStored = kFALSE;
2681 for (jj=0; jj<dummyCounter+1; jj++)
2682 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
2684 if (alreadyStored) continue;
2685 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2686 AliWarning(" Siamo al limite!");
2691 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
2698 AliTOFcluster *tofCluster =
2699 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
2700 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2701 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); //to updated
2702 InsertCluster(tofCluster);
2704 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",
2705 volIdClus, posClus[0], posClus[1], posClus[2],
2706 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2707 tracks[0], tracks[1], tracks[2],
2708 det[0], det[1], det[2], det[3], det[4],
2709 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
2710 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
2715 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
2719 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
2722 } // close loop on second digit
2723 //} // close loop on adesso2
2725 } // close loop on first digit
2726 //} // close loop on adesso1
2733 //for (adesso1=0; adesso1<interestingCounter+1; adesso1++) {
2735 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2736 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2738 //for (adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
2740 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2741 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2743 //for (adesso3=adesso2+1; adesso3<interestingCounter+1; adesso3++) {
2745 for (Int_t thirdIndex=0; thirdIndex<kMaxNumberOfDigitsPerVolume; thirdIndex++) {
2746 if (selectedDigit[adesso3][thirdIndex]==0x0) continue;
2749 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime
2751 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
2753 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime) continue;
2755 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2756 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2757 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2758 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2759 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
2760 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
2761 Int_t volDum = vol1[3];
2764 fTOFGeometry->GetPosPar(vol1,pos);
2765 interestingX[0] = pos[0];
2766 interestingY[0] = pos[1];
2767 interestingZ[0] = pos[2];
2769 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2770 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2771 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2772 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2773 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
2774 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
2778 fTOFGeometry->GetPosPar(vol2,pos);
2779 interestingX[1] = pos[0];
2780 interestingY[1] = pos[1];
2781 interestingZ[1] = pos[2];
2783 interestingTOF[2] = selectedDigit[adesso3][thirdIndex]->GetTDC();
2784 interestingTOT[2] = selectedDigit[adesso3][thirdIndex]->GetTOT();
2785 interestingADC[2] = selectedDigit[adesso3][thirdIndex]->GetADC();
2786 interestingWeight[2] = selectedDigit[adesso3][thirdIndex]->GetWeight();
2787 Int_t vol3[5]; for(jj=0; jj<5; jj++) vol3[jj] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(jj);
2788 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol3[0], vol3[1], vol3[2], vol3[4], vol3[3]));
2792 fTOFGeometry->GetPosPar(vol3,pos);
2793 interestingX[2] = pos[0];
2794 interestingY[2] = pos[1];
2795 interestingZ[2] = pos[2];
2798 AverageCalculations(interestingCounter+1,
2799 interestingX, interestingY, interestingZ,
2800 interestingTOF, interestingTOT, interestingADC,
2802 parTOF, posClus, check);
2804 for (jj=0; jj<5; jj++) det[jj] = -1;
2805 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
2806 fTOFGeometry->GetDetID(posF, det);
2808 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
2809 //volIdClus = GetClusterVolIndex(det);
2811 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2812 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
2813 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
2814 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
2815 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
2816 padsCluster[7] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(4);
2817 padsCluster[8] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(3);
2819 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2820 Int_t ** indDet = new Int_t*[interestingCounter+1];
2821 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj] = new Int_t [5];
2822 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][0] = nSector;
2823 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][1] = nPlate;
2824 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][2] = nStrip;
2825 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][3] = padsCluster[2*jj+3];
2826 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
2827 GetClusterPars(/*check,*/ interestingCounter+1, indDet, interestingWeight, posClus, covClus);
2828 for (jj=0; jj<interestingCounter+1; jj++) delete [] indDet[jj];
2832 // To fill the track index array
2834 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2835 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2836 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
2839 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
2842 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2843 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
2846 alreadyStored = kFALSE;
2847 for (jj=0; jj<dummyCounter+1; jj++)
2848 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
2850 if (alreadyStored) continue;
2851 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2852 AliWarning(" Siamo al limite!");
2857 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
2862 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2863 if (selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk)==-1) continue;
2866 alreadyStored = kFALSE;
2867 for (jj=0; jj<dummyCounter+1; jj++)
2868 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk));
2870 if (alreadyStored) continue;
2871 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2872 AliWarning(" Siamo al limite!");
2877 tracks[dummyCounter] = selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk);
2884 AliTOFcluster *tofCluster =
2885 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
2886 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2887 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
2888 InsertCluster(tofCluster);
2890 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",
2891 volIdClus, posClus[0], posClus[1], posClus[2],
2892 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2893 tracks[0], tracks[1], tracks[2],
2894 det[0], det[1], det[2], det[3], det[4],
2895 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
2896 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
2901 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
2905 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
2909 fTOFdigitMap->ResetDigitNumber(vol3,selectedDigit[adesso3][thirdIndex]->GetIndex());
2912 } // close loop on third digit
2913 //} // close loop on adesso3
2915 } // close loop on second digit
2916 //} // close loop on adesso2
2918 } // close loop on first digit
2919 //} // close loop on adesso1
2927 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2928 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2931 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2932 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2935 for (Int_t thirdIndex=0; thirdIndex<kMaxNumberOfDigitsPerVolume; thirdIndex++) {
2936 if (selectedDigit[adesso3][thirdIndex]==0x0) continue;
2939 for (Int_t fourthIndex=0; fourthIndex<kMaxNumberOfDigitsPerVolume; fourthIndex++) {
2940 if (selectedDigit[adesso4][fourthIndex]==0x0) continue;
2943 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime
2945 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
2947 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso4][fourthIndex]->GetTDC())>fMaxDeltaTime
2949 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
2951 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso4][fourthIndex]->GetTDC())>fMaxDeltaTime
2953 TMath::Abs(selectedDigit[adesso3][thirdIndex]->GetTDC()-selectedDigit[adesso4][fourthIndex]->GetTDC())>fMaxDeltaTime) continue;
2955 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2956 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2957 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2958 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2959 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
2960 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
2961 Int_t volDum = vol1[3];
2964 fTOFGeometry->GetPosPar(vol1,pos);
2965 interestingX[0] = pos[0];
2966 interestingY[0] = pos[1];
2967 interestingZ[0] = pos[2];
2969 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2970 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2971 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2972 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2973 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
2974 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
2978 fTOFGeometry->GetPosPar(vol2,pos);
2979 interestingX[1] = pos[0];
2980 interestingY[1] = pos[1];
2981 interestingZ[1] = pos[2];
2983 interestingTOF[2] = selectedDigit[adesso3][thirdIndex]->GetTDC();
2984 interestingTOT[2] = selectedDigit[adesso3][thirdIndex]->GetTOT();
2985 interestingADC[2] = selectedDigit[adesso3][thirdIndex]->GetADC();
2986 interestingWeight[2] = selectedDigit[adesso3][thirdIndex]->GetWeight();
2987 Int_t vol3[5]; for(jj=0; jj<5; jj++) vol3[jj] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(jj);
2988 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol3[0], vol3[1], vol3[2], vol3[4], vol3[3]));
2992 fTOFGeometry->GetPosPar(vol3,pos);
2993 interestingX[2] = pos[0];
2994 interestingY[2] = pos[1];
2995 interestingZ[2] = pos[2];
2997 interestingTOF[3] = selectedDigit[adesso4][fourthIndex]->GetTDC();
2998 interestingTOT[3] = selectedDigit[adesso4][fourthIndex]->GetTOT();
2999 interestingADC[3] = selectedDigit[adesso4][fourthIndex]->GetADC();
3000 interestingWeight[3] = selectedDigit[adesso4][fourthIndex]->GetWeight();
3001 Int_t vol4[5]; for(jj=0; jj<5; jj++) vol4[jj] = selectedDigit[adesso4][fourthIndex]->GetDetectorIndex(jj);
3002 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol4[0], vol4[1], vol4[2], vol4[4], vol4[3]));
3006 fTOFGeometry->GetPosPar(vol4,pos);
3007 interestingX[3] = pos[0];
3008 interestingY[3] = pos[1];
3009 interestingZ[3] = pos[2];
3012 AverageCalculations(interestingCounter+1,
3013 interestingX, interestingY, interestingZ,
3014 interestingTOF, interestingTOT, interestingADC,
3016 parTOF, posClus, check);
3018 for (jj=0; jj<5; jj++) det[jj] = -1;
3019 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
3020 fTOFGeometry->GetDetID(posF, det);
3022 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
3023 //volIdClus = GetClusterVolIndex(det);
3025 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
3026 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
3027 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
3028 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
3029 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
3030 padsCluster[7] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(4);
3031 padsCluster[8] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(3);
3032 padsCluster[9] = selectedDigit[adesso4][fourthIndex]->GetDetectorIndex(4);
3033 padsCluster[10] = selectedDigit[adesso4][fourthIndex]->GetDetectorIndex(3);
3035 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
3036 Int_t ** indDet = new Int_t*[interestingCounter+1];
3037 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj] = new Int_t [5];
3038 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][0] = nSector;
3039 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][1] = nPlate;
3040 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][2] = nStrip;
3041 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][3] = padsCluster[2*jj+3];
3042 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
3043 GetClusterPars(/*check,*/ interestingCounter+1, indDet, interestingWeight, posClus, covClus);
3044 for (jj=0; jj<interestingCounter+1; jj++) delete [] indDet[jj];
3047 // To fill the track index array
3049 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
3050 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
3051 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
3054 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
3057 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
3058 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
3061 alreadyStored = kFALSE;
3062 for (jj=0; jj<dummyCounter+1; jj++)
3063 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
3065 if (alreadyStored) continue;
3066 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
3067 AliWarning(" Siamo al limite!");
3072 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
3077 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
3078 if (selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk)==-1) continue;
3081 alreadyStored = kFALSE;
3082 for (jj=0; jj<dummyCounter+1; jj++)
3083 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk));
3085 if (alreadyStored) continue;
3086 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
3087 AliWarning(" Siamo al limite!");
3092 tracks[dummyCounter] = selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk);
3097 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
3098 if (selectedDigit[adesso4][fourthIndex]->GetTrackLabel(kk)==-1) continue;
3101 alreadyStored = kFALSE;
3102 for (jj=0; jj<dummyCounter+1; jj++)
3103 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso4][fourthIndex]->GetTrackLabel(kk));
3105 if (alreadyStored) continue;
3106 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
3107 AliWarning(" Siamo al limite!");
3112 tracks[dummyCounter] = selectedDigit[adesso4][fourthIndex]->GetTrackLabel(kk);
3119 AliTOFcluster *tofCluster =
3120 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
3121 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
3122 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
3123 InsertCluster(tofCluster);
3125 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",
3126 volIdClus, posClus[0], posClus[1], posClus[2],
3127 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
3128 tracks[0], tracks[1], tracks[2],
3129 det[0], det[1], det[2], det[3], det[4],
3130 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
3131 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
3136 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
3140 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
3144 fTOFdigitMap->ResetDigitNumber(vol3,selectedDigit[adesso3][thirdIndex]->GetIndex());
3148 fTOFdigitMap->ResetDigitNumber(vol4,selectedDigit[adesso4][fourthIndex]->GetIndex());
3151 } // close loop on fourth digit
3153 } // close loop on third digit
3155 } // close loop on second digit
3157 } // close loop on first digit
3163 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
3164 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
3165 selectedDigit[ii][jj] = 0x0;
3169 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++) {
3170 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
3171 delete [] selectedDigit[ii][jj];
3172 selectedDigit[ii][jj] = 0x0;
3174 delete [] selectedDigit[ii];
3175 selectedDigit[ii] = 0x0;
3177 delete [] selectedDigit;
3178 selectedDigit = 0x0;
3181 //_____________________________________________________________________________
3183 Int_t AliTOFClusterFinderV1::InsertCluster(AliTOFcluster *tofCluster)
3186 // This function adds a TOF cluster to the array of TOF clusters
3187 // sorted in Z, i.e. fTofClusters
3190 if (fNumberOfTofClusters==kTofMaxCluster) {
3191 AliError("Too many clusters !");
3195 if (fNumberOfTofClusters==0) {
3196 fTofClusters[fNumberOfTofClusters++] = tofCluster;
3200 Int_t ii = FindClusterIndex(tofCluster->GetZ());
3201 memmove(fTofClusters+ii+1 ,fTofClusters+ii,(fNumberOfTofClusters-ii)*sizeof(AliTOFcluster*));
3202 fTofClusters[ii] = tofCluster;
3203 fNumberOfTofClusters++;
3208 //_____________________________________________________________________________
3210 Int_t AliTOFClusterFinderV1::FindClusterIndex(Double_t z) const
3213 // This function returns the index of the nearest cluster in z
3216 if (fNumberOfTofClusters==0) return 0;
3217 if (z <= fTofClusters[0]->GetZ()) return 0;
3218 if (z > fTofClusters[fNumberOfTofClusters-1]->GetZ()) return fNumberOfTofClusters;
3219 Int_t b = 0, e = fNumberOfTofClusters-1, m = (b+e)/2;
3220 for (; b<e; m=(b+e)/2) {
3221 if (z > fTofClusters[m]->GetZ()) b=m+1;
3228 //_____________________________________________________________________________
3230 void AliTOFClusterFinderV1::ResetRecpoint()
3233 // Clear the list of reconstructed points
3236 fNumberOfTofClusters = 0;
3237 fNumberOfTofTrgPads = 0;
3238 if (fRecPoints) fRecPoints->Clear();
3241 //_____________________________________________________________________________
3243 void AliTOFClusterFinderV1::ResetDigits()
3246 // Clear the list of digits
3249 fNumberOfTofDigits = 0;
3250 fNumberOfTofTrgPads = 0;
3251 if (fDigits) fDigits->Clear();
3254 //_____________________________________________________________________________
3255 //UShort_t AliTOFClusterFinderV1::GetClusterVolIndex(Int_t *ind) const
3258 // Get the volume ID to retrieve the l2t transformation
3261 // Detector numbering scheme
3263 Int_t nSector = AliTOFGeometry::NSectors();
3264 Int_t nPlate = AliTOFGeometry::NPlates();
3265 Int_t nStripA = AliTOFGeometry::NStripA();
3266 Int_t nStripB = AliTOFGeometry::NStripB();
3267 Int_t nStripC = AliTOFGeometry::NStripC();
3269 Int_t isector =ind[0];
3270 if (isector >= nSector)
3271 AliError(Form("Wrong sector number in TOF (%d) !", isector));
3272 Int_t iplate = ind[1];
3273 if (iplate >= nPlate)
3274 AliError(Form("Wrong plate number in TOF (%d) !", iplate));
3275 Int_t istrip = ind[2];
3277 Int_t stripOffset = 0;
3283 stripOffset = nStripC;
3286 stripOffset = nStripC+nStripB;
3289 stripOffset = nStripC+nStripB+nStripA;
3292 stripOffset = nStripC+nStripB+nStripA+nStripB;
3295 AliError(Form("Wrong plate number in TOF (%d) !", iplate));
3299 Int_t index= (2*(nStripC+nStripB)+nStripA)*isector +
3303 UShort_t volIndex = AliGeomManager::LayerToVolUID(AliGeomManager::kTOF, index);
3308 //_____________________________________________________________________________
3310 void AliTOFClusterFinderV1::GetClusterPars(Int_t *ind, Double_t* pos, Double_t* cov) const
3313 // Starting from the volume indices (ind[5]), for a cluster coming from
3314 // a isolated digits, this function returns:
3315 // the cluster position (pos),
3316 // the cluster covariance matrix elements (cov)
3320 //we now go in the system of the strip: determine the local coordinates
3323 // 47---------------------------------------------------0 ^ z
3324 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 1 |
3325 // ----------------------------------------------------- | y going outwards
3326 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 0 | par[0]=0;
3328 // ----------------------------------------------------- |
3329 // x <-----------------------------------------------------
3331 //move to the tracking ref system
3332 Double_t lpos[3] = { (ind[4]-23.5)*AliTOFGeometry::XPad(),
3334 (ind[3]- 0.5)*AliTOFGeometry::ZPad() };
3335 AliDebug(1, Form(" %f %f %f", lpos[0], lpos[1], lpos[2]));
3338 UShort_t volIndex = fTOFGeometry->GetAliSensVolIndex(ind[0],ind[1],ind[2]);
3339 //UShort_t volIndex = GetClusterVolIndex(ind);
3340 const TGeoHMatrix *l2t = AliGeomManager::GetTracking2LocalMatrix(volIndex);
3342 // Get the position in the track ref system
3344 l2t->MasterToLocal(lpos,tpos);
3349 //Get the cluster covariance in the track ref system
3351 for (Int_t ii=0; ii<9; ii++) lcov[ii] = 0.;
3353 //cluster covariance in the local system:
3358 lcov[4] = 0.42*0.42/3.;
3359 // = ( 5*0.025 (gas gaps thikness)
3360 // + 4*0.040 (internal glasses thickness)
3361 // + 0.5*0.160 (internl PCB)
3362 // + 1*0.055 (external red glass))
3365 lcov[0] = 0.499678;//AliTOFGeometry::XPad()*AliTOFGeometry::XPad()/12.;
3366 lcov[8] = 0.992429;//AliTOFGeometry::ZPad()*AliTOFGeometry::ZPad()/12.;
3368 //cluster covariance in the tracking system:
3370 m.SetRotation(lcov);
3372 m.MultiplyLeft(&l2t->Inverse());
3373 Double_t *tcov = m.GetRotationMatrix();
3374 cov[0] = tcov[0]; cov[1] = tcov[1]; cov[2] = tcov[2];
3375 cov[3] = tcov[4]; cov[4] = tcov[5]; cov[5] = tcov[8];
3380 //_____________________________________________________________________________
3382 void AliTOFClusterFinderV1::GetClusterPars(/*Bool_t check,*/ Int_t counter,
3383 Int_t **ind, Double_t *weight,
3384 Double_t *pos, Double_t *cov) const
3388 // the volumes indices (ind[counter][5]), for a
3389 // cluster coming from a collection of 'counter'
3391 // the volumes weights (weight[counter]), -controlled
3392 // by the 'check' variable control-, for a cluster
3393 // coming from a collection of 'counter' digits,
3394 // the cluster position (pos),
3395 // this function returns:
3396 // the covariance matrix elements (cov) for the found cluster
3400 // we now go in the system of the strip: determine the local coordinates
3402 // 47---------------------------------------------------0 ^ z
3403 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 1 |
3404 // ----------------------------------------------------- | y going outwards
3405 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 0 | par[0]=0;
3407 // ----------------------------------------------------- |
3408 // x <-----------------------------------------------------
3410 for (Int_t ii=0; ii<counter; ii++)
3411 AliDebug(1, Form(" %2d %2d %1d %2d %1d %2d ",
3412 ii, ind[ii][0], ind[ii][1], ind[ii][2], ind[ii][3], ind[ii][4]));
3414 Float_t posF[3]; for (Int_t ii=0; ii<3; ii++) posF[ii] = (Float_t)pos[ii];
3415 AliDebug(1, Form(" %f %f %f", pos[0], pos[1], pos[2]));
3417 Int_t detClus[5] = {-1, -1, -1, -1, -1};
3418 fTOFGeometry->GetDetID(posF, detClus);
3421 UShort_t volIndex = fTOFGeometry->GetAliSensVolIndex(detClus[0],detClus[1],detClus[2]);
3422 //UShort_t volIndex = GetClusterVolIndex(detClus);
3423 AliDebug(1, Form(" %2d %1d %2d %1d %2d %7i",
3424 detClus[0], detClus[1], detClus[2], detClus[3], detClus[4], volIndex));
3426 // Get the position in the TOF strip ref system
3427 const TGeoHMatrix *alice2strip = AliGeomManager::GetOrigGlobalMatrix(volIndex);
3428 Double_t ppos[3] = {-1, -1, -1};
3429 alice2strip->MasterToLocal(pos,ppos);
3430 AliDebug(1, Form(" %f %f %f", ppos[0], ppos[1], ppos[2]));
3433 // Get the position in the tracking ref system
3434 const TGeoHMatrix *g2l = AliGeomManager::GetTracking2LocalMatrix(volIndex);
3435 Double_t lpos[3] = {-1, -1, -1};
3436 g2l->MasterToLocal(ppos,lpos);
3437 AliDebug(1, Form(" %f %f %f", lpos[0], lpos[1], lpos[2]));
3438 for (Int_t ii=0; ii<3; ii++) pos[ii] = lpos[ii];
3440 //Get the cluster covariance in the track ref system
3442 for (Int_t ii=0; ii<9; ii++) lcov[ii] = 0.;
3444 //cluster covariance in the local system:
3449 // Evaluation of the ovariance matrix elements
3450 TOFclusterError(/*check,*/ counter, ind, weight, ppos, lcov);
3452 AliDebug(1, Form("lcov[0] = %f, lcov[8] = %f", lcov[0], lcov[8]));
3454 //cluster covariance in the tracking system:
3456 m.SetRotation(lcov);
3458 m.MultiplyLeft(&g2l->Inverse());
3459 Double_t *tcov = m.GetRotationMatrix();
3460 cov[0] = tcov[0]; cov[1] = tcov[1]; cov[2] = tcov[2];
3461 cov[3] = tcov[4]; cov[4] = tcov[5]; cov[5] = tcov[8];
3466 //_____________________________________________________________________________
3468 void AliTOFClusterFinderV1::TOFclusterError(/*Bool_t check,*/ Int_t counter,
3469 Int_t **ind, Double_t *weight,
3470 Double_t ppos[], Double_t lcov[]) const
3476 //lcov[4] = 0.42*0.42/3.; // cm2
3477 // = ( 5*0.025 (gas gaps thikness)
3478 // + 4*0.040 (internal glasses thickness)
3479 // + 0.5*0.160 (internl PCB)
3480 // + 1*0.055 (external red glass))
3483 Float_t *delta2X = new Float_t[counter];
3484 for (Int_t ii=0; ii<counter; ii++)
3486 ((ind[ii][4]-23.5)*AliTOFGeometry::XPad() - ppos[0])*((ind[ii][4]-23.5)*AliTOFGeometry::XPad() - ppos[0]);
3488 Float_t *delta2Z = new Float_t[counter];
3489 for (Int_t ii=0; ii<counter; ii++)
3491 ((ind[ii][3]- 0.5)*AliTOFGeometry::ZPad() - ppos[2])*((ind[ii][3]- 0.5)*AliTOFGeometry::ZPad() - ppos[2]);
3493 for (Int_t ii=0; ii<counter; ii++)
3494 AliDebug(1, Form("x[%d] = %f, z[%d] = %f, weight[%d] = %f",
3495 ii, (ind[ii][4]-23.5)*AliTOFGeometry::XPad(),
3496 ii, (ind[ii][3]- 0.5)*AliTOFGeometry::ZPad(),
3499 AliDebug(1, Form("xMean = %f, zMean = %f",ppos[0], ppos[2]));
3507 if (ind[0][3]==ind[1][3] && TMath::Abs(ind[0][4]-ind[1][4])==1) { //
3509 lcov[8] = 1.02039; // cm2
3510 lcov[0] = 0.0379409; // cm2
3513 lcov[0] = 0.5*0.5; // cm2
3515 if (weight[0]==weight[1])
3516 lcov[0] = 0.0379409; // cm2
3518 lcov[0] = TMath::Mean(counter, delta2X, weight); // cm2
3524 else if (ind[0][4]==ind[1][4] && TMath::Abs(ind[0][3]-ind[1][3])==1) {//
3526 lcov[0] = 0.505499; // cm2
3527 lcov[8] = 0.0422046; // cm2
3530 lcov[8] = 0.5*0.5; // cm2
3532 if (weight[0]==weight[1])
3533 lcov[8] = 0.0422046; // cm2
3535 lcov[8] = TMath::Mean(counter, delta2Z, weight); // cm2
3544 lcov[0] = 0.0290677; // cm2
3545 lcov[8] = 0.0569726; // cm2
3548 lcov[0] = 0.5*0.5; // cm2
3549 lcov[8] = 0.5*0.5; // cm2
3552 if (weight[0]==weight[1] && weight[0]==weight[2]) {
3553 lcov[0] = 0.0290677; // cm2
3554 lcov[8] = 0.0569726; // cm2
3557 lcov[0] = TMath::Mean(counter, delta2X, weight); // cm2
3558 lcov[8] = TMath::Mean(counter, delta2Z, weight); // cm2
3567 lcov[0] = 0.0223807; // cm2
3568 lcov[8] = 0.0438662; // cm2
3571 lcov[0] = 0.5*0.5; // cm2
3572 lcov[8] = 0.5*0.5; // cm2
3575 if (weight[0]==weight[1] && weight[0]==weight[2] && weight[0]==weight[3]) {
3576 lcov[0] = 0.0223807; // cm2
3577 lcov[8] = 0.0438662; // cm2
3580 lcov[0] = TMath::Mean(counter, delta2X, weight); // cm2
3581 lcov[8] = TMath::Mean(counter, delta2Z, weight); // cm2
3595 //_____________________________________________________________________________
3597 Bool_t AliTOFClusterFinderV1::MakeSlewingCorrection(Int_t *detectorIndex,
3603 // This funtion makes the following:
3605 // - if at least one of the three status (Pulser/Noise/HW) is
3606 // bad, is sets the status of electronic channel, corresponding to the
3607 // volume identified by detectorIndex, as kFALSE;
3608 // - if offline calibration is in the valid status, it performs the
3609 // slewing correction. In particular, by taking into account:
3610 // * the measured tot and tof values (tofDigitToT and tofDigitTdc,
3612 // * the six parameters of 5th order polynomial used
3613 // to fit the tofVStot scatter plot,
3614 // it returns the corrected tof value, i.e. tdcCorr value.
3617 Bool_t output = kTRUE;
3622 //AliInfo(" Calibrating TOF Digits: ");
3624 AliTOFChannelOnlineArray *calDelay = fTOFcalib->GetTOFOnlineDelay();
3625 AliTOFChannelOnlineStatusArray *calStatus = fTOFcalib->GetTOFOnlineStatus();
3627 TObjArray *calTOFArrayOffline = fTOFcalib->GetTOFCalArrayOffline();
3629 Int_t index = AliTOFGeometry::GetIndex(detectorIndex);
3631 UChar_t statusPulser = calStatus->GetPulserStatus(index);
3632 UChar_t statusNoise = calStatus->GetNoiseStatus(index);
3633 UChar_t statusHW = calStatus->GetHWStatus(index);
3634 UChar_t status = calStatus->GetStatus(index);
3636 //check the status, also unknown is fine!!!!!!!
3638 AliDebug(2, Form(" Status for channel %d = %d",index, (Int_t)status));
3639 if((statusPulser & AliTOFChannelOnlineStatusArray::kTOFPulserBad)==(AliTOFChannelOnlineStatusArray::kTOFPulserBad)||(statusNoise & AliTOFChannelOnlineStatusArray::kTOFNoiseBad)==(AliTOFChannelOnlineStatusArray::kTOFNoiseBad)||(statusHW & AliTOFChannelOnlineStatusArray::kTOFHWBad)==(AliTOFChannelOnlineStatusArray::kTOFHWBad)){
3640 AliDebug(2, Form(" Bad Status for channel %d",index));
3641 //fTofClusters[ii]->SetStatus(kFALSE); //odd convention, to avoid conflict with calibration objects currently in the db (temporary solution).
3645 AliDebug(2, Form(" Good Status for channel %d",index));
3648 if (fCalibrateTOFtimes) { // AdC
3650 // Get Rough channel online equalization
3651 Double_t roughDelay = (Double_t)calDelay->GetDelay(index); // in ns
3652 AliDebug(2,Form(" channel delay (ns) = %f", roughDelay));
3653 // Get Refined channel offline calibration parameters
3654 TString validity = (TString)fTOFcalib->GetOfflineValidity();
3655 if (validity.CompareTo("valid")==0) {
3656 AliTOFChannelOffline * calChannelOffline = (AliTOFChannelOffline*)calTOFArrayOffline->At(index);
3658 for (jj = 0; jj<6; jj++)
3659 par[jj] = (Double_t)calChannelOffline->GetSlewPar(jj);
3661 AliDebug(2,Form(" Calib Pars = %f, %f, %f, %f, %f, %f ",par[0],par[1],par[2],par[3],par[4],par[5]));
3662 AliDebug(2,Form(" The ToT and Time, uncorr (counts) = %d , %d", tofDigitToT, tofDigitTdc));
3663 Double_t tToT = (Double_t)(tofDigitToT*AliTOFGeometry::ToTBinWidth());
3664 tToT*=1.E-3; //ToT in ns
3665 AliDebug(2,Form(" The ToT and Time, uncorr (ns)= %e, %e",tofDigitTdc*AliTOFGeometry::TdcBinWidth()*1.E-3,tToT));
3666 timeCorr = par[0] + tToT*(par[1] + tToT*(par[2] + tToT*(par[3] + tToT*(par[4] + tToT*par[5])))); // the time correction (ns)
3669 timeCorr = roughDelay; // correction in ns
3671 AliDebug(2,Form(" The ToT and Time, uncorr (ns)= %e, %e",tofDigitTdc*AliTOFGeometry::TdcBinWidth()*1.E-3,tofDigitToT*AliTOFGeometry::ToTBinWidth()));
3672 AliDebug(2,Form(" The time correction (ns) = %f", timeCorr));
3673 timeCorr = (Double_t)(tofDigitTdc)*AliTOFGeometry::TdcBinWidth()*1.E-3-timeCorr;//redefine the time
3675 AliDebug(2,Form(" The channel time, corr (ps)= %e",timeCorr ));
3676 //tdcCorr = (Int_t)(timeCorr/AliTOFGeometry::TdcBinWidth()); //the corrected time (tdc counts)
3677 tdcCorr = TMath::Nint(timeCorr/AliTOFGeometry::TdcBinWidth()); //the corrected time (tdc counts)
3684 //______________________________________________________________________________
3686 void AliTOFClusterFinderV1::Digits2RecPoints(Int_t iEvent)
3689 // Converts digits to recpoints for TOF
3692 TStopwatch stopwatch;
3695 fRunLoader->GetEvent(iEvent);
3697 AliLoader *localTOFLoader = (AliLoader*)fRunLoader->GetLoader("TOFLoader");
3699 TTree * localTreeD = (TTree*)localTOFLoader->TreeD();
3700 if (localTreeD == 0x0) {
3701 AliFatal("Can not get TreeD");
3705 TBranch *branch = localTreeD->GetBranch("TOF");
3707 AliError("Can't get the branch with the TOF digits !");
3711 TTree *localTreeR = (TTree*)localTOFLoader->TreeR();
3712 if (localTreeR == 0x0)
3714 localTOFLoader->MakeTree("R");
3715 localTreeR = localTOFLoader->TreeR();
3718 Digits2RecPoints(localTreeD, localTreeR);
3720 //localTOFLoader = fRunLoader->GetLoader("TOFLoader");
3721 localTOFLoader->WriteRecPoints("OVERWRITE");
3723 AliDebug(1, Form("Execution time to read TOF digits and to write TOF clusters for the event number %d: R:%.4fs C:%.4fs",
3724 iEvent, stopwatch.RealTime(),stopwatch.CpuTime()));
3727 //______________________________________________________________________________
3729 void AliTOFClusterFinderV1::Digits2RecPoints(Int_t iEvent, AliRawReader *rawReader)
3732 // Converts RAW data to recpoints for TOF
3735 TStopwatch stopwatch;
3738 fRunLoader->GetEvent(iEvent);
3740 AliDebug(2,Form(" Event number %2d ", iEvent));
3742 AliLoader *localTOFLoader = (AliLoader*)fRunLoader->GetLoader("TOFLoader");
3744 TTree *localTreeR = localTOFLoader->TreeR();
3746 if (localTreeR == 0x0){
3747 localTOFLoader->MakeTree("R");
3748 localTreeR = localTOFLoader->TreeR();
3751 Digits2RecPoints(rawReader, localTreeR);
3753 AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters for the event number %d: R:%.4fs C:%.4fs",
3754 iEvent, stopwatch.RealTime(),stopwatch.CpuTime()));
3757 //______________________________________________________________________________
3759 void AliTOFClusterFinderV1::Raw2Digits(Int_t iEvent, AliRawReader *rawReader)
3762 // Converts RAW data to MC digits for TOF
3766 TStopwatch stopwatch;
3769 fRunLoader->GetEvent(iEvent);
3771 AliDebug(2,Form(" Event number %2d ", iEvent));
3773 AliLoader *localTOFLoader = (AliLoader*)fRunLoader->GetLoader("TOFLoader");
3775 TTree *localTreeD = localTOFLoader->TreeD();
3777 if (localTreeD == 0x0){
3778 localTOFLoader->MakeTree("D");
3779 localTreeD = localTOFLoader->TreeD();
3782 Raw2Digits(rawReader, localTreeD);
3784 AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters for the event number %d: R:%.4fs C:%.4fs",
3785 iEvent, stopwatch.RealTime(),stopwatch.CpuTime()));
3788 //______________________________________________________________________________
3790 void AliTOFClusterFinderV1::AverageCalculations(Int_t number, Float_t *interestingX,
3791 Float_t *interestingY, Float_t *interestingZ,
3792 Double_t *interestingTOF, Double_t *interestingTOT,
3793 Double_t *interestingADC, Double_t *interestingWeight,
3794 Int_t *parTOF, Double_t *posClus, Bool_t &check)
3797 // Calculates the mean values for cluster position (x,y,z),
3798 // TOF charge and time
3801 Double_t tofAverage = 0.;
3802 Double_t totAverage = 0.;
3803 Double_t adcAverage = 0.;
3807 for (ii=number-1; ii>=0; ii--) check=check||(interestingWeight[ii]==0 || interestingWeight[ii]==-1);
3811 posClus[0] = TMath::Mean(number, interestingX);
3812 posClus[1] = TMath::Mean(number, interestingY);
3813 posClus[2] = TMath::Mean(number, interestingZ);
3814 tofAverage = TMath::Mean(number, interestingTOF);
3815 totAverage = TMath::Mean(number, interestingTOT);
3816 adcAverage = TMath::Mean(number, interestingADC);
3821 posClus[0] = TMath::Mean(number, interestingX, interestingWeight);
3822 posClus[1] = TMath::Mean(number, interestingY, interestingWeight);
3823 posClus[2] = TMath::Mean(number, interestingZ, interestingWeight);
3824 tofAverage = TMath::Mean(number, interestingTOF, interestingWeight);
3825 totAverage = TMath::Mean(number, interestingTOT, interestingWeight);
3826 adcAverage = TMath::Mean(number, interestingADC, interestingWeight);
3830 parTOF[0] = Int_t(tofAverage);
3831 parTOF[1] = Int_t(totAverage);
3832 parTOF[2] = Int_t(adcAverage);
3833 parTOF[3] = Int_t(tofAverage);//tofND
3834 parTOF[4] = Int_t(tofAverage);//tofRAW