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