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 **************************************************************************/
16 ///////////////////////////////////////////////////////////////////////////////
18 // Reads ACORDE DDL raw data from raw data stream //
20 ///////////////////////////////////////////////////////////////////////////////
22 #include "AliACORDERawStream.h"
23 #include "AliRawReader.h"
26 #include "AliRawReaderRoot.h"
28 ClassImp(AliACORDERawStream)
30 //_____________________________________________________________________________
31 AliACORDERawStream::AliACORDERawStream(AliRawReader* rawReader) :
32 fRawReader(rawReader),
38 // Create an object to read ACORDE raw data
40 // Created: 04 Feb 2008 Mario Sitta
43 fWord[0] = fWord[1] = fWord[2] = fWord[3] = 0;
45 // Select the raw data corresponding to the ACORDE detector id
46 // fRawReader->Reset();
47 AliDebug(1,Form("Selecting raw data for detector %d",AliDAQ::DetectorID("ACORDE")));
48 fRawReader->Select("ACORDE");
52 //_____________________________________________________________________________
53 AliACORDERawStream::AliACORDERawStream(const AliACORDERawStream &r) :
55 fRawReader(r.fRawReader),
60 // Simple copy constructor
61 ((AliACORDERawStream &) r).Copy(*this);
64 //_____________________________________________________________________________
65 AliACORDERawStream::~AliACORDERawStream()
70 //_____________________________________________________________________________
71 AliACORDERawStream &AliACORDERawStream::operator=(const AliACORDERawStream &r)
74 if (this != &r) ((AliACORDERawStream &) r).Copy(*this);
78 //_____________________________________________________________________________
79 void AliACORDERawStream::Reset()
82 // Reset the raw stream parameters
88 // Created: 04 Feb 2008 Mario Sitta
94 if (fRawReader) fRawReader->Reset();
97 //_____________________________________________________________________________
98 Bool_t AliACORDERawStream::Next()
101 // Read next digit from the ACORDE raw data stream;
102 // return kFALSE in case of error or no digits left
108 // Created: 04 Feb 2008 Mario Sitta
111 if (fPosition >= 0) return kFALSE;
113 if (!fRawReader->ReadNextData(fData)) return kFALSE;
114 if (fRawReader->GetDataSize() == 0) return kFALSE;
116 fDataSize = fRawReader->GetDataSize();
117 if (fDataSize != 16) {
118 fRawReader->AddFatalErrorLog(kRawDataSizeErr,Form("size %d != 16",fDataSize));
119 AliWarning(Form("Wrong ACORDE raw data size: %d, expected 16 bytes!",fDataSize));
125 for (Int_t i=0; i<4; i++)
126 fWord[i] = GetNextWord();
131 //_____________________________________________________________________________
132 UInt_t AliACORDERawStream::GetWord(Int_t index) const
135 // Returns the ``index'' word from ACORDE raw data.
138 // index : the index of the requested word
140 // word : the 32 bit ``index'' word
142 // Created: 12 Feb 2008 Mario Sitta
145 if (index < 0 || index > 3) {
146 AliWarning(Form("Wrong word index %d, returning 0",index));
154 //_____________________________________________________________________________
155 UInt_t AliACORDERawStream::GetNextWord()
158 // Returns the next 32 bit word inside the raw data payload.
159 // The method is supposed to be endian (platform) independent.
164 // word : a 32 bit word containing the data
166 // Created: 04 Feb 2008 Mario Sitta
169 if (!fData || fPosition < 0)
170 AliFatal("Raw data payload buffer is not yet initialized !");
173 word |= fData[fPosition++];
174 word |= fData[fPosition++] << 8;
175 word |= fData[fPosition++] << 16;
176 word |= fData[fPosition++] << 24;
181 //_____________________________________________________________________________
183 Int_t AliACORDERawStream::GetNEvents(char* fileName)
185 // Returns the Total Number of Events recorded by ACORDE
186 // Note: it may be a better way to do it !!
187 // Input: fileName to Analyze
188 // Output: Number of Total Events (fNEvents) in fileName
189 // Created: 25 March 2008
190 // Author: Mario Rodriguez Cahuantzi <mrodrigu@mail.cern.ch>
192 AliRawReader* rCount = new AliRawReaderRoot(fileName);
197 if (!rCount->NextEvent()) DyM=1;
204 //____________________________________________________________________________