/* $Id$ */
-//////////////////////////////////////////////////////////////////////
+//____________________________________________________________________
//
// Buffer to read RAW ALTRO FMD format from a AliRawReader
//
-// Currently, I had to overload the Next member function and introduce
-// my own members fMyData, fMyPosition, fMyCount, and fMyBunchLength.
-// The reason is, that we can use the fMyCount to determine the
-// sampling rate used in the ALTRO. However,
-// AliAltroBuffer::fCount is private, so we can not access it.
-//
-// If it wasn't I'd implement Next as
//
-// Bool_t
-// AliFMDRawStreamer::Next()
-// {
-// if (AliAltroRawStreamer::Next()) {
-// if (fPrevPad != fPad)
-// fSampleRate = (fCount - 2) / 128;
-// return kTRUE;
-// }
-// return kFALSE;
-// }
-//
-//////////////////////////////////////////////////////////////////////
-#ifndef ALIFMDRAWSTREAM_H
-# include "AliFMDRawStream.h"
-#endif
-#ifndef ALIRAWREADER_H
-# include "AliRawReader.h"
-#endif
-#ifndef __IOSTREAM__
-# include <iostream>
-#endif
+#include "AliFMDRawStream.h" // ALIFMDRAWSTREAM_H
+#include "AliRawReader.h" // ALIRAWREADER_H
//____________________________________________________________________
ClassImp(AliFMDRawStream);
//____________________________________________________________________
-AliFMDRawStream::AliFMDRawStream(AliRawReader* reader)
+AliFMDRawStream::AliFMDRawStream(AliRawReader* reader, UShort_t sampleRate)
: AliAltroRawStream(reader),
- // fMyData(0),
- // fMyPosition(0),
- // fMyCount(0),
- // fMyBunchLength(0),
- fPrevTime(-1)
-{}
-
-
+ fSampleRate(sampleRate),
+ fPrevTime(-1),
+ fExplicitSampleRate(kFALSE)
+{
+ if (fSampleRate > 0) fExplicitSampleRate = kTRUE;
+}
//_____________________________________________________________________________
Bool_t
// returns kFALSE if there is no digit left
fPrevTime = fTime;
if (AliAltroRawStream::Next()) {
- if (fPrevPad != fPad) {
+ if (!fExplicitSampleRate && fPrevPad != fPad)
fSampleRate = fTimeBunch / 128;
-#if 0
- std::cout << "Setting Sample rate to (" << fTimeBunch << "/"
- << 128 << "=" << fSampleRate << std::endl;
-#endif
- }
return kTRUE;
}
return kFALSE;
}
-#if 0
-//_____________________________________________________________________________
-Bool_t
-AliFMDRawStream::Next()
-{
- // read the next raw digit
- // returns kFALSE if there is no digit left
- fPrevSector = fSector;
- fPrevRow = fRow;
- fPrevPad = fPad;
- fPrevTime = fTime;
-
- while (fMyCount == 0) { // next trailer
- if (fMyPosition <= 0) { // next payload
- do {
- if (!fRawReader->ReadNextData(fMyData)) return kFALSE;
- } while (fRawReader->GetDataSize() == 0);
-
- fMyPosition = (fRawReader->GetDataSize() * 8) / 10;
- while (Get10BitWord(fMyData, fMyPosition-1) == 0x2AA) fMyPosition--;
- }
-
- if (fMyPosition > 0) {
- // read the trailer
- if (fMyPosition <= 4) {
- Error("Next", "could not read trailer");
- return kFALSE;
- }
- fSector = Get10BitWord(fMyData, --fMyPosition);
- fRow = Get10BitWord(fMyData, --fMyPosition);
- fPad = Get10BitWord(fMyData, --fMyPosition);
- fMyCount = Get10BitWord(fMyData, --fMyPosition);
-
- fMyPosition -= (4 - (fMyCount % 4)) % 4; // skip fill words
- fMyBunchLength = 0;
-
- // Set the sample rate, based on the number of samples in the
- // channel.
- fSampleRate = (fMyCount - 2) / 128;
-#if 0
- std::cout << "Setting Sample rate to (" << fMyCount << " - 2)/"
- << 128 << "=" << fSampleRate << std::endl;
-#endif
- }
- }
-
- if (fMyBunchLength == 0) {
- if (fMyPosition <= 0) {
- Error("Next", "could not read bunch length");
- return kFALSE;
- }
- fMyBunchLength = Get10BitWord(fMyData, --fMyPosition) - 2;
- fMyCount--;
-
-
- if (fMyPosition <= 0) {
- Error("Next", "could not read time bin");
- return kFALSE;
- }
- fTime = Get10BitWord(fMyData, --fMyPosition);
- fMyCount--;
- } else {
- fTime--;
- }
-
- if (fMyPosition <= 0) {
- Error("Next", "could not read sample amplitude");
- return kFALSE;
- }
- fSignal = Get10BitWord(fMyData, --fMyPosition);
- fMyCount--;
- fMyBunchLength--;
-
- return kTRUE;
-}
-
-//_____________________________________________________________________________
-UShort_t
-AliFMDRawStream::Get10BitWord(UChar_t* buffer, Int_t position) const
-{
-// return a word in a 10 bit array as an UShort_t
-
- Int_t iBit = position * 10;
- Int_t iByte = iBit / 8;
- Int_t shift = iBit % 8;
-// return ((buffer[iByte+1] * 256 + buffer[iByte]) >> shift) & 0x03FF;
-
- // recalculate the byte numbers and the shift because
- // the raw data is written as integers where the high bits are filled first
- // -> little endian is assumed here !
- Int_t iByteHigh = 4 * (iByte / 4) + 3 - (iByte % 4);
- iByte++;
- Int_t iByteLow = 4 * (iByte / 4) + 3 - (iByte % 4);
- shift = 6 - shift;
- return ((buffer[iByteHigh] * 256 + buffer[iByteLow]) >> shift) & 0x03FF;
-}
-#endif
//_____________________________________________________________________________
//
// EOF