]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - ACORDE/AliACORDERawReader.cxx
fix minor bug: add task argument was not passed to tak
[u/mrichter/AliRoot.git] / ACORDE / AliACORDERawReader.cxx
... / ...
CommitLineData
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// Authors:
17// Mario Rodriguez Cahuantzi <mrodrigu@mail.cern.ch>
18// Arturo Fernandez Tellez <afernan@mail.cern.ch>
19//____________________________________________________________________
20//
21// ACORDE
22// Class for reading ACORDE RAW data in TOF data format
23//
24#include "AliACORDERawReader.h"
25#include "AliBitPacking.h"
26#include "TBits.h"
27
28#include <Riostream.h>
29#include "TMath.h"
30#include "TH1F.h"
31#include "TArrayI.h"
32#include "AliLog.h"
33
34ClassImp(AliACORDERawReader)
35
36AliACORDERawReader::AliACORDERawReader (AliRawReader *rawReader, Bool_t isOnline):
37 TNamed("ACORDERawReader","read raw ACORDE data"),
38 fRawReader(rawReader),
39 fData(NULL),
40 fPosition(0),
41 fIsOnline(isOnline),
42 fDataSize(0)
43{
44
45 fWord[0] = fWord[1] = fWord[2] = fWord[3] = 0;
46
47}
48//_____________________________________________________________________________
49 AliACORDERawReader::~AliACORDERawReader ()
50{
51}
52//_____________________________________________________________________________
53Bool_t AliACORDERawReader::Next()
54{
55
56// Read next digit from the ACORDE raw data stream;
57// return kFALSE in case of error or no digits left
58
59 if (fPosition >= 0) return kFALSE;
60
61 if (!fRawReader->ReadNextData(fData)) return kFALSE;
62 if (fRawReader->GetDataSize() == 0) return kFALSE;
63
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));
68 return kFALSE;
69 }
70
71 fPosition = 0;
72
73 for (Int_t i=0; i<4; i++)
74 fWord[i] = GetNextWord();
75
76 return kTRUE;
77
78
79}
80//_____________________________________________________________________________
81Int_t AliACORDERawReader::GetPosition()
82{
83 // Sets the position in the
84 // input stream
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;
88}
89//_____________________________________________________________________________
90UInt_t AliACORDERawReader::GetNextWord()
91{
92
93 // Returns the next 32 bit word inside the raw data payload.
94 // The method is supposed to be endian (platform) independent.
95
96
97 if (!fData || fPosition < 0)
98 AliFatal("Raw data payload buffer is not yet initialized !");
99
100 UInt_t word = 0;
101 word |= fData[fPosition++];
102 word |= fData[fPosition++] << 8;
103 word |= fData[fPosition++] << 16;
104 word |= fData[fPosition++] << 24;
105
106 return word;
107
108
109}
110