]>
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 | /* | |
7fffa85b | 17 | $Log: AliTOFClusterFinder.cxx,v $ |
18 | Revision 1.31 2007/11/24 14:53:19 zampolli | |
19 | Status flag implemented as UChar_t | |
20 | ||
98f5acd7 | 21 | Revision 1.30 2007/10/04 13:08:52 arcelli |
22 | updates to comply with AliTOFGeometryV5 becoming AliTOFGeometry | |
23 | ||
ba66add8 | 24 | Revision 1.29 2007/10/03 10:42:33 arcelli |
25 | updates to handle new AliTOFcluster, inheriting form AliCluster3D | |
26 | ||
ac359ffe | 27 | Revision 1.28 2007/05/31 16:06:05 arcelli |
28 | move instance of AliRawStream outside loop on DDL | |
29 | ||
ef58b2af | 30 | Revision 1.27 2007/05/02 16:31:49 arcelli |
c3891b7a | 31 | Add methods to handle single event reconstruction. retrieval of Calib |
32 | info moved to AliTOFReconstructor ctor, and passed via a pointer to | |
33 | AliTOFcalib | |
ef58b2af | 34 | |
94f5f8f2 | 35 | Revision 1.26 2007/04/30 19:02:24 arcelli |
36 | hopefully the last refinements for correct type conversion in calibration | |
37 | ||
a33fec85 | 38 | Revision 1.25 2007/04/30 15:22:17 arcelli |
39 | Change TOF digit Time, Tot etc to int type | |
40 | ||
bf33f8f0 | 41 | Revision 1.24 2007/04/27 11:19:31 arcelli |
42 | updates for the new decoder | |
43 | ||
7813bb1a | 44 | Revision 1.23 2007/04/23 16:51:39 decaro |
c3891b7a | 45 | Digits-to-raw_data conversion: correction for a more real description |
46 | (A.De Caro, R.Preghenella) | |
7813bb1a | 47 | |
515faf5d | 48 | Revision 1.22 2007/04/19 17:26:32 arcelli |
49 | Fix a bug (add some debug printout | |
50 | ||
0451c2e6 | 51 | Revision 1.21 2007/04/18 17:28:12 arcelli |
52 | Set the ToT bin width to the one actually used... | |
53 | ||
605370db | 54 | Revision 1.20 2007/03/09 09:57:23 arcelli |
55 | Remove a forgotten include of Riostrem | |
56 | ||
c77771e2 | 57 | Revision 1.19 2007/03/08 15:41:20 arcelli |
58 | set uncorrected times when filling RecPoints | |
59 | ||
3432ebfa | 60 | Revision 1.18 2007/03/06 16:31:20 arcelli |
61 | Add Uncorrected TOF Time signal | |
62 | ||
aa5476d8 | 63 | Revision 1.17 2007/02/28 18:09:11 arcelli |
c3891b7a | 64 | Add protection against failed retrieval of the CDB cal object, |
65 | now Reconstruction exits with AliFatal | |
aa5476d8 | 66 | |
a1cab04c | 67 | Revision 1.16 2007/02/20 15:57:00 decaro |
68 | Raw data update: to read the TOF raw data defined in UNPACKED mode | |
69 | ||
d08a92dd | 70 | |
71 | Revision 0.03 2005/07/28 A. De Caro | |
72 | Implement public method | |
73 | Raw2Digits(Int_t, AliRawReader *) | |
74 | to convert digits from raw data in MC digits | |
75 | (temporary solution) | |
76 | ||
77 | Revision 0.02 2005/07/27 A. De Caro | |
78 | Implement public method | |
79 | Digits2RecPoint(Int_t) | |
80 | to convert digits in clusters | |
81 | ||
82 | Revision 0.02 2005/07/26 A. De Caro | |
83 | Implement private methods | |
84 | InsertCluster(AliTOFcluster *) | |
85 | FindClusterIndex(Double_t) | |
86 | originally implemented in AliTOFtracker | |
87 | by S. Arcelli and C. Zampolli | |
88 | ||
89 | Revision 0.01 2005/07/25 A. De Caro | |
90 | Implement public methods | |
91 | Digits2RecPoint(AliRawReader *, TTree *) | |
92 | Digits2RecPoint(Int_t, AliRawReader *) | |
93 | to convert raw data in clusters | |
94 | */ | |
95 | ||
96 | //////////////////////////////////////////////////////////////// | |
97 | // // | |
98 | // Class for TOF cluster finder // | |
99 | // // | |
100 | // Starting from Raw Data, create rec points, // | |
101 | // fill TreeR for TOF, // | |
102 | // write TOF.RecPoints.root file // | |
103 | // // | |
104 | //////////////////////////////////////////////////////////////// | |
105 | ||
5c7c93fa | 106 | #include "Riostream.h" |
15ec34b9 | 107 | |
0e46b9ae | 108 | #include "TClonesArray.h" |
515faf5d | 109 | #include "TStopwatch.h" |
0e46b9ae | 110 | #include "TTree.h" |
5c7c93fa | 111 | //#include <TGeoManager.h> |
ac359ffe | 112 | #include <TGeoMatrix.h> |
5c7c93fa | 113 | //#include <TGeoPhysicalNode.h> |
d08a92dd | 114 | |
d0eb8f39 | 115 | #include "AliDAQ.h" |
0e46b9ae | 116 | #include "AliLoader.h" |
d08a92dd | 117 | #include "AliLog.h" |
0e46b9ae | 118 | #include "AliRawReader.h" |
d08a92dd | 119 | #include "AliRunLoader.h" |
5c7c93fa | 120 | //#include "AliAlignObj.h" |
121 | #include <AliGeomManager.h> | |
d08a92dd | 122 | |
15ec34b9 | 123 | #include "AliTOFcalib.h" |
17149e6b | 124 | #include "AliTOFChannelOnlineArray.h" |
125 | #include "AliTOFChannelOnlineStatusArray.h" | |
ba66add8 | 126 | #include "AliTOFChannelOffline.h" |
d08a92dd | 127 | #include "AliTOFClusterFinder.h" |
0e46b9ae | 128 | #include "AliTOFcluster.h" |
129 | #include "AliTOFdigit.h" | |
0e46b9ae | 130 | #include "AliTOFGeometry.h" |
15ec34b9 | 131 | #include "AliTOFrawData.h" |
0275b7df | 132 | //#include "AliTOFRawStream.h" |
0e46b9ae | 133 | |
2bf4d9d6 | 134 | #include "AliTOFDeltaBCOffset.h" |
135 | #include "AliTOFCTPLatency.h" | |
f04b3a69 | 136 | #include "AliTOFRunParams.h" |
2bf4d9d6 | 137 | |
15ec34b9 | 138 | //extern TFile *gFile; |
d08a92dd | 139 | |
140 | ClassImp(AliTOFClusterFinder) | |
141 | ||
94f5f8f2 | 142 | AliTOFClusterFinder::AliTOFClusterFinder(AliTOFcalib *calib): |
97986e79 | 143 | TTask("AliTOFClusterFinder",""), |
d08a92dd | 144 | fRunLoader(0), |
145 | fTOFLoader(0), | |
146 | fTreeD(0), | |
147 | fTreeR(0), | |
148 | fDigits(new TClonesArray("AliTOFdigit", 4000)), | |
149 | fRecPoints(new TClonesArray("AliTOFcluster", 4000)), | |
15ec34b9 | 150 | fNumberOfTofClusters(0), |
7813bb1a | 151 | fVerbose(0), |
94f5f8f2 | 152 | fDecoderVersion(0), |
0275b7df | 153 | fTOFcalib(calib), |
154 | fTOFRawStream(AliTOFRawStream()) | |
d08a92dd | 155 | { |
156 | // | |
157 | // Constructor | |
158 | // | |
159 | ||
87e6e016 | 160 | TString validity = (TString)fTOFcalib->GetOfflineValidity(); |
161 | if (validity.CompareTo("valid")==0) { | |
162 | AliInfo(Form(" validity = %s - Using offline calibration parameters",validity.Data())); | |
163 | } else { | |
164 | AliInfo(Form(" validity = %s - Using online calibration parameters",validity.Data())); | |
165 | } | |
166 | ||
d08a92dd | 167 | } |
2bf66a2d | 168 | |
d08a92dd | 169 | //______________________________________________________________________________ |
170 | ||
94f5f8f2 | 171 | AliTOFClusterFinder::AliTOFClusterFinder(AliRunLoader* runLoader, AliTOFcalib *calib): |
97986e79 | 172 | TTask("AliTOFClusterFinder",""), |
d08a92dd | 173 | fRunLoader(runLoader), |
174 | fTOFLoader(runLoader->GetLoader("TOFLoader")), | |
175 | fTreeD(0), | |
176 | fTreeR(0), | |
177 | fDigits(new TClonesArray("AliTOFdigit", 4000)), | |
178 | fRecPoints(new TClonesArray("AliTOFcluster", 4000)), | |
15ec34b9 | 179 | fNumberOfTofClusters(0), |
7813bb1a | 180 | fVerbose(0), |
94f5f8f2 | 181 | fDecoderVersion(0), |
0275b7df | 182 | fTOFcalib(calib), |
183 | fTOFRawStream(AliTOFRawStream()) | |
d08a92dd | 184 | { |
185 | // | |
186 | // Constructor | |
187 | // | |
188 | ||
87e6e016 | 189 | TString validity = (TString)fTOFcalib->GetOfflineValidity(); |
190 | if (validity.CompareTo("valid")==0) { | |
191 | AliInfo(Form(" validity = %s - Using offline calibration parameters",validity.Data())); | |
192 | } else { | |
193 | AliInfo(Form(" validity = %s - Using online calibration parameters",validity.Data())); | |
194 | } | |
195 | ||
7aeeaf38 | 196 | } |
197 | ||
198 | //------------------------------------------------------------------------ | |
199 | AliTOFClusterFinder::AliTOFClusterFinder(const AliTOFClusterFinder &source) | |
97986e79 | 200 | :TTask(source), |
58d8d9a3 | 201 | fRunLoader(0), |
202 | fTOFLoader(0), | |
203 | fTreeD(0), | |
204 | fTreeR(0), | |
8a190ba2 | 205 | fDigits(source.fDigits), |
206 | fRecPoints(source.fRecPoints), | |
15ec34b9 | 207 | fNumberOfTofClusters(0), |
94f5f8f2 | 208 | fVerbose(0), |
8a190ba2 | 209 | fDecoderVersion(source.fDecoderVersion), |
0275b7df | 210 | fTOFcalib(source.fTOFcalib), |
211 | fTOFRawStream(source.fTOFRawStream) | |
7aeeaf38 | 212 | { |
213 | // copy constructor | |
7aeeaf38 | 214 | } |
215 | ||
216 | //------------------------------------------------------------------------ | |
d0eb8f39 | 217 | AliTOFClusterFinder& AliTOFClusterFinder::operator=(const AliTOFClusterFinder &source) |
7aeeaf38 | 218 | { |
219 | // ass. op. | |
8a190ba2 | 220 | |
221 | if (this == &source) | |
222 | return *this; | |
223 | ||
97986e79 | 224 | TTask::operator=(source); |
8a190ba2 | 225 | fDigits=source.fDigits; |
226 | fRecPoints=source.fRecPoints; | |
227 | fVerbose=source.fVerbose; | |
228 | fDecoderVersion=source.fDecoderVersion; | |
229 | fTOFcalib=source.fTOFcalib; | |
0275b7df | 230 | fTOFRawStream=source.fTOFRawStream; |
7aeeaf38 | 231 | return *this; |
232 | ||
d08a92dd | 233 | } |
234 | //______________________________________________________________________________ | |
235 | ||
236 | AliTOFClusterFinder::~AliTOFClusterFinder() | |
237 | { | |
238 | ||
239 | // | |
240 | // Destructor | |
241 | // | |
242 | ||
243 | if (fDigits) | |
244 | { | |
245 | fDigits->Delete(); | |
246 | delete fDigits; | |
247 | fDigits=0; | |
248 | } | |
249 | if (fRecPoints) | |
250 | { | |
251 | fRecPoints->Delete(); | |
252 | delete fRecPoints; | |
253 | fRecPoints=0; | |
254 | } | |
255 | ||
8ba211c3 | 256 | if (fTofClusters || fNumberOfTofClusters) { |
257 | for (Int_t ii=0; ii<fNumberOfTofClusters; ii++) | |
fd6c5c3d | 258 | if (fTofClusters[ii]) fTofClusters[ii]->Delete(); |
8ba211c3 | 259 | fNumberOfTofClusters=0; |
260 | } | |
261 | ||
d08a92dd | 262 | } |
263 | //______________________________________________________________________________ | |
264 | ||
265 | void AliTOFClusterFinder::Digits2RecPoints(Int_t iEvent) | |
266 | { | |
267 | // | |
268 | // Converts digits to recpoints for TOF | |
269 | // | |
270 | ||
515faf5d | 271 | TStopwatch stopwatch; |
272 | stopwatch.Start(); | |
273 | ||
56483762 | 274 | Int_t inholes = 0; |
275 | ||
d08a92dd | 276 | fRunLoader->GetEvent(iEvent); |
277 | ||
278 | fTreeD = fTOFLoader->TreeD(); | |
279 | if (fTreeD == 0x0) | |
280 | { | |
281 | AliFatal("AliTOFClusterFinder: Can not get TreeD"); | |
282 | } | |
283 | ||
284 | TBranch *branch = fTreeD->GetBranch("TOF"); | |
285 | if (!branch) { | |
286 | AliError("can't get the branch with the TOF digits !"); | |
287 | return; | |
288 | } | |
289 | ||
b24266ca | 290 | TClonesArray staticdigits("AliTOFdigit",10000); |
291 | staticdigits.Clear(); | |
292 | TClonesArray *digits =&staticdigits; | |
d08a92dd | 293 | branch->SetAddress(&digits); |
294 | ||
295 | ResetRecpoint(); | |
296 | ||
297 | fTreeR = fTOFLoader->TreeR(); | |
298 | if (fTreeR == 0x0) | |
299 | { | |
300 | fTOFLoader->MakeTree("R"); | |
301 | fTreeR = fTOFLoader->TreeR(); | |
302 | } | |
303 | ||
304 | Int_t bufsize = 32000; | |
305 | fTreeR->Branch("TOF", &fRecPoints, bufsize); | |
306 | ||
307 | fTreeD->GetEvent(0); | |
308 | Int_t nDigits = digits->GetEntriesFast(); | |
309 | AliDebug(2,Form("Number of TOF digits: %d",nDigits)); | |
310 | ||
ac359ffe | 311 | Int_t ii; |
3495d79c | 312 | Int_t dig[5]={-1,-1,-1,-1,-1}; //cluster detector indeces |
313 | Int_t parTOF[7]={0,0,0,0,0,0,0}; //The TOF signal parameters | |
bf33f8f0 | 314 | Bool_t status=kTRUE; // assume all sim channels ok in the beginning... |
d08a92dd | 315 | for (ii=0; ii<nDigits; ii++) { |
316 | AliTOFdigit *d = (AliTOFdigit*)digits->UncheckedAt(ii); | |
317 | dig[0]=d->GetSector(); | |
318 | dig[1]=d->GetPlate(); | |
319 | dig[2]=d->GetStrip(); | |
320 | dig[3]=d->GetPadz(); | |
321 | dig[4]=d->GetPadx(); | |
322 | ||
729f0d7f | 323 | /* check valid index */ |
324 | if (dig[0]==-1||dig[1]==-1||dig[2]==-1||dig[3]==-1||dig[4]==-1) continue; | |
325 | ||
56483762 | 326 | // Do not reconstruct anything in the holes |
327 | if (dig[0]==13 || dig[0]==14 || dig[0]==15 ) { // sectors with holes | |
328 | if (dig[1]==2) { // plate with holes | |
329 | inholes++; | |
330 | continue; | |
331 | } | |
332 | } | |
333 | ||
2bf66a2d | 334 | AliDebug(2,Form(" %2d %1d %2d %1d %2d ",dig[0],dig[1],dig[2],dig[3],dig[4])); |
d0eb8f39 | 335 | |
bf33f8f0 | 336 | parTOF[0] = d->GetTdc(); //the TDC signal |
337 | parTOF[1] = d->GetToT(); //the ToT signal | |
338 | parTOF[2] = d->GetAdc(); // the adc charge | |
339 | parTOF[3] = d->GetTdcND(); // non decalibrated sim time | |
340 | parTOF[4] = d->GetTdc(); // raw time, == Tdc time for the moment | |
2bf4d9d6 | 341 | parTOF[5] = 0; // deltaBC |
342 | parTOF[6] = 0; // L0-L1 latency | |
ac359ffe | 343 | Double_t posClus[3]; |
344 | Double_t covClus[6]; | |
345 | UShort_t volIdClus=GetClusterVolIndex(dig); | |
346 | GetClusterPars(dig, posClus,covClus); | |
347 | 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 | 348 | InsertCluster(tofCluster); |
bafe290d | 349 | |
d08a92dd | 350 | } |
351 | ||
bafe290d | 352 | AliDebug(1,Form("Number of found clusters: %d for event: %d", fNumberOfTofClusters, iEvent)); |
d08a92dd | 353 | |
37879eed | 354 | CalibrateRecPoint(); |
d08a92dd | 355 | FillRecPoint(); |
356 | ||
357 | fTreeR->Fill(); | |
358 | ResetRecpoint(); | |
359 | ||
360 | fTOFLoader = fRunLoader->GetLoader("TOFLoader"); | |
361 | fTOFLoader->WriteRecPoints("OVERWRITE"); | |
362 | ||
bafe290d | 363 | AliDebug(1,Form("Execution time to read TOF digits and to write TOF clusters : R:%.4fs C:%.4fs", |
364 | stopwatch.RealTime(),stopwatch.CpuTime())); | |
56483762 | 365 | if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes)); |
515faf5d | 366 | |
94f5f8f2 | 367 | } |
368 | ||
369 | //______________________________________________________________________________ | |
370 | ||
371 | void AliTOFClusterFinder::Digits2RecPoints(TTree* digitsTree, TTree* clusterTree) | |
372 | { | |
373 | // | |
374 | // Converts digits to recpoints for TOF | |
375 | // | |
376 | ||
377 | TStopwatch stopwatch; | |
378 | stopwatch.Start(); | |
379 | ||
56483762 | 380 | Int_t inholes = 0; |
381 | ||
94f5f8f2 | 382 | /// fRunLoader->GetEvent(iEvent); |
383 | ||
384 | if (digitsTree == 0x0) | |
385 | { | |
386 | AliFatal("AliTOFClusterFinder: Can not get TreeD"); | |
387 | } | |
388 | ||
389 | TBranch *branch = digitsTree->GetBranch("TOF"); | |
390 | if (!branch) { | |
391 | AliError("can't get the branch with the TOF digits !"); | |
392 | return; | |
393 | } | |
394 | ||
b24266ca | 395 | TClonesArray staticdigits("AliTOFdigit",10000); |
396 | staticdigits.Clear(); | |
397 | TClonesArray *digits = & staticdigits; | |
94f5f8f2 | 398 | branch->SetAddress(&digits); |
399 | ||
400 | ResetRecpoint(); | |
401 | ||
402 | fTreeR=clusterTree; | |
403 | Int_t bufsize = 32000; | |
404 | fTreeR->Branch("TOF", &fRecPoints, bufsize); | |
405 | ||
406 | digitsTree->GetEvent(0); | |
407 | Int_t nDigits = digits->GetEntriesFast(); | |
408 | AliDebug(2,Form("Number of TOF digits: %d",nDigits)); | |
409 | ||
ac359ffe | 410 | Int_t ii; |
3495d79c | 411 | Int_t dig[5]={-1,-1,-1,-1,-1}; //cluster detector indeces |
412 | Int_t parTOF[7]={0,0,0,0,0,0,0}; //The TOF signal parameters | |
94f5f8f2 | 413 | Bool_t status=kTRUE; // assume all sim channels ok in the beginning... |
414 | for (ii=0; ii<nDigits; ii++) { | |
415 | AliTOFdigit *d = (AliTOFdigit*)digits->UncheckedAt(ii); | |
416 | dig[0]=d->GetSector(); | |
417 | dig[1]=d->GetPlate(); | |
418 | dig[2]=d->GetStrip(); | |
419 | dig[3]=d->GetPadz(); | |
420 | dig[4]=d->GetPadx(); | |
421 | ||
729f0d7f | 422 | /* check valid index */ |
423 | if (dig[0]==-1||dig[1]==-1||dig[2]==-1||dig[3]==-1||dig[4]==-1) continue; | |
424 | ||
56483762 | 425 | // Do not reconstruct anything in the holes |
426 | if (dig[0]==13 || dig[0]==14 || dig[0]==15 ) { // sectors with holes | |
427 | if (dig[1]==2) { // plate with holes | |
428 | inholes++; | |
429 | continue; | |
430 | } | |
431 | } | |
432 | ||
2bf66a2d | 433 | // AliDebug(2,Form(" %2d %1d %2d %1d %2d ",dig[0],dig[1],dig[2],dig[3],dig[4])); |
94f5f8f2 | 434 | |
94f5f8f2 | 435 | parTOF[0] = d->GetTdc(); //the TDC signal |
436 | parTOF[1] = d->GetToT(); //the ToT signal | |
437 | parTOF[2] = d->GetAdc(); // the adc charge | |
438 | parTOF[3] = d->GetTdcND(); // non decalibrated sim time | |
439 | parTOF[4] = d->GetTdc(); // raw time, == Tdc time for the moment | |
2bf4d9d6 | 440 | parTOF[5] = 0; // deltaBC |
441 | parTOF[6] = 0; // L0-L1 latency | |
ac359ffe | 442 | |
443 | Double_t posClus[3]; | |
444 | Double_t covClus[6]; | |
445 | UShort_t volIdClus=GetClusterVolIndex(dig); | |
446 | GetClusterPars(dig,posClus,covClus); | |
2bf66a2d | 447 | 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 | 448 | InsertCluster(tofCluster); |
449 | ||
450 | } | |
451 | ||
bafe290d | 452 | AliDebug(1,Form("Number of found clusters: %d", fNumberOfTofClusters)); |
94f5f8f2 | 453 | |
454 | CalibrateRecPoint(); | |
455 | FillRecPoint(); | |
456 | ||
457 | clusterTree->Fill(); | |
458 | ResetRecpoint(); | |
459 | ||
bafe290d | 460 | AliDebug(1,Form("Execution time to read TOF digits and to write TOF clusters : R:%.4fs C:%.4fs", |
461 | stopwatch.RealTime(),stopwatch.CpuTime())); | |
56483762 | 462 | if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes)); |
94f5f8f2 | 463 | |
d08a92dd | 464 | } |
465 | //______________________________________________________________________________ | |
466 | ||
467 | void AliTOFClusterFinder::Digits2RecPoints(AliRawReader *rawReader, | |
468 | TTree *clustersTree) | |
469 | { | |
470 | // | |
471 | // Converts RAW data to recpoints for TOF | |
472 | // | |
473 | ||
515faf5d | 474 | TStopwatch stopwatch; |
475 | stopwatch.Start(); | |
476 | ||
56483762 | 477 | Int_t inholes = 0; |
478 | ||
d0eb8f39 | 479 | const Int_t kDDL = AliDAQ::NumberOfDdls("TOF"); |
d08a92dd | 480 | |
481 | ResetRecpoint(); | |
482 | ||
483 | Int_t bufsize = 32000; | |
484 | clustersTree->Branch("TOF", &fRecPoints, bufsize); | |
485 | ||
15ec34b9 | 486 | TClonesArray * clonesRawData; |
487 | ||
15ec34b9 | 488 | Int_t dummy = -1; |
d08a92dd | 489 | |
490 | Int_t detectorIndex[5]; | |
2bf4d9d6 | 491 | Int_t parTOF[7]; |
d08a92dd | 492 | |
15ec34b9 | 493 | ofstream ftxt; |
494 | if (fVerbose==2) ftxt.open("TOFdigitsRead.txt",ios::app); | |
495 | ||
0275b7df | 496 | //AliTOFRawStream tofInput(rawReader); |
497 | fTOFRawStream.Clear(); | |
498 | fTOFRawStream.SetRawReader(rawReader); | |
ef58b2af | 499 | |
5b4ed716 | 500 | if (fDecoderVersion == 1) { |
bafe290d | 501 | AliInfo("Using New Decoder"); |
5b4ed716 | 502 | } |
503 | else if (fDecoderVersion == 2) { | |
504 | AliInfo("Using Enhanced Decoder"); | |
505 | } | |
506 | else { | |
507 | AliInfo("Using Old Decoder"); | |
508 | } | |
bafe290d | 509 | |
15ec34b9 | 510 | Int_t indexDDL = 0; |
511 | for (indexDDL = 0; indexDDL < kDDL; indexDDL++) { | |
512 | ||
513 | rawReader->Reset(); | |
5b4ed716 | 514 | if (fDecoderVersion == 1) { |
0275b7df | 515 | fTOFRawStream.LoadRawDataBuffers(indexDDL,fVerbose); |
5b4ed716 | 516 | } |
517 | else if (fDecoderVersion == 2) { | |
518 | fTOFRawStream.LoadRawDataBuffersV2(indexDDL,fVerbose); | |
519 | } | |
520 | else { | |
521 | fTOFRawStream.LoadRawData(indexDDL); | |
522 | } | |
523 | ||
0275b7df | 524 | clonesRawData = (TClonesArray*)fTOFRawStream.GetRawData(); |
5b4ed716 | 525 | |
15ec34b9 | 526 | for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) { |
527 | ||
528 | AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData); | |
529 | ||
c3891b7a | 530 | //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue; |
531 | if (tofRawDatum->GetTOF()==-1) continue; | |
15ec34b9 | 532 | |
533 | if (fVerbose==2) { | |
534 | if (indexDDL<10) ftxt << " " << indexDDL; | |
535 | else ftxt << " " << indexDDL; | |
536 | if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM(); | |
537 | else ftxt << " " << tofRawDatum->GetTRM(); | |
538 | ftxt << " " << tofRawDatum->GetTRMchain(); | |
539 | if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC(); | |
540 | else ftxt << " " << tofRawDatum->GetTDC(); | |
541 | ftxt << " " << tofRawDatum->GetTDCchannel(); | |
542 | } | |
543 | ||
0275b7df | 544 | fTOFRawStream.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(), |
545 | tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex); | |
15ec34b9 | 546 | dummy = detectorIndex[3]; |
547 | detectorIndex[3] = detectorIndex[4]; | |
548 | detectorIndex[4] = dummy; | |
549 | ||
550 | if (fVerbose==2) { | |
551 | if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0]; | |
552 | else ftxt << " -> " << detectorIndex[0]; | |
553 | ftxt << " " << detectorIndex[1]; | |
554 | if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2]; | |
555 | else ftxt << " " << detectorIndex[2]; | |
556 | ftxt << " " << detectorIndex[3]; | |
557 | if (detectorIndex[4]<10) ftxt << " " << detectorIndex[4]; | |
558 | else ftxt << " " << detectorIndex[4]; | |
559 | } | |
560 | ||
729f0d7f | 561 | /* check valid index */ |
562 | if (detectorIndex[0]==-1||detectorIndex[1]==-1||detectorIndex[2]==-1||detectorIndex[3]==-1||detectorIndex[4]==-1) continue; | |
563 | ||
56483762 | 564 | // Do not reconstruct anything in the holes |
565 | if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes | |
566 | if (detectorIndex[1]==2) { // plate with holes | |
567 | inholes++; | |
568 | continue; | |
569 | } | |
570 | } | |
571 | ||
bf33f8f0 | 572 | parTOF[0] = tofRawDatum->GetTOF(); //TDC |
573 | parTOF[1] = tofRawDatum->GetTOT(); // TOT | |
574 | parTOF[2] = tofRawDatum->GetTOT(); //ADC==TOF | |
3495d79c | 575 | parTOF[3] = 0;//raw data: no track of undecalib sim time |
bf33f8f0 | 576 | parTOF[4] = tofRawDatum->GetTOF(); // RAW time |
2bf4d9d6 | 577 | parTOF[5] = tofRawDatum->GetDeltaBC(); // deltaBC |
578 | parTOF[6] = tofRawDatum->GetL0L1Latency(); // L0-L1 latency | |
ac359ffe | 579 | Double_t posClus[3]; |
580 | Double_t covClus[6]; | |
581 | UShort_t volIdClus=GetClusterVolIndex(detectorIndex); | |
582 | Int_t lab[3]={-1,-1,-1}; | |
583 | Bool_t status=kTRUE; | |
584 | GetClusterPars(detectorIndex,posClus,covClus); | |
2bf66a2d | 585 | 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 | 586 | InsertCluster(tofCluster); |
587 | ||
588 | if (fVerbose==2) { | |
bf33f8f0 | 589 | if (parTOF[1]<10)ftxt << " " << parTOF[1]; |
590 | else if (parTOF[1]>=10 && parTOF[1]<100) ftxt << " " << parTOF[1]; | |
591 | else ftxt << " " << parTOF[1]; | |
592 | if (parTOF[0]<10) ftxt << " " << parTOF[0] << endl; | |
593 | else if (parTOF[0]>=10 && parTOF[0]<100) ftxt << " " << parTOF[0] << endl; | |
594 | else if (parTOF[0]>=100 && parTOF[0]<1000) ftxt << " " << parTOF[0] << endl; | |
595 | else ftxt << " " << parTOF[3] << endl; | |
15ec34b9 | 596 | } |
597 | ||
598 | } // closed loop on TOF raw data per current DDL file | |
599 | ||
600 | clonesRawData->Clear(); | |
601 | ||
602 | } // closed loop on DDL index | |
603 | ||
15ec34b9 | 604 | if (fVerbose==2) ftxt.close(); |
d08a92dd | 605 | |
bafe290d | 606 | AliDebug(1,Form("Number of found clusters: %d", fNumberOfTofClusters)); |
d08a92dd | 607 | |
f04b3a69 | 608 | CalibrateRecPoint(rawReader->GetTimestamp()); |
d08a92dd | 609 | FillRecPoint(); |
610 | ||
611 | clustersTree->Fill(); | |
37879eed | 612 | |
d08a92dd | 613 | ResetRecpoint(); |
614 | ||
515faf5d | 615 | AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters : R:%.4fs C:%.4fs", |
616 | stopwatch.RealTime(),stopwatch.CpuTime())); | |
56483762 | 617 | if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes)); |
515faf5d | 618 | |
d08a92dd | 619 | } |
620 | //______________________________________________________________________________ | |
621 | ||
622 | void AliTOFClusterFinder::Digits2RecPoints(Int_t iEvent, AliRawReader *rawReader) | |
623 | { | |
624 | // | |
625 | // Converts RAW data to recpoints for TOF | |
626 | // | |
627 | ||
515faf5d | 628 | TStopwatch stopwatch; |
629 | stopwatch.Start(); | |
630 | ||
56483762 | 631 | Int_t inholes = 0; |
632 | ||
d0eb8f39 | 633 | const Int_t kDDL = AliDAQ::NumberOfDdls("TOF"); |
d08a92dd | 634 | |
635 | fRunLoader->GetEvent(iEvent); | |
636 | ||
2bf66a2d | 637 | AliDebug(2,Form(" Event number %2d ", iEvent)); |
d08a92dd | 638 | |
639 | fTreeR = fTOFLoader->TreeR(); | |
640 | ||
641 | if (fTreeR == 0x0){ | |
642 | fTOFLoader->MakeTree("R"); | |
643 | fTreeR = fTOFLoader->TreeR(); | |
644 | } | |
645 | ||
646 | Int_t bufsize = 32000; | |
647 | fTreeR->Branch("TOF", &fRecPoints, bufsize); | |
648 | ||
15ec34b9 | 649 | TClonesArray * clonesRawData; |
650 | ||
15ec34b9 | 651 | Int_t dummy = -1; |
d08a92dd | 652 | |
d0eb8f39 | 653 | Int_t detectorIndex[5] = {-1, -1, -1, -1, -1}; |
2bf4d9d6 | 654 | Int_t parTOF[7]; |
15ec34b9 | 655 | ofstream ftxt; |
656 | if (fVerbose==2) ftxt.open("TOFdigitsRead.txt",ios::app); | |
657 | ||
0275b7df | 658 | //AliTOFRawStream tofInput(rawReader); |
659 | fTOFRawStream.Clear(); | |
660 | fTOFRawStream.SetRawReader(rawReader); | |
ef58b2af | 661 | |
5b4ed716 | 662 | if (fDecoderVersion == 1) { |
bafe290d | 663 | AliInfo("Using New Decoder"); |
5b4ed716 | 664 | } |
665 | else if (fDecoderVersion == 2) { | |
666 | AliInfo("Using Enhanced Decoder"); | |
667 | } | |
668 | else { | |
669 | AliInfo("Using Old Decoder"); | |
670 | } | |
bafe290d | 671 | |
15ec34b9 | 672 | Int_t indexDDL = 0; |
d08a92dd | 673 | for (indexDDL = 0; indexDDL < kDDL; indexDDL++) { |
674 | ||
675 | rawReader->Reset(); | |
5b4ed716 | 676 | if (fDecoderVersion == 1) { |
0275b7df | 677 | fTOFRawStream.LoadRawDataBuffers(indexDDL,fVerbose); |
5b4ed716 | 678 | } |
679 | else if (fDecoderVersion == 2) { | |
680 | fTOFRawStream.LoadRawDataBuffersV2(indexDDL,fVerbose); | |
681 | } | |
682 | else { | |
683 | fTOFRawStream.LoadRawData(indexDDL); | |
684 | } | |
15ec34b9 | 685 | |
0275b7df | 686 | clonesRawData = (TClonesArray*)fTOFRawStream.GetRawData(); |
15ec34b9 | 687 | |
688 | for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) { | |
689 | ||
690 | AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData); | |
691 | ||
c3891b7a | 692 | //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue; |
693 | if (tofRawDatum->GetTOF()==-1) continue; | |
15ec34b9 | 694 | |
695 | if (fVerbose==2) { | |
696 | if (indexDDL<10) ftxt << " " << indexDDL; | |
697 | else ftxt << " " << indexDDL; | |
698 | if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM(); | |
699 | else ftxt << " " << tofRawDatum->GetTRM(); | |
700 | ftxt << " " << tofRawDatum->GetTRMchain(); | |
701 | if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC(); | |
702 | else ftxt << " " << tofRawDatum->GetTDC(); | |
703 | ftxt << " " << tofRawDatum->GetTDCchannel(); | |
704 | } | |
705 | ||
0275b7df | 706 | fTOFRawStream.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(), |
707 | tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex); | |
15ec34b9 | 708 | dummy = detectorIndex[3]; |
709 | detectorIndex[3] = detectorIndex[4]; | |
710 | detectorIndex[4] = dummy; | |
711 | ||
712 | if (fVerbose==2) { | |
713 | if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0]; | |
714 | else ftxt << " -> " << detectorIndex[0]; | |
715 | ftxt << " " << detectorIndex[1]; | |
716 | if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2]; | |
717 | else ftxt << " " << detectorIndex[2]; | |
718 | ftxt << " " << detectorIndex[3]; | |
719 | if (detectorIndex[4]<10) ftxt << " " << detectorIndex[4]; | |
720 | else ftxt << " " << detectorIndex[4]; | |
721 | } | |
d0eb8f39 | 722 | |
729f0d7f | 723 | /* check valid index */ |
724 | if (detectorIndex[0]==-1||detectorIndex[1]==-1||detectorIndex[2]==-1||detectorIndex[3]==-1||detectorIndex[4]==-1) continue; | |
725 | ||
56483762 | 726 | // Do not reconstruct anything in the holes |
727 | if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes | |
728 | if (detectorIndex[1]==2) { // plate with holes | |
729 | inholes++; | |
730 | continue; | |
731 | } | |
732 | } | |
733 | ||
bf33f8f0 | 734 | parTOF[0] = tofRawDatum->GetTOF(); // TDC |
735 | parTOF[1] = tofRawDatum->GetTOT(); // TOT | |
736 | parTOF[2] = tofRawDatum->GetTOT(); // raw data have ADC=TOT | |
3495d79c | 737 | parTOF[3] = 0; //raw data: no track of the undecalib sim time |
bf33f8f0 | 738 | parTOF[4] = tofRawDatum->GetTOF(); // Raw time == TDC |
2bf4d9d6 | 739 | parTOF[5] = tofRawDatum->GetDeltaBC(); // deltaBC |
740 | parTOF[6] = tofRawDatum->GetL0L1Latency(); // L0-L1 latency | |
ac359ffe | 741 | Double_t posClus[3]; |
742 | Double_t covClus[6]; | |
743 | UShort_t volIdClus=GetClusterVolIndex(detectorIndex); | |
744 | Int_t lab[3]={-1,-1,-1}; | |
745 | Bool_t status=kTRUE; | |
746 | GetClusterPars(detectorIndex,posClus,covClus); | |
747 | 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 | 748 | InsertCluster(tofCluster); |
749 | ||
15ec34b9 | 750 | if (fVerbose==2) { |
bf33f8f0 | 751 | if (parTOF[1]<10)ftxt << " " << parTOF[1]; |
752 | else if (parTOF[1]>=10 && parTOF[1]<100) ftxt << " " << parTOF[1]; | |
753 | else ftxt << " " << parTOF[1]; | |
754 | if (parTOF[0]<10) ftxt << " " << parTOF[0] << endl; | |
755 | else if (parTOF[0]>=10 && parTOF[0]<100) ftxt << " " << parTOF[0] << endl; | |
756 | else if (parTOF[0]>=100 && parTOF[0]<1000) ftxt << " " << parTOF[0] << endl; | |
757 | else ftxt << " " << parTOF[3] << endl; | |
15ec34b9 | 758 | } |
d08a92dd | 759 | |
15ec34b9 | 760 | } // closed loop on TOF raw data per current DDL file |
761 | ||
762 | clonesRawData->Clear(); | |
763 | ||
764 | } // closed loop on DDL index | |
765 | ||
766 | if (fVerbose==2) ftxt.close(); | |
d08a92dd | 767 | |
bafe290d | 768 | AliDebug(1,Form("Number of found clusters: %d for event: %d", fNumberOfTofClusters, iEvent)); |
d08a92dd | 769 | |
f04b3a69 | 770 | CalibrateRecPoint(rawReader->GetTimestamp()); |
d08a92dd | 771 | FillRecPoint(); |
772 | ||
773 | fTreeR->Fill(); | |
774 | ResetRecpoint(); | |
775 | ||
776 | fTOFLoader = fRunLoader->GetLoader("TOFLoader"); | |
777 | fTOFLoader->WriteRecPoints("OVERWRITE"); | |
778 | ||
515faf5d | 779 | AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters : R:%.4fs C:%.4fs", |
780 | stopwatch.RealTime(),stopwatch.CpuTime())); | |
56483762 | 781 | if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes)); |
515faf5d | 782 | |
d08a92dd | 783 | } |
784 | //______________________________________________________________________________ | |
785 | ||
786 | void AliTOFClusterFinder::Raw2Digits(Int_t iEvent, AliRawReader *rawReader) | |
787 | { | |
788 | // | |
789 | // Converts RAW data to MC digits for TOF | |
790 | // | |
791 | // (temporary solution) | |
792 | // | |
793 | ||
515faf5d | 794 | TStopwatch stopwatch; |
795 | stopwatch.Start(); | |
796 | ||
ba66add8 | 797 | const Int_t kDDL = AliTOFGeometry::NDDL()*AliTOFGeometry::NSectors(); |
15ec34b9 | 798 | |
d08a92dd | 799 | fRunLoader->GetEvent(iEvent); |
800 | ||
801 | fTreeD = fTOFLoader->TreeD(); | |
802 | if (fTreeD) | |
803 | { | |
d0eb8f39 | 804 | AliInfo("TreeD re-creation"); |
d08a92dd | 805 | fTreeD = 0x0; |
806 | fTOFLoader->MakeTree("D"); | |
807 | fTreeD = fTOFLoader->TreeD(); | |
808 | } | |
809 | ||
15ec34b9 | 810 | TClonesArray *tofDigits = new TClonesArray("AliTOFdigit",10000); |
d08a92dd | 811 | Int_t bufsize = 32000; |
812 | fTreeD->Branch("TOF", &tofDigits, bufsize); | |
813 | ||
d08a92dd | 814 | fRunLoader->GetEvent(iEvent); |
815 | ||
2bf66a2d | 816 | AliDebug(2,Form(" Event number %2d ", iEvent)); |
d08a92dd | 817 | |
15ec34b9 | 818 | TClonesArray * clonesRawData; |
819 | ||
820 | Int_t dummy = -1; | |
d08a92dd | 821 | |
822 | Int_t detectorIndex[5]; | |
bf33f8f0 | 823 | Int_t digit[4]; |
d08a92dd | 824 | |
0275b7df | 825 | //AliTOFRawStream tofInput(rawReader); |
826 | fTOFRawStream.Clear(); | |
827 | fTOFRawStream.SetRawReader(rawReader); | |
ef58b2af | 828 | |
5b4ed716 | 829 | if (fDecoderVersion == 1) { |
bafe290d | 830 | AliInfo("Using New Decoder"); |
5b4ed716 | 831 | } |
832 | else if (fDecoderVersion == 2) { | |
833 | AliInfo("Using Enhanced Decoder"); | |
834 | } | |
835 | else { | |
836 | AliInfo("Using Old Decoder"); | |
837 | } | |
bafe290d | 838 | |
15ec34b9 | 839 | Int_t indexDDL = 0; |
d08a92dd | 840 | for (indexDDL = 0; indexDDL < kDDL; indexDDL++) { |
841 | ||
842 | rawReader->Reset(); | |
5b4ed716 | 843 | if (fDecoderVersion == 1) { |
0275b7df | 844 | fTOFRawStream.LoadRawDataBuffers(indexDDL,fVerbose); |
5b4ed716 | 845 | } |
846 | else if (fDecoderVersion == 2) { | |
847 | fTOFRawStream.LoadRawDataBuffersV2(indexDDL,fVerbose); | |
848 | } | |
849 | else { | |
850 | fTOFRawStream.LoadRawData(indexDDL); | |
851 | } | |
d08a92dd | 852 | |
0275b7df | 853 | clonesRawData = (TClonesArray*)fTOFRawStream.GetRawData(); |
d08a92dd | 854 | |
15ec34b9 | 855 | for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) { |
d0eb8f39 | 856 | |
15ec34b9 | 857 | AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData); |
d0eb8f39 | 858 | |
3e2f0097 | 859 | //if (!tofRawDatum->GetTOT() || !tofRawDatum->GetTOF()) continue; |
860 | if (tofRawDatum->GetTOF()==-1) continue; | |
15ec34b9 | 861 | |
0275b7df | 862 | fTOFRawStream.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(), |
863 | tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex); | |
15ec34b9 | 864 | dummy = detectorIndex[3]; |
865 | detectorIndex[3] = detectorIndex[4]; | |
866 | detectorIndex[4] = dummy; | |
d0eb8f39 | 867 | |
0275b7df | 868 | digit[0] = fTOFRawStream.GetTofBin(); |
869 | digit[1] = fTOFRawStream.GetToTbin(); | |
870 | digit[2] = fTOFRawStream.GetToTbin(); | |
3495d79c | 871 | digit[3] = 0; |
d08a92dd | 872 | |
873 | Int_t tracknum[3]={-1,-1,-1}; | |
874 | ||
875 | TClonesArray &aDigits = *tofDigits; | |
876 | Int_t last=tofDigits->GetEntriesFast(); | |
877 | new (aDigits[last]) AliTOFdigit(tracknum, detectorIndex, digit); | |
878 | ||
879 | } // while loop | |
880 | ||
15ec34b9 | 881 | clonesRawData->Clear(); |
882 | ||
d08a92dd | 883 | } // DDL Loop |
884 | ||
885 | fTreeD->Fill(); | |
886 | ||
887 | fTOFLoader = fRunLoader->GetLoader("TOFLoader"); | |
888 | fTOFLoader->WriteDigits("OVERWRITE"); | |
2bf66a2d | 889 | |
890 | delete tofDigits; | |
891 | ||
515faf5d | 892 | AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters : R:%.2fs C:%.2fs", |
893 | stopwatch.RealTime(),stopwatch.CpuTime())); | |
894 | ||
94f5f8f2 | 895 | } |
896 | ||
897 | //______________________________________________________________________________ | |
898 | ||
899 | void AliTOFClusterFinder::Raw2Digits(AliRawReader *rawReader, TTree* digitsTree) | |
900 | { | |
901 | // | |
902 | // Converts RAW data to MC digits for TOF for the current event | |
903 | // | |
904 | // | |
905 | ||
906 | TStopwatch stopwatch; | |
907 | stopwatch.Start(); | |
908 | ||
ba66add8 | 909 | const Int_t kDDL = AliTOFGeometry::NDDL()*AliTOFGeometry::NSectors(); |
94f5f8f2 | 910 | |
911 | if (!digitsTree) | |
912 | { | |
913 | AliError("No input digits Tree"); | |
914 | return; | |
915 | } | |
916 | ||
917 | TClonesArray *tofDigits = new TClonesArray("AliTOFdigit",10000); | |
918 | Int_t bufsize = 32000; | |
919 | digitsTree->Branch("TOF", &tofDigits, bufsize); | |
920 | ||
94f5f8f2 | 921 | TClonesArray * clonesRawData; |
922 | ||
923 | Int_t dummy = -1; | |
924 | ||
925 | Int_t detectorIndex[5]; | |
926 | Int_t digit[4]; | |
927 | ||
0275b7df | 928 | //AliTOFRawStream tofInput(rawReader); |
929 | fTOFRawStream.Clear(); | |
930 | fTOFRawStream.SetRawReader(rawReader); | |
ef58b2af | 931 | |
5b4ed716 | 932 | if (fDecoderVersion == 1) { |
bafe290d | 933 | AliInfo("Using New Decoder"); |
5b4ed716 | 934 | } |
935 | else if (fDecoderVersion == 2) { | |
936 | AliInfo("Using Enhanced Decoder"); | |
937 | } | |
938 | else { | |
939 | AliInfo("Using Old Decoder"); | |
940 | } | |
bafe290d | 941 | |
94f5f8f2 | 942 | Int_t indexDDL = 0; |
943 | for (indexDDL = 0; indexDDL < kDDL; indexDDL++) { | |
944 | ||
945 | rawReader->Reset(); | |
5b4ed716 | 946 | if (fDecoderVersion == 1) { |
0275b7df | 947 | fTOFRawStream.LoadRawDataBuffers(indexDDL,fVerbose); |
5b4ed716 | 948 | } |
949 | else if (fDecoderVersion == 2) { | |
950 | fTOFRawStream.LoadRawDataBuffersV2(indexDDL,fVerbose); | |
951 | } | |
952 | else { | |
953 | fTOFRawStream.LoadRawData(indexDDL); | |
954 | } | |
94f5f8f2 | 955 | |
0275b7df | 956 | clonesRawData = (TClonesArray*)fTOFRawStream.GetRawData(); |
94f5f8f2 | 957 | |
958 | for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) { | |
959 | ||
960 | AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData); | |
961 | ||
3e2f0097 | 962 | //if (!tofRawDatum->GetTOT() || !tofRawDatum->GetTOF()) continue; |
963 | if (tofRawDatum->GetTOF()==-1) continue; | |
94f5f8f2 | 964 | |
0275b7df | 965 | fTOFRawStream.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(), |
966 | tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex); | |
94f5f8f2 | 967 | dummy = detectorIndex[3]; |
968 | detectorIndex[3] = detectorIndex[4]; | |
969 | detectorIndex[4] = dummy; | |
970 | ||
0275b7df | 971 | digit[0] = fTOFRawStream.GetTofBin(); |
972 | digit[1] = fTOFRawStream.GetToTbin(); | |
973 | digit[2] = fTOFRawStream.GetToTbin(); | |
3495d79c | 974 | digit[3] = 0; |
94f5f8f2 | 975 | |
976 | Int_t tracknum[3]={-1,-1,-1}; | |
977 | ||
978 | TClonesArray &aDigits = *tofDigits; | |
979 | Int_t last=tofDigits->GetEntriesFast(); | |
980 | new (aDigits[last]) AliTOFdigit(tracknum, detectorIndex, digit); | |
981 | ||
982 | } // while loop | |
983 | ||
984 | clonesRawData->Clear(); | |
985 | ||
986 | } // DDL Loop | |
987 | ||
988 | digitsTree->Fill(); | |
989 | ||
2bf66a2d | 990 | delete tofDigits; |
991 | ||
992 | AliDebug(1, Form("Got %d digits: ", fDigits->GetEntries())); | |
94f5f8f2 | 993 | AliDebug(1, Form("Execution time to read TOF raw data and fill TOF digit tree : R:%.2fs C:%.2fs", |
994 | stopwatch.RealTime(),stopwatch.CpuTime())); | |
995 | ||
d08a92dd | 996 | } |
997 | //______________________________________________________________________________ | |
998 | ||
999 | Int_t AliTOFClusterFinder::InsertCluster(AliTOFcluster *tofCluster) { | |
1000 | //---------------------------------------------------------------------------// | |
1001 | // This function adds a TOF cluster to the array of TOF clusters sorted in Z // | |
1002 | //---------------------------------------------------------------------------// | |
1003 | if (fNumberOfTofClusters==kTofMaxCluster) { | |
1004 | AliError("Too many clusters !"); | |
1005 | return 1; | |
1006 | } | |
1007 | ||
1008 | if (fNumberOfTofClusters==0) { | |
1009 | fTofClusters[fNumberOfTofClusters++] = tofCluster; | |
1010 | return 0; | |
1011 | } | |
1012 | ||
1013 | Int_t ii = FindClusterIndex(tofCluster->GetZ()); | |
1014 | memmove(fTofClusters+ii+1 ,fTofClusters+ii,(fNumberOfTofClusters-ii)*sizeof(AliTOFcluster*)); | |
1015 | fTofClusters[ii] = tofCluster; | |
1016 | fNumberOfTofClusters++; | |
1017 | ||
1018 | return 0; | |
1019 | ||
1020 | } | |
1021 | //_________________________________________________________________________ | |
1022 | ||
1023 | Int_t AliTOFClusterFinder::FindClusterIndex(Double_t z) const { | |
1024 | //-------------------------------------------------------------------- | |
ac359ffe | 1025 | // This function returns the index of the nearest cluster in z |
d08a92dd | 1026 | //-------------------------------------------------------------------- |
1027 | if (fNumberOfTofClusters==0) return 0; | |
1028 | if (z <= fTofClusters[0]->GetZ()) return 0; | |
1029 | if (z > fTofClusters[fNumberOfTofClusters-1]->GetZ()) return fNumberOfTofClusters; | |
1030 | Int_t b = 0, e = fNumberOfTofClusters-1, m = (b+e)/2; | |
1031 | for (; b<e; m=(b+e)/2) { | |
1032 | if (z > fTofClusters[m]->GetZ()) b=m+1; | |
1033 | else e=m; | |
1034 | } | |
1035 | ||
1036 | return m; | |
1037 | ||
1038 | } | |
1039 | //_________________________________________________________________________ | |
1040 | ||
1041 | void AliTOFClusterFinder::FillRecPoint() | |
1042 | { | |
1043 | // | |
1044 | // Copy the global array of AliTOFcluster, i.e. fTofClusters (sorted | |
1045 | // in Z) in the global TClonesArray of AliTOFcluster, | |
1046 | // i.e. fRecPoints. | |
1047 | // | |
1048 | ||
1049 | Int_t ii, jj; | |
1050 | ||
1051 | Int_t detectorIndex[5]; | |
2bf4d9d6 | 1052 | Int_t parTOF[7]; |
d08a92dd | 1053 | Int_t trackLabels[3]; |
1054 | Int_t digitIndex = -1; | |
bf33f8f0 | 1055 | Bool_t status=kTRUE; |
d08a92dd | 1056 | |
1057 | TClonesArray &lRecPoints = *fRecPoints; | |
1058 | ||
1059 | for (ii=0; ii<fNumberOfTofClusters; ii++) { | |
1060 | ||
1061 | digitIndex = fTofClusters[ii]->GetIndex(); | |
1062 | for(jj=0; jj<5; jj++) detectorIndex[jj] = fTofClusters[ii]->GetDetInd(jj); | |
1063 | for(jj=0; jj<3; jj++) trackLabels[jj] = fTofClusters[ii]->GetLabel(jj); | |
bf33f8f0 | 1064 | parTOF[0] = fTofClusters[ii]->GetTDC(); // TDC |
1065 | parTOF[1] = fTofClusters[ii]->GetToT(); // TOT | |
1066 | parTOF[2] = fTofClusters[ii]->GetADC(); // ADC=TOT | |
1067 | parTOF[3] = fTofClusters[ii]->GetTDCND(); // TDCND | |
1068 | parTOF[4] = fTofClusters[ii]->GetTDCRAW();//RAW | |
2bf4d9d6 | 1069 | parTOF[5] = fTofClusters[ii]->GetDeltaBC();//deltaBC |
1070 | parTOF[6] = fTofClusters[ii]->GetL0L1Latency();//L0-L1 latency | |
bf33f8f0 | 1071 | status=fTofClusters[ii]->GetStatus(); |
ac359ffe | 1072 | Double_t posClus[3]; |
1073 | Double_t covClus[6]; | |
1074 | UShort_t volIdClus=GetClusterVolIndex(detectorIndex); | |
1075 | GetClusterPars(detectorIndex,posClus,covClus); | |
1076 | 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 | 1077 | |
2bf66a2d | 1078 | 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", |
3e2f0097 | 1079 | ii, volIdClus, posClus[0], posClus[1], posClus[2], |
1080 | fTofClusters[ii]->GetSigmaX2(), | |
1081 | fTofClusters[ii]->GetSigmaXY(), | |
1082 | fTofClusters[ii]->GetSigmaXZ(), | |
1083 | fTofClusters[ii]->GetSigmaY2(), | |
1084 | fTofClusters[ii]->GetSigmaYZ(), | |
1085 | fTofClusters[ii]->GetSigmaZ2(), | |
1086 | trackLabels[0], trackLabels[1], trackLabels[2], | |
1087 | detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[3], detectorIndex[4], | |
1088 | parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4], | |
1089 | status, digitIndex)); | |
1090 | ||
d08a92dd | 1091 | } // loop on clusters |
1092 | ||
1093 | } | |
37879eed | 1094 | |
1095 | //_________________________________________________________________________ | |
5b4ed716 | 1096 | |
1097 | /* | |
1098 | * OLD CALIBRATE REC POINTS FUNCTION | |
1099 | */ | |
1100 | ||
1101 | #if 0 | |
f04b3a69 | 1102 | void AliTOFClusterFinder::CalibrateRecPoint(UInt_t timestamp) |
37879eed | 1103 | { |
1104 | // | |
1105 | // Copy the global array of AliTOFcluster, i.e. fTofClusters (sorted | |
1106 | // in Z) in the global TClonesArray of AliTOFcluster, | |
1107 | // i.e. fRecPoints. | |
1108 | // | |
1109 | ||
1110 | Int_t ii, jj; | |
1111 | ||
1112 | Int_t detectorIndex[5]; | |
1113 | Int_t digitIndex = -1; | |
a33fec85 | 1114 | Double_t tToT; |
1115 | Double_t timeCorr; | |
bf33f8f0 | 1116 | Int_t tdcCorr; |
2bf4d9d6 | 1117 | Float_t tdcLatencyWindow; |
bafe290d | 1118 | AliDebug(1," Calibrating TOF Clusters"); |
1119 | ||
17149e6b | 1120 | AliTOFChannelOnlineArray *calDelay = fTOFcalib->GetTOFOnlineDelay(); |
1121 | AliTOFChannelOnlineStatusArray *calStatus = fTOFcalib->GetTOFOnlineStatus(); | |
ba66add8 | 1122 | TObjArray *calTOFArrayOffline = fTOFcalib->GetTOFCalArrayOffline(); |
2bf4d9d6 | 1123 | |
1124 | AliTOFDeltaBCOffset *deltaBCOffsetObj = fTOFcalib->GetDeltaBCOffset(); | |
1125 | Int_t deltaBCOffset = deltaBCOffsetObj->GetDeltaBCOffset(); | |
1126 | AliTOFCTPLatency *ctpLatencyObj = fTOFcalib->GetCTPLatency(); | |
1127 | Float_t ctpLatency = ctpLatencyObj->GetCTPLatency(); | |
f04b3a69 | 1128 | AliTOFRunParams *runParamsObj = fTOFcalib->GetRunParams(); |
1129 | Float_t t0 = runParamsObj->EvalT0(timestamp); | |
bafe290d | 1130 | |
ba66add8 | 1131 | TString validity = (TString)fTOFcalib->GetOfflineValidity(); |
ba66add8 | 1132 | Int_t calibration = -1; |
1133 | if (validity.CompareTo("valid")==0) { | |
87e6e016 | 1134 | //AliInfo(Form(" validity = %s - Using offline calibration parameters",validity.Data())); |
ba66add8 | 1135 | calibration = 1; |
bafe290d | 1136 | } else { |
87e6e016 | 1137 | //AliInfo(Form(" validity = %s - Using online calibration parameters",validity.Data())); |
ba66add8 | 1138 | calibration = 0 ; |
1139 | } | |
bafe290d | 1140 | |
37879eed | 1141 | for (ii=0; ii<fNumberOfTofClusters; ii++) { |
1142 | digitIndex = fTofClusters[ii]->GetIndex(); | |
1143 | for(jj=0; jj<5; jj++) detectorIndex[jj] = fTofClusters[ii]->GetDetInd(jj); | |
1144 | ||
ba66add8 | 1145 | Int_t index = AliTOFGeometry::GetIndex(detectorIndex); |
37879eed | 1146 | |
17149e6b | 1147 | UChar_t statusPulser=calStatus->GetPulserStatus(index); |
1148 | UChar_t statusNoise=calStatus->GetNoiseStatus(index); | |
1149 | UChar_t statusHW=calStatus->GetHWStatus(index); | |
1150 | UChar_t status=calStatus->GetStatus(index); | |
2bf4d9d6 | 1151 | tdcLatencyWindow = calStatus->GetLatencyWindow(index) * 1.e3; /* ns -> ps */ |
1152 | ||
17149e6b | 1153 | //check the status, also unknown is fine!!!!!!! |
1154 | ||
2bf66a2d | 1155 | AliDebug(2, Form(" Status for channel %d = %d",index, (Int_t)status)); |
17149e6b | 1156 | if((statusPulser & AliTOFChannelOnlineStatusArray::kTOFPulserBad)==(AliTOFChannelOnlineStatusArray::kTOFPulserBad)||(statusNoise & AliTOFChannelOnlineStatusArray::kTOFNoiseBad)==(AliTOFChannelOnlineStatusArray::kTOFNoiseBad)||(statusHW & AliTOFChannelOnlineStatusArray::kTOFHWBad)==(AliTOFChannelOnlineStatusArray::kTOFHWBad)){ |
2bf66a2d | 1157 | AliDebug(2, Form(" Bad Status for channel %d",index)); |
7fffa85b | 1158 | fTofClusters[ii]->SetStatus(kFALSE); //odd convention, to avoid conflict with calibration objects currently in the db (temporary solution). |
1159 | } | |
1160 | else { | |
2bf66a2d | 1161 | AliDebug(2, Form(" Good Status for channel %d",index)); |
7fffa85b | 1162 | } |
58d8d9a3 | 1163 | // Get Rough channel online equalization |
17149e6b | 1164 | Double_t roughDelay=(Double_t)calDelay->GetDelay(index); // in ns |
ba66add8 | 1165 | AliDebug(2,Form(" channel delay (ns) = %f", roughDelay)); |
58d8d9a3 | 1166 | // Get Refined channel offline calibration parameters |
ba66add8 | 1167 | if (calibration ==1){ |
1168 | AliTOFChannelOffline * calChannelOffline = (AliTOFChannelOffline*)calTOFArrayOffline->At(index); | |
1169 | Double_t par[6]; | |
1170 | for (Int_t j = 0; j<6; j++){ | |
1171 | par[j]=(Double_t)calChannelOffline->GetSlewPar(j); | |
1172 | } | |
bf33f8f0 | 1173 | AliDebug(2,Form(" Calib Pars = %f, %f, %f, %f, %f, %f ",par[0],par[1],par[2],par[3],par[4],par[5])); |
2bf66a2d | 1174 | AliDebug(2,Form(" The ToT and Time, uncorr (counts) = %d , %d", fTofClusters[ii]->GetToT(),fTofClusters[ii]->GetTDC())); |
3495d79c | 1175 | tToT = (Double_t)(fTofClusters[ii]->GetToT()*AliTOFGeometry::ToTBinWidth()); |
ba66add8 | 1176 | tToT*=1.E-3; //ToT in ns |
104ba366 | 1177 | |
1178 | /* check TOT limits and set new TOT in case */ | |
1179 | if (tToT < AliTOFGeometry::SlewTOTMin()) tToT = AliTOFGeometry::SlewTOTMin(); | |
1180 | if (tToT > AliTOFGeometry::SlewTOTMax()) tToT = AliTOFGeometry::SlewTOTMax(); | |
1181 | ||
ba66add8 | 1182 | AliDebug(2,Form(" The ToT and Time, uncorr (ns)= %e, %e",fTofClusters[ii]->GetTDC()*AliTOFGeometry::TdcBinWidth()*1.E-3,tToT)); |
1183 | 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; // the time correction (ns) | |
1184 | } | |
1185 | else { | |
1186 | timeCorr = roughDelay; // correction in ns | |
1187 | } | |
1188 | AliDebug(2,Form(" The ToT and Time, uncorr (ns)= %e, %e",fTofClusters[ii]->GetTDC()*AliTOFGeometry::TdcBinWidth()*1.E-3,fTofClusters[ii]->GetToT()*AliTOFGeometry::ToTBinWidth())); | |
bf33f8f0 | 1189 | AliDebug(2,Form(" The time correction (ns) = %f", timeCorr)); |
a33fec85 | 1190 | timeCorr=(Double_t)(fTofClusters[ii]->GetTDC())*AliTOFGeometry::TdcBinWidth()*1.E-3-timeCorr;//redefine the time |
1191 | timeCorr*=1.E3; | |
1192 | AliDebug(2,Form(" The channel time, corr (ps)= %e",timeCorr )); | |
2bf4d9d6 | 1193 | |
1194 | /* here timeCorr should be already corrected for calibration. | |
1195 | * we now go into further corrections keeping in mind that timeCorr | |
1196 | * is in ps. | |
1197 | * | |
1198 | * the following corrections are performed in this way: | |
1199 | * | |
f04b3a69 | 1200 | * time = timeRaw - deltaBC + L0L1Latency + CTPLatency - TDCLatencyWindow - T0 |
2bf4d9d6 | 1201 | * |
1202 | */ | |
1203 | ||
1204 | AliDebug(2, Form("applying further corrections (DeltaBC): DeltaBC=%d (BC bins), DeltaBCoffset=%d (BC bins)", fTofClusters[ii]->GetDeltaBC(), deltaBCOffset)); | |
1205 | AliDebug(2, Form("applying further corrections (L0L1Latency): L0L1Latency=%d (BC bins)", fTofClusters[ii]->GetL0L1Latency())); | |
1206 | AliDebug(2, Form("applying further corrections (CTPLatency): CTPLatency=%f (ps)", ctpLatency)); | |
1207 | AliDebug(2, Form("applying further corrections (TDCLatencyWindow): TDCLatencyWindow=%f (ps)", tdcLatencyWindow)); | |
f04b3a69 | 1208 | AliDebug(2, Form("applying further corrections (T0): T0=%f (ps)", t0)); |
2bf4d9d6 | 1209 | |
f04b3a69 | 1210 | /* deltaBC correction (inhibited for the time being) */ |
1211 | // timeCorr -= (fTofClusters[ii]->GetDeltaBC() - deltaBCOffset) * AliTOFGeometry::BunchCrossingBinWidth(); | |
2bf4d9d6 | 1212 | /* L0L1-latency correction */ |
1213 | timeCorr += fTofClusters[ii]->GetL0L1Latency() * AliTOFGeometry::BunchCrossingBinWidth(); | |
1214 | /* CTP-latency correction (from OCDB) */ | |
1215 | timeCorr += ctpLatency; | |
1216 | /* TDC latency-window correction (from OCDB) */ | |
1217 | timeCorr -= tdcLatencyWindow; | |
f04b3a69 | 1218 | /* T0 correction (from OCDB) */ |
1219 | timeCorr -= t0; | |
2bf4d9d6 | 1220 | |
1221 | /* | |
1222 | * end of furhter corrections | |
1223 | */ | |
1224 | ||
a33fec85 | 1225 | tdcCorr=(Int_t)(timeCorr/AliTOFGeometry::TdcBinWidth()); //the corrected time (tdc counts) |
340693af | 1226 | fTofClusters[ii]->SetTDC(tdcCorr); |
37879eed | 1227 | } // loop on clusters |
1228 | ||
37879eed | 1229 | } |
5b4ed716 | 1230 | #endif |
1231 | ||
1232 | //_________________________________________________________________________ | |
1233 | ||
1234 | void AliTOFClusterFinder::CalibrateRecPoint(UInt_t timestamp) | |
1235 | { | |
1236 | // | |
1237 | // Copy the global array of AliTOFcluster, i.e. fTofClusters (sorted | |
1238 | // in Z) in the global TClonesArray of AliTOFcluster, | |
1239 | // i.e. fRecPoints. | |
1240 | // | |
1241 | ||
1242 | Int_t detectorIndex[5]; | |
1243 | Double_t time, tot, corr; | |
1244 | Int_t deltaBC, l0l1, tdcBin; | |
1245 | for (Int_t ii = 0; ii < fNumberOfTofClusters; ii++) { | |
1246 | for(Int_t jj = 0; jj < 5; jj++) detectorIndex[jj] = fTofClusters[ii]->GetDetInd(jj); | |
1247 | ||
1248 | Int_t index = AliTOFGeometry::GetIndex(detectorIndex); | |
1249 | ||
1250 | /* check channel enabled */ | |
1251 | if (!fTOFcalib->IsChannelEnabled(index)) fTofClusters[ii]->SetStatus(kFALSE); | |
1252 | ||
1253 | /* get cluster info */ | |
1254 | time = fTofClusters[ii]->GetTDC() * AliTOFGeometry::TdcBinWidth(); /* ps */ | |
1255 | tot = fTofClusters[ii]->GetToT() * AliTOFGeometry::ToTBinWidth() * 1.e-3; /* ns */ | |
1256 | deltaBC = fTofClusters[ii]->GetDeltaBC(); | |
1257 | l0l1 = fTofClusters[ii]->GetL0L1Latency(); | |
1258 | ||
1259 | /* get correction */ | |
1260 | corr = fTOFcalib->GetTimeCorrection(index, tot, deltaBC, l0l1, timestamp); /* ps */ | |
1261 | AliDebug(2, Form("calibrate index %d: time=%f (ps) tot=%f (ns) deltaBC=%d l0l1=%d timestamp=%d corr=%f (ps)", index, time, tot, deltaBC, l0l1, timestamp, corr)); | |
1262 | ||
1263 | /* apply time correction */ | |
1264 | time -= corr; | |
1265 | ||
1266 | /* convert in TDC bins and set cluster */ | |
3495d79c | 1267 | //tdcBin = (Int_t)(time / AliTOFGeometry::TdcBinWidth()); //the corrected time (tdc counts) |
1268 | tdcBin = TMath::Nint(time / AliTOFGeometry::TdcBinWidth()); //the corrected time (tdc counts) | |
5b4ed716 | 1269 | fTofClusters[ii]->SetTDC(tdcBin); |
1270 | ||
1271 | } // loop on clusters | |
1272 | ||
1273 | } | |
1274 | ||
d08a92dd | 1275 | //______________________________________________________________________________ |
1276 | ||
1277 | void AliTOFClusterFinder::ResetRecpoint() | |
1278 | { | |
1279 | // | |
1280 | // Clear the list of reconstructed points | |
1281 | // | |
1282 | ||
1283 | fNumberOfTofClusters = 0; | |
1284 | if (fRecPoints) fRecPoints->Clear(); | |
1285 | ||
1286 | } | |
1287 | //______________________________________________________________________________ | |
1288 | ||
1289 | void AliTOFClusterFinder::Load() | |
1290 | { | |
1291 | // | |
1292 | // Load TOF.Digits.root and TOF.RecPoints.root files | |
1293 | // | |
1294 | ||
1295 | fTOFLoader->LoadDigits("READ"); | |
1296 | fTOFLoader->LoadRecPoints("recreate"); | |
1297 | ||
1298 | } | |
1299 | //______________________________________________________________________________ | |
1300 | ||
1301 | void AliTOFClusterFinder::LoadClusters() | |
1302 | { | |
1303 | // | |
1304 | // Load TOF.RecPoints.root file | |
1305 | // | |
1306 | ||
1307 | fTOFLoader->LoadRecPoints("recreate"); | |
1308 | ||
1309 | } | |
1310 | //______________________________________________________________________________ | |
1311 | ||
1312 | void AliTOFClusterFinder::UnLoad() | |
1313 | { | |
1314 | // | |
1315 | // Unload TOF.Digits.root and TOF.RecPoints.root files | |
1316 | // | |
1317 | ||
1318 | fTOFLoader->UnloadDigits(); | |
1319 | fTOFLoader->UnloadRecPoints(); | |
1320 | ||
1321 | } | |
1322 | //______________________________________________________________________________ | |
1323 | ||
1324 | void AliTOFClusterFinder::UnLoadClusters() | |
1325 | { | |
1326 | // | |
1327 | // Unload TOF.RecPoints.root file | |
1328 | // | |
1329 | ||
1330 | fTOFLoader->UnloadRecPoints(); | |
1331 | ||
1332 | } | |
ac359ffe | 1333 | //------------------------------------------------------------------------- |
0e74c396 | 1334 | UShort_t AliTOFClusterFinder::GetClusterVolIndex(const Int_t * const ind) const { |
ac359ffe | 1335 | |
1336 | //First of all get the volume ID to retrieve the l2t transformation... | |
1337 | // | |
1338 | // Detector numbering scheme | |
1339 | Int_t nSector = 18; | |
1340 | Int_t nPlate = 5; | |
1341 | Int_t nStripA = 15; | |
1342 | Int_t nStripB = 19; | |
1343 | Int_t nStripC = 19; | |
1344 | ||
1345 | Int_t isector =ind[0]; | |
1346 | if (isector >= nSector) | |
1347 | AliError(Form("Wrong sector number in TOF (%d) !",isector)); | |
1348 | Int_t iplate = ind[1]; | |
1349 | if (iplate >= nPlate) | |
1350 | AliError(Form("Wrong plate number in TOF (%d) !",iplate)); | |
1351 | Int_t istrip = ind[2]; | |
1352 | ||
1353 | Int_t stripOffset = 0; | |
1354 | switch (iplate) { | |
1355 | case 0: | |
1356 | stripOffset = 0; | |
1357 | break; | |
1358 | case 1: | |
1359 | stripOffset = nStripC; | |
1360 | break; | |
1361 | case 2: | |
1362 | stripOffset = nStripC+nStripB; | |
1363 | break; | |
1364 | case 3: | |
1365 | stripOffset = nStripC+nStripB+nStripA; | |
1366 | break; | |
1367 | case 4: | |
1368 | stripOffset = nStripC+nStripB+nStripA+nStripB; | |
1369 | break; | |
1370 | default: | |
1371 | AliError(Form("Wrong plate number in TOF (%d) !",iplate)); | |
1372 | break; | |
1373 | }; | |
1374 | ||
1375 | Int_t index= (2*(nStripC+nStripB)+nStripA)*isector + | |
1376 | stripOffset + | |
1377 | istrip; | |
1378 | ||
1379 | UShort_t volIndex = AliGeomManager::LayerToVolUID(AliGeomManager::kTOF,index); | |
1380 | return volIndex; | |
1381 | } | |
1382 | // | |
1383 | //------------------------------------------------------------------------- | |
1384 | void AliTOFClusterFinder::GetClusterPars(Int_t *ind, Double_t* pos,Double_t* cov) const { | |
1385 | ||
1386 | //First of all get the volume ID to retrieve the l2t transformation... | |
1387 | // | |
1388 | UShort_t volIndex = GetClusterVolIndex(ind); | |
1389 | // | |
1390 | // | |
1391 | //we now go in the system of the strip: determine the local coordinates | |
1392 | // | |
1393 | // | |
1394 | // 47---------------------------------------------------0 ^ z | |
1395 | // | | | | | | | | | | | | | | | | | | | | | | | | | | | 1 | | |
1396 | // ----------------------------------------------------- | y going outwards | |
1397 | // | | | | | | | | | | | | | | | | | | | | | | | | | | | 0 | par[0]=0; | |
1398 | ||
1399 | // ----------------------------------------------------- | | |
1400 | // x <----------------------------------------------------- | |
1401 | ||
b3e52baa | 1402 | /* |
1403 | Float_t localX = (ind[4]-23.5)*AliTOFGeometry::XPad(); | |
1404 | Float_t localY = 0; | |
1405 | Float_t localZ = (ind[3]- 0.5)*AliTOFGeometry::ZPad(); | |
1406 | */ | |
1407 | Float_t localX = (ind[4]-AliTOFGeometry::NpadX()/2)*AliTOFGeometry::XPad()+AliTOFGeometry::XPad()/2.; | |
1408 | Float_t localY = 0; | |
1409 | Float_t localZ = (ind[3]-AliTOFGeometry::NpadZ()/2)*AliTOFGeometry::ZPad()+AliTOFGeometry::ZPad()/2.; | |
ac359ffe | 1410 | //move to the tracking ref system |
1411 | ||
1412 | Double_t lpos[3]; | |
b3e52baa | 1413 | lpos[0] = localX; |
1414 | lpos[1] = localY; | |
1415 | lpos[2] = localZ; | |
ac359ffe | 1416 | |
1417 | const TGeoHMatrix *l2t= AliGeomManager::GetTracking2LocalMatrix(volIndex); | |
1418 | // Get The position in the track ref system | |
1419 | Double_t tpos[3]; | |
1420 | l2t->MasterToLocal(lpos,tpos); | |
b3e52baa | 1421 | pos[0] = tpos[0]; |
1422 | pos[1] = tpos[1]; | |
1423 | pos[2] = tpos[2]; | |
ac359ffe | 1424 | |
1425 | //Get The cluster covariance in the track ref system | |
1426 | Double_t lcov[9]; | |
1427 | ||
1428 | //cluster covariance in the local system: | |
1429 | // sx2 0 0 | |
1430 | // 0 0 0 | |
1431 | // 0 0 sz2 | |
1432 | ||
b3e52baa | 1433 | lcov[0] = AliTOFGeometry::XPad()*AliTOFGeometry::XPad()/12.; |
1434 | lcov[1] = 0; | |
1435 | lcov[2] = 0; | |
1436 | lcov[3] = 0; | |
1437 | lcov[4] = 0; | |
1438 | lcov[5] = 0; | |
1439 | lcov[6] = 0; | |
1440 | lcov[7] = 0; | |
1441 | lcov[8] = AliTOFGeometry::ZPad()*AliTOFGeometry::ZPad()/12.; | |
ac359ffe | 1442 | |
1443 | //cluster covariance in the tracking system: | |
1444 | TGeoHMatrix m; | |
1445 | m.SetRotation(lcov); | |
1446 | m.Multiply(l2t); | |
1447 | m.MultiplyLeft(&l2t->Inverse()); | |
1448 | Double_t *tcov = m.GetRotationMatrix(); | |
1449 | cov[0] = tcov[0]; cov[1] = tcov[1]; cov[2] = tcov[2]; | |
1450 | cov[3] = tcov[4]; cov[4] = tcov[5]; | |
1451 | cov[5] = tcov[8]; | |
1452 | ||
1453 | return; | |
1454 | ||
1455 | } |