1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 // Mario Rodriguez Cahuantzi <mrodrigu@mail.cern.ch>
18 // Arturo Fernandez Tellez <afernan@mail.cern.ch>
19 //____________________________________________________________________
22 // Class for reading ACORDE RAW data in TOF data format
24 #include "AliACORDERawReader.h"
25 #include "AliBitPacking.h"
28 #include <Riostream.h>
34 ClassImp(AliACORDERawReader)
36 AliACORDERawReader::AliACORDERawReader (AliRawReader *rawReader, Bool_t isOnline):
37 TTask("ACORDERawReader","read raw ACORDE data"),
38 fRawReader(rawReader),
45 fWord[0] = fWord[1] = fWord[2] = fWord[3] = 0;
48 //_____________________________________________________________________________
49 AliACORDERawReader::~AliACORDERawReader ()
52 //_____________________________________________________________________________
53 Bool_t AliACORDERawReader::Next()
56 // Read next digit from the ACORDE raw data stream;
57 // return kFALSE in case of error or no digits left
59 if (fPosition >= 0) return kFALSE;
61 if (!fRawReader->ReadNextData(fData)) return kFALSE;
62 if (fRawReader->GetDataSize() == 0) return kFALSE;
64 fDataSize = fRawReader->GetDataSize();
65 if (fDataSize != 16) {
66 fRawReader->AddFatalErrorLog(kRawDataSizeErr,Form("size %d != 16",fDataSize));
67 AliWarning(Form("Wrong ACORDE raw data size: %d, expected 16 bytes!",fDataSize));
73 for (Int_t i=0; i<4; i++)
74 fWord[i] = GetNextWord();
80 //_____________________________________________________________________________
81 Int_t AliACORDERawReader::GetPosition()
83 // Sets the position in the
85 if (((fRawReader->GetDataSize() * 8) % 32) != 0)
86 AliFatal(Form("Incorrect raw data size ! %d words are found !",fRawReader->GetDataSize()));
87 return (fRawReader->GetDataSize() * 8) / 32;
89 //_____________________________________________________________________________
90 UInt_t AliACORDERawReader::GetNextWord()
93 // Returns the next 32 bit word inside the raw data payload.
\r
94 // The method is supposed to be endian (platform) independent.
97 if (!fData || fPosition < 0)
98 AliFatal("Raw data payload buffer is not yet initialized !");
101 word |= fData[fPosition++];
102 word |= fData[fPosition++] << 8;
103 word |= fData[fPosition++] << 16;
104 word |= fData[fPosition++] << 24;