//_HADES_CLASS_DESCRIPTION ////////////////////////////////////////////////////////////////////// // HRpcTrb3Lookup // // Lookup table for the TRB3 unpacker of the RPC detector to map the // Trbnet address to the detector address // sector, column, cell, side, front-end address. ////////////////////////////////////////////////////////////////////// using namespace std; #include "hrpctrb3lookup.h" #include "hpario.h" #include "hdetpario.h" #include #include #include #include ClassImp(HRpcTrb3LookupChan) ClassImp(HRpcTrb3LookupBoard) ClassImp(HRpcTrb3Lookup) HRpcTrb3LookupBoard::HRpcTrb3LookupBoard() { // constructor creates an array of 128 channels array = new TObjArray(65); for(Int_t i=0;i<65;i++) array->AddAt(new HRpcTrb3LookupChan(),i); } HRpcTrb3LookupBoard::~HRpcTrb3LookupBoard() { // destructor deletes the array of channels array->Delete(); delete array; } void HRpcTrb3LookupBoard::clear() { // calls the clear function for each channel for(Int_t i=0;i<65;i++) (*this)[i].clear(); } //--------------------------------------------------------------- HRpcTrb3Lookup::HRpcTrb3Lookup(const Char_t* name, const Char_t* title, const Char_t* context, Int_t minTrbnetAddress, Int_t maxTrbnetAddress) : HParSet(name,title,context) { // constructor creates an empty array of size nBoards arrayOffset=minTrbnetAddress; array = new TObjArray(maxTrbnetAddress-minTrbnetAddress+1); } HRpcTrb3Lookup::~HRpcTrb3Lookup() { // destructor array->Delete(); delete array; } Bool_t HRpcTrb3Lookup::init(HParIo* inp,Int_t* set) { // initializes the container from an input HDetParIo* input=inp->getDetParIo("HRpcParIo"); if (input) return (input->init(this,set)); return kFALSE; } Int_t HRpcTrb3Lookup::write(HParIo* output) { // writes the container to an output HDetParIo* out=output->getDetParIo("HRpcParIo"); if (out) return out->write(this); return -1; } void HRpcTrb3Lookup::clear() { // deletes all HRpcTrb3LookupBoard objects from the array and resets the input versions array->Delete(); status=kFALSE; resetInputVersions(); } void HRpcTrb3Lookup::printParam() { // prints the lookup table printf("Lookup table for the TRB2 unpacker of the RPC detector\n"); printf("trbnet-address channel sector column cell side front-end address geomname\n"); printf("side: l-left, r-right\n"); for(Int_t i=0;i<=array->GetLast();i++) { HRpcTrb3LookupBoard* b=(*this)[i]; if (b) { for(Int_t j=0;jgetSize();j++) { HRpcTrb3LookupChan& chan=(*b)[j]; Int_t sector=chan.getSector(); if (sector>=0) { TString n = chan.getGeomName(); printf("0x%x %4i %3i%4i%4i %c %i %s\n", arrayOffset+i,j,sector, chan.getColumn(),chan.getCell(),chan.getSide(),chan.getFeAddress(),n.Data()); } } } } } Bool_t HRpcTrb3Lookup::fill(Int_t id,Int_t chan, Int_t sec,Int_t mod,Int_t cell,Char_t side,Int_t fea, TString& n) { // creates the HRpcTrb3LookupBoard objects, if not existing, and fills the channel Bool_t rc=kFALSE; HRpcTrb3LookupBoard* p=getBoard(id); if (!p) { p=new HRpcTrb3LookupBoard(); array->AddAt(p,id-arrayOffset); } HRpcTrb3LookupChan* c=p->getChannel(chan); if (c) { c->fill(sec,mod,cell,side,fea,n); rc=kTRUE; } else { Error("fill","Invalid channel number %i",chan); } return rc; } Bool_t HRpcTrb3Lookup::readline(const Char_t *buf) { // decodes one line read from ASCII file I/O and fills the channel Bool_t rc=kFALSE; Int_t id, chan, sec, mod, cell, feAddress; Char_t side='\0'; Char_t gn[100]; Int_t n=sscanf(buf," 0x%x %i %i %i %i %c %i %s",&id,&chan,&sec,&mod,&cell,&side,&feAddress,gn); if (8==n) { TString gN=gn; rc=fill(id,chan,sec,mod,cell,side,feAddress,gN); } else { if (n<8) Error("readline","Not enough values in line %s\n",buf); else Error("readline","Too many values in line %s\n",buf); } return rc; } void HRpcTrb3Lookup::putAsciiHeader(TString& header) { // puts the ASCII header to the string used in HRpcParAsciiFileIo header= "# Lookup table for the TRB2 unpacker of the RPC detector\n" "# Format:\n" "# trbnet-address channel sector column cell side front-end-address geomname\n"; } void HRpcTrb3Lookup::write(fstream& fout) { // writes the information of all non-zero HRpcTrb3LookupBoard objects to the ASCII file for(Int_t i=0;i<=array->GetLast();i++) { HRpcTrb3LookupBoard* b=(*this)[i]; if (b) { for(Int_t j=0;jgetSize();j++) { HRpcTrb3LookupChan& chan=(*b)[j]; Int_t sector=chan.getSector(); if (sector>=0) { fout<<"0x"<