#101318: Patch for various problems in AliROOT
[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++) {
712
713 digitIndex = fTofClusters[ii]->GetIndex();
714 for(jj=0; jj<5; jj++) detectorIndex[jj] = fTofClusters[ii]->GetDetInd(jj);
e885fb81 715 volIdClus = fTOFGeometry->GetAliSensVolIndex(detectorIndex[0],detectorIndex[1],detectorIndex[2]);
716 //volIdClus = GetClusterVolIndex(detectorIndex);
e3bd5504 717 for(jj=0; jj<3; jj++) trackLabels[jj] = fTofClusters[ii]->GetLabel(jj);
718 parTOF[0] = fTofClusters[ii]->GetTDC(); // TDC
719 parTOF[1] = fTofClusters[ii]->GetToT(); // TOT
720 parTOF[2] = fTofClusters[ii]->GetADC(); // ADC=TOT
721 parTOF[3] = fTofClusters[ii]->GetTDCND(); // TDCND
722 parTOF[4] = fTofClusters[ii]->GetTDCRAW();//RAW
1d834a1e 723 parTOF[5] = 0;
724 parTOF[6] = 0;
e3bd5504 725 status = fTofClusters[ii]->GetStatus();
726
727 posClus[0] = fTofClusters[ii]->GetX();
728 posClus[1] = fTofClusters[ii]->GetY();
729 posClus[2] = fTofClusters[ii]->GetZ();
730
731 //for (jj=0; jj<6; jj++) covClus[jj] = 0.;
732 //((AliCluster*)fTofClusters[ii])->GetGlobalCov(covClus);
733
734 new(lRecPoints[ii]) AliTOFcluster(volIdClus, (Double_t)posClus[0], (Double_t)posClus[1], (Double_t)posClus[2],
735 (Double_t)(fTofClusters[ii]->GetSigmaX2()),
736 (Double_t)(fTofClusters[ii]->GetSigmaXY()),
737 (Double_t)(fTofClusters[ii]->GetSigmaXZ()),
738 (Double_t)(fTofClusters[ii]->GetSigmaY2()),
739 (Double_t)(fTofClusters[ii]->GetSigmaYZ()),
740 (Double_t)(fTofClusters[ii]->GetSigmaZ2()),
741 //(Double_t)covClus[0], (Double_t)covClus[1], (Double_t)covClus[2],
742 //(Double_t)covClus[3], (Double_t)covClus[4], (Double_t)covClus[5],
743 trackLabels, detectorIndex, parTOF, status, digitIndex);
744
e885fb81 745 AliDebug(2, Form(" %4d %4d %f %f %f %f %f %f %f %f %f %3d %3d %3d %2d %1d %2d %1d %2d %4d %3d %3d %4d %4d %1d %4d",
e3bd5504 746 ii, volIdClus, posClus[0], posClus[1], posClus[2],
747 fTofClusters[ii]->GetSigmaX2(),
748 fTofClusters[ii]->GetSigmaXY(),
749 fTofClusters[ii]->GetSigmaXZ(),
750 fTofClusters[ii]->GetSigmaY2(),
751 fTofClusters[ii]->GetSigmaYZ(),
752 fTofClusters[ii]->GetSigmaZ2(),
753 trackLabels[0], trackLabels[1], trackLabels[2],
754 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[3], detectorIndex[4],
755 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
756 status, digitIndex));
757
758
759 }
760
761 for (Int_t iSector=0; iSector<AliTOFGeometry::NSectors(); iSector++)
762 for(Int_t iPlate=0; iPlate<AliTOFGeometry::NPlates(); iPlate++) {
763 for(Int_t iStrip=0; iStrip<AliTOFGeometry::NStrip(iPlate); iStrip++) {
764 if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
e885fb81 765 AliDebug(2, Form(" END %2d %1d %2d %5d",
e3bd5504 766 iSector, iPlate, iStrip, fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip)));
767 }
768 }
769
770}
771//_____________________________________________________________________________
772
773void AliTOFClusterFinderV1::FindOnePadClusterPerStrip(Int_t nSector,
774 Int_t nPlate,
775 Int_t nStrip)
776{
777 //
778 // This function searches the isolated digits (stored in the fDigits object),
779 // to perform clusters (stored in the fTofClusters array).
780 // This research has been made by checking the fTOFdigitMap object,
781 // filled at digits/raw-data reading time.
782 //
783
784 const Int_t kMaxNumberOfTracksPerDigit = 3;
cc7a1acd 785 const Int_t kMaxNumberOfDigitsPerVolume = 10;
e3bd5504 786
787 Int_t jj = 0;
788
e3bd5504 789 Int_t det[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padZ,padX
790 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padX,padZ
791 UShort_t volIdClus = 0;
792
793 Float_t pos[3];
794 for (jj=0; jj<3; jj++) pos[jj] = 0.;
795 Double_t posClus[3];
796 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
797
798 Double_t covClus[6];
799 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
800
1d834a1e 801 Int_t parTOF[7];
802 for (jj=0; jj<7; jj++) parTOF[jj] = 0;
e3bd5504 803
804 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
805
806 Int_t tracks[kMaxNumberOfTracksPerDigit];
ed1f8475 807 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
e3bd5504 808
809 Int_t dummyCounter=-1;
e3bd5504 810
811 AliTOFdigit *digitInteresting;
812
813 Int_t iPadX = -1;
814 Int_t iPadZ = -1;
815 for (iPadX=0; iPadX<AliTOFGeometry::NpadX(); iPadX++) {
816 for (iPadZ=0; iPadZ<AliTOFGeometry::NpadZ(); iPadZ++) {
817 vol[4] = iPadZ , vol[3] = iPadX;
818
e885fb81 819 AliDebug(3, Form(" %1d %2d\n", iPadZ, iPadX));
e3bd5504 820
821 if (fTOFdigitMap->GetNumberOfDigits(vol)==0) continue;
822
823 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
824 if (fTOFdigitMap->GetDigitIndex(vol,digIndex)<0) continue;
825 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(fTOFdigitMap->GetDigitIndex(vol,digIndex));
826
e885fb81 827 AliDebug(2, Form(" %3d %5d %2d %1d %2d %1d %2d %d %d %d %5d %5d %5d %5d",
828 fTOFdigitMap->GetNumberOfDigits(vol), digIndex,
e3bd5504 829 vol[0], vol[1], vol[2] ,vol[4], vol[3],
830 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
831 digitInteresting->GetToT(),
832 fTOFdigitMap->GetDigitIndex(vol,digIndex),
833 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
834
e885fb81 835 det[3] = vol[4]; // padz
836 det[4] = vol[3]; // padx
837 fTOFGeometry->GetPosPar(det,pos);
e3bd5504 838 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
839
840 //insert cluster
841 for (jj=0; jj<3; jj++) posClus[jj] = pos[jj];
842
843 parTOF[0] = Int_t(digitInteresting->GetTdc());
e885fb81 844 parTOF[1] = Int_t(digitInteresting->GetToT());
845 parTOF[2] = Int_t(digitInteresting->GetAdc());
846 parTOF[3] = Int_t(digitInteresting->GetTdcND());
e3bd5504 847 parTOF[4] = Int_t(digitInteresting->GetTdc());
1d834a1e 848 parTOF[5] = 0;
849 parTOF[6] = 0;
e3bd5504 850
e885fb81 851 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
852 //volIdClus = GetClusterVolIndex(det);
e3bd5504 853
854 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
855 GetClusterPars(det, posClus, covClus);
856
857 // To fill the track index array
858 dummyCounter=-1;
859 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
860 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) { // three is the max number of tracks associated to one digit
861 if (digitInteresting->GetTrack(jj)==-1) continue;
862 else {
863 dummyCounter++;
864 tracks[dummyCounter] = digitInteresting->GetTrack(jj);
865 }
866 }
867
868 AliTOFcluster *tofCluster =
869 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
870 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
871 tracks, det, parTOF, status, fTOFdigitMap->GetDigitIndex(vol,digIndex));
872 InsertCluster(tofCluster);
873
e885fb81 874 AliDebug(2, Form(" %4d %f %f %f %f %f %f %f %f %f %3d %3d %3d %2d %1d %2d %1d %2d %4d %3d %3d %4d %4d %1d %4d",
e3bd5504 875 volIdClus, posClus[0], posClus[1], posClus[2],
876 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
877 tracks[0], tracks[1], tracks[2],
878 det[0], det[1], det[2], det[3], det[4],
879 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
880 status, fTOFdigitMap->GetDigitIndex(vol,digIndex)));
881
882 AliDebug(2, Form(" %f %f %f", pos[0], pos[1], pos[2]));
e885fb81 883 AliDebug(2, Form(" %d %d", parTOF[0], parTOF[2]));
884
885 fTOFdigitMap->ResetDigit(vol, digIndex);
886
887 }
888
889 }
890 }
891
892}
893//_____________________________________________________________________________
894
895void AliTOFClusterFinderV1::FindClustersWithoutTOT(Int_t nSector,
896 Int_t nPlate,
897 Int_t nStrip)
898{
899 //
900 // This function searches the isolated digits without TOT
901 // measurement (stored in the fDigits object), to perform clusters
902 // (stored in the fTofClusters array). This research has been made
903 // by checking the fTOFdigitMap object, filled at digits/raw-data
904 // reading time.
905 //
906
907 const Int_t kMaxNumberOfTracksPerDigit = 3;
cc7a1acd 908 const Int_t kMaxNumberOfDigitsPerVolume = 10;
e885fb81 909
910 Int_t jj = 0;
911
912 Int_t det[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padZ,padX
913 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padX,padZ
914 UShort_t volIdClus = 0;
915
916 Float_t pos[3];
917 for (jj=0; jj<3; jj++) pos[jj] = 0.;
918 Double_t posClus[3];
919 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
920
921 Double_t covClus[6];
922 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
923
1d834a1e 924 Int_t parTOF[7];
925 for (jj=0; jj<7; jj++) parTOF[jj] = 0;
e885fb81 926
927 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
928 Int_t tracks[kMaxNumberOfTracksPerDigit];
ed1f8475 929 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
e885fb81 930
931 Int_t dummyCounter=-1;
932
933 AliTOFdigit *digitInteresting;
934
935 Int_t iPadX = -1;
936 Int_t iPadZ = -1;
937 for (iPadX=0; iPadX<AliTOFGeometry::NpadX(); iPadX++) {
938 for (iPadZ=0; iPadZ<AliTOFGeometry::NpadZ(); iPadZ++) {
939 vol[4] = iPadZ , vol[3] = iPadX;
940
941 AliDebug(3, Form(" %1d %2d\n", iPadZ, iPadX));
942
943 if (fTOFdigitMap->GetNumberOfDigits(vol)==0) continue;
944
945 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
946 if (fTOFdigitMap->GetDigitIndex(vol,digIndex)<0) continue;
947 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(fTOFdigitMap->GetDigitIndex(vol,digIndex));
948 if (digitInteresting->GetToT()>0) continue; // AdC
949
950 AliDebug(2, Form(" %3d %5d %2d %1d %2d %1d %2d %d %d %d %5d %5d %5d %5d",
951 fTOFdigitMap->GetNumberOfDigits(vol), digIndex,
952 vol[0], vol[1], vol[2] ,vol[4], vol[3],
953 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
954 digitInteresting->GetToT(),
955 fTOFdigitMap->GetDigitIndex(vol,digIndex),
956 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
957
958 det[3] = vol[4]; // padz
959 det[4] = vol[3]; // padx
960 fTOFGeometry->GetPosPar(det,pos);
961 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
962
963 //insert cluster
964 for (jj=0; jj<3; jj++) posClus[jj] = pos[jj];
965
966 parTOF[0] = Int_t(digitInteresting->GetTdc());
967 parTOF[1] = Int_t(digitInteresting->GetToT());
968 parTOF[2] = Int_t(digitInteresting->GetAdc());
969 parTOF[3] = Int_t(digitInteresting->GetTdcND());
970 parTOF[4] = Int_t(digitInteresting->GetTdc());
1d834a1e 971 parTOF[5] = 0;
972 parTOF[6] = 0;
e885fb81 973
974 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
975 //volIdClus = GetClusterVolIndex(det);
976
977 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
978 GetClusterPars(det, posClus, covClus);
979
980 // To fill the track index array
981 dummyCounter=-1;
982 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
983 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) { // three is the max number of tracks associated to one digit
984 if (digitInteresting->GetTrack(jj)==-1) continue;
985 else {
986 dummyCounter++;
987 tracks[dummyCounter] = digitInteresting->GetTrack(jj);
988 }
989 }
990
991 AliTOFcluster *tofCluster =
992 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
993 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
994 tracks, det, parTOF, status, fTOFdigitMap->GetDigitIndex(vol,digIndex));
995 InsertCluster(tofCluster);
996
997 AliDebug(2, Form(" %4d %f %f %f %f %f %f %f %f %f %3d %3d %3d %2d %1d %2d %1d %2d %4d %3d %3d %4d %4d %1d %4d",
998 volIdClus, posClus[0], posClus[1], posClus[2],
999 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1000 tracks[0], tracks[1], tracks[2],
1001 det[0], det[1], det[2], det[3], det[4],
1002 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
1003 status, fTOFdigitMap->GetDigitIndex(vol,digIndex)));
1004
1005 AliDebug(2, Form(" %f %f %f", pos[0], pos[1], pos[2]));
1006 AliDebug(2, Form(" %d %d", parTOF[0], parTOF[2]));
e3bd5504 1007
e3bd5504 1008 fTOFdigitMap->ResetDigit(vol, digIndex);
1009
1010 }
1011
1012 }
1013 }
1014
1015}
1016//_____________________________________________________________________________
1017
1018void AliTOFClusterFinderV1::FindClusters34(Int_t nSector,
1019 Int_t nPlate,
1020 Int_t nStrip)
1021{
1022 //
1023 // This function searches the neighbouring digits (stored in the fDigits object),
1024 // to perform clusters (stored in the fTofClusters array).
1025 //
1026 // This research has been made by checking the fTOFdigitMap object,
1027 // filled at digits/raw-data reading time.
1028 //
1029
1030 const Int_t kMaxNumberOfInterestingPads = 4;
1031 const Int_t kMaxNumberOfTracksPerDigit = 3;
cc7a1acd 1032 const Int_t kMaxNumberOfDigitsPerVolume = 10;
e3bd5504 1033
1034 Int_t ii = 0;
1035
1036 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
1037 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1038 digitsInVolumeIndices[ii] = -1;
1039
e3bd5504 1040 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
1041
1042 Float_t pos[3] = {0.,0.,0.};
1043
1044 Int_t jj = 0;
1045 Int_t interestingPadX[kMaxNumberOfInterestingPads];
1046 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
1047 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
1048 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
1049 Double_t interestingTOT[kMaxNumberOfInterestingPads];
1050 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
1051 Double_t interestingADC[kMaxNumberOfInterestingPads];
1052 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
1053 Double_t interestingTOF[kMaxNumberOfInterestingPads];
1054 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
1055 Double_t interestingWeight[kMaxNumberOfInterestingPads];
1056 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
1057
1058 Float_t interestingX[kMaxNumberOfInterestingPads];
1059 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
1060 Float_t interestingY[kMaxNumberOfInterestingPads];
1061 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
1062 Float_t interestingZ[kMaxNumberOfInterestingPads];
1063 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
1064
1065 Float_t interDigit[kMaxNumberOfInterestingPads];
1066 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
1067
1068 Int_t padsCluster[11];
1069 padsCluster[0] = nSector;
1070 padsCluster[1] = nPlate;
1071 padsCluster[2] = nStrip;
1072 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1073
1074 Int_t interestingCounter=-1;
e885fb81 1075 Int_t digitIndexLocal=-1; // AdC
e3bd5504 1076 Int_t iPad = -1;
1077 Int_t iPadX = -1;
1078 Int_t iPadZ = -1;
1079
1d834a1e 1080 Int_t parTOF[7];
1081 for (jj=0; jj<7; jj++) parTOF[jj] = 0;
e3bd5504 1082 Double_t posClus[3];
1083 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
1084 Int_t det[5];
1085 for (jj=0; jj<5; jj++) det[jj] = -1;
1086 Float_t posF[3];
1087 for (jj=0; jj<3; jj++) posF[jj] = 0.;
1088 UShort_t volIdClus = 0;
1089 Bool_t check = kFALSE;
1090 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
1091 Double_t covClus[6];
1092 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1093 Int_t tracks[kMaxNumberOfTracksPerDigit];
ed1f8475 1094 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
e3bd5504 1095 Int_t dummyCounter=-1;
1096 Bool_t alreadyStored = kFALSE;
1097
1098 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
1099 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1100 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
1101
1102 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1103 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
1104
1105 AliTOFdigit *digitInteresting;
1106
1107 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
1108
1109 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
1110 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
1111
e885fb81 1112 AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
e3bd5504 1113
1114
1115
1116
1117
1118
1119 interestingCounter=-1;
1120
1121 vol[4] = iPadZ , vol[3] = iPadX;
1122 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1123 interestingCounter++;
1124
1125 vol[4] = iPadZ, vol[3] = iPadX+1;
1126 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1127 interestingCounter++;
1128
1129 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1130 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1131 interestingCounter++;
1132
1133 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1134 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1135 interestingCounter++;
1136
1137 if (interestingCounter+1!=4) continue; // the hit pads have to be 4
1138 else interestingCounter=-1;
1139
1140
1141 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1142 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1143 selectedDigit[ii][jj] = 0x0;
1144
1145
1146 vol[4] = iPadZ, vol[3] = iPadX;
1147
1148 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1149 interestingCounter++;
1150 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1151 digitsInVolumeIndices[ii] = -1;
1152 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
e885fb81 1153 digitIndexLocal=-1; // AdC
e3bd5504 1154 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1155 if (digitsInVolumeIndices[digIndex]<0) continue;
1156 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
e885fb81 1157 if (digitInteresting->GetToT()<=0) continue; // AdC
1158 digitIndexLocal++; // AdC
e3bd5504 1159
4682c56e 1160 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
e3bd5504 1161 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1162 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1163 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1164 digitsInVolumeIndices[digIndex],
1165 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1166
1167
e885fb81 1168 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
e3bd5504 1169 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1170 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1171 digitInteresting->GetToT()*digitInteresting->GetToT(),
1172 digitsInVolumeIndices[digIndex],
1173 digitInteresting->GetTracks());
1174 }
e885fb81 1175 if (digitIndexLocal==-1) interestingCounter--; // AdC
e3bd5504 1176 }
1177
1178
1179 vol[4] = iPadZ, vol[3] = iPadX+1;
1180
1181 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1182 interestingCounter++;
1183 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1184 digitsInVolumeIndices[ii] = -1;
1185 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
e885fb81 1186 digitIndexLocal=-1; // AdC
e3bd5504 1187 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1188 if (digitsInVolumeIndices[digIndex]<0) continue;
1189 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
e885fb81 1190 if (digitInteresting->GetToT()<=0) continue; // AdC
1191 digitIndexLocal++; // AdC
e3bd5504 1192
4682c56e 1193 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
e3bd5504 1194 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1195 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1196 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1197 digitsInVolumeIndices[digIndex],
1198 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1199
1200
e885fb81 1201 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
e3bd5504 1202 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1203 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1204 digitInteresting->GetToT()*digitInteresting->GetToT(),
1205 digitsInVolumeIndices[digIndex],
1206 digitInteresting->GetTracks());
1207 }
e885fb81 1208 if (digitIndexLocal==-1) interestingCounter--; // AdC
e3bd5504 1209 }
1210
1211
1212 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1213
1214 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1215 interestingCounter++;
1216 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1217 digitsInVolumeIndices[ii] = -1;
1218 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
e885fb81 1219 digitIndexLocal=-1; // AdC
e3bd5504 1220 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1221 if (digitsInVolumeIndices[digIndex]<0) continue;
1222 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
e885fb81 1223 if (digitInteresting->GetToT()<=0) continue; // AdC
1224 digitIndexLocal++; // AdC
e3bd5504 1225
4682c56e 1226 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
e3bd5504 1227 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1228 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1229 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1230 digitsInVolumeIndices[digIndex],
1231 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1232
1233
e885fb81 1234 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
e3bd5504 1235 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1236 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1237 digitInteresting->GetToT()*digitInteresting->GetToT(),
1238 digitsInVolumeIndices[digIndex],
1239 digitInteresting->GetTracks());
1240 }
e885fb81 1241 if (digitIndexLocal==-1) interestingCounter--; // AdC
e3bd5504 1242 }
1243
1244
1245 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1246
1247 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1248 interestingCounter++;
1249 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1250 digitsInVolumeIndices[ii] = -1;
1251 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
e885fb81 1252 digitIndexLocal=-1;
e3bd5504 1253 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1254 if (digitsInVolumeIndices[digIndex]<0) continue;
1255 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
e885fb81 1256 if (digitInteresting->GetToT()<=0) continue; // AdC
1257 digitIndexLocal++; // AdC
e3bd5504 1258
4682c56e 1259 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
e3bd5504 1260 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1261 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1262 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1263 digitsInVolumeIndices[digIndex],
1264 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1265
e885fb81 1266 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
e3bd5504 1267 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1268 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1269 digitInteresting->GetToT()*digitInteresting->GetToT(),
1270 digitsInVolumeIndices[digIndex],
1271 digitInteresting->GetTracks());
1272 }
e885fb81 1273 if (digitIndexLocal==-1) interestingCounter--; // AdC
e3bd5504 1274 }
1275
e885fb81 1276 AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
e3bd5504 1277
1278 for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
1279 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
1280 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
1281
1282 for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
1283 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
1284 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
1285
1286 for (Int_t adesso3=adesso2+1; adesso3<interestingCounter+1; adesso3++) {
1287 for (Int_t thirdIndex=0; thirdIndex<kMaxNumberOfDigitsPerVolume; thirdIndex++) {
1288 if (selectedDigit[adesso3][thirdIndex]==0x0) continue;
1289
1290
1291 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime
1292 ||
1293 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
1294 ||
1295 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime) continue;
1296
1297 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
1298 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
1299 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
1300 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
1301 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
e885fb81 1302 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
e3bd5504 1303 Int_t volDum = vol1[3];
1304 vol1[3] = vol1[4];
1305 vol1[4] = volDum;
e885fb81 1306 fTOFGeometry->GetPosPar(vol1,pos);
e3bd5504 1307 interestingX[0] = pos[0];
1308 interestingY[0] = pos[1];
1309 interestingZ[0] = pos[2];
1310
1311 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
1312 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
1313 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
1314 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
1315 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
e885fb81 1316 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
e3bd5504 1317 volDum = vol2[3];
1318 vol2[3] = vol2[4];
1319 vol2[4] = volDum;
e885fb81 1320 fTOFGeometry->GetPosPar(vol2,pos);
e3bd5504 1321 interestingX[1] = pos[0];
1322 interestingY[1] = pos[1];
1323 interestingZ[1] = pos[2];
1324
1325 interestingTOF[2] = selectedDigit[adesso3][thirdIndex]->GetTDC();
1326 interestingTOT[2] = selectedDigit[adesso3][thirdIndex]->GetTOT();
1327 interestingADC[2] = selectedDigit[adesso3][thirdIndex]->GetADC();
1328 interestingWeight[2] = selectedDigit[adesso3][thirdIndex]->GetWeight();
1329 Int_t vol3[5]; for(jj=0; jj<5; jj++) vol3[jj] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(jj);
e885fb81 1330 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol3[0], vol3[1], vol3[2], vol3[4], vol3[3]));
e3bd5504 1331 volDum = vol3[3];
1332 vol3[3] = vol3[4];
1333 vol3[4] = volDum;
e885fb81 1334 fTOFGeometry->GetPosPar(vol3,pos);
e3bd5504 1335 interestingX[2] = pos[0];
1336 interestingY[2] = pos[1];
1337 interestingZ[2] = pos[2];
1338
1339
1340 AverageCalculations(3, interestingX, interestingY, interestingZ,
1341 interestingTOF, interestingTOT, interestingADC,
1342 interestingWeight,
1343 parTOF, posClus, check);
1344
1345
1346 for (jj=0; jj<5; jj++) det[jj] = -1;
1347 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
e885fb81 1348 fTOFGeometry->GetDetID(posF, det);
e3bd5504 1349
e885fb81 1350 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
1351 //volIdClus = GetClusterVolIndex(det);
e3bd5504 1352
1353 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1354 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
1355 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
1356 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
1357 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
1358 padsCluster[7] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(4);
1359 padsCluster[8] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(3);
1360
1361 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1362 Int_t ** indDet = new Int_t*[3];
1363 for (jj=0; jj<3; jj++) indDet[jj] = new Int_t [5];
1364 for (jj=0; jj<3; jj++) indDet[jj][0] = nSector;
1365 for (jj=0; jj<3; jj++) indDet[jj][1] = nPlate;
1366 for (jj=0; jj<3; jj++) indDet[jj][2] = nStrip;
1367 for (jj=0; jj<3; jj++) indDet[jj][3] = padsCluster[2*jj+3];
1368 for (jj=0; jj<3; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
e885fb81 1369 GetClusterPars(/*check,*/ 3, indDet, interestingWeight, posClus, covClus);
e3bd5504 1370 for (jj=0; jj<3; jj++) delete [] indDet[jj];
1d834a1e 1371 delete [] indDet;
e3bd5504 1372
1373 // To fill the track index array
1374 dummyCounter=-1;
1375 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1376 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1377 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
1378 else {
1379 dummyCounter++;
1380 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
1381 }
1382 }
1383 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1384 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
1385 else {
1386
1387 alreadyStored = kFALSE;
1388 for (jj=0; jj<dummyCounter+1; jj++)
1389 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
1390
1391 if (alreadyStored) continue;
1392 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
1393 AliWarning(" Siamo al limite!");
1394 continue;
1395 }
1396
1397 dummyCounter++;
1398 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
1399
1400 }
1401
1402 }
1403 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1404 if (selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk)==-1) continue;
1405 else {
1406
1407 alreadyStored = kFALSE;
1408 for (jj=0; jj<dummyCounter+1; jj++)
1409 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk));
1410
1411 if (alreadyStored) continue;
1412 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
1413 AliWarning(" Siamo al limite!");
1414 continue;
1415 }
1416
1417 dummyCounter++;
1418 tracks[dummyCounter] = selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk);
1419
1420 }
1421
1422 }
1423
1424
1425 AliTOFcluster *tofCluster =
1426 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
1427 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1428 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
1429 InsertCluster(tofCluster);
1430
e885fb81 1431 AliDebug(2, Form(" %4d %f %f %f %f %f %f %f %f %f %3d %3d %3d %2d %1d %2d %1d %2d %4d %3d %3d %4d %4d %1d %4d",
e3bd5504 1432 volIdClus, posClus[0], posClus[1], posClus[2],
1433 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1434 tracks[0], tracks[1], tracks[2],
1435 det[0], det[1], det[2], det[3], det[4],
1436 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
1437 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
1438
1439
1440 volDum = vol1[3];
1441 vol1[3] = vol1[4];
1442 vol1[4] = volDum;
1443 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
1444 volDum = vol2[3];
1445 vol2[3] = vol2[4];
1446 vol2[4] = volDum;
1447 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
1448 volDum = vol3[3];
1449 vol3[3] = vol3[4];
1450 vol3[4] = volDum;
1451 fTOFdigitMap->ResetDigitNumber(vol3,selectedDigit[adesso3][thirdIndex]->GetIndex());
1452
1453
1454 } // close loop on third digit
1455 } // close loop on adesso3
1456
1457 } // close loop on second digit
1458 } // close loop on adesso2
1459
1460 } // close loop on first digit
1461 } // close loop on adesso1
1462
1463 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1464 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1465 selectedDigit[ii][jj] = 0x0;
1466
1467 } // loop on iPad
1468
ed1f8475 1469 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++) {
e3bd5504 1470 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
ed1f8475 1471 delete [] selectedDigit[ii][jj];
e3bd5504 1472 selectedDigit[ii][jj] = 0x0;
1473 }
ed1f8475 1474 delete [] selectedDigit[ii];
1475 selectedDigit[ii] = 0x0;
1476 }
b5ed6afb 1477 delete [] selectedDigit;
ed1f8475 1478 selectedDigit = 0x0;
e3bd5504 1479
1480}
1481//_____________________________________________________________________________
1482
1483void AliTOFClusterFinderV1::FindClusters23(Int_t nSector,
1484 Int_t nPlate,
1485 Int_t nStrip)
1486{
1487 //
1488 // This function searches the neighbouring digits (stored in the fDigits object),
1489 // to perform clusters (stored in the fTofClusters array).
1490 //
1491 // This research has been made by checking the fTOFdigitMap object,
1492 // filled at digits/raw-data reading time.
1493 //
1494
1495 const Int_t kMaxNumberOfInterestingPads = 4;
1496 const Int_t kMaxNumberOfTracksPerDigit = 3;
cc7a1acd 1497 const Int_t kMaxNumberOfDigitsPerVolume = 10;
e3bd5504 1498
1499 Int_t ii = 0;
1500
1501 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
1502 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1503 digitsInVolumeIndices[ii] = -1;
1504
e3bd5504 1505 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
1506
1507 Float_t pos[3] = {0.,0.,0.};
1508
1509 Int_t jj = 0;
1510 Int_t interestingPadX[kMaxNumberOfInterestingPads];
1511 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
1512 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
1513 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
1514 Double_t interestingTOT[kMaxNumberOfInterestingPads];
1515 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
1516 Double_t interestingADC[kMaxNumberOfInterestingPads];
1517 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
1518 Double_t interestingTOF[kMaxNumberOfInterestingPads];
1519 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
1520 Double_t interestingWeight[kMaxNumberOfInterestingPads];
1521 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
1522
1523 Float_t interestingX[kMaxNumberOfInterestingPads];
1524 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
1525 Float_t interestingY[kMaxNumberOfInterestingPads];
1526 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
1527 Float_t interestingZ[kMaxNumberOfInterestingPads];
1528 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
1529
1530 Float_t interDigit[kMaxNumberOfInterestingPads];
1531 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
1532
1533 Int_t padsCluster[11];
1534 padsCluster[0] = nSector;
1535 padsCluster[1] = nPlate;
1536 padsCluster[2] = nStrip;
1537 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1538
1539 Int_t interestingCounter=-1;
e885fb81 1540 Int_t digitIndexLocal = -1;
e3bd5504 1541 Int_t iPad = -1;
1542 Int_t iPadX = -1;
1543 Int_t iPadZ = -1;
1544
1545 Bool_t check = kFALSE;
1d834a1e 1546 Int_t parTOF[7];
1547 for (jj=0; jj<7; jj++) parTOF[jj] = 0;
e3bd5504 1548 Double_t posClus[3];
1549 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
1550 Int_t det[5];
1551 for (jj=0; jj<5; jj++) det[jj] = -1;
1552 Float_t posF[3];
1553 for (jj=0; jj<3; jj++) posF[jj] = 0.;
1554 UShort_t volIdClus = 0;
1555 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
1556 Double_t covClus[6];
1557 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1558 Int_t tracks[kMaxNumberOfTracksPerDigit];
ed1f8475 1559 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
e3bd5504 1560 Int_t dummyCounter=-1;
1561 Bool_t alreadyStored = kFALSE;
1562
1563 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
1564 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1565 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
1566
1567 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1568 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
1569
1570 AliTOFdigit *digitInteresting;
1571
1572 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
1573
1574 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
1575 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
1576
e885fb81 1577 AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
e3bd5504 1578
1579
1580
1581
1582
1583
1584 interestingCounter=-1;
1585
1586 vol[4] = iPadZ , vol[3] = iPadX;
1587 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1588 interestingCounter++;
1589
1590 vol[4] = iPadZ, vol[3] = iPadX+1;
1591 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1592 interestingCounter++;
1593
1594 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1595 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1596 interestingCounter++;
1597
1598 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1599 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1600 interestingCounter++;
1601
1602 if (interestingCounter+1!=3) continue; // the hit pads have to be 3
1603 else interestingCounter=-1;
1604
1605
1606 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1607 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1608 selectedDigit[ii][jj] = 0x0;
1609
1610
1611 vol[4] = iPadZ, vol[3] = iPadX;
1612
1613 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1614 interestingCounter++;
1615 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1616 digitsInVolumeIndices[ii] = -1;
1617 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
e885fb81 1618 digitIndexLocal=-1;
e3bd5504 1619 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1620 if (digitsInVolumeIndices[digIndex]<0) continue;
1621 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
e885fb81 1622 if (digitInteresting->GetToT()<=0) continue; // AdC
1623 digitIndexLocal++; // AdC
e3bd5504 1624
4682c56e 1625 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
e3bd5504 1626 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1627 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1628 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1629 digitsInVolumeIndices[digIndex],
1630 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1631
e885fb81 1632 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
e3bd5504 1633 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1634 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1635 digitInteresting->GetToT()*digitInteresting->GetToT(),
1636 digitsInVolumeIndices[digIndex],
1637 digitInteresting->GetTracks());
1638 }
e885fb81 1639 if (digitIndexLocal==-1) interestingCounter--; // AdC
e3bd5504 1640 }
1641
1642
1643 vol[4] = iPadZ, vol[3] = iPadX+1;
1644
1645 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1646 interestingCounter++;
1647 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1648 digitsInVolumeIndices[ii] = -1;
1649 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
e885fb81 1650 digitIndexLocal=-1; // AdC
e3bd5504 1651 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1652 if (digitsInVolumeIndices[digIndex]<0) continue;
1653 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
e885fb81 1654 if (digitInteresting->GetToT()<=0) continue; // AdC
1655 digitIndexLocal++; // AdC
e3bd5504 1656
4682c56e 1657 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
e3bd5504 1658 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1659 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1660 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1661 digitsInVolumeIndices[digIndex],
1662 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1663
e885fb81 1664 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
e3bd5504 1665 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1666 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1667 digitInteresting->GetToT()*digitInteresting->GetToT(),
1668 digitsInVolumeIndices[digIndex],
1669 digitInteresting->GetTracks());
1670 }
e885fb81 1671 if (digitIndexLocal==-1) interestingCounter--; // AdC
e3bd5504 1672 }
1673
1674
1675 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
1676
1677 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1678 interestingCounter++;
1679 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1680 digitsInVolumeIndices[ii] = -1;
1681 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
e885fb81 1682 digitIndexLocal=-1; // AdC
e3bd5504 1683 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1684 if (digitsInVolumeIndices[digIndex]<0) continue;
1685 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
e885fb81 1686 if (digitInteresting->GetToT()<=0) continue; // AdC
1687 digitIndexLocal++; // AdC
e3bd5504 1688
4682c56e 1689 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
e3bd5504 1690 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1691 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1692 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1693 digitsInVolumeIndices[digIndex],
1694 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1695
e885fb81 1696 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
e3bd5504 1697 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1698 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1699 digitInteresting->GetToT()*digitInteresting->GetToT(),
1700 digitsInVolumeIndices[digIndex],
1701 digitInteresting->GetTracks());
1702 }
e885fb81 1703 if (digitIndexLocal==-1) interestingCounter--; // AdC
e3bd5504 1704 }
1705
1706
1707 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
1708
1709 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
1710 interestingCounter++;
1711 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1712 digitsInVolumeIndices[ii] = -1;
1713 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
e885fb81 1714 digitIndexLocal=-1; // AdC
e3bd5504 1715 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
1716 if (digitsInVolumeIndices[digIndex]<0) continue;
1717 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
e885fb81 1718 if (digitInteresting->GetToT()<=0) continue; // AdC
1719 digitIndexLocal++; // AdC
e3bd5504 1720
4682c56e 1721 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
e3bd5504 1722 vol[0], vol[1], vol[2] ,vol[4], vol[3],
1723 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
1724 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
1725 digitsInVolumeIndices[digIndex],
1726 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
1727
e885fb81 1728 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
e3bd5504 1729 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
1730 digitInteresting->GetAdc(), digitInteresting->GetToT(),
1731 digitInteresting->GetToT()*digitInteresting->GetToT(),
1732 digitsInVolumeIndices[digIndex],
1733 digitInteresting->GetTracks());
1734 }
e885fb81 1735 if (digitIndexLocal==-1) interestingCounter--; // AdC
e3bd5504 1736 }
1737
e885fb81 1738 AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
e3bd5504 1739
1740 for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
1741 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
1742 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
1743
1744 for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
1745 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
1746 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
1747
1748 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime) continue;
1749
1750 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
1751 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
1752 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
1753 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
1754 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
e885fb81 1755 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
e3bd5504 1756 Int_t volDum = vol1[3];
1757 vol1[3] = vol1[4];
1758 vol1[4] = volDum;
e885fb81 1759 fTOFGeometry->GetPosPar(vol1,pos);
e3bd5504 1760 interestingX[0] = pos[0];
1761 interestingY[0] = pos[1];
1762 interestingZ[0] = pos[2];
1763
1764 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
1765 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
1766 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
1767 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
1768 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
e885fb81 1769 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
e3bd5504 1770 volDum = vol2[3];
1771 vol2[3] = vol2[4];
1772 vol2[4] = volDum;
e885fb81 1773 fTOFGeometry->GetPosPar(vol2,pos);
e3bd5504 1774 interestingX[1] = pos[0];
1775 interestingY[1] = pos[1];
1776 interestingZ[1] = pos[2];
1777
1778 AverageCalculations(2, interestingX, interestingY, interestingZ,
1779 interestingTOF, interestingTOT, interestingADC,
1780 interestingWeight,
1781 parTOF, posClus, check);
1782
1783 for (jj=0; jj<5; jj++) det[jj] = -1;
1784 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
e885fb81 1785 fTOFGeometry->GetDetID(posF, det);
e3bd5504 1786
e885fb81 1787 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
1788 //volIdClus = GetClusterVolIndex(det);
e3bd5504 1789
1790 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1791 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
1792 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
1793 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
1794 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
1795
1796 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1797 Int_t ** indDet = new Int_t*[2];
1798 for (jj=0; jj<2; jj++) indDet[jj] = new Int_t [5];
1799 for (jj=0; jj<2; jj++) indDet[jj][0] = nSector;
1800 for (jj=0; jj<2; jj++) indDet[jj][1] = nPlate;
1801 for (jj=0; jj<2; jj++) indDet[jj][2] = nStrip;
1802 for (jj=0; jj<2; jj++) indDet[jj][3] = padsCluster[2*jj+3];
1803 for (jj=0; jj<2; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
e885fb81 1804 GetClusterPars(/*check,*/ 2, indDet, interestingWeight, posClus, covClus);
e3bd5504 1805 for (jj=0; jj<2; jj++) delete [] indDet[jj];
1d834a1e 1806 delete [] indDet;
e3bd5504 1807
1808 // To fill the track index array
1809 dummyCounter=-1;
1810 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
1811 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1812 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
1813 else {
1814 dummyCounter++;
1815 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
1816 }
1817 }
1818 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
1819 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
1820 else {
1821
1822 alreadyStored = kFALSE;
1823 for (jj=0; jj<dummyCounter+1; jj++)
1824 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
1825
1826 if (alreadyStored) continue;
1827 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
1828 AliWarning(" Siamo al limite!");
1829 continue;
1830 }
1831
1832 dummyCounter++;
1833 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
1834
1835 }
1836
1837 }
1838
1839
1840 AliTOFcluster *tofCluster =
1841 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
1842 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1843 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
1844 InsertCluster(tofCluster);
1845
e885fb81 1846 AliDebug(2, Form(" %4d %f %f %f %f %f %f %f %f %f %3d %3d %3d %2d %1d %2d %1d %2d %4d %3d %3d %4d %4d %1d %4d",
e3bd5504 1847 volIdClus, posClus[0], posClus[1], posClus[2],
1848 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
1849 tracks[0], tracks[1], tracks[2],
1850 det[0], det[1], det[2], det[3], det[4],
1851 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
1852 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
1853
1854 volDum = vol1[3];
1855 vol1[3] = vol1[4];
1856 vol1[4] = volDum;
1857 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
1858 volDum = vol2[3];
1859 vol2[3] = vol2[4];
1860 vol2[4] = volDum;
1861 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
1862
1863
1864 } // close loop on second digit
1865 } // close loop on adesso2
1866
1867 } // close loop on first digit
1868 } // close loop on adesso1
1869
1870 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1871 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
1872 selectedDigit[ii][jj] = 0x0;
1873
1874 } // loop on iPad
1875
ed1f8475 1876 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++) {
e3bd5504 1877 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
ed1f8475 1878 delete [] selectedDigit[ii][jj];
e3bd5504 1879 selectedDigit[ii][jj] = 0x0;
1880 }
ed1f8475 1881 delete [] selectedDigit[ii];
1882 selectedDigit[ii] = 0x0;
1883 }
b5ed6afb 1884 delete [] selectedDigit;
ed1f8475 1885 selectedDigit = 0x0;
e3bd5504 1886
1887}
1888//_____________________________________________________________________________
1889
1890void AliTOFClusterFinderV1::FindClusters24(Int_t nSector,
1891 Int_t nPlate,
1892 Int_t nStrip)
1893{
1894 //
1895 // This function searches the neighbouring digits (stored in the fDigits object),
1896 // to perform clusters (stored in the fTofClusters array).
1897 //
1898 // This research has been made by checking the fTOFdigitMap object,
1899 // filled at digits/raw-data reading time.
1900 //
1901
1902 const Int_t kMaxNumberOfInterestingPads = 4;
1903 const Int_t kMaxNumberOfTracksPerDigit = 3;
cc7a1acd 1904 const Int_t kMaxNumberOfDigitsPerVolume = 10;
e3bd5504 1905
1906 Int_t ii = 0;
1907
1908 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
1909 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
1910 digitsInVolumeIndices[ii] = -1;
1911
e3bd5504 1912 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
1913
1914 Float_t pos[3] = {0.,0.,0.};
1915
1916 Int_t jj = 0;
1917 Int_t interestingPadX[kMaxNumberOfInterestingPads];
1918 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
1919 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
1920 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
1921 Double_t interestingTOT[kMaxNumberOfInterestingPads];
1922 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
1923 Double_t interestingADC[kMaxNumberOfInterestingPads];
1924 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
1925 Double_t interestingTOF[kMaxNumberOfInterestingPads];
1926 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
1927 Double_t interestingWeight[kMaxNumberOfInterestingPads];
1928 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
1929
1930 Float_t interestingX[kMaxNumberOfInterestingPads];
1931 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
1932 Float_t interestingY[kMaxNumberOfInterestingPads];
1933 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
1934 Float_t interestingZ[kMaxNumberOfInterestingPads];
1935 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
1936
1937 Float_t interDigit[kMaxNumberOfInterestingPads];
1938 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
1939
1940 Int_t padsCluster[11];
1941 padsCluster[0] = nSector;
1942 padsCluster[1] = nPlate;
1943 padsCluster[2] = nStrip;
1944 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
1945
1946 Int_t interestingCounter=-1;
e885fb81 1947 Int_t digitIndexLocal = -1;
e3bd5504 1948 Int_t iPad = -1;
1949 Int_t iPadX = -1;
1950 Int_t iPadZ = -1;
1951
1952 Bool_t check = kFALSE;
1d834a1e 1953 Int_t parTOF[7];
1954 for (jj=0; jj<7; jj++) parTOF[jj] = 0;
e3bd5504 1955 Double_t posClus[3];
1956 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
1957 Int_t det[5];
1958 for (jj=0; jj<5; jj++) det[jj] = -1;
1959 Float_t posF[3];
1960 for (jj=0; jj<3; jj++) posF[jj] = 0.;
1961 UShort_t volIdClus = 0;
1962 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
1963 Double_t covClus[6];
1964 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
1965 Int_t tracks[kMaxNumberOfTracksPerDigit];
ed1f8475 1966 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
e3bd5504 1967 Int_t dummyCounter=-1;
1968 Bool_t alreadyStored = kFALSE;
1969
1970 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
1971 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1972 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
1973
1974 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
1975 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
1976
1977 AliTOFdigit *digitInteresting;
1978
1979 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
1980
1981 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
1982 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
1983
e885fb81 1984 AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
e3bd5504 1985
1986
1987
1988
1989
1990
1991 interestingCounter=-1;
1992
1993 vol[4] = iPadZ , vol[3] = iPadX;
1994 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1995 interestingCounter++;
1996
1997 vol[4] = iPadZ, vol[3] = iPadX+1;
1998 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
1999 interestingCounter++;
2000
2001 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
2002 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2003 interestingCounter++;
2004
2005 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
2006 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2007 interestingCounter++;
2008
2009 if (interestingCounter+1!=4) continue; // the hit pads have to be 4
2010 else interestingCounter=-1;
2011
2012
2013 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2014 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
2015 selectedDigit[ii][jj] = 0x0;
2016
2017
2018 vol[4] = iPadZ, vol[3] = iPadX;
2019
2020 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2021 interestingCounter++;
2022 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2023 digitsInVolumeIndices[ii] = -1;
2024 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
e885fb81 2025 digitIndexLocal=-1; // AdC
e3bd5504 2026 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2027 if (digitsInVolumeIndices[digIndex]<0) continue;
2028 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
e885fb81 2029 if (digitInteresting->GetToT()<=0) continue; // AdC
2030 digitIndexLocal++; // AdC
e3bd5504 2031
4682c56e 2032 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
e3bd5504 2033 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2034 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2035 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2036 digitsInVolumeIndices[digIndex],
2037 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2038
e885fb81 2039 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
e3bd5504 2040 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2041 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2042 digitInteresting->GetToT()*digitInteresting->GetToT(),
2043 digitsInVolumeIndices[digIndex],
2044 digitInteresting->GetTracks());
2045 }
e885fb81 2046 if (digitIndexLocal==-1) interestingCounter--; // AdC
e3bd5504 2047 }
2048
2049
2050 vol[4] = iPadZ, vol[3] = iPadX+1;
2051
2052 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2053 interestingCounter++;
2054 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2055 digitsInVolumeIndices[ii] = -1;
2056 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
e885fb81 2057 digitIndexLocal=-1; // AdC
e3bd5504 2058 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2059 if (digitsInVolumeIndices[digIndex]<0) continue;
2060 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
e885fb81 2061 if (digitInteresting->GetToT()<=0) continue; // AdC
2062 digitIndexLocal++; // AdC
e3bd5504 2063
4682c56e 2064 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
e3bd5504 2065 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2066 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2067 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2068 digitsInVolumeIndices[digIndex],
2069 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2070
e885fb81 2071 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
e3bd5504 2072 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2073 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2074 digitInteresting->GetToT()*digitInteresting->GetToT(),
2075 digitsInVolumeIndices[digIndex],
2076 digitInteresting->GetTracks());
2077 }
e885fb81 2078 if (digitIndexLocal==-1) interestingCounter--; // AdC
e3bd5504 2079 }
2080
2081
2082 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
2083
2084 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2085 interestingCounter++;
2086 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2087 digitsInVolumeIndices[ii] = -1;
2088 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
e885fb81 2089 digitIndexLocal=-1; // AdC
e3bd5504 2090 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2091 if (digitsInVolumeIndices[digIndex]<0) continue;
2092 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
e885fb81 2093 if (digitInteresting->GetToT()<=0) continue; // AdC
2094 digitIndexLocal++; // AdC
e3bd5504 2095
4682c56e 2096 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
e3bd5504 2097 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2098 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2099 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2100 digitsInVolumeIndices[digIndex],
2101 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2102
e885fb81 2103 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
e3bd5504 2104 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2105 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2106 digitInteresting->GetToT()*digitInteresting->GetToT(),
2107 digitsInVolumeIndices[digIndex],
2108 digitInteresting->GetTracks());
2109 }
e885fb81 2110 if (digitIndexLocal==-1) interestingCounter--; // AdC
e3bd5504 2111 }
2112
2113
2114 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
2115
2116 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2117 interestingCounter++;
2118 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2119 digitsInVolumeIndices[ii] = -1;
2120 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
e885fb81 2121 digitIndexLocal=-1; // AdC
e3bd5504 2122 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2123 if (digitsInVolumeIndices[digIndex]<0) continue;
2124 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
e885fb81 2125 if (digitInteresting->GetToT()<=0) continue; // AdC
2126 digitIndexLocal++; // AdC
e3bd5504 2127
4682c56e 2128 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
e3bd5504 2129 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2130 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2131 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2132 digitsInVolumeIndices[digIndex],
2133 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
2134
e885fb81 2135 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
e3bd5504 2136 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2137 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2138 digitInteresting->GetToT()*digitInteresting->GetToT(),
2139 digitsInVolumeIndices[digIndex],
2140 digitInteresting->GetTracks());
2141 }
e885fb81 2142 if (digitIndexLocal==-1) interestingCounter--; // AdC
e3bd5504 2143 }
2144
e885fb81 2145 AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
e3bd5504 2146
2147 for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
2148 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2149 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2150
2151 for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
2152 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2153 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2154
2155 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime) continue;
2156
2157 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2158 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2159 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2160 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2161 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
e885fb81 2162 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
e3bd5504 2163 Int_t volDum = vol1[3];
2164 vol1[3] = vol1[4];
2165 vol1[4] = volDum;
e885fb81 2166 fTOFGeometry->GetPosPar(vol1,pos);
e3bd5504 2167 interestingX[0] = pos[0];
2168 interestingY[0] = pos[1];
2169 interestingZ[0] = pos[2];
2170
2171 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2172 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2173 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2174 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2175 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
e885fb81 2176 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
e3bd5504 2177 volDum = vol2[3];
2178 vol2[3] = vol2[4];
2179 vol2[4] = volDum;
e885fb81 2180 fTOFGeometry->GetPosPar(vol2,pos);
e3bd5504 2181 interestingX[1] = pos[0];
2182 interestingY[1] = pos[1];
2183 interestingZ[1] = pos[2];
2184
2185
2186 AverageCalculations(2, interestingX, interestingY, interestingZ,
2187 interestingTOF, interestingTOT, interestingADC,
2188 interestingWeight,
2189 parTOF, posClus, check);
2190
2191 for (jj=0; jj<5; jj++) det[jj] = -1;
2192 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
e885fb81 2193 fTOFGeometry->GetDetID(posF, det);
e3bd5504 2194
e885fb81 2195 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
2196 //volIdClus = GetClusterVolIndex(det);
e3bd5504 2197
2198 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2199 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
2200 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
2201 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
2202 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
2203
2204 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2205 Int_t ** indDet = new Int_t*[2];
2206 for (jj=0; jj<2; jj++) indDet[jj] = new Int_t [5];
2207 for (jj=0; jj<2; jj++) indDet[jj][0] = nSector;
2208 for (jj=0; jj<2; jj++) indDet[jj][1] = nPlate;
2209 for (jj=0; jj<2; jj++) indDet[jj][2] = nStrip;
2210 for (jj=0; jj<2; jj++) indDet[jj][3] = padsCluster[2*jj+3];
2211 for (jj=0; jj<2; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
e885fb81 2212 GetClusterPars(/*check,*/ 2, indDet, interestingWeight, posClus, covClus);
e3bd5504 2213 for (jj=0; jj<2; jj++) delete [] indDet[jj];
1d834a1e 2214 delete [] indDet;
e3bd5504 2215
2216 // To fill the track index array
2217 dummyCounter=-1;
2218 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2219 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2220 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
2221 else {
2222 dummyCounter++;
2223 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
2224 }
2225 }
2226 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2227 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
2228 else {
2229
2230 alreadyStored = kFALSE;
2231 for (jj=0; jj<dummyCounter+1; jj++)
2232 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
2233
2234 if (alreadyStored) continue;
2235 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2236 AliWarning(" Siamo al limite!");
2237 continue;
2238 }
2239
2240 dummyCounter++;
2241 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
2242
2243 }
2244
2245 }
2246
2247
2248 AliTOFcluster *tofCluster =
2249 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
2250 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2251 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
2252 InsertCluster(tofCluster);
2253
e885fb81 2254 AliDebug(2, Form(" %4d %f %f %f %f %f %f %f %f %f %3d %3d %3d %2d %1d %2d %1d %2d %4d %3d %3d %4d %4d %1d %4d",
e3bd5504 2255 volIdClus, posClus[0], posClus[1], posClus[2],
2256 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2257 tracks[0], tracks[1], tracks[2],
2258 det[0], det[1], det[2], det[3], det[4],
2259 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
2260 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
2261
2262 volDum = vol1[3];
2263 vol1[3] = vol1[4];
2264 vol1[4] = volDum;
2265 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
2266 volDum = vol2[3];
2267 vol2[3] = vol2[4];
2268 vol2[4] = volDum;
2269 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
2270
2271
2272 } // close loop on second digit
2273 } // close loop on adesso2
2274
2275 } // close loop on first digit
2276 } // close loop on adesso1
2277
2278 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2279 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
2280 selectedDigit[ii][jj] = 0x0;
2281
2282 } // loop on iPad
2283
ed1f8475 2284 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++) {
e3bd5504 2285 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
ed1f8475 2286 delete [] selectedDigit[ii][jj];
e3bd5504 2287 selectedDigit[ii][jj] = 0x0;
2288 }
ed1f8475 2289 delete [] selectedDigit[ii];
2290 selectedDigit[ii] = 0x0;
2291 }
b5ed6afb 2292 delete [] selectedDigit;
ed1f8475 2293 selectedDigit = 0x0;
e3bd5504 2294
2295}
2296//_____________________________________________________________________________
2297
2298void AliTOFClusterFinderV1::FindClustersPerStrip(Int_t nSector,
2299 Int_t nPlate,
2300 Int_t nStrip,
2301 Int_t group)
2302{
2303 //
2304 // This function searches the neighbouring digits (stored in the fDigits object),
2305 // to perform clusters (stored in the fTofClusters array).
2306 //
2307 // Each strip is read four times:
2308 // - 1st time: it searches possible clusters formed by four
2309 // neighbouring digits;
2310 // - 2nd time: it searches possible clusters formed by three
2311 // neighbouring digits;
2312 // - 3rd time: it searches possible clusters formed by two
2313 // neighbouring digits;
2314 // - 4th time: the remaining isolated digits have been transformed
2315 // in clusters.
2316 // This research has been made by checking the fTOFdigitMap object,
2317 // filled at digits/raw-data reading time.
2318 //
2319
2320 const Int_t kMaxNumberOfInterestingPads = 4;
2321 const Int_t kMaxNumberOfTracksPerDigit = 3;
cc7a1acd 2322 const Int_t kMaxNumberOfDigitsPerVolume = 10;
e3bd5504 2323
2324 Int_t ii = 0;
2325
2326 Int_t digitsInVolumeIndices[kMaxNumberOfDigitsPerVolume];
2327 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2328 digitsInVolumeIndices[ii] = -1;
2329
e3bd5504 2330 Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
2331
2332 Float_t pos[3] = {0.,0.,0.};
2333
2334 Int_t jj = 0;
2335 Int_t interestingPadX[kMaxNumberOfInterestingPads];
2336 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadX[jj] = -1;
2337 Int_t interestingPadZ[kMaxNumberOfInterestingPads];
2338 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingPadZ[jj] = -1;
2339 Double_t interestingTOT[kMaxNumberOfInterestingPads];
2340 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOT[jj] = 0;
2341 Double_t interestingADC[kMaxNumberOfInterestingPads];
2342 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingADC[jj] = 0;
2343 Double_t interestingTOF[kMaxNumberOfInterestingPads];
2344 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingTOF[jj] = 0;
2345 Double_t interestingWeight[kMaxNumberOfInterestingPads];
2346 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingWeight[jj] = 0;
2347
2348 Float_t interestingX[kMaxNumberOfInterestingPads];
2349 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingX[jj] = 0;
2350 Float_t interestingY[kMaxNumberOfInterestingPads];
2351 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingY[jj] = 0;
2352 Float_t interestingZ[kMaxNumberOfInterestingPads];
2353 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interestingZ[jj] = 0;
2354
2355 Float_t interDigit[kMaxNumberOfInterestingPads];
2356 for (jj=0; jj<kMaxNumberOfInterestingPads; jj++) interDigit[jj] = 0;
2357
2358 Int_t padsCluster[11];
2359 padsCluster[0] = nSector;
2360 padsCluster[1] = nPlate;
2361 padsCluster[2] = nStrip;
2362 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2363
2364 Int_t interestingCounter=-1;
e885fb81 2365 Int_t digitIndexLocal = -1;
e3bd5504 2366 Int_t iPad = -1;
2367 Int_t iPadX = -1;
2368 Int_t iPadZ = -1;
2369
2370 Bool_t check = kFALSE;
1d834a1e 2371 Int_t parTOF[7];
2372 for (jj=0; jj<7; jj++) parTOF[jj] = 0;
e3bd5504 2373 Double_t posClus[3];
2374 for (jj=0; jj<3; jj++) posClus[jj] = 0.;
2375 Int_t det[5];
2376 for (jj=0; jj<5; jj++) det[jj] = -1;
2377 Float_t posF[3];
2378 for (jj=0; jj<3; jj++) posF[jj] = 0.;
2379 UShort_t volIdClus = 0;
2380 Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
2381 Double_t covClus[6];
2382 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2383 Int_t tracks[kMaxNumberOfTracksPerDigit];
ed1f8475 2384 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
e3bd5504 2385 Int_t dummyCounter=-1;
2386 Bool_t alreadyStored = kFALSE;
2387
2388 AliTOFselectedDigit ***selectedDigit = new AliTOFselectedDigit**[kMaxNumberOfInterestingPads];
2389 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2390 selectedDigit[ii] = new AliTOFselectedDigit*[kMaxNumberOfDigitsPerVolume];
2391
2392 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2393 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) selectedDigit[ii][jj] = 0x0;
2394
2395 AliTOFdigit *digitInteresting;
2396
2397 group = group-1;
2398
2399 for (iPad=0; iPad<AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX()-3; iPad+=2) {
2400
2401 iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
2402 iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
2403
e885fb81 2404 AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
e3bd5504 2405
2406
2407
2408
2409
2410
2411 interestingCounter=-1;
2412
2413 vol[4] = iPadZ , vol[3] = iPadX;
2414 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2415 interestingCounter++;
2416
2417 vol[4] = iPadZ, vol[3] = iPadX+1;
2418 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2419 interestingCounter++;
2420
2421 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
2422 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2423 interestingCounter++;
2424
2425 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
2426 if (fTOFdigitMap->GetNumberOfDigits(vol)>0)
2427 interestingCounter++;
2428
2429 if (interestingCounter!=group) continue;
2430 else interestingCounter=-1;
2431
2432
2433 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
2434 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
2435 selectedDigit[ii][jj] = 0x0;
2436
2437
2438 vol[4] = iPadZ, vol[3] = iPadX;
2439
2440 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2441 interestingCounter++;
2442 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2443 digitsInVolumeIndices[ii] = -1;
2444 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
e885fb81 2445 digitIndexLocal=-1; // AdC
e3bd5504 2446 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2447 if (digitsInVolumeIndices[digIndex]<0) continue;
2448 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
e885fb81 2449 if (digitInteresting->GetToT()<=0) continue; // AdC
2450 digitIndexLocal++; // AdC
e3bd5504 2451
e885fb81 2452 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
e3bd5504 2453 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2454 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2455 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2456 digitsInVolumeIndices[digIndex],
2457 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
e885fb81 2458 AliDebug(1,Form(" to try %d %d ",digIndex, interestingCounter));
e3bd5504 2459
e885fb81 2460 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
e3bd5504 2461 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2462 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2463 digitInteresting->GetToT()*digitInteresting->GetToT(),
2464 digitsInVolumeIndices[digIndex],
2465 digitInteresting->GetTracks());
2466 }
e885fb81 2467 if (digitIndexLocal==-1) interestingCounter--; // AdC
e3bd5504 2468 }
2469
2470
2471 vol[4] = iPadZ, vol[3] = iPadX+1;
2472
2473 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2474 interestingCounter++;
2475 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2476 digitsInVolumeIndices[ii] = -1;
2477 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
e885fb81 2478 digitIndexLocal=-1; // AdC
e3bd5504 2479 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2480 if (digitsInVolumeIndices[digIndex]<0) continue;
2481 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
e885fb81 2482 if (digitInteresting->GetToT()<=0) continue; // AdC
2483 digitIndexLocal++; // AdC
e3bd5504 2484
e885fb81 2485 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
e3bd5504 2486 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2487 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2488 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2489 digitsInVolumeIndices[digIndex],
2490 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
e885fb81 2491 AliDebug(1,Form(" to try %d %d ",digIndex, interestingCounter));
e3bd5504 2492
e885fb81 2493 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
e3bd5504 2494 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2495 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2496 digitInteresting->GetToT()*digitInteresting->GetToT(),
2497 digitsInVolumeIndices[digIndex],
2498 digitInteresting->GetTracks());
2499 }
e885fb81 2500 if (digitIndexLocal==-1) interestingCounter--; // AdC
e3bd5504 2501 }
2502
2503
2504 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX;
2505
2506 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2507 interestingCounter++;
2508 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2509 digitsInVolumeIndices[ii] = -1;
2510 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
e885fb81 2511 digitIndexLocal=-1; // AdC
e3bd5504 2512 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2513 if (digitsInVolumeIndices[digIndex]<0) continue;
2514 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
e885fb81 2515 if (digitInteresting->GetToT()<=0) continue; // AdC
2516 digitIndexLocal++; // AdC
e3bd5504 2517
e885fb81 2518 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
e3bd5504 2519 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2520 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2521 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2522 digitsInVolumeIndices[digIndex],
2523 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
e885fb81 2524 AliDebug(1,Form(" to try %d %d ",digIndex, interestingCounter));
e3bd5504 2525
e885fb81 2526 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
e3bd5504 2527 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2528 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2529 digitInteresting->GetToT()*digitInteresting->GetToT(),
2530 digitsInVolumeIndices[digIndex],
2531 digitInteresting->GetTracks());
2532 }
e885fb81 2533 if (digitIndexLocal==-1) interestingCounter--; // AdC
e3bd5504 2534 }
2535
2536
2537 vol[4] = AliTOFGeometry::NpadZ()-(iPadZ+1), vol[3] = iPadX+1;
2538
2539 if (fTOFdigitMap->GetNumberOfDigits(vol)>0) {
2540 interestingCounter++;
2541 for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
2542 digitsInVolumeIndices[ii] = -1;
2543 fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
e885fb81 2544 digitIndexLocal=-1; // AdC
e3bd5504 2545 for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
2546 if (digitsInVolumeIndices[digIndex]<0) continue;
2547 digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
e885fb81 2548 if (digitInteresting->GetToT()<=0) continue; // AdC
2549 digitIndexLocal++; // AdC
e3bd5504 2550
e885fb81 2551 AliDebug(1,Form(" %2d %1d %2d %1d %2d %d %d %d %d %5d %5d %5d %5d",
e3bd5504 2552 vol[0], vol[1], vol[2] ,vol[4], vol[3],
2553 digitInteresting->GetTdc(), digitInteresting->GetAdc(),
2554 digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
2555 digitsInVolumeIndices[digIndex],
2556 digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
e885fb81 2557 AliDebug(1,Form(" to try %d %d ",digIndex, interestingCounter));
e3bd5504 2558
e885fb81 2559 selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
e3bd5504 2560 AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
2561 digitInteresting->GetAdc(), digitInteresting->GetToT(),
2562 digitInteresting->GetToT()*digitInteresting->GetToT(),
2563 digitsInVolumeIndices[digIndex],
2564 digitInteresting->GetTracks());
2565 }
e885fb81 2566 if (digitIndexLocal==-1) interestingCounter--; // AdC
e3bd5504 2567 }
2568
e885fb81 2569 AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
e3bd5504 2570
d7ed6a6d 2571 Int_t adesso1 = -1;
2572 Int_t adesso2 = -1;
2573 Int_t adesso3 = -1;
2574 Int_t adesso4 = -1;
2575
e3bd5504 2576 switch(interestingCounter+1) {
2577
2578 case 2:
2579
d7ed6a6d 2580 //for (adesso1=0; adesso1<interestingCounter+1; adesso1++) {
2581 adesso1 = 0;
e3bd5504 2582 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2583 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2584
d7ed6a6d 2585 //for (adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
2586 adesso2 = 1;
e3bd5504 2587 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2588 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2589
d7ed6a6d 2590 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime) {
2591 AliDebug(1,Form(" selD1[%d][%d]->GetTDC()=%d selD2[%d][%d]->GetTDC()=%d -- %d ",
ed1f8475 2592 adesso1,firstIndex,(Int_t)selectedDigit[adesso1][firstIndex]->GetTDC(),
2593 adesso2,secondIndex,(Int_t)selectedDigit[adesso2][secondIndex]->GetTDC(),
d7ed6a6d 2594 fMaxDeltaTime));
2595 continue;
2596 }
e3bd5504 2597
4682c56e 2598 AliDebug(1, Form(" %1d %1d (0x%p) %1d %1d (0x%p)", adesso1, firstIndex,selectedDigit[adesso1][firstIndex],
e3bd5504 2599 adesso2, secondIndex,selectedDigit[adesso2][secondIndex]));
2600
2601 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2602 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2603 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2604 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2605 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
e885fb81 2606 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
e3bd5504 2607 Int_t volDum = vol1[3];
2608 vol1[3] = vol1[4];
2609 vol1[4] = volDum;
e885fb81 2610 fTOFGeometry->GetPosPar(vol1,pos);
e3bd5504 2611 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
2612 interestingX[0] = pos[0];
2613 interestingY[0] = pos[1];
2614 interestingZ[0] = pos[2];
2615
2616 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2617 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2618 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2619 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2620 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
e885fb81 2621 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
e3bd5504 2622 volDum = vol2[3];
2623 vol2[3] = vol2[4];
2624 vol2[4] = volDum;
e885fb81 2625 fTOFGeometry->GetPosPar(vol2,pos);
e3bd5504 2626 AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
2627 interestingX[1] = pos[0];
2628 interestingY[1] = pos[1];
2629 interestingZ[1] = pos[2];
2630
2631
2632 AverageCalculations(interestingCounter+1,
2633 interestingX, interestingY, interestingZ,
2634 interestingTOF, interestingTOT, interestingADC,
2635 interestingWeight,
2636 parTOF, posClus, check);
2637
2638 for (jj=0; jj<5; jj++) det[jj] = -1;
2639 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
2640
2641 AliDebug(1,Form(" %f %f %f", posF[0], posF[1], posF[2]));
e885fb81 2642 fTOFGeometry->GetDetID(posF, det);
2643 AliDebug(1,Form(" %2d %1d %2d %1d %2d", det[0], det[1], det[2], det[3], det[4]));
e3bd5504 2644
e885fb81 2645 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
2646 //volIdClus = GetClusterVolIndex(det);
e3bd5504 2647
2648 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2649 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
2650 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
2651 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
2652 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
2653
2654 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2655 Int_t ** indDet = new Int_t*[interestingCounter+1];
2656 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj] = new Int_t [5];
2657 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][0] = nSector;
2658 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][1] = nPlate;
2659 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][2] = nStrip;
2660 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][3] = padsCluster[2*jj+3];
2661 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
e885fb81 2662 GetClusterPars(/*check,*/ interestingCounter+1, indDet, interestingWeight, posClus, covClus);
e3bd5504 2663 for (jj=0; jj<interestingCounter+1; jj++) delete [] indDet[jj];
1d834a1e 2664 delete [] indDet;
e3bd5504 2665
2666 // To fill the track index array
2667 dummyCounter=-1;
2668 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2669 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2670 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
2671 else {
2672 dummyCounter++;
2673 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
2674 }
2675 }
2676 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2677 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
2678 else {
2679
2680 alreadyStored = kFALSE;
2681 for (jj=0; jj<dummyCounter+1; jj++)
2682 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
2683
2684 if (alreadyStored) continue;
2685 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2686 AliWarning(" Siamo al limite!");
2687 continue;
2688 }
2689
2690 dummyCounter++;
2691 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
2692
2693 }
2694
2695 }
2696
2697
2698 AliTOFcluster *tofCluster =
2699 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
2700 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2701 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); //to updated
2702 InsertCluster(tofCluster);
2703
e885fb81 2704 AliDebug(2, Form(" %4d %f %f %f %f %f %f %f %f %f %3d %3d %3d %2d %1d %2d %1d %2d %4d %3d %3d %4d %4d %1d %4d",
e3bd5504 2705 volIdClus, posClus[0], posClus[1], posClus[2],
2706 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2707 tracks[0], tracks[1], tracks[2],
2708 det[0], det[1], det[2], det[3], det[4],
2709 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
2710 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
2711
2712 volDum = vol1[3];
2713 vol1[3] = vol1[4];
2714 vol1[4] = volDum;
2715 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
2716 volDum = vol2[3];
2717 vol2[3] = vol2[4];
2718 vol2[4] = volDum;
2719 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
2720
2721
2722 } // close loop on second digit
d7ed6a6d 2723 //} // close loop on adesso2
e3bd5504 2724
2725 } // close loop on first digit
d7ed6a6d 2726 //} // close loop on adesso1
e3bd5504 2727
2728
2729 break;
2730
2731 case 3:
2732
d7ed6a6d 2733 //for (adesso1=0; adesso1<interestingCounter+1; adesso1++) {
2734 adesso1 = 0;
e3bd5504 2735 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2736 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2737
d7ed6a6d 2738 //for (adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
2739 adesso2 = 1;
e3bd5504 2740 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2741 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2742
d7ed6a6d 2743 //for (adesso3=adesso2+1; adesso3<interestingCounter+1; adesso3++) {
2744 adesso3 = 2;
e3bd5504 2745 for (Int_t thirdIndex=0; thirdIndex<kMaxNumberOfDigitsPerVolume; thirdIndex++) {
2746 if (selectedDigit[adesso3][thirdIndex]==0x0) continue;
2747
2748
2749 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime
2750 ||
2751 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
2752 ||
2753 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime) continue;
2754
2755 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2756 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2757 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2758 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2759 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
e885fb81 2760 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
e3bd5504 2761 Int_t volDum = vol1[3];
2762 vol1[3] = vol1[4];
2763 vol1[4] = volDum;
e885fb81 2764 fTOFGeometry->GetPosPar(vol1,pos);
e3bd5504 2765 interestingX[0] = pos[0];
2766 interestingY[0] = pos[1];
2767 interestingZ[0] = pos[2];
2768
2769 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2770 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2771 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2772 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2773 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
e885fb81 2774 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
e3bd5504 2775 volDum = vol2[3];
2776 vol2[3] = vol2[4];
2777 vol2[4] = volDum;
e885fb81 2778 fTOFGeometry->GetPosPar(vol2,pos);
e3bd5504 2779 interestingX[1] = pos[0];
2780 interestingY[1] = pos[1];
2781 interestingZ[1] = pos[2];
2782
2783 interestingTOF[2] = selectedDigit[adesso3][thirdIndex]->GetTDC();
2784 interestingTOT[2] = selectedDigit[adesso3][thirdIndex]->GetTOT();
2785 interestingADC[2] = selectedDigit[adesso3][thirdIndex]->GetADC();
2786 interestingWeight[2] = selectedDigit[adesso3][thirdIndex]->GetWeight();
2787 Int_t vol3[5]; for(jj=0; jj<5; jj++) vol3[jj] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(jj);
e885fb81 2788 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol3[0], vol3[1], vol3[2], vol3[4], vol3[3]));
e3bd5504 2789 volDum = vol3[3];
2790 vol3[3] = vol3[4];
2791 vol3[4] = volDum;
e885fb81 2792 fTOFGeometry->GetPosPar(vol3,pos);
e3bd5504 2793 interestingX[2] = pos[0];
2794 interestingY[2] = pos[1];
2795 interestingZ[2] = pos[2];
2796
2797
2798 AverageCalculations(interestingCounter+1,
2799 interestingX, interestingY, interestingZ,
2800 interestingTOF, interestingTOT, interestingADC,
2801 interestingWeight,
2802 parTOF, posClus, check);
2803
2804 for (jj=0; jj<5; jj++) det[jj] = -1;
2805 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
e885fb81 2806 fTOFGeometry->GetDetID(posF, det);
e3bd5504 2807
e885fb81 2808 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
2809 //volIdClus = GetClusterVolIndex(det);
e3bd5504 2810
2811 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
2812 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
2813 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
2814 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
2815 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
2816 padsCluster[7] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(4);
2817 padsCluster[8] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(3);
2818
2819 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
2820 Int_t ** indDet = new Int_t*[interestingCounter+1];
2821 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj] = new Int_t [5];
2822 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][0] = nSector;
2823 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][1] = nPlate;
2824 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][2] = nStrip;
2825 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][3] = padsCluster[2*jj+3];
2826 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
e885fb81 2827 GetClusterPars(/*check,*/ interestingCounter+1, indDet, interestingWeight, posClus, covClus);
e3bd5504 2828 for (jj=0; jj<interestingCounter+1; jj++) delete [] indDet[jj];
1d834a1e 2829 delete [] indDet;
2830
e3bd5504 2831
2832 // To fill the track index array
2833 dummyCounter=-1;
2834 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
2835 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2836 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
2837 else {
2838 dummyCounter++;
2839 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
2840 }
2841 }
2842 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2843 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
2844 else {
2845
2846 alreadyStored = kFALSE;
2847 for (jj=0; jj<dummyCounter+1; jj++)
2848 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
2849
2850 if (alreadyStored) continue;
2851 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2852 AliWarning(" Siamo al limite!");
2853 continue;
2854 }
2855
2856 dummyCounter++;
2857 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
2858
2859 }
2860
2861 }
2862 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
2863 if (selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk)==-1) continue;
2864 else {
2865
2866 alreadyStored = kFALSE;
2867 for (jj=0; jj<dummyCounter+1; jj++)
2868 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk));
2869
2870 if (alreadyStored) continue;
2871 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
2872 AliWarning(" Siamo al limite!");
2873 continue;
2874 }
2875
2876 dummyCounter++;
2877 tracks[dummyCounter] = selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk);
2878
2879 }
2880
2881 }
2882
2883
2884 AliTOFcluster *tofCluster =
2885 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
2886 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2887 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
2888 InsertCluster(tofCluster);
2889
e885fb81 2890 AliDebug(2, Form(" %4d %f %f %f %f %f %f %f %f %f %3d %3d %3d %2d %1d %2d %1d %2d %4d %3d %3d %4d %4d %1d %4d",
e3bd5504 2891 volIdClus, posClus[0], posClus[1], posClus[2],
2892 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
2893 tracks[0], tracks[1], tracks[2],
2894 det[0], det[1], det[2], det[3], det[4],
2895 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
2896 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
2897
2898 volDum = vol1[3];
2899 vol1[3] = vol1[4];
2900 vol1[4] = volDum;
2901 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
2902 volDum = vol2[3];
2903 vol2[3] = vol2[4];
2904 vol2[4] = volDum;
2905 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
2906 volDum = vol3[3];
2907 vol3[3] = vol3[4];
2908 vol3[4] = volDum;
2909 fTOFdigitMap->ResetDigitNumber(vol3,selectedDigit[adesso3][thirdIndex]->GetIndex());
2910
2911
2912 } // close loop on third digit
d7ed6a6d 2913 //} // close loop on adesso3
e3bd5504 2914
2915 } // close loop on second digit
d7ed6a6d 2916 //} // close loop on adesso2
e3bd5504 2917
2918 } // close loop on first digit
d7ed6a6d 2919 //} // close loop on adesso1
e3bd5504 2920
2921
2922 break;
2923
2924 case 4:
2925
d7ed6a6d 2926 adesso1 = 0;
e3bd5504 2927 for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
2928 if (selectedDigit[adesso1][firstIndex]==0x0) continue;
2929
d7ed6a6d 2930 adesso2 = 1;
e3bd5504 2931 for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
2932 if (selectedDigit[adesso2][secondIndex]==0x0) continue;
2933
d7ed6a6d 2934 adesso3 = 2;
e3bd5504 2935 for (Int_t thirdIndex=0; thirdIndex<kMaxNumberOfDigitsPerVolume; thirdIndex++) {
2936 if (selectedDigit[adesso3][thirdIndex]==0x0) continue;
2937
d7ed6a6d 2938 adesso4 = 3;
e3bd5504 2939 for (Int_t fourthIndex=0; fourthIndex<kMaxNumberOfDigitsPerVolume; fourthIndex++) {
2940 if (selectedDigit[adesso4][fourthIndex]==0x0) continue;
2941
2942
2943 if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime
2944 ||
2945 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
2946 ||
2947 TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso4][fourthIndex]->GetTDC())>fMaxDeltaTime
2948 ||
2949 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso3][thirdIndex]->GetTDC())>fMaxDeltaTime
2950 ||
2951 TMath::Abs(selectedDigit[adesso2][secondIndex]->GetTDC()-selectedDigit[adesso4][fourthIndex]->GetTDC())>fMaxDeltaTime
2952 ||
2953 TMath::Abs(selectedDigit[adesso3][thirdIndex]->GetTDC()-selectedDigit[adesso4][fourthIndex]->GetTDC())>fMaxDeltaTime) continue;
2954
2955 interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
2956 interestingTOT[0] = selectedDigit[adesso1][firstIndex]->GetTOT();
2957 interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
2958 interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
2959 Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
e885fb81 2960 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
e3bd5504 2961 Int_t volDum = vol1[3];
2962 vol1[3] = vol1[4];
2963 vol1[4] = volDum;
e885fb81 2964 fTOFGeometry->GetPosPar(vol1,pos);
e3bd5504 2965 interestingX[0] = pos[0];
2966 interestingY[0] = pos[1];
2967 interestingZ[0] = pos[2];
2968
2969 interestingTOF[1] = selectedDigit[adesso2][secondIndex]->GetTDC();
2970 interestingTOT[1] = selectedDigit[adesso2][secondIndex]->GetTOT();
2971 interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
2972 interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
2973 Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
e885fb81 2974 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
e3bd5504 2975 volDum = vol2[3];
2976 vol2[3] = vol2[4];
2977 vol2[4] = volDum;
e885fb81 2978 fTOFGeometry->GetPosPar(vol2,pos);
e3bd5504 2979 interestingX[1] = pos[0];
2980 interestingY[1] = pos[1];
2981 interestingZ[1] = pos[2];
2982
2983 interestingTOF[2] = selectedDigit[adesso3][thirdIndex]->GetTDC();
2984 interestingTOT[2] = selectedDigit[adesso3][thirdIndex]->GetTOT();
2985 interestingADC[2] = selectedDigit[adesso3][thirdIndex]->GetADC();
2986 interestingWeight[2] = selectedDigit[adesso3][thirdIndex]->GetWeight();
2987 Int_t vol3[5]; for(jj=0; jj<5; jj++) vol3[jj] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(jj);
e885fb81 2988 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol3[0], vol3[1], vol3[2], vol3[4], vol3[3]));
e3bd5504 2989 volDum = vol3[3];
2990 vol3[3] = vol3[4];
2991 vol3[4] = volDum;
e885fb81 2992 fTOFGeometry->GetPosPar(vol3,pos);
e3bd5504 2993 interestingX[2] = pos[0];
2994 interestingY[2] = pos[1];
2995 interestingZ[2] = pos[2];
2996
2997 interestingTOF[3] = selectedDigit[adesso4][fourthIndex]->GetTDC();
2998 interestingTOT[3] = selectedDigit[adesso4][fourthIndex]->GetTOT();
2999 interestingADC[3] = selectedDigit[adesso4][fourthIndex]->GetADC();
3000 interestingWeight[3] = selectedDigit[adesso4][fourthIndex]->GetWeight();
3001 Int_t vol4[5]; for(jj=0; jj<5; jj++) vol4[jj] = selectedDigit[adesso4][fourthIndex]->GetDetectorIndex(jj);
e885fb81 3002 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol4[0], vol4[1], vol4[2], vol4[4], vol4[3]));
e3bd5504 3003 volDum = vol4[3];
3004 vol4[3] = vol4[4];
3005 vol4[4] = volDum;
e885fb81 3006 fTOFGeometry->GetPosPar(vol4,pos);
e3bd5504 3007 interestingX[3] = pos[0];
3008 interestingY[3] = pos[1];
3009 interestingZ[3] = pos[2];
3010
3011
3012 AverageCalculations(interestingCounter+1,
3013 interestingX, interestingY, interestingZ,
3014 interestingTOF, interestingTOT, interestingADC,
3015 interestingWeight,
3016 parTOF, posClus, check);
3017
3018 for (jj=0; jj<5; jj++) det[jj] = -1;
3019 for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
e885fb81 3020 fTOFGeometry->GetDetID(posF, det);
e3bd5504 3021
e885fb81 3022 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
3023 //volIdClus = GetClusterVolIndex(det);
e3bd5504 3024
3025 for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
3026 padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
3027 padsCluster[4] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(3);
3028 padsCluster[5] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(4);
3029 padsCluster[6] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(3);
3030 padsCluster[7] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(4);
3031 padsCluster[8] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(3);
3032 padsCluster[9] = selectedDigit[adesso4][fourthIndex]->GetDetectorIndex(4);
3033 padsCluster[10] = selectedDigit[adesso4][fourthIndex]->GetDetectorIndex(3);
3034
3035 for (jj=0; jj<6; jj++) covClus[jj] = 0.;
3036 Int_t ** indDet = new Int_t*[interestingCounter+1];
3037 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj] = new Int_t [5];
3038 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][0] = nSector;
3039 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][1] = nPlate;
3040 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][2] = nStrip;
3041 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][3] = padsCluster[2*jj+3];
3042 for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
e885fb81 3043 GetClusterPars(/*check,*/ interestingCounter+1, indDet, interestingWeight, posClus, covClus);
e3bd5504 3044 for (jj=0; jj<interestingCounter+1; jj++) delete [] indDet[jj];
1d834a1e 3045 delete [] indDet;
e3bd5504 3046
3047 // To fill the track index array
3048 dummyCounter=-1;
3049 for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
3050 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
3051 if (selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk)==-1) continue;
3052 else {
3053 dummyCounter++;
3054 tracks[dummyCounter] = selectedDigit[adesso1][firstIndex]->GetTrackLabel(kk);
3055 }
3056 }
3057 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
3058 if (selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk)==-1) continue;
3059 else {
3060
3061 alreadyStored = kFALSE;
3062 for (jj=0; jj<dummyCounter+1; jj++)
3063 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk));
3064
3065 if (alreadyStored) continue;
3066 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
3067 AliWarning(" Siamo al limite!");
3068 continue;
3069 }
3070
3071 dummyCounter++;
3072 tracks[dummyCounter] = selectedDigit[adesso2][secondIndex]->GetTrackLabel(kk);
3073
3074 }
3075
3076 }
3077 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
3078 if (selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk)==-1) continue;
3079 else {
3080
3081 alreadyStored = kFALSE;
3082 for (jj=0; jj<dummyCounter+1; jj++)
3083 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk));
3084
3085 if (alreadyStored) continue;
3086 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
3087 AliWarning(" Siamo al limite!");
3088 continue;
3089 }
3090
3091 dummyCounter++;
3092 tracks[dummyCounter] = selectedDigit[adesso3][thirdIndex]->GetTrackLabel(kk);
3093
3094 }
3095
3096 }
3097 for (Int_t kk=0; kk<kMaxNumberOfTracksPerDigit; kk++) { // three is the max number of tracks associated to one digit
3098 if (selectedDigit[adesso4][fourthIndex]->GetTrackLabel(kk)==-1) continue;
3099 else {
3100
3101 alreadyStored = kFALSE;
3102 for (jj=0; jj<dummyCounter+1; jj++)
3103 alreadyStored = alreadyStored || (tracks[jj]!=-1 && tracks[jj]==selectedDigit[adesso4][fourthIndex]->GetTrackLabel(kk));
3104
3105 if (alreadyStored) continue;
3106 if (dummyCounter==2) { // three is the max number of tracks associated to one cluster
3107 AliWarning(" Siamo al limite!");
3108 continue;
3109 }
3110
3111 dummyCounter++;
3112 tracks[dummyCounter] = selectedDigit[adesso4][fourthIndex]->GetTrackLabel(kk);
3113
3114 }
3115
3116 }
3117
3118
3119 AliTOFcluster *tofCluster =
3120 new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
3121 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
3122 tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
3123 InsertCluster(tofCluster);
3124
e885fb81 3125 AliDebug(2, Form(" %4d %f %f %f %f %f %f %f %f %f %3d %3d %3d %2d %1d %2d %1d %2d %4d %3d %3d %4d %4d %1d %4d",
e3bd5504 3126 volIdClus, posClus[0], posClus[1], posClus[2],
3127 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
3128 tracks[0], tracks[1], tracks[2],
3129 det[0], det[1], det[2], det[3], det[4],
3130 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
3131 status, selectedDigit[adesso1][firstIndex]->GetIndex()));
3132
3133 volDum = vol1[3];
3134 vol1[3] = vol1[4];
3135 vol1[4] = volDum;
3136 fTOFdigitMap->ResetDigitNumber(vol1,selectedDigit[adesso1][firstIndex]->GetIndex());
3137 volDum = vol2[3];
3138 vol2[3] = vol2[4];
3139 vol2[4] = volDum;
3140 fTOFdigitMap->ResetDigitNumber(vol2,selectedDigit[adesso2][secondIndex]->GetIndex());
3141 volDum = vol3[3];
3142 vol3[3] = vol3[4];
3143 vol3[4] = volDum;
3144 fTOFdigitMap->ResetDigitNumber(vol3,selectedDigit[adesso3][thirdIndex]->GetIndex());
3145 volDum = vol4[3];
3146 vol4[3] = vol4[4];
3147 vol4[4] = volDum;
3148 fTOFdigitMap->ResetDigitNumber(vol4,selectedDigit[adesso4][fourthIndex]->GetIndex());
3149
3150
3151 } // close loop on fourth digit
3152
3153 } // close loop on third digit
3154
3155 } // close loop on second digit
3156
3157 } // close loop on first digit
3158
3159 break;
3160
3161 }
3162
3163 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
3164 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++)
3165 selectedDigit[ii][jj] = 0x0;
3166
3167 } // loop on iPad
3168
ed1f8475 3169 for (ii=0; ii<kMaxNumberOfInterestingPads; ii++) {
e3bd5504 3170 for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
ed1f8475 3171 delete [] selectedDigit[ii][jj];
e3bd5504 3172 selectedDigit[ii][jj] = 0x0;
3173 }
ed1f8475 3174 delete [] selectedDigit[ii];
3175 selectedDigit[ii] = 0x0;
3176 }
b5ed6afb 3177 delete [] selectedDigit;
ed1f8475 3178 selectedDigit = 0x0;
e3bd5504 3179
3180}
3181//_____________________________________________________________________________
3182
3183Int_t AliTOFClusterFinderV1::InsertCluster(AliTOFcluster *tofCluster)
3184{
3185 //
3186 // This function adds a TOF cluster to the array of TOF clusters
3187 // sorted in Z, i.e. fTofClusters
3188 //
3189
3190 if (fNumberOfTofClusters==kTofMaxCluster) {
3191 AliError("Too many clusters !");
3192 return 1;
3193 }
3194
3195 if (fNumberOfTofClusters==0) {
3196 fTofClusters[fNumberOfTofClusters++] = tofCluster;
3197 return 0;
3198 }
3199
3200 Int_t ii = FindClusterIndex(tofCluster->GetZ());
3201 memmove(fTofClusters+ii+1 ,fTofClusters+ii,(fNumberOfTofClusters-ii)*sizeof(AliTOFcluster*));
3202 fTofClusters[ii] = tofCluster;
3203 fNumberOfTofClusters++;
3204
3205 return 0;
3206
3207}
3208//_____________________________________________________________________________
3209
3210Int_t AliTOFClusterFinderV1::FindClusterIndex(Double_t z) const
3211{
3212 //
3213 // This function returns the index of the nearest cluster in z
3214 //
3215