Line data Source code
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 :
34 12 : ClassImp(AliACORDERawReader)
35 :
36 : AliACORDERawReader::AliACORDERawReader (AliRawReader *rawReader, Bool_t isOnline):
37 0 : TNamed("ACORDERawReader","read raw ACORDE data"),
38 0 : fRawReader(rawReader),
39 0 : fData(NULL),
40 0 : fPosition(0),
41 0 : fIsOnline(isOnline),
42 0 : fDataSize(0)
43 0 : {
44 :
45 0 : fWord[0] = fWord[1] = fWord[2] = fWord[3] = 0;
46 :
47 0 : }
48 : //_____________________________________________________________________________
49 : AliACORDERawReader::~AliACORDERawReader ()
50 0 : {
51 0 : }
52 : //_____________________________________________________________________________
53 : Bool_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 0 : if (fPosition >= 0) return kFALSE;
60 :
61 0 : if (!fRawReader->ReadNextData(fData)) return kFALSE;
62 0 : if (fRawReader->GetDataSize() == 0) return kFALSE;
63 :
64 0 : fDataSize = fRawReader->GetDataSize();
65 0 : if (fDataSize != 16) {
66 0 : fRawReader->AddFatalErrorLog(kRawDataSizeErr,Form("size %d != 16",fDataSize));
67 0 : AliWarning(Form("Wrong ACORDE raw data size: %d, expected 16 bytes!",fDataSize));
68 0 : return kFALSE;
69 : }
70 :
71 0 : fPosition = 0;
72 :
73 0 : for (Int_t i=0; i<4; i++)
74 0 : fWord[i] = GetNextWord();
75 :
76 0 : return kTRUE;
77 :
78 :
79 0 : }
80 : //_____________________________________________________________________________
81 : Int_t AliACORDERawReader::GetPosition()
82 : {
83 : // Sets the position in the
84 : // input stream
85 0 : if (((fRawReader->GetDataSize() * 8) % 32) != 0)
86 0 : AliFatal(Form("Incorrect raw data size ! %d words are found !",fRawReader->GetDataSize()));
87 0 : return (fRawReader->GetDataSize() * 8) / 32;
88 : }
89 : //_____________________________________________________________________________
90 : UInt_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 0 : if (!fData || fPosition < 0)
98 0 : AliFatal("Raw data payload buffer is not yet initialized !");
99 :
100 : UInt_t word = 0;
101 0 : word |= fData[fPosition++];
102 0 : word |= fData[fPosition++] << 8;
103 0 : word |= fData[fPosition++] << 16;
104 0 : word |= fData[fPosition++] << 24;
105 :
106 0 : return word;
107 :
108 :
109 : }
110 :
|