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