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