//*-- AUTHOR : J.Wuestenfeld //*-- Modified : 13/08/2003 by J. Wuestenfeld //_HADES_CLASS_DESCRIPTION //////////////////////////////////////////////////////////////////////////// // HMdcTdcChannel // // Container class for the TDC channle masks of the MDC // //////////////////////////////////////////////////////////////////////////// using namespace std; #include #include "hmdctdcchannel.h" #include "hades.h" #include "hruntimedb.h" #include "hspectrometer.h" #include "hmdcdetector.h" #include "hpario.h" #include "hdetpario.h" #include "hmdcrawstruct.h" #include "hmessagemgr.h" #include "TSystem.h" #include #include #include ClassImp(HMdcTdcChannelTdc) ClassImp(HMdcTdcChannelMbo) ClassImp(HMdcTdcChannelMod) ClassImp(HMdcTdcChannelSec) ClassImp(HMdcTdcChannel) void HMdcTdcChannelTdc::fill(HMdcTdcChannelTdc& r) { channelMask[0]=r.getChannelMask(0); channelMask[1]=r.getChannelMask(1); } HMdcTdcChannelMbo::HMdcTdcChannelMbo(Int_t tdc, const Text_t* name) { // constructor takes the number of TDCs and the name of the MBO SetName(name); array = new TObjArray(tdc); for (Int_t i=0; iAddAt(new HMdcTdcChannelTdc(),i); } HMdcTdcChannelMbo::~HMdcTdcChannelMbo() { // destructor array->Delete(); delete array; } HMdcTdcChannelMod::HMdcTdcChannelMod(Int_t sec, Int_t mod, Int_t mbo) { // constructor takes the sector, module and MBO number array = new TObjArray(mbo); HMdcRawStruct* pMdc = (HMdcRawStruct*)gHades->getRuntimeDb()->getContainer("MdcRawStruct"); if (pMdc) { HMdcRawModStru& rMod=(*pMdc)[sec][mod]; for (Int_t i=0; iAddAt(new HMdcTdcChannelMbo((Int_t)(rMbo.getNTdcs()/8),(Char_t*)rMbo.GetName()),i); } } else { delete array; ERROR_msg(HMessageMgr::DET_MDC,"HMdcTdcChannelMod not created, container MdcRawStruct not found"); exit(1); } } HMdcTdcChannelMod::~HMdcTdcChannelMod() { // destructor array->Delete(); delete array; } HMdcTdcChannelSec::HMdcTdcChannelSec(Int_t sec, Int_t mod) { // constructor takes the sector, module number array = new TObjArray(mod); for (Int_t i=0; iAddAt(new HMdcTdcChannelMod(sec,i),i); } HMdcTdcChannelSec::~HMdcTdcChannelSec() { // destructor array->Delete(); delete array; } HMdcTdcChannel::HMdcTdcChannel(const Char_t* name,const Char_t* title, const Char_t* context,Int_t n) : HParSet(name,title,context) { // constructor strcpy(detName,"Mdc"); oraVersion=-1; array = new TObjArray(n); mapNotConnectedChannels = kFALSE; status = kTRUE; for (Int_t i=0; iAddAt(new HMdcTdcChannelSec(i),i); } HMdcTdcChannel::~HMdcTdcChannel() { // destructor array->Delete(); delete array; } Bool_t HMdcTdcChannel::init(HParIo* inp,Int_t* set) { // intitializes the container from an input if((raw_struct=(HMdcRawStruct*)gHades->getRuntimeDb()->getContainer("MdcRawStruct")) == NULL) return kFALSE; if((conWires=(HMdcConnectedWires*)gHades->getRuntimeDb()->getContainer("MdcConnectedWires")) == NULL) return kFALSE; if((lookupGeom = (HMdcLookupGeom *)gHades->getRuntimeDb()->getContainer("MdcLookupGeom")) == NULL) return kFALSE; HDetParIo* input=inp->getDetParIo("HMdcParIo"); if(input) if (!input->init(this,set)) return kFALSE; return kTRUE; } Int_t HMdcTdcChannel::write(HParIo* output) { // writes the container to an output HDetParIo* out=output->getDetParIo("HMdcParIo"); if (out) return out->write(this); return -1; } void HMdcTdcChannel::readline(const Char_t* buf, Int_t* set) { // decodes one line read from ascii file I/O and calls HMdcTdcChannelTdc::fill(...) Int_t sec, mod, mbo, dbo; Int_t cal,meas; Char_t mboName[20]; sscanf(buf,"%i%i%i%s%i%x%x",&sec, &mod, &mbo, mboName, &dbo, &cal,&meas); Int_t n=sec*4+mod; if (!set[n]) return; HMdcTdcChannelMbo& rMbo=(*this)[sec][mod][mbo]; rMbo.SetName(mboName); HMdcTdcChannelTdc& tdc=rMbo[dbo]; tdc.fill(cal,0); tdc.fill(meas,1); set[n]=999; } void HMdcTdcChannel::readLineFromFile(const Char_t* buf) { // decodes one line read from ascii file I/O and calls HMdcTdcChannelTdc::fill(...) Int_t sec, mod, mbo, dbo; Int_t cal,meas; sscanf(buf,"%i%i%i%i%x%x", &mod, &sec, &mbo, &dbo, &cal,&meas); HMdcRawModStru & rawMod=(*raw_struct)[sec][mod]; HMdcRawMothStru &rawMbo=rawMod[mbo]; if (rawMbo.getNTdcs() >= dbo*16 ) { HMdcTdcChannelMbo& rMbo=(*this)[sec][mod][mbo]; HMdcTdcChannelTdc& db=rMbo[dbo-1]; db.fill(cal,0); db.fill(meas,1); } } void HMdcTdcChannel::putAsciiHeader(TString& header) { // puts the ascii header to the string used in HMdcParAsciiFileIo header= "# Channelmasks of the MDC TDC\n" "# Format:\n" "# sector module mbo mboName TDC# cal. mask meas. mask\n"; } Bool_t HMdcTdcChannel::writeline(Char_t *buf, Int_t sec, Int_t mod, Int_t mbo, Int_t dbo) { // writes one line to the buffer used by ascii file I/O HMdcTdcChannelMbo& rMbo=(*this)[sec][mod][mbo]; HMdcTdcChannelTdc& db=rMbo[dbo]; sprintf(buf,"%1i %1i %2i %s %2i %2x %2x\n", sec, mod, mbo, rMbo.GetName(), dbo, db.getChannelMask(0),db.getChannelMask(1)); return kTRUE; } void HMdcTdcChannel::clear() { // clears the container oraVersion=-1; for(Int_t s=0;sgetMsg()->info(10,HMessageMgr::DET_MDC,GetName(), "%1i %1i %2i %s %1i %2x %2x", s, m, l, mbo.GetName(), c, mbo[c].getChannelMask(0), mbo[c].getChannelMask(1)); } } } } SEPERATOR_msg("-",60); } void HMdcTdcChannel::mapOutUnusedChannels(void) { // Maps out all channels that have no wire connected. Test is done against HMdcLookupGeom container. for(Int_t s=0;s