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