]>
Commit | Line | Data |
---|---|---|
571dda3d | 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 | /* | |
d0eb8f39 | 17 | $Log$ |
dd824655 | 18 | Revision 1.19.1 2008/09/19 preghenella |
19 | Decode method updated: | |
20 | it reads the CDH from the rawReader and sends it to the decoder; | |
21 | LoadRawDataBuffers modified: | |
22 | it corrects tof hit infos per ddlBC and deltaBC offsets | |
23 | (in case of the static member fgApplyBCCorrections | |
24 | has been setted to kTRUE); | |
25 | Added static member fgApplyBCCorrections (kTRUE by default) | |
26 | and the related static method ApplyBCCorrections; | |
27 | ||
96f01799 | 28 | Revision 1.19 2007/05/18 13:07:53 decaro |
29 | Error messages stored in the global raw-reader error log (Cvetan, Chiara) | |
30 | ||
019f6101 | 31 | Revision 1.18 2007/05/08 11:53:29 arcelli |
32 | Improved class flexibility for further use (R.Preghenella) | |
33 | ||
2fd622fa | 34 | Revision 1.17 2007/05/03 08:53:50 decaro |
35 | Coding convention: RS3 violation -> suppression | |
36 | ||
19eefa2b | 37 | Revision 1.16 2007/05/03 08:22:22 decaro |
38 | Coding convention: RN17 violation -> suppression | |
39 | ||
dfcee998 | 40 | Revision 1.15 2007/04/30 15:22:06 arcelli |
41 | Change TOF digit Time, Tot etc to int type | |
42 | ||
bf33f8f0 | 43 | Revision 1.14 2007/04/27 11:11:53 arcelli |
44 | updates for the new decoder | |
45 | ||
dfcee998 | 46 | Revision 1.13 2007/03/16 11:46:35 decaro |
47 | Coding convention: RN17 rule violation -> suppression | |
48 | ||
8994284f | 49 | Revision 1.12 2007/02/22 09:43:45 decaro |
50 | Added AliTOFRawStream::GetIndex method for online calibration (C.Zampolli) | |
51 | ||
740f0695 | 52 | Revision 1.11 2007/02/20 15:57:00 decaro |
53 | Raw data update: to read the TOF raw data defined in UNPACKED mode | |
54 | ||
15ec34b9 | 55 | Revision 1.10 2006/12/15 14:01:38 cvetan |
56 | Memory leak fixed | |
57 | ||
f1aa96cc | 58 | Revision 1.9 2006/10/13 11:22:27 arcelli |
59 | remove warnings due to uninitialized AliTOFtdcDigit data members | |
60 | ||
36f66fad | 61 | Revision 1.8 2006/08/22 13:30:17 arcelli |
62 | removal of effective c++ warnings (C.Zampolli) | |
63 | ||
655e379f | 64 | Revision 1.7 2006/08/10 14:46:54 decaro |
65 | TOF raw data format: updated version | |
66 | ||
d0eb8f39 | 67 | Revision 1.6.1 2006/06/28 A. De Caro, R. Preghenella: |
68 | Update TOF raw data format | |
69 | according to the final version | |
70 | (see the ALICE internal note in preparation | |
71 | 'ALICE TOF raw data format') | |
72 | Added the methods for the correspoonding numbering | |
73 | between the equipment IDs and the volume IDs: | |
74 | Equip2VolNPlate(...) | |
75 | Equip2VolNStrip(...) | |
76 | Equip2VolNPad(...) | |
77 | ||
571dda3d | 78 | Revision 0.02 2005/07/28 A. De Caro: |
79 | Update format TOF raw data | |
80 | (temporary solution) | |
81 | Correction of few wrong corrispondences | |
82 | between 'software' and 'hardware' numberings | |
83 | ||
84 | Revision 0.01 2005/07/22 A. De Caro | |
85 | Implement methods Next() | |
86 | GetSector(), | |
87 | GetPlate(), | |
88 | GetStrip(), | |
89 | GetPadZ(), | |
90 | GetPadX() | |
91 | */ | |
92 | ||
0e46b9ae | 93 | //////////////////////////////////////////////////////////////////////// |
94 | // // | |
95 | // This class provides access to TOF raw data in DDL files. // | |
96 | // // | |
97 | // It loops over all TOF raw data given by the AliRawReader. // | |
98 | // // | |
99 | //////////////////////////////////////////////////////////////////////// | |
571dda3d | 100 | |
15ec34b9 | 101 | |
13d6bff9 | 102 | #include "Riostream.h" |
103 | ||
15ec34b9 | 104 | #include "TClonesArray.h" |
105 | ||
106 | #include "AliDAQ.h" | |
d0eb8f39 | 107 | #include "AliLog.h" |
571dda3d | 108 | #include "AliRawReader.h" |
109 | ||
110 | #include "AliTOFGeometry.h" | |
15ec34b9 | 111 | #include "AliTOFrawData.h" |
112 | #include "AliTOFRawMap.h" | |
571dda3d | 113 | #include "AliTOFRawStream.h" |
32ead898 | 114 | //#include "AliTOFCableLengthMap.h" |
571dda3d | 115 | |
5c7c93fa | 116 | #include "AliTOFHitData.h" |
d0eb8f39 | 117 | |
32ead898 | 118 | #include "AliRawEventHeaderBase.h" |
143cfc81 | 119 | #include "AliRawDataHeader.h" |
32ead898 | 120 | |
571dda3d | 121 | ClassImp(AliTOFRawStream) |
122 | ||
32ead898 | 123 | const Int_t AliTOFRawStream::fgkddlBCshift[72] = |
124 | { | |
125 | 2, 2, -1, -1, | |
cfceaf15 | 126 | 2, 2, 0, 0, |
32ead898 | 127 | 2, 2, 0, 0, |
128 | 2, 2, 0, 0, | |
129 | 2, 2, 0, 0, | |
130 | 2, 2, 0, 0, | |
131 | 2, 2, 0, 0, | |
132 | 2, 2, 0, 0, | |
133 | 2, 2, 0, 0, | |
134 | 2, 2, 0, 0, | |
135 | 2, 2, -1, -1, | |
136 | 2, 2, -1, -1, | |
137 | 2, 2, -2, -2, | |
138 | 2, 2, -2, -2, | |
139 | 2, 2, -2, -2, | |
140 | 2, 2, -1, -1, | |
141 | 2, 2, -1, -1, | |
142 | 2, 2, -1, -1 | |
143 | }; | |
144 | ||
dd824655 | 145 | Bool_t AliTOFRawStream::fgApplyBCCorrections = kTRUE; |
571dda3d | 146 | //_____________________________________________________________________________ |
655e379f | 147 | AliTOFRawStream::AliTOFRawStream(AliRawReader* rawReader): |
15ec34b9 | 148 | fRawReader(rawReader), |
7813bb1a | 149 | fTOFrawData(0x0), |
150 | fDecoder(new AliTOFDecoder()), | |
655e379f | 151 | fDDL(-1), |
152 | fTRM(-1), | |
655e379f | 153 | fTRMchain(-1), |
15ec34b9 | 154 | fTDC(-1), |
655e379f | 155 | fTDCchannel(-1), |
15ec34b9 | 156 | fTime(-1), |
655e379f | 157 | fToT(-1), |
15ec34b9 | 158 | fLeadingEdge(-1), |
159 | fTrailingEdge(-1), | |
655e379f | 160 | fErrorFlag(-1), |
655e379f | 161 | fSector(-1), |
162 | fPlate(-1), | |
163 | fStrip(-1), | |
164 | fPadX(-1), | |
165 | fPadZ(-1), | |
15ec34b9 | 166 | fPackedDigits(0), |
655e379f | 167 | fWordType(-1), |
168 | fSlotID(-1), | |
169 | fACQ(-1), | |
170 | fPSbit(-1), | |
655e379f | 171 | fTDCerrorFlag(-1), |
172 | fInsideDRM(kFALSE), | |
173 | fInsideTRM(kFALSE), | |
174 | fInsideLTM(kFALSE), | |
175 | fInsideTRMchain0(kFALSE), | |
38f24f3f | 176 | fInsideTRMchain1(kFALSE), |
d35d0ea0 | 177 | fDataBuffer(), |
178 | fPackedDataBuffer(), | |
38f24f3f | 179 | fLocalEventCounterDRM(-1), |
180 | fLocalEventCounterLTM(-1), | |
181 | fLocalEventCounterTRM(0x0), | |
32ead898 | 182 | fLocalEventCounterChain(0x0), |
ca6d7f17 | 183 | fChainBunchID(0x0), |
32ead898 | 184 | fCableLengthMap(0x0), |
185 | fEventID(0) | |
571dda3d | 186 | { |
187 | // | |
188 | // create an object to read TOF raw digits | |
189 | // | |
190 | ||
7813bb1a | 191 | for (Int_t i=0;i<AliDAQ::NumberOfDdls("TOF");i++){ |
d35d0ea0 | 192 | ResetDataBuffer(i); |
193 | ResetPackedDataBuffer(i); | |
7813bb1a | 194 | } |
195 | ||
196 | fTOFrawData = new TClonesArray("AliTOFrawData",1000); | |
197 | fTOFrawData->SetOwner(); | |
198 | ||
15ec34b9 | 199 | fRawReader->Reset(); |
362c9d61 | 200 | fRawReader->Select("TOF"); |
38f24f3f | 201 | |
ca6d7f17 | 202 | fLocalEventCounterTRM = new Int_t[13]; |
203 | fLocalEventCounterChain = new Int_t*[13]; | |
204 | fChainBunchID = new Int_t*[13]; | |
205 | for (Int_t j=0;j<13;j++){ | |
206 | fLocalEventCounterTRM[j] = -1; | |
207 | fLocalEventCounterChain[j] = new Int_t[2]; | |
208 | fChainBunchID[j] = new Int_t[2]; | |
209 | for (Int_t k=0;k<2;k++){ | |
210 | fLocalEventCounterChain[j][k] = -1; | |
211 | fChainBunchID[j][k] = -1; | |
212 | } | |
213 | } | |
38f24f3f | 214 | |
32ead898 | 215 | fCableLengthMap = new AliTOFCableLengthMap(); |
216 | ||
ca6d7f17 | 217 | fEventID = (Int_t)fRawReader->GetBCID(); //bunch crossing |
218 | ||
571dda3d | 219 | } |
220 | ||
221 | //_____________________________________________________________________________ | |
655e379f | 222 | AliTOFRawStream::AliTOFRawStream(): |
7813bb1a | 223 | fRawReader(0x0), |
7813bb1a | 224 | fTOFrawData(0x0), |
225 | fDecoder(new AliTOFDecoder()), | |
655e379f | 226 | fDDL(-1), |
227 | fTRM(-1), | |
655e379f | 228 | fTRMchain(-1), |
15ec34b9 | 229 | fTDC(-1), |
655e379f | 230 | fTDCchannel(-1), |
15ec34b9 | 231 | fTime(-1), |
655e379f | 232 | fToT(-1), |
15ec34b9 | 233 | fLeadingEdge(-1), |
234 | fTrailingEdge(-1), | |
655e379f | 235 | fErrorFlag(-1), |
655e379f | 236 | fSector(-1), |
237 | fPlate(-1), | |
238 | fStrip(-1), | |
239 | fPadX(-1), | |
240 | fPadZ(-1), | |
15ec34b9 | 241 | fPackedDigits(0), |
655e379f | 242 | fWordType(-1), |
243 | fSlotID(-1), | |
244 | fACQ(-1), | |
245 | fPSbit(-1), | |
655e379f | 246 | fTDCerrorFlag(-1), |
247 | fInsideDRM(kFALSE), | |
248 | fInsideTRM(kFALSE), | |
249 | fInsideLTM(kFALSE), | |
250 | fInsideTRMchain0(kFALSE), | |
38f24f3f | 251 | fInsideTRMchain1(kFALSE), |
d35d0ea0 | 252 | fDataBuffer(), |
253 | fPackedDataBuffer(), | |
38f24f3f | 254 | fLocalEventCounterDRM(-1), |
255 | fLocalEventCounterLTM(-1), | |
256 | fLocalEventCounterTRM(0x0), | |
32ead898 | 257 | fLocalEventCounterChain(0x0), |
ca6d7f17 | 258 | fChainBunchID(0x0), |
32ead898 | 259 | fCableLengthMap(0x0), |
260 | fEventID(0) | |
571dda3d | 261 | { |
262 | // | |
d0eb8f39 | 263 | // default ctr |
571dda3d | 264 | // |
7813bb1a | 265 | for (Int_t i=0;i<AliDAQ::NumberOfDdls("TOF");i++){ |
d35d0ea0 | 266 | ResetDataBuffer(i); |
267 | ResetPackedDataBuffer(i); | |
7813bb1a | 268 | } |
15ec34b9 | 269 | |
7813bb1a | 270 | fTOFrawData = new TClonesArray("AliTOFrawData",1000); |
271 | fTOFrawData->SetOwner(); | |
38f24f3f | 272 | |
ca6d7f17 | 273 | fLocalEventCounterTRM = new Int_t[13]; |
274 | fLocalEventCounterChain = new Int_t*[13]; | |
275 | fChainBunchID = new Int_t*[13]; | |
276 | for (Int_t j=0;j<13;j++){ | |
277 | fLocalEventCounterTRM[j] = -1; | |
278 | fLocalEventCounterChain[j] = new Int_t[2]; | |
279 | fChainBunchID[j] = new Int_t[2]; | |
280 | for (Int_t k=0;k<2;k++){ | |
281 | fLocalEventCounterChain[j][k] = -1; | |
282 | fChainBunchID[j][k] = -1; | |
283 | } | |
284 | } | |
38f24f3f | 285 | |
32ead898 | 286 | fCableLengthMap = new AliTOFCableLengthMap(); |
287 | ||
d0eb8f39 | 288 | } |
289 | ||
290 | //_____________________________________________________________________________ | |
291 | AliTOFRawStream::AliTOFRawStream(const AliTOFRawStream& stream) : | |
655e379f | 292 | TObject(stream), |
8a190ba2 | 293 | fRawReader(stream.fRawReader), |
294 | fTOFrawData(stream.fTOFrawData), | |
7813bb1a | 295 | fDecoder(new AliTOFDecoder()), |
8a190ba2 | 296 | fDDL(stream.fDDL), |
297 | fTRM(stream.fTRM), | |
298 | fTRMchain(stream.fTRMchain), | |
299 | fTDC(stream.fTDC), | |
300 | fTDCchannel(stream.fTDCchannel), | |
301 | fTime(stream.fTime), | |
302 | fToT(-stream.fToT), | |
303 | fLeadingEdge(stream.fLeadingEdge), | |
304 | fTrailingEdge(stream.fTrailingEdge), | |
305 | fErrorFlag(stream.fErrorFlag), | |
306 | fSector(stream.fSector), | |
307 | fPlate(stream.fPlate), | |
308 | fStrip(stream.fStrip), | |
309 | fPadX(stream.fPadX), | |
310 | fPadZ(stream.fPadZ), | |
311 | fPackedDigits(stream.fPackedDigits), | |
312 | fWordType(stream.fWordType), | |
313 | fSlotID(stream.fSlotID), | |
314 | fACQ(stream.fACQ), | |
315 | fPSbit(stream.fPSbit), | |
316 | fTDCerrorFlag(stream.fTDCerrorFlag), | |
317 | fInsideDRM(stream.fInsideDRM), | |
318 | fInsideTRM(stream.fInsideTRM), | |
319 | fInsideLTM(stream.fInsideLTM), | |
320 | fInsideTRMchain0(stream.fInsideTRMchain0), | |
321 | fInsideTRMchain1(stream.fInsideTRMchain1), | |
d35d0ea0 | 322 | fDataBuffer(), |
323 | fPackedDataBuffer(), | |
8a190ba2 | 324 | fLocalEventCounterDRM(stream.fLocalEventCounterDRM), |
325 | fLocalEventCounterLTM(stream.fLocalEventCounterLTM), | |
38f24f3f | 326 | fLocalEventCounterTRM(0x0), |
32ead898 | 327 | fLocalEventCounterChain(0x0), |
ca6d7f17 | 328 | fChainBunchID(0x0), |
8a190ba2 | 329 | fCableLengthMap(stream.fCableLengthMap), |
330 | fEventID(stream.fEventID) | |
d0eb8f39 | 331 | { |
332 | // | |
333 | // copy constructor | |
334 | // | |
335 | ||
7813bb1a | 336 | for (Int_t i=0;i<AliDAQ::NumberOfDdls("TOF");i++){ |
d35d0ea0 | 337 | fDataBuffer[i] = stream.fDataBuffer[i]; |
338 | fPackedDataBuffer[i] = stream.fPackedDataBuffer[i]; | |
7813bb1a | 339 | } |
340 | ||
341 | fTOFrawData = new TClonesArray(*stream.fTOFrawData); | |
38f24f3f | 342 | |
ca6d7f17 | 343 | for (Int_t j=0;j<13;j++){ |
344 | fLocalEventCounterTRM[j] = stream.fLocalEventCounterTRM[j]; | |
345 | for (Int_t k=0;k<2;k++){ | |
346 | fLocalEventCounterChain[j][k] = stream.fLocalEventCounterChain[j][k]; | |
347 | fChainBunchID[j][k] = stream.fChainBunchID[j][k]; | |
348 | } | |
349 | } | |
38f24f3f | 350 | |
571dda3d | 351 | } |
352 | ||
353 | //_____________________________________________________________________________ | |
354 | AliTOFRawStream& AliTOFRawStream::operator = (const AliTOFRawStream& stream) | |
355 | { | |
356 | // | |
357 | // assignment operator | |
358 | // | |
359 | ||
8a190ba2 | 360 | if (this == &stream) |
361 | return *this; | |
362 | ||
363 | TObject::operator=(stream); | |
364 | ||
571dda3d | 365 | fRawReader = stream.fRawReader; |
15ec34b9 | 366 | |
367 | fTOFrawData = stream.fTOFrawData; | |
368 | ||
571dda3d | 369 | fDDL = stream.fDDL; |
370 | fTRM = stream.fTRM; | |
d0eb8f39 | 371 | fTRMchain = stream.fTRMchain; |
15ec34b9 | 372 | fTDC = stream.fTDC; |
d0eb8f39 | 373 | fTDCchannel = stream.fTDCchannel; |
15ec34b9 | 374 | fTime = stream.fTime; |
d0eb8f39 | 375 | fToT = stream.fToT; |
15ec34b9 | 376 | fLeadingEdge = stream.fLeadingEdge; |
377 | fTrailingEdge = stream.fTrailingEdge; | |
571dda3d | 378 | fErrorFlag = stream.fErrorFlag; |
d0eb8f39 | 379 | |
380 | fSector = stream.fSector; | |
381 | fPlate = stream.fPlate; | |
382 | fStrip = stream.fStrip; | |
383 | fPadX = stream.fPadX; | |
384 | fPadZ = stream.fPadZ; | |
571dda3d | 385 | |
15ec34b9 | 386 | fPackedDigits = stream.fPackedDigits; |
387 | ||
d0eb8f39 | 388 | fWordType = stream.fWordType; |
389 | fSlotID = stream.fSlotID; | |
390 | fACQ = stream.fACQ; | |
391 | fPSbit = stream.fPSbit; | |
d0eb8f39 | 392 | fTDCerrorFlag = stream.fTDCerrorFlag; |
393 | fInsideDRM = stream.fInsideDRM; | |
394 | fInsideTRM = stream.fInsideTRM; | |
395 | fInsideLTM = stream.fInsideLTM; | |
396 | fInsideTRMchain0 = stream.fInsideTRMchain0; | |
397 | fInsideTRMchain1 = stream.fInsideTRMchain1; | |
7813bb1a | 398 | |
399 | for (Int_t i=0;i<AliDAQ::NumberOfDdls("TOF");i++){ | |
400 | fDataBuffer[i] = stream.fDataBuffer[i]; | |
401 | fPackedDataBuffer[i] = stream.fPackedDataBuffer[i]; | |
402 | } | |
403 | ||
404 | fTOFrawData = stream.fTOFrawData; | |
38f24f3f | 405 | |
ca6d7f17 | 406 | fLocalEventCounterDRM = stream.fLocalEventCounterDRM; |
407 | fLocalEventCounterLTM = stream.fLocalEventCounterLTM; | |
408 | for (Int_t j=0;j<13;j++){ | |
409 | fLocalEventCounterTRM[j] = stream.fLocalEventCounterTRM[j]; | |
410 | for (Int_t k=0;k<2;k++){ | |
411 | fLocalEventCounterChain[j][k] = stream.fLocalEventCounterChain[j][k]; | |
412 | fChainBunchID[j][k] = stream.fChainBunchID[j][k]; | |
413 | } | |
414 | } | |
38f24f3f | 415 | |
32ead898 | 416 | fCableLengthMap = stream.fCableLengthMap; |
417 | ||
418 | fEventID = stream.fEventID; | |
419 | ||
571dda3d | 420 | return *this; |
421 | ||
422 | } | |
423 | ||
424 | //_____________________________________________________________________________ | |
425 | AliTOFRawStream::~AliTOFRawStream() | |
426 | { | |
427 | // destructor | |
428 | ||
15ec34b9 | 429 | fPackedDigits = 0; |
430 | ||
7813bb1a | 431 | delete fDecoder; |
15ec34b9 | 432 | |
7813bb1a | 433 | fTOFrawData->Clear(); |
434 | delete fTOFrawData; | |
38f24f3f | 435 | |
415c84fa | 436 | delete [] fLocalEventCounterTRM; |
ca6d7f17 | 437 | for (Int_t ii=0; ii<2; ii++) { |
32ead898 | 438 | delete [] fLocalEventCounterChain[ii]; |
ca6d7f17 | 439 | delete [] fChainBunchID[ii]; |
440 | } | |
32ead898 | 441 | delete fCableLengthMap; |
38f24f3f | 442 | |
571dda3d | 443 | } |
444 | ||
445 | ||
15ec34b9 | 446 | //_____________________________________________________________________________ |
447 | ||
448 | void AliTOFRawStream::LoadRawData(Int_t indexDDL) | |
449 | { | |
0192b95f | 450 | // |
451 | // To load raw data | |
452 | // | |
15ec34b9 | 453 | |
74cd22f8 | 454 | fTOFrawData->Clear(); |
0192b95f | 455 | |
74cd22f8 | 456 | TClonesArray &arrayTofRawData = *fTOFrawData; |
457 | ||
15ec34b9 | 458 | fPackedDigits = 0; |
459 | ||
460 | // create raw data map | |
461 | AliTOFRawMap *rawMap = new AliTOFRawMap(fTOFrawData); | |
462 | rawMap->Clear(); | |
463 | ||
464 | Int_t slot[4] = {-1, -1, -1, -1}; | |
465 | ||
415c84fa | 466 | fLocalEventCounterDRM = -1; |
467 | fLocalEventCounterLTM = -1; | |
468 | for (Int_t ii=0; ii<13; ii++) | |
469 | fLocalEventCounterTRM[ii] = -1; | |
470 | for (Int_t ii=0; ii<13; ii++) | |
471 | for (Int_t jj=0; jj<2; jj++) | |
472 | fLocalEventCounterChain[ii][jj] = -1; | |
473 | ||
15ec34b9 | 474 | fRawReader->Reset(); |
475 | fRawReader->Select("TOF", indexDDL, indexDDL); | |
476 | ||
477 | Bool_t signal = kFALSE; | |
478 | ||
74cd22f8 | 479 | AliTOFrawData *rawDigit = NULL; |
7813bb1a | 480 | |
15ec34b9 | 481 | while(Next()) { |
482 | ||
483 | signal = (fSector!=-1 && fPlate!=-1 && fStrip!=-1 && fPadZ!=-1 && fPadX!=-1); | |
484 | if (signal) { | |
38f24f3f | 485 | AliDebug(2,Form(" %2i %1i %2i %1i %2i", fSector, fPlate, fStrip, fPadZ, fPadX)); |
15ec34b9 | 486 | |
487 | slot[0] = fTRM; | |
488 | slot[1] = fTRMchain; | |
489 | slot[2] = fTDC; | |
490 | slot[3] = fTDCchannel; | |
491 | ||
492 | if (rawMap->TestHit(slot) != kEmpty) { | |
493 | ||
74cd22f8 | 494 | rawDigit = static_cast<AliTOFrawData*>(rawMap->GetHit(slot)); |
15ec34b9 | 495 | |
496 | if (rawDigit->GetLeading()!=-1 && rawDigit->GetTrailing()==-1 && | |
497 | fLeadingEdge==-1 && fTrailingEdge!=-1) { | |
498 | ||
499 | rawDigit->Update(fTime, fToT, fLeadingEdge, fTrailingEdge, fPSbit, fACQ, fErrorFlag); | |
500 | } | |
501 | else if ( ((rawDigit->GetTOF()!=-1 || rawDigit->GetLeading()!=-1 || rawDigit->GetTrailing()!=-1) && | |
502 | (fLeadingEdge!=-1 || fTrailingEdge!=-1 || fTime!=-1) ) | |
503 | ||
0192b95f | 504 | ) |
15ec34b9 | 505 | { |
506 | ||
74cd22f8 | 507 | new (arrayTofRawData[fPackedDigits++]) AliTOFrawData(fTRM, fTRMchain, fTDC, fTDCchannel, fTime, fToT, fLeadingEdge, fTrailingEdge, fPSbit, fACQ, fErrorFlag); |
15ec34b9 | 508 | |
74cd22f8 | 509 | rawMap->SetHit(slot); |
15ec34b9 | 510 | |
74cd22f8 | 511 | } |
15ec34b9 | 512 | |
513 | ||
514 | } | |
515 | else { | |
516 | ||
15ec34b9 | 517 | new (arrayTofRawData[fPackedDigits++]) AliTOFrawData(fTRM, fTRMchain, fTDC, fTDCchannel, fTime, fToT, fLeadingEdge, fTrailingEdge, fPSbit, fACQ, fErrorFlag); |
518 | ||
519 | rawMap->SetHit(slot); | |
520 | ||
521 | } // else if (rawMap->TestHit(slot) == kEmpty) | |
522 | ||
523 | } // if (signal) | |
524 | ||
525 | } // closed -> while (Next()) | |
526 | ||
74cd22f8 | 527 | rawMap->Delete(); |
7813bb1a | 528 | |
15ec34b9 | 529 | } |
530 | ||
571dda3d | 531 | //_____________________________________________________________________________ |
532 | Bool_t AliTOFRawStream::Next() | |
533 | { | |
d0eb8f39 | 534 | // |
535 | // Read next 32-bit word in TOF raw data files | |
536 | // returns kFALSE if there is no word left | |
537 | // | |
571dda3d | 538 | |
539 | UInt_t data; | |
540 | ||
38f24f3f | 541 | Int_t dummy = 0; |
542 | ||
571dda3d | 543 | if (!fRawReader->ReadNextInt(data)) return kFALSE; |
544 | ||
d0eb8f39 | 545 | if (fSector!=-1 && fPlate!=-1 && fStrip!=-1 && fPadZ!=-1 && fPadX!=-1) { |
546 | fSector = -1; | |
15ec34b9 | 547 | fPlate = -1; |
548 | fStrip = -1; | |
549 | fPadZ = -1; | |
550 | fPadX = -1; | |
551 | fTime = -1; | |
552 | fToT = -1; | |
553 | fLeadingEdge = -1; | |
554 | fTrailingEdge = -1; | |
d0eb8f39 | 555 | } |
571dda3d | 556 | |
571dda3d | 557 | fDDL = fRawReader->GetDDLID(); |
558 | ||
d0eb8f39 | 559 | fWordType = GetField(data,WORD_TYPE_MASK,WORD_TYPE_POSITION); |
560 | ||
561 | switch (fWordType) { // switch word type | |
562 | ||
563 | case GLOBAL_HEADER_TYPE: // global header | |
564 | fSlotID = GetField(data, HEADER_SLOT_ID_MASK, HEADER_SLOT_ID_POSITION); | |
565 | fTRM = fSlotID; | |
566 | ||
567 | ||
568 | switch (fSlotID) { // switch global header slot ID | |
569 | ||
570 | case DRM_ID_NUMBER: //DRM global header | |
571 | if (fInsideDRM) { // unexpected DRM global headers -> exit | |
572 | break; | |
573 | } | |
574 | fInsideDRM = kTRUE; // DRM global header accepted | |
575 | break; | |
576 | ||
577 | case LTM_ID_NUMBER: // LTM global header | |
578 | if (fInsideLTM) { // unexpected LTM global headers -> exit | |
579 | break; | |
580 | } | |
581 | fInsideLTM = kTRUE; // LTM global header accepted | |
582 | break; | |
583 | ||
584 | case 3: //TRM header | |
585 | case 4: //TRM header | |
586 | case 5: //TRM header | |
587 | case 6: //TRM header | |
588 | case 7: //TRM header | |
589 | case 8: //TRM header | |
590 | case 9: //TRM header | |
591 | case 10: //TRM header | |
592 | case 11: //TRM header | |
593 | case 12: //TRM header | |
594 | if (fInsideTRM) { // unexpected TRM global headers -> exit | |
595 | break; | |
596 | } | |
597 | fInsideTRM = kTRUE; // TRM global header accepted | |
598 | fACQ = GetField(data,TRM_ACQ_BITS_MASK,TRM_ACQ_BITS_POSITION); | |
599 | break; | |
600 | ||
601 | default: // unexpected global header slot ID | |
602 | break; | |
603 | ||
604 | } //end switch global header slot id | |
605 | ||
606 | break; | |
607 | ||
608 | ||
609 | case GLOBAL_TRAILER_TYPE: // global trailer | |
610 | fSlotID = GetField(data,HEADER_SLOT_ID_MASK,HEADER_SLOT_ID_POSITION); | |
d0eb8f39 | 611 | |
612 | switch (fSlotID) { // switch global trailer slot ID | |
613 | ||
614 | case DRM_ID_NUMBER: // DRM global trailer | |
615 | if (!fInsideDRM) { // unexpected DRM global trailers -> exit | |
616 | break; | |
617 | } | |
38f24f3f | 618 | dummy = 0x0000fff0; |
619 | //AliInfo(Form(" DRM local event counter = %i", GetField(data,dummy,4))); | |
ca6d7f17 | 620 | fLocalEventCounterDRM = GetField(data,dummy,4); |
d0eb8f39 | 621 | fInsideDRM = kFALSE; // DRM global trailer accepted |
622 | fInsideTRM = kFALSE; | |
623 | fInsideLTM = kFALSE; | |
624 | fInsideTRMchain0 = kFALSE; | |
625 | fInsideTRMchain1 = kFALSE; | |
d0eb8f39 | 626 | fSector = -1; |
15ec34b9 | 627 | fPlate = -1; |
628 | fStrip = -1; | |
629 | fPadZ = -1; | |
630 | fPadX = -1; | |
631 | fDDL = -1; | |
632 | fTRM = -1; | |
633 | fTDC = -1; | |
634 | fTRMchain = -1; | |
d0eb8f39 | 635 | fTDCchannel = -1; |
15ec34b9 | 636 | fTime = -1; |
637 | fToT = -1; | |
638 | fLeadingEdge = -1; | |
639 | fTrailingEdge = -1; | |
d0eb8f39 | 640 | fErrorFlag = -1; |
15ec34b9 | 641 | fACQ = -1; |
d0eb8f39 | 642 | fPSbit = -1; |
d0eb8f39 | 643 | fTDCerrorFlag = -1; |
644 | break; | |
645 | case LTM_ID_NUMBER: // LTM global trailer | |
646 | if (!fInsideLTM) { // unexpected LTM global trailer -> exit | |
647 | break; | |
648 | } | |
38f24f3f | 649 | dummy = 0x0fff0000; |
650 | //AliInfo(Form(" LTM local event counter = %i", GetField(data,dummy,16))); | |
ca6d7f17 | 651 | fLocalEventCounterLTM = GetField(data,dummy,16); |
d0eb8f39 | 652 | fInsideLTM = kFALSE; // LTM global trailer accepted |
653 | break; | |
654 | case 15: //TRM global trailer | |
655 | if (!fInsideTRM) { // unexpected TRM global trailers -> exit | |
656 | break; | |
657 | } | |
38f24f3f | 658 | dummy = 0x0fff0000; |
659 | //AliInfo(Form(" TRM local event counter = %i", GetField(data,dummy,16))); | |
ca6d7f17 | 660 | fLocalEventCounterTRM[fTRM] = GetField(data,dummy,16); |
d0eb8f39 | 661 | fInsideTRM = kFALSE; // TRM global trailer accepted |
662 | break; | |
663 | default: // unexpected global trailer slot ID | |
664 | break; | |
665 | } //end switch global trailer slot id | |
666 | ||
667 | ||
668 | break; | |
669 | ||
670 | ||
671 | case ERROR_TYPE: // TDC error | |
15ec34b9 | 672 | fTDC = GetField(data,TRM_TDC_ERROR_TDC_ID_MASK,TRM_TDC_ERROR_TDC_ID_POSITION); |
d0eb8f39 | 673 | fTDCerrorFlag = GetField(data,TRM_TDC_ERROR_FLAGS_MASK,TRM_TDC_ERROR_FLAGS_POSITION); |
674 | break; | |
675 | ||
676 | ||
677 | case FILLER_TYPE: // filler | |
678 | break; | |
679 | ||
680 | ||
681 | default: // other word types | |
682 | ||
683 | if (fInsideTRM) { // inside TRM | |
684 | ||
685 | switch (fWordType) { // switch word type inside TRM | |
686 | case TRM_CHAIN0_HEADER_TYPE: // TRM chain0 header | |
687 | if (fInsideTRMchain0) { // unexpected TRM chain0 header | |
688 | break; | |
689 | } | |
690 | fInsideTRMchain0 = kTRUE; | |
691 | fTRMchain = 0; | |
ca6d7f17 | 692 | dummy = 0x0000fff0; |
693 | //AliInfo(Form(" chain bunch ID = %i", GetField(data,dummy,4))); | |
694 | fChainBunchID[fTRM][fTRMchain] = GetField(data,dummy,4); | |
d0eb8f39 | 695 | break; |
696 | case TRM_CHAIN0_TRAILER_TYPE: // TRM chain0 trailer | |
697 | if (!fInsideTRMchain0) { // unexpected TRM chain0 trailer | |
698 | break; | |
699 | } | |
38f24f3f | 700 | dummy = 0x0fff0000; |
701 | //AliInfo(Form(" chain local event counter = %i", GetField(data,dummy,16))); | |
ca6d7f17 | 702 | fLocalEventCounterChain[fTRM][fTRMchain] = GetField(data,dummy,16); |
d0eb8f39 | 703 | fInsideTRMchain0 = kFALSE; |
704 | fTRMchain = -1; | |
705 | break; | |
706 | case TRM_CHAIN1_HEADER_TYPE: // TRM chain1 header | |
707 | if (fInsideTRMchain1) { // unexpected TRM chain1 header | |
708 | break; | |
709 | } | |
710 | fInsideTRMchain1 = kTRUE; | |
711 | fTRMchain = 1; | |
ca6d7f17 | 712 | dummy = 0x0000fff0; |
713 | //AliInfo(Form(" chain bunch ID = %i", GetField(data,dummy,4))); | |
714 | fChainBunchID[fTRM][fTRMchain] = GetField(data,dummy,4); | |
d0eb8f39 | 715 | break; |
716 | case TRM_CHAIN1_TRAILER_TYPE: // TRM chain1 trailer | |
717 | if (!fInsideTRMchain1) { // unexpected TRM chain1 trailer | |
718 | break; | |
719 | } | |
38f24f3f | 720 | dummy = 0x0fff0000; |
721 | //AliInfo(Form(" chain local event counter = %i", GetField(data,dummy,16))); | |
ca6d7f17 | 722 | fLocalEventCounterChain[fTRM][fTRMchain] = GetField(data,dummy,16); |
d0eb8f39 | 723 | fInsideTRMchain1 = kFALSE; |
724 | fTRMchain = -1; | |
725 | break; | |
726 | } // end switch word type inside TRM | |
727 | ||
728 | } // end if (fInsideTRM) | |
729 | ||
730 | ||
731 | if ( | |
732 | ((fInsideTRMchain0&&!fInsideTRMchain1) || (!fInsideTRMchain0&&fInsideTRMchain1)) | |
733 | && fWordType!=TRM_CHAIN0_HEADER_TYPE && fWordType!=TRM_CHAIN0_TRAILER_TYPE | |
734 | && fWordType!=TRM_CHAIN1_HEADER_TYPE && fWordType!=TRM_CHAIN1_TRAILER_TYPE | |
735 | ){ // inside TRM chains | |
15ec34b9 | 736 | |
737 | fPSbit = GetField(data,TRM_PS_BITS_MASK,TRM_PS_BITS_POSITION); | |
738 | fTDC = GetField(data,TRM_TDC_ID_MASK,TRM_TDC_ID_POSITION); | |
d0eb8f39 | 739 | fTDCchannel = GetField(data,TRM_CHAN_MASK,TRM_CHAN_POSITION); |
15ec34b9 | 740 | fErrorFlag = GetField(data,TRM_E_BIT_MASK,TRM_E_BIT_POSITION); |
741 | ||
742 | SetSector(); | |
743 | SetPlate(); | |
744 | SetStrip(); | |
745 | SetPadZ(); | |
746 | SetPadX(); | |
747 | ||
d0eb8f39 | 748 | |
749 | switch (fPSbit) { // switch fPSbit bits inside TRM chains | |
15ec34b9 | 750 | |
751 | case 0: // packing ok, digit time and TOT | |
752 | fToT = GetField(data,TRM_TOT_WIDTH_MASK, TRM_TOT_WIDTH_POSITION); | |
32ead898 | 753 | fTime = GetField(data,TRM_DIGIT_TIME_MASK,TRM_DIGIT_TIME_POSITION) |
cfceaf15 | 754 | /*- |
755 | fCableLengthMap->GetCableTimeShiftBin(fDDL, fTRM, fTRMchain, fTDC)*/ | |
32ead898 | 756 | ; |
143cfc81 | 757 | if (fgApplyBCCorrections) { |
ca6d7f17 | 758 | AliDebug(2,"Apply nominal DDL BC time-shift correction"); |
759 | AliDebug(2,"Apply deltaBC time-shift correction"); | |
760 | AliDebug(2,Form(" fChainBunchID[%d][%d] = %d ,fEventID = %d",fTRM,fTRMchain,fChainBunchID[fTRM][fTRMchain],fEventID)); | |
143cfc81 | 761 | fTime += |
ca6d7f17 | 762 | (Int_t)(fgkddlBCshift[fDDL]*25./AliTOFGeometry::TdcBinWidth()*1.E+03) |
143cfc81 | 763 | + |
ca6d7f17 | 764 | (Int_t)((fChainBunchID[fTRM][fTRMchain]-fEventID)*25./AliTOFGeometry::TdcBinWidth()*1.E+03); |
143cfc81 | 765 | } |
d0eb8f39 | 766 | break; |
767 | ||
768 | case 1: // leading edge digit, long digit time, no TOT | |
15ec34b9 | 769 | //fToT = -1; |
770 | //fTime = -1; | |
32ead898 | 771 | fLeadingEdge = GetField(data,TRM_LONG_DIGIT_TIME_MASK,TRM_LONG_DIGIT_TIME_POSITION) |
cfceaf15 | 772 | /*- |
773 | fCableLengthMap->GetCableTimeShiftBin(fDDL, fTRM, fTRMchain, fTDC)*/ | |
32ead898 | 774 | ; |
143cfc81 | 775 | if (fgApplyBCCorrections) { |
ca6d7f17 | 776 | AliDebug(2,"Apply nominal DDL BC time-shift correction"); |
777 | AliDebug(2,"Apply deltaBC time-shift correction"); | |
778 | AliDebug(2,Form(" fChainBunchID[%d][%d] = %d ,fEventID = %d",fTRM,fTRMchain,fChainBunchID[fTRM][fTRMchain],fEventID)); | |
143cfc81 | 779 | fLeadingEdge += |
ca6d7f17 | 780 | (Int_t)(fgkddlBCshift[fDDL]*25./AliTOFGeometry::TdcBinWidth()*1.E+03) |
143cfc81 | 781 | + |
ca6d7f17 | 782 | (Int_t)((fChainBunchID[fTRM][fTRMchain]-fEventID)*25./AliTOFGeometry::TdcBinWidth()*1.E+03); |
143cfc81 | 783 | } |
d0eb8f39 | 784 | break; |
785 | ||
786 | case 2: // trailing edge digit, long digit time, no TOT | |
15ec34b9 | 787 | //fToT = -1; |
788 | //fTime = -1; | |
32ead898 | 789 | fTrailingEdge = GetField(data,TRM_LONG_DIGIT_TIME_MASK,TRM_LONG_DIGIT_TIME_POSITION) |
cfceaf15 | 790 | /*- |
791 | fCableLengthMap->GetCableTimeShiftBin(fDDL, fTRM, fTRMchain, fTDC)*/ | |
32ead898 | 792 | ; |
143cfc81 | 793 | if (fgApplyBCCorrections) { |
ca6d7f17 | 794 | AliDebug(2,"Apply nominal DDL BC time-shift correction"); |
795 | AliDebug(2,"Apply deltaBC time-shift correction"); | |
796 | AliDebug(2,Form(" fChainBunchID[%d][%d] = %d ,fEventID = %d",fTRM,fTRMchain,fChainBunchID[fTRM][fTRMchain],fEventID)); | |
143cfc81 | 797 | fTrailingEdge += |
ca6d7f17 | 798 | (Int_t)(fgkddlBCshift[fDDL]*25./AliTOFGeometry::TdcBinWidth()*1.E+03) |
143cfc81 | 799 | + |
ca6d7f17 | 800 | (Int_t)((fChainBunchID[fTRM][fTRMchain]-fEventID)*25./AliTOFGeometry::TdcBinWidth()*1.E+03); |
143cfc81 | 801 | } |
d0eb8f39 | 802 | break; |
15ec34b9 | 803 | |
d0eb8f39 | 804 | case 3: // TOT overflow |
15ec34b9 | 805 | fToT = GetField(data,TRM_TOT_WIDTH_MASK, TRM_TOT_WIDTH_POSITION); |
32ead898 | 806 | fTime = GetField(data,TRM_DIGIT_TIME_MASK,TRM_DIGIT_TIME_POSITION) |
cfceaf15 | 807 | /*- |
808 | fCableLengthMap->GetCableTimeShiftBin(fDDL, fTRM, fTRMchain, fTDC)*/ | |
32ead898 | 809 | ; |
143cfc81 | 810 | if (fgApplyBCCorrections) { |
ca6d7f17 | 811 | AliDebug(2,"Apply nominal DDL BC time-shift correction"); |
812 | AliDebug(2,"Apply deltaBC time-shift correction"); | |
813 | AliDebug(2,Form(" fChainBunchID[%d][%d] = %d ,fEventID = %d",fTRM,fTRMchain,fChainBunchID[fTRM][fTRMchain],fEventID)); | |
143cfc81 | 814 | fTime += |
ca6d7f17 | 815 | (Int_t)(fgkddlBCshift[fDDL]*25./AliTOFGeometry::TdcBinWidth()*1.E+03) |
143cfc81 | 816 | + |
ca6d7f17 | 817 | (Int_t)((fChainBunchID[fTRM][fTRMchain]-fEventID)*25./AliTOFGeometry::TdcBinWidth()*1.E+03); |
143cfc81 | 818 | } |
d0eb8f39 | 819 | break; |
d0eb8f39 | 820 | |
15ec34b9 | 821 | } // end switch PS bits inside TRM chains |
d0eb8f39 | 822 | |
823 | } // end if is inside TRM chains | |
824 | ||
825 | } // end switch on fWordType | |
571dda3d | 826 | |
15ec34b9 | 827 | |
571dda3d | 828 | return kTRUE; |
7813bb1a | 829 | |
571dda3d | 830 | } |
831 | //_____________________________________________________________________________ | |
832 | ||
d0eb8f39 | 833 | void AliTOFRawStream::SetSector() |
571dda3d | 834 | { |
835 | // | |
d0eb8f39 | 836 | // Evaluate the TOF sector number -> [ 0;17] |
837 | // corresponding to the TOF equipment IDs: | |
838 | // fDDL -> [ 0;71] | |
839 | // fTRM -> [ 3;12] | |
15ec34b9 | 840 | // fTRMchain -> [ 0; 1] |
d0eb8f39 | 841 | // fTDC -> [ 0;14] |
842 | // fTDCchannel -> [ 0; 7] | |
571dda3d | 843 | // |
844 | ||
845 | Int_t iSector = -1; | |
571dda3d | 846 | |
d0eb8f39 | 847 | if (!(fDDL==-1)) iSector = Int_t((Float_t)(fDDL)/AliTOFGeometry::NDDL()); |
848 | ||
849 | fSector = iSector; | |
571dda3d | 850 | |
851 | } | |
852 | //_____________________________________________________________________________ | |
853 | ||
d0eb8f39 | 854 | |
855 | void AliTOFRawStream::SetPlate() | |
571dda3d | 856 | { |
857 | // | |
d0eb8f39 | 858 | // Evaluate the TOF plate number ->[ 0; 4] |
859 | // corresponding to the TOF equipment IDs: | |
860 | // fDDL -> [ 0;71] | |
861 | // fTRM -> [ 3;12] | |
15ec34b9 | 862 | // fTRMchain -> [ 0; 1] |
d0eb8f39 | 863 | // fTDC -> [ 0;14] |
864 | // fTDCchannel -> [ 0; 7] | |
571dda3d | 865 | // |
866 | ||
867 | Int_t iPlate = -1; | |
d0eb8f39 | 868 | if (!(fDDL==-1 || fTRM==-1 || fTDC==-1 |
869 | || fSector==-1)) | |
870 | iPlate = Equip2VolNplate(GetDDLnumberPerSector(fDDL), fTRM, fTDC); | |
571dda3d | 871 | |
d0eb8f39 | 872 | fPlate = iPlate; |
571dda3d | 873 | |
874 | } | |
875 | //_____________________________________________________________________________ | |
876 | ||
d0eb8f39 | 877 | void AliTOFRawStream::SetStrip() |
571dda3d | 878 | { |
879 | // | |
d0eb8f39 | 880 | // Evaluate the TOF strip number per module -> [ 0; 14/18] |
881 | // corresponding to the TOF equipment IDs: | |
882 | // fDDL -> [ 0;71] | |
883 | // fTRM -> [ 3;12] | |
15ec34b9 | 884 | // fTRMchain -> [ 0; 1] |
d0eb8f39 | 885 | // fTDC -> [ 0;14] |
886 | // fTDCchannel -> [ 0; 7] | |
571dda3d | 887 | // |
888 | ||
889 | Int_t iStrip = -1; | |
890 | ||
d0eb8f39 | 891 | if (!(fDDL==-1 || fTRM==-1 || fTDC==-1 |
892 | || fSector==-1 || fPlate==-1)) | |
893 | iStrip = Equip2VolNstrip(GetDDLnumberPerSector(fDDL), fTRM, fTDC); | |
571dda3d | 894 | |
d0eb8f39 | 895 | fStrip = iStrip; |
571dda3d | 896 | |
897 | } | |
898 | //_____________________________________________________________________________ | |
899 | ||
d0eb8f39 | 900 | void AliTOFRawStream::SetPadZ() |
571dda3d | 901 | { |
902 | // | |
d0eb8f39 | 903 | // Evaluate the TOF padRow number per strip -> [ 0; 1] |
904 | // corresponding to the TOF equipment IDs: | |
905 | // fDDL -> [ 0;71] | |
906 | // fTRM -> [ 3;12] | |
15ec34b9 | 907 | // fTRMchain -> [ 0; 1] |
d0eb8f39 | 908 | // fTDC -> [ 0;14] |
909 | // fTDCchannel -> [ 0; 7] | |
571dda3d | 910 | // |
911 | ||
912 | Int_t iPadZ = -1; | |
913 | ||
d0eb8f39 | 914 | if (!(fDDL==-1 || fTRM==-1 || fTRMchain==-1 || fTDC==-1 || fTDCchannel==-1 |
915 | || fSector==-1 || fPlate==-1 || fStrip==-1)) | |
916 | { | |
917 | Int_t iPadAlongTheStrip = Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel); | |
918 | if (iPadAlongTheStrip!=-1) | |
919 | iPadZ = iPadAlongTheStrip%AliTOFGeometry::NpadZ(); | |
920 | } | |
571dda3d | 921 | |
38f24f3f | 922 | //iPadZ = Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel)%AliTOFGeometry::NpadZ(); |
923 | //iPadZ = Equip2VolNpadZ(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel); | |
924 | ||
d0eb8f39 | 925 | fPadZ = iPadZ; |
571dda3d | 926 | |
d0eb8f39 | 927 | } |
928 | //_____________________________________________________________________________ | |
929 | ||
930 | void AliTOFRawStream::SetPadX() | |
931 | { | |
932 | // | |
933 | // Evaluate the TOF pad number per strip padRow -> [ 0;47] | |
934 | // corresponding to the TOF equipment IDs: | |
935 | // fDDL -> [ 0;71] | |
936 | // fTRM -> [ 3;12] | |
15ec34b9 | 937 | // fTRMchain -> [ 0; 1] |
d0eb8f39 | 938 | // fTDC -> [ 0;14] |
939 | // fTDCchannel -> [ 0; 7] | |
940 | // | |
571dda3d | 941 | |
d0eb8f39 | 942 | Int_t iPadX = -1; |
571dda3d | 943 | |
d0eb8f39 | 944 | if (!(fDDL==-1 || fTRM==-1 || fTRMchain==-1 || fTDC==-1 || fTDCchannel==-1 |
945 | || fSector==-1 || fPlate==-1 || fStrip==-1)) | |
946 | { | |
947 | Int_t iPadAlongTheStrip = Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel); | |
948 | if (iPadAlongTheStrip!=-1) | |
949 | iPadX = (Int_t)(iPadAlongTheStrip/(Float_t(AliTOFGeometry::NpadZ()))); | |
950 | } | |
951 | ||
38f24f3f | 952 | //iPadX = (Int_t)(Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel)/(Float_t(AliTOFGeometry::NpadZ()))); |
953 | //iPadX = Equip2VolNpadX(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel); | |
954 | ||
d0eb8f39 | 955 | fPadX = iPadX; |
571dda3d | 956 | |
957 | } | |
571dda3d | 958 | |
d0eb8f39 | 959 | //---------------------------------------------------------------------------- |
960 | Int_t AliTOFRawStream::GetField(UInt_t word, Int_t fieldMask, Int_t fieldPosition) const | |
961 | { | |
962 | // | |
963 | // | |
964 | // | |
965 | ||
966 | return ((word & fieldMask) >> fieldPosition); | |
967 | } | |
968 | ||
969 | //---------------------------------------------------------------------------- | |
13d6bff9 | 970 | Int_t AliTOFRawStream::Equip2VolNplate(Int_t iDDL, Int_t nTRM, Int_t nTDC) |
571dda3d | 971 | { |
972 | // | |
d0eb8f39 | 973 | // Returns the TOF plate number [0;4] |
974 | // corresponding to the TOF equipment ID numbers: | |
975 | // iDDL -> DDL number per sector [0;3] | |
976 | // nTRM -> TRM number [3;12] | |
977 | // nTDC -> TDC number [0;14] | |
571dda3d | 978 | // |
979 | ||
d0eb8f39 | 980 | Int_t iPlate = -1; |
5f72a2bf | 981 | |
d0eb8f39 | 982 | if (iDDL==0) { |
983 | ||
984 | if (nTRM>=4 && nTRM<7) { | |
985 | iPlate = 0; | |
986 | } else if (nTRM==7) { | |
987 | if (nTDC<12) iPlate = 0; | |
988 | else iPlate = 1; | |
989 | } else if (nTRM>=8 && nTRM<11) { | |
990 | iPlate = 1; | |
991 | } else if (nTRM==11) { | |
992 | if (nTDC<9) iPlate = 1; | |
993 | else iPlate = 2; | |
994 | }else if (nTRM==12) { | |
995 | iPlate = 2; | |
996 | } | |
997 | ||
998 | } else if (iDDL==1) { | |
999 | ||
1000 | if (nTRM==3) { | |
1001 | if (nTDC<3) iPlate = 0; | |
1002 | } else if (nTRM>=4 && nTRM<7) { | |
1003 | iPlate = 0; | |
1004 | } else if (nTRM==7) { | |
1005 | if (nTDC<6) iPlate = 1; | |
1006 | else iPlate = 0; | |
1007 | } else if (nTRM>=8 && nTRM<11) { | |
1008 | iPlate = 1; | |
1009 | } else if (nTRM==11) { | |
1010 | if (nTDC<9) iPlate = 2; | |
1011 | else iPlate = 1; | |
1012 | } else if (nTRM==12) { | |
1013 | iPlate = 2; | |
1014 | } | |
1015 | ||
1016 | } else if (iDDL==2) { | |
1017 | ||
1018 | if (nTRM>=4 && nTRM<7) { | |
1019 | iPlate = 4; | |
1020 | } else if (nTRM==7) { | |
1021 | if (nTDC<12) iPlate = 4; | |
1022 | else iPlate = 3; | |
1023 | } else if (nTRM>=8 && nTRM<11) { | |
1024 | iPlate = 3; | |
1025 | } else if (nTRM==11) { | |
1026 | if (nTDC<9) iPlate = 3; | |
1027 | else iPlate = 2; | |
1028 | }else if (nTRM==12) { | |
1029 | iPlate = 2; | |
1030 | } | |
1031 | ||
1032 | } else if (iDDL==3) { | |
1033 | ||
1034 | if (nTRM==3) { | |
1035 | if (nTDC<3) iPlate = 4; | |
1036 | } else if (nTRM>=4 && nTRM<7) { | |
1037 | iPlate = 4; | |
1038 | } else if (nTRM==7) { | |
1039 | if (nTDC<6) iPlate = 3; | |
1040 | else iPlate = 4; | |
1041 | } else if (nTRM>=8 && nTRM<11) { | |
1042 | iPlate = 3; | |
1043 | } else if (nTRM==11) { | |
1044 | if (nTDC<9) iPlate = 2; | |
1045 | else iPlate = 3; | |
1046 | } else if (nTRM==12) { | |
1047 | iPlate = 2; | |
1048 | } | |
571dda3d | 1049 | |
d0eb8f39 | 1050 | } |
571dda3d | 1051 | |
d0eb8f39 | 1052 | return iPlate; |
571dda3d | 1053 | |
d0eb8f39 | 1054 | } |
571dda3d | 1055 | |
d0eb8f39 | 1056 | //---------------------------------------------------------------------------- |
13d6bff9 | 1057 | Int_t AliTOFRawStream::Equip2VolNstrip(Int_t iDDL, Int_t nTRM, Int_t nTDC) |
d0eb8f39 | 1058 | { |
1059 | // | |
1060 | // Returns the TOF strip number per module: | |
1061 | // [0;14], in the central plates, | |
1062 | // [0;18], in the intermediate and external plates | |
1063 | // corresponding to the TOF equipment ID numbers: | |
1064 | // iDDL -> DDL number per sector [0;3] | |
1065 | // nTRM -> TRM number [3;12] | |
1066 | // nTDC -> TDC number [0;14] | |
1067 | // | |
571dda3d | 1068 | |
d0eb8f39 | 1069 | Int_t iStrip = -1; |
571dda3d | 1070 | |
d0eb8f39 | 1071 | if (iDDL==0) { |
1072 | ||
1073 | if (nTRM== 4) iStrip = (Int_t)(nTDC/3.); | |
1074 | else if (nTRM== 5) iStrip = 5 + (Int_t)(nTDC/3.); | |
1075 | else if (nTRM== 6) iStrip = 10 + (Int_t)(nTDC/3.); | |
1076 | else if (nTRM== 7) { | |
1077 | if (nTDC<12) iStrip = 15 + (Int_t)(nTDC/3.); | |
1078 | else iStrip = (Int_t)(nTDC/3.) - 4; | |
1079 | } | |
1080 | else if (nTRM== 8) iStrip = 1 + (Int_t)(nTDC/3.); | |
1081 | else if (nTRM== 9) iStrip = 6 + (Int_t)(nTDC/3.); | |
1082 | else if (nTRM==10) iStrip = 11 + (Int_t)(nTDC/3.); | |
1083 | else if (nTRM==11) { | |
1084 | if (nTDC<9) iStrip = 16 + (Int_t)(nTDC/3.); | |
1085 | else iStrip = (Int_t)(nTDC/3.) - 3; | |
1086 | } | |
1087 | else if (nTRM==12) iStrip = 2 + (Int_t)(nTDC/3.); | |
1088 | ||
1089 | } else if (iDDL==1) { | |
1090 | ||
1091 | if (nTRM==3 && nTDC<3) iStrip = (Int_t)(nTDC/3.); | |
1092 | else if (nTRM== 4) iStrip = 5 - (Int_t)(nTDC/3.); | |
1093 | else if (nTRM== 5) iStrip = 10 - (Int_t)(nTDC/3.); | |
1094 | else if (nTRM== 6) iStrip = 15 - (Int_t)(nTDC/3.); | |
1095 | else if (nTRM== 7) { | |
1096 | if (nTDC<6) iStrip = 1 - (Int_t)(nTDC/3.); | |
1097 | else iStrip = 20 - (Int_t)(nTDC/3.); | |
1098 | } | |
1099 | else if (nTRM== 8) iStrip = 6 - (Int_t)(nTDC/3.); | |
1100 | else if (nTRM== 9) iStrip = 11 - (Int_t)(nTDC/3.); | |
1101 | else if (nTRM==10) iStrip = 16 - (Int_t)(nTDC/3.); | |
1102 | else if (nTRM==11) { | |
1103 | if (nTDC<9) iStrip = 2 - (Int_t)(nTDC/3.); | |
1104 | else iStrip = 21 - (Int_t)(nTDC/3.); | |
1105 | } | |
1106 | else if (nTRM==12) iStrip = 7 - (Int_t)(nTDC/3.); | |
1107 | ||
1108 | } else if (iDDL==2) { | |
1109 | ||
1110 | if (nTRM== 4) iStrip = 18 - (Int_t)(nTDC/3.); | |
1111 | else if (nTRM== 5) iStrip = 18 - ( 5 + (Int_t)(nTDC/3.)); | |
1112 | else if (nTRM== 6) iStrip = 18 - (10 + (Int_t)(nTDC/3.)); | |
1113 | else if (nTRM== 7) { | |
1114 | if (nTDC<12) iStrip = 18 - (15 + (Int_t)(nTDC/3.)); | |
1115 | else iStrip = 18 - ((Int_t)(nTDC/3.) - 4); | |
1116 | } | |
1117 | else if (nTRM== 8) iStrip = 18 - ( 1 + (Int_t)(nTDC/3.)); | |
1118 | else if (nTRM== 9) iStrip = 18 - ( 6 + (Int_t)(nTDC/3.)); | |
1119 | else if (nTRM==10) iStrip = 18 - (11 + (Int_t)(nTDC/3.)); | |
1120 | else if (nTRM==11) { | |
1121 | if (nTDC<9) iStrip = 18 - (16 + (Int_t)(nTDC/3.)); | |
1122 | else iStrip = 14 - ((Int_t)(nTDC/3.) - 3); | |
1123 | } | |
1124 | else if (nTRM==12) iStrip = 14 - ( 2 + (Int_t)(nTDC/3.)); | |
1125 | ||
1126 | } else if (iDDL==3) { | |
1127 | ||
1128 | if (nTRM==3 && nTDC<3) iStrip = 18 - (Int_t)(nTDC/3.); | |
1129 | else if (nTRM== 4) iStrip = 18 - ( 5 - (Int_t)(nTDC/3.)); | |
1130 | else if (nTRM== 5) iStrip = 18 - (10 - (Int_t)(nTDC/3.)); | |
1131 | else if (nTRM== 6) iStrip = 18 - (15 - (Int_t)(nTDC/3.)); | |
1132 | else if (nTRM== 7) { | |
1133 | if (nTDC<6) iStrip = 18 - (1 - (Int_t)(nTDC/3.)); | |
1134 | else iStrip = 18 - (20 - (Int_t)(nTDC/3.)); | |
1135 | } | |
1136 | else if (nTRM== 8) iStrip = 18 - ( 6 - (Int_t)(nTDC/3.)); | |
1137 | else if (nTRM== 9) iStrip = 18 - (11 - (Int_t)(nTDC/3.)); | |
1138 | else if (nTRM==10) iStrip = 18 - (16 - (Int_t)(nTDC/3.)); | |
1139 | else if (nTRM==11) { | |
1140 | if (nTDC<9) iStrip = 14 - ( 2 - (Int_t)(nTDC/3.)); | |
1141 | else iStrip = 18 - (21 - (Int_t)(nTDC/3.)); | |
1142 | } | |
1143 | else if (nTRM==12) iStrip = 14 - ( 7 - (Int_t)(nTDC/3.)); | |
1144 | ||
1145 | } | |
1146 | ||
1147 | return iStrip; | |
1148 | ||
1149 | } | |
1150 | ||
1151 | //---------------------------------------------------------------------------- | |
1152 | Int_t AliTOFRawStream::Equip2VolNpad(Int_t iDDL, Int_t iChain, Int_t nTDC, | |
13d6bff9 | 1153 | Int_t iCH) |
d0eb8f39 | 1154 | { |
1155 | // | |
1156 | // Returns the TOF pad number per strip [0;95] | |
1157 | // corresponding to the TOF equipment ID numbers: | |
1158 | // iDDL -> DDL number per sector [0;3] | |
1159 | // iChain -> TRM chain number [0;1] | |
1160 | // nTDC -> TDC number [0;14] | |
1161 | // iCH -> TDC channel number [0;7] | |
1162 | // | |
1163 | ||
1164 | Int_t iPadAlongTheStrip = -1; | |
1165 | ||
38f24f3f | 1166 | // wrong |
1167 | //Int_t iTDClocal = nTDC%3 + (1-iChain)*3; | |
1168 | //if (iDDL==0 || iDDL==3) iTDClocal = 5 - iTDClocal; | |
1169 | //else if (iDDL==1 || iDDL==2) iTDClocal = 6 + (5 - iTDClocal); | |
d0eb8f39 | 1170 | |
38f24f3f | 1171 | // right |
1172 | Int_t iTDClocal = -1; | |
1173 | Int_t iTDClocal03 = nTDC%3 + (1-iChain)*3; | |
1174 | Int_t iTDClocal12 = 2-nTDC%3 + iChain*3; | |
1175 | if (iDDL==0 || iDDL==3) iTDClocal = 5 - iTDClocal03; | |
1176 | else if (iDDL==1 || iDDL==2) iTDClocal = 6 + (5 - iTDClocal12); | |
d0eb8f39 | 1177 | |
1178 | Int_t iCHlocal = iCH; | |
1179 | if (iDDL==0 || iDDL==3) iCHlocal = 7 - iCH; | |
1180 | ||
1181 | iPadAlongTheStrip = iTDClocal*AliTOFGeometry::NCh() + iCHlocal; | |
1182 | ||
1183 | if (((iDDL==1 || iDDL==2) && iPadAlongTheStrip< AliTOFGeometry::NpadX()) || | |
019f6101 | 1184 | ((iDDL==0 || iDDL==3) && iPadAlongTheStrip>=AliTOFGeometry::NpadX())) { |
13d6bff9 | 1185 | std::cerr << "Problems with the padX number!" << endl; |
1186 | //AliWarning("Problems with the padX number!"); | |
019f6101 | 1187 | } |
d0eb8f39 | 1188 | return iPadAlongTheStrip; |
1189 | ||
1190 | } | |
1191 | ||
38f24f3f | 1192 | //---------------------------------------------------------------------------- |
1193 | Int_t AliTOFRawStream::Equip2VolNpadX(Int_t iDDL, Int_t iChain, Int_t nTDC, | |
1194 | Int_t iCH) | |
1195 | { | |
1196 | // | |
1197 | // Returns the TOF padX number [0;47] | |
1198 | // corresponding to the TOF equipment ID numbers: | |
1199 | // iDDL -> DDL number per sector [0;3] | |
1200 | // iChain -> TRM chain number [0;1] | |
1201 | // nTDC -> TDC number [0;14] | |
1202 | // iCH -> TDC channel number [0;7] | |
1203 | // | |
1204 | ||
1205 | Int_t iPadX = (Int_t)(AliTOFRawStream::Equip2VolNpad(iDDL, iChain, nTDC, iCH)/ | |
1206 | (Float_t(AliTOFGeometry::NpadZ()))); | |
1207 | ||
1208 | return iPadX; | |
1209 | ||
1210 | } | |
1211 | ||
1212 | //---------------------------------------------------------------------------- | |
1213 | Int_t AliTOFRawStream::Equip2VolNpadZ(Int_t iDDL, Int_t iChain, Int_t nTDC, | |
1214 | Int_t iCH) | |
1215 | { | |
1216 | // | |
1217 | // Returns the TOF padZ number [0;1] | |
1218 | // corresponding to the TOF equipment ID numbers: | |
1219 | // iDDL -> DDL number per sector [0;3] | |
1220 | // iChain -> TRM chain number [0;1] | |
1221 | // nTDC -> TDC number [0;14] | |
1222 | // iCH -> TDC channel number [0;7] | |
1223 | // | |
1224 | ||
1225 | Int_t iPadZ = AliTOFRawStream::Equip2VolNpad(iDDL, iChain, nTDC, iCH)%AliTOFGeometry::NpadZ(); | |
1226 | ||
1227 | return iPadZ; | |
1228 | ||
1229 | } | |
1230 | ||
d0eb8f39 | 1231 | //---------------------------------------------------------------------------- |
5f72a2bf | 1232 | Int_t AliTOFRawStream::GetSectorNumber(Int_t nDDL) |
d0eb8f39 | 1233 | { |
1234 | // | |
1235 | // Returns the sector number [0;17] | |
1236 | // corresponing to the assigned DRM/DDL number [0;71] | |
1237 | // | |
1238 | ||
1239 | Int_t iSector = Int_t((Float_t)(nDDL)/AliTOFGeometry::NDDL()); | |
1240 | ||
1241 | return iSector; | |
1242 | ||
1243 | } | |
1244 | //---------------------------------------------------------------------------- | |
5f72a2bf | 1245 | Int_t AliTOFRawStream::GetDDLnumberPerSector(Int_t nDDL) |
d0eb8f39 | 1246 | { |
1247 | // | |
1248 | // Return the DRM/DDL number per sector [0;3] | |
1249 | // corresponing to the assigned DRM/DDL number [0;71] | |
1250 | // | |
1251 | ||
1252 | Int_t iDDL = nDDL%AliTOFGeometry::NDDL(); | |
1253 | ||
1254 | return iDDL; | |
1255 | ||
1256 | } | |
1257 | ||
7813bb1a | 1258 | //---------------------------------------------------------------------------- |
1259 | void AliTOFRawStream::EquipmentId2VolumeId(AliTOFHitData *hitData, Int_t *volume) const | |
1260 | { | |
1261 | EquipmentId2VolumeId(hitData->GetDDLID(),hitData->GetSlotID(),hitData->GetChain(),hitData->GetTDC(),hitData->GetChan(),volume); | |
1262 | } | |
d0eb8f39 | 1263 | //---------------------------------------------------------------------------- |
1264 | void AliTOFRawStream::EquipmentId2VolumeId(Int_t nDDL, Int_t nTRM, Int_t iChain, | |
1265 | Int_t nTDC, Int_t iCH, | |
1266 | Int_t *volume) const | |
1267 | { | |
1268 | // | |
1269 | // To convert: | |
1270 | // nDDL (variable in [0;71]) -> number of the DDL file | |
1271 | // nTRM (variable in [3;12]) -> number of the TRM slot | |
1272 | // iChain (variable in [0; 1]) -> number of the TRM chain | |
1273 | // nTDC (variable in [0;14]) -> number of the TDC | |
1274 | // iCH (variable in [0; 7]) -> number of the TDC channel | |
1275 | // | |
1276 | // in: | |
1277 | // sector number, i.e. volume[0] (variable in [0,17]) | |
1278 | // plate number, i.e. volume[1] (variable in [0, 5]) | |
1279 | // strip number, i.e. volume[2] (variable in [0,14/18]) | |
1280 | // padX number, i.e. volume[3] (variable in [0,47]) | |
1281 | // padZ number, i.e. volume[4] (variable in [0, 1]) | |
1282 | // | |
1283 | ||
1284 | Int_t iDDL = GetDDLnumberPerSector(nDDL); | |
1285 | ||
1286 | Int_t iSector = GetSectorNumber(nDDL); | |
1287 | ||
1288 | Int_t iPlate = Equip2VolNplate(iDDL, nTRM, nTDC); | |
019f6101 | 1289 | if (iPlate==-1) { |
13d6bff9 | 1290 | if (fRawReader) |
1291 | fRawReader->AddMajorErrorLog(kPlateError,"plate = -1"); | |
019f6101 | 1292 | AliWarning("Problems with the plate number!"); |
1293 | } | |
d0eb8f39 | 1294 | |
1295 | Int_t iStrip = Equip2VolNstrip(iDDL, nTRM, nTDC); | |
019f6101 | 1296 | if (iStrip==-1) { |
13d6bff9 | 1297 | if (fRawReader) |
1298 | fRawReader->AddMajorErrorLog(kStripError,"strip = -1"); | |
019f6101 | 1299 | AliWarning("Problems with the strip number!"); |
1300 | } | |
d0eb8f39 | 1301 | |
1302 | Int_t iPadAlongTheStrip = Equip2VolNpad(iDDL, iChain, nTDC, iCH); | |
019f6101 | 1303 | if (iPadAlongTheStrip==-1){ |
13d6bff9 | 1304 | if (fRawReader) |
1305 | fRawReader->AddMajorErrorLog(kPadAlongStripError,"pad = -1"); | |
019f6101 | 1306 | AliWarning("Problems with the pad number along the strip!"); |
1307 | } | |
13d6bff9 | 1308 | |
d0eb8f39 | 1309 | Int_t iPadX = (Int_t)(iPadAlongTheStrip/(Float_t(AliTOFGeometry::NpadZ()))); |
1310 | Int_t iPadZ = iPadAlongTheStrip%AliTOFGeometry::NpadZ(); | |
38f24f3f | 1311 | |
1312 | //Int_t iPadX = (Int_t)(Equip2VolNpad(iDDL, iChain, nTDC, iCH)/(Float_t(AliTOFGeometry::NpadZ()))); | |
1313 | //Int_t iPadZ = Equip2VolNpad(iDDL, iChain, nTDC, iCH)%AliTOFGeometry::NpadZ(); | |
1314 | ||
1315 | //Int_t iPadX = Equip2VolNpadX(iDDL, iChain, nTDC, iCH); | |
1316 | //Int_t iPadZ = Equip2VolNpadZ(iDDL, iChain, nTDC, iCH); | |
1317 | ||
d0eb8f39 | 1318 | volume[0] = iSector; |
1319 | volume[1] = iPlate; | |
1320 | volume[2] = iStrip; | |
1321 | volume[3] = iPadX; | |
1322 | volume[4] = iPadZ; | |
571dda3d | 1323 | |
1324 | } | |
7813bb1a | 1325 | //----------------------------------------------------------------------------- |
019f6101 | 1326 | Bool_t AliTOFRawStream::DecodeDDL(Int_t nDDLMin, Int_t nDDLMax, Int_t verbose = 0) { |
1327 | // | |
1328 | // To decode raw data for DDL number in [nDDLmin; nDDLmax] | |
1329 | // | |
1330 | ||
7813bb1a | 1331 | //check and fix valid DDL range |
019f6101 | 1332 | if (nDDLMin < 0){ |
1333 | nDDLMin = 0; | |
1334 | fRawReader->AddMinorErrorLog(kDDLMinError); | |
1335 | AliWarning("Wrong DDL range: setting first DDL ID to 0"); | |
7813bb1a | 1336 | } |
019f6101 | 1337 | if (nDDLMax > 71){ |
1338 | nDDLMax = 71; | |
1339 | fRawReader->AddMinorErrorLog(kDDLMaxError); | |
1340 | AliWarning("Wrong DDL range: setting last DDL ID to 71"); | |
7813bb1a | 1341 | } |
1342 | ||
1343 | //select required DDLs | |
019f6101 | 1344 | fRawReader->Select("TOF", nDDLMin, nDDLMax); |
7813bb1a | 1345 | |
1346 | if (verbose) | |
019f6101 | 1347 | AliInfo(Form("Selected TOF DDL range: %d-%d", nDDLMin, nDDLMax)); |
7813bb1a | 1348 | |
2fd622fa | 1349 | return(Decode(verbose)); |
1350 | } | |
1351 | //----------------------------------------------------------------------------- | |
019f6101 | 1352 | Bool_t AliTOFRawStream::Decode(Int_t verbose = 0) { |
1353 | // | |
1354 | // New decoder method | |
1355 | // | |
1356 | ||
2fd622fa | 1357 | Int_t currentEquipment; |
1358 | Int_t currentDDL; | |
dd824655 | 1359 | const AliRawDataHeader *currentCDH; |
2fd622fa | 1360 | |
1361 | //pointers | |
1362 | UChar_t *data = 0x0; | |
1363 | ||
7813bb1a | 1364 | //loop and read DDL headers |
1365 | while(fRawReader->ReadHeader()){ | |
1366 | ||
1367 | //memory leak prevention (actually data should be always 0x0 here) | |
1368 | if (data != 0x0) | |
1369 | delete [] data; | |
1370 | ||
1371 | //get equipment infos | |
1372 | currentEquipment = fRawReader->GetEquipmentId(); | |
1373 | currentDDL = fRawReader->GetDDLID(); | |
dd824655 | 1374 | currentCDH = fRawReader->GetDataHeader(); |
7813bb1a | 1375 | const Int_t kDataSize = fRawReader->GetDataSize(); |
1376 | const Int_t kDataWords = kDataSize / 4; | |
1377 | data = new UChar_t[kDataSize]; | |
1378 | ||
1379 | if (verbose) | |
1380 | AliInfo(Form("Found equipment # %d header (DDL # %d): %d bytes (%d words)", currentEquipment, currentDDL, kDataSize, kDataWords)); | |
1381 | ||
1382 | if (verbose) | |
1383 | AliInfo(Form("Reading equipment #%d (DDL # %d) data...", currentEquipment, currentDDL)); | |
1384 | ||
1385 | //read equipment payload | |
1386 | if (!fRawReader->ReadNext(data, kDataSize)) | |
1387 | { | |
019f6101 | 1388 | fRawReader->AddMajorErrorLog(kDDLdataReading); |
7813bb1a | 1389 | if (verbose) |
019f6101 | 1390 | AliWarning("Error while reading DDL data. Go to next equipment"); |
7813bb1a | 1391 | delete [] data; |
1392 | data = 0x0; | |
1393 | continue; | |
1394 | } | |
1395 | ||
1396 | if (verbose) | |
1397 | AliInfo(Form("Equipment # %d (DDL # %d) data has been readed", currentEquipment, currentDDL)); | |
1398 | ||
1399 | ||
1400 | //set up the decoder | |
1401 | fDecoder->SetVerbose(verbose); | |
d35d0ea0 | 1402 | fDecoder->SetDataBuffer(&fDataBuffer[currentDDL]); |
1403 | fDecoder->SetPackedDataBuffer(&fPackedDataBuffer[currentDDL]); | |
7813bb1a | 1404 | |
1405 | //start decoding | |
dd824655 | 1406 | if (fDecoder->Decode((UInt_t *)data, kDataWords, currentCDH) == kTRUE) { |
019f6101 | 1407 | fRawReader->AddMajorErrorLog(kDDLDecoder,Form("DDL # = %d",currentDDL)); |
1408 | AliWarning(Form("Error while decoding DDL # %d: decoder returned with errors", currentDDL)); | |
1409 | } | |
7813bb1a | 1410 | |
1411 | delete [] data; | |
1412 | data = 0x0; | |
1413 | } | |
1414 | ||
1415 | //reset reader | |
1416 | fRawReader->Reset(); | |
1417 | ||
1418 | if (verbose) | |
1419 | AliInfo("All done"); | |
1420 | ||
1421 | return kFALSE; | |
1422 | ||
1423 | } | |
1424 | //--------------------------------------------------------------------------- | |
1425 | void | |
1426 | AliTOFRawStream::ResetBuffers() | |
1427 | { | |
19eefa2b | 1428 | // |
1429 | // To reset the buffers | |
1430 | // | |
1431 | ||
7813bb1a | 1432 | for (Int_t iDDL = 0; iDDL < AliDAQ::NumberOfDdls("TOF"); iDDL++){ |
1433 | ResetDataBuffer(iDDL); | |
1434 | ResetPackedDataBuffer(iDDL); | |
1435 | } | |
1436 | } | |
1437 | ||
1438 | //--------------------------------------------------------------------------- | |
1439 | Bool_t | |
1440 | AliTOFRawStream::LoadRawDataBuffers(Int_t indexDDL, Int_t verbose) | |
1441 | { | |
19eefa2b | 1442 | // |
1443 | // To load the buffers | |
1444 | // | |
1445 | ||
7813bb1a | 1446 | fTOFrawData->Clear(); |
1447 | fPackedDigits = 0; | |
1448 | ||
1449 | if (verbose > 0) | |
1450 | AliInfo(Form("Decoding raw data for DDL # %d ...", indexDDL)); | |
1451 | ||
1452 | if (DecodeDDL(indexDDL, indexDDL, verbose) != 0){ //decode DDL | |
019f6101 | 1453 | fRawReader->AddMajorErrorLog(kDDLDecoder,Form("DDL # = %d",indexDDL)); |
1454 | AliWarning(Form("Error while decoding DDL # %d", indexDDL)); | |
7813bb1a | 1455 | return kTRUE; |
1456 | } | |
1457 | ||
1458 | if (verbose > 0) | |
d35d0ea0 | 1459 | AliInfo(Form("Done. %d packed %s been found.", fPackedDataBuffer[indexDDL].GetEntries(), fPackedDataBuffer[indexDDL].GetEntries() > 1 ? "hits have" : "hit has")); |
7813bb1a | 1460 | |
1461 | AliTOFHitData *hitData; //hit data pointer | |
1462 | ||
1463 | if (verbose > 0) | |
1464 | AliInfo("Filling TClonesArray ..."); | |
1465 | ||
dd824655 | 1466 | if (verbose > 0) |
1467 | if (fgApplyBCCorrections) { | |
1468 | AliInfo("Apply nominal DDL BC time-shift correction"); | |
1469 | AliInfo("Apply deltaBC time-shift correction"); | |
1470 | } | |
1471 | ||
7813bb1a | 1472 | //loop over DDL packed hits |
d35d0ea0 | 1473 | for (Int_t iHit = 0; iHit < fPackedDataBuffer[indexDDL].GetEntries(); iHit++){ |
1474 | hitData = fPackedDataBuffer[indexDDL].GetHit(iHit); //get hit data | |
7813bb1a | 1475 | Int_t hitACQ = hitData->GetACQ(); |
1476 | Int_t hitPS = hitData->GetPS(); | |
1477 | Int_t hitSlotID = hitData->GetSlotID(); | |
1478 | Int_t hitChain = hitData->GetChain(); | |
1479 | Int_t hitTDC = hitData->GetTDC(); | |
1480 | Int_t hitChan = hitData->GetChan(); | |
7813bb1a | 1481 | Int_t hitTimeBin = hitData->GetTimeBin(); |
7813bb1a | 1482 | Int_t hitTOTBin = hitData->GetTOTBin(); |
dd824655 | 1483 | |
1484 | if (fgApplyBCCorrections) { | |
1485 | /* DDL BC shift time correction */ | |
1486 | hitTimeBin += fgkddlBCshift[indexDDL]; | |
1487 | /* deltaBC shift time correction */ | |
1488 | hitTimeBin += hitData->GetDeltaBunchID(); | |
1489 | } | |
1490 | ||
1491 | Int_t hitLeading = hitData->GetTimeBin(); | |
bf33f8f0 | 1492 | Int_t hitTrailing = -1; |
1493 | Int_t hitError = -1; | |
7813bb1a | 1494 | |
1495 | TClonesArray &arrayTofRawData = *fTOFrawData; | |
bf33f8f0 | 1496 | new (arrayTofRawData[fPackedDigits++]) AliTOFrawData(hitSlotID, hitChain, hitTDC, hitChan, hitTimeBin, hitTOTBin, hitLeading, hitTrailing, hitPS, hitACQ, hitError); |
7813bb1a | 1497 | } |
1498 | ||
1499 | if (verbose > 0) | |
1500 | AliInfo("Done."); | |
1501 | ||
1502 | if (verbose > 0) | |
1503 | AliInfo("Resetting buffers ..."); | |
1504 | ||
d35d0ea0 | 1505 | fDataBuffer[indexDDL].Reset(); |
1506 | fPackedDataBuffer[indexDDL].Reset(); | |
7813bb1a | 1507 | |
1508 | if (verbose > 0) | |
1509 | AliInfo("Done."); | |
1510 | ||
1511 | return kFALSE; | |
1512 | } | |
1513 | ||
5f72a2bf | 1514 | //--------------------------------------------------------------------------- |
1515 | void AliTOFRawStream::Geant2EquipmentId(Int_t vol[], Int_t eqId[]) | |
1516 | { | |
1517 | // | |
1518 | // To convert: | |
1519 | // nSector number -vol[0]- (variable in [0,17]) | |
1520 | // nPlate number -vol[1]- (variable in [0, 5]) | |
1521 | // nStrip number -vol[2]- (variable in [0,14/18]) | |
1522 | // nPadZ number -vol[3]- (variable in [0, 1]) | |
1523 | // nPadX number -vol[4]- (variable in [0,47]) | |
1524 | // in: | |
1525 | // nDDL -eqId[0]- (variable in [0;71]) -> number of the DDL file | |
1526 | // nTRM -eqId[1]- (variable in [3;12]) -> number of the TRM file | |
1527 | // nTDC -eqId[2]- (variable in [0;14]) -> number of the TDC file | |
1528 | // nChain -eqId[3]- (variable in [0; 1]) -> number of the chain file | |
1529 | // nChannel -eqId[4]- (variable in [0; 8]) -> number of the channel file | |
1530 | // | |
1531 | ||
1532 | eqId[0] = Geant2DDL(vol); | |
1533 | eqId[1] = Geant2TRM(vol); | |
1534 | eqId[2] = Geant2TDC(vol); | |
1535 | eqId[3] = Geant2Chain(vol); | |
1536 | eqId[4] = Geant2Channel(vol); | |
1537 | ||
1538 | } | |
1539 | ||
1540 | //--------------------------------------------------------------------------- | |
1541 | Int_t AliTOFRawStream::Geant2DDL(Int_t vol[]) | |
1542 | { | |
1543 | // | |
1544 | // To convert: | |
1545 | // nSector number -vol[0]- (variable in [0,17]) | |
1546 | // nPlate number -vol[1]- (variable in [0, 5]) | |
1547 | // nStrip number -vol[2]- (variable in [0,14/18]) | |
1548 | // nPadZ number -vol[3]- (variable in [0, 1]) | |
1549 | // nPadX number -vol[4]- (variable in [0,47]) | |
1550 | // in: | |
1551 | // nDDL (variable in [0;71]) -> number of the DDL file | |
1552 | // | |
1553 | ||
1554 | ||
1555 | Int_t iDDL = -1; | |
1556 | ||
1557 | if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) { | |
1558 | printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]); | |
1559 | return iDDL; | |
1560 | } | |
1561 | if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) { | |
1562 | printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]); | |
1563 | return iDDL; | |
1564 | } | |
1565 | if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) { | |
1566 | printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1])); | |
1567 | return iDDL; | |
1568 | } | |
1569 | if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ()) | |
1570 | printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]); | |
1571 | if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX()) | |
1572 | printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]); | |
1573 | if ( vol[3]>=AliTOFGeometry::NpadZ() ) { | |
1574 | printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]); | |
1575 | return iDDL; | |
1576 | } | |
1577 | ||
1578 | Int_t nSector = vol[0]; | |
1579 | Int_t nPlate = vol[1]; | |
1580 | Int_t nStrip = vol[2]; | |
1581 | Int_t nPadX = vol[4]; | |
1582 | ||
1583 | if ( nPadX<24 && ( nPlate==0 || nPlate==1 || (nPlate==2 && nStrip<7) ) ) | |
1584 | iDDL = 0; | |
1585 | else if ( nPadX>=24 && ( nPlate==0 || nPlate==1 || (nPlate==2 && nStrip<8) ) ) | |
1586 | iDDL = 1; | |
1587 | else if ( nPadX>=24 && ( nPlate==3 || nPlate==4 || (nPlate==2 && nStrip>7) ) ) | |
1588 | iDDL = 2; | |
1589 | else if ( nPadX<24 && ( nPlate==3 || nPlate==4 || (nPlate==2 && nStrip>6) ) ) | |
1590 | iDDL = 3; | |
1591 | ||
1592 | return 4*nSector+iDDL; | |
1593 | ||
1594 | } | |
1595 | ||
1596 | //--------------------------------------------------------------------------- | |
1597 | Int_t AliTOFRawStream::Geant2TRM(Int_t vol[]) | |
1598 | { | |
1599 | // | |
1600 | // To convert: | |
1601 | // nSector number -vol[0]- (variable in [0,17]) | |
1602 | // nPlate number -vol[1]- (variable in [0, 5]) | |
1603 | // nStrip number -vol[2]- (variable in [0,14/18]) | |
1604 | // nPadZ number -vol[3]- (variable in [0, 1]) | |
1605 | // nPadX number -vol[4]- (variable in [0,47]) | |
1606 | // in: | |
1607 | // nTRM (variable in [3;12]) -> number of the TRM slot | |
1608 | // | |
1609 | ||
1610 | Int_t nTRM = -1; | |
1611 | ||
1612 | if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) { | |
1613 | printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]); | |
1614 | return nTRM; | |
1615 | } | |
1616 | if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) { | |
1617 | printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]); | |
1618 | return nTRM; | |
1619 | } | |
1620 | if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) { | |
1621 | printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1])); | |
1622 | return nTRM; | |
1623 | } | |
1624 | if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ()) { | |
1625 | printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]); | |
1626 | return nTRM; | |
1627 | } | |
1628 | if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX()) { | |
1629 | printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]); | |
1630 | return nTRM; | |
1631 | } | |
1632 | ||
1633 | if ( vol[3]>=AliTOFGeometry::NpadZ() ) | |
1634 | { | |
1635 | printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]); | |
1636 | return nTRM; | |
1637 | } | |
1638 | ||
1639 | Int_t nPlate = vol[1]; | |
1640 | Int_t nStrip = vol[2]; | |
1641 | ||
1642 | Int_t iDDL = Geant2DDL(vol)%4; | |
1643 | ||
1644 | switch (iDDL) { | |
1645 | ||
1646 | case 0: | |
1647 | ||
1648 | if (nPlate==0) { | |
1649 | if (nStrip<= 4) nTRM = 4; | |
1650 | else if (nStrip> 4 && nStrip<= 9) nTRM = 5; | |
1651 | else if (nStrip> 9 && nStrip<=14) nTRM = 6; | |
1652 | else if (nStrip>14) nTRM = 7; | |
1653 | } | |
1654 | else if (nPlate==1) { | |
1655 | if (nStrip== 0) nTRM = 7; | |
1656 | else if (nStrip> 0 && nStrip<= 5) nTRM = 8; | |
1657 | else if (nStrip> 5 && nStrip<=10) nTRM = 9; | |
1658 | else if (nStrip>10 && nStrip<=15) nTRM = 10; | |
1659 | else if (nStrip>15) nTRM = 11; | |
1660 | } | |
1661 | else if (nPlate==2) { | |
1662 | if (nStrip<= 1) nTRM = 11; | |
1663 | else if (nStrip> 1 && nStrip< 7) nTRM = 12; | |
1664 | } | |
1665 | ||
1666 | break; | |
1667 | case 1: | |
1668 | ||
1669 | if (nPlate==0) { | |
1670 | if (nStrip== 0) nTRM = 3; | |
1671 | else if (nStrip> 0 && nStrip<= 5) nTRM = 4; | |
1672 | else if (nStrip> 5 && nStrip<=10) nTRM = 5; | |
1673 | else if (nStrip>10 && nStrip<=15) nTRM = 6; | |
1674 | else if (nStrip>15) nTRM = 7; | |
1675 | } | |
1676 | else if (nPlate==1) { | |
1677 | if (nStrip<=1) nTRM = 7; | |
1678 | else if (nStrip> 1 && nStrip<= 6) nTRM = 8; | |
1679 | else if (nStrip> 6 && nStrip<=11) nTRM = 9; | |
1680 | else if (nStrip>11 && nStrip<=16) nTRM = 10; | |
1681 | else if (nStrip>16) nTRM = 11; | |
1682 | } | |
1683 | else if (nPlate==2) { | |
1684 | if (nStrip<= 2) nTRM = 11; | |
1685 | else if (nStrip> 2 && nStrip<= 7) nTRM = 12; | |
1686 | } | |
1687 | ||
1688 | break; | |
1689 | case 2: | |
1690 | ||
1691 | if (nPlate==4) { | |
1692 | if (nStrip>=14) nTRM = 4; | |
1693 | else if (nStrip<14 && nStrip>= 9) nTRM = 5; | |
1694 | else if (nStrip< 9 && nStrip>= 4) nTRM = 6; | |
1695 | else if (nStrip< 4) nTRM = 7; | |
1696 | } | |
1697 | else if (nPlate==3) { | |
1698 | if (nStrip==18) nTRM = 7; | |
1699 | else if (nStrip<18 && nStrip>=13) nTRM = 8; | |
1700 | else if (nStrip<13 && nStrip>= 8) nTRM = 9; | |
1701 | else if (nStrip< 8 && nStrip>= 3) nTRM = 10; | |
1702 | else if (nStrip< 3) nTRM = 11; | |
1703 | } | |
1704 | else if (nPlate==2) { | |
1705 | if (nStrip>=13) nTRM = 11; | |
1706 | else if (nStrip<13 && nStrip>= 8) nTRM = 12; | |
1707 | } | |
1708 | ||
1709 | break; | |
1710 | case 3: | |
1711 | ||
1712 | if (nPlate==4) { | |
1713 | if (nStrip==18) nTRM = 3; | |
1714 | else if (nStrip<18 && nStrip>=13) nTRM = 4; | |
1715 | else if (nStrip<13 && nStrip>= 8) nTRM = 5; | |
1716 | else if (nStrip< 8 && nStrip>= 3) nTRM = 6; | |
1717 | else if (nStrip< 3) nTRM = 7; | |
1718 | } | |
1719 | else if (nPlate==3) { | |
1720 | if (nStrip>=17) nTRM = 7; | |
1721 | else if (nStrip<17 && nStrip>=12) nTRM = 8; | |
1722 | else if (nStrip<12 && nStrip>= 7) nTRM = 9; | |
1723 | else if (nStrip< 7 && nStrip>= 2) nTRM = 10; | |
1724 | else if (nStrip< 2) nTRM = 11; | |
1725 | } | |
1726 | else if (nPlate==2) { | |
1727 | if (nStrip>=12) nTRM = 11; | |
1728 | else if (nStrip <12 && nStrip>= 7) nTRM = 12; | |
1729 | } | |
1730 | ||
1731 | break; | |
1732 | ||
1733 | } | |
1734 | ||
1735 | return nTRM; | |
1736 | ||
1737 | } | |
1738 | ||
1739 | //--------------------------------------------------------------------------- | |
1740 | Int_t AliTOFRawStream::Geant2TDC(Int_t vol[]) | |
1741 | { | |
1742 | // | |
1743 | // To convert: | |
1744 | // nSector number -vol[0]- (variable in [0,17]) | |
1745 | // nPlate number -vol[1]- (variable in [0, 5]) | |
1746 | // nStrip number -vol[2]- (variable in [0,14/18]) | |
1747 | // nPadZ number -vol[3]- (variable in [0, 1]) | |
1748 | // nPadX number -vol[4]- (variable in [0,47]) | |
1749 | // in: | |
1750 | // nTDC (variable in [0;14]) -> number of the TDC | |
1751 | // | |
1752 | ||
1753 | Int_t nTDC = -1; | |
1754 | ||
1755 | if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) { | |
1756 | printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]); | |
1757 | return nTDC; | |
1758 | } | |
1759 | if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) { | |
1760 | printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]); | |
1761 | return nTDC; | |
1762 | } | |
1763 | if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) { | |
1764 | printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1])); | |
1765 | return nTDC; | |
1766 | } | |
1767 | if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ()) | |
1768 | printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]); | |
1769 | if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX()) | |
1770 | printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]); | |
1771 | if ( vol[3]>=AliTOFGeometry::NpadZ() ) { | |
1772 | printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]); | |
1773 | return nTDC; | |
1774 | } | |
1775 | ||
1776 | Int_t nPlate = vol[1]; | |
1777 | Int_t nStrip = vol[2]; | |
1778 | Int_t iPadX = vol[4]; | |
1779 | ||
1780 | Int_t iDDL = Geant2DDL(vol)%4; | |
1781 | ||
1782 | switch (iDDL) { | |
1783 | ||
1784 | case 0: | |
1785 | ||
1786 | if (nPlate==0) { | |
1787 | if (nStrip<= 4) nTDC = (3*(nStrip)+2-(iPadX/4)%3); | |
1788 | else if (nStrip> 4 && nStrip<= 9) nTDC = (3*(nStrip- 5)+2-(iPadX/4)%3); | |
1789 | else if (nStrip> 9 && nStrip<=14) nTDC = (3*(nStrip-10)+2-(iPadX/4)%3); | |
1790 | else if (nStrip>14) nTDC = (3*(nStrip-15)+2-(iPadX/4)%3); | |
1791 | } | |
1792 | else if (nPlate==1) { | |
1793 | if (nStrip== 0) nTDC = (3*(nStrip+ 4)+2-(iPadX/4)%3); | |
1794 | else if (nStrip> 0 && nStrip<= 5) nTDC = (3*(nStrip- 1)+2-(iPadX/4)%3); | |
1795 | else if (nStrip> 5 && nStrip<=10) nTDC = (3*(nStrip- 6)+2-(iPadX/4)%3); | |
1796 | else if (nStrip>10 && nStrip<=15) nTDC = (3*(nStrip-11)+2-(iPadX/4)%3); | |
1797 | else if (nStrip>15) nTDC = (3*(nStrip-16)+2-(iPadX/4)%3); | |
1798 | } | |
1799 | else if (nPlate==2) { | |
1800 | if (nStrip<= 1) nTDC = (3*(nStrip+ 3)+2-(iPadX/4)%3); | |
1801 | else if (nStrip> 1 && nStrip< 7) nTDC = (3*(nStrip- 2)+2-(iPadX/4)%3); | |
1802 | } | |
1803 | ||
1804 | break; | |
1805 | case 1: | |
1806 | ||
1807 | if (nPlate==0) { | |
1808 | if (nStrip== 0) nTDC = (3*(nStrip)+(iPadX/4)%3); | |
1809 | else if (nStrip> 0 && nStrip<= 5) nTDC = (3*( 5-nStrip)+(iPadX/4)%3); | |
1810 | else if (nStrip> 5 && nStrip<=10) nTDC = (3*(10-nStrip)+(iPadX/4)%3); | |
1811 | else if (nStrip>10 && nStrip<=15) nTDC = (3*(15-nStrip)+(iPadX/4)%3); | |
1812 | else if (nStrip>15) nTDC = (3*(20-nStrip)+(iPadX/4)%3); | |
1813 | } | |
1814 | else if (nPlate==1) { | |
1815 | if (nStrip<= 1) nTDC = (3*( 1-nStrip)+(iPadX/4)%3); | |
1816 | else if (nStrip> 1 && nStrip<= 6) nTDC = (3*( 6-nStrip)+(iPadX/4)%3); | |
1817 | else if (nStrip> 6 && nStrip<=11) nTDC = (3*(11-nStrip)+(iPadX/4)%3); | |
1818 | else if (nStrip>11 && nStrip<=16) nTDC = (3*(16-nStrip)+(iPadX/4)%3); | |
1819 | else if (nStrip>16) nTDC = (3*(21-nStrip)+(iPadX/4)%3); | |
1820 | } | |
1821 | else if (nPlate==2) { | |
1822 | if (nStrip<= 2) nTDC = (3*( 2-nStrip)+(iPadX/4)%3); | |
1823 | else if (nStrip> 2 && nStrip<= 7) nTDC = (3*( 7-nStrip)+(iPadX/4)%3); | |
1824 | } | |
1825 | ||
1826 | break; | |
1827 | case 2: | |
1828 | ||
1829 | if (nPlate==4) { | |
1830 | if (nStrip>=14) nTDC = (3*(18-nStrip)+((iPadX/4)%3)); | |
1831 | else if (nStrip<14 && nStrip>= 9) nTDC = (3*(13-nStrip)+((iPadX/4)%3)); | |
1832 | else if (nStrip< 9 && nStrip>= 4) nTDC = (3*( 8-nStrip)+((iPadX/4)%3)); | |
1833 | else if (nStrip< 4) nTDC = (3*( 3-nStrip)+((iPadX/4)%3)); | |
1834 | } | |
1835 | else if (nPlate==3) { | |
1836 | if (nStrip==18) nTDC = (3*(22-nStrip)+((iPadX/4)%3)); | |
1837 | else if (nStrip<18 && nStrip>=13) nTDC = (3*(17-nStrip)+((iPadX/4)%3)); | |
1838 | else if (nStrip<13 && nStrip>= 8) nTDC = (3*(12-nStrip)+((iPadX/4)%3)); | |
1839 | else if (nStrip< 8 && nStrip>= 3) nTDC = (3*( 7-nStrip)+((iPadX/4)%3)); | |
1840 | else if (nStrip< 3) nTDC = (3*( 2-nStrip)+((iPadX/4)%3)); | |
1841 | } | |
1842 | else if (nPlate==2) { | |
1843 | if (nStrip>=13) nTDC = (3*(17-nStrip)+((iPadX/4)%3)); | |
1844 | else if (nStrip<13 && nStrip>= 8) nTDC = (3*(12-nStrip)+((iPadX/4)%3)); | |
1845 | } | |
1846 | ||
1847 | break; | |
1848 | case 3: | |
1849 | ||
1850 | if (nPlate==4) { | |
1851 | if (nStrip==18) nTDC = (3*(nStrip-18)+2-(iPadX/4)%3); | |
1852 | else if (nStrip<18 && nStrip>=13) nTDC = (3*(nStrip-13)+2-(iPadX/4)%3); | |
1853 | else if (nStrip<13 && nStrip>= 8) nTDC = (3*(nStrip- 8)+2-(iPadX/4)%3); | |
1854 | else if (nStrip< 8 && nStrip>= 3) nTDC = (3*(nStrip- 3)+2-(iPadX/4)%3); | |
1855 | else if (nStrip< 3) nTDC = (3*(nStrip+ 2)+2-(iPadX/4)%3); | |
1856 | } | |
1857 | else if (nPlate==3) { | |
1858 | if (nStrip>=17) nTDC = (3*(nStrip-17)+2-(iPadX/4)%3); | |
1859 | else if (nStrip<17 && nStrip>=12) nTDC = (3*(nStrip-12)+2-(iPadX/4)%3); | |
1860 | else if (nStrip<12 && nStrip>= 7) nTDC = (3*(nStrip- 7)+2-(iPadX/4)%3); | |
1861 | else if (nStrip< 7 && nStrip>= 2) nTDC = (3*(nStrip- 2)+2-(iPadX/4)%3); | |
1862 | else if (nStrip< 2) nTDC = (3*(nStrip+ 3)+2-(iPadX/4)%3); | |
1863 | } | |
1864 | else if (nPlate==2) { | |
1865 | if (nStrip>=12) nTDC = (3*(nStrip-12)+2-(iPadX/4)%3); | |
1866 | else if (nStrip <12 && nStrip>= 7) nTDC = (3*(nStrip- 7)+2-(iPadX/4)%3); | |
1867 | } | |
1868 | ||
1869 | break; | |
1870 | ||
1871 | } | |
1872 | ||
1873 | return nTDC; | |
1874 | ||
1875 | } | |
1876 | ||
1877 | //--------------------------------------------------------------------------- | |
1878 | Int_t AliTOFRawStream::Geant2Chain(Int_t vol[]) | |
1879 | { | |
1880 | // | |
1881 | // To convert: | |
1882 | // nSector number -vol[0]- (variable in [0,17]) | |
1883 | // nPlate number -vol[1]- (variable in [0, 5]) | |
1884 | // nStrip number -vol[2]- (variable in [0,14/18]) | |
1885 | // nPadZ number -vol[3]- (variable in [0, 1]) | |
1886 | // nPadX number -vol[4]- variable in [0,47]) | |
1887 | // in: | |
1888 | // nChain (variable in [0; 1]) -> number of the TRM chain | |
1889 | // | |
1890 | ||
1891 | Int_t nChain = -1; | |
1892 | ||
1893 | if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) { | |
1894 | printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]); | |
1895 | return nChain; | |
1896 | } | |
1897 | if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) { | |
1898 | printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]); | |
1899 | return nChain; | |
1900 | } | |
1901 | if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) { | |
1902 | printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1])); | |
1903 | return nChain; | |
1904 | } | |
1905 | if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ()) | |
1906 | printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]); | |
1907 | if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX()) | |
1908 | printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]); | |
1909 | if ( vol[3]>=AliTOFGeometry::NpadZ() ) { | |
1910 | printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]); | |
1911 | return nChain; | |
1912 | } | |
1913 | ||
1914 | Int_t iPadX = vol[4]; | |
1915 | ||
1916 | if (iPadX<12 || iPadX>=36) nChain = 0; | |
1917 | else nChain = 1; | |
1918 | ||
1919 | return nChain; | |
1920 | ||
1921 | } | |
1922 | ||
1923 | //--------------------------------------------------------------------------- | |
1924 | Int_t AliTOFRawStream::Geant2Channel(Int_t vol[]) | |
1925 | { | |
1926 | // | |
1927 | // To convert: | |
1928 | // nSector number -vol[0]- (variable in [0,17]) | |
1929 | // nPlate number -vol[1]- (variable in [0, 5]) | |
1930 | // nStrip number -vol[2]- (variable in [0,14/18]) | |
1931 | // nPadZ number -vol[3]- (variable in [0, 1]) | |
1932 | // nPadX number -vol[4]- (variable in [0,47]) | |
1933 | // in: | |
1934 | // nChannel (variable in [0; 7]) -> number of the TDC channel | |
1935 | // | |
1936 | ||
1937 | Int_t nChannel = -1; | |
1938 | ||
1939 | if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) { | |
1940 | printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]); | |
1941 | return nChannel; | |
1942 | } | |
1943 | if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) { | |
1944 | printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]); | |
1945 | return nChannel; | |
1946 | } | |
1947 | if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) { | |
1948 | printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1])); | |
1949 | return nChannel; | |
1950 | } | |
1951 | if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ()) | |
1952 | printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]); | |
1953 | if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX()) | |
1954 | printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]); | |
1955 | if ( vol[3]>=AliTOFGeometry::NpadZ() ) { | |
1956 | printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]); | |
1957 | return nChannel; | |
1958 | } | |
1959 | ||
1960 | Int_t iPadZ = vol[3]; | |
1961 | Int_t iPadX = vol[4]; | |
1962 | ||
1963 | Int_t iDDL = Geant2DDL(vol)%4; | |
1964 | ||
1965 | switch (iDDL) { | |
1966 | ||
1967 | case 0: | |
1968 | nChannel = ((2*(23-iPadX) + (1-iPadZ)))%8; | |
1969 | break; | |
1970 | case 1: | |
1971 | nChannel = ((2*(iPadX-24) + (iPadZ)))%8; | |
1972 | break; | |
1973 | case 2: | |
1974 | nChannel = ((2*(iPadX-24) + (iPadZ)))%8; | |
1975 | break; | |
1976 | case 3: | |
1977 | nChannel = ((2*(23-iPadX) + (1-iPadZ)))%8; | |
1978 | break; | |
1979 | } | |
1980 | ||
1981 | return nChannel; | |
1982 | ||
1983 | } |