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