using namespace std;
#include "hmdccalpar.h"
#include "hades.h"
#include "hruntimedb.h"
#include "hspectrometer.h"
#include "hmdcdetector.h"
#include "hpario.h"
#include "hdetpario.h"
#include "hmdcgeomstruct.h"
#include "hmdclookupraw.h"
#include "hmessagemgr.h"
ClassImp(HMdcCalParCell)
ClassImp(HMdcCalParLayer)
ClassImp(HMdcCalParMod)
ClassImp(HMdcCalParSec)
ClassImp(HMdcCalPar)
HMdcCalParLayer::HMdcCalParLayer(Int_t n) {
array = new TObjArray(n);
for (Int_t i = 0; i < n; ++i)
array->AddAt(new HMdcCalParCell(),i);
}
HMdcCalParLayer::~HMdcCalParLayer() {
array->Delete();
delete array;
}
Int_t HMdcCalParLayer::getSize() {
return array->GetEntries();
}
HMdcCalParMod::HMdcCalParMod(Int_t sec, Int_t mod, Int_t n) {
array = new TObjArray(n);
HMdcGeomStruct* pMdc=
(HMdcGeomStruct*)gHades->getRuntimeDb()->getContainer("MdcGeomStruct");
if (pMdc) {
HMdcGeomSecStru& pS=(*pMdc)[sec];
HMdcGeomModStru& pM=pS[mod];
for (Int_t i = 0; i < n; i++) {
array->AddAt(new HMdcCalParLayer(pM[i]),i);
}
}
else cerr<<"HMdcCalParMod not created, container MdcGeomStruct not found"<<endl;
}
HMdcCalParMod::~HMdcCalParMod() {
array->Delete();
delete array;
}
Int_t HMdcCalParMod::getSize() {
return array->GetEntries();
}
HMdcCalParSec::HMdcCalParSec(Int_t sec, Int_t n) {
sector=sec;
array = new TObjArray(n);
for (Int_t i = 0; i < n; i++)
array->AddAt(new HMdcCalParMod(sector,i,6),i);
}
HMdcCalParSec::~HMdcCalParSec() {
array->Delete();
delete array;
}
Int_t HMdcCalParSec::getSize() {
return array->GetEntries();
}
HMdcCalPar::HMdcCalPar(const Char_t* name,const Char_t* title,
const Char_t* context)
: HParSet(name,title,context) {
strcpy(detName,"Mdc");
array = new TObjArray(6);
for (Int_t i = 0; i < 6; i++)
array->AddAt(new HMdcCalParSec(i, 4),i);
ntuple=0;
HRuntimeDb* rtdb=gHades->getRuntimeDb();
HMdcCalParRaw *calparraw=0;
calparraw=(HMdcCalParRaw*)rtdb->getContainer("MdcCalParRaw");
HMdcLookupRaw *lookup=0;
lookup=(HMdcLookupRaw*)rtdb->getContainer("MdcLookupRaw");
}
HMdcCalPar::~HMdcCalPar() {
array->Delete();
delete array;
delete ntuple;
}
Int_t HMdcCalPar::getSize() {
return array->GetEntries();
}
Bool_t HMdcCalPar::init(HParIo* inp,Int_t* set) {
HRuntimeDb* rtdb=gHades->getRuntimeDb();
HMdcLookupRaw *lookup=
(HMdcLookupRaw*)rtdb->getContainer("MdcLookupRaw");
if (!lookup) return kFALSE;
HMdcCalParRaw *pRaw=
(HMdcCalParRaw*)rtdb->getContainer("MdcCalParRaw");
if (!pRaw) return kFALSE;
if (!pRaw->hasChanged() && !lookup->hasChanged()) return kTRUE;
clear();
for(Int_t s=0; s<6; s++) {
for(Int_t mo=0; mo<4; mo++) {
HMdcCalParMod& mod=(*this)[s][mo];
Int_t nLay=mod.getSize();
for(Int_t l=0; l<nLay; l++) {
for(Int_t c=0; c<mod[l].getSize(); c++) {
HMdcLookupCell &cell=(*lookup)[s][mo][l][c];
Int_t m=cell.getNMoth();
Int_t t=cell.getNChan();
if (m>=0 && t>=0) {
HMdcCalParCell& wire=mod[l][c];
HMdcCalParTdc& tdc=(*pRaw)[s][mo][m][t];
wire.fill(tdc.getSlope(),tdc.getOffset(),
tdc.getSlopeErr(),tdc.getOffsetErr(),
tdc.getSlopeMethod(),tdc.getOffsetMethod());
}
}
}
}
}
changed=kTRUE;
Int_t v1=pRaw->getInputVersion(1);
Int_t v2=pRaw->getInputVersion(2);
versions[1]=v1;
versions[2]=v2;
return kTRUE;
}
Int_t HMdcCalPar::write(HParIo* output) {
HDetParIo* out=output->getDetParIo("HMdcParIo");
if (out) return out->write(this);
return -1;
}
void HMdcCalPar::clear() {
for(Int_t s=0;s<6;s++) {
HMdcCalParSec& sec=(*this)[s];
for(Int_t m=0;m<4;m++) {
HMdcCalParMod& mod=sec[m];
Int_t nl=mod.getSize();
for(Int_t l=0;l<nl;l++) {
HMdcCalParLayer& lay=mod[l];
Int_t nc=lay.getSize();
for(Int_t n=0;n<nc;n++) {
HMdcCalParCell& cell=lay[n];
cell.clear();
}
}
}
}
status=kFALSE;
resetInputVersions();
}
TNtuple* HMdcCalPar::getNtuple() {
if (ntuple) ntuple->Reset();
else ntuple=new TNtuple("MdcCalParNtuple","Ntuple of Mdc calibration parameters",
"s:m:l:c:slo:off");
Float_t slo, off;
for(Int_t s=0;s<6;s++) {
HMdcCalParSec& sec=(*this)[s];
for(Int_t m=0;m<4;m++) {
HMdcCalParMod& mod=sec[m];
Int_t nl=mod.getSize();
for(Int_t l=0;l<nl;l++) {
HMdcCalParLayer& lay=mod[l];
Int_t nc=lay.getSize();
for(Int_t n=0;n<nc;n++) {
HMdcCalParCell& cell=lay[n];
slo=cell.getSlope();
off=cell.getOffset();
ntuple->Fill(s,m,l,n,slo,off);
}
}
}
}
return ntuple;
}
Bool_t HMdcCalPar::fillMdcCalParRaw(HMdcCalParRaw& rPar) {
HRuntimeDb* rtdb=gHades->getRuntimeDb();
rPar.clear();
HMdcLookupRaw *lookup=
(HMdcLookupRaw*)rtdb->getContainer("MdcLookupRaw");
if (!lookup) {
ERROR_msg(HMessageMgr::DET_MDC,"lookup table MdcLookupRaw not found");
return kFALSE;
}
for(Int_t s=0; s<6; s++) {
for(Int_t mo=0; mo<4; mo++) {
HMdcCalParMod& mod=(*this)[s][mo];
Int_t nLay=mod.getSize();
for(Int_t l=0; l<nLay; l++) {
for(Int_t c=0; c<mod[l].getSize(); c++) {
HMdcLookupCell &cell=(*lookup)[s][mo][l][c];
Int_t m=cell.getNMoth();
Int_t t=cell.getNChan();
if (m>=0 && t>=0) {
HMdcCalParCell& wire=mod[l][c];
HMdcCalParTdc& tdc=rPar[s][mo][m][t];
tdc.setOffset(wire.getOffset());
tdc.fill(wire.getSlope(),wire.getOffset(),
wire.getSlopeErr(),wire.getOffsetErr(),
wire.getSlopeMethod(),wire.getOffsetMethod());
}
}
}
}
}
return kTRUE;
}
void HMdcCalPar::putAsciiHeader(TString& header) {
header=
"# Calibration parameters of the MDC\n"
"# Format:\n"
"# sec mod mbo tdc slope offset slopeErr offsetErr slopeMethod offsetMethod\n";
}
Bool_t HMdcCalPar::writeline(Char_t *buf, Int_t sec, Int_t mod, Int_t lay, Int_t cell) {
HMdcCalParCell &chan=(*this)[sec][mod][lay][cell];
sprintf(buf,"%1i %1i %1i %3i %10.5f %10.2f %12.5f %12.2f %1i %1i\n",
sec, mod, lay, cell,
chan.getSlope(), chan.getOffset(),chan.getSlopeErr(), chan.getOffsetErr(),
chan.getSlopeMethod(), chan.getOffsetMethod());
return kTRUE;
}
Last change: Sat May 22 13:00:00 2010
Last generated: 2010-05-22 13:00
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.