#ifndef HRPCTRB3LOOKUP_H #define HRPCTRB3LOOKUP_H #include "TObject.h" #include "TObjArray.h" #include "TString.h" #include "hparset.h" #include "htrbnetdef.h" #include using namespace Trbnet; using namespace std; class HRpcTrb3LookupChan : public TObject { protected: Int_t sector; // sector number Int_t column; // column number Int_t cell; // cell number Char_t side; // side of cell Int_t feAddress; // front end address TString geomname; // geometric position public: HRpcTrb3LookupChan() { clear(); } ~HRpcTrb3LookupChan() {;} Int_t getSector() { return sector; } Int_t getColumn() { return column; } Int_t getCell() { return cell; } Char_t getSide() { return side; } Int_t getFeAddress() { return feAddress; } TString getGeomName() { return geomname; } void getAddress(Int_t& se,Int_t& co,Int_t& ce,Char_t& si,Int_t& fa) { se=sector; co=column; ce=cell; si=side; fa=feAddress; } void getAddress(Int_t& se,Int_t& co,Int_t& ce) { se=sector; co=column; ce=cell; } void fill(Int_t se,Int_t co,Int_t ce,Char_t si,Int_t fa,TString& gn) { sector=se; column=co; cell=ce; side=si; feAddress=fa; geomname=gn; } void fill(HRpcTrb3LookupChan& r) { sector=r.getSector(); column=r.getColumn(); cell=r.getCell(); side=r.getSide(); feAddress=r.getFeAddress(); geomname=r.getGeomName(); } void setSector(const Int_t n) { sector=n; } void setColumn(const Int_t n) { column=n; } void setCell(const Int_t n) { cell=n; } void setSide(Char_t c) { side=c; } void setFeAddress(const Int_t n) { feAddress=n; } void setGeomName(TString n) { geomname=n; } void clear() { sector=column=cell=feAddress=-1; side='\0'; } ClassDef(HRpcTrb3LookupChan,1) // Channel level of the lookup table for the RPC TRB2 unpacker }; class HRpcTrb3LookupBoard: public TObject { friend class HRpcTrb3Lookup; protected: TObjArray* array; // pointer array containing HRpcTrb3LookupChan objects public: HRpcTrb3LookupBoard(); ~HRpcTrb3LookupBoard(); HRpcTrb3LookupChan* getChannel(Int_t c) { if (c >= 0 && c < getSize()) return &((*this)[c]); else return 0; } HRpcTrb3LookupChan& operator[](Int_t i) { return *static_cast((*array)[i]); } Int_t getSize() { return array ? array->GetLast() + 1 : 0; } void clear(); ClassDef(HRpcTrb3LookupBoard,1) // Board level of the lookup table for the RPC TRB3 unpacker }; class HRpcTrb3Lookup : public HParSet { protected: TObjArray* array; // array of pointers of type HRpcTrb3LookupBoard Int_t arrayOffset; // offset to calculate the index Int_t lookup[6][6][50][2][2]; //! reverse lookup s,col,cell,side (right = 0,left =1), tdc/chan void fillLookup(); void initLookup(); public: HRpcTrb3Lookup(const Char_t* name="RpcTrb3Lookup", const Char_t* title="Lookup table for the TRB3 unpacker of the RPC detector", const Char_t* context="RpcTrb3LookupProduction", Int_t minTrbnetAddress=Trbnet::kRpcTrb3MinTrbnetAddress, Int_t maxTrbnetAddress=Trbnet::kRpcTrb3MaxTrbnetAddress); ~HRpcTrb3Lookup(); HRpcTrb3LookupBoard* getBoard(Int_t trbnetAddress) { if ((arrayOffset <= trbnetAddress) && (trbnetAddress <= (array->GetSize() + arrayOffset))) return (HRpcTrb3LookupBoard*)(array->At(trbnetAddress - arrayOffset)); return 0; } HRpcTrb3LookupBoard* 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,Int_t,TString& n); Bool_t find(Int_t s, Int_t col, Int_t cell,Int_t side, Int_t& tdc,Int_t& chan); Bool_t readline(const Char_t*); void putAsciiHeader(TString&); void write(fstream&); ClassDef(HRpcTrb3Lookup,1) // Lookup table for the TRB3 unpacker of the RPC detector }; #endif /*!HRPCTRB3LOOKUP_H*/