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