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