#include "hmdcmboreadout.h"
#include "hmdcrawstruct.h"
#include "hades.h"
#include "hruntimedb.h"
#include "hspectrometer.h"
#include "hmdcdetector.h"
#include "hpario.h"
#include "hdetpario.h"
#include "hmessagemgr.h"
ClassImp(HMdcMboReadoutMoth)
ClassImp(HMdcMboReadoutMod)
ClassImp(HMdcMboReadoutSec)
ClassImp(HMdcMboReadout)
void HMdcMboReadoutMoth::fill(Int_t b,Int_t bp,Int_t r,Int_t s,Int_t sp) {
bus=b;
busPos=bp;
roc=r;
samPos=s;
sam=sp;
}
void HMdcMboReadoutMoth::fill(HMdcMboReadoutMoth& r){
bus=r.getBus();
busPos=r.getBusPos();
roc=r.getRoc();
sam=r.getSam();
samPos=r.getSamPos();
}
HMdcMboReadoutMod::HMdcMboReadoutMod(Int_t n) {
array = new TObjArray(n);
for(Int_t i=0;i<n;i++) array->AddAt(new HMdcMboReadoutMoth(),i);
}
HMdcMboReadoutMod::~HMdcMboReadoutMod() {
array->Delete();
delete array;
}
HMdcMboReadoutSec::HMdcMboReadoutSec(Int_t n) {
array = new TObjArray(n);
for(Int_t i=0;i<n;i++) array->AddAt(new HMdcMboReadoutMod(16),i);
}
HMdcMboReadoutSec::~HMdcMboReadoutSec() {
array->Delete();
delete array;
}
HMdcMboReadout::HMdcMboReadout(const Char_t* name,const Char_t* title,
const Char_t* context,Int_t n)
: HParSet(name,title,context) {
strcpy(detName,"Mdc");
array = new TObjArray(n);
for(Int_t i=0;i<n;i++) array->AddAt(new HMdcMboReadoutSec(4),i);
HMdcRawStruct* pMdc=
(HMdcRawStruct*)gHades->getRuntimeDb()->getContainer("MdcRawStruct");
if (pMdc) {
for(Int_t i=0;i<6;i++) {
for(Int_t j=0;j<4;j++) {
for(Int_t k=0;k<16;k++)
(*this)[i][j][k].SetName((Char_t*)((*pMdc)[i][j][k].GetName()));
}
}
} else {
ERROR_msg(HMessageMgr::DET_MDC,"MBO names in HMdcMboReadout not initialized");
ERROR_msg(HMessageMgr::DET_MDC,"container MdcRawStruct not found");
}
}
HMdcMboReadout::~HMdcMboReadout() {
array->Delete();
delete array;
}
Bool_t HMdcMboReadout::init(HParIo* inp,Int_t* set) {
HDetParIo* input=inp->getDetParIo("HMdcParIo");
if (input) return (input->init(this,set));
return kFALSE;
}
Int_t HMdcMboReadout::write(HParIo* output) {
HDetParIo* out=output->getDetParIo("HMdcParIo");
if (out) return out->write(this);
return -1;
}
void HMdcMboReadout::clear() {
for(Int_t i=0;i<this->getSize();i++) {
HMdcMboReadoutSec& sec=(*this)[i];
for(Int_t j=0;j<sec.getSize();j++) {
HMdcMboReadoutMod& mod=sec[j];
for(Int_t k=0;k<mod.getSize();k++) {
HMdcMboReadoutMoth& moth=mod[k];
moth.clear();
}
}
}
status=kFALSE;
resetInputVersions();
}
void HMdcMboReadout::printParam() {
SEPERATOR_msg("-",60);
INFO_msg(10,HMessageMgr::DET_MDC,"MBO index MBO name");
INFO_msg(10,HMessageMgr::DET_MDC," BUS BUS position ROC SAM position SAM");
HMdcDetector* set=(HMdcDetector*)(((HSpectrometer*)(gHades->getSetup()))->getDetector("Mdc"));
if (set) {
for(Int_t i=0;i<this->getSize();i++) {
HMdcMboReadoutSec& sec=(*this)[i];
for(Int_t j=0;j<sec.getSize();j++) {
HMdcMboReadoutMod& mod=sec[j];
if (set->getModule(i,j)) {
gHades->getMsg()->info(10,HMessageMgr::DET_MDC,GetName()
,"sector: %i module: %i",i,j);
for(Int_t k=0;k<mod.getSize();k++) {
HMdcMboReadoutMoth& moth=mod[k];
Int_t bus=moth.getBus();
if (bus!=-1) {
gHades->getMsg()->info(10,HMessageMgr::DET_MDC,GetName()
,"%3i %s%6i%3i%3i%4i%3i\n",
k,moth.GetName(),bus,moth.getBusPos(),moth.getRoc(),
moth.getSamPos(),moth.getSam());
}
}
}
}
}
}
SEPERATOR_msg("-",60);
}
void HMdcMboReadout::readline(const Char_t *buf, Int_t*set) {
Char_t mboName[155];
Int_t sec, mod, mboInd, bus, busPos, roc, sam, samPos;
sscanf(buf,"%i%i%i%s%i%i%i%i%i",
&sec,&mod,&mboInd,mboName,&bus,&busPos,&roc,&samPos,&sam);
Int_t n=sec*4+mod;
if (!set[n]) return;;
HMdcMboReadoutMoth& r=(*this)[sec][mod][mboInd];
if (strcmp(r.GetName(),mboName)) {
ERROR_msg(HMessageMgr::DET_MDC,"MBO names are different in MdcRawStruct and in Ascii file");
return;
}
r.fill(bus,busPos,roc,samPos,sam);
set[n]=999;
}
void HMdcMboReadout::putAsciiHeader(TString& header) {
header=
"# Readout addresses of all MDC motherboards\n"
"# Format:\n"
"# sector module MBO index MBO name\n"
"# BUS BUS position ROC SAM position SAM\n";
}
Bool_t HMdcMboReadout::writeline(Char_t *buf, Int_t sec, Int_t mod, Int_t mbo) {
HMdcMboReadoutMoth &moth=(*this)[sec][mod][mbo];
Int_t bus=moth.getBus();
if (bus==-1) return kFALSE;
sprintf(buf,"%1i %1i %2i %s %6i %3i %3i %4i %3i\n",
sec, mod, mbo, moth.GetName(), bus,
moth.getBusPos(), moth.getRoc(),
moth.getSamPos(), moth.getSam());
return kTRUE;
}
Last change: Sat May 22 13:02:53 2010
Last generated: 2010-05-22 13:02
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.