fixing warnings
[u/mrichter/AliRoot.git] / TOF / AliTOFClusterFinderV1.cxx
CommitLineData
e3bd5504 1/***************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16/*
17$Log: AliTOFClusterFinderV1.cxx,v $
e885fb81 18Revision 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
23
e3bd5504 24Revision 0.01 2008/05/10 A. De Caro
25 */
26
27/////////////////////////////////////////
28// //
29// Class for TOF cluster finder (V1) //
30// //
31// Input data: Raw Data or Digits; //
32// Output data: Digits or Rec Points //
33// //
34/////////////////////////////////////////
35
36#include "Riostream.h"
37
38#include "TClonesArray.h"
39#include "TStopwatch.h"
40#include "TTree.h"
41#include "TGeoMatrix.h"
42#include "TString.h"
43
44#include "AliDAQ.h"
45#include "AliLog.h"
46#include "AliRawReader.h"
47#include "AliRunLoader.h"
48#include "AliGeomManager.h"
49
50#include "AliTOFcalib.h"
51#include "AliTOFChannelOnlineArray.h"
52#include "AliTOFChannelOnlineStatusArray.h"
53#include "AliTOFChannelOffline.h"
54#include "AliTOFClusterFinderV1.h"
55#include "AliTOFcluster.h"
56#include "AliTOFdigit.h"
e3bd5504 57#include "AliTOFDigitMap.h"
e3bd5504 58#include "AliTOFrawData.h"
45a69ca6 59#include "AliTOFReconstructor.h"
60#include "AliTOFRecoParam.h"
e3bd5504 61
62ClassImp(AliTOFClusterFinderV1)
63
e885fb81 64//_____________________________________________________________________________
e3bd5504 65AliTOFClusterFinderV1::AliTOFClusterFinderV1(AliTOFcalib *calib):
ed1f8475 66 TTask("AliTOFClusterFinderV1",""),
e3bd5504 67 fRunLoader(0),
68 fDigits(new TClonesArray("AliTOFdigit", 4000)),
69 fRecPoints(new TClonesArray("AliTOFcluster", 4000)),
70 fNumberOfTofClusters(0),
71 fNumberOfTofDigits(0),
d7ed6a6d 72 fkRecoParam(0),//AliTOFReconstructor::GetRecoParam()),
73 fMaxDeltaTime(0),//fkRecoParam->GetMaxDeltaTime()),
e3bd5504 74 fVerbose(0),
75 fDecoderVersion(0),
76 fTOFcalib(calib),
0275b7df 77 fTOFdigitMap(new AliTOFDigitMap()),
e885fb81 78 fTOFGeometry(new AliTOFGeometry()),
d7ed6a6d 79 fTOFdigits(new TTree()),
80 fTOFRawStream(AliTOFRawStream()),
81 fCalibrateTOFtimes(1)
e3bd5504 82{
83//
84// Constructor
85//
d7ed6a6d 86
87 if (AliTOFReconstructor::GetRecoParam()) {
88 fkRecoParam = AliTOFReconstructor::GetRecoParam();
89 fMaxDeltaTime = fkRecoParam->GetMaxDeltaTime();
90 }
91 else
92 fMaxDeltaTime = 2;
93
94 TString validity = (TString)fTOFcalib->GetOfflineValidity();
95 if (validity.CompareTo("valid")==0) {
96 AliInfo(Form(" validity = %s - Using offline calibration parameters", validity.Data()));
97 } else {
98 AliInfo(Form(" validity = %s - Using online calibration parameters", validity.Data()));
99 }
100
e3bd5504 101}
e3bd5504 102
e885fb81 103//_____________________________________________________________________________
e3bd5504 104AliTOFClusterFinderV1::AliTOFClusterFinderV1(AliRunLoader* runLoader, AliTOFcalib *calib):
ed1f8475 105 TTask("AliTOFClusterFinderV1",""),
e3bd5504 106 fRunLoader(runLoader),
107 fDigits(new TClonesArray("AliTOFdigit", 4000)),
108 fRecPoints(new TClonesArray("AliTOFcluster", 4000)),
109 fNumberOfTofClusters(0),
110 fNumberOfTofDigits(0),
d7ed6a6d 111 fkRecoParam(0),//AliTOFReconstructor::GetRecoParam()),
112 fMaxDeltaTime(0),//fkRecoParam->GetMaxDeltaTime()),
e3bd5504 113 fVerbose(0),
114 fDecoderVersion(0),
115 fTOFcalib(calib),
0275b7df 116 fTOFdigitMap(new AliTOFDigitMap()),
e885fb81 117 fTOFGeometry(new AliTOFGeometry()),
d7ed6a6d 118 fTOFdigits(new TTree()),
119 fTOFRawStream(AliTOFRawStream()),
120 fCalibrateTOFtimes(1)
e3bd5504 121{
122//
123// Constructor
124//
d7ed6a6d 125
126 if (AliTOFReconstructor::GetRecoParam()) {
127 fkRecoParam = AliTOFReconstructor::GetRecoParam();
128 fMaxDeltaTime = fkRecoParam->GetMaxDeltaTime();
129 }
130 else
131 fMaxDeltaTime = 2;
132
133 TString validity = (TString)fTOFcalib->GetOfflineValidity();
134 if (validity.CompareTo("valid")==0) {
135 AliInfo(Form(" validity = %s - Using offline calibration parameters", validity.Data()));
136 } else {
137 AliInfo(Form(" validity = %s - Using online calibration parameters", validity.Data()));
138 }
e3bd5504 139
140}
141//_____________________________________________________________________________
142
143AliTOFClusterFinderV1::AliTOFClusterFinderV1(const AliTOFClusterFinderV1 &source)
ed1f8475 144 :TTask(source),
8a190ba2 145 fRunLoader(0),
146 fDigits(source.fDigits),
147 fRecPoints(source.fRecPoints),
c0f9ecc7 148 fNumberOfTofClusters(0),
149 fNumberOfTofDigits(0),
d7ed6a6d 150 fkRecoParam(0),//AliTOFReconstructor::GetRecoParam()),
151 fMaxDeltaTime(0),//fkRecoParam->GetMaxDeltaTime()),
c0f9ecc7 152 fVerbose(0),
153 fDecoderVersion(source.fDecoderVersion),
154 fTOFcalib(source.fTOFcalib),
0275b7df 155 fTOFdigitMap(new AliTOFDigitMap()),
e885fb81 156 fTOFGeometry(new AliTOFGeometry()),
157 fTOFdigits(source.fTOFdigits),
d7ed6a6d 158 fTOFRawStream(source.fTOFRawStream),
159 fCalibrateTOFtimes(1)
e3bd5504 160{
161 // copy constructor
d7ed6a6d 162
163 if (AliTOFReconstructor::GetRecoParam()) {
164 fkRecoParam = AliTOFReconstructor::GetRecoParam();
165 fMaxDeltaTime = fkRecoParam->GetMaxDeltaTime();
166 }
167 else
168 fMaxDeltaTime = 2;
169
e3bd5504 170}
171//_____________________________________________________________________________
172
173AliTOFClusterFinderV1& AliTOFClusterFinderV1::operator=(const AliTOFClusterFinderV1 &source)
174{
175 // ass. op.
8a190ba2 176
177 if (this == &source)
178 return *this;
179
180 TObject::operator=(source);
181 fDigits=source.fDigits;
182 fRecPoints=source.fRecPoints;
183 fVerbose=source.fVerbose;
184 fDecoderVersion=source.fDecoderVersion;
185 fTOFcalib=source.fTOFcalib;
186 fTOFdigitMap=source.fTOFdigitMap;
e885fb81 187 fTOFGeometry=source.fTOFGeometry;
188 fTOFdigits=source.fTOFdigits;
0275b7df 189 fTOFRawStream=source.fTOFRawStream;
d7ed6a6d 190 fCalibrateTOFtimes=source.fCalibrateTOFtimes;
e3bd5504 191 return *this;
192
193}
194//_____________________________________________________________________________
195
196AliTOFClusterFinderV1::~AliTOFClusterFinderV1()
197{
198
199 //
200 // Destructor
201 //
202
203 if (fDigits)
204 {
205 fDigits->Delete();
206 delete fDigits;
207 fDigits=0;
208 }
209 if (fRecPoints)
210 {
211 fRecPoints->Delete();
212 delete fRecPoints;
213 fRecPoints=0;
214 }
215
216 delete fTOFdigitMap;
217
e885fb81 218 delete fTOFGeometry;
219
220 delete fTOFdigits;
221
8ba211c3 222 if (fTofClusters || fNumberOfTofClusters) {
223 for (Int_t ii=0; ii<fNumberOfTofClusters; ii++)
fd6c5c3d 224 if (fTofClusters[ii]) fTofClusters[ii]->Delete();
8ba211c3 225 fNumberOfTofClusters = 0;
226 }
227
e3bd5504 228}
229//_____________________________________________________________________________
230
231void AliTOFClusterFinderV1::Digits2RecPoints(TTree* digitsTree, TTree* clusterTree)
232{
233 //
234 // Converts digits to recPoints for TOF
235 //
236
237 TStopwatch stopwatch;
238 stopwatch.Start();
239
240 Int_t inholes = 0;
241
ed1f8475 242 fDigits->Clear();
e3bd5504 243 TClonesArray &aDigits = *fDigits;
244
245 if (digitsTree == 0x0)
246 AliFatal("Can not get TreeD for TOF");
247
248 TBranch *branch = digitsTree->GetBranch("TOF");
249 if (!branch) {
250 AliError("Can not get branch with the TOF digits !");
251 return;
252 }
253
254 TClonesArray staticDigits("AliTOFdigit",10000);
255 staticDigits.Clear();
256 TClonesArray *digits = &staticDigits;
257 branch->SetAddress(&digits);
258 digitsTree->GetEvent(0);
d7ed6a6d 259 AliDebug(1,Form("Number of TOF digits: %d", digits->GetEntriesFast()));
e3bd5504 260
261 AliTOFdigit *tofDigit;
262
263 Int_t jj = 0;
264 Int_t detectorIndex[5];
265 for (jj=0; jj<5; jj++) detectorIndex[jj] = -1;
266 Int_t info[4];
267 for (jj=0; jj<4; jj++) info[jj] = -1;
268 Int_t *tracks;
269 Int_t tdcCorr;
270 Int_t dummy = -1;
271 Int_t last = -1;
272
273 Bool_t status = kTRUE;
274
bafe290d 275 AliDebug(1," Calibrating TOF Digits");
d7ed6a6d 276 /*
e3bd5504 277 TString validity = (TString)fTOFcalib->GetOfflineValidity();
e3bd5504 278 if (validity.CompareTo("valid")==0) {
bafe290d 279 AliInfo(Form(" validity = %s - Using offline calibration parameters", validity.Data()));
280 } else
281 AliInfo(Form(" validity = %s - Using online calibration parameters", validity.Data()));
d7ed6a6d 282 */
e3bd5504 283
284 Int_t ii = 0;
285 for (ii=0; ii<digits->GetEntriesFast(); ii++) {
286 tofDigit = (AliTOFdigit*)digits->UncheckedAt(ii);
287 detectorIndex[0] = tofDigit->GetSector();
288 detectorIndex[1] = tofDigit->GetPlate();
289 detectorIndex[2] = tofDigit->GetStrip();
290 detectorIndex[3] = tofDigit->GetPadz();
291 detectorIndex[4] = tofDigit->GetPadx();
292
293 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
294 if (detectorIndex[1]==2) { // plate with holes
295 inholes++;
296 continue;
297 }
298 }
299
d7ed6a6d 300 tdcCorr = tofDigit->GetTdc();
e3bd5504 301 status = MakeSlewingCorrection(detectorIndex, tofDigit->GetToT(), tofDigit->GetTdc(), tdcCorr);
302
303 for (jj=0; jj<4; jj++) info[jj] = -1;
304 info[0] = tdcCorr;//tofDigit->GetTdc();
305 info[1] = tofDigit->GetAdc();
306 info[2] = tofDigit->GetToT();
90b234fe 307 info[3] = tofDigit->GetTdcND();//tofDigit->GetTdc();//
e3bd5504 308 tracks = tofDigit->GetTracks();
309
310 dummy = detectorIndex[3];
311 detectorIndex[3] = detectorIndex[4];//padx
312 detectorIndex[4] = dummy;//padz
313 last = fDigits->GetEntriesFast();
314 new (aDigits[last]) AliTOFdigit(tracks, detectorIndex, info);
315 if (status) fTOFdigitMap->AddDigit(detectorIndex, last);
316
e885fb81 317 AliDebug(2, Form(" Digits reading %2d -> %2d %1d %2d %1d %2d (%d, %d, %d)",
e3bd5504 318 last,
319 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[3], detectorIndex[4],
320 info[0], info[1], info[3]));
321
322 }
323
324 fNumberOfTofDigits = fDigits->GetEntriesFast();
325
326 ResetRecpoint();
327
328 Int_t bufsize = 32000;
329 clusterTree->Branch("TOF", &fRecPoints, bufsize);
330
331 FillRecPoint();
332 clusterTree->Fill();
333
d7ed6a6d 334 AliDebug(1,Form("Number of found clusters: %d", fNumberOfTofClusters));
e3bd5504 335
336 ResetRecpoint();
337
338 fTOFdigitMap->Clear();
339
340 ResetDigits();
341
bafe290d 342 AliDebug(1,Form("Execution time to read TOF digits and to write TOF clusters : R:%.4fs C:%.4fs",
343 stopwatch.RealTime(),stopwatch.CpuTime()));
e3bd5504 344
345 if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
346
347}
348//_____________________________________________________________________________
349
350void AliTOFClusterFinderV1::Digits2RecPoints(AliRawReader *rawReader, TTree *clustersTree)
351{
352 //
353 // Converts raw data to recPoints for TOF
354 //
355
356 TStopwatch stopwatch;
357 stopwatch.Start();
358
359
360 AliDebug(2, "TreeD re-creation");
e885fb81 361 //TTree *digitsTree = new TTree();
362 //Raw2Digits(rawReader, digitsTree);
e3bd5504 363
e885fb81 364 Raw2Digits(rawReader, fTOFdigits);
e3bd5504 365
d7ed6a6d 366 AliDebug(1,Form("Number of TOF digits: %d", fNumberOfTofDigits));
e3bd5504 367 ResetRecpoint();
368
369 Int_t bufsize = 32000;
370 clustersTree->Branch("TOF", &fRecPoints, bufsize);
371 FillRecPoint();
372
373 clustersTree->Fill();
374
d7ed6a6d 375 AliDebug(1,Form("Number of found clusters: %d", fNumberOfTofClusters));
e3bd5504 376
377 ResetRecpoint();
378
379 fTOFdigitMap->Clear();
380
381 ResetDigits();
382
bafe290d 383 AliDebug(1,Form("Execution time to read TOF raw data and to write TOF clusters : R:%.4fs C:%.4fs",
384 stopwatch.RealTime(),stopwatch.CpuTime()));
e3bd5504 385
386}
387
388//_____________________________________________________________________________
389
390void AliTOFClusterFinderV1::Raw2Digits(AliRawReader *rawReader, TTree* digitsTree)
391{
392 //
393 // Converts raw data to digits for TOF
394 //
395
396 TStopwatch stopwatch;
397 stopwatch.Start();
398
399 Int_t inholes = 0;
400
401 const Int_t kMaxNumberOfTracksPerDigit = 3;
402 const Int_t kDDL = AliDAQ::NumberOfDdls("TOF");
403
404 digitsTree->Branch("TOF", &fDigits);
405 TClonesArray &aDigits = *fDigits;
406
0275b7df 407 fTOFRawStream.Clear();
408 fTOFRawStream.SetRawReader(rawReader);
e3bd5504 409
410 ofstream ftxt;
411 if (fVerbose==2) ftxt.open("TOFdigitsRead.txt",ios::app);
412
413 TClonesArray staticRawData("AliTOFrawData",10000);
414 staticRawData.Clear();
415 TClonesArray * clonesRawData = &staticRawData;
416
417 Int_t dummy = -1;
418 Int_t detectorIndex[5] = {-1, -1, -1, -1, -1};
419 Int_t digit[4];
420 Int_t tracks[kMaxNumberOfTracksPerDigit];
421 for (Int_t ii=0; ii<kMaxNumberOfTracksPerDigit; ii++)
422 tracks[ii] = -1;
423 Int_t last = -1;
424 Int_t tdcCorr = 0;
425
426 Bool_t status = kTRUE;
427
d7ed6a6d 428 /*
e3bd5504 429 TString validity = (TString)fTOFcalib->GetOfflineValidity();
e3bd5504 430 if (validity.CompareTo("valid")==0) {
bafe290d 431 AliInfo(Form(" validity = %s - Using offline calibration parameters", validity.Data()));
432 } else
433 AliInfo(Form(" validity = %s - Using online calibration parameters", validity.Data()));
d7ed6a6d 434 */
bafe290d 435
436 if (fDecoderVersion)
437 AliInfo("Using New Decoder");
e3bd5504 438
439 Int_t indexDDL = 0;
440 Int_t iRawData = 0;
441 for (indexDDL=0; indexDDL<kDDL; indexDDL++) {
442
443 rawReader->Reset();
bafe290d 444 if (fDecoderVersion)
0275b7df 445 fTOFRawStream.LoadRawDataBuffers(indexDDL,fVerbose);
0275b7df 446 else fTOFRawStream.LoadRawData(indexDDL);
e3bd5504 447
0275b7df 448 clonesRawData = (TClonesArray*)fTOFRawStream.GetRawData();
d7ed6a6d 449 if (clonesRawData->GetEntriesFast()!=0) AliDebug(2,Form(" TOF raw data number = %3d", clonesRawData->GetEntriesFast()));
e3bd5504 450 for (iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
451
452 AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
453
454 //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
455 if (tofRawDatum->GetTOF()==-1) continue;
456
0275b7df 457 fTOFRawStream.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
458 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
e3bd5504 459
460 tdcCorr = 0;
461 dummy = detectorIndex[3];
462 detectorIndex[3] = detectorIndex[4];//padz
463 detectorIndex[4] = dummy;//padx
d7ed6a6d 464
465 tdcCorr = tofRawDatum->GetTOF();
e3bd5504 466 status = MakeSlewingCorrection(detectorIndex, tofRawDatum->GetTOT(), tofRawDatum->GetTOF(), tdcCorr);
467
468 digit[0] = tdcCorr;
469 digit[1] = tofRawDatum->GetTOT();
470 digit[2] = tofRawDatum->GetTOT();
e885fb81 471 digit[3] = -1;//tofRawDatum->GetTOF(); //tofND
e3bd5504 472
473 dummy = detectorIndex[3];
474 detectorIndex[3] = detectorIndex[4];//padx
475 detectorIndex[4] = dummy;//padz
476
d7ed6a6d 477 /* check valid index */
478 if (detectorIndex[0]==-1||detectorIndex[1]==-1||detectorIndex[2]==-1||detectorIndex[3]==-1||detectorIndex[4]==-1) continue;
729f0d7f 479
e3bd5504 480 // Do not reconstruct anything in the holes
481 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
482 if (detectorIndex[1]==2) { // plate with holes
483 inholes++;
484 continue;
485 }
486 }
487
488 last = fDigits->GetEntriesFast();
489 new (aDigits[last]) AliTOFdigit(tracks, detectorIndex, digit);
490 if (status) fTOFdigitMap->AddDigit(detectorIndex, last);
491
492 if (fVerbose==2) {
493 if (indexDDL<10) ftxt << " " << indexDDL;
494 else ftxt << " " << indexDDL;
495 if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM();
496 else ftxt << " " << tofRawDatum->GetTRM();
497 ftxt << " " << tofRawDatum->GetTRMchain();
498 if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC();
499 else ftxt << " " << tofRawDatum->GetTDC();
500 ftxt << " " << tofRawDatum->GetTDCchannel();
501
502 if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0];
503 else ftxt << " -> " << detectorIndex[0];
504 ftxt << " " << detectorIndex[1];
505 if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2];
506 else ftxt << " " << detectorIndex[2];
507 ftxt << " " << detectorIndex[4];
508 if (detectorIndex[4]<10) ftxt << " " << detectorIndex[3];
509 else ftxt << " " << detectorIndex[3];
510
511 if (digit[1]<10)ftxt << " " << digit[1];
512 else if (digit[1]>=10 && digit[1]<100) ftxt << " " << digit[1];
513 else ftxt << " " << digit[1];
514 if (digit[0]<10) ftxt << " " << digit[0] << endl;
515 else if (digit[0]>=10 && digit[0]<100) ftxt << " " << digit[0] << endl;
516 else if (digit[0]>=100 && digit[0]<1000) ftxt << " " << digit[0] << endl;
517 else ftxt << " " << digit[3] << endl;
518 }
519
e885fb81 520 AliDebug(2, Form(" Raw data reading %2d -> %2d %1d %2d %1d %2d (%d, %d, %d)",
e3bd5504 521 last,
522 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[4], detectorIndex[3],
523 digit[0], digit[1], digit[3]));
524
525 } // while loop
526
527 clonesRawData->Clear();
528
529 } // DDL Loop
530
531 if (fVerbose==2) ftxt.close();
532
533 digitsTree->Fill();
534
535 fNumberOfTofDigits = fDigits->GetEntries();
536
537 AliDebug(1, Form("Got %d TOF digits", fNumberOfTofDigits));
538 AliDebug(1, Form("Execution time to read TOF raw data and fill TOF digit tree : R:%.2fs C:%.2fs",
539 stopwatch.RealTime(),stopwatch.CpuTime()));
540
541 if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
542
543}
544//_____________________________________________________________________________
545
546void AliTOFClusterFinderV1::FillRecPoint()
547{
548 //
549 // Fill the global TClonesArray of AliTOFcluster objects,
550 // i.e. fRecPoints
551 //
552
b9b780e4 553 Int_t dummy4 = -1;
554 Int_t dummy3 = -1;
555 Int_t dummy2 = -1;
d7ed6a6d 556 Int_t dummy = -1;
e3bd5504 557
e885fb81 558 for(Int_t iPlate=AliTOFGeometry::NPlates()-1; iPlate>=0; iPlate--) {
559 for(Int_t iStrip=AliTOFGeometry::NStrip(iPlate)-1; iStrip>=0; iStrip--) {
560 //for (Int_t iSector=AliTOFGeometry::NSectors()-1; iSector>=0; iSector--) {
e3bd5504 561 for (Int_t iSector=0; iSector<AliTOFGeometry::NSectors(); iSector++) {
e885fb81 562
d7ed6a6d 563
ed1f8475 564 if (fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))
565 AliDebug(1,Form(" Number of TOF digits in (%2d,%1d,%2d) -> %d",
566 iSector,iPlate,iStrip,fTOFdigitMap->FilledCellsInStrip(iSector,iPlate,iStrip)));
d7ed6a6d 567
e885fb81 568 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
569 FindClustersWithoutTOT(iSector, iPlate, iStrip); // clusters coming from digits without TOT measurement
570
ed1f8475 571 if (fMaxDeltaTime>0) {
e885fb81 572
ed1f8475 573 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
574 //if (fTOFdigitMap->FilledCellsInStrip(iSector,iPlate,iStrip)>=4)
575 FindClustersPerStrip(iSector, iPlate, iStrip, 4); // 4 pads clusters
576 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
e885fb81 577
ed1f8475 578 dummy4 = fNumberOfTofClusters;
579 FindClustersPerStrip(iSector, iPlate, iStrip, 4); // 4 pads clusters
580 if (fNumberOfTofClusters!=dummy4)
4682c56e 581 AliDebug(2, Form(" (4): n1= %5d, n2 = %5d", dummy4, fNumberOfTofClusters));
e885fb81 582
583
ed1f8475 584 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
585 FindClustersPerStrip(iSector, iPlate, iStrip, 3); // 3 pads clusters
586 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
e885fb81 587
ed1f8475 588 dummy3 = fNumberOfTofClusters;
589 FindClustersPerStrip(iSector, iPlate, iStrip, 3); // 3 pads clusters
590 if (fNumberOfTofClusters!=dummy3)
4682c56e 591 AliDebug(2, Form(" (3): n1= %5d, n2 = %5d", dummy3, fNumberOfTofClusters));
e885fb81 592
593
ed1f8475 594 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
595 FindClustersPerStrip(iSector, iPlate, iStrip, 2); // 2 pads clusters
596 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
e885fb81 597
ed1f8475 598 dummy2 = fNumberOfTofClusters;
599 FindClustersPerStrip(iSector, iPlate, iStrip, 2); // 2 pads clusters
600 if (fNumberOfTofClusters!=dummy2)
4682c56e 601 AliDebug(2, Form(" (2): n1= %5d, n2 =%5d", dummy2, fNumberOfTofClusters));
e885fb81 602
603
ed1f8475 604 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
605 dummy = fNumberOfTofClusters;
606 FindClusters34(iSector, iPlate, iStrip); // 3 pads clusters between 4 hit pads
607 if (fNumberOfTofClusters!=dummy)
608 AliDebug(2, Form(" (3 between 4): n1 = %5d, n2 = %5d", fNumberOfTofClusters, dummy));
e885fb81 609
610
ed1f8475 611 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
612 dummy = fNumberOfTofClusters;
613 FindClusters23(iSector, iPlate, iStrip); // 2 pads clusters between 3 hit pads
614 if (fNumberOfTofClusters!=dummy)
615 AliDebug(2, Form(" (2 between 3): n1 = %5d, n2 = %5d", fNumberOfTofClusters, dummy));
e3bd5504 616
ed1f8475 617 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
618 dummy = fNumberOfTofClusters;
619 FindClusters24(iSector, iPlate, iStrip); // 2 pads clusters between 4 hit pads
620 if (fNumberOfTofClusters!=dummy)
621 AliDebug(2, Form(" (2 between 4): n1 = %5d, n2 = %5d", fNumberOfTofClusters, dummy));
e3bd5504 622
623
ed1f8475 624 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
625 dummy = fNumberOfTofClusters;
626 FindOnePadClusterPerStrip(iSector, iPlate, iStrip); // 1 pad clusters
627 if (fNumberOfTofClusters!=dummy)
628 AliDebug(2,Form(" (1): n1 = %5d, n2 = %5d", fNumberOfTofClusters, dummy));
629
630 if (fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip)>0)
631 AliDebug(2, Form(" (1): number of clusters = %5d (remaining digit %2d), -%2d %1d %2d-",
632 fNumberOfTofClusters, fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip),
633 iSector, iPlate, iStrip));
634
635 }
636 else {
637 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
638 dummy = fNumberOfTofClusters;
639 FindOnePadClusterPerStrip(iSector, iPlate, iStrip); // 1 pad clusters
640 if (fNumberOfTofClusters!=dummy)
641 AliDebug(2,Form(" (1): n1 = %5d, n2 = %5d", fNumberOfTofClusters, dummy));
642
643 if (fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip)>0)
644 AliDebug(2, Form(" (1): number of clusters = %5d (remaining digit %2d), -%2d %1d %2d-",
645 fNumberOfTofClusters, fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip),
646 iSector, iPlate, iStrip));
647
648 }
e3bd5504 649
e3bd5504 650
651 }
652 }
653 }
654
655
656 TClonesArray &lRecPoints = *fRecPoints;
657
658 Int_t ii, jj;
659
660 Int_t detectorIndex[5];
e885fb81 661 for (jj=0; jj<5; jj++) detectorIndex[jj] = -1;
e3bd5504 662 Int_t parTOF[5];
e885fb81 663 for (jj=0; jj<5; jj++) parTOF[jj] = -1;
e3bd5504 664 Int_t trackLabels[3];
e885fb81 665 for (jj=0; jj<3; jj++) trackLabels[jj] = -1;
e3bd5504 666 Int_t digitIndex = -1;
667 Bool_t status = kTRUE;
668 Float_t posClus[3];
669 for (ii=0; ii<3; ii++) posClus[ii] = 0.;
670 //Float_t covClus[6];
671 //for (ii=0; ii<6; ii++) covClus[ii] = 0.;
672 UShort_t volIdClus;
673
674 for (ii=0; ii<fNumberOfTofClusters; ii++) {
675
676 digitIndex = fTofClusters[ii]->GetIndex();
677 for(jj=0; jj<5; jj++) detectorIndex[jj] = fTofClusters[ii]->GetDetInd(jj);
e885fb81 678 volIdClus = fTOFGeometry->GetAliSensVolIndex(detectorIndex[0],detectorIndex[1],detectorIndex[2]);
679 //volIdClus = GetClusterVolIndex(detectorIndex);
e3bd5504 680 for(jj=0; jj<3; jj++) trackLabels[jj] = fTofClusters[ii]->GetLabel(jj);
681 parTOF[0] = fTofClusters[ii]->GetTDC(); // TDC
682 parTOF[1] = fTofClusters[ii]->GetToT(); // TOT
683 parTOF[2] = fTofClusters[ii]->GetADC(); // ADC=TOT
684 parTOF[3] = fTofClusters[ii]->GetTDCND(); // TDCND
685 parTOF[4] = fTofClusters[ii]->GetTDCRAW();//RAW
686 status = fTofClusters[ii]->GetStatus();
687
688 posClus[0] = fTofClusters[ii]->GetX();
689 posClus[1] = fTofClusters[ii]->GetY();
690 posClus[2] = fTofClusters[ii]->GetZ();
691
692 //for (jj=0; jj<6; jj++) covClus[jj] = 0.;
693 //((AliCluster*)fTofClusters[ii])->GetGlobalCov(covClus);
694
695 new(lRecPoints[ii]) AliTOFcluster(volIdClus, (Double_t)posClus[0], (Double_t)posClus[1], (Double_t)posClus[2],
696 (Double_t)(fTofClusters[ii]->GetSigmaX2()),
697 (Double_t)(fTofClusters[ii]->GetSigmaXY()),
698 (Double_t)(fTofClusters[ii]->GetSigmaXZ()),
699 (Double_t)(fTofClusters[ii]->GetSigmaY2()),
700 (Double_t)(fTofClusters[ii]->GetSigmaYZ()),
701 (Double_t)(fTofClusters[ii]->GetSigmaZ2()),
702 //(Double_t)covClus[0], (Double_t)covClus[1], (Double_t)covClus[2],
703 //(Double_t)covClus[3], (Double_t)covClus[4], (Double_t)covClus[5],
704 trackLabels, detectorIndex, parTOF, status, digitIndex);
705
e885fb81 706 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",
e3bd5504 707 ii, volIdClus, posClus[0], posClus[1], posClus[2],
708 fTofClusters[ii]->GetSigmaX2(),
709 fTofClusters[ii]->GetSigmaXY(),
710 fTofClusters[ii]->GetSigmaXZ(),
711 fTofClusters[ii]->GetSigmaY2(),
712 fTofClusters[ii]->GetSigmaYZ(),
713 fTofClusters[ii]->GetSigmaZ2(),
714 trackLabels[0], trackLabels[1], trackLabels[2],
715 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[3], detectorIndex[4],
716 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
717 status, digitIndex));
718
719
720 }
721
722 for (Int_t iSector=0; iSector<AliTOFGeometry::NSectors(); iSector++)
723 for(Int_t iPlate=0; iPlate<AliTOFGeometry::NPlates(); iPlate++) {
724 for(Int_t iStrip=0; iStrip<AliTOFGeometry::NStrip(iPlate); iStrip++) {
725 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
e885fb81 726 AliDebug(2, Form(" END %2d %1d %2d %5d",
e3bd5504 727 iSector, iPlate, iStrip, fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip)));
728 }
729 }
730
731}
732//_____________________________________________________________________________
733
734void AliTOFClusterFinderV1::FindOnePadClusterPerStrip(Int_t nSector,
735 Int_t nPlate,
736 Int_t nStrip)
737{
738 //
739 // This function searches the isolated digits (stored in the fDigits object),
740 // to perform clusters (stored in the fTofClusters array).
741 // This research has been made by checking the fTOFdigitMap object,
742 // filled at digits/raw-data reading time.
743 //
744
745 const Int_t kMaxNumberOfTracksPerDigit = 3;
cc7a1acd 746 const Int_t kMaxNumberOfDigitsPerVolume = 10;
e3bd5504 747
748 Int_t jj = 0;
749
e3bd5504 750 Int_t det[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padZ,padX
751 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padX,padZ
752 UShort_t volIdClus = 0;
753
754 Float_t pos[3];
755 for (jj=0; jj<3; jj++) pos[jj] = 0.;
756 Double_t posClus[3];
757 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
758
759 Double_t covClus[6];
760 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
761
762 Int_t parTOF[5];
763 for (jj=0; jj<5; jj++) parTOF[jj] = 0;
764
765 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
766
767 Int_t tracks[kMaxNumberOfTracksPerDigit];
ed1f8475 768 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
e3bd5504 769
770 Int_t dummyCounter=-1;
e3bd5504 771
772 AliTOFdigit *digitInteresting;
773
774 Int_t iPadX = -1;
775 Int_t iPadZ = -1;
776 for (iPadX=0; iPadX<AliTOFGeometry::NpadX(); iPadX++) {
777 for (iPadZ=0; iPadZ<AliTOFGeometry::NpadZ(); iPadZ++) {
778 vol[4] = iPadZ , vol[3] = iPadX;
779
e885fb81 780 AliDebug(3, Form(" %1d %2d\n", iPadZ, iPadX));
e3bd5504 781
782 if (fTOFdigitMap->GetNumberOfDigits(vol)==0) continue;
783
784 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
785 if (fTOFdigitMap->GetDigitIndex(vol,digIndex)<0) continue;
786 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(fTOFdigitMap->GetDigitIndex(vol,digIndex));
787
e885fb81 788 AliDebug(2, Form(" %3d %5d %2d %1d %2d %1d %2d %d %d %d %5d %5d %5d %5d",
789 fTOFdigitMap->GetNumberOfDigits(vol), digIndex,
e3bd5504 790 vol[0], vol[1], vol[2] ,vol[4], vol[3],
791 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
792 digitInteresting->GetToT(),
793 fTOFdigitMap->GetDigitIndex(vol,digIndex),
794 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
795
e885fb81 796 det[3] = vol[4]; // padz
797 det[4] = vol[3]; // padx
798 fTOFGeometry->GetPosPar(det,pos);
e3bd5504 799 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
800
801 //insert cluster
802 for (jj=0; jj<3; jj++) posClus[jj] = pos[jj];
803
804 parTOF[0] = Int_t(digitInteresting->GetTdc());
e885fb81 805 parTOF[1] = Int_t(digitInteresting->GetToT());
806 parTOF[2] = Int_t(digitInteresting->GetAdc());
807 parTOF[3] = Int_t(digitInteresting->GetTdcND());
e3bd5504 808 parTOF[4] = Int_t(digitInteresting->GetTdc());
809
e885fb81 810 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
811 //volIdClus = GetClusterVolIndex(det);
e3bd5504 812
813 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
814 GetClusterPars(det, posClus, covClus);
815
816 // To fill the track index array
817 dummyCounter=-1;
818 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
819 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) { // three is the max number of tracks associated to one digit
820 if (digitInteresting->GetTrack(jj)==-1) continue;
821 else {
822 dummyCounter++;
823 tracks[dummyCounter] = digitInteresting->GetTrack(jj);
824 }
825 }
826
827 AliTOFcluster *tofCluster =
828 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
829 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
830 tracks, det, parTOF, status, fTOFdigitMap->GetDigitIndex(vol,digIndex));
831 InsertCluster(tofCluster);
832
e885fb81 833 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",
e3bd5504 834 volIdClus, posClus[0], posClus[1], posClus[2],
835 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
836 tracks[0], tracks[1], tracks[2],
837 det[0], det[1], det[2], det[3], det[4],
838 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
839 status, fTOFdigitMap->GetDigitIndex(vol,digIndex)));
840
841 AliDebug(2, Form(" %f %f %f", pos[0], pos[1], pos[2]));
e885fb81 842 AliDebug(2, Form(" %d %d", parTOF[0], parTOF[2]));
843
844 fTOFdigitMap->ResetDigit(vol, digIndex);
845
846 }
847
848 }
849 }
850
851}
852//_____________________________________________________________________________
853
854void AliTOFClusterFinderV1::FindClustersWithoutTOT(Int_t nSector,
855 Int_t nPlate,
856 Int_t nStrip)
857{
858 //
859 // This function searches the isolated digits without TOT
860 // measurement (stored in the fDigits object), to perform clusters
861 // (stored in the fTofClusters array). This research has been made
862 // by checking the fTOFdigitMap object, filled at digits/raw-data
863 // reading time.
864 //
865
866 const Int_t kMaxNumberOfTracksPerDigit = 3;
cc7a1acd 867 const Int_t kMaxNumberOfDigitsPerVolume = 10;
e885fb81 868
869 Int_t jj = 0;
870
871 Int_t det[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padZ,padX
872 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padX,padZ
873 UShort_t volIdClus = 0;
874
875 Float_t pos[3];
876 for (jj=0; jj<3; jj++) pos[jj] = 0.;
877 Double_t posClus[3];
878 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
879
880 Double_t covClus[6];
881 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
882
883 Int_t parTOF[5];
884 for (jj=0; jj<5; jj++) parTOF[jj] = 0;
885
886 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
887 Int_t tracks[kMaxNumberOfTracksPerDigit];
ed1f8475 888 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
e885fb81 889
890 Int_t dummyCounter=-1;
891
892 AliTOFdigit *digitInteresting;
893
894 Int_t iPadX = -1;
895 Int_t iPadZ = -1;
896 for (iPadX=0; iPadX<AliTOFGeometry::NpadX(); iPadX++) {
897 for (iPadZ=0; iPadZ<AliTOFGeometry::NpadZ(); iPadZ++) {
898 vol[4] = iPadZ , vol[3] = iPadX;
899
900 AliDebug(3, Form(" %1d %2d\n", iPadZ, iPadX));
901
902 if (fTOFdigitMap->GetNumberOfDigits(vol)==0) continue;
903
904 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
905 if (fTOFdigitMap->GetDigitIndex(vol,digIndex)<0) continue;
906 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(fTOFdigitMap->GetDigitIndex(vol,digIndex));
907 if (digitInteresting->GetToT()>0) continue; // AdC
908
909 AliDebug(2, Form(" %3d %5d %2d %1d %2d %1d %2d %d %d %d %5d %5d %5d %5d",
910 fTOFdigitMap->GetNumberOfDigits(vol), digIndex,
911 vol[0], vol[1], vol[2] ,vol[4], vol[3],
912 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
913 digitInteresting->GetToT(),
914 fTOFdigitMap->GetDigitIndex(vol,digIndex),
915 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
916
917 det[3] = vol[4]; // padz
918 det[4] = vol[3]; // padx
919 fTOFGeometry->GetPosPar(det,pos);
920 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
921
922 //insert cluster
923 for (jj=0; jj<3; jj++) posClus[jj] = pos[jj];
924
925 parTOF[0] = Int_t(digitInteresting->GetTdc());
926 parTOF[1] = Int_t(digitInteresting->GetToT());
927 parTOF[2] = Int_t(digitInteresting->GetAdc());
928 parTOF[3] = Int_t(digitInteresting->GetTdcND());
929 parTOF[4] = Int_t(digitInteresting->GetTdc());
930
931 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
932 //volIdClus = GetClusterVolIndex(det);
933
934 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
935 GetClusterPars(det, posClus, covClus);
936
937 // To fill the track index array
938 dummyCounter=-1;
939 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
940 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) { // three is the max number of tracks associated to one digit
941 if (digitInteresting->GetTrack(jj)==-1) continue;
942 else {
943 dummyCounter++;
944 tracks[dummyCounter] = digitInteresting->GetTrack(jj);
945 }
946 }
947
948 AliTOFcluster *tofCluster =
949 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
950 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
951 tracks, det, parTOF, status, fTOFdigitMap->GetDigitIndex(vol,digIndex));
952 InsertCluster(tofCluster);
953
954 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",
955 volIdClus, posClus[0], posClus[1], posClus[2],
956 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
957 tracks[0], tracks[1], tracks[2],
958 det[0], det[1], det[2], det[3], det[4],
959 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
960 status, fTOFdigitMap->GetDigitIndex(vol,digIndex)));
961
962 AliDebug(2, Form(" %f %f %f", pos[0], pos[1], pos[2]));
963 AliDebug(2, Form(" %d %d", parTOF[0], parTOF[2]));
e3bd5504 964
e3bd5504 965 fTOFdigitMap->ResetDigit(vol, digIndex);
966
967 }
968
969 }
970 }
971
972}
973//_____________________________________________________________________________
974
975void AliTOFClusterFinderV1::FindClusters34(Int_t nSector,
976 Int_t nPlate,
977 Int_t nStrip)
978{
979 //
980 // This function searches the neighbouring digits (stored in the fDigits object),
981 // to perform clusters (stored in the fTofClusters array).
982 //
983 // This research has been made by checking the fTOFdigitMap object,
984 // filled at digits/raw-data reading time.
985 //
986
987 const Int_t kMaxNumberOfInterestingPads = 4;
988 const Int_t kMaxNumberOfTracksPerDigit = 3;
cc7a1acd 989 const Int_t kMaxNumberOfDigitsPerVolume = 10;
e3bd5504 990
991 Int_t ii = 0;
992
993 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
994 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
995 digitsInVolumeIndices[ii] = -1;
996
e3bd5504 997 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
998
999 Float_t pos[3] = {0.,0.,0.};
1000
1001 Int_t jj = 0;
1002 Int_t interestingPadX[kMaxNumberOfInterestingPads];
1003 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
1004 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
1005 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
1006 Double_t interestingTOT[kMaxNumberOfInterestingPads];
1007 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
1008 Double_t interestingADC[kMaxNumberOfInterestingPads];
1009 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
1010 Double_t interestingTOF[kMaxNumberOfInterestingPads];
1011 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
1012 Double_t interestingWeight[kMaxNumberOfInterestingPads];
1013 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
1014
1015 Float_t interestingX[kMaxNumberOfInterestingPads];
1016 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
1017 Float_t interestingY[kMaxNumberOfInterestingPads];
1018 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
1019 Float_t interestingZ[kMaxNumberOfInterestingPads];
1020 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
1021
1022 Float_t interDigit[kMaxNumberOfInterestingPads];
1023 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
1024
1025 Int_t padsCluster[11];
1026 padsCluster[0] = nSector;
1027 padsCluster[1] = nPlate;
1028 padsCluster[2] = nStrip;
1029 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1030
1031 Int_t interestingCounter=-1;
e885fb81 1032 Int_t digitIndexLocal=-1; // AdC
e3bd5504 1033 Int_t iPad = -1;
1034 Int_t iPadX = -1;
1035 Int_t iPadZ = -1;
1036
1037 Int_t parTOF[5];
1038 for (jj=0; jj<5; jj++) parTOF[jj] = 0;
1039 Double_t posClus[3];
1040 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
1041 Int_t det[5];
1042 for (jj=0; jj<5; jj++) det[jj] = -1;
1043 Float_t posF[3];
1044 for (jj=0; jj<3; jj++) posF[jj] = 0.;
1045 UShort_t volIdClus = 0;
1046 Bool_t check = kFALSE;
1047 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
1048 Double_t covClus[6];
1049 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1050 Int_t tracks[kMaxNumberOfTracksPerDigit];
ed1f8475 1051 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
e3bd5504 1052 Int_t dummyCounter=-1;
1053 Bool_t alreadyStored = kFALSE;
1054
1055 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
1056 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1057 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
1058
1059 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1060 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
1061
1062 AliTOFdigit *digitInteresting;
1063
1064 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
1065
1066 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
1067 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
1068
e885fb81 1069 AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
e3bd5504 1070
1071
1072
1073
1074
1075
1076 interestingCounter=-1;
1077
1078 vol[4] = iPadZ , vol[3] = iPadX;
1079 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1080 interestingCounter++;
1081
1082 vol[4] = iPadZ, vol[3] = iPadX+1;
1083 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1084 interestingCounter++;
1085
1086 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1087 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1088 interestingCounter++;
1089
1090 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1091 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1092 interestingCounter++;
1093
1094 if (interestingCounter+1!=4) continue; // the hit pads have to be 4
1095 else interestingCounter=-1;
1096
1097
1098 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1099 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1100 selectedDigit[ii][jj] = 0x0;
1101
1102
1103 vol[4] = iPadZ, vol[3] = iPadX;
1104
1105 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1106 interestingCounter++;
1107 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1108 digitsInVolumeIndices[ii] = -1;
1109 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
e885fb81 1110 digitIndexLocal=-1; // AdC
e3bd5504 1111 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1112 if (digitsInVolumeIndices[digIndex]<0) continue;
1113 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
e885fb81 1114 if (digitInteresting->GetToT()<=0) continue; // AdC
1115 digitIndexLocal++; // AdC
e3bd5504 1116
4682c56e 1117 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
e3bd5504 1118 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1119 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1120 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1121 digitsInVolumeIndices[digIndex],
1122 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1123
1124
e885fb81 1125 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
e3bd5504 1126 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1127 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1128 digitInteresting->GetToT()*digitInteresting->GetToT(),
1129 digitsInVolumeIndices[digIndex],
1130 digitInteresting->GetTracks());
1131 }
e885fb81 1132 if (digitIndexLocal==-1) interestingCounter--; // AdC
e3bd5504 1133 }
1134
1135
1136 vol[4] = iPadZ, vol[3] = iPadX+1;
1137
1138 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1139 interestingCounter++;
1140 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1141 digitsInVolumeIndices[ii] = -1;
1142 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
e885fb81 1143 digitIndexLocal=-1; // AdC
e3bd5504 1144 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1145 if (digitsInVolumeIndices[digIndex]<0) continue;
1146 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
e885fb81 1147 if (digitInteresting->GetToT()<=0) continue; // AdC
1148 digitIndexLocal++; // AdC
e3bd5504 1149
4682c56e 1150 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
e3bd5504 1151 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1152 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1153 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1154 digitsInVolumeIndices[digIndex],
1155 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1156
1157
e885fb81 1158 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
e3bd5504 1159 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1160 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1161 digitInteresting->GetToT()*digitInteresting->GetToT(),
1162 digitsInVolumeIndices[digIndex],
1163 digitInteresting->GetTracks());
1164 }
e885fb81 1165 if (digitIndexLocal==-1) interestingCounter--; // AdC
e3bd5504 1166 }
1167
1168
1169 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1170
1171 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1172 interestingCounter++;
1173 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1174 digitsInVolumeIndices[ii] = -1;
1175 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
e885fb81 1176 digitIndexLocal=-1; // AdC
e3bd5504 1177 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1178 if (digitsInVolumeIndices[digIndex]<0) continue;
1179 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
e885fb81 1180 if (digitInteresting->GetToT()<=0) continue; // AdC
1181 digitIndexLocal++; // AdC
e3bd5504 1182
4682c56e 1183 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
e3bd5504 1184 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1185 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1186 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1187 digitsInVolumeIndices[digIndex],
1188 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1189
1190
e885fb81 1191 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
e3bd5504 1192 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1193 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1194 digitInteresting->GetToT()*digitInteresting->GetToT(),
1195 digitsInVolumeIndices[digIndex],
1196 digitInteresting->GetTracks());
1197 }
e885fb81 1198 if (digitIndexLocal==-1) interestingCounter--; // AdC
e3bd5504 1199 }
1200
1201
1202 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1203
1204 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1205 interestingCounter++;
1206 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1207 digitsInVolumeIndices[ii] = -1;
1208 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
e885fb81 1209 digitIndexLocal=-1;
e3bd5504 1210 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1211 if (digitsInVolumeIndices[digIndex]<0) continue;
1212 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
e885fb81 1213 if (digitInteresting->GetToT()<=0) continue; // AdC
1214 digitIndexLocal++; // AdC
e3bd5504 1215
4682c56e 1216 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
e3bd5504 1217 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1218 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1219 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1220 digitsInVolumeIndices[digIndex],
1221 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1222
e885fb81 1223 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
e3bd5504 1224 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1225 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1226 digitInteresting->GetToT()*digitInteresting->GetToT(),
1227 digitsInVolumeIndices[digIndex],
1228 digitInteresting->GetTracks());
1229 }
e885fb81 1230 if (digitIndexLocal==-1) interestingCounter--; // AdC
e3bd5504 1231 }
1232
e885fb81 1233 AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
e3bd5504 1234
1235 for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
1236 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
1237 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
1238
1239 for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
1240 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
1241 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
1242
1243 for (Int_t adesso3=adesso2+1; adesso3<interestingCounter+1; adesso3++) {
1244 for (Int_t thirdIndex=0; thirdIndex<kMaxNumberOfDigitsPerVolume; thirdIndex++) {
1245 if (selectedDigit[adesso3][thirdIndex]==0x0) continue;
1246
1247
1248 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime
1249 ||
1250 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
1251 ||
1252 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime) continue;
1253
1254 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
1255 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
1256 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
1257 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
1258 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
e885fb81 1259 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
e3bd5504 1260 Int_t volDum = vol1[3];
1261 vol1[3] = vol1[4];
1262 vol1[4] = volDum;
e885fb81 1263 fTOFGeometry->GetPosPar(vol1,pos);
e3bd5504 1264 interestingX[0] = pos[0];
1265 interestingY[0] = pos[1];
1266 interestingZ[0] = pos[2];
1267
1268 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
1269 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
1270 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
1271 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
1272 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
e885fb81 1273 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
e3bd5504 1274 volDum = vol2[3];
1275 vol2[3] = vol2[4];
1276 vol2[4] = volDum;
e885fb81 1277 fTOFGeometry->GetPosPar(vol2,pos);
e3bd5504 1278 interestingX[1] = pos[0];
1279 interestingY[1] = pos[1];
1280 interestingZ[1] = pos[2];
1281
1282 interestingTOF[2] = selectedDigit[adesso3][thirdIndex]->GetTDC();
1283 interestingTOT[2] = selectedDigit[adesso3][thirdIndex]->GetTOT();
1284 interestingADC[2] = selectedDigit[adesso3][thirdIndex]->GetADC();
1285 interestingWeight[2] = selectedDigit[adesso3][thirdIndex]->GetWeight();
1286 Int_t vol3[5]; for(jj=0; jj<5; jj++) vol3[jj] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(jj);
e885fb81 1287 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol3[0], vol3[1], vol3[2], vol3[4], vol3[3]));
e3bd5504 1288 volDum = vol3[3];
1289 vol3[3] = vol3[4];
1290 vol3[4] = volDum;
e885fb81 1291 fTOFGeometry->GetPosPar(vol3,pos);
e3bd5504 1292 interestingX[2] = pos[0];
1293 interestingY[2] = pos[1];
1294 interestingZ[2] = pos[2];
1295
1296
1297 AverageCalculations(3, interestingX, interestingY, interestingZ,
1298 interestingTOF, interestingTOT, interestingADC,
1299 interestingWeight,
1300 parTOF, posClus, check);
1301
1302
1303 for (jj=0; jj<5; jj++) det[jj] = -1;
1304 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
e885fb81 1305 fTOFGeometry->GetDetID(posF, det);
e3bd5504 1306
e885fb81 1307 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
1308 //volIdClus = GetClusterVolIndex(det);
e3bd5504 1309
1310 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1311 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
1312 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
1313 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
1314 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
1315 padsCluster[7] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(4);
1316 padsCluster[8] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(3);
1317
1318 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1319 Int_t ** indDet = new Int_t*[3];
1320 for (jj=0; jj<3; jj++) indDet[jj] = new Int_t [5];
1321 for (jj=0; jj<3; jj++) indDet[jj][0] = nSector;
1322 for (jj=0; jj<3; jj++) indDet[jj][1] = nPlate;
1323 for (jj=0; jj<3; jj++) indDet[jj][2] = nStrip;
1324 for (jj=0; jj<3; jj++) indDet[jj][3] = padsCluster[2*jj+3];
1325 for (jj=0; jj<3; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
e885fb81 1326 GetClusterPars(/*check,*/ 3, indDet, interestingWeight, posClus, covClus);
e3bd5504 1327 for (jj=0; jj<3; jj++) delete [] indDet[jj];
1328
1329 // To fill the track index array
1330 dummyCounter=-1;
1331 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1332 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1333 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
1334 else {
1335 dummyCounter++;
1336 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
1337 }
1338 }
1339 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1340 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
1341 else {
1342
1343 alreadyStored = kFALSE;
1344 for (jj=0; jj<dummyCounter+1; jj++)
1345 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
1346
1347 if (alreadyStored) continue;
1348 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
1349 AliWarning(" Siamo al limite!");
1350 continue;
1351 }
1352
1353 dummyCounter++;
1354 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
1355
1356 }
1357
1358 }
1359 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1360 if (selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk)==-1) continue;
1361 else {
1362
1363 alreadyStored = kFALSE;
1364 for (jj=0; jj<dummyCounter+1; jj++)
1365 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk));
1366
1367 if (alreadyStored) continue;
1368 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
1369 AliWarning(" Siamo al limite!");
1370 continue;
1371 }
1372
1373 dummyCounter++;
1374 tracks[dummyCounter] = selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk);
1375
1376 }
1377
1378 }
1379
1380
1381 AliTOFcluster *tofCluster =
1382 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
1383 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1384 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
1385 InsertCluster(tofCluster);
1386
e885fb81 1387 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",
e3bd5504 1388 volIdClus, posClus[0], posClus[1], posClus[2],
1389 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1390 tracks[0], tracks[1], tracks[2],
1391 det[0], det[1], det[2], det[3], det[4],
1392 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
1393 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
1394
1395
1396 volDum = vol1[3];
1397 vol1[3] = vol1[4];
1398 vol1[4] = volDum;
1399 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
1400 volDum = vol2[3];
1401 vol2[3] = vol2[4];
1402 vol2[4] = volDum;
1403 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
1404 volDum = vol3[3];
1405 vol3[3] = vol3[4];
1406 vol3[4] = volDum;
1407 fTOFdigitMap->ResetDigitNumber(vol3,selectedDigit[adesso3][thirdIndex]->GetIndex());
1408
1409
1410 } // close loop on third digit
1411 } // close loop on adesso3
1412
1413 } // close loop on second digit
1414 } // close loop on adesso2
1415
1416 } // close loop on first digit
1417 } // close loop on adesso1
1418
1419 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1420 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1421 selectedDigit[ii][jj] = 0x0;
1422
1423 } // loop on iPad
1424
ed1f8475 1425 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++) {
e3bd5504 1426 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
ed1f8475 1427 delete [] selectedDigit[ii][jj];
e3bd5504 1428 selectedDigit[ii][jj] = 0x0;
1429 }
ed1f8475 1430 delete [] selectedDigit[ii];
1431 selectedDigit[ii] = 0x0;
1432 }
b5ed6afb 1433 delete [] selectedDigit;
ed1f8475 1434 selectedDigit = 0x0;
e3bd5504 1435
1436}
1437//_____________________________________________________________________________
1438
1439void AliTOFClusterFinderV1::FindClusters23(Int_t nSector,
1440 Int_t nPlate,
1441 Int_t nStrip)
1442{
1443 //
1444 // This function searches the neighbouring digits (stored in the fDigits object),
1445 // to perform clusters (stored in the fTofClusters array).
1446 //
1447 // This research has been made by checking the fTOFdigitMap object,
1448 // filled at digits/raw-data reading time.
1449 //
1450
1451 const Int_t kMaxNumberOfInterestingPads = 4;
1452 const Int_t kMaxNumberOfTracksPerDigit = 3;
cc7a1acd 1453 const Int_t kMaxNumberOfDigitsPerVolume = 10;
e3bd5504 1454
1455 Int_t ii = 0;
1456
1457 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
1458 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1459 digitsInVolumeIndices[ii] = -1;
1460
e3bd5504 1461 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
1462
1463 Float_t pos[3] = {0.,0.,0.};
1464
1465 Int_t jj = 0;
1466 Int_t interestingPadX[kMaxNumberOfInterestingPads];
1467 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
1468 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
1469 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
1470 Double_t interestingTOT[kMaxNumberOfInterestingPads];
1471 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
1472 Double_t interestingADC[kMaxNumberOfInterestingPads];
1473 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
1474 Double_t interestingTOF[kMaxNumberOfInterestingPads];
1475 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
1476 Double_t interestingWeight[kMaxNumberOfInterestingPads];
1477 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
1478
1479 Float_t interestingX[kMaxNumberOfInterestingPads];
1480 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
1481 Float_t interestingY[kMaxNumberOfInterestingPads];
1482 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
1483 Float_t interestingZ[kMaxNumberOfInterestingPads];
1484 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
1485
1486 Float_t interDigit[kMaxNumberOfInterestingPads];
1487 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
1488
1489 Int_t padsCluster[11];
1490 padsCluster[0] = nSector;
1491 padsCluster[1] = nPlate;
1492 padsCluster[2] = nStrip;
1493 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1494
1495 Int_t interestingCounter=-1;
e885fb81 1496 Int_t digitIndexLocal = -1;
e3bd5504 1497 Int_t iPad = -1;
1498 Int_t iPadX = -1;
1499 Int_t iPadZ = -1;
1500
1501 Bool_t check = kFALSE;
1502 Int_t parTOF[5];
1503 for (jj=0; jj<5; jj++) parTOF[jj] = 0;
1504 Double_t posClus[3];
1505 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
1506 Int_t det[5];
1507 for (jj=0; jj<5; jj++) det[jj] = -1;
1508 Float_t posF[3];
1509 for (jj=0; jj<3; jj++) posF[jj] = 0.;
1510 UShort_t volIdClus = 0;
1511 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
1512 Double_t covClus[6];
1513 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1514 Int_t tracks[kMaxNumberOfTracksPerDigit];
ed1f8475 1515 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
e3bd5504 1516 Int_t dummyCounter=-1;
1517 Bool_t alreadyStored = kFALSE;
1518
1519 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
1520 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1521 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
1522
1523 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1524 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
1525
1526 AliTOFdigit *digitInteresting;
1527
1528 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
1529
1530 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
1531 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
1532
e885fb81 1533 AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
e3bd5504 1534
1535
1536
1537
1538
1539
1540 interestingCounter=-1;
1541
1542 vol[4] = iPadZ , vol[3] = iPadX;
1543 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1544 interestingCounter++;
1545
1546 vol[4] = iPadZ, vol[3] = iPadX+1;
1547 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1548 interestingCounter++;
1549
1550 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1551 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1552 interestingCounter++;
1553
1554 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1555 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1556 interestingCounter++;
1557
1558 if (interestingCounter+1!=3) continue; // the hit pads have to be 3
1559 else interestingCounter=-1;
1560
1561
1562 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1563 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1564 selectedDigit[ii][jj] = 0x0;
1565
1566
1567 vol[4] = iPadZ, vol[3] = iPadX;
1568
1569 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1570 interestingCounter++;
1571 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1572 digitsInVolumeIndices[ii] = -1;
1573 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
e885fb81 1574 digitIndexLocal=-1;
e3bd5504 1575 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1576 if (digitsInVolumeIndices[digIndex]<0) continue;
1577 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
e885fb81 1578 if (digitInteresting->GetToT()<=0) continue; // AdC
1579 digitIndexLocal++; // AdC
e3bd5504 1580
4682c56e 1581 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
e3bd5504 1582 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1583 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1584 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1585 digitsInVolumeIndices[digIndex],
1586 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1587
e885fb81 1588 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
e3bd5504 1589 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1590 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1591 digitInteresting->GetToT()*digitInteresting->GetToT(),
1592 digitsInVolumeIndices[digIndex],
1593 digitInteresting->GetTracks());
1594 }
e885fb81 1595 if (digitIndexLocal==-1) interestingCounter--; // AdC
e3bd5504 1596 }
1597
1598
1599 vol[4] = iPadZ, vol[3] = iPadX+1;
1600
1601 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1602 interestingCounter++;
1603 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1604 digitsInVolumeIndices[ii] = -1;
1605 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
e885fb81 1606 digitIndexLocal=-1; // AdC
e3bd5504 1607 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1608 if (digitsInVolumeIndices[digIndex]<0) continue;
1609 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
e885fb81 1610 if (digitInteresting->GetToT()<=0) continue; // AdC
1611 digitIndexLocal++; // AdC
e3bd5504 1612
4682c56e 1613 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
e3bd5504 1614 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1615 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1616 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1617 digitsInVolumeIndices[digIndex],
1618 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1619
e885fb81 1620 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
e3bd5504 1621 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1622 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1623 digitInteresting->GetToT()*digitInteresting->GetToT(),
1624 digitsInVolumeIndices[digIndex],
1625 digitInteresting->GetTracks());
1626 }
e885fb81 1627 if (digitIndexLocal==-1) interestingCounter--; // AdC
e3bd5504 1628 }
1629
1630
1631 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1632
1633 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1634 interestingCounter++;
1635 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1636 digitsInVolumeIndices[ii] = -1;
1637 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
e885fb81 1638 digitIndexLocal=-1; // AdC
e3bd5504 1639 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1640 if (digitsInVolumeIndices[digIndex]<0) continue;
1641 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
e885fb81 1642 if (digitInteresting->GetToT()<=0) continue; // AdC
1643 digitIndexLocal++; // AdC
e3bd5504 1644
4682c56e 1645 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
e3bd5504 1646 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1647 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1648 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1649 digitsInVolumeIndices[digIndex],
1650 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1651
e885fb81 1652 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
e3bd5504 1653 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1654 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1655 digitInteresting->GetToT()*digitInteresting->GetToT(),
1656 digitsInVolumeIndices[digIndex],
1657 digitInteresting->GetTracks());
1658 }
e885fb81 1659 if (digitIndexLocal==-1) interestingCounter--; // AdC
e3bd5504 1660 }
1661
1662
1663 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1664
1665 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1666 interestingCounter++;
1667 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1668 digitsInVolumeIndices[ii] = -1;
1669 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
e885fb81 1670 digitIndexLocal=-1; // AdC
e3bd5504 1671 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1672 if (digitsInVolumeIndices[digIndex]<0) continue;
1673 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
e885fb81 1674 if (digitInteresting->GetToT()<=0) continue; // AdC
1675 digitIndexLocal++; // AdC
e3bd5504 1676
4682c56e 1677 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
e3bd5504 1678 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1679 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1680 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1681 digitsInVolumeIndices[digIndex],
1682 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1683
e885fb81 1684 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
e3bd5504 1685 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1686 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1687 digitInteresting->GetToT()*digitInteresting->GetToT(),
1688 digitsInVolumeIndices[digIndex],
1689 digitInteresting->GetTracks());
1690 }
e885fb81 1691 if (digitIndexLocal==-1) interestingCounter--; // AdC
e3bd5504 1692 }
1693
e885fb81 1694 AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
e3bd5504 1695
1696 for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
1697 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
1698 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
1699
1700 for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
1701 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
1702 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
1703
1704 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime) continue;
1705
1706 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
1707 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
1708 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
1709 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
1710 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
e885fb81 1711 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
e3bd5504 1712 Int_t volDum = vol1[3];
1713 vol1[3] = vol1[4];
1714 vol1[4] = volDum;
e885fb81 1715 fTOFGeometry->GetPosPar(vol1,pos);
e3bd5504 1716 interestingX[0] = pos[0];
1717 interestingY[0] = pos[1];
1718 interestingZ[0] = pos[2];
1719
1720 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
1721 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
1722 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
1723 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
1724 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
e885fb81 1725 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
e3bd5504 1726 volDum = vol2[3];
1727 vol2[3] = vol2[4];
1728 vol2[4] = volDum;
e885fb81 1729 fTOFGeometry->GetPosPar(vol2,pos);
e3bd5504 1730 interestingX[1] = pos[0];
1731 interestingY[1] = pos[1];
1732 interestingZ[1] = pos[2];
1733
1734 AverageCalculations(2, interestingX, interestingY, interestingZ,
1735 interestingTOF, interestingTOT, interestingADC,
1736 interestingWeight,
1737 parTOF, posClus, check);
1738
1739 for (jj=0; jj<5; jj++) det[jj] = -1;
1740 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
e885fb81 1741 fTOFGeometry->GetDetID(posF, det);
e3bd5504 1742
e885fb81 1743 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
1744 //volIdClus = GetClusterVolIndex(det);
e3bd5504 1745
1746 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1747 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
1748 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
1749 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
1750 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
1751
1752 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1753 Int_t ** indDet = new Int_t*[2];
1754 for (jj=0; jj<2; jj++) indDet[jj] = new Int_t [5];
1755 for (jj=0; jj<2; jj++) indDet[jj][0] = nSector;
1756 for (jj=0; jj<2; jj++) indDet[jj][1] = nPlate;
1757 for (jj=0; jj<2; jj++) indDet[jj][2] = nStrip;
1758 for (jj=0; jj<2; jj++) indDet[jj][3] = padsCluster[2*jj+3];
1759 for (jj=0; jj<2; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
e885fb81 1760 GetClusterPars(/*check,*/ 2, indDet, interestingWeight, posClus, covClus);
e3bd5504 1761 for (jj=0; jj<2; jj++) delete [] indDet[jj];
1762
1763 // To fill the track index array
1764 dummyCounter=-1;
1765 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1766 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1767 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
1768 else {
1769 dummyCounter++;
1770 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
1771 }
1772 }
1773 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1774 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
1775 else {
1776
1777 alreadyStored = kFALSE;
1778 for (jj=0; jj<dummyCounter+1; jj++)
1779 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
1780
1781 if (alreadyStored) continue;
1782 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
1783 AliWarning(" Siamo al limite!");
1784 continue;
1785 }
1786
1787 dummyCounter++;
1788 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
1789
1790 }
1791
1792 }
1793
1794
1795 AliTOFcluster *tofCluster =
1796 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
1797 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1798 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
1799 InsertCluster(tofCluster);
1800
e885fb81 1801 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",
e3bd5504 1802 volIdClus, posClus[0], posClus[1], posClus[2],
1803 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1804 tracks[0], tracks[1], tracks[2],
1805 det[0], det[1], det[2], det[3], det[4],
1806 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
1807 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
1808
1809 volDum = vol1[3];
1810 vol1[3] = vol1[4];
1811 vol1[4] = volDum;
1812 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
1813 volDum = vol2[3];
1814 vol2[3] = vol2[4];
1815 vol2[4] = volDum;
1816 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
1817
1818
1819 } // close loop on second digit
1820 } // close loop on adesso2
1821
1822 } // close loop on first digit
1823 } // close loop on adesso1
1824
1825 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1826 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1827 selectedDigit[ii][jj] = 0x0;
1828
1829 } // loop on iPad
1830
ed1f8475 1831 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++) {
e3bd5504 1832 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
ed1f8475 1833 delete [] selectedDigit[ii][jj];
e3bd5504 1834 selectedDigit[ii][jj] = 0x0;
1835 }
ed1f8475 1836 delete [] selectedDigit[ii];
1837 selectedDigit[ii] = 0x0;
1838 }
b5ed6afb 1839 delete [] selectedDigit;
ed1f8475 1840 selectedDigit = 0x0;
e3bd5504 1841
1842}
1843//_____________________________________________________________________________
1844
1845void AliTOFClusterFinderV1::FindClusters24(Int_t nSector,
1846 Int_t nPlate,
1847 Int_t nStrip)
1848{
1849 //
1850 // This function searches the neighbouring digits (stored in the fDigits object),
1851 // to perform clusters (stored in the fTofClusters array).
1852 //
1853 // This research has been made by checking the fTOFdigitMap object,
1854 // filled at digits/raw-data reading time.
1855 //
1856
1857 const Int_t kMaxNumberOfInterestingPads = 4;
1858 const Int_t kMaxNumberOfTracksPerDigit = 3;
cc7a1acd 1859 const Int_t kMaxNumberOfDigitsPerVolume = 10;
e3bd5504 1860
1861 Int_t ii = 0;
1862
1863 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
1864 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1865 digitsInVolumeIndices[ii] = -1;
1866
e3bd5504 1867 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
1868
1869 Float_t pos[3] = {0.,0.,0.};
1870
1871 Int_t jj = 0;
1872 Int_t interestingPadX[kMaxNumberOfInterestingPads];
1873 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
1874 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
1875 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
1876 Double_t interestingTOT[kMaxNumberOfInterestingPads];
1877 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
1878 Double_t interestingADC[kMaxNumberOfInterestingPads];
1879 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
1880 Double_t interestingTOF[kMaxNumberOfInterestingPads];
1881 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
1882 Double_t interestingWeight[kMaxNumberOfInterestingPads];
1883 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
1884
1885 Float_t interestingX[kMaxNumberOfInterestingPads];
1886 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
1887 Float_t interestingY[kMaxNumberOfInterestingPads];
1888 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
1889 Float_t interestingZ[kMaxNumberOfInterestingPads];
1890 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
1891
1892 Float_t interDigit[kMaxNumberOfInterestingPads];
1893 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
1894
1895 Int_t padsCluster[11];
1896 padsCluster[0] = nSector;
1897 padsCluster[1] = nPlate;
1898 padsCluster[2] = nStrip;
1899 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1900
1901 Int_t interestingCounter=-1;
e885fb81 1902 Int_t digitIndexLocal = -1;
e3bd5504 1903 Int_t iPad = -1;
1904 Int_t iPadX = -1;
1905 Int_t iPadZ = -1;
1906
1907 Bool_t check = kFALSE;
1908 Int_t parTOF[5];
1909 for (jj=0; jj<5; jj++) parTOF[jj] = 0;
1910 Double_t posClus[3];
1911 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
1912 Int_t det[5];
1913 for (jj=0; jj<5; jj++) det[jj] = -1;
1914 Float_t posF[3];
1915 for (jj=0; jj<3; jj++) posF[jj] = 0.;
1916 UShort_t volIdClus = 0;
1917 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
1918 Double_t covClus[6];
1919 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1920 Int_t tracks[kMaxNumberOfTracksPerDigit];
ed1f8475 1921 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
e3bd5504 1922 Int_t dummyCounter=-1;
1923 Bool_t alreadyStored = kFALSE;
1924
1925 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
1926 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1927 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
1928
1929 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1930 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
1931
1932 AliTOFdigit *digitInteresting;
1933
1934 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
1935
1936 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
1937 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
1938
e885fb81 1939 AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
e3bd5504 1940
1941
1942
1943
1944
1945
1946 interestingCounter=-1;
1947
1948 vol[4] = iPadZ , vol[3] = iPadX;
1949 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1950 interestingCounter++;
1951
1952 vol[4] = iPadZ, vol[3] = iPadX+1;
1953 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1954 interestingCounter++;
1955
1956 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1957 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1958 interestingCounter++;
1959
1960 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1961 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1962 interestingCounter++;
1963
1964 if (interestingCounter+1!=4) continue; // the hit pads have to be 4
1965 else interestingCounter=-1;
1966
1967
1968 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1969 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1970 selectedDigit[ii][jj] = 0x0;
1971
1972
1973 vol[4] = iPadZ, vol[3] = iPadX;
1974
1975 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1976 interestingCounter++;
1977 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1978 digitsInVolumeIndices[ii] = -1;
1979 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
e885fb81 1980 digitIndexLocal=-1; // AdC
e3bd5504 1981 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1982 if (digitsInVolumeIndices[digIndex]<0) continue;
1983 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
e885fb81 1984 if (digitInteresting->GetToT()<=0) continue; // AdC
1985 digitIndexLocal++; // AdC
e3bd5504 1986
4682c56e 1987 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
e3bd5504 1988 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1989 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1990 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1991 digitsInVolumeIndices[digIndex],
1992 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1993
e885fb81 1994 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
e3bd5504 1995 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1996 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1997 digitInteresting->GetToT()*digitInteresting->GetToT(),
1998 digitsInVolumeIndices[digIndex],
1999 digitInteresting->GetTracks());
2000 }
e885fb81 2001 if (digitIndexLocal==-1) interestingCounter--; // AdC
e3bd5504 2002 }
2003
2004
2005 vol[4] = iPadZ, vol[3] = iPadX+1;
2006
2007 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2008 interestingCounter++;
2009 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2010 digitsInVolumeIndices[ii] = -1;
2011 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
e885fb81 2012 digitIndexLocal=-1; // AdC
e3bd5504 2013 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2014 if (digitsInVolumeIndices[digIndex]<0) continue;
2015 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
e885fb81 2016 if (digitInteresting->GetToT()<=0) continue; // AdC
2017 digitIndexLocal++; // AdC
e3bd5504 2018
4682c56e 2019 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
e3bd5504 2020 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2021 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2022 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2023 digitsInVolumeIndices[digIndex],
2024 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2025
e885fb81 2026 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
e3bd5504 2027 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2028 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2029 digitInteresting->GetToT()*digitInteresting->GetToT(),
2030 digitsInVolumeIndices[digIndex],
2031 digitInteresting->GetTracks());
2032 }
e885fb81 2033 if (digitIndexLocal==-1) interestingCounter--; // AdC
e3bd5504 2034 }
2035
2036
2037 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
2038
2039 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2040 interestingCounter++;
2041 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2042 digitsInVolumeIndices[ii] = -1;
2043 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
e885fb81 2044 digitIndexLocal=-1; // AdC
e3bd5504 2045 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2046 if (digitsInVolumeIndices[digIndex]<0) continue;
2047 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
e885fb81 2048 if (digitInteresting->GetToT()<=0) continue; // AdC
2049 digitIndexLocal++; // AdC
e3bd5504 2050
4682c56e 2051 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
e3bd5504 2052 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2053 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2054 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2055 digitsInVolumeIndices[digIndex],
2056 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2057
e885fb81 2058 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
e3bd5504 2059 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2060 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2061 digitInteresting->GetToT()*digitInteresting->GetToT(),
2062 digitsInVolumeIndices[digIndex],
2063 digitInteresting->GetTracks());
2064 }
e885fb81 2065 if (digitIndexLocal==-1) interestingCounter--; // AdC
e3bd5504 2066 }
2067
2068
2069 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
2070
2071 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2072 interestingCounter++;
2073 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2074 digitsInVolumeIndices[ii] = -1;
2075 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
e885fb81 2076 digitIndexLocal=-1; // AdC
e3bd5504 2077 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2078 if (digitsInVolumeIndices[digIndex]<0) continue;
2079 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
e885fb81 2080 if (digitInteresting->GetToT()<=0) continue; // AdC
2081 digitIndexLocal++; // AdC
e3bd5504 2082
4682c56e 2083 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
e3bd5504 2084 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2085 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2086 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2087 digitsInVolumeIndices[digIndex],
2088 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2089
e885fb81 2090 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
e3bd5504 2091 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2092 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2093 digitInteresting->GetToT()*digitInteresting->GetToT(),
2094 digitsInVolumeIndices[digIndex],
2095 digitInteresting->GetTracks());
2096 }
e885fb81 2097 if (digitIndexLocal==-1) interestingCounter--; // AdC
e3bd5504 2098 }
2099
e885fb81 2100 AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
e3bd5504 2101
2102 for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
2103 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2104 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2105
2106 for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
2107 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2108 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2109
2110 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime) continue;
2111
2112 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2113 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2114 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2115 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2116 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
e885fb81 2117 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
e3bd5504 2118 Int_t volDum = vol1[3];
2119 vol1[3] = vol1[4];
2120 vol1[4] = volDum;
e885fb81 2121 fTOFGeometry->GetPosPar(vol1,pos);
e3bd5504 2122 interestingX[0] = pos[0];
2123 interestingY[0] = pos[1];
2124 interestingZ[0] = pos[2];
2125
2126 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2127 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2128 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2129 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2130 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
e885fb81 2131 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
e3bd5504 2132 volDum = vol2[3];
2133 vol2[3] = vol2[4];
2134 vol2[4] = volDum;
e885fb81 2135 fTOFGeometry->GetPosPar(vol2,pos);
e3bd5504 2136 interestingX[1] = pos[0];
2137 interestingY[1] = pos[1];
2138 interestingZ[1] = pos[2];
2139
2140
2141 AverageCalculations(2, interestingX, interestingY, interestingZ,
2142 interestingTOF, interestingTOT, interestingADC,
2143 interestingWeight,
2144 parTOF, posClus, check);
2145
2146 for (jj=0; jj<5; jj++) det[jj] = -1;
2147 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
e885fb81 2148 fTOFGeometry->GetDetID(posF, det);
e3bd5504 2149
e885fb81 2150 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
2151 //volIdClus = GetClusterVolIndex(det);
e3bd5504 2152
2153 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2154 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
2155 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
2156 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
2157 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
2158
2159 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2160 Int_t ** indDet = new Int_t*[2];
2161 for (jj=0; jj<2; jj++) indDet[jj] = new Int_t [5];
2162 for (jj=0; jj<2; jj++) indDet[jj][0] = nSector;
2163 for (jj=0; jj<2; jj++) indDet[jj][1] = nPlate;
2164 for (jj=0; jj<2; jj++) indDet[jj][2] = nStrip;
2165 for (jj=0; jj<2; jj++) indDet[jj][3] = padsCluster[2*jj+3];
2166 for (jj=0; jj<2; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
e885fb81 2167 GetClusterPars(/*check,*/ 2, indDet, interestingWeight, posClus, covClus);
e3bd5504 2168 for (jj=0; jj<2; jj++) delete [] indDet[jj];
2169
2170 // To fill the track index array
2171 dummyCounter=-1;
2172 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2173 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2174 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
2175 else {
2176 dummyCounter++;
2177 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
2178 }
2179 }
2180 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2181 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
2182 else {
2183
2184 alreadyStored = kFALSE;
2185 for (jj=0; jj<dummyCounter+1; jj++)
2186 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
2187
2188 if (alreadyStored) continue;
2189 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2190 AliWarning(" Siamo al limite!");
2191 continue;
2192 }
2193
2194 dummyCounter++;
2195 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
2196
2197 }
2198
2199 }
2200
2201
2202 AliTOFcluster *tofCluster =
2203 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
2204 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2205 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
2206 InsertCluster(tofCluster);
2207
e885fb81 2208 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",
e3bd5504 2209 volIdClus, posClus[0], posClus[1], posClus[2],
2210 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2211 tracks[0], tracks[1], tracks[2],
2212 det[0], det[1], det[2], det[3], det[4],
2213 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
2214 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
2215
2216 volDum = vol1[3];
2217 vol1[3] = vol1[4];
2218 vol1[4] = volDum;
2219 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
2220 volDum = vol2[3];
2221 vol2[3] = vol2[4];
2222 vol2[4] = volDum;
2223 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
2224
2225
2226 } // close loop on second digit
2227 } // close loop on adesso2
2228
2229 } // close loop on first digit
2230 } // close loop on adesso1
2231
2232 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2233 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
2234 selectedDigit[ii][jj] = 0x0;
2235
2236 } // loop on iPad
2237
ed1f8475 2238 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++) {
e3bd5504 2239 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
ed1f8475 2240 delete [] selectedDigit[ii][jj];
e3bd5504 2241 selectedDigit[ii][jj] = 0x0;
2242 }
ed1f8475 2243 delete [] selectedDigit[ii];
2244 selectedDigit[ii] = 0x0;
2245 }
b5ed6afb 2246 delete [] selectedDigit;
ed1f8475 2247 selectedDigit = 0x0;
e3bd5504 2248
2249}
2250//_____________________________________________________________________________
2251
2252void AliTOFClusterFinderV1::FindClustersPerStrip(Int_t nSector,
2253 Int_t nPlate,
2254 Int_t nStrip,
2255 Int_t group)
2256{
2257 //
2258 // This function searches the neighbouring digits (stored in the fDigits object),
2259 // to perform clusters (stored in the fTofClusters array).
2260 //
2261 // Each strip is read four times:
2262 // - 1st time: it searches possible clusters formed by four
2263 // neighbouring digits;
2264 // - 2nd time: it searches possible clusters formed by three
2265 // neighbouring digits;
2266 // - 3rd time: it searches possible clusters formed by two
2267 // neighbouring digits;
2268 // - 4th time: the remaining isolated digits have been transformed
2269 // in clusters.
2270 // This research has been made by checking the fTOFdigitMap object,
2271 // filled at digits/raw-data reading time.
2272 //
2273
2274 const Int_t kMaxNumberOfInterestingPads = 4;
2275 const Int_t kMaxNumberOfTracksPerDigit = 3;
cc7a1acd 2276 const Int_t kMaxNumberOfDigitsPerVolume = 10;
e3bd5504 2277
2278 Int_t ii = 0;
2279
2280 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
2281 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2282 digitsInVolumeIndices[ii] = -1;
2283
e3bd5504 2284 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
2285
2286 Float_t pos[3] = {0.,0.,0.};
2287
2288 Int_t jj = 0;
2289 Int_t interestingPadX[kMaxNumberOfInterestingPads];
2290 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
2291 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
2292 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
2293 Double_t interestingTOT[kMaxNumberOfInterestingPads];
2294 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
2295 Double_t interestingADC[kMaxNumberOfInterestingPads];
2296 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
2297 Double_t interestingTOF[kMaxNumberOfInterestingPads];
2298 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
2299 Double_t interestingWeight[kMaxNumberOfInterestingPads];
2300 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
2301
2302 Float_t interestingX[kMaxNumberOfInterestingPads];
2303 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
2304 Float_t interestingY[kMaxNumberOfInterestingPads];
2305 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
2306 Float_t interestingZ[kMaxNumberOfInterestingPads];
2307 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
2308
2309 Float_t interDigit[kMaxNumberOfInterestingPads];
2310 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
2311
2312 Int_t padsCluster[11];
2313 padsCluster[0] = nSector;
2314 padsCluster[1] = nPlate;
2315 padsCluster[2] = nStrip;
2316 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2317
2318 Int_t interestingCounter=-1;
e885fb81 2319 Int_t digitIndexLocal = -1;
e3bd5504 2320 Int_t iPad = -1;
2321 Int_t iPadX = -1;
2322 Int_t iPadZ = -1;
2323
2324 Bool_t check = kFALSE;
2325 Int_t parTOF[5];
2326 for (jj=0; jj<5; jj++) parTOF[jj] = 0;
2327 Double_t posClus[3];
2328 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
2329 Int_t det[5];
2330 for (jj=0; jj<5; jj++) det[jj] = -1;
2331 Float_t posF[3];
2332 for (jj=0; jj<3; jj++) posF[jj] = 0.;
2333 UShort_t volIdClus = 0;
2334 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
2335 Double_t covClus[6];
2336 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2337 Int_t tracks[kMaxNumberOfTracksPerDigit];
ed1f8475 2338 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
e3bd5504 2339 Int_t dummyCounter=-1;
2340 Bool_t alreadyStored = kFALSE;
2341
2342 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
2343 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2344 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
2345
2346 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2347 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
2348
2349 AliTOFdigit *digitInteresting;
2350
2351 group = group-1;
2352
2353 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
2354
2355 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
2356 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
2357
e885fb81 2358 AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
e3bd5504 2359
2360
2361
2362
2363
2364
2365 interestingCounter=-1;
2366
2367 vol[4] = iPadZ , vol[3] = iPadX;
2368 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2369 interestingCounter++;
2370
2371 vol[4] = iPadZ, vol[3] = iPadX+1;
2372 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2373 interestingCounter++;
2374
2375 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
2376 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2377 interestingCounter++;
2378
2379 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
2380 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2381 interestingCounter++;
2382
2383 if (interestingCounter!=group) continue;
2384 else interestingCounter=-1;
2385
2386
2387 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2388 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
2389 selectedDigit[ii][jj] = 0x0;
2390
2391
2392 vol[4] = iPadZ, vol[3] = iPadX;
2393
2394 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2395 interestingCounter++;
2396 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2397 digitsInVolumeIndices[ii] = -1;
2398 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
e885fb81 2399 digitIndexLocal=-1; // AdC
e3bd5504 2400 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2401 if (digitsInVolumeIndices[digIndex]<0) continue;
2402 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
e885fb81 2403 if (digitInteresting->GetToT()<=0) continue; // AdC
2404 digitIndexLocal++; // AdC
e3bd5504 2405
e885fb81 2406 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
e3bd5504 2407 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2408 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2409 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2410 digitsInVolumeIndices[digIndex],
2411 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
e885fb81 2412 AliDebug(1,Form(" to try %d %d ",digIndex, interestingCounter));
e3bd5504 2413
e885fb81 2414 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
e3bd5504 2415 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2416 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2417 digitInteresting->GetToT()*digitInteresting->GetToT(),
2418 digitsInVolumeIndices[digIndex],
2419 digitInteresting->GetTracks());
2420 }
e885fb81 2421 if (digitIndexLocal==-1) interestingCounter--; // AdC
e3bd5504 2422 }
2423
2424
2425 vol[4] = iPadZ, vol[3] = iPadX+1;
2426
2427 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2428 interestingCounter++;
2429 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2430 digitsInVolumeIndices[ii] = -1;
2431 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
e885fb81 2432 digitIndexLocal=-1; // AdC
e3bd5504 2433 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2434 if (digitsInVolumeIndices[digIndex]<0) continue;
2435 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
e885fb81 2436 if (digitInteresting->GetToT()<=0) continue; // AdC
2437 digitIndexLocal++; // AdC
e3bd5504 2438
e885fb81 2439 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
e3bd5504 2440 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2441 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2442 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2443 digitsInVolumeIndices[digIndex],
2444 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
e885fb81 2445 AliDebug(1,Form(" to try %d %d ",digIndex, interestingCounter));
e3bd5504 2446
e885fb81 2447 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
e3bd5504 2448 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2449 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2450 digitInteresting->GetToT()*digitInteresting->GetToT(),
2451 digitsInVolumeIndices[digIndex],
2452 digitInteresting->GetTracks());
2453 }
e885fb81 2454 if (digitIndexLocal==-1) interestingCounter--; // AdC
e3bd5504 2455 }
2456
2457
2458 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
2459
2460 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2461 interestingCounter++;
2462 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2463 digitsInVolumeIndices[ii] = -1;
2464 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
e885fb81 2465 digitIndexLocal=-1; // AdC
e3bd5504 2466 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2467 if (digitsInVolumeIndices[digIndex]<0) continue;
2468 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
e885fb81 2469 if (digitInteresting->GetToT()<=0) continue; // AdC
2470 digitIndexLocal++; // AdC
e3bd5504 2471
e885fb81 2472 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
e3bd5504 2473 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2474 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2475 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2476 digitsInVolumeIndices[digIndex],
2477 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
e885fb81 2478 AliDebug(1,Form(" to try %d %d ",digIndex, interestingCounter));
e3bd5504 2479
e885fb81 2480 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
e3bd5504 2481 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2482 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2483 digitInteresting->GetToT()*digitInteresting->GetToT(),
2484 digitsInVolumeIndices[digIndex],
2485 digitInteresting->GetTracks());
2486 }
e885fb81 2487 if (digitIndexLocal==-1) interestingCounter--; // AdC
e3bd5504 2488 }
2489
2490
2491 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
2492
2493 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2494 interestingCounter++;
2495 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2496 digitsInVolumeIndices[ii] = -1;
2497 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
e885fb81 2498 digitIndexLocal=-1; // AdC
e3bd5504 2499 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2500 if (digitsInVolumeIndices[digIndex]<0) continue;
2501 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
e885fb81 2502 if (digitInteresting->GetToT()<=0) continue; // AdC
2503 digitIndexLocal++; // AdC
e3bd5504 2504
e885fb81 2505 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
e3bd5504 2506 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2507 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2508 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2509 digitsInVolumeIndices[digIndex],
2510 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
e885fb81 2511 AliDebug(1,Form(" to try %d %d ",digIndex, interestingCounter));
e3bd5504 2512
e885fb81 2513 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
e3bd5504 2514 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2515 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2516 digitInteresting->GetToT()*digitInteresting->GetToT(),
2517 digitsInVolumeIndices[digIndex],
2518 digitInteresting->GetTracks());
2519 }
e885fb81 2520 if (digitIndexLocal==-1) interestingCounter--; // AdC
e3bd5504 2521 }
2522
e885fb81 2523 AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
e3bd5504 2524
d7ed6a6d 2525 Int_t adesso1 = -1;
2526 Int_t adesso2 = -1;
2527 Int_t adesso3 = -1;
2528 Int_t adesso4 = -1;
2529
e3bd5504 2530 switch(interestingCounter+1) {
2531
2532 case 2:
2533
d7ed6a6d 2534 //for (adesso1=0; adesso1<interestingCounter+1; adesso1++) {
2535 adesso1 = 0;
e3bd5504 2536 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2537 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2538
d7ed6a6d 2539 //for (adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
2540 adesso2 = 1;
e3bd5504 2541 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2542 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2543
d7ed6a6d 2544 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime) {
2545 AliDebug(1,Form(" selD1[%d][%d]->GetTDC()=%d selD2[%d][%d]->GetTDC()=%d -- %d ",
ed1f8475 2546 adesso1,firstIndex,(Int_t)selectedDigit[adesso1][firstIndex]->GetTDC(),
2547 adesso2,secondIndex,(Int_t)selectedDigit[adesso2][secondIndex]->GetTDC(),
d7ed6a6d 2548 fMaxDeltaTime));
2549 continue;
2550 }
e3bd5504 2551
4682c56e 2552 AliDebug(1, Form(" %1d %1d (0x%p) %1d %1d (0x%p)", adesso1, firstIndex,selectedDigit[adesso1][firstIndex],
e3bd5504 2553 adesso2, secondIndex,selectedDigit[adesso2][secondIndex]));
2554
2555 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2556 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2557 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2558 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2559 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
e885fb81 2560 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
e3bd5504 2561 Int_t volDum = vol1[3];
2562 vol1[3] = vol1[4];
2563 vol1[4] = volDum;
e885fb81 2564 fTOFGeometry->GetPosPar(vol1,pos);
e3bd5504 2565 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
2566 interestingX[0] = pos[0];
2567 interestingY[0] = pos[1];
2568 interestingZ[0] = pos[2];
2569
2570 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2571 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2572 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2573 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2574 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
e885fb81 2575 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
e3bd5504 2576 volDum = vol2[3];
2577 vol2[3] = vol2[4];
2578 vol2[4] = volDum;
e885fb81 2579 fTOFGeometry->GetPosPar(vol2,pos);
e3bd5504 2580 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
2581 interestingX[1] = pos[0];
2582 interestingY[1] = pos[1];
2583 interestingZ[1] = pos[2];
2584
2585
2586 AverageCalculations(interestingCounter+1,
2587 interestingX, interestingY, interestingZ,
2588 interestingTOF, interestingTOT, interestingADC,
2589 interestingWeight,
2590 parTOF, posClus, check);
2591
2592 for (jj=0; jj<5; jj++) det[jj] = -1;
2593 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
2594
2595 AliDebug(1,Form(" %f %f %f", posF[0], posF[1], posF[2]));
e885fb81 2596 fTOFGeometry->GetDetID(posF, det);
2597 AliDebug(1,Form(" %2d %1d %2d %1d %2d", det[0], det[1], det[2], det[3], det[4]));
e3bd5504 2598
e885fb81 2599 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
2600 //volIdClus = GetClusterVolIndex(det);
e3bd5504 2601
2602 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2603 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
2604 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
2605 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
2606 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
2607
2608 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2609 Int_t ** indDet = new Int_t*[interestingCounter+1];
2610 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj] = new Int_t [5];
2611 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][0] = nSector;
2612 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][1] = nPlate;
2613 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][2] = nStrip;
2614 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][3] = padsCluster[2*jj+3];
2615 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
e885fb81 2616 GetClusterPars(/*check,*/ interestingCounter+1, indDet, interestingWeight, posClus, covClus);
e3bd5504 2617 for (jj=0; jj<interestingCounter+1; jj++) delete [] indDet[jj];
2618
2619 // To fill the track index array
2620 dummyCounter=-1;
2621 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2622 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2623 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
2624 else {
2625 dummyCounter++;
2626 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
2627 }
2628 }
2629 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2630 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
2631 else {
2632
2633 alreadyStored = kFALSE;
2634 for (jj=0; jj<dummyCounter+1; jj++)
2635 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
2636
2637 if (alreadyStored) continue;
2638 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2639 AliWarning(" Siamo al limite!");
2640 continue;
2641 }
2642
2643 dummyCounter++;
2644 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
2645
2646 }
2647
2648 }
2649
2650
2651 AliTOFcluster *tofCluster =
2652 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
2653 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2654 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); //to updated
2655 InsertCluster(tofCluster);
2656
e885fb81 2657 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",
e3bd5504 2658 volIdClus, posClus[0], posClus[1], posClus[2],
2659 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2660 tracks[0], tracks[1], tracks[2],
2661 det[0], det[1], det[2], det[3], det[4],
2662 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
2663 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
2664
2665 volDum = vol1[3];
2666 vol1[3] = vol1[4];
2667 vol1[4] = volDum;
2668 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
2669 volDum = vol2[3];
2670 vol2[3] = vol2[4];
2671 vol2[4] = volDum;
2672 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
2673
2674
2675 } // close loop on second digit
d7ed6a6d 2676 //} // close loop on adesso2
e3bd5504 2677
2678 } // close loop on first digit
d7ed6a6d 2679 //} // close loop on adesso1
e3bd5504 2680
2681
2682 break;
2683
2684 case 3:
2685
d7ed6a6d 2686 //for (adesso1=0; adesso1<interestingCounter+1; adesso1++) {
2687 adesso1 = 0;
e3bd5504 2688 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2689 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2690
d7ed6a6d 2691 //for (adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
2692 adesso2 = 1;
e3bd5504 2693 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2694 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2695
d7ed6a6d 2696 //for (adesso3=adesso2+1; adesso3<interestingCounter+1; adesso3++) {
2697 adesso3 = 2;
e3bd5504 2698 for (Int_t thirdIndex=0; thirdIndex<kMaxNumberOfDigitsPerVolume; thirdIndex++) {
2699 if (selectedDigit[adesso3][thirdIndex]==0x0) continue;
2700
2701
2702 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime
2703 ||
2704 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
2705 ||
2706 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime) continue;
2707
2708 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2709 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2710 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2711 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2712 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
e885fb81 2713 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
e3bd5504 2714 Int_t volDum = vol1[3];
2715 vol1[3] = vol1[4];
2716 vol1[4] = volDum;
e885fb81 2717 fTOFGeometry->GetPosPar(vol1,pos);
e3bd5504 2718 interestingX[0] = pos[0];
2719 interestingY[0] = pos[1];
2720 interestingZ[0] = pos[2];
2721
2722 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2723 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2724 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2725 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2726 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
e885fb81 2727 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
e3bd5504 2728 volDum = vol2[3];
2729 vol2[3] = vol2[4];
2730 vol2[4] = volDum;
e885fb81 2731 fTOFGeometry->GetPosPar(vol2,pos);
e3bd5504 2732 interestingX[1] = pos[0];
2733 interestingY[1] = pos[1];
2734 interestingZ[1] = pos[2];
2735
2736 interestingTOF[2] = selectedDigit[adesso3][thirdIndex]->GetTDC();
2737 interestingTOT[2] = selectedDigit[adesso3][thirdIndex]->GetTOT();
2738 interestingADC[2] = selectedDigit[adesso3][thirdIndex]->GetADC();
2739 interestingWeight[2] = selectedDigit[adesso3][thirdIndex]->GetWeight();
2740 Int_t vol3[5]; for(jj=0; jj<5; jj++) vol3[jj] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(jj);
e885fb81 2741 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol3[0], vol3[1], vol3[2], vol3[4], vol3[3]));
e3bd5504 2742 volDum = vol3[3];
2743 vol3[3] = vol3[4];
2744 vol3[4] = volDum;
e885fb81 2745 fTOFGeometry->GetPosPar(vol3,pos);
e3bd5504 2746 interestingX[2] = pos[0];
2747 interestingY[2] = pos[1];
2748 interestingZ[2] = pos[2];
2749
2750
2751 AverageCalculations(interestingCounter+1,
2752 interestingX, interestingY, interestingZ,
2753 interestingTOF, interestingTOT, interestingADC,
2754 interestingWeight,
2755 parTOF, posClus, check);
2756
2757 for (jj=0; jj<5; jj++) det[jj] = -1;
2758 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
e885fb81 2759 fTOFGeometry->GetDetID(posF, det);
e3bd5504 2760
e885fb81 2761 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
2762 //volIdClus = GetClusterVolIndex(det);
e3bd5504 2763
2764 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2765 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
2766 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
2767 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
2768 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
2769 padsCluster[7] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(4);
2770 padsCluster[8] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(3);
2771
2772 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2773 Int_t ** indDet = new Int_t*[interestingCounter+1];
2774 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj] = new Int_t [5];
2775 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][0] = nSector;
2776 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][1] = nPlate;
2777 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][2] = nStrip;
2778 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][3] = padsCluster[2*jj+3];
2779 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
e885fb81 2780 GetClusterPars(/*check,*/ interestingCounter+1, indDet, interestingWeight, posClus, covClus);
e3bd5504 2781 for (jj=0; jj<interestingCounter+1; jj++) delete [] indDet[jj];
2782
2783 // To fill the track index array
2784 dummyCounter=-1;
2785 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2786 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2787 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
2788 else {
2789 dummyCounter++;
2790 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
2791 }
2792 }
2793 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2794 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
2795 else {
2796
2797 alreadyStored = kFALSE;
2798 for (jj=0; jj<dummyCounter+1; jj++)
2799 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
2800
2801 if (alreadyStored) continue;
2802 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2803 AliWarning(" Siamo al limite!");
2804 continue;
2805 }
2806
2807 dummyCounter++;
2808 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
2809
2810 }
2811
2812 }
2813 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2814 if (selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk)==-1) continue;
2815 else {
2816
2817 alreadyStored = kFALSE;
2818 for (jj=0; jj<dummyCounter+1; jj++)
2819 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk));
2820
2821 if (alreadyStored) continue;
2822 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2823 AliWarning(" Siamo al limite!");
2824 continue;
2825 }
2826
2827 dummyCounter++;
2828 tracks[dummyCounter] = selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk);
2829
2830 }
2831
2832 }
2833
2834
2835 AliTOFcluster *tofCluster =
2836 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
2837 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2838 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
2839 InsertCluster(tofCluster);
2840
e885fb81 2841 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",
e3bd5504 2842 volIdClus, posClus[0], posClus[1], posClus[2],
2843 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2844 tracks[0], tracks[1], tracks[2],
2845 det[0], det[1], det[2], det[3], det[4],
2846 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
2847 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
2848
2849 volDum = vol1[3];
2850 vol1[3] = vol1[4];
2851 vol1[4] = volDum;
2852 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
2853 volDum = vol2[3];
2854 vol2[3] = vol2[4];
2855 vol2[4] = volDum;
2856 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
2857 volDum = vol3[3];
2858 vol3[3] = vol3[4];
2859 vol3[4] = volDum;
2860 fTOFdigitMap->ResetDigitNumber(vol3,selectedDigit[adesso3][thirdIndex]->GetIndex());
2861
2862
2863 } // close loop on third digit
d7ed6a6d 2864 //} // close loop on adesso3
e3bd5504 2865
2866 } // close loop on second digit
d7ed6a6d 2867 //} // close loop on adesso2
e3bd5504 2868
2869 } // close loop on first digit
d7ed6a6d 2870 //} // close loop on adesso1
e3bd5504 2871
2872
2873 break;
2874
2875 case 4:
2876
d7ed6a6d 2877 adesso1 = 0;
e3bd5504 2878 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2879 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2880
d7ed6a6d 2881 adesso2 = 1;
e3bd5504 2882 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2883 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2884
d7ed6a6d 2885 adesso3 = 2;
e3bd5504 2886 for (Int_t thirdIndex=0; thirdIndex<kMaxNumberOfDigitsPerVolume; thirdIndex++) {
2887 if (selectedDigit[adesso3][thirdIndex]==0x0) continue;
2888
d7ed6a6d 2889 adesso4 = 3;
e3bd5504 2890 for (Int_t fourthIndex=0; fourthIndex<kMaxNumberOfDigitsPerVolume; fourthIndex++) {
2891 if (selectedDigit[adesso4][fourthIndex]==0x0) continue;
2892
2893
2894 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime
2895 ||
2896 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
2897 ||
2898 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso4][fourthIndex]->GetTDC())>fMaxDeltaTime
2899 ||
2900 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
2901 ||
2902 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso4][fourthIndex]->GetTDC())>fMaxDeltaTime
2903 ||
2904 TMath::Abs(selectedDigit[adesso3][thirdIndex]->GetTDC()-selectedDigit[adesso4][fourthIndex]->GetTDC())>fMaxDeltaTime) continue;
2905
2906 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2907 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2908 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2909 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2910 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
e885fb81 2911 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
e3bd5504 2912 Int_t volDum = vol1[3];
2913 vol1[3] = vol1[4];
2914 vol1[4] = volDum;
e885fb81 2915 fTOFGeometry->GetPosPar(vol1,pos);
e3bd5504 2916 interestingX[0] = pos[0];
2917 interestingY[0] = pos[1];
2918 interestingZ[0] = pos[2];
2919
2920 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2921 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2922 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2923 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2924 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
e885fb81 2925 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
e3bd5504 2926 volDum = vol2[3];
2927 vol2[3] = vol2[4];
2928 vol2[4] = volDum;
e885fb81 2929 fTOFGeometry->GetPosPar(vol2,pos);
e3bd5504 2930 interestingX[1] = pos[0];
2931 interestingY[1] = pos[1];
2932 interestingZ[1] = pos[2];
2933
2934 interestingTOF[2] = selectedDigit[adesso3][thirdIndex]->GetTDC();
2935 interestingTOT[2] = selectedDigit[adesso3][thirdIndex]->GetTOT();
2936 interestingADC[2] = selectedDigit[adesso3][thirdIndex]->GetADC();
2937 interestingWeight[2] = selectedDigit[adesso3][thirdIndex]->GetWeight();
2938 Int_t vol3[5]; for(jj=0; jj<5; jj++) vol3[jj] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(jj);
e885fb81 2939 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol3[0], vol3[1], vol3[2], vol3[4], vol3[3]));
e3bd5504 2940 volDum = vol3[3];
2941 vol3[3] = vol3[4];
2942 vol3[4] = volDum;
e885fb81 2943 fTOFGeometry->GetPosPar(vol3,pos);
e3bd5504 2944 interestingX[2] = pos[0];
2945 interestingY[2] = pos[1];
2946 interestingZ[2] = pos[2];
2947
2948 interestingTOF[3] = selectedDigit[adesso4][fourthIndex]->GetTDC();
2949 interestingTOT[3] = selectedDigit[adesso4][fourthIndex]->GetTOT();
2950 interestingADC[3] = selectedDigit[adesso4][fourthIndex]->GetADC();
2951 interestingWeight[3] = selectedDigit[adesso4][fourthIndex]->GetWeight();
2952 Int_t vol4[5]; for(jj=0; jj<5; jj++) vol4[jj] = selectedDigit[adesso4][fourthIndex]->GetDetectorIndex(jj);
e885fb81 2953 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol4[0], vol4[1], vol4[2], vol4[4], vol4[3]));
e3bd5504 2954 volDum = vol4[3];
2955 vol4[3] = vol4[4];
2956 vol4[4] = volDum;
e885fb81 2957 fTOFGeometry->GetPosPar(vol4,pos);
e3bd5504 2958 interestingX[3] = pos[0];
2959 interestingY[3] = pos[1];
2960 interestingZ[3] = pos[2];
2961
2962
2963 AverageCalculations(interestingCounter+1,
2964 interestingX, interestingY, interestingZ,
2965 interestingTOF, interestingTOT, interestingADC,
2966 interestingWeight,
2967 parTOF, posClus, check);
2968
2969 for (jj=0; jj<5; jj++) det[jj] = -1;
2970 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
e885fb81 2971 fTOFGeometry->GetDetID(posF, det);
e3bd5504 2972
e885fb81 2973 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
2974 //volIdClus = GetClusterVolIndex(det);
e3bd5504 2975
2976 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2977 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
2978 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
2979 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
2980 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
2981 padsCluster[7] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(4);
2982 padsCluster[8] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(3);
2983 padsCluster[9] = selectedDigit[adesso4][fourthIndex]->GetDetectorIndex(4);
2984 padsCluster[10] = selectedDigit[adesso4][fourthIndex]->GetDetectorIndex(3);
2985
2986 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2987 Int_t ** indDet = new Int_t*[interestingCounter+1];
2988 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj] = new Int_t [5];
2989 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][0] = nSector;
2990 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][1] = nPlate;
2991 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][2] = nStrip;
2992 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][3] = padsCluster[2*jj+3];
2993 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
e885fb81 2994 GetClusterPars(/*check,*/ interestingCounter+1, indDet, interestingWeight, posClus, covClus);
e3bd5504 2995 for (jj=0; jj<interestingCounter+1; jj++) delete [] indDet[jj];
2996
2997 // To fill the track index array
2998 dummyCounter=-1;
2999 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
3000 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
3001 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
3002 else {
3003 dummyCounter++;
3004 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
3005 }
3006 }
3007 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
3008 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
3009 else {
3010
3011 alreadyStored = kFALSE;
3012 for (jj=0; jj<dummyCounter+1; jj++)
3013 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
3014
3015 if (alreadyStored) continue;
3016 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
3017 AliWarning(" Siamo al limite!");
3018 continue;
3019 }
3020
3021 dummyCounter++;
3022 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
3023
3024 }
3025
3026 }
3027 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
3028 if (selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk)==-1) continue;
3029 else {
3030
3031 alreadyStored = kFALSE;
3032 for (jj=0; jj<dummyCounter+1; jj++)
3033 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk));
3034
3035 if (alreadyStored) continue;
3036 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
3037 AliWarning(" Siamo al limite!");
3038 continue;
3039 }
3040
3041 dummyCounter++;
3042 tracks[dummyCounter] = selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk);
3043
3044 }
3045
3046 }
3047 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
3048 if (selectedDigit[adesso4][fourthIndex]->GetTrackLabel(kk)==-1) continue;
3049 else {
3050
3051 alreadyStored = kFALSE;
3052 for (jj=0; jj<dummyCounter+1; jj++)
3053 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso4][fourthIndex]->GetTrackLabel(kk));
3054
3055 if (alreadyStored) continue;
3056 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
3057 AliWarning(" Siamo al limite!");
3058 continue;
3059 }
3060
3061 dummyCounter++;
3062 tracks[dummyCounter] = selectedDigit[adesso4][fourthIndex]->GetTrackLabel(kk);
3063
3064 }
3065
3066 }
3067
3068
3069 AliTOFcluster *tofCluster =
3070 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
3071 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
3072 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
3073 InsertCluster(tofCluster);
3074
e885fb81 3075 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",
e3bd5504 3076 volIdClus, posClus[0], posClus[1], posClus[2],
3077 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
3078 tracks[0], tracks[1], tracks[2],
3079 det[0], det[1], det[2], det[3], det[4],
3080 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
3081 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
3082
3083 volDum = vol1[3];
3084 vol1[3] = vol1[4];
3085 vol1[4] = volDum;
3086 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
3087 volDum = vol2[3];
3088 vol2[3] = vol2[4];
3089 vol2[4] = volDum;
3090 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
3091 volDum = vol3[3];
3092 vol3[3] = vol3[4];
3093 vol3[4] = volDum;
3094 fTOFdigitMap->ResetDigitNumber(vol3,selectedDigit[adesso3][thirdIndex]->GetIndex());
3095 volDum = vol4[3];
3096 vol4[3] = vol4[4];
3097 vol4[4] = volDum;
3098 fTOFdigitMap->ResetDigitNumber(vol4,selectedDigit[adesso4][fourthIndex]->GetIndex());
3099
3100
3101 } // close loop on fourth digit
3102
3103 } // close loop on third digit
3104
3105 } // close loop on second digit
3106
3107 } // close loop on first digit
3108
3109 break;
3110
3111 }
3112
3113 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
3114 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
3115 selectedDigit[ii][jj] = 0x0;
3116
3117 } // loop on iPad
3118
ed1f8475 3119 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++) {
e3bd5504 3120 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
ed1f8475 3121 delete [] selectedDigit[ii][jj];
e3bd5504 3122 selectedDigit[ii][jj] = 0x0;
3123 }
ed1f8475 3124 delete [] selectedDigit[ii];
3125 selectedDigit[ii] = 0x0;
3126 }
b5ed6afb 3127 delete [] selectedDigit;
ed1f8475 3128 selectedDigit = 0x0;
e3bd5504 3129
3130}
3131//_____________________________________________________________________________
3132
3133Int_t AliTOFClusterFinderV1::InsertCluster(AliTOFcluster *tofCluster)
3134{
3135 //
3136 // This function adds a TOF cluster to the array of TOF clusters
3137 // sorted in Z, i.e. fTofClusters
3138 //
3139
3140 if (fNumberOfTofClusters==kTofMaxCluster) {
3141 AliError("Too many clusters !");
3142 return 1;
3143 }
3144
3145 if (fNumberOfTofClusters==0) {
3146 fTofClusters[fNumberOfTofClusters++] = tofCluster;
3147 return 0;
3148 }
3149
3150 Int_t ii = FindClusterIndex(tofCluster->GetZ());
3151 memmove(fTofClusters+ii+1 ,fTofClusters+ii,(fNumberOfTofClusters-ii)*sizeof(AliTOFcluster*));
3152 fTofClusters[ii] = tofCluster;
3153 fNumberOfTofClusters++;
3154
3155 return 0;
3156
3157}
3158//_____________________________________________________________________________
3159
3160Int_t AliTOFClusterFinderV1::FindClusterIndex(Double_t z) const
3161{
3162 //
3163 // This function returns the index of the nearest cluster in z
3164 //
3165
3166 if (fNumberOfTofClusters==0) return 0;
3167 if (z <= fTofClusters[0]->GetZ()) return 0;
3168 if (z > fTofClusters[fNumberOfTofClusters-1]->GetZ()) return fNumberOfTofClusters;
3169 Int_t b = 0, e = fNumberOfTofClusters-1, m = (b+e)/2;
3170 for (; b<e; m=(b+e)/2) {
3171 if (z > fTofClusters[m]->GetZ()) b=m+1;
3172 else e=m;
3173 }
3174
3175 return m;
3176
3177}
3178//_____________________________________________________________________________
3179
3180void AliTOFClusterFinderV1::ResetRecpoint()
3181{
3182 //
3183 // Clear the list of reconstructed points
3184 //
3185
3186 fNumberOfTofClusters = 0;
3187 if (fRecPoints) fRecPoints->Clear();
3188
3189}
3190//_____________________________________________________________________________
3191
3192void AliTOFClusterFinderV1::ResetDigits()
3193{
3194 //
3195 // Clear the list of digits
3196 //
3197
3198 fNumberOfTofDigits = 0;
3199 if (fDigits) fDigits->Clear();
3200
3201}
3202//_____________________________________________________________________________
e885fb81 3203//UShort_t AliTOFClusterFinderV1::GetClusterVolIndex(Int_t *ind) const
3204//{
e3bd5504 3205 //
3206 // Get the volume ID to retrieve the l2t transformation
3207 //
3208
3209 // Detector numbering scheme
e885fb81 3210/*
e3bd5504 3211 Int_t nSector = AliTOFGeometry::NSectors();
3212 Int_t nPlate = AliTOFGeometry::NPlates();
3213 Int_t nStripA = AliTOFGeometry::NStripA();
3214 Int_t nStripB = AliTOFGeometry::NStripB();
3215 Int_t nStripC = AliTOFGeometry::NStripC();
3216
3217 Int_t isector =ind[0];
3218 if (isector >= nSector)
3219 AliError(Form("Wrong sector number in TOF (%d) !", isector));
3220 Int_t iplate = ind[1];
3221 if (iplate >= nPlate)
3222 AliError(Form("Wrong plate number in TOF (%d) !", iplate));
3223 Int_t istrip = ind[2];
3224
3225 Int_t stripOffset = 0;
3226 switch (iplate) {
3227 case 0:
3228 stripOffset = 0;
3229 break;
3230 case 1:
3231 stripOffset = nStripC;
3232 break;
3233 case 2:
3234 stripOffset = nStripC+nStripB;
3235 break;
3236 case 3:
3237 stripOffset = nStripC+nStripB+nStripA;
3238 break;
3239 case 4:
3240 stripOffset = nStripC+nStripB+nStripA+nStripB;
3241 break;
3242 default:
3243 AliError(Form("Wrong plate number in TOF (%d) !", iplate));
3244 break;
3245 };
3246
3247 Int_t index= (2*(nStripC+nStripB)+nStripA)*isector +
3248 stripOffset +
3249 istrip;
3250
3251 UShort_t volIndex = AliGeomManager::LayerToVolUID(AliGeomManager::kTOF, index);
3252 return volIndex;
3253
3254}
e885fb81 3255*/
e3bd5504 3256//_____________________________________________________________________________