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