]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TOF/AliTOFRawStream.cxx
Minor changes
[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
15ec34b9 434//_____________________________________________________________________________
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
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));
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
38f24f3f 1182//----------------------------------------------------------------------------
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
d0eb8f39 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
7813bb1a 1248//----------------------------------------------------------------------------
1249void AliTOFRawStream::EquipmentId2VolumeId(AliTOFHitData *hitData, Int_t *volume) const
1250{
1251 EquipmentId2VolumeId(hitData->GetDDLID(),hitData->GetSlotID(),hitData->GetChain(),hitData->GetTDC(),hitData->GetChan(),volume);
1252}
d0eb8f39 1253//----------------------------------------------------------------------------
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
125f7e0b 1274 for (Int_t ii=0; ii<5; ii++) volume[ii] = -1;
1275
d0eb8f39 1276 Int_t iDDL = GetDDLnumberPerSector(nDDL);
1277
125f7e0b 1278 if (iDDL%2==1 && nTRM==3 && nTDC/3>0) { // Signal not coming from a TOF pad but -probably- from a TOF OR signal
1279 //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);
1280 return;
1281 }
1282
d0eb8f39 1283 Int_t iSector = GetSectorNumber(nDDL);
1284
1285 Int_t iPlate = Equip2VolNplate(iDDL, nTRM, nTDC);
019f6101 1286 if (iPlate==-1) {
a9137e31 1287 /*if (fRawReader)
1288 fRawReader->AddMajorErrorLog(kPlateError,"plate = -1");*/
125f7e0b 1289 printf("Warning -> AliTOFRawStream::EquipmentId2VolumeId: Problems with the plate number (%2d %2d %2d)!\n",
1290 nDDL, nTRM, nTDC);
019f6101 1291 }
d0eb8f39 1292
1293 Int_t iStrip = Equip2VolNstrip(iDDL, nTRM, nTDC);
019f6101 1294 if (iStrip==-1) {
a9137e31 1295 /*if (fRawReader)
1296 fRawReader->AddMajorErrorLog(kStripError,"strip = -1");*/
125f7e0b 1297 printf("Warning -> AliTOFRawStream::EquipmentId2VolumeId: Problems with the strip number (%2d %2d %2d)!\n",
1298 nDDL, nTRM, nTDC);
019f6101 1299 }
d0eb8f39 1300
1301 Int_t iPadAlongTheStrip = Equip2VolNpad(iDDL, iChain, nTDC, iCH);
a9137e31 1302 if (iPadAlongTheStrip==-1) {
1303 /*if (fRawReader)
1304 fRawReader->AddMajorErrorLog(kPadAlongStripError,"pad = -1");*/
125f7e0b 1305 printf("Warning -> AliTOFRawStream::EquipmentId2VolumeId: Problems with the pad number along the strip (%2d %1d %2d %1d)!\n",
1306 nDDL, iChain, nTDC, iCH);
019f6101 1307 }
13d6bff9 1308
d0eb8f39 1309 Int_t iPadX = (Int_t)(iPadAlongTheStrip/(Float_t(AliTOFGeometry::NpadZ())));
1310 Int_t iPadZ = iPadAlongTheStrip%AliTOFGeometry::NpadZ();
38f24f3f 1311
1312 //Int_t iPadX = (Int_t)(Equip2VolNpad(iDDL, iChain, nTDC, iCH)/(Float_t(AliTOFGeometry::NpadZ())));
1313 //Int_t iPadZ = Equip2VolNpad(iDDL, iChain, nTDC, iCH)%AliTOFGeometry::NpadZ();
1314
1315 //Int_t iPadX = Equip2VolNpadX(iDDL, iChain, nTDC, iCH);
1316 //Int_t iPadZ = Equip2VolNpadZ(iDDL, iChain, nTDC, iCH);
1317
d0eb8f39 1318 volume[0] = iSector;
1319 volume[1] = iPlate;
1320 volume[2] = iStrip;
1321 volume[3] = iPadX;
1322 volume[4] = iPadZ;
571dda3d 1323
1324}
7813bb1a 1325//-----------------------------------------------------------------------------
019f6101 1326Bool_t AliTOFRawStream::DecodeDDL(Int_t nDDLMin, Int_t nDDLMax, Int_t verbose = 0) {
1327 //
1328 // To decode raw data for DDL number in [nDDLmin; nDDLmax]
1329 //
1330
7813bb1a 1331 //check and fix valid DDL range
019f6101 1332 if (nDDLMin < 0){
1333 nDDLMin = 0;
1334 fRawReader->AddMinorErrorLog(kDDLMinError);
1335 AliWarning("Wrong DDL range: setting first DDL ID to 0");
7813bb1a 1336 }
019f6101 1337 if (nDDLMax > 71){
1338 nDDLMax = 71;
1339 fRawReader->AddMinorErrorLog(kDDLMaxError);
1340 AliWarning("Wrong DDL range: setting last DDL ID to 71");
7813bb1a 1341 }
1342
1343 //select required DDLs
019f6101 1344 fRawReader->Select("TOF", nDDLMin, nDDLMax);
7813bb1a 1345
1346 if (verbose)
019f6101 1347 AliInfo(Form("Selected TOF DDL range: %d-%d", nDDLMin, nDDLMax));
7813bb1a 1348
2fd622fa 1349 return(Decode(verbose));
1350}
1351//-----------------------------------------------------------------------------
019f6101 1352Bool_t AliTOFRawStream::Decode(Int_t verbose = 0) {
1353 //
1354 // New decoder method
1355 //
1356
2fd622fa 1357 Int_t currentEquipment;
1358 Int_t currentDDL;
dd824655 1359 const AliRawDataHeader *currentCDH;
2fd622fa 1360
1361 //pointers
1362 UChar_t *data = 0x0;
1363
7813bb1a 1364 //loop and read DDL headers
1365 while(fRawReader->ReadHeader()){
1366
1367 //memory leak prevention (actually data should be always 0x0 here)
1368 if (data != 0x0)
1369 delete [] data;
1370
1371 //get equipment infos
1372 currentEquipment = fRawReader->GetEquipmentId();
1373 currentDDL = fRawReader->GetDDLID();
dd824655 1374 currentCDH = fRawReader->GetDataHeader();
7813bb1a 1375 const Int_t kDataSize = fRawReader->GetDataSize();
1376 const Int_t kDataWords = kDataSize / 4;
1377 data = new UChar_t[kDataSize];
1378
1379 if (verbose)
1380 AliInfo(Form("Found equipment # %d header (DDL # %d): %d bytes (%d words)", currentEquipment, currentDDL, kDataSize, kDataWords));
1381
1382 if (verbose)
1383 AliInfo(Form("Reading equipment #%d (DDL # %d) data...", currentEquipment, currentDDL));
1384
1385 //read equipment payload
1386 if (!fRawReader->ReadNext(data, kDataSize))
1387 {
019f6101 1388 fRawReader->AddMajorErrorLog(kDDLdataReading);
7813bb1a 1389 if (verbose)
019f6101 1390 AliWarning("Error while reading DDL data. Go to next equipment");
7813bb1a 1391 delete [] data;
1392 data = 0x0;
1393 continue;
1394 }
1395
1396 if (verbose)
1397 AliInfo(Form("Equipment # %d (DDL # %d) data has been readed", currentEquipment, currentDDL));
1398
1399
1400 //set up the decoder
1401 fDecoder->SetVerbose(verbose);
d35d0ea0 1402 fDecoder->SetDataBuffer(&fDataBuffer[currentDDL]);
1403 fDecoder->SetPackedDataBuffer(&fPackedDataBuffer[currentDDL]);
7813bb1a 1404
1405 //start decoding
dd824655 1406 if (fDecoder->Decode((UInt_t *)data, kDataWords, currentCDH) == kTRUE) {
019f6101 1407 fRawReader->AddMajorErrorLog(kDDLDecoder,Form("DDL # = %d",currentDDL));
1408 AliWarning(Form("Error while decoding DDL # %d: decoder returned with errors", currentDDL));
1409 }
7813bb1a 1410
1411 delete [] data;
1412 data = 0x0;
1413 }
1414
1415 //reset reader
1416 fRawReader->Reset();
1417
1418 if (verbose)
1419 AliInfo("All done");
1420
1421 return kFALSE;
1422
1423}
1424//---------------------------------------------------------------------------
1425void
1426AliTOFRawStream::ResetBuffers()
1427{
19eefa2b 1428 //
1429 // To reset the buffers
1430 //
1431
7813bb1a 1432 for (Int_t iDDL = 0; iDDL < AliDAQ::NumberOfDdls("TOF"); iDDL++){
1433 ResetDataBuffer(iDDL);
1434 ResetPackedDataBuffer(iDDL);
1435 }
1436}
1437
1438//---------------------------------------------------------------------------
1439Bool_t
1440AliTOFRawStream::LoadRawDataBuffers(Int_t indexDDL, Int_t verbose)
1441{
19eefa2b 1442 //
1443 // To load the buffers
1444 //
1445
7813bb1a 1446 fTOFrawData->Clear();
1447 fPackedDigits = 0;
1448
1449 if (verbose > 0)
1450 AliInfo(Form("Decoding raw data for DDL # %d ...", indexDDL));
1451
1452 if (DecodeDDL(indexDDL, indexDDL, verbose) != 0){ //decode DDL
019f6101 1453 fRawReader->AddMajorErrorLog(kDDLDecoder,Form("DDL # = %d",indexDDL));
1454 AliWarning(Form("Error while decoding DDL # %d", indexDDL));
7813bb1a 1455 return kTRUE;
1456 }
1457
1458 if (verbose > 0)
d35d0ea0 1459 AliInfo(Form("Done. %d packed %s been found.", fPackedDataBuffer[indexDDL].GetEntries(), fPackedDataBuffer[indexDDL].GetEntries() > 1 ? "hits have" : "hit has"));
7813bb1a 1460
1461 AliTOFHitData *hitData; //hit data pointer
1462
1463 if (verbose > 0)
1464 AliInfo("Filling TClonesArray ...");
1465
dd824655 1466 if (verbose > 0)
1467 if (fgApplyBCCorrections) {
1468 AliInfo("Apply nominal DDL BC time-shift correction");
1469 AliInfo("Apply deltaBC time-shift correction");
1470 }
1471
7813bb1a 1472 //loop over DDL packed hits
d35d0ea0 1473 for (Int_t iHit = 0; iHit < fPackedDataBuffer[indexDDL].GetEntries(); iHit++){
1474 hitData = fPackedDataBuffer[indexDDL].GetHit(iHit); //get hit data
7813bb1a 1475 Int_t hitACQ = hitData->GetACQ();
1476 Int_t hitPS = hitData->GetPS();
1477 Int_t hitSlotID = hitData->GetSlotID();
1478 Int_t hitChain = hitData->GetChain();
1479 Int_t hitTDC = hitData->GetTDC();
1480 Int_t hitChan = hitData->GetChan();
7813bb1a 1481 Int_t hitTimeBin = hitData->GetTimeBin();
7813bb1a 1482 Int_t hitTOTBin = hitData->GetTOTBin();
dd824655 1483
1484 if (fgApplyBCCorrections) {
1485 /* DDL BC shift time correction */
1486 hitTimeBin += fgkddlBCshift[indexDDL];
1487 /* deltaBC shift time correction */
1488 hitTimeBin += hitData->GetDeltaBunchID();
1489 }
1490
1491 Int_t hitLeading = hitData->GetTimeBin();
bf33f8f0 1492 Int_t hitTrailing = -1;
1493 Int_t hitError = -1;
7813bb1a 1494
1495 TClonesArray &arrayTofRawData = *fTOFrawData;
bf33f8f0 1496 new (arrayTofRawData[fPackedDigits++]) AliTOFrawData(hitSlotID, hitChain, hitTDC, hitChan, hitTimeBin, hitTOTBin, hitLeading, hitTrailing, hitPS, hitACQ, hitError);
7813bb1a 1497 }
1498
1499 if (verbose > 0)
1500 AliInfo("Done.");
1501
1502 if (verbose > 0)
1503 AliInfo("Resetting buffers ...");
1504
d35d0ea0 1505 fDataBuffer[indexDDL].Reset();
1506 fPackedDataBuffer[indexDDL].Reset();
7813bb1a 1507
1508 if (verbose > 0)
1509 AliInfo("Done.");
1510
1511 return kFALSE;
1512}
1513
5f72a2bf 1514//---------------------------------------------------------------------------
1515void AliTOFRawStream::Geant2EquipmentId(Int_t vol[], Int_t eqId[])
1516{
1517 //
1518 // To convert:
1519 // nSector number -vol[0]- (variable in [0,17])
1520 // nPlate number -vol[1]- (variable in [0, 5])
1521 // nStrip number -vol[2]- (variable in [0,14/18])
1522 // nPadZ number -vol[3]- (variable in [0, 1])
1523 // nPadX number -vol[4]- (variable in [0,47])
1524 // in:
e1d95075 1525 // nDDL -eqId[0]- (variable in [0;71]) -> number of the DDL
1526 // nTRM -eqId[1]- (variable in [3;12]) -> number of the TRM
1527 // nTDC -eqId[2]- (variable in [0;14]) -> number of the TDC
1528 // nChain -eqId[3]- (variable in [0; 1]) -> number of the chain
1529 // nChannel -eqId[4]- (variable in [0; 8]) -> number of the channel
5f72a2bf 1530 //
1531
1532 eqId[0] = Geant2DDL(vol);
1533 eqId[1] = Geant2TRM(vol);
1534 eqId[2] = Geant2TDC(vol);
1535 eqId[3] = Geant2Chain(vol);
1536 eqId[4] = Geant2Channel(vol);
1537
1538}
1539
1540//---------------------------------------------------------------------------
1541Int_t AliTOFRawStream::Geant2DDL(Int_t vol[])
1542{
1543 //
1544 // To convert:
1545 // nSector number -vol[0]- (variable in [0,17])
1546 // nPlate number -vol[1]- (variable in [0, 5])
1547 // nStrip number -vol[2]- (variable in [0,14/18])
1548 // nPadZ number -vol[3]- (variable in [0, 1])
1549 // nPadX number -vol[4]- (variable in [0,47])
1550 // in:
e1d95075 1551 // nDDL (variable in [0;71]) -> number of the DDL
5f72a2bf 1552 //
1553
1554
1555 Int_t iDDL = -1;
1556
1557 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
1558 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
1559 return iDDL;
1560 }
1561 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
1562 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
1563 return iDDL;
1564 }
1565 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
1566 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
1567 return iDDL;
1568 }
1569 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ())
1570 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
1571 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX())
1572 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
1573 if ( vol[3]>=AliTOFGeometry::NpadZ() ) {
1574 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
1575 return iDDL;
1576 }
1577
1578 Int_t nSector = vol[0];
1579 Int_t nPlate = vol[1];
1580 Int_t nStrip = vol[2];
1581 Int_t nPadX = vol[4];
1582
1583 if ( nPadX<24 && ( nPlate==0 || nPlate==1 || (nPlate==2 && nStrip<7) ) )
1584 iDDL = 0;
1585 else if ( nPadX>=24 && ( nPlate==0 || nPlate==1 || (nPlate==2 && nStrip<8) ) )
1586 iDDL = 1;
1587 else if ( nPadX>=24 && ( nPlate==3 || nPlate==4 || (nPlate==2 && nStrip>7) ) )
1588 iDDL = 2;
1589 else if ( nPadX<24 && ( nPlate==3 || nPlate==4 || (nPlate==2 && nStrip>6) ) )
1590 iDDL = 3;
1591
1592 return 4*nSector+iDDL;
1593
1594}
1595
1596//---------------------------------------------------------------------------
1597Int_t AliTOFRawStream::Geant2TRM(Int_t vol[])
1598{
1599 //
1600 // To convert:
1601 // nSector number -vol[0]- (variable in [0,17])
1602 // nPlate number -vol[1]- (variable in [0, 5])
1603 // nStrip number -vol[2]- (variable in [0,14/18])
1604 // nPadZ number -vol[3]- (variable in [0, 1])
1605 // nPadX number -vol[4]- (variable in [0,47])
1606 // in:
1607 // nTRM (variable in [3;12]) -> number of the TRM slot
1608 //
1609
1610 Int_t nTRM = -1;
1611
1612 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
1613 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
1614 return nTRM;
1615 }
1616 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
1617 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
1618 return nTRM;
1619 }
1620 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
1621 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
1622 return nTRM;
1623 }
1624 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ()) {
1625 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
1626 return nTRM;
1627 }
1628 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX()) {
1629 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
1630 return nTRM;
1631 }
1632
1633 if ( vol[3]>=AliTOFGeometry::NpadZ() )
1634 {
1635 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
1636 return nTRM;
1637 }
1638
1639 Int_t nPlate = vol[1];
1640 Int_t nStrip = vol[2];
1641
1642 Int_t iDDL = Geant2DDL(vol)%4;
1643
1644 switch (iDDL) {
1645
1646 case 0:
1647
1648 if (nPlate==0) {
1649 if (nStrip<= 4) nTRM = 4;
1650 else if (nStrip> 4 && nStrip<= 9) nTRM = 5;
1651 else if (nStrip> 9 && nStrip<=14) nTRM = 6;
1652 else if (nStrip>14) nTRM = 7;
1653 }
1654 else if (nPlate==1) {
1655 if (nStrip== 0) nTRM = 7;
1656 else if (nStrip> 0 && nStrip<= 5) nTRM = 8;
1657 else if (nStrip> 5 && nStrip<=10) nTRM = 9;
1658 else if (nStrip>10 && nStrip<=15) nTRM = 10;
1659 else if (nStrip>15) nTRM = 11;
1660 }
1661 else if (nPlate==2) {
1662 if (nStrip<= 1) nTRM = 11;
1663 else if (nStrip> 1 && nStrip< 7) nTRM = 12;
1664 }
1665
1666 break;
1667 case 1:
1668
1669 if (nPlate==0) {
1670 if (nStrip== 0) nTRM = 3;
1671 else if (nStrip> 0 && nStrip<= 5) nTRM = 4;
1672 else if (nStrip> 5 && nStrip<=10) nTRM = 5;
1673 else if (nStrip>10 && nStrip<=15) nTRM = 6;
1674 else if (nStrip>15) nTRM = 7;
1675 }
1676 else if (nPlate==1) {
1677 if (nStrip<=1) nTRM = 7;
1678 else if (nStrip> 1 && nStrip<= 6) nTRM = 8;
1679 else if (nStrip> 6 && nStrip<=11) nTRM = 9;
1680 else if (nStrip>11 && nStrip<=16) nTRM = 10;
1681 else if (nStrip>16) nTRM = 11;
1682 }
1683 else if (nPlate==2) {
1684 if (nStrip<= 2) nTRM = 11;
1685 else if (nStrip> 2 && nStrip<= 7) nTRM = 12;
1686 }
1687
1688 break;
1689 case 2:
1690
1691 if (nPlate==4) {
1692 if (nStrip>=14) nTRM = 4;
1693 else if (nStrip<14 && nStrip>= 9) nTRM = 5;
1694 else if (nStrip< 9 && nStrip>= 4) nTRM = 6;
1695 else if (nStrip< 4) nTRM = 7;
1696 }
1697 else if (nPlate==3) {
1698 if (nStrip==18) nTRM = 7;
1699 else if (nStrip<18 && nStrip>=13) nTRM = 8;
1700 else if (nStrip<13 && nStrip>= 8) nTRM = 9;
1701 else if (nStrip< 8 && nStrip>= 3) nTRM = 10;
1702 else if (nStrip< 3) nTRM = 11;
1703 }
1704 else if (nPlate==2) {
1705 if (nStrip>=13) nTRM = 11;
1706 else if (nStrip<13 && nStrip>= 8) nTRM = 12;
1707 }
1708
1709 break;
1710 case 3:
1711
1712 if (nPlate==4) {
1713 if (nStrip==18) nTRM = 3;
1714 else if (nStrip<18 && nStrip>=13) nTRM = 4;
1715 else if (nStrip<13 && nStrip>= 8) nTRM = 5;
1716 else if (nStrip< 8 && nStrip>= 3) nTRM = 6;
1717 else if (nStrip< 3) nTRM = 7;
1718 }
1719 else if (nPlate==3) {
1720 if (nStrip>=17) nTRM = 7;
1721 else if (nStrip<17 && nStrip>=12) nTRM = 8;
1722 else if (nStrip<12 && nStrip>= 7) nTRM = 9;
1723 else if (nStrip< 7 && nStrip>= 2) nTRM = 10;
1724 else if (nStrip< 2) nTRM = 11;
1725 }
1726 else if (nPlate==2) {
1727 if (nStrip>=12) nTRM = 11;
1728 else if (nStrip <12 && nStrip>= 7) nTRM = 12;
1729 }
1730
1731 break;
1732
1733 }
1734
1735 return nTRM;
1736
1737}
1738
1739//---------------------------------------------------------------------------
1740Int_t AliTOFRawStream::Geant2TDC(Int_t vol[])
1741{
1742 //
1743 // To convert:
1744 // nSector number -vol[0]- (variable in [0,17])
1745 // nPlate number -vol[1]- (variable in [0, 5])
1746 // nStrip number -vol[2]- (variable in [0,14/18])
1747 // nPadZ number -vol[3]- (variable in [0, 1])
1748 // nPadX number -vol[4]- (variable in [0,47])
1749 // in:
1750 // nTDC (variable in [0;14]) -> number of the TDC
1751 //
1752
1753 Int_t nTDC = -1;
1754
1755 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
1756 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
1757 return nTDC;
1758 }
1759 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
1760 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
1761 return nTDC;
1762 }
1763 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
1764 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
1765 return nTDC;
1766 }
1767 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ())
1768 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
1769 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX())
1770 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
1771 if ( vol[3]>=AliTOFGeometry::NpadZ() ) {
1772 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
1773 return nTDC;
1774 }
1775
1776 Int_t nPlate = vol[1];
1777 Int_t nStrip = vol[2];
1778 Int_t iPadX = vol[4];
1779
1780 Int_t iDDL = Geant2DDL(vol)%4;
1781
1782 switch (iDDL) {
1783
1784 case 0:
1785
1786 if (nPlate==0) {
1787 if (nStrip<= 4) nTDC = (3*(nStrip)+2-(iPadX/4)%3);
1788 else if (nStrip> 4 && nStrip<= 9) nTDC = (3*(nStrip- 5)+2-(iPadX/4)%3);
1789 else if (nStrip> 9 && nStrip<=14) nTDC = (3*(nStrip-10)+2-(iPadX/4)%3);
1790 else if (nStrip>14) nTDC = (3*(nStrip-15)+2-(iPadX/4)%3);
1791 }
1792 else if (nPlate==1) {
1793 if (nStrip== 0) nTDC = (3*(nStrip+ 4)+2-(iPadX/4)%3);
1794 else if (nStrip> 0 && nStrip<= 5) nTDC = (3*(nStrip- 1)+2-(iPadX/4)%3);
1795 else if (nStrip> 5 && nStrip<=10) nTDC = (3*(nStrip- 6)+2-(iPadX/4)%3);
1796 else if (nStrip>10 && nStrip<=15) nTDC = (3*(nStrip-11)+2-(iPadX/4)%3);
1797 else if (nStrip>15) nTDC = (3*(nStrip-16)+2-(iPadX/4)%3);
1798 }
1799 else if (nPlate==2) {
1800 if (nStrip<= 1) nTDC = (3*(nStrip+ 3)+2-(iPadX/4)%3);
1801 else if (nStrip> 1 && nStrip< 7) nTDC = (3*(nStrip- 2)+2-(iPadX/4)%3);
1802 }
1803
1804 break;
1805 case 1:
1806
1807 if (nPlate==0) {
1808 if (nStrip== 0) nTDC = (3*(nStrip)+(iPadX/4)%3);
1809 else if (nStrip> 0 && nStrip<= 5) nTDC = (3*( 5-nStrip)+(iPadX/4)%3);
1810 else if (nStrip> 5 && nStrip<=10) nTDC = (3*(10-nStrip)+(iPadX/4)%3);
1811 else if (nStrip>10 && nStrip<=15) nTDC = (3*(15-nStrip)+(iPadX/4)%3);
1812 else if (nStrip>15) nTDC = (3*(20-nStrip)+(iPadX/4)%3);
1813 }
1814 else if (nPlate==1) {
1815 if (nStrip<= 1) nTDC = (3*( 1-nStrip)+(iPadX/4)%3);
1816 else if (nStrip> 1 && nStrip<= 6) nTDC = (3*( 6-nStrip)+(iPadX/4)%3);
1817 else if (nStrip> 6 && nStrip<=11) nTDC = (3*(11-nStrip)+(iPadX/4)%3);
1818 else if (nStrip>11 && nStrip<=16) nTDC = (3*(16-nStrip)+(iPadX/4)%3);
1819 else if (nStrip>16) nTDC = (3*(21-nStrip)+(iPadX/4)%3);
1820 }
1821 else if (nPlate==2) {
1822 if (nStrip<= 2) nTDC = (3*( 2-nStrip)+(iPadX/4)%3);
1823 else if (nStrip> 2 && nStrip<= 7) nTDC = (3*( 7-nStrip)+(iPadX/4)%3);
1824 }
1825
1826 break;
1827 case 2:
1828
1829 if (nPlate==4) {
1830 if (nStrip>=14) nTDC = (3*(18-nStrip)+((iPadX/4)%3));
1831 else if (nStrip<14 && nStrip>= 9) nTDC = (3*(13-nStrip)+((iPadX/4)%3));
1832 else if (nStrip< 9 && nStrip>= 4) nTDC = (3*( 8-nStrip)+((iPadX/4)%3));
1833 else if (nStrip< 4) nTDC = (3*( 3-nStrip)+((iPadX/4)%3));
1834 }
1835 else if (nPlate==3) {
1836 if (nStrip==18) nTDC = (3*(22-nStrip)+((iPadX/4)%3));
1837 else if (nStrip<18 && nStrip>=13) nTDC = (3*(17-nStrip)+((iPadX/4)%3));
1838 else if (nStrip<13 && nStrip>= 8) nTDC = (3*(12-nStrip)+((iPadX/4)%3));
1839 else if (nStrip< 8 && nStrip>= 3) nTDC = (3*( 7-nStrip)+((iPadX/4)%3));
1840 else if (nStrip< 3) nTDC = (3*( 2-nStrip)+((iPadX/4)%3));
1841 }
1842 else if (nPlate==2) {
1843 if (nStrip>=13) nTDC = (3*(17-nStrip)+((iPadX/4)%3));
1844 else if (nStrip<13 && nStrip>= 8) nTDC = (3*(12-nStrip)+((iPadX/4)%3));
1845 }
1846
1847 break;
1848 case 3:
1849
1850 if (nPlate==4) {
1851 if (nStrip==18) nTDC = (3*(nStrip-18)+2-(iPadX/4)%3);
1852 else if (nStrip<18 && nStrip>=13) nTDC = (3*(nStrip-13)+2-(iPadX/4)%3);
1853 else if (nStrip<13 && nStrip>= 8) nTDC = (3*(nStrip- 8)+2-(iPadX/4)%3);
1854 else if (nStrip< 8 && nStrip>= 3) nTDC = (3*(nStrip- 3)+2-(iPadX/4)%3);
1855 else if (nStrip< 3) nTDC = (3*(nStrip+ 2)+2-(iPadX/4)%3);
1856 }
1857 else if (nPlate==3) {
1858 if (nStrip>=17) nTDC = (3*(nStrip-17)+2-(iPadX/4)%3);
1859 else if (nStrip<17 && nStrip>=12) nTDC = (3*(nStrip-12)+2-(iPadX/4)%3);
1860 else if (nStrip<12 && nStrip>= 7) nTDC = (3*(nStrip- 7)+2-(iPadX/4)%3);
1861 else if (nStrip< 7 && nStrip>= 2) nTDC = (3*(nStrip- 2)+2-(iPadX/4)%3);
1862 else if (nStrip< 2) nTDC = (3*(nStrip+ 3)+2-(iPadX/4)%3);
1863 }
1864 else if (nPlate==2) {
1865 if (nStrip>=12) nTDC = (3*(nStrip-12)+2-(iPadX/4)%3);
1866 else if (nStrip <12 && nStrip>= 7) nTDC = (3*(nStrip- 7)+2-(iPadX/4)%3);
1867 }
1868
1869 break;
1870
1871 }
1872
1873 return nTDC;
1874
1875}
1876
1877//---------------------------------------------------------------------------
1878Int_t AliTOFRawStream::Geant2Chain(Int_t vol[])
1879{
1880 //
1881 // To convert:
1882 // nSector number -vol[0]- (variable in [0,17])
1883 // nPlate number -vol[1]- (variable in [0, 5])
1884 // nStrip number -vol[2]- (variable in [0,14/18])
1885 // nPadZ number -vol[3]- (variable in [0, 1])
1886 // nPadX number -vol[4]- variable in [0,47])
1887 // in:
1888 // nChain (variable in [0; 1]) -> number of the TRM chain
1889 //
1890
1891 Int_t nChain = -1;
1892
1893 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
1894 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
1895 return nChain;
1896 }
1897 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
1898 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
1899 return nChain;
1900 }
1901 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
1902 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
1903 return nChain;
1904 }
1905 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ())
1906 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
1907 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX())
1908 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
1909 if ( vol[3]>=AliTOFGeometry::NpadZ() ) {
1910 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
1911 return nChain;
1912 }
1913
1914 Int_t iPadX = vol[4];
1915
1916 if (iPadX<12 || iPadX>=36) nChain = 0;
1917 else nChain = 1;
1918
1919 return nChain;
1920
1921}
1922
1923//---------------------------------------------------------------------------
1924Int_t AliTOFRawStream::Geant2Channel(Int_t vol[])
1925{
1926 //
1927 // To convert:
1928 // nSector number -vol[0]- (variable in [0,17])
1929 // nPlate number -vol[1]- (variable in [0, 5])
1930 // nStrip number -vol[2]- (variable in [0,14/18])
1931 // nPadZ number -vol[3]- (variable in [0, 1])
1932 // nPadX number -vol[4]- (variable in [0,47])
1933 // in:
1934 // nChannel (variable in [0; 7]) -> number of the TDC channel
1935 //
1936
1937 Int_t nChannel = -1;
1938
1939 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
1940 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
1941 return nChannel;
1942 }
1943 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
1944 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
1945 return nChannel;
1946 }
1947 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
1948 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
1949 return nChannel;
1950 }
1951 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ())
1952 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
1953 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX())
1954 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
1955 if ( vol[3]>=AliTOFGeometry::NpadZ() ) {
1956 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
1957 return nChannel;
1958 }
1959
1960 Int_t iPadZ = vol[3];
1961 Int_t iPadX = vol[4];
1962
1963 Int_t iDDL = Geant2DDL(vol)%4;
1964
1965 switch (iDDL) {
1966
1967 case 0:
1968 nChannel = ((2*(23-iPadX) + (1-iPadZ)))%8;
1969 break;
1970 case 1:
1971 nChannel = ((2*(iPadX-24) + (iPadZ)))%8;
1972 break;
1973 case 2:
1974 nChannel = ((2*(iPadX-24) + (iPadZ)))%8;
1975 break;
1976 case 3:
1977 nChannel = ((2*(23-iPadX) + (1-iPadZ)))%8;
1978 break;
1979 }
1980
1981 return nChannel;
1982
1983}
f472295e 1984
1985//____________________________________________________________________________
1986void AliTOFRawStream::Raw2Digits(AliRawReader* rawReader, TClonesArray* digitsArray)
1987{
1988 //
1989 // Converts raw data to digits for TOF
1990 //
1991
1992 TStopwatch stopwatch;
1993 stopwatch.Start();
1994
1995 //TClonesArray *fDigits = new TClonesArray("AliTOFdigit", 4000);
1996 //digitsTree->Branch("TOF", &fDigits);
1997 TClonesArray &aDigits = *digitsArray;
1998
1999 Int_t inholes = 0;
2000
2001 Clear();
2002 SetRawReader(rawReader);
2003
2004 //ofstream ftxt;
2005 //if (fVerbose==2) ftxt.open("TOFdigitsRead.txt",ios::app);
2006
2007 TClonesArray staticRawData("AliTOFrawData",10000);
2008 staticRawData.Clear();
2009 TClonesArray * clonesRawData = &staticRawData;
2010
2011 Int_t dummy = -1;
2012 Int_t detectorIndex[5] = {-1, -1, -1, -1, -1};
2013 Int_t digit[4];
2014
2015 const Int_t kMaxNumberOfTracksPerDigit = 3;
2016 Int_t tracks[kMaxNumberOfTracksPerDigit];
2017 for (Int_t ii=0; ii<kMaxNumberOfTracksPerDigit; ii++)
2018 tracks[ii] = -1;
2019 Int_t last = -1;
2020
2021 Int_t indexDDL = 0;
2022 Int_t iRawData = 0;
2023 AliTOFrawData *tofRawDatum = 0;
2024 for (indexDDL=0; indexDDL<AliDAQ::NumberOfDdls("TOF"); indexDDL++) {
2025
2026 rawReader->Reset();
2027 if (fNewDecoderVersion) {
2028 AliInfo("Using New Decoder \n");
2029 LoadRawDataBuffers(indexDDL, 0);
2030 }
2031 else
2032 LoadRawData(indexDDL);
2033
2034 clonesRawData = GetRawData();
2035 if (clonesRawData->GetEntriesFast()!=0) AliInfo(Form(" TOF raw data number = %3d", clonesRawData->GetEntriesFast()));
2036 for (iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
2037
2038 tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
2039
2040 //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
2041 if (tofRawDatum->GetTOF()==-1) continue;
2042
2043 EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
2044 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
2045
2046 dummy = detectorIndex[3];
2047 detectorIndex[3] = detectorIndex[4];//padz
2048 detectorIndex[4] = dummy;//padx
2049
2050 digit[0] = tofRawDatum->GetTOF();
2051 digit[1] = tofRawDatum->GetTOT();
2052 digit[2] = tofRawDatum->GetTOT();
2053 digit[3] = -1;//tofRawDatum->GetTOF(); //tofND
2054
2055 dummy = detectorIndex[3];
2056 detectorIndex[3] = detectorIndex[4];//padx
2057 detectorIndex[4] = dummy;//padz
2058
2059 // Do not reconstruct anything in the holes
2060 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
2061 if (detectorIndex[1]==2) { // plate with holes
2062 inholes++;
2063 continue;
2064 }
2065 }
2066
2067 last = digitsArray->GetEntriesFast();
2068 new (aDigits[last]) AliTOFdigit(tracks, detectorIndex, digit);
2069 /*
2070 if (fVerbose==2) {
2071 if (indexDDL<10) ftxt << " " << indexDDL;
2072 else ftxt << " " << indexDDL;
2073 if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM();
2074 else ftxt << " " << tofRawDatum->GetTRM();
2075 ftxt << " " << tofRawDatum->GetTRMchain();
2076 if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC();
2077 else ftxt << " " << tofRawDatum->GetTDC();
2078 ftxt << " " << tofRawDatum->GetTDCchannel();
2079
2080 if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0];
2081 else ftxt << " -> " << detectorIndex[0];
2082 ftxt << " " << detectorIndex[1];
2083 if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2];
2084 else ftxt << " " << detectorIndex[2];
2085 ftxt << " " << detectorIndex[4];
2086 if (detectorIndex[4]<10) ftxt << " " << detectorIndex[3];
2087 else ftxt << " " << detectorIndex[3];
2088
2089 if (digit[1]<10)ftxt << " " << digit[1];
2090 else if (digit[1]>=10 && digit[1]<100) ftxt << " " << digit[1];
2091 else ftxt << " " << digit[1];
2092 if (digit[0]<10) ftxt << " " << digit[0] << endl;
2093 else if (digit[0]>=10 && digit[0]<100) ftxt << " " << digit[0] << endl;
2094 else if (digit[0]>=100 && digit[0]<1000) ftxt << " " << digit[0] << endl;
2095 else ftxt << " " << digit[3] << endl;
2096 }
2097 */
2098 AliDebug(2, Form(" Raw data reading %2d -> %2d %1d %2d %1d %2d (%d, %d, %d)",
2099 last,
2100 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[4], detectorIndex[3],
2101 digit[0], digit[1], digit[3]));
2102
2103 tofRawDatum = 0;
2104 } // loop on tofRawData array
2105
2106 clonesRawData->Clear();
2107
2108 } // DDL Loop
2109
2110 //if (fVerbose==2) ftxt.close();
2111
2112
2113 if (inholes) AliWarning(Form("Raw data in the TOF holes: %d",inholes));
2114
2115 Int_t nDigits = digitsArray->GetEntries();
2116 AliDebug(1, Form("Got %d TOF digits", nDigits));
2117 AliDebug(1, Form("Execution time to read TOF raw data and fill TOF digit tree : R:%.2fs C:%.2fs",
2118 stopwatch.RealTime(),stopwatch.CpuTime()));
2119
2120}
2121
2122//____________________________________________________________________________
2123void AliTOFRawStream::Raw2SDigits(AliRawReader* rawReader, TClonesArray* sdigitsArray)
2124{
2125 //
2126 // Converts raw data to sdigits for TOF
2127 //
2128
2129 TStopwatch stopwatch;
2130 stopwatch.Start();
2131
2132 Int_t inholes = 0;
2133
2134 //if(!GetLoader()->TreeS()) {MakeTree("S"); MakeBranch("S");}
2135 TClonesArray &aSDigits = *sdigitsArray;
2136
2137 Clear();
2138 SetRawReader(rawReader);
2139
2140 //ofstream ftxt;
2141 //if (fVerbose==2) ftxt.open("TOFsdigitsRead.txt",ios::app);
2142
2143 TClonesArray staticRawData("AliTOFrawData",10000);
2144 staticRawData.Clear();
2145 TClonesArray * clonesRawData = &staticRawData;
2146
2147 Int_t dummy = -1;
2148 Int_t detectorIndex[5] = {-1, -1, -1, -1, -1};
2149 Int_t digit[2];
2150 Int_t track = -1;
2151 Int_t last = -1;
2152
2153 Int_t indexDDL = 0;
2154 Int_t iRawData = 0;
2155 AliTOFrawData *tofRawDatum = 0;
2156 for (indexDDL=0; indexDDL<AliDAQ::NumberOfDdls("TOF"); indexDDL++) {
2157
2158 rawReader->Reset();
2159 if (fNewDecoderVersion) {
2160 AliInfo("Using New Decoder \n");
2161 LoadRawDataBuffers(indexDDL, 0);
2162 }
2163 else
2164 LoadRawData(indexDDL);
2165
2166 clonesRawData = GetRawData();
2167 if (clonesRawData->GetEntriesFast()!=0) AliInfo(Form(" TOF raw data number = %3d", clonesRawData->GetEntriesFast()));
2168 for (iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
2169
2170 tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
2171
2172 //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
2173 if (tofRawDatum->GetTOF()==-1) continue;
2174
2175 EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
2176 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
2177
2178 dummy = detectorIndex[3];
2179 detectorIndex[3] = detectorIndex[4];//padz
2180 detectorIndex[4] = dummy;//padx
2181
2182 digit[0] = tofRawDatum->GetTOF();
2183 digit[1] = tofRawDatum->GetTOT();
2184
2185 dummy = detectorIndex[3];
2186 detectorIndex[3] = detectorIndex[4];//padx
2187 detectorIndex[4] = dummy;//padz
2188
2189 // Do not reconstruct anything in the holes
2190 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
2191 if (detectorIndex[1]==2) { // plate with holes
2192 inholes++;
2193 continue;
2194 }
2195 }
2196
2197 last = sdigitsArray->GetEntriesFast();
2198 new (aSDigits[last]) AliTOFSDigit(track, detectorIndex, digit);
2199 /*
2200 if (fVerbose==2) {
2201 if (indexDDL<10) ftxt << " " << indexDDL;
2202 else ftxt << " " << indexDDL;
2203 if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM();
2204 else ftxt << " " << tofRawDatum->GetTRM();
2205 ftxt << " " << tofRawDatum->GetTRMchain();
2206 if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC();
2207 else ftxt << " " << tofRawDatum->GetTDC();
2208 ftxt << " " << tofRawDatum->GetTDCchannel();
2209
2210 if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0];
2211 else ftxt << " -> " << detectorIndex[0];
2212 ftxt << " " << detectorIndex[1];
2213 if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2];
2214 else ftxt << " " << detectorIndex[2];
2215 ftxt << " " << detectorIndex[4];
2216 if (detectorIndex[4]<10) ftxt << " " << detectorIndex[3];
2217 else ftxt << " " << detectorIndex[3];
2218
2219 if (digit[1]<10)ftxt << " " << digit[1];
2220 else if (digit[1]>=10 && digit[1]<100) ftxt << " " << digit[1];
2221 else ftxt << " " << digit[1];
2222 if (digit[0]<10) ftxt << " " << digit[0] << endl;
2223 else if (digit[0]>=10 && digit[0]<100) ftxt << " " << digit[0] << endl;
2224 else if (digit[0]>=100 && digit[0]<1000) ftxt << " " << digit[0] << endl;
2225 else ftxt << " " << digit[3] << endl;
2226 }
2227 */
2228 AliDebug(2, Form(" Raw data reading %2d -> %2d %1d %2d %1d %2d (%d, %d, %d)",
2229 last,
2230 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[4], detectorIndex[3],
2231 digit[0], digit[1], digit[3]));
2232
2233 tofRawDatum = 0;
2234 } // while loop
2235
2236 clonesRawData->Clear();
2237
2238 } // DDL Loop
2239
2240 //if (fVerbose==2) ftxt.close();
2241
2242 if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
2243
2244 Int_t nSDigits = sdigitsArray->GetEntries();
2245 AliDebug(1, Form("Got %d TOF sdigits", nSDigits));
2246 AliDebug(1, Form("Execution time to read TOF raw data and fill TOF sdigit tree : R:%.2fs C:%.2fs",
2247 stopwatch.RealTime(),stopwatch.CpuTime()));
2248
2249}