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