// and the sample rate should be set explicitly.
//
#include "AliFMDRawStream.h" // ALIFMDRAWSTREAM_H
-#include <AliRawReader.h> // ALIRAWREADER_H
+// #include <AliRawReader.h> // ALIRAWREADER_H
+#include "AliFMDParameters.h"
+// #include <AliLog.h>
+#include "AliFMDDebug.h" // Better debug macros
+// #include <iomanip>
+// #include <iostream>
//____________________________________________________________________
ClassImp(AliFMDRawStream)
+#if 0
+ ; // This is here to keep Emacs for indenting the next line
+#endif
//____________________________________________________________________
-AliFMDRawStream::AliFMDRawStream(AliRawReader* reader, UShort_t sampleRate)
- : AliAltroRawStream(reader),
- fSampleRate(sampleRate),
- fPrevTime(-1),
- fExplicitSampleRate(kFALSE)
+AliFMDRawStream::AliFMDRawStream(AliRawReader* reader)
+ : AliAltroRawStream(reader)
{
- if (fSampleRate > 0) fExplicitSampleRate = kTRUE;
+ // CTOR
+ fNoAltroMapping = kFALSE;
+ // Select FMD DDL's
+ SelectRawData("FMD");
}
//_____________________________________________________________________________
Bool_t
-AliFMDRawStream::Next()
+AliFMDRawStream::ReadChannel(UInt_t& ddl, UInt_t& addr,
+ UInt_t& len, UShort_t* data)
{
- // read the next raw digit
- // returns kFALSE if there is no digit left
- fPrevTime = fTime;
- if (AliAltroRawStream::Next()) {
- if (!fExplicitSampleRate && fPrevPad != fPad)
- fSampleRate = fTimeBunch / 128;
- return kTRUE;
- }
- return kFALSE;
+ // Read one channel and return. Returns 0 when there's no more
+ // data.
+ Int_t l = 0;
+ static Int_t last = 0xFFFF; // 0xFFFF means signal is used
+ Bool_t next = kTRUE;
+ do {
+ Int_t signal = last;
+ if (last > 0x3FF) {
+ AliFMDDebug(30, ("Last is 0x%x, so reading a new word", last));
+ next = Next();
+ if(!next){
+ addr = GetPrevHWAddress();
+ ddl = GetPrevDDLNumber();
+ len = l+1; // Need to add one - l points to last valid index
+ last = signal;
+ break;
+ }
+ signal = GetSignal();
+ if (GetHWAddress() != GetPrevHWAddress() && GetPrevHWAddress() >= 0) {
+ AliFMDDebug(15, ("New hardware address, was 0x%x, now 0x%x",
+ GetPrevHWAddress(), GetHWAddress()));
+ addr = GetPrevHWAddress();
+ ddl = GetPrevDDLNumber();
+ len = l+1; // Need to add one - l points to last valid index
+ last = signal;
+ break;
+ }
+ }
+ Int_t t = GetTime();
+ l = TMath::Max(l, t);
+ data[t] = signal;
+ last = 0xFFFF;
+ } while (next);
+ return next;
}
+
//_____________________________________________________________________________
//
// EOF