#ifndef HMDCTRBCLOOKUP_H #define HMDCTRBCLOOKUP_H #include "TObject.h" #include "TObjArray.h" #include "hparset.h" #include "htrbnetdef.h" #include using namespace Trbnet; using namespace std; // number of channels per MDC tdc #define HMDC_MAXTDCCHANNELS 32 class HMdcTrbCLookupChan: public TObject { protected: Int_t sector; // sector number Int_t module; // module (plane) number Int_t mbo; // motherboard index Int_t layer; // layer Int_t wire; // wire (cell) number Char_t side; // readout side (redundant?) public: HMdcTrbCLookupChan() { clear(); } ~HMdcTrbCLookupChan() { ; } Int_t getSector() { return sector; } Int_t getModule() { return module; } Int_t getMBO() { return mbo; } Int_t getLayer() { return layer; } Int_t getWire() { return wire; } Char_t getSide() { return side; } void getAddress(Int_t &s, Int_t &p, Int_t &m, Int_t &l, Int_t &w, Char_t &t) { s = sector; p = module; m = mbo; l = layer; w = wire; t = side; } // mapping of TDC entities for raw categorie floc last index // previously done from dataword: // Int_t tdcCh = dataword->getTdcNumber()*8 + dataword->getChannel(); void getAddress(Int_t &s, Int_t &p, Int_t &m) { s = sector; p = module; m = mbo; } void fill(Int_t s, Int_t p, Int_t m, Int_t l, Int_t w, Char_t t) { sector = s; module = p; mbo = m; layer = l; wire = w; side = t; } void fill(HMdcTrbCLookupChan &r) { sector = r.getSector(); module = r.getModule(); mbo = r.getMBO(); layer = r.getLayer(); wire = r.getWire(); side = r.getSide(); } void setSector(const Int_t n) { sector = n; } void setModule(const Int_t n) { module = n; } void setMBO(const Int_t n) { mbo = n; } void setLayer(const Int_t n) { layer = n; } void setWire(const Int_t n) { wire = n; } void setSide(Char_t c) { side = c; } void clear() { sector = -1; module = -1; mbo = -1; layer = -1; wire = -1; side = '\0'; } ClassDef(HMdcTrbCLookupChan,1) // Channel level of the lookup table for the TOF TRB3 unpacker }; class HMdcTrbCLookupBoard: public TObject { friend class HMdcTrbCLookup; protected: TObjArray *array; // pointer array containing HMdcTrbCLookupChan objects public: HMdcTrbCLookupBoard(); ~HMdcTrbCLookupBoard(); HMdcTrbCLookupChan* getChannel(Int_t c) { if (c >= 0 && c < getSize()) return &((*this)[c]); else return 0; } HMdcTrbCLookupChan& operator[](Int_t i) { return *static_cast((*array)[i]); } Int_t getSize() { return array ? array->GetLast() + 1 : 0; } void clear();ClassDef(HMdcTrbCLookupBoard,1) // Board level of the lookup table for the TOF TRB3 unpacker }; class HMdcTrbCLookup: public HParSet { protected: TObjArray *array; // array of pointers of type HMdcTrbCLookupBoard Int_t arrayOffset; // offset to calculate the index public: HMdcTrbCLookup(const Char_t *name = "MdcTrbCLookup", const Char_t *title = "Lookup table for the TRB3 unpacker of the MDC detector", const Char_t *context = "MdcTrbCLookupProduction", Int_t minTrbnetAddress = Trbnet::kMdcTrbCMinTrbnetAddress, Int_t maxTrbnetAddress = Trbnet::kMdcTrbCMaxTrbnetAddress); ~HMdcTrbCLookup(); HMdcTrbCLookupBoard* getBoard(Int_t trbnetAddress) { if ((arrayOffset <= trbnetAddress) && (trbnetAddress <= (array->GetSize() + arrayOffset))) return (HMdcTrbCLookupBoard*) (array->At( trbnetAddress - arrayOffset)); return 0; } HMdcTrbCLookupBoard* 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 id,Int_t chan, Int_t sec, Int_t mod, Int_t mbo, Int_t layer, Int_t wire, Char_t side); Bool_t readline(const Char_t*); void putAsciiHeader(TString&); void write(fstream&);ClassDef(HMdcTrbCLookup,1) // Lookup table for the TRB3 unpacker of the TOF detector }; #endif /*!HTOFTRB3LOOKUP_H*/