#ifndef HTOFTRB3LOOKUP_H #define HTOFTRB3LOOKUP_H #include "TObject.h" #include "TObjArray.h" #include "hparset.h" #include "htrbnetdef.h" #include using namespace Trbnet; using namespace std; class HTofTrb3LookupChan : public TObject { protected: Int_t sector; // sector number Int_t module; // module number Int_t cell; // cell number Char_t side; // side of cell public: HTofTrb3LookupChan() { clear(); } ~HTofTrb3LookupChan() {;} Int_t getSector() { return sector; } Int_t getModule() { return module; } Int_t getCell() { return cell; } Char_t getSide() { return side; } void getAddress(Int_t& s,Int_t& m,Int_t& c,Char_t& t) { s=sector; m=module; c=cell; t=side; } void getAddress(Int_t& s,Int_t& m,Int_t& c) { s=sector; m=module; c=cell; } void fill(Int_t s,Int_t m,Int_t c,Char_t t) { sector=s; module=m; cell=c; side=t; } void fill(HTofTrb3LookupChan& r) { sector=r.getSector(); module=r.getModule(); cell=r.getCell(); side=r.getSide(); } void setSector(const Int_t n) { sector=n; } void setModule(const Int_t n) { module=n; } void setCell(const Int_t n) { cell=n; } void setSide(Char_t c) { side=c; } void clear() { sector=-1; module=-1; cell=-1; side='\0'; } ClassDef(HTofTrb3LookupChan,1) // Channel level of the lookup table for the TOF TRB3 unpacker }; class HTofTrb3LookupBoard: public TObject { friend class HTofTrb3Lookup; protected: TObjArray* array; // pointer array containing HTofTrb3LookupChan objects public: HTofTrb3LookupBoard(); ~HTofTrb3LookupBoard(); HTofTrb3LookupChan* getChannel(Int_t c) { if (c>=0 && c< getSize()) return &((*this)[c]); else return 0; } HTofTrb3LookupChan& operator[](Int_t i) { return *static_cast((*array)[i]); } Int_t getSize() { return array ? array->GetLast() + 1 : 0; } void clear(); ClassDef(HTofTrb3LookupBoard,1) // Board level of the lookup table for the TOF TRB3 unpacker }; class HTofTrb3Lookup : public HParSet { protected: TObjArray* array; // array of pointers of type HTofTrb3LookupBoard Int_t arrayOffset; // offset to calculate the index public: HTofTrb3Lookup(const Char_t* name="TofTrb3Lookup", const Char_t* title="Lookup table for the TRB3 unpacker of the TOF detector", const Char_t* context="TofTrb3LookupProduction", Int_t minTrbnetAddress=Trbnet::kTOFTrb3MinTrbnetAddress, Int_t maxTrbnetAddress=Trbnet::kTOFTrb3MaxTrbnetAddress); ~HTofTrb3Lookup(); HTofTrb3LookupBoard* getBoard(Int_t trbnetAddress) { if ((arrayOffset <= trbnetAddress) && (trbnetAddress <= (array->GetSize() + arrayOffset))) return (HTofTrb3LookupBoard*)(array->At(trbnetAddress - arrayOffset)); return 0; } HTofTrb3LookupBoard* operator[](Int_t i) { return static_cast((*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,Int_t,Char_t); Bool_t readline(const Char_t*); void putAsciiHeader(TString&); void write(fstream&); ClassDef(HTofTrb3Lookup,1) // Lookup table for the TRB3 unpacker of the TOF detector }; #endif /*!HTOFTRB3LOOKUP_H*/