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