#ifndef HITOFTRB3LOOKUP_H #define HITOFTRB3LOOKUP_H #include "TObjArray.h" #include "TObject.h" #include "hparset.h" #include "htrbnetdef.h" using namespace Trbnet; using namespace std; class HiTofTrb3LookupChan : public TObject { protected: Int_t sector; // sector number Int_t module; // module number Int_t cell; // cell number Int_t slot; // slot number in HiTofRaw public: HiTofTrb3LookupChan() { clear(); } ~HiTofTrb3LookupChan() { ; } Int_t getSector() { return sector; } Int_t getModule() { return module; } Int_t getCell() { return cell; } Int_t getSlot() { return slot; } 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,Int_t sl) { sector = s; module = m; cell = c; slot = sl; } void fill(HiTofTrb3LookupChan& r) { sector = r.getSector(); module = r.getModule(); cell = r.getCell(); slot = r.getSlot(); } 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 setSlot (const Int_t n) { slot = n; } void clear() { sector = -1; module = -1; cell = -1; slot = -1; } ClassDef(HiTofTrb3LookupChan, 1) // Channel level of the lookup table for the iTOF TRB3 unpacker }; class HiTofTrb3LookupTdc: public TObject { friend class HiTofTrb3Lookup; protected: TObjArray* array; // pointer array containing HiTofTrb3LookupChan objects public: HiTofTrb3LookupTdc(); ~HiTofTrb3LookupTdc(); Int_t getSize() { return array ? array->GetLast()+1 : 0; } HiTofTrb3LookupChan* getChannel(Int_t c) { if (c >= 0 && c < getSize()) return &((*this)[c]); else return 0; } HiTofTrb3LookupChan& operator[](Int_t i) { return *static_cast((*array)[i]); } void clear(); ClassDef(HiTofTrb3LookupTdc, 1) // Tdc level of the lookup table for the iTOF TRB3 unpacker }; class HiTofTrb3Lookup : public HParSet { protected: TObjArray* array; // array of pointers of type HiTofTrb2LookupTdc Int_t arrayOffset; // offset to calculate the index Int_t lookup[6][1][3][15][2]; //! reverse lookup void fillLookup(); void initLookup(); public: HiTofTrb3Lookup(const Char_t* name = "iTofTrb3Lookup", const Char_t* title = "Lookup table for the TRB3 unpacker of the START2 detector", const Char_t* context = "iTofTrb3LookupProduction", Int_t minTrbnetAddress = Trbnet::kiTofTrb3MinTrbnetAddress, Int_t maxTrbnetAddress = Trbnet::kiTofTrb3MaxTrbnetAddress); ~HiTofTrb3Lookup(); HiTofTrb3LookupTdc* getTdc(Int_t trbnetAddress) { if ((arrayOffset <= trbnetAddress) && (trbnetAddress <= (array->GetSize() + arrayOffset))) return (HiTofTrb3LookupTdc*)(array->At(trbnetAddress - arrayOffset)); return 0; } HiTofTrb3LookupTdc* 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, Int_t); Bool_t find(Int_t s, Int_t m,Int_t c, Int_t sl, Int_t& tdc,Int_t& chan); Bool_t readline(const Char_t*); void putAsciiHeader(TString&); void write(fstream&); ClassDef(HiTofTrb3Lookup, 1) // Lookup table for the TRB2 unpacker of the iTOF detector }; #endif /*!HITOFTRB3LOOKUP_H*/