]>
Commit | Line | Data |
---|---|---|
d08a92dd | 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 | /* | |
15ec34b9 | 17 | $Log$ |
ac359ffe | 18 | Revision 1.28 2007/05/31 16:06:05 arcelli |
19 | move instance of AliRawStream outside loop on DDL | |
20 | ||
ef58b2af | 21 | Revision 1.27 2007/05/02 16:31:49 arcelli |
22 | Add methods to handle single event reconstruction. retrieval of Calib info moved to AliTOFReconstructor ctor, and passed via a pointer to AliTOFcalib | |
23 | ||
94f5f8f2 | 24 | Revision 1.26 2007/04/30 19:02:24 arcelli |
25 | hopefully the last refinements for correct type conversion in calibration | |
26 | ||
a33fec85 | 27 | Revision 1.25 2007/04/30 15:22:17 arcelli |
28 | Change TOF digit Time, Tot etc to int type | |
29 | ||
bf33f8f0 | 30 | Revision 1.24 2007/04/27 11:19:31 arcelli |
31 | updates for the new decoder | |
32 | ||
7813bb1a | 33 | Revision 1.23 2007/04/23 16:51:39 decaro |
34 | Digits-to-raw_data conversion: correction for a more real description (A.De Caro, R.Preghenella) | |
35 | ||
515faf5d | 36 | Revision 1.22 2007/04/19 17:26:32 arcelli |
37 | Fix a bug (add some debug printout | |
38 | ||
0451c2e6 | 39 | Revision 1.21 2007/04/18 17:28:12 arcelli |
40 | Set the ToT bin width to the one actually used... | |
41 | ||
605370db | 42 | Revision 1.20 2007/03/09 09:57:23 arcelli |
43 | Remove a forgotten include of Riostrem | |
44 | ||
c77771e2 | 45 | Revision 1.19 2007/03/08 15:41:20 arcelli |
46 | set uncorrected times when filling RecPoints | |
47 | ||
3432ebfa | 48 | Revision 1.18 2007/03/06 16:31:20 arcelli |
49 | Add Uncorrected TOF Time signal | |
50 | ||
aa5476d8 | 51 | Revision 1.17 2007/02/28 18:09:11 arcelli |
52 | Add protection against failed retrieval of the CDB cal object, now Reconstruction exits with AliFatal | |
53 | ||
a1cab04c | 54 | Revision 1.16 2007/02/20 15:57:00 decaro |
55 | Raw data update: to read the TOF raw data defined in UNPACKED mode | |
56 | ||
d08a92dd | 57 | |
58 | Revision 0.03 2005/07/28 A. De Caro | |
59 | Implement public method | |
60 | Raw2Digits(Int_t, AliRawReader *) | |
61 | to convert digits from raw data in MC digits | |
62 | (temporary solution) | |
63 | ||
64 | Revision 0.02 2005/07/27 A. De Caro | |
65 | Implement public method | |
66 | Digits2RecPoint(Int_t) | |
67 | to convert digits in clusters | |
68 | ||
69 | Revision 0.02 2005/07/26 A. De Caro | |
70 | Implement private methods | |
71 | InsertCluster(AliTOFcluster *) | |
72 | FindClusterIndex(Double_t) | |
73 | originally implemented in AliTOFtracker | |
74 | by S. Arcelli and C. Zampolli | |
75 | ||
76 | Revision 0.01 2005/07/25 A. De Caro | |
77 | Implement public methods | |
78 | Digits2RecPoint(AliRawReader *, TTree *) | |
79 | Digits2RecPoint(Int_t, AliRawReader *) | |
80 | to convert raw data in clusters | |
81 | */ | |
82 | ||
83 | //////////////////////////////////////////////////////////////// | |
84 | // // | |
85 | // Class for TOF cluster finder // | |
86 | // // | |
87 | // Starting from Raw Data, create rec points, // | |
88 | // fill TreeR for TOF, // | |
89 | // write TOF.RecPoints.root file // | |
90 | // // | |
91 | //////////////////////////////////////////////////////////////// | |
92 | ||
15ec34b9 | 93 | |
0e46b9ae | 94 | #include "TClonesArray.h" |
515faf5d | 95 | #include "TStopwatch.h" |
0e46b9ae | 96 | #include "TTree.h" |
ac359ffe | 97 | #include <TGeoManager.h> |
98 | #include <AliGeomManager.h> | |
99 | #include <TGeoMatrix.h> | |
100 | #include <TGeoPhysicalNode.h> | |
101 | #include "AliAlignObj.h" | |
d08a92dd | 102 | |
d0eb8f39 | 103 | #include "AliDAQ.h" |
0e46b9ae | 104 | #include "AliLoader.h" |
d08a92dd | 105 | #include "AliLog.h" |
0e46b9ae | 106 | #include "AliRawReader.h" |
d08a92dd | 107 | #include "AliRunLoader.h" |
d08a92dd | 108 | |
37879eed | 109 | #include "AliTOFCal.h" |
15ec34b9 | 110 | #include "AliTOFcalib.h" |
37879eed | 111 | #include "AliTOFChannel.h" |
d08a92dd | 112 | #include "AliTOFClusterFinder.h" |
0e46b9ae | 113 | #include "AliTOFcluster.h" |
114 | #include "AliTOFdigit.h" | |
0e46b9ae | 115 | #include "AliTOFGeometry.h" |
15ec34b9 | 116 | #include "AliTOFGeometryV5.h" |
117 | #include "AliTOFrawData.h" | |
0e46b9ae | 118 | #include "AliTOFRawStream.h" |
3432ebfa | 119 | #include "Riostream.h" |
0e46b9ae | 120 | |
15ec34b9 | 121 | //extern TFile *gFile; |
d08a92dd | 122 | |
123 | ClassImp(AliTOFClusterFinder) | |
124 | ||
94f5f8f2 | 125 | AliTOFClusterFinder::AliTOFClusterFinder(AliTOFcalib *calib): |
d08a92dd | 126 | fRunLoader(0), |
127 | fTOFLoader(0), | |
128 | fTreeD(0), | |
129 | fTreeR(0), | |
58d8d9a3 | 130 | fTOFGeometry(new AliTOFGeometryV5()), |
d08a92dd | 131 | fDigits(new TClonesArray("AliTOFdigit", 4000)), |
132 | fRecPoints(new TClonesArray("AliTOFcluster", 4000)), | |
15ec34b9 | 133 | fNumberOfTofClusters(0), |
7813bb1a | 134 | fVerbose(0), |
94f5f8f2 | 135 | fDecoderVersion(0), |
136 | fTOFcalib(calib) | |
d08a92dd | 137 | { |
138 | // | |
139 | // Constructor | |
140 | // | |
141 | ||
3bbdf45d | 142 | AliInfo("V5 TOF Geometry is taken as the default"); |
37879eed | 143 | |
d08a92dd | 144 | } |
145 | //______________________________________________________________________________ | |
146 | ||
94f5f8f2 | 147 | AliTOFClusterFinder::AliTOFClusterFinder(AliRunLoader* runLoader, AliTOFcalib *calib): |
d08a92dd | 148 | fRunLoader(runLoader), |
149 | fTOFLoader(runLoader->GetLoader("TOFLoader")), | |
150 | fTreeD(0), | |
151 | fTreeR(0), | |
58d8d9a3 | 152 | fTOFGeometry(new AliTOFGeometryV5()), |
d08a92dd | 153 | fDigits(new TClonesArray("AliTOFdigit", 4000)), |
154 | fRecPoints(new TClonesArray("AliTOFcluster", 4000)), | |
15ec34b9 | 155 | fNumberOfTofClusters(0), |
7813bb1a | 156 | fVerbose(0), |
94f5f8f2 | 157 | fDecoderVersion(0), |
158 | fTOFcalib(calib) | |
d08a92dd | 159 | { |
160 | // | |
161 | // Constructor | |
162 | // | |
163 | ||
7aeeaf38 | 164 | } |
165 | ||
166 | //------------------------------------------------------------------------ | |
167 | AliTOFClusterFinder::AliTOFClusterFinder(const AliTOFClusterFinder &source) | |
58d8d9a3 | 168 | :TObject(), |
169 | fRunLoader(0), | |
170 | fTOFLoader(0), | |
171 | fTreeD(0), | |
172 | fTreeR(0), | |
173 | fTOFGeometry(new AliTOFGeometryV5()), | |
174 | fDigits(new TClonesArray("AliTOFdigit", 4000)), | |
175 | fRecPoints(new TClonesArray("AliTOFcluster", 4000)), | |
15ec34b9 | 176 | fNumberOfTofClusters(0), |
94f5f8f2 | 177 | fVerbose(0), |
178 | fDecoderVersion(0), | |
179 | fTOFcalib(0) | |
7aeeaf38 | 180 | { |
181 | // copy constructor | |
182 | this->fDigits=source.fDigits; | |
183 | this->fRecPoints=source.fRecPoints; | |
184 | this->fTOFGeometry=source.fTOFGeometry; | |
7813bb1a | 185 | this->fDecoderVersion=source.fDecoderVersion; |
94f5f8f2 | 186 | this->fTOFcalib=source.fTOFcalib; |
7aeeaf38 | 187 | |
188 | } | |
189 | ||
190 | //------------------------------------------------------------------------ | |
d0eb8f39 | 191 | AliTOFClusterFinder& AliTOFClusterFinder::operator=(const AliTOFClusterFinder &source) |
7aeeaf38 | 192 | { |
193 | // ass. op. | |
194 | this->fDigits=source.fDigits; | |
195 | this->fRecPoints=source.fRecPoints; | |
196 | this->fTOFGeometry=source.fTOFGeometry; | |
15ec34b9 | 197 | this->fVerbose=source.fVerbose; |
7813bb1a | 198 | this->fDecoderVersion=source.fDecoderVersion; |
94f5f8f2 | 199 | this->fTOFcalib=source.fTOFcalib; |
7aeeaf38 | 200 | return *this; |
201 | ||
d08a92dd | 202 | } |
203 | //______________________________________________________________________________ | |
204 | ||
205 | AliTOFClusterFinder::~AliTOFClusterFinder() | |
206 | { | |
207 | ||
208 | // | |
209 | // Destructor | |
210 | // | |
211 | ||
212 | if (fDigits) | |
213 | { | |
214 | fDigits->Delete(); | |
215 | delete fDigits; | |
216 | fDigits=0; | |
217 | } | |
218 | if (fRecPoints) | |
219 | { | |
220 | fRecPoints->Delete(); | |
221 | delete fRecPoints; | |
222 | fRecPoints=0; | |
223 | } | |
224 | ||
225 | delete fTOFGeometry; | |
226 | ||
227 | } | |
228 | //______________________________________________________________________________ | |
229 | ||
230 | void AliTOFClusterFinder::Digits2RecPoints(Int_t iEvent) | |
231 | { | |
232 | // | |
233 | // Converts digits to recpoints for TOF | |
234 | // | |
235 | ||
515faf5d | 236 | TStopwatch stopwatch; |
237 | stopwatch.Start(); | |
238 | ||
d08a92dd | 239 | fRunLoader->GetEvent(iEvent); |
240 | ||
241 | fTreeD = fTOFLoader->TreeD(); | |
242 | if (fTreeD == 0x0) | |
243 | { | |
244 | AliFatal("AliTOFClusterFinder: Can not get TreeD"); | |
245 | } | |
246 | ||
247 | TBranch *branch = fTreeD->GetBranch("TOF"); | |
248 | if (!branch) { | |
249 | AliError("can't get the branch with the TOF digits !"); | |
250 | return; | |
251 | } | |
252 | ||
15ec34b9 | 253 | TClonesArray *digits = new TClonesArray("AliTOFdigit",10000); |
d08a92dd | 254 | branch->SetAddress(&digits); |
255 | ||
256 | ResetRecpoint(); | |
257 | ||
258 | fTreeR = fTOFLoader->TreeR(); | |
259 | if (fTreeR == 0x0) | |
260 | { | |
261 | fTOFLoader->MakeTree("R"); | |
262 | fTreeR = fTOFLoader->TreeR(); | |
263 | } | |
264 | ||
265 | Int_t bufsize = 32000; | |
266 | fTreeR->Branch("TOF", &fRecPoints, bufsize); | |
267 | ||
268 | fTreeD->GetEvent(0); | |
269 | Int_t nDigits = digits->GetEntriesFast(); | |
270 | AliDebug(2,Form("Number of TOF digits: %d",nDigits)); | |
271 | ||
ac359ffe | 272 | Int_t ii; |
bf33f8f0 | 273 | Int_t dig[5]; //cluster detector indeces |
bf33f8f0 | 274 | Int_t parTOF[5]; //The TOF signal parameters |
275 | Bool_t status=kTRUE; // assume all sim channels ok in the beginning... | |
d08a92dd | 276 | for (ii=0; ii<nDigits; ii++) { |
277 | AliTOFdigit *d = (AliTOFdigit*)digits->UncheckedAt(ii); | |
278 | dig[0]=d->GetSector(); | |
279 | dig[1]=d->GetPlate(); | |
280 | dig[2]=d->GetStrip(); | |
281 | dig[3]=d->GetPadz(); | |
282 | dig[4]=d->GetPadx(); | |
283 | ||
bf33f8f0 | 284 | // AliDebug(2,Form(" %2i %1i %2i %1i %2i ",dig[0],dig[1],dig[2],dig[3],dig[4])); |
d0eb8f39 | 285 | |
bf33f8f0 | 286 | parTOF[0] = d->GetTdc(); //the TDC signal |
287 | parTOF[1] = d->GetToT(); //the ToT signal | |
288 | parTOF[2] = d->GetAdc(); // the adc charge | |
289 | parTOF[3] = d->GetTdcND(); // non decalibrated sim time | |
290 | parTOF[4] = d->GetTdc(); // raw time, == Tdc time for the moment | |
ac359ffe | 291 | Double_t posClus[3]; |
292 | Double_t covClus[6]; | |
293 | UShort_t volIdClus=GetClusterVolIndex(dig); | |
294 | GetClusterPars(dig, posClus,covClus); | |
295 | AliTOFcluster *tofCluster = new AliTOFcluster(volIdClus,posClus[0],posClus[1],posClus[2],covClus[0],covClus[1],covClus[2],covClus[3],covClus[4],covClus[5],d->GetTracks(),dig,parTOF,status,ii); | |
d08a92dd | 296 | InsertCluster(tofCluster); |
297 | ||
298 | } | |
299 | ||
94f5f8f2 | 300 | AliInfo(Form("Number of found clusters: %i for event: %i", fNumberOfTofClusters, iEvent)); |
d08a92dd | 301 | |
37879eed | 302 | CalibrateRecPoint(); |
d08a92dd | 303 | FillRecPoint(); |
304 | ||
305 | fTreeR->Fill(); | |
306 | ResetRecpoint(); | |
307 | ||
308 | fTOFLoader = fRunLoader->GetLoader("TOFLoader"); | |
309 | fTOFLoader->WriteRecPoints("OVERWRITE"); | |
310 | ||
515faf5d | 311 | AliInfo(Form("Execution time to read TOF digits and to write TOF clusters : R:%.4fs C:%.4fs", |
312 | stopwatch.RealTime(),stopwatch.CpuTime())); | |
313 | ||
94f5f8f2 | 314 | digits->Delete(); |
315 | delete digits; | |
316 | } | |
317 | ||
318 | //______________________________________________________________________________ | |
319 | ||
320 | void AliTOFClusterFinder::Digits2RecPoints(TTree* digitsTree, TTree* clusterTree) | |
321 | { | |
322 | // | |
323 | // Converts digits to recpoints for TOF | |
324 | // | |
325 | ||
326 | TStopwatch stopwatch; | |
327 | stopwatch.Start(); | |
328 | ||
329 | /// fRunLoader->GetEvent(iEvent); | |
330 | ||
331 | if (digitsTree == 0x0) | |
332 | { | |
333 | AliFatal("AliTOFClusterFinder: Can not get TreeD"); | |
334 | } | |
335 | ||
336 | TBranch *branch = digitsTree->GetBranch("TOF"); | |
337 | if (!branch) { | |
338 | AliError("can't get the branch with the TOF digits !"); | |
339 | return; | |
340 | } | |
341 | ||
342 | TClonesArray *digits = new TClonesArray("AliTOFdigit",10000); | |
343 | branch->SetAddress(&digits); | |
344 | ||
345 | ResetRecpoint(); | |
346 | ||
347 | fTreeR=clusterTree; | |
348 | Int_t bufsize = 32000; | |
349 | fTreeR->Branch("TOF", &fRecPoints, bufsize); | |
350 | ||
351 | digitsTree->GetEvent(0); | |
352 | Int_t nDigits = digits->GetEntriesFast(); | |
353 | AliDebug(2,Form("Number of TOF digits: %d",nDigits)); | |
354 | ||
ac359ffe | 355 | Int_t ii; |
94f5f8f2 | 356 | Int_t dig[5]; //cluster detector indeces |
94f5f8f2 | 357 | Int_t parTOF[5]; //The TOF signal parameters |
358 | Bool_t status=kTRUE; // assume all sim channels ok in the beginning... | |
359 | for (ii=0; ii<nDigits; ii++) { | |
360 | AliTOFdigit *d = (AliTOFdigit*)digits->UncheckedAt(ii); | |
361 | dig[0]=d->GetSector(); | |
362 | dig[1]=d->GetPlate(); | |
363 | dig[2]=d->GetStrip(); | |
364 | dig[3]=d->GetPadz(); | |
365 | dig[4]=d->GetPadx(); | |
366 | ||
367 | // AliDebug(2,Form(" %2i %1i %2i %1i %2i ",dig[0],dig[1],dig[2],dig[3],dig[4])); | |
368 | ||
94f5f8f2 | 369 | parTOF[0] = d->GetTdc(); //the TDC signal |
370 | parTOF[1] = d->GetToT(); //the ToT signal | |
371 | parTOF[2] = d->GetAdc(); // the adc charge | |
372 | parTOF[3] = d->GetTdcND(); // non decalibrated sim time | |
373 | parTOF[4] = d->GetTdc(); // raw time, == Tdc time for the moment | |
ac359ffe | 374 | |
375 | Double_t posClus[3]; | |
376 | Double_t covClus[6]; | |
377 | UShort_t volIdClus=GetClusterVolIndex(dig); | |
378 | GetClusterPars(dig,posClus,covClus); | |
379 | AliTOFcluster *tofCluster = new AliTOFcluster(volIdClus,posClus[0],posClus[1],posClus[2],covClus[0],covClus[1],covClus[2],covClus[3],covClus[4],covClus[5],d->GetTracks(),dig,parTOF,status,ii); | |
94f5f8f2 | 380 | InsertCluster(tofCluster); |
381 | ||
382 | } | |
383 | ||
384 | AliInfo(Form("Number of found clusters: %i", fNumberOfTofClusters)); | |
385 | ||
386 | CalibrateRecPoint(); | |
387 | FillRecPoint(); | |
388 | ||
389 | clusterTree->Fill(); | |
390 | ResetRecpoint(); | |
391 | ||
392 | AliInfo(Form("Execution time to read TOF digits and to write TOF clusters : R:%.4fs C:%.4fs", | |
393 | stopwatch.RealTime(),stopwatch.CpuTime())); | |
394 | ||
395 | digits->Delete(); | |
396 | delete digits; | |
d08a92dd | 397 | } |
398 | //______________________________________________________________________________ | |
399 | ||
400 | void AliTOFClusterFinder::Digits2RecPoints(AliRawReader *rawReader, | |
401 | TTree *clustersTree) | |
402 | { | |
403 | // | |
404 | // Converts RAW data to recpoints for TOF | |
405 | // | |
406 | ||
515faf5d | 407 | TStopwatch stopwatch; |
408 | stopwatch.Start(); | |
409 | ||
d0eb8f39 | 410 | //const Int_t kDDL = fTOFGeometry->NDDL()*fTOFGeometry->NSectors(); |
411 | const Int_t kDDL = AliDAQ::NumberOfDdls("TOF"); | |
d08a92dd | 412 | |
413 | ResetRecpoint(); | |
414 | ||
415 | Int_t bufsize = 32000; | |
416 | clustersTree->Branch("TOF", &fRecPoints, bufsize); | |
417 | ||
15ec34b9 | 418 | TClonesArray * clonesRawData; |
419 | ||
15ec34b9 | 420 | Int_t dummy = -1; |
d08a92dd | 421 | |
422 | Int_t detectorIndex[5]; | |
bf33f8f0 | 423 | Int_t parTOF[5]; |
d08a92dd | 424 | |
15ec34b9 | 425 | ofstream ftxt; |
426 | if (fVerbose==2) ftxt.open("TOFdigitsRead.txt",ios::app); | |
427 | ||
ef58b2af | 428 | AliTOFRawStream tofInput(rawReader); |
429 | ||
15ec34b9 | 430 | Int_t indexDDL = 0; |
431 | for (indexDDL = 0; indexDDL < kDDL; indexDDL++) { | |
432 | ||
433 | rawReader->Reset(); | |
7813bb1a | 434 | if (fDecoderVersion) { |
435 | AliInfo("Using New Decoder \n"); | |
436 | tofInput.LoadRawDataBuffers(indexDDL,fVerbose); | |
437 | } | |
438 | else tofInput.LoadRawData(indexDDL); | |
15ec34b9 | 439 | |
440 | clonesRawData = (TClonesArray*)tofInput.GetRawData(); | |
441 | ||
442 | for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) { | |
443 | ||
444 | AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData); | |
445 | ||
446 | if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue; | |
447 | ||
448 | if (fVerbose==2) { | |
449 | if (indexDDL<10) ftxt << " " << indexDDL; | |
450 | else ftxt << " " << indexDDL; | |
451 | if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM(); | |
452 | else ftxt << " " << tofRawDatum->GetTRM(); | |
453 | ftxt << " " << tofRawDatum->GetTRMchain(); | |
454 | if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC(); | |
455 | else ftxt << " " << tofRawDatum->GetTDC(); | |
456 | ftxt << " " << tofRawDatum->GetTDCchannel(); | |
457 | } | |
458 | ||
459 | tofInput.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(), | |
460 | tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex); | |
461 | dummy = detectorIndex[3]; | |
462 | detectorIndex[3] = detectorIndex[4]; | |
463 | detectorIndex[4] = dummy; | |
464 | ||
465 | if (fVerbose==2) { | |
466 | if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0]; | |
467 | else ftxt << " -> " << detectorIndex[0]; | |
468 | ftxt << " " << detectorIndex[1]; | |
469 | if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2]; | |
470 | else ftxt << " " << detectorIndex[2]; | |
471 | ftxt << " " << detectorIndex[3]; | |
472 | if (detectorIndex[4]<10) ftxt << " " << detectorIndex[4]; | |
473 | else ftxt << " " << detectorIndex[4]; | |
474 | } | |
475 | ||
bf33f8f0 | 476 | parTOF[0] = tofRawDatum->GetTOF(); //TDC |
477 | parTOF[1] = tofRawDatum->GetTOT(); // TOT | |
478 | parTOF[2] = tofRawDatum->GetTOT(); //ADC==TOF | |
479 | parTOF[3] = -1;//raw data: no track of undecalib sim time | |
480 | parTOF[4] = tofRawDatum->GetTOF(); // RAW time | |
ac359ffe | 481 | Double_t posClus[3]; |
482 | Double_t covClus[6]; | |
483 | UShort_t volIdClus=GetClusterVolIndex(detectorIndex); | |
484 | Int_t lab[3]={-1,-1,-1}; | |
485 | Bool_t status=kTRUE; | |
486 | GetClusterPars(detectorIndex,posClus,covClus); | |
487 | AliTOFcluster *tofCluster = new AliTOFcluster(volIdClus,posClus[0],posClus[1],posClus[2],covClus[0],covClus[1],covClus[2],covClus[3],covClus[4],covClus[5],lab,detectorIndex,parTOF,status,-1); | |
15ec34b9 | 488 | InsertCluster(tofCluster); |
489 | ||
490 | if (fVerbose==2) { | |
bf33f8f0 | 491 | if (parTOF[1]<10)ftxt << " " << parTOF[1]; |
492 | else if (parTOF[1]>=10 && parTOF[1]<100) ftxt << " " << parTOF[1]; | |
493 | else ftxt << " " << parTOF[1]; | |
494 | if (parTOF[0]<10) ftxt << " " << parTOF[0] << endl; | |
495 | else if (parTOF[0]>=10 && parTOF[0]<100) ftxt << " " << parTOF[0] << endl; | |
496 | else if (parTOF[0]>=100 && parTOF[0]<1000) ftxt << " " << parTOF[0] << endl; | |
497 | else ftxt << " " << parTOF[3] << endl; | |
15ec34b9 | 498 | } |
499 | ||
500 | } // closed loop on TOF raw data per current DDL file | |
501 | ||
502 | clonesRawData->Clear(); | |
503 | ||
504 | } // closed loop on DDL index | |
505 | ||
15ec34b9 | 506 | if (fVerbose==2) ftxt.close(); |
d08a92dd | 507 | |
508 | AliInfo(Form("Number of found clusters: %i", fNumberOfTofClusters)); | |
509 | ||
37879eed | 510 | CalibrateRecPoint(); |
d08a92dd | 511 | FillRecPoint(); |
512 | ||
513 | clustersTree->Fill(); | |
37879eed | 514 | |
d08a92dd | 515 | ResetRecpoint(); |
516 | ||
515faf5d | 517 | AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters : R:%.4fs C:%.4fs", |
518 | stopwatch.RealTime(),stopwatch.CpuTime())); | |
519 | ||
d08a92dd | 520 | } |
521 | //______________________________________________________________________________ | |
522 | ||
523 | void AliTOFClusterFinder::Digits2RecPoints(Int_t iEvent, AliRawReader *rawReader) | |
524 | { | |
525 | // | |
526 | // Converts RAW data to recpoints for TOF | |
527 | // | |
528 | ||
515faf5d | 529 | TStopwatch stopwatch; |
530 | stopwatch.Start(); | |
531 | ||
d0eb8f39 | 532 | //const Int_t kDDL = fTOFGeometry->NDDL()*fTOFGeometry->NSectors(); |
533 | const Int_t kDDL = AliDAQ::NumberOfDdls("TOF"); | |
d08a92dd | 534 | |
535 | fRunLoader->GetEvent(iEvent); | |
536 | ||
537 | AliDebug(2,Form(" Event number %2i ", iEvent)); | |
538 | ||
539 | fTreeR = fTOFLoader->TreeR(); | |
540 | ||
541 | if (fTreeR == 0x0){ | |
542 | fTOFLoader->MakeTree("R"); | |
543 | fTreeR = fTOFLoader->TreeR(); | |
544 | } | |
545 | ||
546 | Int_t bufsize = 32000; | |
547 | fTreeR->Branch("TOF", &fRecPoints, bufsize); | |
548 | ||
15ec34b9 | 549 | TClonesArray * clonesRawData; |
550 | ||
15ec34b9 | 551 | Int_t dummy = -1; |
d08a92dd | 552 | |
d0eb8f39 | 553 | Int_t detectorIndex[5] = {-1, -1, -1, -1, -1}; |
bf33f8f0 | 554 | Int_t parTOF[5]; |
15ec34b9 | 555 | ofstream ftxt; |
556 | if (fVerbose==2) ftxt.open("TOFdigitsRead.txt",ios::app); | |
557 | ||
ef58b2af | 558 | AliTOFRawStream tofInput(rawReader); |
559 | ||
15ec34b9 | 560 | Int_t indexDDL = 0; |
d08a92dd | 561 | for (indexDDL = 0; indexDDL < kDDL; indexDDL++) { |
562 | ||
563 | rawReader->Reset(); | |
7813bb1a | 564 | if (fDecoderVersion) { |
565 | AliInfo("Using New Decoder \n"); | |
566 | tofInput.LoadRawDataBuffers(indexDDL,fVerbose); | |
567 | } | |
568 | else tofInput.LoadRawData(indexDDL); | |
15ec34b9 | 569 | |
570 | clonesRawData = (TClonesArray*)tofInput.GetRawData(); | |
571 | ||
572 | for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) { | |
573 | ||
574 | AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData); | |
575 | ||
576 | if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue; | |
577 | ||
578 | if (fVerbose==2) { | |
579 | if (indexDDL<10) ftxt << " " << indexDDL; | |
580 | else ftxt << " " << indexDDL; | |
581 | if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM(); | |
582 | else ftxt << " " << tofRawDatum->GetTRM(); | |
583 | ftxt << " " << tofRawDatum->GetTRMchain(); | |
584 | if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC(); | |
585 | else ftxt << " " << tofRawDatum->GetTDC(); | |
586 | ftxt << " " << tofRawDatum->GetTDCchannel(); | |
587 | } | |
588 | ||
589 | tofInput.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(), | |
590 | tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex); | |
591 | dummy = detectorIndex[3]; | |
592 | detectorIndex[3] = detectorIndex[4]; | |
593 | detectorIndex[4] = dummy; | |
594 | ||
595 | if (fVerbose==2) { | |
596 | if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0]; | |
597 | else ftxt << " -> " << detectorIndex[0]; | |
598 | ftxt << " " << detectorIndex[1]; | |
599 | if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2]; | |
600 | else ftxt << " " << detectorIndex[2]; | |
601 | ftxt << " " << detectorIndex[3]; | |
602 | if (detectorIndex[4]<10) ftxt << " " << detectorIndex[4]; | |
603 | else ftxt << " " << detectorIndex[4]; | |
604 | } | |
d0eb8f39 | 605 | |
bf33f8f0 | 606 | parTOF[0] = tofRawDatum->GetTOF(); // TDC |
607 | parTOF[1] = tofRawDatum->GetTOT(); // TOT | |
608 | parTOF[2] = tofRawDatum->GetTOT(); // raw data have ADC=TOT | |
609 | parTOF[3] = -1; //raw data: no track of the undecalib sim time | |
610 | parTOF[4] = tofRawDatum->GetTOF(); // Raw time == TDC | |
ac359ffe | 611 | Double_t posClus[3]; |
612 | Double_t covClus[6]; | |
613 | UShort_t volIdClus=GetClusterVolIndex(detectorIndex); | |
614 | Int_t lab[3]={-1,-1,-1}; | |
615 | Bool_t status=kTRUE; | |
616 | GetClusterPars(detectorIndex,posClus,covClus); | |
617 | AliTOFcluster *tofCluster = new AliTOFcluster(volIdClus,posClus[0],posClus[1],posClus[2],covClus[0],covClus[1],covClus[2],covClus[3],covClus[4],covClus[5],lab,detectorIndex,parTOF,status,-1); | |
d08a92dd | 618 | InsertCluster(tofCluster); |
619 | ||
15ec34b9 | 620 | if (fVerbose==2) { |
bf33f8f0 | 621 | if (parTOF[1]<10)ftxt << " " << parTOF[1]; |
622 | else if (parTOF[1]>=10 && parTOF[1]<100) ftxt << " " << parTOF[1]; | |
623 | else ftxt << " " << parTOF[1]; | |
624 | if (parTOF[0]<10) ftxt << " " << parTOF[0] << endl; | |
625 | else if (parTOF[0]>=10 && parTOF[0]<100) ftxt << " " << parTOF[0] << endl; | |
626 | else if (parTOF[0]>=100 && parTOF[0]<1000) ftxt << " " << parTOF[0] << endl; | |
627 | else ftxt << " " << parTOF[3] << endl; | |
15ec34b9 | 628 | } |
d08a92dd | 629 | |
15ec34b9 | 630 | } // closed loop on TOF raw data per current DDL file |
631 | ||
632 | clonesRawData->Clear(); | |
633 | ||
634 | } // closed loop on DDL index | |
635 | ||
636 | if (fVerbose==2) ftxt.close(); | |
d08a92dd | 637 | |
94f5f8f2 | 638 | AliInfo(Form("Number of found clusters: %i for event: %i", fNumberOfTofClusters, iEvent)); |
d08a92dd | 639 | |
37879eed | 640 | CalibrateRecPoint(); |
d08a92dd | 641 | FillRecPoint(); |
642 | ||
643 | fTreeR->Fill(); | |
644 | ResetRecpoint(); | |
645 | ||
646 | fTOFLoader = fRunLoader->GetLoader("TOFLoader"); | |
647 | fTOFLoader->WriteRecPoints("OVERWRITE"); | |
648 | ||
515faf5d | 649 | AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters : R:%.4fs C:%.4fs", |
650 | stopwatch.RealTime(),stopwatch.CpuTime())); | |
651 | ||
d08a92dd | 652 | } |
653 | //______________________________________________________________________________ | |
654 | ||
655 | void AliTOFClusterFinder::Raw2Digits(Int_t iEvent, AliRawReader *rawReader) | |
656 | { | |
657 | // | |
658 | // Converts RAW data to MC digits for TOF | |
659 | // | |
660 | // (temporary solution) | |
661 | // | |
662 | ||
515faf5d | 663 | TStopwatch stopwatch; |
664 | stopwatch.Start(); | |
665 | ||
15ec34b9 | 666 | //const Int_t kDDL = fTOFGeometry->NDDL()*fTOFGeometry->NSectors(); |
667 | const Int_t kDDL = fTOFGeometry->NDDL()*fTOFGeometry->NSectors(); | |
668 | ||
d08a92dd | 669 | fRunLoader->GetEvent(iEvent); |
670 | ||
671 | fTreeD = fTOFLoader->TreeD(); | |
672 | if (fTreeD) | |
673 | { | |
d0eb8f39 | 674 | AliInfo("TreeD re-creation"); |
d08a92dd | 675 | fTreeD = 0x0; |
676 | fTOFLoader->MakeTree("D"); | |
677 | fTreeD = fTOFLoader->TreeD(); | |
678 | } | |
679 | ||
15ec34b9 | 680 | TClonesArray *tofDigits = new TClonesArray("AliTOFdigit",10000); |
d08a92dd | 681 | Int_t bufsize = 32000; |
682 | fTreeD->Branch("TOF", &tofDigits, bufsize); | |
683 | ||
d08a92dd | 684 | fRunLoader->GetEvent(iEvent); |
685 | ||
686 | AliDebug(2,Form(" Event number %2i ", iEvent)); | |
687 | ||
15ec34b9 | 688 | TClonesArray * clonesRawData; |
689 | ||
690 | Int_t dummy = -1; | |
d08a92dd | 691 | |
692 | Int_t detectorIndex[5]; | |
bf33f8f0 | 693 | Int_t digit[4]; |
d08a92dd | 694 | |
ef58b2af | 695 | AliTOFRawStream tofInput(rawReader); |
696 | ||
15ec34b9 | 697 | Int_t indexDDL = 0; |
d08a92dd | 698 | for (indexDDL = 0; indexDDL < kDDL; indexDDL++) { |
699 | ||
700 | rawReader->Reset(); | |
7813bb1a | 701 | if (fDecoderVersion) { |
702 | AliInfo("Using New Decoder \n"); | |
703 | tofInput.LoadRawDataBuffers(indexDDL,fVerbose); | |
704 | } | |
705 | else tofInput.LoadRawData(indexDDL); | |
d08a92dd | 706 | |
15ec34b9 | 707 | clonesRawData = (TClonesArray*)tofInput.GetRawData(); |
d08a92dd | 708 | |
15ec34b9 | 709 | for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) { |
d0eb8f39 | 710 | |
15ec34b9 | 711 | AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData); |
d0eb8f39 | 712 | |
15ec34b9 | 713 | if (!tofRawDatum->GetTOT() || !tofRawDatum->GetTOF()) continue; |
714 | ||
715 | tofInput.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(), | |
716 | tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex); | |
717 | dummy = detectorIndex[3]; | |
718 | detectorIndex[3] = detectorIndex[4]; | |
719 | detectorIndex[4] = dummy; | |
d0eb8f39 | 720 | |
bf33f8f0 | 721 | digit[0] = tofInput.GetTofBin(); |
722 | digit[1] = tofInput.GetToTbin(); | |
723 | digit[2] = tofInput.GetToTbin(); | |
724 | digit[3] = -1; | |
d08a92dd | 725 | |
726 | Int_t tracknum[3]={-1,-1,-1}; | |
727 | ||
728 | TClonesArray &aDigits = *tofDigits; | |
729 | Int_t last=tofDigits->GetEntriesFast(); | |
730 | new (aDigits[last]) AliTOFdigit(tracknum, detectorIndex, digit); | |
731 | ||
732 | } // while loop | |
733 | ||
15ec34b9 | 734 | clonesRawData->Clear(); |
735 | ||
d08a92dd | 736 | } // DDL Loop |
737 | ||
738 | fTreeD->Fill(); | |
739 | ||
740 | fTOFLoader = fRunLoader->GetLoader("TOFLoader"); | |
741 | fTOFLoader->WriteDigits("OVERWRITE"); | |
742 | ||
515faf5d | 743 | AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters : R:%.2fs C:%.2fs", |
744 | stopwatch.RealTime(),stopwatch.CpuTime())); | |
745 | ||
94f5f8f2 | 746 | } |
747 | ||
748 | //______________________________________________________________________________ | |
749 | ||
750 | void AliTOFClusterFinder::Raw2Digits(AliRawReader *rawReader, TTree* digitsTree) | |
751 | { | |
752 | // | |
753 | // Converts RAW data to MC digits for TOF for the current event | |
754 | // | |
755 | // | |
756 | ||
757 | TStopwatch stopwatch; | |
758 | stopwatch.Start(); | |
759 | ||
760 | const Int_t kDDL = fTOFGeometry->NDDL()*fTOFGeometry->NSectors(); | |
761 | ||
762 | if (!digitsTree) | |
763 | { | |
764 | AliError("No input digits Tree"); | |
765 | return; | |
766 | } | |
767 | ||
768 | TClonesArray *tofDigits = new TClonesArray("AliTOFdigit",10000); | |
769 | Int_t bufsize = 32000; | |
770 | digitsTree->Branch("TOF", &tofDigits, bufsize); | |
771 | ||
772 | /// fRunLoader->GetEvent(iEvent); | |
773 | ||
774 | /// AliDebug(2,Form(" Event number %2i ", iEvent)); | |
775 | ||
776 | TClonesArray * clonesRawData; | |
777 | ||
778 | Int_t dummy = -1; | |
779 | ||
780 | Int_t detectorIndex[5]; | |
781 | Int_t digit[4]; | |
782 | ||
ef58b2af | 783 | AliTOFRawStream tofInput(rawReader); |
784 | ||
94f5f8f2 | 785 | Int_t indexDDL = 0; |
786 | for (indexDDL = 0; indexDDL < kDDL; indexDDL++) { | |
787 | ||
788 | rawReader->Reset(); | |
94f5f8f2 | 789 | if (fDecoderVersion) { |
790 | AliInfo("Using New Decoder \n"); | |
791 | tofInput.LoadRawDataBuffers(indexDDL,fVerbose); | |
792 | } | |
793 | else tofInput.LoadRawData(indexDDL); | |
794 | ||
795 | clonesRawData = (TClonesArray*)tofInput.GetRawData(); | |
796 | ||
797 | for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) { | |
798 | ||
799 | AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData); | |
800 | ||
801 | if (!tofRawDatum->GetTOT() || !tofRawDatum->GetTOF()) continue; | |
802 | ||
803 | tofInput.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(), | |
804 | tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex); | |
805 | dummy = detectorIndex[3]; | |
806 | detectorIndex[3] = detectorIndex[4]; | |
807 | detectorIndex[4] = dummy; | |
808 | ||
809 | digit[0] = tofInput.GetTofBin(); | |
810 | digit[1] = tofInput.GetToTbin(); | |
811 | digit[2] = tofInput.GetToTbin(); | |
812 | digit[3] = -1; | |
813 | ||
814 | Int_t tracknum[3]={-1,-1,-1}; | |
815 | ||
816 | TClonesArray &aDigits = *tofDigits; | |
817 | Int_t last=tofDigits->GetEntriesFast(); | |
818 | new (aDigits[last]) AliTOFdigit(tracknum, detectorIndex, digit); | |
819 | ||
820 | } // while loop | |
821 | ||
822 | clonesRawData->Clear(); | |
823 | ||
824 | } // DDL Loop | |
825 | ||
826 | digitsTree->Fill(); | |
827 | ||
828 | AliDebug(1, Form("Got %d digits: ", tofDigits->GetEntries())); | |
829 | AliDebug(1, Form("Execution time to read TOF raw data and fill TOF digit tree : R:%.2fs C:%.2fs", | |
830 | stopwatch.RealTime(),stopwatch.CpuTime())); | |
831 | ||
d08a92dd | 832 | } |
833 | //______________________________________________________________________________ | |
834 | ||
835 | Int_t AliTOFClusterFinder::InsertCluster(AliTOFcluster *tofCluster) { | |
836 | //---------------------------------------------------------------------------// | |
837 | // This function adds a TOF cluster to the array of TOF clusters sorted in Z // | |
838 | //---------------------------------------------------------------------------// | |
839 | if (fNumberOfTofClusters==kTofMaxCluster) { | |
840 | AliError("Too many clusters !"); | |
841 | return 1; | |
842 | } | |
843 | ||
844 | if (fNumberOfTofClusters==0) { | |
845 | fTofClusters[fNumberOfTofClusters++] = tofCluster; | |
846 | return 0; | |
847 | } | |
848 | ||
849 | Int_t ii = FindClusterIndex(tofCluster->GetZ()); | |
850 | memmove(fTofClusters+ii+1 ,fTofClusters+ii,(fNumberOfTofClusters-ii)*sizeof(AliTOFcluster*)); | |
851 | fTofClusters[ii] = tofCluster; | |
852 | fNumberOfTofClusters++; | |
853 | ||
854 | return 0; | |
855 | ||
856 | } | |
857 | //_________________________________________________________________________ | |
858 | ||
859 | Int_t AliTOFClusterFinder::FindClusterIndex(Double_t z) const { | |
860 | //-------------------------------------------------------------------- | |
ac359ffe | 861 | // This function returns the index of the nearest cluster in z |
d08a92dd | 862 | //-------------------------------------------------------------------- |
863 | if (fNumberOfTofClusters==0) return 0; | |
864 | if (z <= fTofClusters[0]->GetZ()) return 0; | |
865 | if (z > fTofClusters[fNumberOfTofClusters-1]->GetZ()) return fNumberOfTofClusters; | |
866 | Int_t b = 0, e = fNumberOfTofClusters-1, m = (b+e)/2; | |
867 | for (; b<e; m=(b+e)/2) { | |
868 | if (z > fTofClusters[m]->GetZ()) b=m+1; | |
869 | else e=m; | |
870 | } | |
871 | ||
872 | return m; | |
873 | ||
874 | } | |
875 | //_________________________________________________________________________ | |
876 | ||
877 | void AliTOFClusterFinder::FillRecPoint() | |
878 | { | |
879 | // | |
880 | // Copy the global array of AliTOFcluster, i.e. fTofClusters (sorted | |
881 | // in Z) in the global TClonesArray of AliTOFcluster, | |
882 | // i.e. fRecPoints. | |
883 | // | |
884 | ||
885 | Int_t ii, jj; | |
886 | ||
887 | Int_t detectorIndex[5]; | |
bf33f8f0 | 888 | Int_t parTOF[5]; |
d08a92dd | 889 | Int_t trackLabels[3]; |
890 | Int_t digitIndex = -1; | |
bf33f8f0 | 891 | Bool_t status=kTRUE; |
d08a92dd | 892 | |
893 | TClonesArray &lRecPoints = *fRecPoints; | |
894 | ||
895 | for (ii=0; ii<fNumberOfTofClusters; ii++) { | |
896 | ||
897 | digitIndex = fTofClusters[ii]->GetIndex(); | |
898 | for(jj=0; jj<5; jj++) detectorIndex[jj] = fTofClusters[ii]->GetDetInd(jj); | |
899 | for(jj=0; jj<3; jj++) trackLabels[jj] = fTofClusters[ii]->GetLabel(jj); | |
bf33f8f0 | 900 | parTOF[0] = fTofClusters[ii]->GetTDC(); // TDC |
901 | parTOF[1] = fTofClusters[ii]->GetToT(); // TOT | |
902 | parTOF[2] = fTofClusters[ii]->GetADC(); // ADC=TOT | |
903 | parTOF[3] = fTofClusters[ii]->GetTDCND(); // TDCND | |
904 | parTOF[4] = fTofClusters[ii]->GetTDCRAW();//RAW | |
905 | status=fTofClusters[ii]->GetStatus(); | |
ac359ffe | 906 | Double_t posClus[3]; |
907 | Double_t covClus[6]; | |
908 | UShort_t volIdClus=GetClusterVolIndex(detectorIndex); | |
909 | GetClusterPars(detectorIndex,posClus,covClus); | |
910 | new(lRecPoints[ii]) AliTOFcluster(volIdClus,posClus[0],posClus[1],posClus[2],covClus[0],covClus[1],covClus[2],covClus[3],covClus[4],covClus[5],trackLabels,detectorIndex, parTOF,status,digitIndex); | |
d08a92dd | 911 | |
912 | } // loop on clusters | |
913 | ||
914 | } | |
37879eed | 915 | |
916 | //_________________________________________________________________________ | |
917 | void AliTOFClusterFinder::CalibrateRecPoint() | |
918 | { | |
919 | // | |
920 | // Copy the global array of AliTOFcluster, i.e. fTofClusters (sorted | |
921 | // in Z) in the global TClonesArray of AliTOFcluster, | |
922 | // i.e. fRecPoints. | |
923 | // | |
924 | ||
925 | Int_t ii, jj; | |
926 | ||
927 | Int_t detectorIndex[5]; | |
928 | Int_t digitIndex = -1; | |
a33fec85 | 929 | Double_t tToT; |
930 | Double_t timeCorr; | |
bf33f8f0 | 931 | Int_t tdcCorr; |
37879eed | 932 | AliInfo(" Calibrating TOF Clusters: ") |
a1cab04c | 933 | |
94f5f8f2 | 934 | AliTOFCal *calTOFArray = fTOFcalib->GetTOFCalArray(); |
37879eed | 935 | |
936 | for (ii=0; ii<fNumberOfTofClusters; ii++) { | |
937 | digitIndex = fTofClusters[ii]->GetIndex(); | |
938 | for(jj=0; jj<5; jj++) detectorIndex[jj] = fTofClusters[ii]->GetDetInd(jj); | |
939 | ||
94f5f8f2 | 940 | Int_t index = fTOFcalib->GetIndex(detectorIndex); |
37879eed | 941 | |
340693af | 942 | AliTOFChannel * calChannel = calTOFArray->GetChannel(index); |
58d8d9a3 | 943 | |
944 | // Get channel status | |
945 | Bool_t status=calChannel->GetStatus(); | |
946 | if(status)fTofClusters[ii]->SetStatus(!status); //odd convention, to avoid conflict with calibration objects currently in the db (temporary solution). | |
58d8d9a3 | 947 | // Get Rough channel online equalization |
948 | Float_t roughDelay=calChannel->GetDelay(); | |
0451c2e6 | 949 | AliDebug(2,Form(" channel delay = %f", roughDelay)); |
58d8d9a3 | 950 | // Get Refined channel offline calibration parameters |
37879eed | 951 | Float_t par[6]; |
952 | for (Int_t j = 0; j<6; j++){ | |
340693af | 953 | par[j]=calChannel->GetSlewPar(j); |
bf33f8f0 | 954 | AliDebug(2,Form(" Calib Pars = %f, %f, %f, %f, %f, %f ",par[0],par[1],par[2],par[3],par[4],par[5])); |
955 | } | |
956 | AliDebug(2,Form(" The ToT and Time, uncorr (counts) = %i , %i", fTofClusters[ii]->GetToT(),fTofClusters[ii]->GetTDC())); | |
a33fec85 | 957 | tToT = (Double_t)(fTofClusters[ii]->GetToT()*AliTOFGeometry::ToTBinWidth()); tToT*=1.E-3; //ToT in ns |
958 | AliDebug(2,Form(" The ToT and Time, uncorr (ns)= %e, %e",fTofClusters[ii]->GetTDC()*AliTOFGeometry::TdcBinWidth()*1.E-3,tToT)); | |
bf33f8f0 | 959 | timeCorr=par[0]+par[1]*tToT+par[2]*tToT*tToT+par[3]*tToT*tToT*tToT+par[4]*tToT*tToT*tToT*tToT+par[5]*tToT*tToT*tToT*tToT*tToT+roughDelay; // the time correction |
960 | AliDebug(2,Form(" The time correction (ns) = %f", timeCorr)); | |
a33fec85 | 961 | timeCorr=(Double_t)(fTofClusters[ii]->GetTDC())*AliTOFGeometry::TdcBinWidth()*1.E-3-timeCorr;//redefine the time |
962 | timeCorr*=1.E3; | |
963 | AliDebug(2,Form(" The channel time, corr (ps)= %e",timeCorr )); | |
964 | tdcCorr=(Int_t)(timeCorr/AliTOFGeometry::TdcBinWidth()); //the corrected time (tdc counts) | |
340693af | 965 | fTofClusters[ii]->SetTDC(tdcCorr); |
a33fec85 | 966 | AliDebug(2,Form(" The channel time, corr (counts) = %i",fTofClusters[ii]->GetTDC())); |
37879eed | 967 | |
968 | } // loop on clusters | |
969 | ||
37879eed | 970 | } |
d08a92dd | 971 | //______________________________________________________________________________ |
972 | ||
973 | void AliTOFClusterFinder::ResetRecpoint() | |
974 | { | |
975 | // | |
976 | // Clear the list of reconstructed points | |
977 | // | |
978 | ||
979 | fNumberOfTofClusters = 0; | |
980 | if (fRecPoints) fRecPoints->Clear(); | |
981 | ||
982 | } | |
983 | //______________________________________________________________________________ | |
984 | ||
985 | void AliTOFClusterFinder::Load() | |
986 | { | |
987 | // | |
988 | // Load TOF.Digits.root and TOF.RecPoints.root files | |
989 | // | |
990 | ||
991 | fTOFLoader->LoadDigits("READ"); | |
992 | fTOFLoader->LoadRecPoints("recreate"); | |
993 | ||
994 | } | |
995 | //______________________________________________________________________________ | |
996 | ||
997 | void AliTOFClusterFinder::LoadClusters() | |
998 | { | |
999 | // | |
1000 | // Load TOF.RecPoints.root file | |
1001 | // | |
1002 | ||
1003 | fTOFLoader->LoadRecPoints("recreate"); | |
1004 | ||
1005 | } | |
1006 | //______________________________________________________________________________ | |
1007 | ||
1008 | void AliTOFClusterFinder::UnLoad() | |
1009 | { | |
1010 | // | |
1011 | // Unload TOF.Digits.root and TOF.RecPoints.root files | |
1012 | // | |
1013 | ||
1014 | fTOFLoader->UnloadDigits(); | |
1015 | fTOFLoader->UnloadRecPoints(); | |
1016 | ||
1017 | } | |
1018 | //______________________________________________________________________________ | |
1019 | ||
1020 | void AliTOFClusterFinder::UnLoadClusters() | |
1021 | { | |
1022 | // | |
1023 | // Unload TOF.RecPoints.root file | |
1024 | // | |
1025 | ||
1026 | fTOFLoader->UnloadRecPoints(); | |
1027 | ||
1028 | } | |
ac359ffe | 1029 | //------------------------------------------------------------------------- |
1030 | UShort_t AliTOFClusterFinder::GetClusterVolIndex(Int_t *ind) const { | |
1031 | ||
1032 | //First of all get the volume ID to retrieve the l2t transformation... | |
1033 | // | |
1034 | // Detector numbering scheme | |
1035 | Int_t nSector = 18; | |
1036 | Int_t nPlate = 5; | |
1037 | Int_t nStripA = 15; | |
1038 | Int_t nStripB = 19; | |
1039 | Int_t nStripC = 19; | |
1040 | ||
1041 | Int_t isector =ind[0]; | |
1042 | if (isector >= nSector) | |
1043 | AliError(Form("Wrong sector number in TOF (%d) !",isector)); | |
1044 | Int_t iplate = ind[1]; | |
1045 | if (iplate >= nPlate) | |
1046 | AliError(Form("Wrong plate number in TOF (%d) !",iplate)); | |
1047 | Int_t istrip = ind[2]; | |
1048 | ||
1049 | Int_t stripOffset = 0; | |
1050 | switch (iplate) { | |
1051 | case 0: | |
1052 | stripOffset = 0; | |
1053 | break; | |
1054 | case 1: | |
1055 | stripOffset = nStripC; | |
1056 | break; | |
1057 | case 2: | |
1058 | stripOffset = nStripC+nStripB; | |
1059 | break; | |
1060 | case 3: | |
1061 | stripOffset = nStripC+nStripB+nStripA; | |
1062 | break; | |
1063 | case 4: | |
1064 | stripOffset = nStripC+nStripB+nStripA+nStripB; | |
1065 | break; | |
1066 | default: | |
1067 | AliError(Form("Wrong plate number in TOF (%d) !",iplate)); | |
1068 | break; | |
1069 | }; | |
1070 | ||
1071 | Int_t index= (2*(nStripC+nStripB)+nStripA)*isector + | |
1072 | stripOffset + | |
1073 | istrip; | |
1074 | ||
1075 | UShort_t volIndex = AliGeomManager::LayerToVolUID(AliGeomManager::kTOF,index); | |
1076 | return volIndex; | |
1077 | } | |
1078 | // | |
1079 | //------------------------------------------------------------------------- | |
1080 | void AliTOFClusterFinder::GetClusterPars(Int_t *ind, Double_t* pos,Double_t* cov) const { | |
1081 | ||
1082 | //First of all get the volume ID to retrieve the l2t transformation... | |
1083 | // | |
1084 | UShort_t volIndex = GetClusterVolIndex(ind); | |
1085 | // | |
1086 | // | |
1087 | //we now go in the system of the strip: determine the local coordinates | |
1088 | // | |
1089 | // | |
1090 | // 47---------------------------------------------------0 ^ z | |
1091 | // | | | | | | | | | | | | | | | | | | | | | | | | | | | 1 | | |
1092 | // ----------------------------------------------------- | y going outwards | |
1093 | // | | | | | | | | | | | | | | | | | | | | | | | | | | | 0 | par[0]=0; | |
1094 | ||
1095 | // ----------------------------------------------------- | | |
1096 | // x <----------------------------------------------------- | |
1097 | ||
1098 | Float_t localX=(ind[4]-23.5)*2.5; | |
1099 | Float_t localY=0; | |
1100 | Float_t localZ=(ind[3]-0.5)*3.5; | |
1101 | ||
1102 | //move to the tracking ref system | |
1103 | ||
1104 | Double_t lpos[3]; | |
1105 | lpos[0]=localX; | |
1106 | lpos[1]=localY; | |
1107 | lpos[2]=localZ; | |
1108 | ||
1109 | const TGeoHMatrix *l2t= AliGeomManager::GetTracking2LocalMatrix(volIndex); | |
1110 | // Get The position in the track ref system | |
1111 | Double_t tpos[3]; | |
1112 | l2t->MasterToLocal(lpos,tpos); | |
1113 | pos[0]=tpos[0]; | |
1114 | pos[1]=tpos[1]; | |
1115 | pos[2]=tpos[2]; | |
1116 | ||
1117 | //Get The cluster covariance in the track ref system | |
1118 | Double_t lcov[9]; | |
1119 | ||
1120 | //cluster covariance in the local system: | |
1121 | // sx2 0 0 | |
1122 | // 0 0 0 | |
1123 | // 0 0 sz2 | |
1124 | ||
1125 | lcov[0]=2.5*2.5/12.; | |
1126 | lcov[1]=0; | |
1127 | lcov[2]=0; | |
1128 | lcov[3]=0; | |
1129 | lcov[4]=0; | |
1130 | lcov[5]=0; | |
1131 | lcov[6]=0; | |
1132 | lcov[7]=0; | |
1133 | lcov[8]=3.5*3.5/12.; | |
1134 | ||
1135 | //cluster covariance in the tracking system: | |
1136 | TGeoHMatrix m; | |
1137 | m.SetRotation(lcov); | |
1138 | m.Multiply(l2t); | |
1139 | m.MultiplyLeft(&l2t->Inverse()); | |
1140 | Double_t *tcov = m.GetRotationMatrix(); | |
1141 | cov[0] = tcov[0]; cov[1] = tcov[1]; cov[2] = tcov[2]; | |
1142 | cov[3] = tcov[4]; cov[4] = tcov[5]; | |
1143 | cov[5] = tcov[8]; | |
1144 | ||
1145 | return; | |
1146 | ||
1147 | } |