AliTPCTransform.h - removing warning visible in
[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{
128 2, 2, -1, -1,
cfceaf15 129 2, 2, 0, 0,
32ead898 130 2, 2, 0, 0,
131 2, 2, 0, 0,
132 2, 2, 0, 0,
133 2, 2, 0, 0,
134 2, 2, 0, 0,
135 2, 2, 0, 0,
136 2, 2, 0, 0,
137 2, 2, 0, 0,
138 2, 2, -1, -1,
139 2, 2, -1, -1,
140 2, 2, -2, -2,
141 2, 2, -2, -2,
142 2, 2, -2, -2,
143 2, 2, -1, -1,
144 2, 2, -1, -1,
145 2, 2, -1, -1
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
ca6d7f17 214 fEventID = (Int_t)fRawReader->GetBCID(); //bunch crossing
215
571dda3d 216}
217
218//_____________________________________________________________________________
655e379f 219AliTOFRawStream::AliTOFRawStream():
2bf66a2d 220 fRawReader(0x0),
221 fTOFrawData(new TClonesArray("AliTOFrawData",1000)),
7813bb1a 222 fDecoder(new AliTOFDecoder()),
655e379f 223 fDDL(-1),
224 fTRM(-1),
655e379f 225 fTRMchain(-1),
15ec34b9 226 fTDC(-1),
655e379f 227 fTDCchannel(-1),
15ec34b9 228 fTime(-1),
655e379f 229 fToT(-1),
15ec34b9 230 fLeadingEdge(-1),
231 fTrailingEdge(-1),
655e379f 232 fErrorFlag(-1),
655e379f 233 fSector(-1),
234 fPlate(-1),
235 fStrip(-1),
236 fPadX(-1),
237 fPadZ(-1),
15ec34b9 238 fPackedDigits(0),
655e379f 239 fWordType(-1),
240 fSlotID(-1),
241 fACQ(-1),
242 fPSbit(-1),
655e379f 243 fTDCerrorFlag(-1),
244 fInsideDRM(kFALSE),
245 fInsideTRM(kFALSE),
246 fInsideLTM(kFALSE),
247 fInsideTRMchain0(kFALSE),
38f24f3f 248 fInsideTRMchain1(kFALSE),
5042b04a 249 //fDataBuffer(),
250 //fPackedDataBuffer(),
38f24f3f 251 fLocalEventCounterDRM(-1),
252 fLocalEventCounterLTM(-1),
5042b04a 253 //fLocalEventCounterTRM(),
254 //fLocalEventCounterChain(),
255 //fChainBunchID(),
04bacbd9 256 //fCableLengthMap(new AliTOFCableLengthMap()),
f472295e 257 fEventID(0),
258 fNewDecoderVersion(0)
571dda3d 259{
260 //
d0eb8f39 261 // default ctr
571dda3d 262 //
7813bb1a 263 for (Int_t i=0;i<AliDAQ::NumberOfDdls("TOF");i++){
d35d0ea0 264 ResetDataBuffer(i);
265 ResetPackedDataBuffer(i);
7813bb1a 266 }
15ec34b9 267
2bf66a2d 268 //fTOFrawData = new TClonesArray("AliTOFrawData",1000);
7813bb1a 269 fTOFrawData->SetOwner();
38f24f3f 270
ca6d7f17 271 for (Int_t j=0;j<13;j++){
272 fLocalEventCounterTRM[j] = -1;
ca6d7f17 273 for (Int_t k=0;k<2;k++){
274 fLocalEventCounterChain[j][k] = -1;
275 fChainBunchID[j][k] = -1;
276 }
277 }
38f24f3f 278
d0eb8f39 279}
280
281//_____________________________________________________________________________
282AliTOFRawStream::AliTOFRawStream(const AliTOFRawStream& stream) :
655e379f 283 TObject(stream),
8a190ba2 284 fRawReader(stream.fRawReader),
285 fTOFrawData(stream.fTOFrawData),
7813bb1a 286 fDecoder(new AliTOFDecoder()),
8a190ba2 287 fDDL(stream.fDDL),
288 fTRM(stream.fTRM),
289 fTRMchain(stream.fTRMchain),
290 fTDC(stream.fTDC),
291 fTDCchannel(stream.fTDCchannel),
292 fTime(stream.fTime),
293 fToT(-stream.fToT),
294 fLeadingEdge(stream.fLeadingEdge),
295 fTrailingEdge(stream.fTrailingEdge),
296 fErrorFlag(stream.fErrorFlag),
297 fSector(stream.fSector),
298 fPlate(stream.fPlate),
299 fStrip(stream.fStrip),
300 fPadX(stream.fPadX),
301 fPadZ(stream.fPadZ),
302 fPackedDigits(stream.fPackedDigits),
303 fWordType(stream.fWordType),
304 fSlotID(stream.fSlotID),
305 fACQ(stream.fACQ),
306 fPSbit(stream.fPSbit),
307 fTDCerrorFlag(stream.fTDCerrorFlag),
308 fInsideDRM(stream.fInsideDRM),
309 fInsideTRM(stream.fInsideTRM),
310 fInsideLTM(stream.fInsideLTM),
311 fInsideTRMchain0(stream.fInsideTRMchain0),
312 fInsideTRMchain1(stream.fInsideTRMchain1),
5042b04a 313 //fDataBuffer(),
314 //fPackedDataBuffer(),
8a190ba2 315 fLocalEventCounterDRM(stream.fLocalEventCounterDRM),
316 fLocalEventCounterLTM(stream.fLocalEventCounterLTM),
5042b04a 317 //fLocalEventCounterTRM(),
318 //fLocalEventCounterChain(),
319 //fChainBunchID(),
04bacbd9 320 //fCableLengthMap(stream.fCableLengthMap),
f472295e 321 fEventID(stream.fEventID),
322 fNewDecoderVersion(stream.fNewDecoderVersion)
d0eb8f39 323{
324 //
325 // copy constructor
326 //
327
7813bb1a 328 for (Int_t i=0;i<AliDAQ::NumberOfDdls("TOF");i++){
d35d0ea0 329 fDataBuffer[i] = stream.fDataBuffer[i];
330 fPackedDataBuffer[i] = stream.fPackedDataBuffer[i];
7813bb1a 331 }
332
333 fTOFrawData = new TClonesArray(*stream.fTOFrawData);
38f24f3f 334
ca6d7f17 335 for (Int_t j=0;j<13;j++){
336 fLocalEventCounterTRM[j] = stream.fLocalEventCounterTRM[j];
337 for (Int_t k=0;k<2;k++){
338 fLocalEventCounterChain[j][k] = stream.fLocalEventCounterChain[j][k];
339 fChainBunchID[j][k] = stream.fChainBunchID[j][k];
340 }
341 }
38f24f3f 342
571dda3d 343}
344
345//_____________________________________________________________________________
346AliTOFRawStream& AliTOFRawStream::operator = (const AliTOFRawStream& stream)
347{
348 //
349 // assignment operator
350 //
351
8a190ba2 352 if (this == &stream)
353 return *this;
354
355 TObject::operator=(stream);
356
571dda3d 357 fRawReader = stream.fRawReader;
15ec34b9 358
359 fTOFrawData = stream.fTOFrawData;
360
571dda3d 361 fDDL = stream.fDDL;
362 fTRM = stream.fTRM;
d0eb8f39 363 fTRMchain = stream.fTRMchain;
15ec34b9 364 fTDC = stream.fTDC;
d0eb8f39 365 fTDCchannel = stream.fTDCchannel;
15ec34b9 366 fTime = stream.fTime;
d0eb8f39 367 fToT = stream.fToT;
15ec34b9 368 fLeadingEdge = stream.fLeadingEdge;
369 fTrailingEdge = stream.fTrailingEdge;
571dda3d 370 fErrorFlag = stream.fErrorFlag;
d0eb8f39 371
372 fSector = stream.fSector;
373 fPlate = stream.fPlate;
374 fStrip = stream.fStrip;
375 fPadX = stream.fPadX;
376 fPadZ = stream.fPadZ;
571dda3d 377
15ec34b9 378 fPackedDigits = stream.fPackedDigits;
379
d0eb8f39 380 fWordType = stream.fWordType;
381 fSlotID = stream.fSlotID;
382 fACQ = stream.fACQ;
383 fPSbit = stream.fPSbit;
d0eb8f39 384 fTDCerrorFlag = stream.fTDCerrorFlag;
385 fInsideDRM = stream.fInsideDRM;
386 fInsideTRM = stream.fInsideTRM;
387 fInsideLTM = stream.fInsideLTM;
388 fInsideTRMchain0 = stream.fInsideTRMchain0;
389 fInsideTRMchain1 = stream.fInsideTRMchain1;
7813bb1a 390
391 for (Int_t i=0;i<AliDAQ::NumberOfDdls("TOF");i++){
392 fDataBuffer[i] = stream.fDataBuffer[i];
393 fPackedDataBuffer[i] = stream.fPackedDataBuffer[i];
394 }
395
396 fTOFrawData = stream.fTOFrawData;
38f24f3f 397
ca6d7f17 398 fLocalEventCounterDRM = stream.fLocalEventCounterDRM;
399 fLocalEventCounterLTM = stream.fLocalEventCounterLTM;
400 for (Int_t j=0;j<13;j++){
401 fLocalEventCounterTRM[j] = stream.fLocalEventCounterTRM[j];
402 for (Int_t k=0;k<2;k++){
403 fLocalEventCounterChain[j][k] = stream.fLocalEventCounterChain[j][k];
404 fChainBunchID[j][k] = stream.fChainBunchID[j][k];
405 }
406 }
38f24f3f 407
04bacbd9 408 //fCableLengthMap = stream.fCableLengthMap;
32ead898 409
410 fEventID = stream.fEventID;
f472295e 411 fNewDecoderVersion = stream.fNewDecoderVersion;
32ead898 412
571dda3d 413 return *this;
414
415}
416
417//_____________________________________________________________________________
418AliTOFRawStream::~AliTOFRawStream()
419{
420// destructor
421
15ec34b9 422 fPackedDigits = 0;
423
7813bb1a 424 delete fDecoder;
15ec34b9 425
7813bb1a 426 fTOFrawData->Clear();
427 delete fTOFrawData;
38f24f3f 428
04bacbd9 429 //delete fCableLengthMap;
38f24f3f 430
571dda3d 431}
432
433
434//_____________________________________________________________________________
15ec34b9 435
436void AliTOFRawStream::LoadRawData(Int_t indexDDL)
437{
0192b95f 438 //
439 // To load raw data
440 //
15ec34b9 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
521//_____________________________________________________________________________
571dda3d 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));
143cfc81 751 fTime +=
ca6d7f17 752 (Int_t)(fgkddlBCshift[fDDL]*25./AliTOFGeometry::TdcBinWidth()*1.E+03)
143cfc81 753 +
ca6d7f17 754 (Int_t)((fChainBunchID[fTRM][fTRMchain]-fEventID)*25./AliTOFGeometry::TdcBinWidth()*1.E+03);
143cfc81 755 }
d0eb8f39 756 break;
757
758 case 1: // leading edge digit, long digit time, no TOT
15ec34b9 759 //fToT = -1;
760 //fTime = -1;
32ead898 761 fLeadingEdge = GetField(data,TRM_LONG_DIGIT_TIME_MASK,TRM_LONG_DIGIT_TIME_POSITION)
cfceaf15 762 /*-
763 fCableLengthMap->GetCableTimeShiftBin(fDDL, fTRM, fTRMchain, fTDC)*/
32ead898 764 ;
143cfc81 765 if (fgApplyBCCorrections) {
ca6d7f17 766 AliDebug(2,"Apply nominal DDL BC time-shift correction");
767 AliDebug(2,"Apply deltaBC time-shift correction");
768 AliDebug(2,Form(" fChainBunchID[%d][%d] = %d ,fEventID = %d",fTRM,fTRMchain,fChainBunchID[fTRM][fTRMchain],fEventID));
143cfc81 769 fLeadingEdge +=
ca6d7f17 770 (Int_t)(fgkddlBCshift[fDDL]*25./AliTOFGeometry::TdcBinWidth()*1.E+03)
143cfc81 771 +
ca6d7f17 772 (Int_t)((fChainBunchID[fTRM][fTRMchain]-fEventID)*25./AliTOFGeometry::TdcBinWidth()*1.E+03);
143cfc81 773 }
d0eb8f39 774 break;
775
776 case 2: // trailing edge digit, long digit time, no TOT
15ec34b9 777 //fToT = -1;
778 //fTime = -1;
32ead898 779 fTrailingEdge = GetField(data,TRM_LONG_DIGIT_TIME_MASK,TRM_LONG_DIGIT_TIME_POSITION)
cfceaf15 780 /*-
781 fCableLengthMap->GetCableTimeShiftBin(fDDL, fTRM, fTRMchain, fTDC)*/
32ead898 782 ;
143cfc81 783 if (fgApplyBCCorrections) {
ca6d7f17 784 AliDebug(2,"Apply nominal DDL BC time-shift correction");
785 AliDebug(2,"Apply deltaBC time-shift correction");
786 AliDebug(2,Form(" fChainBunchID[%d][%d] = %d ,fEventID = %d",fTRM,fTRMchain,fChainBunchID[fTRM][fTRMchain],fEventID));
143cfc81 787 fTrailingEdge +=
ca6d7f17 788 (Int_t)(fgkddlBCshift[fDDL]*25./AliTOFGeometry::TdcBinWidth()*1.E+03)
143cfc81 789 +
ca6d7f17 790 (Int_t)((fChainBunchID[fTRM][fTRMchain]-fEventID)*25./AliTOFGeometry::TdcBinWidth()*1.E+03);
143cfc81 791 }
d0eb8f39 792 break;
15ec34b9 793
d0eb8f39 794 case 3: // TOT overflow
15ec34b9 795 fToT = GetField(data,TRM_TOT_WIDTH_MASK, TRM_TOT_WIDTH_POSITION);
32ead898 796 fTime = GetField(data,TRM_DIGIT_TIME_MASK,TRM_DIGIT_TIME_POSITION)
cfceaf15 797 /*-
798 fCableLengthMap->GetCableTimeShiftBin(fDDL, fTRM, fTRMchain, fTDC)*/
32ead898 799 ;
143cfc81 800 if (fgApplyBCCorrections) {
ca6d7f17 801 AliDebug(2,"Apply nominal DDL BC time-shift correction");
802 AliDebug(2,"Apply deltaBC time-shift correction");
803 AliDebug(2,Form(" fChainBunchID[%d][%d] = %d ,fEventID = %d",fTRM,fTRMchain,fChainBunchID[fTRM][fTRMchain],fEventID));
143cfc81 804 fTime +=
ca6d7f17 805 (Int_t)(fgkddlBCshift[fDDL]*25./AliTOFGeometry::TdcBinWidth()*1.E+03)
143cfc81 806 +
ca6d7f17 807 (Int_t)((fChainBunchID[fTRM][fTRMchain]-fEventID)*25./AliTOFGeometry::TdcBinWidth()*1.E+03);
143cfc81 808 }
d0eb8f39 809 break;
d0eb8f39 810
15ec34b9 811 } // end switch PS bits inside TRM chains
d0eb8f39 812
813 } // end if is inside TRM chains
814
815 } // end switch on fWordType
571dda3d 816
15ec34b9 817
571dda3d 818 return kTRUE;
7813bb1a 819
571dda3d 820}
821//_____________________________________________________________________________
822
d0eb8f39 823void AliTOFRawStream::SetSector()
571dda3d 824{
825 //
d0eb8f39 826 // Evaluate the TOF sector number -> [ 0;17]
827 // corresponding to the TOF equipment IDs:
828 // fDDL -> [ 0;71]
829 // fTRM -> [ 3;12]
15ec34b9 830 // fTRMchain -> [ 0; 1]
d0eb8f39 831 // fTDC -> [ 0;14]
832 // fTDCchannel -> [ 0; 7]
571dda3d 833 //
834
835 Int_t iSector = -1;
571dda3d 836
d0eb8f39 837 if (!(fDDL==-1)) iSector = Int_t((Float_t)(fDDL)/AliTOFGeometry::NDDL());
838
839 fSector = iSector;
571dda3d 840
841}
842//_____________________________________________________________________________
843
d0eb8f39 844
845void AliTOFRawStream::SetPlate()
571dda3d 846{
847 //
d0eb8f39 848 // Evaluate the TOF plate number ->[ 0; 4]
849 // corresponding to the TOF equipment IDs:
850 // fDDL -> [ 0;71]
851 // fTRM -> [ 3;12]
15ec34b9 852 // fTRMchain -> [ 0; 1]
d0eb8f39 853 // fTDC -> [ 0;14]
854 // fTDCchannel -> [ 0; 7]
571dda3d 855 //
856
857 Int_t iPlate = -1;
d0eb8f39 858 if (!(fDDL==-1 || fTRM==-1 || fTDC==-1
859 || fSector==-1))
860 iPlate = Equip2VolNplate(GetDDLnumberPerSector(fDDL), fTRM, fTDC);
571dda3d 861
d0eb8f39 862 fPlate = iPlate;
571dda3d 863
864}
865//_____________________________________________________________________________
866
d0eb8f39 867void AliTOFRawStream::SetStrip()
571dda3d 868{
869 //
d0eb8f39 870 // Evaluate the TOF strip number per module -> [ 0; 14/18]
871 // corresponding to the TOF equipment IDs:
872 // fDDL -> [ 0;71]
873 // fTRM -> [ 3;12]
15ec34b9 874 // fTRMchain -> [ 0; 1]
d0eb8f39 875 // fTDC -> [ 0;14]
876 // fTDCchannel -> [ 0; 7]
571dda3d 877 //
878
879 Int_t iStrip = -1;
880
d0eb8f39 881 if (!(fDDL==-1 || fTRM==-1 || fTDC==-1
882 || fSector==-1 || fPlate==-1))
883 iStrip = Equip2VolNstrip(GetDDLnumberPerSector(fDDL), fTRM, fTDC);
571dda3d 884
d0eb8f39 885 fStrip = iStrip;
571dda3d 886
887}
888//_____________________________________________________________________________
889
d0eb8f39 890void AliTOFRawStream::SetPadZ()
571dda3d 891{
892 //
d0eb8f39 893 // Evaluate the TOF padRow number per strip -> [ 0; 1]
894 // corresponding to the TOF equipment IDs:
895 // fDDL -> [ 0;71]
896 // fTRM -> [ 3;12]
15ec34b9 897 // fTRMchain -> [ 0; 1]
d0eb8f39 898 // fTDC -> [ 0;14]
899 // fTDCchannel -> [ 0; 7]
571dda3d 900 //
901
902 Int_t iPadZ = -1;
903
d0eb8f39 904 if (!(fDDL==-1 || fTRM==-1 || fTRMchain==-1 || fTDC==-1 || fTDCchannel==-1
905 || fSector==-1 || fPlate==-1 || fStrip==-1))
906 {
907 Int_t iPadAlongTheStrip = Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel);
908 if (iPadAlongTheStrip!=-1)
909 iPadZ = iPadAlongTheStrip%AliTOFGeometry::NpadZ();
910 }
571dda3d 911
38f24f3f 912 //iPadZ = Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel)%AliTOFGeometry::NpadZ();
913 //iPadZ = Equip2VolNpadZ(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel);
914
d0eb8f39 915 fPadZ = iPadZ;
571dda3d 916
d0eb8f39 917}
918//_____________________________________________________________________________
919
920void AliTOFRawStream::SetPadX()
921{
922 //
923 // Evaluate the TOF pad number per strip padRow -> [ 0;47]
924 // corresponding to the TOF equipment IDs:
925 // fDDL -> [ 0;71]
926 // fTRM -> [ 3;12]
15ec34b9 927 // fTRMchain -> [ 0; 1]
d0eb8f39 928 // fTDC -> [ 0;14]
929 // fTDCchannel -> [ 0; 7]
930 //
571dda3d 931
d0eb8f39 932 Int_t iPadX = -1;
571dda3d 933
d0eb8f39 934 if (!(fDDL==-1 || fTRM==-1 || fTRMchain==-1 || fTDC==-1 || fTDCchannel==-1
935 || fSector==-1 || fPlate==-1 || fStrip==-1))
936 {
937 Int_t iPadAlongTheStrip = Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel);
938 if (iPadAlongTheStrip!=-1)
939 iPadX = (Int_t)(iPadAlongTheStrip/(Float_t(AliTOFGeometry::NpadZ())));
940 }
941
38f24f3f 942 //iPadX = (Int_t)(Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel)/(Float_t(AliTOFGeometry::NpadZ())));
943 //iPadX = Equip2VolNpadX(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel);
944
d0eb8f39 945 fPadX = iPadX;
571dda3d 946
947}
571dda3d 948
d0eb8f39 949//----------------------------------------------------------------------------
950Int_t AliTOFRawStream::GetField(UInt_t word, Int_t fieldMask, Int_t fieldPosition) const
951{
952 //
953 //
954 //
955
956 return ((word & fieldMask) >> fieldPosition);
957}
958
959//----------------------------------------------------------------------------
13d6bff9 960Int_t AliTOFRawStream::Equip2VolNplate(Int_t iDDL, Int_t nTRM, Int_t nTDC)
571dda3d 961{
962 //
d0eb8f39 963 // Returns the TOF plate number [0;4]
964 // corresponding to the TOF equipment ID numbers:
965 // iDDL -> DDL number per sector [0;3]
966 // nTRM -> TRM number [3;12]
967 // nTDC -> TDC number [0;14]
571dda3d 968 //
969
d0eb8f39 970 Int_t iPlate = -1;
5f72a2bf 971
d0eb8f39 972 if (iDDL==0) {
973
974 if (nTRM>=4 && nTRM<7) {
975 iPlate = 0;
976 } else if (nTRM==7) {
977 if (nTDC<12) iPlate = 0;
978 else iPlate = 1;
979 } else if (nTRM>=8 && nTRM<11) {
980 iPlate = 1;
981 } else if (nTRM==11) {
982 if (nTDC<9) iPlate = 1;
983 else iPlate = 2;
984 }else if (nTRM==12) {
985 iPlate = 2;
986 }
987
988 } else if (iDDL==1) {
989
990 if (nTRM==3) {
991 if (nTDC<3) iPlate = 0;
992 } else if (nTRM>=4 && nTRM<7) {
993 iPlate = 0;
994 } else if (nTRM==7) {
995 if (nTDC<6) iPlate = 1;
996 else iPlate = 0;
997 } else if (nTRM>=8 && nTRM<11) {
998 iPlate = 1;
999 } else if (nTRM==11) {
1000 if (nTDC<9) iPlate = 2;
1001 else iPlate = 1;
1002 } else if (nTRM==12) {
1003 iPlate = 2;
1004 }
1005
1006 } else if (iDDL==2) {
1007
1008 if (nTRM>=4 && nTRM<7) {
1009 iPlate = 4;
1010 } else if (nTRM==7) {
1011 if (nTDC<12) iPlate = 4;
1012 else iPlate = 3;
1013 } else if (nTRM>=8 && nTRM<11) {
1014 iPlate = 3;
1015 } else if (nTRM==11) {
1016 if (nTDC<9) iPlate = 3;
1017 else iPlate = 2;
1018 }else if (nTRM==12) {
1019 iPlate = 2;
1020 }
1021
1022 } else if (iDDL==3) {
1023
1024 if (nTRM==3) {
1025 if (nTDC<3) iPlate = 4;
1026 } else if (nTRM>=4 && nTRM<7) {
1027 iPlate = 4;
1028 } else if (nTRM==7) {
1029 if (nTDC<6) iPlate = 3;
1030 else iPlate = 4;
1031 } else if (nTRM>=8 && nTRM<11) {
1032 iPlate = 3;
1033 } else if (nTRM==11) {
1034 if (nTDC<9) iPlate = 2;
1035 else iPlate = 3;
1036 } else if (nTRM==12) {
1037 iPlate = 2;
1038 }
571dda3d 1039
d0eb8f39 1040 }
571dda3d 1041
d0eb8f39 1042 return iPlate;
571dda3d 1043
d0eb8f39 1044}
571dda3d 1045
d0eb8f39 1046//----------------------------------------------------------------------------
13d6bff9 1047Int_t AliTOFRawStream::Equip2VolNstrip(Int_t iDDL, Int_t nTRM, Int_t nTDC)
d0eb8f39 1048{
1049 //
1050 // Returns the TOF strip number per module:
1051 // [0;14], in the central plates,
1052 // [0;18], in the intermediate and external plates
1053 // corresponding to the TOF equipment ID numbers:
1054 // iDDL -> DDL number per sector [0;3]
1055 // nTRM -> TRM number [3;12]
1056 // nTDC -> TDC number [0;14]
1057 //
571dda3d 1058
d0eb8f39 1059 Int_t iStrip = -1;
571dda3d 1060
d0eb8f39 1061 if (iDDL==0) {
1062
1063 if (nTRM== 4) iStrip = (Int_t)(nTDC/3.);
1064 else if (nTRM== 5) iStrip = 5 + (Int_t)(nTDC/3.);
1065 else if (nTRM== 6) iStrip = 10 + (Int_t)(nTDC/3.);
1066 else if (nTRM== 7) {
1067 if (nTDC<12) iStrip = 15 + (Int_t)(nTDC/3.);
1068 else iStrip = (Int_t)(nTDC/3.) - 4;
1069 }
1070 else if (nTRM== 8) iStrip = 1 + (Int_t)(nTDC/3.);
1071 else if (nTRM== 9) iStrip = 6 + (Int_t)(nTDC/3.);
1072 else if (nTRM==10) iStrip = 11 + (Int_t)(nTDC/3.);
1073 else if (nTRM==11) {
1074 if (nTDC<9) iStrip = 16 + (Int_t)(nTDC/3.);
1075 else iStrip = (Int_t)(nTDC/3.) - 3;
1076 }
1077 else if (nTRM==12) iStrip = 2 + (Int_t)(nTDC/3.);
1078
1079 } else if (iDDL==1) {
1080
1081 if (nTRM==3 && nTDC<3) iStrip = (Int_t)(nTDC/3.);
1082 else if (nTRM== 4) iStrip = 5 - (Int_t)(nTDC/3.);
1083 else if (nTRM== 5) iStrip = 10 - (Int_t)(nTDC/3.);
1084 else if (nTRM== 6) iStrip = 15 - (Int_t)(nTDC/3.);
1085 else if (nTRM== 7) {
1086 if (nTDC<6) iStrip = 1 - (Int_t)(nTDC/3.);
1087 else iStrip = 20 - (Int_t)(nTDC/3.);
1088 }
1089 else if (nTRM== 8) iStrip = 6 - (Int_t)(nTDC/3.);
1090 else if (nTRM== 9) iStrip = 11 - (Int_t)(nTDC/3.);
1091 else if (nTRM==10) iStrip = 16 - (Int_t)(nTDC/3.);
1092 else if (nTRM==11) {
1093 if (nTDC<9) iStrip = 2 - (Int_t)(nTDC/3.);
1094 else iStrip = 21 - (Int_t)(nTDC/3.);
1095 }
1096 else if (nTRM==12) iStrip = 7 - (Int_t)(nTDC/3.);
1097
1098 } else if (iDDL==2) {
1099
1100 if (nTRM== 4) iStrip = 18 - (Int_t)(nTDC/3.);
1101 else if (nTRM== 5) iStrip = 18 - ( 5 + (Int_t)(nTDC/3.));
1102 else if (nTRM== 6) iStrip = 18 - (10 + (Int_t)(nTDC/3.));
1103 else if (nTRM== 7) {
1104 if (nTDC<12) iStrip = 18 - (15 + (Int_t)(nTDC/3.));
1105 else iStrip = 18 - ((Int_t)(nTDC/3.) - 4);
1106 }
1107 else if (nTRM== 8) iStrip = 18 - ( 1 + (Int_t)(nTDC/3.));
1108 else if (nTRM== 9) iStrip = 18 - ( 6 + (Int_t)(nTDC/3.));
1109 else if (nTRM==10) iStrip = 18 - (11 + (Int_t)(nTDC/3.));
1110 else if (nTRM==11) {
1111 if (nTDC<9) iStrip = 18 - (16 + (Int_t)(nTDC/3.));
1112 else iStrip = 14 - ((Int_t)(nTDC/3.) - 3);
1113 }
1114 else if (nTRM==12) iStrip = 14 - ( 2 + (Int_t)(nTDC/3.));
1115
1116 } else if (iDDL==3) {
1117
1118 if (nTRM==3 && nTDC<3) iStrip = 18 - (Int_t)(nTDC/3.);
1119 else if (nTRM== 4) iStrip = 18 - ( 5 - (Int_t)(nTDC/3.));
1120 else if (nTRM== 5) iStrip = 18 - (10 - (Int_t)(nTDC/3.));
1121 else if (nTRM== 6) iStrip = 18 - (15 - (Int_t)(nTDC/3.));
1122 else if (nTRM== 7) {
1123 if (nTDC<6) iStrip = 18 - (1 - (Int_t)(nTDC/3.));
1124 else iStrip = 18 - (20 - (Int_t)(nTDC/3.));
1125 }
1126 else if (nTRM== 8) iStrip = 18 - ( 6 - (Int_t)(nTDC/3.));
1127 else if (nTRM== 9) iStrip = 18 - (11 - (Int_t)(nTDC/3.));
1128 else if (nTRM==10) iStrip = 18 - (16 - (Int_t)(nTDC/3.));
1129 else if (nTRM==11) {
1130 if (nTDC<9) iStrip = 14 - ( 2 - (Int_t)(nTDC/3.));
1131 else iStrip = 18 - (21 - (Int_t)(nTDC/3.));
1132 }
1133 else if (nTRM==12) iStrip = 14 - ( 7 - (Int_t)(nTDC/3.));
1134
1135 }
1136
1137 return iStrip;
1138
1139}
1140
1141//----------------------------------------------------------------------------
1142Int_t AliTOFRawStream::Equip2VolNpad(Int_t iDDL, Int_t iChain, Int_t nTDC,
13d6bff9 1143 Int_t iCH)
d0eb8f39 1144{
1145 //
1146 // Returns the TOF pad number per strip [0;95]
1147 // corresponding to the TOF equipment ID numbers:
1148 // iDDL -> DDL number per sector [0;3]
1149 // iChain -> TRM chain number [0;1]
1150 // nTDC -> TDC number [0;14]
1151 // iCH -> TDC channel number [0;7]
1152 //
1153
1154 Int_t iPadAlongTheStrip = -1;
1155
38f24f3f 1156 // wrong
1157 //Int_t iTDClocal = nTDC%3 + (1-iChain)*3;
1158 //if (iDDL==0 || iDDL==3) iTDClocal = 5 - iTDClocal;
1159 //else if (iDDL==1 || iDDL==2) iTDClocal = 6 + (5 - iTDClocal);
d0eb8f39 1160
38f24f3f 1161 // right
1162 Int_t iTDClocal = -1;
1163 Int_t iTDClocal03 = nTDC%3 + (1-iChain)*3;
1164 Int_t iTDClocal12 = 2-nTDC%3 + iChain*3;
1165 if (iDDL==0 || iDDL==3) iTDClocal = 5 - iTDClocal03;
1166 else if (iDDL==1 || iDDL==2) iTDClocal = 6 + (5 - iTDClocal12);
d0eb8f39 1167
1168 Int_t iCHlocal = iCH;
1169 if (iDDL==0 || iDDL==3) iCHlocal = 7 - iCH;
1170
1171 iPadAlongTheStrip = iTDClocal*AliTOFGeometry::NCh() + iCHlocal;
1172
1173 if (((iDDL==1 || iDDL==2) && iPadAlongTheStrip< AliTOFGeometry::NpadX()) ||
019f6101 1174 ((iDDL==0 || iDDL==3) && iPadAlongTheStrip>=AliTOFGeometry::NpadX())) {
a9137e31 1175 std::cerr << "Warning -> AliTOFRawStream::Equip2VolNpad: Problems with the padX number!" << endl;
13d6bff9 1176 //AliWarning("Problems with the padX number!");
019f6101 1177 }
d0eb8f39 1178 return iPadAlongTheStrip;
1179
1180}
1181
1182//----------------------------------------------------------------------------
38f24f3f 1183Int_t AliTOFRawStream::Equip2VolNpadX(Int_t iDDL, Int_t iChain, Int_t nTDC,
1184 Int_t iCH)
1185{
1186 //
1187 // Returns the TOF padX number [0;47]
1188 // corresponding to the TOF equipment ID numbers:
1189 // iDDL -> DDL number per sector [0;3]
1190 // iChain -> TRM chain number [0;1]
1191 // nTDC -> TDC number [0;14]
1192 // iCH -> TDC channel number [0;7]
1193 //
1194
1195 Int_t iPadX = (Int_t)(AliTOFRawStream::Equip2VolNpad(iDDL, iChain, nTDC, iCH)/
1196 (Float_t(AliTOFGeometry::NpadZ())));
1197
1198 return iPadX;
1199
1200}
1201
1202//----------------------------------------------------------------------------
1203Int_t AliTOFRawStream::Equip2VolNpadZ(Int_t iDDL, Int_t iChain, Int_t nTDC,
1204 Int_t iCH)
1205{
1206 //
1207 // Returns the TOF padZ number [0;1]
1208 // corresponding to the TOF equipment ID numbers:
1209 // iDDL -> DDL number per sector [0;3]
1210 // iChain -> TRM chain number [0;1]
1211 // nTDC -> TDC number [0;14]
1212 // iCH -> TDC channel number [0;7]
1213 //
1214
1215 Int_t iPadZ = AliTOFRawStream::Equip2VolNpad(iDDL, iChain, nTDC, iCH)%AliTOFGeometry::NpadZ();
1216
1217 return iPadZ;
1218
1219}
1220
1221//----------------------------------------------------------------------------
5f72a2bf 1222Int_t AliTOFRawStream::GetSectorNumber(Int_t nDDL)
d0eb8f39 1223{
1224 //
1225 // Returns the sector number [0;17]
1226 // corresponing to the assigned DRM/DDL number [0;71]
1227 //
1228
1229 Int_t iSector = Int_t((Float_t)(nDDL)/AliTOFGeometry::NDDL());
1230
1231 return iSector;
1232
1233}
1234//----------------------------------------------------------------------------
5f72a2bf 1235Int_t AliTOFRawStream::GetDDLnumberPerSector(Int_t nDDL)
d0eb8f39 1236{
1237 //
1238 // Return the DRM/DDL number per sector [0;3]
1239 // corresponing to the assigned DRM/DDL number [0;71]
1240 //
1241
1242 Int_t iDDL = nDDL%AliTOFGeometry::NDDL();
1243
1244 return iDDL;
1245
1246}
1247
1248//----------------------------------------------------------------------------
7813bb1a 1249void AliTOFRawStream::EquipmentId2VolumeId(AliTOFHitData *hitData, Int_t *volume) const
1250{
1251 EquipmentId2VolumeId(hitData->GetDDLID(),hitData->GetSlotID(),hitData->GetChain(),hitData->GetTDC(),hitData->GetChan(),volume);
1252}
1253//----------------------------------------------------------------------------
d0eb8f39 1254void AliTOFRawStream::EquipmentId2VolumeId(Int_t nDDL, Int_t nTRM, Int_t iChain,
1255 Int_t nTDC, Int_t iCH,
a9137e31 1256 Int_t *volume)
d0eb8f39 1257{
1258 //
1259 // To convert:
1260 // nDDL (variable in [0;71]) -> number of the DDL file
1261 // nTRM (variable in [3;12]) -> number of the TRM slot
1262 // iChain (variable in [0; 1]) -> number of the TRM chain
1263 // nTDC (variable in [0;14]) -> number of the TDC
1264 // iCH (variable in [0; 7]) -> number of the TDC channel
1265 //
1266 // in:
1267 // sector number, i.e. volume[0] (variable in [0,17])
1268 // plate number, i.e. volume[1] (variable in [0, 5])
1269 // strip number, i.e. volume[2] (variable in [0,14/18])
1270 // padX number, i.e. volume[3] (variable in [0,47])
1271 // padZ number, i.e. volume[4] (variable in [0, 1])
1272 //
1273
1274 Int_t iDDL = GetDDLnumberPerSector(nDDL);
1275
1276 Int_t iSector = GetSectorNumber(nDDL);
1277
1278 Int_t iPlate = Equip2VolNplate(iDDL, nTRM, nTDC);
019f6101 1279 if (iPlate==-1) {
a9137e31 1280 /*if (fRawReader)
1281 fRawReader->AddMajorErrorLog(kPlateError,"plate = -1");*/
da37d318 1282 printf("Warning -> AliTOFRawStream::EquipmentId2VolumeId: Problems with the plate number!\n");
019f6101 1283 }
d0eb8f39 1284
1285 Int_t iStrip = Equip2VolNstrip(iDDL, nTRM, nTDC);
019f6101 1286 if (iStrip==-1) {
a9137e31 1287 /*if (fRawReader)
1288 fRawReader->AddMajorErrorLog(kStripError,"strip = -1");*/
1289 printf("Warning -> AliTOFRawStream::EquipmentId2VolumeId: Problems with the strip number!\n");
019f6101 1290 }
d0eb8f39 1291
1292 Int_t iPadAlongTheStrip = Equip2VolNpad(iDDL, iChain, nTDC, iCH);
a9137e31 1293 if (iPadAlongTheStrip==-1) {
1294 /*if (fRawReader)
1295 fRawReader->AddMajorErrorLog(kPadAlongStripError,"pad = -1");*/
1296 printf("Warning -> AliTOFRawStream::EquipmentId2VolumeId: Problems with the pad number along the strip!\n");
019f6101 1297 }
13d6bff9 1298
d0eb8f39 1299 Int_t iPadX = (Int_t)(iPadAlongTheStrip/(Float_t(AliTOFGeometry::NpadZ())));
1300 Int_t iPadZ = iPadAlongTheStrip%AliTOFGeometry::NpadZ();
38f24f3f 1301
1302 //Int_t iPadX = (Int_t)(Equip2VolNpad(iDDL, iChain, nTDC, iCH)/(Float_t(AliTOFGeometry::NpadZ())));
1303 //Int_t iPadZ = Equip2VolNpad(iDDL, iChain, nTDC, iCH)%AliTOFGeometry::NpadZ();
1304
1305 //Int_t iPadX = Equip2VolNpadX(iDDL, iChain, nTDC, iCH);
1306 //Int_t iPadZ = Equip2VolNpadZ(iDDL, iChain, nTDC, iCH);
1307
d0eb8f39 1308 volume[0] = iSector;
1309 volume[1] = iPlate;
1310 volume[2] = iStrip;
1311 volume[3] = iPadX;
1312 volume[4] = iPadZ;
571dda3d 1313
1314}
7813bb1a 1315//-----------------------------------------------------------------------------
019f6101 1316Bool_t AliTOFRawStream::DecodeDDL(Int_t nDDLMin, Int_t nDDLMax, Int_t verbose = 0) {
1317 //
1318 // To decode raw data for DDL number in [nDDLmin; nDDLmax]
1319 //
1320
7813bb1a 1321 //check and fix valid DDL range
019f6101 1322 if (nDDLMin < 0){
1323 nDDLMin = 0;
1324 fRawReader->AddMinorErrorLog(kDDLMinError);
1325 AliWarning("Wrong DDL range: setting first DDL ID to 0");
7813bb1a 1326 }
019f6101 1327 if (nDDLMax > 71){
1328 nDDLMax = 71;
1329 fRawReader->AddMinorErrorLog(kDDLMaxError);
1330 AliWarning("Wrong DDL range: setting last DDL ID to 71");
7813bb1a 1331 }
1332
1333 //select required DDLs
019f6101 1334 fRawReader->Select("TOF", nDDLMin, nDDLMax);
7813bb1a 1335
1336 if (verbose)
019f6101 1337 AliInfo(Form("Selected TOF DDL range: %d-%d", nDDLMin, nDDLMax));
7813bb1a 1338
2fd622fa 1339 return(Decode(verbose));
1340}
1341//-----------------------------------------------------------------------------
019f6101 1342Bool_t AliTOFRawStream::Decode(Int_t verbose = 0) {
1343 //
1344 // New decoder method
1345 //
1346
2fd622fa 1347 Int_t currentEquipment;
1348 Int_t currentDDL;
dd824655 1349 const AliRawDataHeader *currentCDH;
2fd622fa 1350
1351 //pointers
1352 UChar_t *data = 0x0;
1353
7813bb1a 1354 //loop and read DDL headers
1355 while(fRawReader->ReadHeader()){
1356
1357 //memory leak prevention (actually data should be always 0x0 here)
1358 if (data != 0x0)
1359 delete [] data;
1360
1361 //get equipment infos
1362 currentEquipment = fRawReader->GetEquipmentId();
1363 currentDDL = fRawReader->GetDDLID();
dd824655 1364 currentCDH = fRawReader->GetDataHeader();
7813bb1a 1365 const Int_t kDataSize = fRawReader->GetDataSize();
1366 const Int_t kDataWords = kDataSize / 4;
1367 data = new UChar_t[kDataSize];
1368
1369 if (verbose)
1370 AliInfo(Form("Found equipment # %d header (DDL # %d): %d bytes (%d words)", currentEquipment, currentDDL, kDataSize, kDataWords));
1371
1372 if (verbose)
1373 AliInfo(Form("Reading equipment #%d (DDL # %d) data...", currentEquipment, currentDDL));
1374
1375 //read equipment payload
1376 if (!fRawReader->ReadNext(data, kDataSize))
1377 {
019f6101 1378 fRawReader->AddMajorErrorLog(kDDLdataReading);
7813bb1a 1379 if (verbose)
019f6101 1380 AliWarning("Error while reading DDL data. Go to next equipment");
7813bb1a 1381 delete [] data;
1382 data = 0x0;
1383 continue;
1384 }
1385
1386 if (verbose)
1387 AliInfo(Form("Equipment # %d (DDL # %d) data has been readed", currentEquipment, currentDDL));
1388
1389
1390 //set up the decoder
1391 fDecoder->SetVerbose(verbose);
d35d0ea0 1392 fDecoder->SetDataBuffer(&fDataBuffer[currentDDL]);
1393 fDecoder->SetPackedDataBuffer(&fPackedDataBuffer[currentDDL]);
7813bb1a 1394
1395 //start decoding
dd824655 1396 if (fDecoder->Decode((UInt_t *)data, kDataWords, currentCDH) == kTRUE) {
019f6101 1397 fRawReader->AddMajorErrorLog(kDDLDecoder,Form("DDL # = %d",currentDDL));
1398 AliWarning(Form("Error while decoding DDL # %d: decoder returned with errors", currentDDL));
1399 }
7813bb1a 1400
1401 delete [] data;
1402 data = 0x0;
1403 }
1404
1405 //reset reader
1406 fRawReader->Reset();
1407
1408 if (verbose)
1409 AliInfo("All done");
1410
1411 return kFALSE;
1412
1413}
1414//---------------------------------------------------------------------------
1415void
1416AliTOFRawStream::ResetBuffers()
1417{
19eefa2b 1418 //
1419 // To reset the buffers
1420 //
1421
7813bb1a 1422 for (Int_t iDDL = 0; iDDL < AliDAQ::NumberOfDdls("TOF"); iDDL++){
1423 ResetDataBuffer(iDDL);
1424 ResetPackedDataBuffer(iDDL);
1425 }
1426}
1427
1428//---------------------------------------------------------------------------
1429Bool_t
1430AliTOFRawStream::LoadRawDataBuffers(Int_t indexDDL, Int_t verbose)
1431{
19eefa2b 1432 //
1433 // To load the buffers
1434 //
1435
7813bb1a 1436 fTOFrawData->Clear();
1437 fPackedDigits = 0;
1438
1439 if (verbose > 0)
1440 AliInfo(Form("Decoding raw data for DDL # %d ...", indexDDL));
1441
1442 if (DecodeDDL(indexDDL, indexDDL, verbose) != 0){ //decode DDL
019f6101 1443 fRawReader->AddMajorErrorLog(kDDLDecoder,Form("DDL # = %d",indexDDL));
1444 AliWarning(Form("Error while decoding DDL # %d", indexDDL));
7813bb1a 1445 return kTRUE;
1446 }
1447
1448 if (verbose > 0)
d35d0ea0 1449 AliInfo(Form("Done. %d packed %s been found.", fPackedDataBuffer[indexDDL].GetEntries(), fPackedDataBuffer[indexDDL].GetEntries() > 1 ? "hits have" : "hit has"));
7813bb1a 1450
1451 AliTOFHitData *hitData; //hit data pointer
1452
1453 if (verbose > 0)
1454 AliInfo("Filling TClonesArray ...");
1455
dd824655 1456 if (verbose > 0)
1457 if (fgApplyBCCorrections) {
1458 AliInfo("Apply nominal DDL BC time-shift correction");
1459 AliInfo("Apply deltaBC time-shift correction");
1460 }
1461
7813bb1a 1462 //loop over DDL packed hits
d35d0ea0 1463 for (Int_t iHit = 0; iHit < fPackedDataBuffer[indexDDL].GetEntries(); iHit++){
1464 hitData = fPackedDataBuffer[indexDDL].GetHit(iHit); //get hit data
7813bb1a 1465 Int_t hitACQ = hitData->GetACQ();
1466 Int_t hitPS = hitData->GetPS();
1467 Int_t hitSlotID = hitData->GetSlotID();
1468 Int_t hitChain = hitData->GetChain();
1469 Int_t hitTDC = hitData->GetTDC();
1470 Int_t hitChan = hitData->GetChan();
7813bb1a 1471 Int_t hitTimeBin = hitData->GetTimeBin();
7813bb1a 1472 Int_t hitTOTBin = hitData->GetTOTBin();
dd824655 1473
1474 if (fgApplyBCCorrections) {
1475 /* DDL BC shift time correction */
1476 hitTimeBin += fgkddlBCshift[indexDDL];
1477 /* deltaBC shift time correction */
1478 hitTimeBin += hitData->GetDeltaBunchID();
1479 }
1480
1481 Int_t hitLeading = hitData->GetTimeBin();
bf33f8f0 1482 Int_t hitTrailing = -1;
1483 Int_t hitError = -1;
7813bb1a 1484
1485 TClonesArray &arrayTofRawData = *fTOFrawData;
bf33f8f0 1486 new (arrayTofRawData[fPackedDigits++]) AliTOFrawData(hitSlotID, hitChain, hitTDC, hitChan, hitTimeBin, hitTOTBin, hitLeading, hitTrailing, hitPS, hitACQ, hitError);
7813bb1a 1487 }
1488
1489 if (verbose > 0)
1490 AliInfo("Done.");
1491
1492 if (verbose > 0)
1493 AliInfo("Resetting buffers ...");
1494
d35d0ea0 1495 fDataBuffer[indexDDL].Reset();
1496 fPackedDataBuffer[indexDDL].Reset();
7813bb1a 1497
1498 if (verbose > 0)
1499 AliInfo("Done.");
1500
1501 return kFALSE;
1502}
1503
5f72a2bf 1504//---------------------------------------------------------------------------
1505void AliTOFRawStream::Geant2EquipmentId(Int_t vol[], Int_t eqId[])
1506{
1507 //
1508 // To convert:
1509 // nSector number -vol[0]- (variable in [0,17])
1510 // nPlate number -vol[1]- (variable in [0, 5])
1511 // nStrip number -vol[2]- (variable in [0,14/18])
1512 // nPadZ number -vol[3]- (variable in [0, 1])
1513 // nPadX number -vol[4]- (variable in [0,47])
1514 // in:
e1d95075 1515 // nDDL -eqId[0]- (variable in [0;71]) -> number of the DDL
1516 // nTRM -eqId[1]- (variable in [3;12]) -> number of the TRM
1517 // nTDC -eqId[2]- (variable in [0;14]) -> number of the TDC
1518 // nChain -eqId[3]- (variable in [0; 1]) -> number of the chain
1519 // nChannel -eqId[4]- (variable in [0; 8]) -> number of the channel
5f72a2bf 1520 //
1521
1522 eqId[0] = Geant2DDL(vol);
1523 eqId[1] = Geant2TRM(vol);
1524 eqId[2] = Geant2TDC(vol);
1525 eqId[3] = Geant2Chain(vol);
1526 eqId[4] = Geant2Channel(vol);
1527
1528}
1529
1530//---------------------------------------------------------------------------
1531Int_t AliTOFRawStream::Geant2DDL(Int_t vol[])
1532{
1533 //
1534 // To convert:
1535 // nSector number -vol[0]- (variable in [0,17])
1536 // nPlate number -vol[1]- (variable in [0, 5])
1537 // nStrip number -vol[2]- (variable in [0,14/18])
1538 // nPadZ number -vol[3]- (variable in [0, 1])
1539 // nPadX number -vol[4]- (variable in [0,47])
1540 // in:
e1d95075 1541 // nDDL (variable in [0;71]) -> number of the DDL
5f72a2bf 1542 //
1543
1544
1545 Int_t iDDL = -1;
1546
1547 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
1548 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
1549 return iDDL;
1550 }
1551 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
1552 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
1553 return iDDL;
1554 }
1555 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
1556 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
1557 return iDDL;
1558 }
1559 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ())
1560 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
1561 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX())
1562 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
1563 if ( vol[3]>=AliTOFGeometry::NpadZ() ) {
1564 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
1565 return iDDL;
1566 }
1567
1568 Int_t nSector = vol[0];
1569 Int_t nPlate = vol[1];
1570 Int_t nStrip = vol[2];
1571 Int_t nPadX = vol[4];
1572
1573 if ( nPadX<24 && ( nPlate==0 || nPlate==1 || (nPlate==2 && nStrip<7) ) )
1574 iDDL = 0;
1575 else if ( nPadX>=24 && ( nPlate==0 || nPlate==1 || (nPlate==2 && nStrip<8) ) )
1576 iDDL = 1;
1577 else if ( nPadX>=24 && ( nPlate==3 || nPlate==4 || (nPlate==2 && nStrip>7) ) )
1578 iDDL = 2;
1579 else if ( nPadX<24 && ( nPlate==3 || nPlate==4 || (nPlate==2 && nStrip>6) ) )
1580 iDDL = 3;
1581
1582 return 4*nSector+iDDL;
1583
1584}
1585
1586//---------------------------------------------------------------------------
1587Int_t AliTOFRawStream::Geant2TRM(Int_t vol[])
1588{
1589 //
1590 // To convert:
1591 // nSector number -vol[0]- (variable in [0,17])
1592 // nPlate number -vol[1]- (variable in [0, 5])
1593 // nStrip number -vol[2]- (variable in [0,14/18])
1594 // nPadZ number -vol[3]- (variable in [0, 1])
1595 // nPadX number -vol[4]- (variable in [0,47])
1596 // in:
1597 // nTRM (variable in [3;12]) -> number of the TRM slot
1598 //
1599
1600 Int_t nTRM = -1;
1601
1602 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
1603 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
1604 return nTRM;
1605 }
1606 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
1607 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
1608 return nTRM;
1609 }
1610 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
1611 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
1612 return nTRM;
1613 }
1614 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ()) {
1615 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
1616 return nTRM;
1617 }
1618 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX()) {
1619 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
1620 return nTRM;
1621 }
1622
1623 if ( vol[3]>=AliTOFGeometry::NpadZ() )
1624 {
1625 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
1626 return nTRM;
1627 }
1628
1629 Int_t nPlate = vol[1];
1630 Int_t nStrip = vol[2];
1631
1632 Int_t iDDL = Geant2DDL(vol)%4;
1633
1634 switch (iDDL) {
1635
1636 case 0:
1637
1638 if (nPlate==0) {
1639 if (nStrip<= 4) nTRM = 4;
1640 else if (nStrip> 4 && nStrip<= 9) nTRM = 5;
1641 else if (nStrip> 9 && nStrip<=14) nTRM = 6;
1642 else if (nStrip>14) nTRM = 7;
1643 }
1644 else if (nPlate==1) {
1645 if (nStrip== 0) nTRM = 7;
1646 else if (nStrip> 0 && nStrip<= 5) nTRM = 8;
1647 else if (nStrip> 5 && nStrip<=10) nTRM = 9;
1648 else if (nStrip>10 && nStrip<=15) nTRM = 10;
1649 else if (nStrip>15) nTRM = 11;
1650 }
1651 else if (nPlate==2) {
1652 if (nStrip<= 1) nTRM = 11;
1653 else if (nStrip> 1 && nStrip< 7) nTRM = 12;
1654 }
1655
1656 break;
1657 case 1:
1658
1659 if (nPlate==0) {
1660 if (nStrip== 0) nTRM = 3;
1661 else if (nStrip> 0 && nStrip<= 5) nTRM = 4;
1662 else if (nStrip> 5 && nStrip<=10) nTRM = 5;
1663 else if (nStrip>10 && nStrip<=15) nTRM = 6;
1664 else if (nStrip>15) nTRM = 7;
1665 }
1666 else if (nPlate==1) {
1667 if (nStrip<=1) nTRM = 7;
1668 else if (nStrip> 1 && nStrip<= 6) nTRM = 8;
1669 else if (nStrip> 6 && nStrip<=11) nTRM = 9;
1670 else if (nStrip>11 && nStrip<=16) nTRM = 10;
1671 else if (nStrip>16) nTRM = 11;
1672 }
1673 else if (nPlate==2) {
1674 if (nStrip<= 2) nTRM = 11;
1675 else if (nStrip> 2 && nStrip<= 7) nTRM = 12;
1676 }
1677
1678 break;
1679 case 2:
1680
1681 if (nPlate==4) {
1682 if (nStrip>=14) nTRM = 4;
1683 else if (nStrip<14 && nStrip>= 9) nTRM = 5;
1684 else if (nStrip< 9 && nStrip>= 4) nTRM = 6;
1685 else if (nStrip< 4) nTRM = 7;
1686 }
1687 else if (nPlate==3) {
1688 if (nStrip==18) nTRM = 7;
1689 else if (nStrip<18 && nStrip>=13) nTRM = 8;
1690 else if (nStrip<13 && nStrip>= 8) nTRM = 9;
1691 else if (nStrip< 8 && nStrip>= 3) nTRM = 10;
1692 else if (nStrip< 3) nTRM = 11;
1693 }
1694 else if (nPlate==2) {
1695 if (nStrip>=13) nTRM = 11;
1696 else if (nStrip<13 && nStrip>= 8) nTRM = 12;
1697 }
1698
1699 break;
1700 case 3:
1701
1702 if (nPlate==4) {
1703 if (nStrip==18) nTRM = 3;
1704 else if (nStrip<18 && nStrip>=13) nTRM = 4;
1705 else if (nStrip<13 && nStrip>= 8) nTRM = 5;
1706 else if (nStrip< 8 && nStrip>= 3) nTRM = 6;
1707 else if (nStrip< 3) nTRM = 7;
1708 }
1709 else if (nPlate==3) {
1710 if (nStrip>=17) nTRM = 7;
1711 else if (nStrip<17 && nStrip>=12) nTRM = 8;
1712 else if (nStrip<12 && nStrip>= 7) nTRM = 9;
1713 else if (nStrip< 7 && nStrip>= 2) nTRM = 10;
1714 else if (nStrip< 2) nTRM = 11;
1715 }
1716 else if (nPlate==2) {
1717 if (nStrip>=12) nTRM = 11;
1718 else if (nStrip <12 && nStrip>= 7) nTRM = 12;
1719 }
1720
1721 break;
1722
1723 }
1724
1725 return nTRM;
1726
1727}
1728
1729//---------------------------------------------------------------------------
1730Int_t AliTOFRawStream::Geant2TDC(Int_t vol[])
1731{
1732 //
1733 // To convert:
1734 // nSector number -vol[0]- (variable in [0,17])
1735 // nPlate number -vol[1]- (variable in [0, 5])
1736 // nStrip number -vol[2]- (variable in [0,14/18])
1737 // nPadZ number -vol[3]- (variable in [0, 1])
1738 // nPadX number -vol[4]- (variable in [0,47])
1739 // in:
1740 // nTDC (variable in [0;14]) -> number of the TDC
1741 //
1742
1743 Int_t nTDC = -1;
1744
1745 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
1746 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
1747 return nTDC;
1748 }
1749 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
1750 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
1751 return nTDC;
1752 }
1753 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
1754 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
1755 return nTDC;
1756 }
1757 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ())
1758 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
1759 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX())
1760 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
1761 if ( vol[3]>=AliTOFGeometry::NpadZ() ) {
1762 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
1763 return nTDC;
1764 }
1765
1766 Int_t nPlate = vol[1];
1767 Int_t nStrip = vol[2];
1768 Int_t iPadX = vol[4];
1769
1770 Int_t iDDL = Geant2DDL(vol)%4;
1771
1772 switch (iDDL) {
1773
1774 case 0:
1775
1776 if (nPlate==0) {
1777 if (nStrip<= 4) nTDC = (3*(nStrip)+2-(iPadX/4)%3);
1778 else if (nStrip> 4 && nStrip<= 9) nTDC = (3*(nStrip- 5)+2-(iPadX/4)%3);
1779 else if (nStrip> 9 && nStrip<=14) nTDC = (3*(nStrip-10)+2-(iPadX/4)%3);
1780 else if (nStrip>14) nTDC = (3*(nStrip-15)+2-(iPadX/4)%3);
1781 }
1782 else if (nPlate==1) {
1783 if (nStrip== 0) nTDC = (3*(nStrip+ 4)+2-(iPadX/4)%3);
1784 else if (nStrip> 0 && nStrip<= 5) nTDC = (3*(nStrip- 1)+2-(iPadX/4)%3);
1785 else if (nStrip> 5 && nStrip<=10) nTDC = (3*(nStrip- 6)+2-(iPadX/4)%3);
1786 else if (nStrip>10 && nStrip<=15) nTDC = (3*(nStrip-11)+2-(iPadX/4)%3);
1787 else if (nStrip>15) nTDC = (3*(nStrip-16)+2-(iPadX/4)%3);
1788 }
1789 else if (nPlate==2) {
1790 if (nStrip<= 1) nTDC = (3*(nStrip+ 3)+2-(iPadX/4)%3);
1791 else if (nStrip> 1 && nStrip< 7) nTDC = (3*(nStrip- 2)+2-(iPadX/4)%3);
1792 }
1793
1794 break;
1795 case 1:
1796
1797 if (nPlate==0) {
1798 if (nStrip== 0) nTDC = (3*(nStrip)+(iPadX/4)%3);
1799 else if (nStrip> 0 && nStrip<= 5) nTDC = (3*( 5-nStrip)+(iPadX/4)%3);
1800 else if (nStrip> 5 && nStrip<=10) nTDC = (3*(10-nStrip)+(iPadX/4)%3);
1801 else if (nStrip>10 && nStrip<=15) nTDC = (3*(15-nStrip)+(iPadX/4)%3);
1802 else if (nStrip>15) nTDC = (3*(20-nStrip)+(iPadX/4)%3);
1803 }
1804 else if (nPlate==1) {
1805 if (nStrip<= 1) nTDC = (3*( 1-nStrip)+(iPadX/4)%3);
1806 else if (nStrip> 1 && nStrip<= 6) nTDC = (3*( 6-nStrip)+(iPadX/4)%3);
1807 else if (nStrip> 6 && nStrip<=11) nTDC = (3*(11-nStrip)+(iPadX/4)%3);
1808 else if (nStrip>11 && nStrip<=16) nTDC = (3*(16-nStrip)+(iPadX/4)%3);
1809 else if (nStrip>16) nTDC = (3*(21-nStrip)+(iPadX/4)%3);
1810 }
1811 else if (nPlate==2) {
1812 if (nStrip<= 2) nTDC = (3*( 2-nStrip)+(iPadX/4)%3);
1813 else if (nStrip> 2 && nStrip<= 7) nTDC = (3*( 7-nStrip)+(iPadX/4)%3);
1814 }
1815
1816 break;
1817 case 2:
1818
1819 if (nPlate==4) {
1820 if (nStrip>=14) nTDC = (3*(18-nStrip)+((iPadX/4)%3));
1821 else if (nStrip<14 && nStrip>= 9) nTDC = (3*(13-nStrip)+((iPadX/4)%3));
1822 else if (nStrip< 9 && nStrip>= 4) nTDC = (3*( 8-nStrip)+((iPadX/4)%3));
1823 else if (nStrip< 4) nTDC = (3*( 3-nStrip)+((iPadX/4)%3));
1824 }
1825 else if (nPlate==3) {
1826 if (nStrip==18) nTDC = (3*(22-nStrip)+((iPadX/4)%3));
1827 else if (nStrip<18 && nStrip>=13) nTDC = (3*(17-nStrip)+((iPadX/4)%3));
1828 else if (nStrip<13 && nStrip>= 8) nTDC = (3*(12-nStrip)+((iPadX/4)%3));
1829 else if (nStrip< 8 && nStrip>= 3) nTDC = (3*( 7-nStrip)+((iPadX/4)%3));
1830 else if (nStrip< 3) nTDC = (3*( 2-nStrip)+((iPadX/4)%3));
1831 }
1832 else if (nPlate==2) {
1833 if (nStrip>=13) nTDC = (3*(17-nStrip)+((iPadX/4)%3));
1834 else if (nStrip<13 && nStrip>= 8) nTDC = (3*(12-nStrip)+((iPadX/4)%3));
1835 }
1836
1837 break;
1838 case 3:
1839
1840 if (nPlate==4) {
1841 if (nStrip==18) nTDC = (3*(nStrip-18)+2-(iPadX/4)%3);
1842 else if (nStrip<18 && nStrip>=13) nTDC = (3*(nStrip-13)+2-(iPadX/4)%3);
1843 else if (nStrip<13 && nStrip>= 8) nTDC = (3*(nStrip- 8)+2-(iPadX/4)%3);
1844 else if (nStrip< 8 && nStrip>= 3) nTDC = (3*(nStrip- 3)+2-(iPadX/4)%3);
1845 else if (nStrip< 3) nTDC = (3*(nStrip+ 2)+2-(iPadX/4)%3);
1846 }
1847 else if (nPlate==3) {
1848 if (nStrip>=17) nTDC = (3*(nStrip-17)+2-(iPadX/4)%3);
1849 else if (nStrip<17 && nStrip>=12) nTDC = (3*(nStrip-12)+2-(iPadX/4)%3);
1850 else if (nStrip<12 && nStrip>= 7) nTDC = (3*(nStrip- 7)+2-(iPadX/4)%3);
1851 else if (nStrip< 7 && nStrip>= 2) nTDC = (3*(nStrip- 2)+2-(iPadX/4)%3);
1852 else if (nStrip< 2) nTDC = (3*(nStrip+ 3)+2-(iPadX/4)%3);
1853 }
1854 else if (nPlate==2) {
1855 if (nStrip>=12) nTDC = (3*(nStrip-12)+2-(iPadX/4)%3);
1856 else if (nStrip <12 && nStrip>= 7) nTDC = (3*(nStrip- 7)+2-(iPadX/4)%3);
1857 }
1858
1859 break;
1860
1861 }
1862
1863 return nTDC;
1864
1865}
1866
1867//---------------------------------------------------------------------------
1868Int_t AliTOFRawStream::Geant2Chain(Int_t vol[])
1869{
1870 //
1871 // To convert:
1872 // nSector number -vol[0]- (variable in [0,17])
1873 // nPlate number -vol[1]- (variable in [0, 5])
1874 // nStrip number -vol[2]- (variable in [0,14/18])
1875 // nPadZ number -vol[3]- (variable in [0, 1])
1876 // nPadX number -vol[4]- variable in [0,47])
1877 // in:
1878 // nChain (variable in [0; 1]) -> number of the TRM chain
1879 //
1880
1881 Int_t nChain = -1;
1882
1883 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
1884 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
1885 return nChain;
1886 }
1887 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
1888 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
1889 return nChain;
1890 }
1891 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
1892 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
1893 return nChain;
1894 }
1895 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ())
1896 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
1897 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX())
1898 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
1899 if ( vol[3]>=AliTOFGeometry::NpadZ() ) {
1900 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
1901 return nChain;
1902 }
1903
1904 Int_t iPadX = vol[4];
1905
1906 if (iPadX<12 || iPadX>=36) nChain = 0;
1907 else nChain = 1;
1908
1909 return nChain;
1910
1911}
1912
1913//---------------------------------------------------------------------------
1914Int_t AliTOFRawStream::Geant2Channel(Int_t vol[])
1915{
1916 //
1917 // To convert:
1918 // nSector number -vol[0]- (variable in [0,17])
1919 // nPlate number -vol[1]- (variable in [0, 5])
1920 // nStrip number -vol[2]- (variable in [0,14/18])
1921 // nPadZ number -vol[3]- (variable in [0, 1])
1922 // nPadX number -vol[4]- (variable in [0,47])
1923 // in:
1924 // nChannel (variable in [0; 7]) -> number of the TDC channel
1925 //
1926
1927 Int_t nChannel = -1;
1928
1929 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
1930 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
1931 return nChannel;
1932 }
1933 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
1934 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
1935 return nChannel;
1936 }
1937 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
1938 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
1939 return nChannel;
1940 }
1941 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ())
1942 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
1943 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX())
1944 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
1945 if ( vol[3]>=AliTOFGeometry::NpadZ() ) {
1946 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
1947 return nChannel;
1948 }
1949
1950 Int_t iPadZ = vol[3];
1951 Int_t iPadX = vol[4];
1952
1953 Int_t iDDL = Geant2DDL(vol)%4;
1954
1955 switch (iDDL) {
1956
1957 case 0:
1958 nChannel = ((2*(23-iPadX) + (1-iPadZ)))%8;
1959 break;
1960 case 1:
1961 nChannel = ((2*(iPadX-24) + (iPadZ)))%8;
1962 break;
1963 case 2:
1964 nChannel = ((2*(iPadX-24) + (iPadZ)))%8;
1965 break;
1966 case 3:
1967 nChannel = ((2*(23-iPadX) + (1-iPadZ)))%8;
1968 break;
1969 }
1970
1971 return nChannel;
1972
1973}
f472295e 1974
1975//____________________________________________________________________________
1976void AliTOFRawStream::Raw2Digits(AliRawReader* rawReader, TClonesArray* digitsArray)
1977{
1978 //
1979 // Converts raw data to digits for TOF
1980 //
1981
1982 TStopwatch stopwatch;
1983 stopwatch.Start();
1984
1985 //TClonesArray *fDigits = new TClonesArray("AliTOFdigit", 4000);
1986 //digitsTree->Branch("TOF", &fDigits);
1987 TClonesArray &aDigits = *digitsArray;
1988
1989 Int_t inholes = 0;
1990
1991 Clear();
1992 SetRawReader(rawReader);
1993
1994 //ofstream ftxt;
1995 //if (fVerbose==2) ftxt.open("TOFdigitsRead.txt",ios::app);
1996
1997 TClonesArray staticRawData("AliTOFrawData",10000);
1998 staticRawData.Clear();
1999 TClonesArray * clonesRawData = &staticRawData;
2000
2001 Int_t dummy = -1;
2002 Int_t detectorIndex[5] = {-1, -1, -1, -1, -1};
2003 Int_t digit[4];
2004
2005 const Int_t kMaxNumberOfTracksPerDigit = 3;
2006 Int_t tracks[kMaxNumberOfTracksPerDigit];
2007 for (Int_t ii=0; ii<kMaxNumberOfTracksPerDigit; ii++)
2008 tracks[ii] = -1;
2009 Int_t last = -1;
2010
2011 Int_t indexDDL = 0;
2012 Int_t iRawData = 0;
2013 AliTOFrawData *tofRawDatum = 0;
2014 for (indexDDL=0; indexDDL<AliDAQ::NumberOfDdls("TOF"); indexDDL++) {
2015
2016 rawReader->Reset();
2017 if (fNewDecoderVersion) {
2018 AliInfo("Using New Decoder \n");
2019 LoadRawDataBuffers(indexDDL, 0);
2020 }
2021 else
2022 LoadRawData(indexDDL);
2023
2024 clonesRawData = GetRawData();
2025 if (clonesRawData->GetEntriesFast()!=0) AliInfo(Form(" TOF raw data number = %3d", clonesRawData->GetEntriesFast()));
2026 for (iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
2027
2028 tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
2029
2030 //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
2031 if (tofRawDatum->GetTOF()==-1) continue;
2032
2033 EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
2034 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
2035
2036 dummy = detectorIndex[3];
2037 detectorIndex[3] = detectorIndex[4];//padz
2038 detectorIndex[4] = dummy;//padx
2039
2040 digit[0] = tofRawDatum->GetTOF();
2041 digit[1] = tofRawDatum->GetTOT();
2042 digit[2] = tofRawDatum->GetTOT();
2043 digit[3] = -1;//tofRawDatum->GetTOF(); //tofND
2044
2045 dummy = detectorIndex[3];
2046 detectorIndex[3] = detectorIndex[4];//padx
2047 detectorIndex[4] = dummy;//padz
2048
2049 // Do not reconstruct anything in the holes
2050 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
2051 if (detectorIndex[1]==2) { // plate with holes
2052 inholes++;
2053 continue;
2054 }
2055 }
2056
2057 last = digitsArray->GetEntriesFast();
2058 new (aDigits[last]) AliTOFdigit(tracks, detectorIndex, digit);
2059 /*
2060 if (fVerbose==2) {
2061 if (indexDDL<10) ftxt << " " << indexDDL;
2062 else ftxt << " " << indexDDL;
2063 if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM();
2064 else ftxt << " " << tofRawDatum->GetTRM();
2065 ftxt << " " << tofRawDatum->GetTRMchain();
2066 if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC();
2067 else ftxt << " " << tofRawDatum->GetTDC();
2068 ftxt << " " << tofRawDatum->GetTDCchannel();
2069
2070 if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0];
2071 else ftxt << " -> " << detectorIndex[0];
2072 ftxt << " " << detectorIndex[1];
2073 if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2];
2074 else ftxt << " " << detectorIndex[2];
2075 ftxt << " " << detectorIndex[4];
2076 if (detectorIndex[4]<10) ftxt << " " << detectorIndex[3];
2077 else ftxt << " " << detectorIndex[3];
2078
2079 if (digit[1]<10)ftxt << " " << digit[1];
2080 else if (digit[1]>=10 && digit[1]<100) ftxt << " " << digit[1];
2081 else ftxt << " " << digit[1];
2082 if (digit[0]<10) ftxt << " " << digit[0] << endl;
2083 else if (digit[0]>=10 && digit[0]<100) ftxt << " " << digit[0] << endl;
2084 else if (digit[0]>=100 && digit[0]<1000) ftxt << " " << digit[0] << endl;
2085 else ftxt << " " << digit[3] << endl;
2086 }
2087 */
2088 AliDebug(2, Form(" Raw data reading %2d -> %2d %1d %2d %1d %2d (%d, %d, %d)",
2089 last,
2090 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[4], detectorIndex[3],
2091 digit[0], digit[1], digit[3]));
2092
2093 tofRawDatum = 0;
2094 } // loop on tofRawData array
2095
2096 clonesRawData->Clear();
2097
2098 } // DDL Loop
2099
2100 //if (fVerbose==2) ftxt.close();
2101
2102
2103 if (inholes) AliWarning(Form("Raw data in the TOF holes: %d",inholes));
2104
2105 Int_t nDigits = digitsArray->GetEntries();
2106 AliDebug(1, Form("Got %d TOF digits", nDigits));
2107 AliDebug(1, Form("Execution time to read TOF raw data and fill TOF digit tree : R:%.2fs C:%.2fs",
2108 stopwatch.RealTime(),stopwatch.CpuTime()));
2109
2110}
2111
2112//____________________________________________________________________________
2113void AliTOFRawStream::Raw2SDigits(AliRawReader* rawReader, TClonesArray* sdigitsArray)
2114{
2115 //
2116 // Converts raw data to sdigits for TOF
2117 //
2118
2119 TStopwatch stopwatch;
2120 stopwatch.Start();
2121
2122 Int_t inholes = 0;
2123
2124 //if(!GetLoader()->TreeS()) {MakeTree("S"); MakeBranch("S");}
2125 TClonesArray &aSDigits = *sdigitsArray;
2126
2127 Clear();
2128 SetRawReader(rawReader);
2129
2130 //ofstream ftxt;
2131 //if (fVerbose==2) ftxt.open("TOFsdigitsRead.txt",ios::app);
2132
2133 TClonesArray staticRawData("AliTOFrawData",10000);
2134 staticRawData.Clear();
2135 TClonesArray * clonesRawData = &staticRawData;
2136
2137 Int_t dummy = -1;
2138 Int_t detectorIndex[5] = {-1, -1, -1, -1, -1};
2139 Int_t digit[2];
2140 Int_t track = -1;
2141 Int_t last = -1;
2142
2143 Int_t indexDDL = 0;
2144 Int_t iRawData = 0;
2145 AliTOFrawData *tofRawDatum = 0;
2146 for (indexDDL=0; indexDDL<AliDAQ::NumberOfDdls("TOF"); indexDDL++) {
2147
2148 rawReader->Reset();
2149 if (fNewDecoderVersion) {
2150 AliInfo("Using New Decoder \n");
2151 LoadRawDataBuffers(indexDDL, 0);
2152 }
2153 else
2154 LoadRawData(indexDDL);
2155
2156 clonesRawData = GetRawData();
2157 if (clonesRawData->GetEntriesFast()!=0) AliInfo(Form(" TOF raw data number = %3d", clonesRawData->GetEntriesFast()));
2158 for (iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
2159
2160 tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
2161
2162 //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
2163 if (tofRawDatum->GetTOF()==-1) continue;
2164
2165 EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
2166 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
2167
2168 dummy = detectorIndex[3];
2169 detectorIndex[3] = detectorIndex[4];//padz
2170 detectorIndex[4] = dummy;//padx
2171
2172 digit[0] = tofRawDatum->GetTOF();
2173 digit[1] = tofRawDatum->GetTOT();
2174
2175 dummy = detectorIndex[3];
2176 detectorIndex[3] = detectorIndex[4];//padx
2177 detectorIndex[4] = dummy;//padz
2178
2179 // Do not reconstruct anything in the holes
2180 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
2181 if (detectorIndex[1]==2) { // plate with holes
2182 inholes++;
2183 continue;
2184 }
2185 }
2186
2187 last = sdigitsArray->GetEntriesFast();
2188 new (aSDigits[last]) AliTOFSDigit(track, detectorIndex, digit);
2189 /*
2190 if (fVerbose==2) {
2191 if (indexDDL<10) ftxt << " " << indexDDL;
2192 else ftxt << " " << indexDDL;
2193 if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM();
2194 else ftxt << " " << tofRawDatum->GetTRM();
2195 ftxt << " " << tofRawDatum->GetTRMchain();
2196 if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC();
2197 else ftxt << " " << tofRawDatum->GetTDC();
2198 ftxt << " " << tofRawDatum->GetTDCchannel();
2199
2200 if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0];
2201 else ftxt << " -> " << detectorIndex[0];
2202 ftxt << " " << detectorIndex[1];
2203 if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2];
2204 else ftxt << " " << detectorIndex[2];
2205 ftxt << " " << detectorIndex[4];
2206 if (detectorIndex[4]<10) ftxt << " " << detectorIndex[3];
2207 else ftxt << " " << detectorIndex[3];
2208
2209 if (digit[1]<10)ftxt << " " << digit[1];
2210 else if (digit[1]>=10 && digit[1]<100) ftxt << " " << digit[1];
2211 else ftxt << " " << digit[1];
2212 if (digit[0]<10) ftxt << " " << digit[0] << endl;
2213 else if (digit[0]>=10 && digit[0]<100) ftxt << " " << digit[0] << endl;
2214 else if (digit[0]>=100 && digit[0]<1000) ftxt << " " << digit[0] << endl;
2215 else ftxt << " " << digit[3] << endl;
2216 }
2217 */
2218 AliDebug(2, Form(" Raw data reading %2d -> %2d %1d %2d %1d %2d (%d, %d, %d)",
2219 last,
2220 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[4], detectorIndex[3],
2221 digit[0], digit[1], digit[3]));
2222
2223 tofRawDatum = 0;
2224 } // while loop
2225
2226 clonesRawData->Clear();
2227
2228 } // DDL Loop
2229
2230 //if (fVerbose==2) ftxt.close();
2231
2232 if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
2233
2234 Int_t nSDigits = sdigitsArray->GetEntries();
2235 AliDebug(1, Form("Got %d TOF sdigits", nSDigits));
2236 AliDebug(1, Form("Execution time to read TOF raw data and fill TOF sdigit tree : R:%.2fs C:%.2fs",
2237 stopwatch.RealTime(),stopwatch.CpuTime()));
2238
2239}