]>
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" |
0e46b9ae | 132 | #include "AliTOFRawStream.h" |
133 | ||
15ec34b9 | 134 | //extern TFile *gFile; |
d08a92dd | 135 | |
136 | ClassImp(AliTOFClusterFinder) | |
137 | ||
94f5f8f2 | 138 | AliTOFClusterFinder::AliTOFClusterFinder(AliTOFcalib *calib): |
d08a92dd | 139 | fRunLoader(0), |
140 | fTOFLoader(0), | |
141 | fTreeD(0), | |
142 | fTreeR(0), | |
143 | fDigits(new TClonesArray("AliTOFdigit", 4000)), | |
144 | fRecPoints(new TClonesArray("AliTOFcluster", 4000)), | |
15ec34b9 | 145 | fNumberOfTofClusters(0), |
7813bb1a | 146 | fVerbose(0), |
94f5f8f2 | 147 | fDecoderVersion(0), |
148 | fTOFcalib(calib) | |
d08a92dd | 149 | { |
150 | // | |
151 | // Constructor | |
152 | // | |
153 | ||
d08a92dd | 154 | } |
155 | //______________________________________________________________________________ | |
156 | ||
94f5f8f2 | 157 | AliTOFClusterFinder::AliTOFClusterFinder(AliRunLoader* runLoader, AliTOFcalib *calib): |
d08a92dd | 158 | fRunLoader(runLoader), |
159 | fTOFLoader(runLoader->GetLoader("TOFLoader")), | |
160 | fTreeD(0), | |
161 | fTreeR(0), | |
162 | fDigits(new TClonesArray("AliTOFdigit", 4000)), | |
163 | fRecPoints(new TClonesArray("AliTOFcluster", 4000)), | |
15ec34b9 | 164 | fNumberOfTofClusters(0), |
7813bb1a | 165 | fVerbose(0), |
94f5f8f2 | 166 | fDecoderVersion(0), |
167 | fTOFcalib(calib) | |
d08a92dd | 168 | { |
169 | // | |
170 | // Constructor | |
171 | // | |
172 | ||
7aeeaf38 | 173 | } |
174 | ||
175 | //------------------------------------------------------------------------ | |
176 | AliTOFClusterFinder::AliTOFClusterFinder(const AliTOFClusterFinder &source) | |
8a190ba2 | 177 | :TObject(source), |
58d8d9a3 | 178 | fRunLoader(0), |
179 | fTOFLoader(0), | |
180 | fTreeD(0), | |
181 | fTreeR(0), | |
8a190ba2 | 182 | fDigits(source.fDigits), |
183 | fRecPoints(source.fRecPoints), | |
15ec34b9 | 184 | fNumberOfTofClusters(0), |
94f5f8f2 | 185 | fVerbose(0), |
8a190ba2 | 186 | fDecoderVersion(source.fDecoderVersion), |
187 | fTOFcalib(source.fTOFcalib) | |
7aeeaf38 | 188 | { |
189 | // copy constructor | |
7aeeaf38 | 190 | } |
191 | ||
192 | //------------------------------------------------------------------------ | |
d0eb8f39 | 193 | AliTOFClusterFinder& AliTOFClusterFinder::operator=(const AliTOFClusterFinder &source) |
7aeeaf38 | 194 | { |
195 | // ass. op. | |
8a190ba2 | 196 | |
197 | if (this == &source) | |
198 | return *this; | |
199 | ||
200 | TObject::operator=(source); | |
201 | fDigits=source.fDigits; | |
202 | fRecPoints=source.fRecPoints; | |
203 | fVerbose=source.fVerbose; | |
204 | fDecoderVersion=source.fDecoderVersion; | |
205 | fTOFcalib=source.fTOFcalib; | |
7aeeaf38 | 206 | return *this; |
207 | ||
d08a92dd | 208 | } |
209 | //______________________________________________________________________________ | |
210 | ||
211 | AliTOFClusterFinder::~AliTOFClusterFinder() | |
212 | { | |
213 | ||
214 | // | |
215 | // Destructor | |
216 | // | |
217 | ||
218 | if (fDigits) | |
219 | { | |
220 | fDigits->Delete(); | |
221 | delete fDigits; | |
222 | fDigits=0; | |
223 | } | |
224 | if (fRecPoints) | |
225 | { | |
226 | fRecPoints->Delete(); | |
227 | delete fRecPoints; | |
228 | fRecPoints=0; | |
229 | } | |
230 | ||
d08a92dd | 231 | } |
232 | //______________________________________________________________________________ | |
233 | ||
234 | void AliTOFClusterFinder::Digits2RecPoints(Int_t iEvent) | |
235 | { | |
236 | // | |
237 | // Converts digits to recpoints for TOF | |
238 | // | |
239 | ||
515faf5d | 240 | TStopwatch stopwatch; |
241 | stopwatch.Start(); | |
242 | ||
56483762 | 243 | Int_t inholes = 0; |
244 | ||
d08a92dd | 245 | fRunLoader->GetEvent(iEvent); |
246 | ||
247 | fTreeD = fTOFLoader->TreeD(); | |
248 | if (fTreeD == 0x0) | |
249 | { | |
250 | AliFatal("AliTOFClusterFinder: Can not get TreeD"); | |
251 | } | |
252 | ||
253 | TBranch *branch = fTreeD->GetBranch("TOF"); | |
254 | if (!branch) { | |
255 | AliError("can't get the branch with the TOF digits !"); | |
256 | return; | |
257 | } | |
258 | ||
b24266ca | 259 | TClonesArray staticdigits("AliTOFdigit",10000); |
260 | staticdigits.Clear(); | |
261 | TClonesArray *digits =&staticdigits; | |
d08a92dd | 262 | branch->SetAddress(&digits); |
263 | ||
264 | ResetRecpoint(); | |
265 | ||
266 | fTreeR = fTOFLoader->TreeR(); | |
267 | if (fTreeR == 0x0) | |
268 | { | |
269 | fTOFLoader->MakeTree("R"); | |
270 | fTreeR = fTOFLoader->TreeR(); | |
271 | } | |
272 | ||
273 | Int_t bufsize = 32000; | |
274 | fTreeR->Branch("TOF", &fRecPoints, bufsize); | |
275 | ||
276 | fTreeD->GetEvent(0); | |
277 | Int_t nDigits = digits->GetEntriesFast(); | |
278 | AliDebug(2,Form("Number of TOF digits: %d",nDigits)); | |
279 | ||
ac359ffe | 280 | Int_t ii; |
bf33f8f0 | 281 | Int_t dig[5]; //cluster detector indeces |
bf33f8f0 | 282 | Int_t parTOF[5]; //The TOF signal parameters |
283 | Bool_t status=kTRUE; // assume all sim channels ok in the beginning... | |
d08a92dd | 284 | for (ii=0; ii<nDigits; ii++) { |
285 | AliTOFdigit *d = (AliTOFdigit*)digits->UncheckedAt(ii); | |
286 | dig[0]=d->GetSector(); | |
287 | dig[1]=d->GetPlate(); | |
288 | dig[2]=d->GetStrip(); | |
289 | dig[3]=d->GetPadz(); | |
290 | dig[4]=d->GetPadx(); | |
291 | ||
56483762 | 292 | // Do not reconstruct anything in the holes |
293 | if (dig[0]==13 || dig[0]==14 || dig[0]==15 ) { // sectors with holes | |
294 | if (dig[1]==2) { // plate with holes | |
295 | inholes++; | |
296 | continue; | |
297 | } | |
298 | } | |
299 | ||
bf33f8f0 | 300 | // AliDebug(2,Form(" %2i %1i %2i %1i %2i ",dig[0],dig[1],dig[2],dig[3],dig[4])); |
d0eb8f39 | 301 | |
bf33f8f0 | 302 | parTOF[0] = d->GetTdc(); //the TDC signal |
303 | parTOF[1] = d->GetToT(); //the ToT signal | |
304 | parTOF[2] = d->GetAdc(); // the adc charge | |
305 | parTOF[3] = d->GetTdcND(); // non decalibrated sim time | |
306 | parTOF[4] = d->GetTdc(); // raw time, == Tdc time for the moment | |
ac359ffe | 307 | Double_t posClus[3]; |
308 | Double_t covClus[6]; | |
309 | UShort_t volIdClus=GetClusterVolIndex(dig); | |
310 | GetClusterPars(dig, posClus,covClus); | |
311 | 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 | 312 | InsertCluster(tofCluster); |
313 | ||
314 | } | |
315 | ||
94f5f8f2 | 316 | AliInfo(Form("Number of found clusters: %i for event: %i", fNumberOfTofClusters, iEvent)); |
d08a92dd | 317 | |
37879eed | 318 | CalibrateRecPoint(); |
d08a92dd | 319 | FillRecPoint(); |
320 | ||
321 | fTreeR->Fill(); | |
322 | ResetRecpoint(); | |
323 | ||
324 | fTOFLoader = fRunLoader->GetLoader("TOFLoader"); | |
325 | fTOFLoader->WriteRecPoints("OVERWRITE"); | |
326 | ||
515faf5d | 327 | AliInfo(Form("Execution time to read TOF digits and to write TOF clusters : R:%.4fs C:%.4fs", |
328 | stopwatch.RealTime(),stopwatch.CpuTime())); | |
56483762 | 329 | if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes)); |
515faf5d | 330 | |
94f5f8f2 | 331 | } |
332 | ||
333 | //______________________________________________________________________________ | |
334 | ||
335 | void AliTOFClusterFinder::Digits2RecPoints(TTree* digitsTree, TTree* clusterTree) | |
336 | { | |
337 | // | |
338 | // Converts digits to recpoints for TOF | |
339 | // | |
340 | ||
341 | TStopwatch stopwatch; | |
342 | stopwatch.Start(); | |
343 | ||
56483762 | 344 | Int_t inholes = 0; |
345 | ||
94f5f8f2 | 346 | /// fRunLoader->GetEvent(iEvent); |
347 | ||
348 | if (digitsTree == 0x0) | |
349 | { | |
350 | AliFatal("AliTOFClusterFinder: Can not get TreeD"); | |
351 | } | |
352 | ||
353 | TBranch *branch = digitsTree->GetBranch("TOF"); | |
354 | if (!branch) { | |
355 | AliError("can't get the branch with the TOF digits !"); | |
356 | return; | |
357 | } | |
358 | ||
b24266ca | 359 | TClonesArray staticdigits("AliTOFdigit",10000); |
360 | staticdigits.Clear(); | |
361 | TClonesArray *digits = & staticdigits; | |
94f5f8f2 | 362 | branch->SetAddress(&digits); |
363 | ||
364 | ResetRecpoint(); | |
365 | ||
366 | fTreeR=clusterTree; | |
367 | Int_t bufsize = 32000; | |
368 | fTreeR->Branch("TOF", &fRecPoints, bufsize); | |
369 | ||
370 | digitsTree->GetEvent(0); | |
371 | Int_t nDigits = digits->GetEntriesFast(); | |
372 | AliDebug(2,Form("Number of TOF digits: %d",nDigits)); | |
373 | ||
ac359ffe | 374 | Int_t ii; |
94f5f8f2 | 375 | Int_t dig[5]; //cluster detector indeces |
94f5f8f2 | 376 | Int_t parTOF[5]; //The TOF signal parameters |
377 | Bool_t status=kTRUE; // assume all sim channels ok in the beginning... | |
378 | for (ii=0; ii<nDigits; ii++) { | |
379 | AliTOFdigit *d = (AliTOFdigit*)digits->UncheckedAt(ii); | |
380 | dig[0]=d->GetSector(); | |
381 | dig[1]=d->GetPlate(); | |
382 | dig[2]=d->GetStrip(); | |
383 | dig[3]=d->GetPadz(); | |
384 | dig[4]=d->GetPadx(); | |
385 | ||
56483762 | 386 | // Do not reconstruct anything in the holes |
387 | if (dig[0]==13 || dig[0]==14 || dig[0]==15 ) { // sectors with holes | |
388 | if (dig[1]==2) { // plate with holes | |
389 | inholes++; | |
390 | continue; | |
391 | } | |
392 | } | |
393 | ||
94f5f8f2 | 394 | // AliDebug(2,Form(" %2i %1i %2i %1i %2i ",dig[0],dig[1],dig[2],dig[3],dig[4])); |
395 | ||
94f5f8f2 | 396 | parTOF[0] = d->GetTdc(); //the TDC signal |
397 | parTOF[1] = d->GetToT(); //the ToT signal | |
398 | parTOF[2] = d->GetAdc(); // the adc charge | |
399 | parTOF[3] = d->GetTdcND(); // non decalibrated sim time | |
400 | parTOF[4] = d->GetTdc(); // raw time, == Tdc time for the moment | |
ac359ffe | 401 | |
402 | Double_t posClus[3]; | |
403 | Double_t covClus[6]; | |
404 | UShort_t volIdClus=GetClusterVolIndex(dig); | |
405 | GetClusterPars(dig,posClus,covClus); | |
406 | 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 | 407 | InsertCluster(tofCluster); |
408 | ||
409 | } | |
410 | ||
411 | AliInfo(Form("Number of found clusters: %i", fNumberOfTofClusters)); | |
412 | ||
413 | CalibrateRecPoint(); | |
414 | FillRecPoint(); | |
415 | ||
416 | clusterTree->Fill(); | |
417 | ResetRecpoint(); | |
418 | ||
419 | AliInfo(Form("Execution time to read TOF digits and to write TOF clusters : R:%.4fs C:%.4fs", | |
420 | stopwatch.RealTime(),stopwatch.CpuTime())); | |
56483762 | 421 | if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes)); |
94f5f8f2 | 422 | |
d08a92dd | 423 | } |
424 | //______________________________________________________________________________ | |
425 | ||
426 | void AliTOFClusterFinder::Digits2RecPoints(AliRawReader *rawReader, | |
427 | TTree *clustersTree) | |
428 | { | |
429 | // | |
430 | // Converts RAW data to recpoints for TOF | |
431 | // | |
432 | ||
515faf5d | 433 | TStopwatch stopwatch; |
434 | stopwatch.Start(); | |
435 | ||
56483762 | 436 | Int_t inholes = 0; |
437 | ||
d0eb8f39 | 438 | //const Int_t kDDL = fTOFGeometry->NDDL()*fTOFGeometry->NSectors(); |
439 | const Int_t kDDL = AliDAQ::NumberOfDdls("TOF"); | |
d08a92dd | 440 | |
441 | ResetRecpoint(); | |
442 | ||
443 | Int_t bufsize = 32000; | |
444 | clustersTree->Branch("TOF", &fRecPoints, bufsize); | |
445 | ||
15ec34b9 | 446 | TClonesArray * clonesRawData; |
447 | ||
15ec34b9 | 448 | Int_t dummy = -1; |
d08a92dd | 449 | |
450 | Int_t detectorIndex[5]; | |
bf33f8f0 | 451 | Int_t parTOF[5]; |
d08a92dd | 452 | |
15ec34b9 | 453 | ofstream ftxt; |
454 | if (fVerbose==2) ftxt.open("TOFdigitsRead.txt",ios::app); | |
455 | ||
ef58b2af | 456 | AliTOFRawStream tofInput(rawReader); |
457 | ||
15ec34b9 | 458 | Int_t indexDDL = 0; |
459 | for (indexDDL = 0; indexDDL < kDDL; indexDDL++) { | |
460 | ||
461 | rawReader->Reset(); | |
7813bb1a | 462 | if (fDecoderVersion) { |
463 | AliInfo("Using New Decoder \n"); | |
464 | tofInput.LoadRawDataBuffers(indexDDL,fVerbose); | |
465 | } | |
466 | else tofInput.LoadRawData(indexDDL); | |
15ec34b9 | 467 | |
468 | clonesRawData = (TClonesArray*)tofInput.GetRawData(); | |
469 | ||
470 | for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) { | |
471 | ||
472 | AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData); | |
473 | ||
c3891b7a | 474 | //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue; |
475 | if (tofRawDatum->GetTOF()==-1) continue; | |
15ec34b9 | 476 | |
477 | if (fVerbose==2) { | |
478 | if (indexDDL<10) ftxt << " " << indexDDL; | |
479 | else ftxt << " " << indexDDL; | |
480 | if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM(); | |
481 | else ftxt << " " << tofRawDatum->GetTRM(); | |
482 | ftxt << " " << tofRawDatum->GetTRMchain(); | |
483 | if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC(); | |
484 | else ftxt << " " << tofRawDatum->GetTDC(); | |
485 | ftxt << " " << tofRawDatum->GetTDCchannel(); | |
486 | } | |
487 | ||
488 | tofInput.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(), | |
489 | tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex); | |
490 | dummy = detectorIndex[3]; | |
491 | detectorIndex[3] = detectorIndex[4]; | |
492 | detectorIndex[4] = dummy; | |
493 | ||
494 | if (fVerbose==2) { | |
495 | if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0]; | |
496 | else ftxt << " -> " << detectorIndex[0]; | |
497 | ftxt << " " << detectorIndex[1]; | |
498 | if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2]; | |
499 | else ftxt << " " << detectorIndex[2]; | |
500 | ftxt << " " << detectorIndex[3]; | |
501 | if (detectorIndex[4]<10) ftxt << " " << detectorIndex[4]; | |
502 | else ftxt << " " << detectorIndex[4]; | |
503 | } | |
504 | ||
56483762 | 505 | // Do not reconstruct anything in the holes |
506 | if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes | |
507 | if (detectorIndex[1]==2) { // plate with holes | |
508 | inholes++; | |
509 | continue; | |
510 | } | |
511 | } | |
512 | ||
bf33f8f0 | 513 | parTOF[0] = tofRawDatum->GetTOF(); //TDC |
514 | parTOF[1] = tofRawDatum->GetTOT(); // TOT | |
515 | parTOF[2] = tofRawDatum->GetTOT(); //ADC==TOF | |
516 | parTOF[3] = -1;//raw data: no track of undecalib sim time | |
517 | parTOF[4] = tofRawDatum->GetTOF(); // RAW time | |
ac359ffe | 518 | Double_t posClus[3]; |
519 | Double_t covClus[6]; | |
520 | UShort_t volIdClus=GetClusterVolIndex(detectorIndex); | |
521 | Int_t lab[3]={-1,-1,-1}; | |
522 | Bool_t status=kTRUE; | |
523 | GetClusterPars(detectorIndex,posClus,covClus); | |
524 | 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 | 525 | InsertCluster(tofCluster); |
526 | ||
527 | if (fVerbose==2) { | |
bf33f8f0 | 528 | if (parTOF[1]<10)ftxt << " " << parTOF[1]; |
529 | else if (parTOF[1]>=10 && parTOF[1]<100) ftxt << " " << parTOF[1]; | |
530 | else ftxt << " " << parTOF[1]; | |
531 | if (parTOF[0]<10) ftxt << " " << parTOF[0] << endl; | |
532 | else if (parTOF[0]>=10 && parTOF[0]<100) ftxt << " " << parTOF[0] << endl; | |
533 | else if (parTOF[0]>=100 && parTOF[0]<1000) ftxt << " " << parTOF[0] << endl; | |
534 | else ftxt << " " << parTOF[3] << endl; | |
15ec34b9 | 535 | } |
536 | ||
537 | } // closed loop on TOF raw data per current DDL file | |
538 | ||
539 | clonesRawData->Clear(); | |
540 | ||
541 | } // closed loop on DDL index | |
542 | ||
15ec34b9 | 543 | if (fVerbose==2) ftxt.close(); |
d08a92dd | 544 | |
545 | AliInfo(Form("Number of found clusters: %i", fNumberOfTofClusters)); | |
546 | ||
37879eed | 547 | CalibrateRecPoint(); |
d08a92dd | 548 | FillRecPoint(); |
549 | ||
550 | clustersTree->Fill(); | |
37879eed | 551 | |
d08a92dd | 552 | ResetRecpoint(); |
553 | ||
515faf5d | 554 | AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters : R:%.4fs C:%.4fs", |
555 | stopwatch.RealTime(),stopwatch.CpuTime())); | |
56483762 | 556 | if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes)); |
515faf5d | 557 | |
d08a92dd | 558 | } |
559 | //______________________________________________________________________________ | |
560 | ||
561 | void AliTOFClusterFinder::Digits2RecPoints(Int_t iEvent, AliRawReader *rawReader) | |
562 | { | |
563 | // | |
564 | // Converts RAW data to recpoints for TOF | |
565 | // | |
566 | ||
515faf5d | 567 | TStopwatch stopwatch; |
568 | stopwatch.Start(); | |
569 | ||
56483762 | 570 | Int_t inholes = 0; |
571 | ||
d0eb8f39 | 572 | //const Int_t kDDL = fTOFGeometry->NDDL()*fTOFGeometry->NSectors(); |
573 | const Int_t kDDL = AliDAQ::NumberOfDdls("TOF"); | |
d08a92dd | 574 | |
575 | fRunLoader->GetEvent(iEvent); | |
576 | ||
577 | AliDebug(2,Form(" Event number %2i ", iEvent)); | |
578 | ||
579 | fTreeR = fTOFLoader->TreeR(); | |
580 | ||
581 | if (fTreeR == 0x0){ | |
582 | fTOFLoader->MakeTree("R"); | |
583 | fTreeR = fTOFLoader->TreeR(); | |
584 | } | |
585 | ||
586 | Int_t bufsize = 32000; | |
587 | fTreeR->Branch("TOF", &fRecPoints, bufsize); | |
588 | ||
15ec34b9 | 589 | TClonesArray * clonesRawData; |
590 | ||
15ec34b9 | 591 | Int_t dummy = -1; |
d08a92dd | 592 | |
d0eb8f39 | 593 | Int_t detectorIndex[5] = {-1, -1, -1, -1, -1}; |
bf33f8f0 | 594 | Int_t parTOF[5]; |
15ec34b9 | 595 | ofstream ftxt; |
596 | if (fVerbose==2) ftxt.open("TOFdigitsRead.txt",ios::app); | |
597 | ||
ef58b2af | 598 | AliTOFRawStream tofInput(rawReader); |
599 | ||
15ec34b9 | 600 | Int_t indexDDL = 0; |
d08a92dd | 601 | for (indexDDL = 0; indexDDL < kDDL; indexDDL++) { |
602 | ||
603 | rawReader->Reset(); | |
7813bb1a | 604 | if (fDecoderVersion) { |
605 | AliInfo("Using New Decoder \n"); | |
606 | tofInput.LoadRawDataBuffers(indexDDL,fVerbose); | |
607 | } | |
608 | else tofInput.LoadRawData(indexDDL); | |
15ec34b9 | 609 | |
610 | clonesRawData = (TClonesArray*)tofInput.GetRawData(); | |
611 | ||
612 | for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) { | |
613 | ||
614 | AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData); | |
615 | ||
c3891b7a | 616 | //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue; |
617 | if (tofRawDatum->GetTOF()==-1) continue; | |
15ec34b9 | 618 | |
619 | if (fVerbose==2) { | |
620 | if (indexDDL<10) ftxt << " " << indexDDL; | |
621 | else ftxt << " " << indexDDL; | |
622 | if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM(); | |
623 | else ftxt << " " << tofRawDatum->GetTRM(); | |
624 | ftxt << " " << tofRawDatum->GetTRMchain(); | |
625 | if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC(); | |
626 | else ftxt << " " << tofRawDatum->GetTDC(); | |
627 | ftxt << " " << tofRawDatum->GetTDCchannel(); | |
628 | } | |
629 | ||
630 | tofInput.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(), | |
631 | tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex); | |
632 | dummy = detectorIndex[3]; | |
633 | detectorIndex[3] = detectorIndex[4]; | |
634 | detectorIndex[4] = dummy; | |
635 | ||
636 | if (fVerbose==2) { | |
637 | if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0]; | |
638 | else ftxt << " -> " << detectorIndex[0]; | |
639 | ftxt << " " << detectorIndex[1]; | |
640 | if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2]; | |
641 | else ftxt << " " << detectorIndex[2]; | |
642 | ftxt << " " << detectorIndex[3]; | |
643 | if (detectorIndex[4]<10) ftxt << " " << detectorIndex[4]; | |
644 | else ftxt << " " << detectorIndex[4]; | |
645 | } | |
d0eb8f39 | 646 | |
56483762 | 647 | // Do not reconstruct anything in the holes |
648 | if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes | |
649 | if (detectorIndex[1]==2) { // plate with holes | |
650 | inholes++; | |
651 | continue; | |
652 | } | |
653 | } | |
654 | ||
bf33f8f0 | 655 | parTOF[0] = tofRawDatum->GetTOF(); // TDC |
656 | parTOF[1] = tofRawDatum->GetTOT(); // TOT | |
657 | parTOF[2] = tofRawDatum->GetTOT(); // raw data have ADC=TOT | |
658 | parTOF[3] = -1; //raw data: no track of the undecalib sim time | |
659 | parTOF[4] = tofRawDatum->GetTOF(); // Raw time == TDC | |
ac359ffe | 660 | Double_t posClus[3]; |
661 | Double_t covClus[6]; | |
662 | UShort_t volIdClus=GetClusterVolIndex(detectorIndex); | |
663 | Int_t lab[3]={-1,-1,-1}; | |
664 | Bool_t status=kTRUE; | |
665 | GetClusterPars(detectorIndex,posClus,covClus); | |
666 | 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 | 667 | InsertCluster(tofCluster); |
668 | ||
15ec34b9 | 669 | if (fVerbose==2) { |
bf33f8f0 | 670 | if (parTOF[1]<10)ftxt << " " << parTOF[1]; |
671 | else if (parTOF[1]>=10 && parTOF[1]<100) ftxt << " " << parTOF[1]; | |
672 | else ftxt << " " << parTOF[1]; | |
673 | if (parTOF[0]<10) ftxt << " " << parTOF[0] << endl; | |
674 | else if (parTOF[0]>=10 && parTOF[0]<100) ftxt << " " << parTOF[0] << endl; | |
675 | else if (parTOF[0]>=100 && parTOF[0]<1000) ftxt << " " << parTOF[0] << endl; | |
676 | else ftxt << " " << parTOF[3] << endl; | |
15ec34b9 | 677 | } |
d08a92dd | 678 | |
15ec34b9 | 679 | } // closed loop on TOF raw data per current DDL file |
680 | ||
681 | clonesRawData->Clear(); | |
682 | ||
683 | } // closed loop on DDL index | |
684 | ||
685 | if (fVerbose==2) ftxt.close(); | |
d08a92dd | 686 | |
94f5f8f2 | 687 | AliInfo(Form("Number of found clusters: %i for event: %i", fNumberOfTofClusters, iEvent)); |
d08a92dd | 688 | |
37879eed | 689 | CalibrateRecPoint(); |
d08a92dd | 690 | FillRecPoint(); |
691 | ||
692 | fTreeR->Fill(); | |
693 | ResetRecpoint(); | |
694 | ||
695 | fTOFLoader = fRunLoader->GetLoader("TOFLoader"); | |
696 | fTOFLoader->WriteRecPoints("OVERWRITE"); | |
697 | ||
515faf5d | 698 | AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters : R:%.4fs C:%.4fs", |
699 | stopwatch.RealTime(),stopwatch.CpuTime())); | |
56483762 | 700 | if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes)); |
515faf5d | 701 | |
d08a92dd | 702 | } |
703 | //______________________________________________________________________________ | |
704 | ||
705 | void AliTOFClusterFinder::Raw2Digits(Int_t iEvent, AliRawReader *rawReader) | |
706 | { | |
707 | // | |
708 | // Converts RAW data to MC digits for TOF | |
709 | // | |
710 | // (temporary solution) | |
711 | // | |
712 | ||
515faf5d | 713 | TStopwatch stopwatch; |
714 | stopwatch.Start(); | |
715 | ||
15ec34b9 | 716 | //const Int_t kDDL = fTOFGeometry->NDDL()*fTOFGeometry->NSectors(); |
ba66add8 | 717 | const Int_t kDDL = AliTOFGeometry::NDDL()*AliTOFGeometry::NSectors(); |
15ec34b9 | 718 | |
d08a92dd | 719 | fRunLoader->GetEvent(iEvent); |
720 | ||
721 | fTreeD = fTOFLoader->TreeD(); | |
722 | if (fTreeD) | |
723 | { | |
d0eb8f39 | 724 | AliInfo("TreeD re-creation"); |
d08a92dd | 725 | fTreeD = 0x0; |
726 | fTOFLoader->MakeTree("D"); | |
727 | fTreeD = fTOFLoader->TreeD(); | |
728 | } | |
729 | ||
15ec34b9 | 730 | TClonesArray *tofDigits = new TClonesArray("AliTOFdigit",10000); |
d08a92dd | 731 | Int_t bufsize = 32000; |
732 | fTreeD->Branch("TOF", &tofDigits, bufsize); | |
733 | ||
d08a92dd | 734 | fRunLoader->GetEvent(iEvent); |
735 | ||
736 | AliDebug(2,Form(" Event number %2i ", iEvent)); | |
737 | ||
15ec34b9 | 738 | TClonesArray * clonesRawData; |
739 | ||
740 | Int_t dummy = -1; | |
d08a92dd | 741 | |
742 | Int_t detectorIndex[5]; | |
bf33f8f0 | 743 | Int_t digit[4]; |
d08a92dd | 744 | |
ef58b2af | 745 | AliTOFRawStream tofInput(rawReader); |
746 | ||
15ec34b9 | 747 | Int_t indexDDL = 0; |
d08a92dd | 748 | for (indexDDL = 0; indexDDL < kDDL; indexDDL++) { |
749 | ||
750 | rawReader->Reset(); | |
7813bb1a | 751 | if (fDecoderVersion) { |
752 | AliInfo("Using New Decoder \n"); | |
753 | tofInput.LoadRawDataBuffers(indexDDL,fVerbose); | |
754 | } | |
755 | else tofInput.LoadRawData(indexDDL); | |
d08a92dd | 756 | |
15ec34b9 | 757 | clonesRawData = (TClonesArray*)tofInput.GetRawData(); |
d08a92dd | 758 | |
15ec34b9 | 759 | for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) { |
d0eb8f39 | 760 | |
15ec34b9 | 761 | AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData); |
d0eb8f39 | 762 | |
3e2f0097 | 763 | //if (!tofRawDatum->GetTOT() || !tofRawDatum->GetTOF()) continue; |
764 | if (tofRawDatum->GetTOF()==-1) continue; | |
15ec34b9 | 765 | |
766 | tofInput.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(), | |
767 | tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex); | |
768 | dummy = detectorIndex[3]; | |
769 | detectorIndex[3] = detectorIndex[4]; | |
770 | detectorIndex[4] = dummy; | |
d0eb8f39 | 771 | |
bf33f8f0 | 772 | digit[0] = tofInput.GetTofBin(); |
773 | digit[1] = tofInput.GetToTbin(); | |
774 | digit[2] = tofInput.GetToTbin(); | |
775 | digit[3] = -1; | |
d08a92dd | 776 | |
777 | Int_t tracknum[3]={-1,-1,-1}; | |
778 | ||
779 | TClonesArray &aDigits = *tofDigits; | |
780 | Int_t last=tofDigits->GetEntriesFast(); | |
781 | new (aDigits[last]) AliTOFdigit(tracknum, detectorIndex, digit); | |
782 | ||
783 | } // while loop | |
784 | ||
15ec34b9 | 785 | clonesRawData->Clear(); |
786 | ||
d08a92dd | 787 | } // DDL Loop |
788 | ||
789 | fTreeD->Fill(); | |
790 | ||
791 | fTOFLoader = fRunLoader->GetLoader("TOFLoader"); | |
792 | fTOFLoader->WriteDigits("OVERWRITE"); | |
793 | ||
515faf5d | 794 | AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters : R:%.2fs C:%.2fs", |
795 | stopwatch.RealTime(),stopwatch.CpuTime())); | |
796 | ||
94f5f8f2 | 797 | } |
798 | ||
799 | //______________________________________________________________________________ | |
800 | ||
801 | void AliTOFClusterFinder::Raw2Digits(AliRawReader *rawReader, TTree* digitsTree) | |
802 | { | |
803 | // | |
804 | // Converts RAW data to MC digits for TOF for the current event | |
805 | // | |
806 | // | |
807 | ||
808 | TStopwatch stopwatch; | |
809 | stopwatch.Start(); | |
810 | ||
ba66add8 | 811 | const Int_t kDDL = AliTOFGeometry::NDDL()*AliTOFGeometry::NSectors(); |
94f5f8f2 | 812 | |
813 | if (!digitsTree) | |
814 | { | |
815 | AliError("No input digits Tree"); | |
816 | return; | |
817 | } | |
818 | ||
819 | TClonesArray *tofDigits = new TClonesArray("AliTOFdigit",10000); | |
820 | Int_t bufsize = 32000; | |
821 | digitsTree->Branch("TOF", &tofDigits, bufsize); | |
822 | ||
823 | /// fRunLoader->GetEvent(iEvent); | |
824 | ||
825 | /// AliDebug(2,Form(" Event number %2i ", iEvent)); | |
826 | ||
827 | TClonesArray * clonesRawData; | |
828 | ||
829 | Int_t dummy = -1; | |
830 | ||
831 | Int_t detectorIndex[5]; | |
832 | Int_t digit[4]; | |
833 | ||
ef58b2af | 834 | AliTOFRawStream tofInput(rawReader); |
835 | ||
94f5f8f2 | 836 | Int_t indexDDL = 0; |
837 | for (indexDDL = 0; indexDDL < kDDL; indexDDL++) { | |
838 | ||
839 | rawReader->Reset(); | |
94f5f8f2 | 840 | if (fDecoderVersion) { |
841 | AliInfo("Using New Decoder \n"); | |
842 | tofInput.LoadRawDataBuffers(indexDDL,fVerbose); | |
843 | } | |
844 | else tofInput.LoadRawData(indexDDL); | |
845 | ||
846 | clonesRawData = (TClonesArray*)tofInput.GetRawData(); | |
847 | ||
848 | for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) { | |
849 | ||
850 | AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData); | |
851 | ||
3e2f0097 | 852 | //if (!tofRawDatum->GetTOT() || !tofRawDatum->GetTOF()) continue; |
853 | if (tofRawDatum->GetTOF()==-1) continue; | |
94f5f8f2 | 854 | |
855 | tofInput.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(), | |
856 | tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex); | |
857 | dummy = detectorIndex[3]; | |
858 | detectorIndex[3] = detectorIndex[4]; | |
859 | detectorIndex[4] = dummy; | |
860 | ||
861 | digit[0] = tofInput.GetTofBin(); | |
862 | digit[1] = tofInput.GetToTbin(); | |
863 | digit[2] = tofInput.GetToTbin(); | |
864 | digit[3] = -1; | |
865 | ||
866 | Int_t tracknum[3]={-1,-1,-1}; | |
867 | ||
868 | TClonesArray &aDigits = *tofDigits; | |
869 | Int_t last=tofDigits->GetEntriesFast(); | |
870 | new (aDigits[last]) AliTOFdigit(tracknum, detectorIndex, digit); | |
871 | ||
872 | } // while loop | |
873 | ||
874 | clonesRawData->Clear(); | |
875 | ||
876 | } // DDL Loop | |
877 | ||
878 | digitsTree->Fill(); | |
879 | ||
880 | AliDebug(1, Form("Got %d digits: ", tofDigits->GetEntries())); | |
881 | AliDebug(1, Form("Execution time to read TOF raw data and fill TOF digit tree : R:%.2fs C:%.2fs", | |
882 | stopwatch.RealTime(),stopwatch.CpuTime())); | |
883 | ||
d08a92dd | 884 | } |
885 | //______________________________________________________________________________ | |
886 | ||
887 | Int_t AliTOFClusterFinder::InsertCluster(AliTOFcluster *tofCluster) { | |
888 | //---------------------------------------------------------------------------// | |
889 | // This function adds a TOF cluster to the array of TOF clusters sorted in Z // | |
890 | //---------------------------------------------------------------------------// | |
891 | if (fNumberOfTofClusters==kTofMaxCluster) { | |
892 | AliError("Too many clusters !"); | |
893 | return 1; | |
894 | } | |
895 | ||
896 | if (fNumberOfTofClusters==0) { | |
897 | fTofClusters[fNumberOfTofClusters++] = tofCluster; | |
898 | return 0; | |
899 | } | |
900 | ||
901 | Int_t ii = FindClusterIndex(tofCluster->GetZ()); | |
902 | memmove(fTofClusters+ii+1 ,fTofClusters+ii,(fNumberOfTofClusters-ii)*sizeof(AliTOFcluster*)); | |
903 | fTofClusters[ii] = tofCluster; | |
904 | fNumberOfTofClusters++; | |
905 | ||
906 | return 0; | |
907 | ||
908 | } | |
909 | //_________________________________________________________________________ | |
910 | ||
911 | Int_t AliTOFClusterFinder::FindClusterIndex(Double_t z) const { | |
912 | //-------------------------------------------------------------------- | |
ac359ffe | 913 | // This function returns the index of the nearest cluster in z |
d08a92dd | 914 | //-------------------------------------------------------------------- |
915 | if (fNumberOfTofClusters==0) return 0; | |
916 | if (z <= fTofClusters[0]->GetZ()) return 0; | |
917 | if (z > fTofClusters[fNumberOfTofClusters-1]->GetZ()) return fNumberOfTofClusters; | |
918 | Int_t b = 0, e = fNumberOfTofClusters-1, m = (b+e)/2; | |
919 | for (; b<e; m=(b+e)/2) { | |
920 | if (z > fTofClusters[m]->GetZ()) b=m+1; | |
921 | else e=m; | |
922 | } | |
923 | ||
924 | return m; | |
925 | ||
926 | } | |
927 | //_________________________________________________________________________ | |
928 | ||
929 | void AliTOFClusterFinder::FillRecPoint() | |
930 | { | |
931 | // | |
932 | // Copy the global array of AliTOFcluster, i.e. fTofClusters (sorted | |
933 | // in Z) in the global TClonesArray of AliTOFcluster, | |
934 | // i.e. fRecPoints. | |
935 | // | |
936 | ||
937 | Int_t ii, jj; | |
938 | ||
939 | Int_t detectorIndex[5]; | |
bf33f8f0 | 940 | Int_t parTOF[5]; |
d08a92dd | 941 | Int_t trackLabels[3]; |
942 | Int_t digitIndex = -1; | |
bf33f8f0 | 943 | Bool_t status=kTRUE; |
d08a92dd | 944 | |
945 | TClonesArray &lRecPoints = *fRecPoints; | |
946 | ||
947 | for (ii=0; ii<fNumberOfTofClusters; ii++) { | |
948 | ||
949 | digitIndex = fTofClusters[ii]->GetIndex(); | |
950 | for(jj=0; jj<5; jj++) detectorIndex[jj] = fTofClusters[ii]->GetDetInd(jj); | |
951 | for(jj=0; jj<3; jj++) trackLabels[jj] = fTofClusters[ii]->GetLabel(jj); | |
bf33f8f0 | 952 | parTOF[0] = fTofClusters[ii]->GetTDC(); // TDC |
953 | parTOF[1] = fTofClusters[ii]->GetToT(); // TOT | |
954 | parTOF[2] = fTofClusters[ii]->GetADC(); // ADC=TOT | |
955 | parTOF[3] = fTofClusters[ii]->GetTDCND(); // TDCND | |
956 | parTOF[4] = fTofClusters[ii]->GetTDCRAW();//RAW | |
957 | status=fTofClusters[ii]->GetStatus(); | |
ac359ffe | 958 | Double_t posClus[3]; |
959 | Double_t covClus[6]; | |
960 | UShort_t volIdClus=GetClusterVolIndex(detectorIndex); | |
961 | GetClusterPars(detectorIndex,posClus,covClus); | |
962 | 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 | 963 | |
3e2f0097 | 964 | AliDebug(2, Form(" %4i %4i %f %f %f %f %f %f %f %f %f %3i %3i %3i %2i %1i %2i %1i %2i %4i %3i %3i %4i %4i %1i %4i", |
965 | ii, volIdClus, posClus[0], posClus[1], posClus[2], | |
966 | fTofClusters[ii]->GetSigmaX2(), | |
967 | fTofClusters[ii]->GetSigmaXY(), | |
968 | fTofClusters[ii]->GetSigmaXZ(), | |
969 | fTofClusters[ii]->GetSigmaY2(), | |
970 | fTofClusters[ii]->GetSigmaYZ(), | |
971 | fTofClusters[ii]->GetSigmaZ2(), | |
972 | trackLabels[0], trackLabels[1], trackLabels[2], | |
973 | detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[3], detectorIndex[4], | |
974 | parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4], | |
975 | status, digitIndex)); | |
976 | ||
d08a92dd | 977 | } // loop on clusters |
978 | ||
979 | } | |
37879eed | 980 | |
981 | //_________________________________________________________________________ | |
982 | void AliTOFClusterFinder::CalibrateRecPoint() | |
983 | { | |
984 | // | |
985 | // Copy the global array of AliTOFcluster, i.e. fTofClusters (sorted | |
986 | // in Z) in the global TClonesArray of AliTOFcluster, | |
987 | // i.e. fRecPoints. | |
988 | // | |
989 | ||
990 | Int_t ii, jj; | |
991 | ||
992 | Int_t detectorIndex[5]; | |
993 | Int_t digitIndex = -1; | |
a33fec85 | 994 | Double_t tToT; |
995 | Double_t timeCorr; | |
bf33f8f0 | 996 | Int_t tdcCorr; |
37879eed | 997 | AliInfo(" Calibrating TOF Clusters: ") |
a1cab04c | 998 | |
17149e6b | 999 | AliTOFChannelOnlineArray *calDelay = fTOFcalib->GetTOFOnlineDelay(); |
1000 | AliTOFChannelOnlineStatusArray *calStatus = fTOFcalib->GetTOFOnlineStatus(); | |
ba66add8 | 1001 | TObjArray *calTOFArrayOffline = fTOFcalib->GetTOFCalArrayOffline(); |
1002 | TString validity = (TString)fTOFcalib->GetOfflineValidity(); | |
1003 | AliInfo(Form(" validity = %s",validity.Data())); | |
1004 | Int_t calibration = -1; | |
1005 | if (validity.CompareTo("valid")==0) { | |
1006 | AliInfo(" Using offline calibration parameters"); | |
1007 | calibration = 1; | |
1008 | } | |
1009 | else { | |
1010 | AliInfo(" Using online calibration parameters"); | |
1011 | calibration = 0 ; | |
1012 | } | |
37879eed | 1013 | for (ii=0; ii<fNumberOfTofClusters; ii++) { |
1014 | digitIndex = fTofClusters[ii]->GetIndex(); | |
1015 | for(jj=0; jj<5; jj++) detectorIndex[jj] = fTofClusters[ii]->GetDetInd(jj); | |
1016 | ||
ba66add8 | 1017 | Int_t index = AliTOFGeometry::GetIndex(detectorIndex); |
37879eed | 1018 | |
17149e6b | 1019 | UChar_t statusPulser=calStatus->GetPulserStatus(index); |
1020 | UChar_t statusNoise=calStatus->GetNoiseStatus(index); | |
1021 | UChar_t statusHW=calStatus->GetHWStatus(index); | |
1022 | UChar_t status=calStatus->GetStatus(index); | |
1023 | ||
1024 | //check the status, also unknown is fine!!!!!!! | |
1025 | ||
1026 | AliDebug(2, Form(" Status for channel %i = %i",index, (Int_t)status)); | |
1027 | if((statusPulser & AliTOFChannelOnlineStatusArray::kTOFPulserBad)==(AliTOFChannelOnlineStatusArray::kTOFPulserBad)||(statusNoise & AliTOFChannelOnlineStatusArray::kTOFNoiseBad)==(AliTOFChannelOnlineStatusArray::kTOFNoiseBad)||(statusHW & AliTOFChannelOnlineStatusArray::kTOFHWBad)==(AliTOFChannelOnlineStatusArray::kTOFHWBad)){ | |
7fffa85b | 1028 | AliDebug(2, Form(" Bad Status for channel %i",index)); |
1029 | fTofClusters[ii]->SetStatus(kFALSE); //odd convention, to avoid conflict with calibration objects currently in the db (temporary solution). | |
1030 | } | |
1031 | else { | |
1032 | AliDebug(2, Form(" Good Status for channel %i",index)); | |
1033 | } | |
58d8d9a3 | 1034 | // Get Rough channel online equalization |
17149e6b | 1035 | Double_t roughDelay=(Double_t)calDelay->GetDelay(index); // in ns |
ba66add8 | 1036 | AliDebug(2,Form(" channel delay (ns) = %f", roughDelay)); |
58d8d9a3 | 1037 | // Get Refined channel offline calibration parameters |
ba66add8 | 1038 | if (calibration ==1){ |
1039 | AliTOFChannelOffline * calChannelOffline = (AliTOFChannelOffline*)calTOFArrayOffline->At(index); | |
1040 | Double_t par[6]; | |
1041 | for (Int_t j = 0; j<6; j++){ | |
1042 | par[j]=(Double_t)calChannelOffline->GetSlewPar(j); | |
1043 | } | |
bf33f8f0 | 1044 | AliDebug(2,Form(" Calib Pars = %f, %f, %f, %f, %f, %f ",par[0],par[1],par[2],par[3],par[4],par[5])); |
ba66add8 | 1045 | AliDebug(2,Form(" The ToT and Time, uncorr (counts) = %i , %i", fTofClusters[ii]->GetToT(),fTofClusters[ii]->GetTDC())); |
1046 | tToT = (Double_t)(fTofClusters[ii]->GetToT()*AliTOFGeometry::ToTBinWidth()); | |
1047 | tToT*=1.E-3; //ToT in ns | |
1048 | AliDebug(2,Form(" The ToT and Time, uncorr (ns)= %e, %e",fTofClusters[ii]->GetTDC()*AliTOFGeometry::TdcBinWidth()*1.E-3,tToT)); | |
1049 | 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) | |
1050 | } | |
1051 | else { | |
1052 | timeCorr = roughDelay; // correction in ns | |
1053 | } | |
1054 | 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 | 1055 | AliDebug(2,Form(" The time correction (ns) = %f", timeCorr)); |
a33fec85 | 1056 | timeCorr=(Double_t)(fTofClusters[ii]->GetTDC())*AliTOFGeometry::TdcBinWidth()*1.E-3-timeCorr;//redefine the time |
1057 | timeCorr*=1.E3; | |
1058 | AliDebug(2,Form(" The channel time, corr (ps)= %e",timeCorr )); | |
1059 | tdcCorr=(Int_t)(timeCorr/AliTOFGeometry::TdcBinWidth()); //the corrected time (tdc counts) | |
340693af | 1060 | fTofClusters[ii]->SetTDC(tdcCorr); |
37879eed | 1061 | } // loop on clusters |
1062 | ||
37879eed | 1063 | } |
d08a92dd | 1064 | //______________________________________________________________________________ |
1065 | ||
1066 | void AliTOFClusterFinder::ResetRecpoint() | |
1067 | { | |
1068 | // | |
1069 | // Clear the list of reconstructed points | |
1070 | // | |
1071 | ||
1072 | fNumberOfTofClusters = 0; | |
1073 | if (fRecPoints) fRecPoints->Clear(); | |
1074 | ||
1075 | } | |
1076 | //______________________________________________________________________________ | |
1077 | ||
1078 | void AliTOFClusterFinder::Load() | |
1079 | { | |
1080 | // | |
1081 | // Load TOF.Digits.root and TOF.RecPoints.root files | |
1082 | // | |
1083 | ||
1084 | fTOFLoader->LoadDigits("READ"); | |
1085 | fTOFLoader->LoadRecPoints("recreate"); | |
1086 | ||
1087 | } | |
1088 | //______________________________________________________________________________ | |
1089 | ||
1090 | void AliTOFClusterFinder::LoadClusters() | |
1091 | { | |
1092 | // | |
1093 | // Load TOF.RecPoints.root file | |
1094 | // | |
1095 | ||
1096 | fTOFLoader->LoadRecPoints("recreate"); | |
1097 | ||
1098 | } | |
1099 | //______________________________________________________________________________ | |
1100 | ||
1101 | void AliTOFClusterFinder::UnLoad() | |
1102 | { | |
1103 | // | |
1104 | // Unload TOF.Digits.root and TOF.RecPoints.root files | |
1105 | // | |
1106 | ||
1107 | fTOFLoader->UnloadDigits(); | |
1108 | fTOFLoader->UnloadRecPoints(); | |
1109 | ||
1110 | } | |
1111 | //______________________________________________________________________________ | |
1112 | ||
1113 | void AliTOFClusterFinder::UnLoadClusters() | |
1114 | { | |
1115 | // | |
1116 | // Unload TOF.RecPoints.root file | |
1117 | // | |
1118 | ||
1119 | fTOFLoader->UnloadRecPoints(); | |
1120 | ||
1121 | } | |
ac359ffe | 1122 | //------------------------------------------------------------------------- |
1123 | UShort_t AliTOFClusterFinder::GetClusterVolIndex(Int_t *ind) const { | |
1124 | ||
1125 | //First of all get the volume ID to retrieve the l2t transformation... | |
1126 | // | |
1127 | // Detector numbering scheme | |
1128 | Int_t nSector = 18; | |
1129 | Int_t nPlate = 5; | |
1130 | Int_t nStripA = 15; | |
1131 | Int_t nStripB = 19; | |
1132 | Int_t nStripC = 19; | |
1133 | ||
1134 | Int_t isector =ind[0]; | |
1135 | if (isector >= nSector) | |
1136 | AliError(Form("Wrong sector number in TOF (%d) !",isector)); | |
1137 | Int_t iplate = ind[1]; | |
1138 | if (iplate >= nPlate) | |
1139 | AliError(Form("Wrong plate number in TOF (%d) !",iplate)); | |
1140 | Int_t istrip = ind[2]; | |
1141 | ||
1142 | Int_t stripOffset = 0; | |
1143 | switch (iplate) { | |
1144 | case 0: | |
1145 | stripOffset = 0; | |
1146 | break; | |
1147 | case 1: | |
1148 | stripOffset = nStripC; | |
1149 | break; | |
1150 | case 2: | |
1151 | stripOffset = nStripC+nStripB; | |
1152 | break; | |
1153 | case 3: | |
1154 | stripOffset = nStripC+nStripB+nStripA; | |
1155 | break; | |
1156 | case 4: | |
1157 | stripOffset = nStripC+nStripB+nStripA+nStripB; | |
1158 | break; | |
1159 | default: | |
1160 | AliError(Form("Wrong plate number in TOF (%d) !",iplate)); | |
1161 | break; | |
1162 | }; | |
1163 | ||
1164 | Int_t index= (2*(nStripC+nStripB)+nStripA)*isector + | |
1165 | stripOffset + | |
1166 | istrip; | |
1167 | ||
1168 | UShort_t volIndex = AliGeomManager::LayerToVolUID(AliGeomManager::kTOF,index); | |
1169 | return volIndex; | |
1170 | } | |
1171 | // | |
1172 | //------------------------------------------------------------------------- | |
1173 | void AliTOFClusterFinder::GetClusterPars(Int_t *ind, Double_t* pos,Double_t* cov) const { | |
1174 | ||
1175 | //First of all get the volume ID to retrieve the l2t transformation... | |
1176 | // | |
1177 | UShort_t volIndex = GetClusterVolIndex(ind); | |
1178 | // | |
1179 | // | |
1180 | //we now go in the system of the strip: determine the local coordinates | |
1181 | // | |
1182 | // | |
1183 | // 47---------------------------------------------------0 ^ z | |
1184 | // | | | | | | | | | | | | | | | | | | | | | | | | | | | 1 | | |
1185 | // ----------------------------------------------------- | y going outwards | |
1186 | // | | | | | | | | | | | | | | | | | | | | | | | | | | | 0 | par[0]=0; | |
1187 | ||
1188 | // ----------------------------------------------------- | | |
1189 | // x <----------------------------------------------------- | |
1190 | ||
c0f9ecc7 | 1191 | Float_t localX=(ind[4]-23.5)*AliTOFGeometry::XPad(); |
1192 | Float_t localY=0; | |
1193 | Float_t localZ=(ind[3]- 0.5)*AliTOFGeometry::ZPad(); | |
ac359ffe | 1194 | |
1195 | //move to the tracking ref system | |
1196 | ||
1197 | Double_t lpos[3]; | |
1198 | lpos[0]=localX; | |
1199 | lpos[1]=localY; | |
1200 | lpos[2]=localZ; | |
1201 | ||
1202 | const TGeoHMatrix *l2t= AliGeomManager::GetTracking2LocalMatrix(volIndex); | |
1203 | // Get The position in the track ref system | |
1204 | Double_t tpos[3]; | |
1205 | l2t->MasterToLocal(lpos,tpos); | |
1206 | pos[0]=tpos[0]; | |
1207 | pos[1]=tpos[1]; | |
1208 | pos[2]=tpos[2]; | |
1209 | ||
1210 | //Get The cluster covariance in the track ref system | |
1211 | Double_t lcov[9]; | |
1212 | ||
1213 | //cluster covariance in the local system: | |
1214 | // sx2 0 0 | |
1215 | // 0 0 0 | |
1216 | // 0 0 sz2 | |
1217 | ||
c0f9ecc7 | 1218 | lcov[0]=AliTOFGeometry::XPad()*AliTOFGeometry::XPad()/12.; |
ac359ffe | 1219 | lcov[1]=0; |
1220 | lcov[2]=0; | |
1221 | lcov[3]=0; | |
1222 | lcov[4]=0; | |
1223 | lcov[5]=0; | |
1224 | lcov[6]=0; | |
1225 | lcov[7]=0; | |
c0f9ecc7 | 1226 | lcov[8]=AliTOFGeometry::ZPad()*AliTOFGeometry::ZPad()/12.; |
ac359ffe | 1227 | |
1228 | //cluster covariance in the tracking system: | |
1229 | TGeoHMatrix m; | |
1230 | m.SetRotation(lcov); | |
1231 | m.Multiply(l2t); | |
1232 | m.MultiplyLeft(&l2t->Inverse()); | |
1233 | Double_t *tcov = m.GetRotationMatrix(); | |
1234 | cov[0] = tcov[0]; cov[1] = tcov[1]; cov[2] = tcov[2]; | |
1235 | cov[3] = tcov[4]; cov[4] = tcov[5]; | |
1236 | cov[5] = tcov[8]; | |
1237 | ||
1238 | return; | |
1239 | ||
1240 | } |