//*-- AUTHOR Ilse Koenig //*-- created : 15/12/2009 by Ilse Koenig // Modified for new MDC readout 29-08-2024 by JAM (j.adamczewski@gsi.de) //_HADES_CLASS_DESCRIPTION ////////////////////////////////////////////////////////////////////// // HMdcTrbCLookup // // Lookup table for the TRB Clock TDC unpacker of the MDC detector to map the // Trbnet address (range defined in htrbnetdef.h) and channel (0..31) // to the detector address // sector, module, cell, side. ////////////////////////////////////////////////////////////////////// using namespace std; #include "hmdctrbclookup.h" #include "hpario.h" #include "hdetpario.h" #include #include #include #include ClassImp(HMdcTrbCLookupChan) ClassImp(HMdcTrbCLookupBoard) ClassImp(HMdcTrbCLookup) HMdcTrbCLookupBoard::HMdcTrbCLookupBoard() { // constructor creates an array of 128 channels array = new TObjArray(HMDC_MAXTDCCHANNELS); for(Int_t i=0;iAddAt(new HMdcTrbCLookupChan(),i); } HMdcTrbCLookupBoard::~HMdcTrbCLookupBoard() { // destructor deletes the array of channels array->Delete(); delete array; } void HMdcTrbCLookupBoard::clear() { // calls the clear function for each channel for(Int_t i=0;iDelete(); delete array; } Bool_t HMdcTrbCLookup::init(HParIo* inp,Int_t* set) { // initializes the container from an input HDetParIo* input=inp->getDetParIo("HMdcParIo"); if (input) return (input->init(this,set)); return kFALSE; } Int_t HMdcTrbCLookup::write(HParIo* output) { // writes the container to an output HDetParIo* out=output->getDetParIo("HMdcParIo"); if (out) return out->write(this); return -1; } void HMdcTrbCLookup::clear() { // deletes all HMdcTrbCLookupBoard objects from the array and resets the input versions array->Delete(); status=kFALSE; resetInputVersions(); } void HMdcTrbCLookup::printParam() { // prints the lookup table printf("Lookup table for the TRB3 unpacker of the MDC detector\n"); printf("trbnet-address channel sector module MBO layer wire side\n"); printf("side: l-left, r-right\n"); for(Int_t i=0;i<=array->GetLast();i++) { HMdcTrbCLookupBoard* b=(*this)[i]; if (b) { for(Int_t j=0;jgetSize();j++) { HMdcTrbCLookupChan& chan=(*b)[j]; Int_t sector=chan.getSector(); if (sector>=0) { printf("0x%x %4i %3i %4i %4i %4i %4i %c\n", arrayOffset+i,j,sector, chan.getModule(),chan.getMBO(),chan.getLayer(),chan.getWire(), chan.getSide()); } } } } } Bool_t HMdcTrbCLookup::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) { // creates the HMdcTrbCLookupBoard objects, if not existing, and fills the channel Bool_t rc=kFALSE; HMdcTrbCLookupBoard* p=getBoard(id); if (!p) { p=new HMdcTrbCLookupBoard(); array->AddAt(p,id-arrayOffset); } HMdcTrbCLookupChan* c=p->getChannel(chan); if (c) { c->fill(sec,mod,mbo, layer, wire,side); rc=kTRUE; } else { Error("fill","Invalid channel number %i",chan); } return rc; } Bool_t HMdcTrbCLookup::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, mbo, layer, wire; Char_t side = '\0'; // TODO: refactor ascii format, may also contain readout side (redundant?) Int_t n = sscanf(buf, " 0x%x %i %i %i %i %i %i %c\n", &id, &chan, &mod, &sec, &mbo, &layer, &wire, &side); if (8 == n || 7 == n) { // for first try, we allow files without the side information JAM rc = fill(id, chan, sec, mod, mbo, layer, wire, side); } else { if (n < 7) //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 HMdcTrbCLookup::putAsciiHeader(TString& header) { // puts the ASCII header to the string used in HMdcParAsciiFileIo header= "# Lookup table for the TRBC unpacker of the MDC detector\n" "# Format:\n" "# trbnet-address channel module sector MBO layer wire (side)\n"; } void HMdcTrbCLookup::write(fstream& fout) { // writes the information of all non-zero HMdcTrbCLookupBoard objects to the ASCII file for(Int_t i=0;i<=array->GetLast();i++) { HMdcTrbCLookupBoard* b=(*this)[i]; if (b) { for(Int_t j=0;jgetSize();j++) { HMdcTrbCLookupChan& chan=(*b)[j]; Int_t sector=chan.getSector(); if (sector>=0) { fout<<"0x"<