#ifndef HSTART2TRB2LOOKUP_H
#define HSTART2TRB2LOOKUP_H
#include "TObjArray.h"
#include "TObject.h"
#include "hparset.h"
#include "htrbnetdef.h"
using namespace Trbnet;
using namespace std;
class HStart2Trb2LookupChan : public TObject {
protected:
Int_t module;
Int_t cell;
public:
HStart2Trb2LookupChan() {
clear();
}
~HStart2Trb2LookupChan() {
;
}
Int_t getModule() {
return module;
}
Int_t getCell() {
return cell;
}
void getAddress(Int_t& m, Int_t& c) {
m = module;
c = cell;
}
void fill(Int_t m, Int_t c) {
module = m;
cell = c;
}
void fill(HStart2Trb2LookupChan& r) {
module = r.getModule();
cell = r.getCell();
}
void setModule(const Int_t n) {
module = n;
}
void setCell(const Int_t n) {
cell = n;
}
void clear() {
module = -1;
cell = -1;
}
ClassDef(HStart2Trb2LookupChan, 1)
};
class HStart2Trb2LookupBoard: public TObject {
friend class HStart2Trb2Lookup;
protected:
TObjArray* array;
public:
HStart2Trb2LookupBoard();
~HStart2Trb2LookupBoard();
HStart2Trb2LookupChan* getChannel(Int_t c) {
if (c >= 0 && c < 128) return &((*this)[c]);
else return 0;
}
HStart2Trb2LookupChan& operator[](Int_t i) {
return *static_cast<HStart2Trb2LookupChan*>((*array)[i]);
}
Int_t getSize() {
return 128;
}
void clear();
ClassDef(HStart2Trb2LookupBoard, 1)
};
class HStart2Trb2Lookup : public HParSet {
protected:
TObjArray* array;
Int_t arrayOffset;
public:
HStart2Trb2Lookup(const Char_t* name = "Start2Trb2Lookup",
const Char_t* title = "Lookup table for the TRB2 unpacker of the START2 detector",
const Char_t* context = "Start2Trb2LookupProduction",
Int_t minTrbnetAddress = Trbnet::kStartMinTrbnetAddress,
Int_t maxTrbnetAddress = Trbnet::kStartMaxTrbnetAddress);
~HStart2Trb2Lookup();
HStart2Trb2LookupBoard* getBoard(Int_t trbnetAddress) {
return (HStart2Trb2LookupBoard*)(array->At(trbnetAddress - arrayOffset));
}
HStart2Trb2LookupBoard* operator[](Int_t i) {
return static_cast<HStart2Trb2LookupBoard*>((*array)[i]);
}
Int_t getSize() {
return array->GetLast() + 1;
}
Int_t getArrayOffset() {
return arrayOffset;
}
Bool_t init(HParIo* input, Int_t* set);
Int_t write(HParIo* output);
void clear();
void printParam();
Bool_t fill(Int_t, Int_t, Int_t, Int_t);
Bool_t readline(const Char_t*);
void putAsciiHeader(TString&);
void write(fstream&);
ClassDef(HStart2Trb2Lookup, 1)
};
#endif /*!HSTART2TRB2LOOKUP_H*/