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