00001 #ifndef ALIFMDALTROIO_H
00002 #define ALIFMDALTROIO_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <iosfwd>
00011 #include <TObject.h>
00012
00013
00018 class AliFMDAltroIO : public TObject
00019 {
00020 public:
00022 typedef long long W40_t;
00024 typedef Int_t W10_t;
00026 AliFMDAltroIO();
00028 virtual ~AliFMDAltroIO() {}
00030 enum {
00032 kNoError,
00034 kBadFile,
00036 kBadBits,
00038 kBadRead,
00040 kBadWrite,
00042 kBadSeek,
00044 kBadTell,
00046 kBadTrailer,
00048 kBadFill
00049 };
00051 static const W40_t fgkTrailerMask;
00053 const char* ErrorString(Int_t err) const;
00054 protected:
00056 W40_t fBuffer;
00058 Int_t fIBuffer;
00059
00065 virtual W40_t ConcatW40(size_t n, const W10_t& w) const;
00071 virtual W10_t ExtractW10(size_t n, const W40_t w) const;
00072
00073 ClassDef(AliFMDAltroIO,0);
00074 };
00075
00076
00087 class AliFMDAltroReader : public AliFMDAltroIO
00088 {
00089 public:
00093 AliFMDAltroReader(std::istream& stream);
00094 virtual ~AliFMDAltroReader() {}
00106 Int_t ReadChannel(UShort_t& board, UShort_t& chip, UShort_t& channel,
00107 UShort_t& last, UShort_t* data);
00117 Int_t ReadChannel(UShort_t& hwaddr, UShort_t& last, UShort_t* data);
00123 Int_t ExtractTrailer(UShort_t& hwaddr, UShort_t& last);
00129 Int_t ExtractBunches(UShort_t last, UShort_t* data);
00134 Int_t ExtractFillWords(UShort_t last);
00139 Int_t ExtractBunch(UShort_t* data);
00143 Bool_t IsTrailer(W40_t x);
00145 Bool_t IsBof();
00146 protected:
00148 std::istream& fInput;
00150
00151 size_t fCurrent;
00153 size_t fBegin;
00154
00157 virtual Int_t ReadW40();
00160 virtual W10_t GetNextW10();
00163 virtual W40_t GetNextW40();
00164
00165 ClassDef(AliFMDAltroReader,0);
00166 };
00167
00168
00178 class AliFMDAltroWriter : public AliFMDAltroIO
00179 {
00180 public:
00184 AliFMDAltroWriter(std::ostream& stream);
00185 virtual ~AliFMDAltroWriter() {}
00187 void SetThreshold(UShort_t threshold) { fThreshold = threshold; }
00191 Int_t Close();
00194 Int_t Flush();
00199 Int_t AddSignal(UShort_t adc);
00206 Int_t AddChannelTrailer(UShort_t board, UShort_t chip, UShort_t channel);
00211 Int_t AddChannelTrailer(UInt_t hwaddr);
00212 protected:
00217 Int_t AddToBuffer(UShort_t x);
00221 Int_t AddBunchTrailer();
00225 Int_t AddFillWords();
00227 UShort_t fThreshold;
00229 UShort_t fTime;
00231 UShort_t fLength;
00233 UShort_t fLast;
00235 size_t fBegin;
00237 size_t fHeader;
00239 Long_t fTotal;
00241 std::ostream& fOutput;
00242
00243 ClassDef(AliFMDAltroWriter,0);
00244 };
00245
00246
00247
00248 #endif
00249
00250
00251
00252
00253
00254
00255
00256