//*-- AUTHOR : J. Kempter //*-- Modified : 17/01/2002 by I. Koenig //_HADES_CLASS_DESCRIPTION //////////////////////////////////////////////////////////////////////////// // HMdcCalParRaw // // Container class for the TDC calibration parameters of the MDC // //////////////////////////////////////////////////////////////////////////// using namespace std; #include #include "hmdccalparraw.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 #include ClassImp(HMdcCalParTdc) ClassImp(HMdcCalParMbo) ClassImp(HMdcCalParRawMod) ClassImp(HMdcCalParRawSec) ClassImp(HMdcCalParRaw) void HMdcCalParTdc::fill(HMdcCalParTdc& r) { slope=r.getSlope(); offset=r.getOffset(); slopeErr=r.getSlopeErr(); offsetErr=r.getOffsetErr(); slopeMethod=r.getSlopeMethod(); offsetMethod=r.getOffsetMethod(); } HMdcCalParMbo::HMdcCalParMbo(Int_t tdc, const Text_t* name) { // constructor takes to number of TDC channels and the name of the MBO SetName(name); array = new TObjArray(tdc); for (Int_t i=0; iAddAt(new HMdcCalParTdc(),i); } HMdcCalParMbo::~HMdcCalParMbo() { // destructor array->Delete(); delete array; } HMdcCalParRawMod::HMdcCalParRawMod(Int_t mbo) { // constructor takes the number of MBOs array = new TObjArray(mbo); } HMdcCalParRawMod::~HMdcCalParRawMod() { // destructor array->Delete(); delete array; } void HMdcCalParRawMod::createMbo(Int_t mbo, Int_t nTdcs, const Char_t* mboName) { // creates the array object of type HMdcCalParMbo if (mboGetSize() && array->At(mbo)==NULL) { array->AddAt(new HMdcCalParMbo(nTdcs,mboName),mbo); } } HMdcCalParRawSec::HMdcCalParRawSec(Int_t mod) { // constructor takes the number of modules array = new TObjArray(mod); for (Int_t i=0; iAddAt(new HMdcCalParRawMod(),i); } HMdcCalParRawSec::~HMdcCalParRawSec() { // destructor array->Delete(); delete array; } HMdcCalParRaw::HMdcCalParRaw(const Char_t* name,const Char_t* title, const Char_t* context,Int_t n) : HParSet(name,title,context) { // constructor strcpy(detName,"Mdc"); array = new TObjArray(n); for (Int_t i=0; iAddAt(new HMdcCalParRawSec(),i); gHades->getRuntimeDb()->getContainer("MdcRawStruct"); } HMdcCalParRaw::~HMdcCalParRaw() { // destructor array->Delete(); delete array; } Bool_t HMdcCalParRaw::init(HParIo* inp,Int_t* set) { // creates the array objects of type HMdcCalParRawMbo using the data in the parameter container // MdcRawStruct and initializes the container from an input HMdcRawStruct* pRawStruct= (HMdcRawStruct*)gHades->getRuntimeDb()->findContainer("MdcRawStruct"); if (pRawStruct==NULL) { Error("HMdcCalParRaw::init()","MdcCalParRaw not initialized, container MdcRawStruct not found"); return kFALSE; } for(Int_t s=0;sgetDetParIo("HMdcParIo"); if (input) return (input->init(this,set)); return kFALSE; } Int_t HMdcCalParRaw::write(HParIo* output) { // writes the container to an output HDetParIo* out=output->getDetParIo("HMdcParIo"); if (out) return out->write(this); return -1; } void HMdcCalParRaw::readline(const Char_t* buf, Int_t* set) { // decodes one line read from ascii file I/O and calls HMdcCalParTdc::fill(...) Int_t sec, mod, mbo, tdc, slopeMethod,offsetMethod; Float_t slope, offset, slopeErr,offsetErr; Char_t mboName[10]; sscanf(buf,"%i%i%i%s%i%f%f%f%f%i%i", &sec, &mod, &mbo, mboName, &tdc, &slope, &offset, &slopeErr, &offsetErr, &slopeMethod, &offsetMethod); Int_t n=sec*4+mod; if (!set[n]) return; HMdcCalParMbo& rMbo=(*this)[sec][mod][mbo]; rMbo.SetName(mboName); HMdcCalParTdc& t=rMbo[tdc]; t.fill(slope,offset,slopeErr,offsetErr,slopeMethod,offsetMethod); set[n]=999; } void HMdcCalParRaw::putAsciiHeader(TString& header) { // puts the ascii header to the string used in HMdcParAsciiFileIo header= "# Calibration parameters of the MDC\n" "# Format:\n" "# sector module mbo mboName tdc slope offset slopeErr offsetErr slopeMethod offsetMethod\n"; } Bool_t HMdcCalParRaw::writeline(Char_t *buf, Int_t sec, Int_t mod, Int_t mbo, Int_t tdc) { // writes one line to the buffer used by ascii file I/O HMdcCalParMbo& rMbo=(*this)[sec][mod][mbo]; HMdcCalParTdc& chan=rMbo[tdc]; sprintf(buf,"%1i %1i %2i %s %3i % 10.5f % 10.2f % 12.5f % 12.2f %1i %1i \n", sec, mod, mbo, rMbo.GetName(), tdc, chan.getSlope(), chan.getOffset(), chan.getSlopeErr(), chan.getOffsetErr(),chan.getSlopeMethod(), chan.getOffsetMethod()); return kTRUE; } void HMdcCalParRaw::clear() { // clears the container for(Int_t s=0;sgetMsg()->info(10,HMessageMgr::DET_MDC,GetName(), "%1i %1i %2i %s %3i % 10.5f % 10.2f % 12.5f % 12.2f %1i %1i\n", s, m, l, mbo.GetName(),c, mbo[c].getSlope(),mbo[c].getOffset(), mbo[c].getSlopeErr(),mbo[c].getOffsetErr(), mbo[c].getSlopeMethod(),mbo[c].getOffsetMethod() ); } } } } SEPERATOR_msg("-",60); } void HMdcCalParRaw::shiftOffsets(Float_t shift0,Float_t shift1,Float_t shift2,Float_t shift3) { // shift offsets per module type by global offset // new_offset = old_offset+shift; // offset in tdc channels with negative offsetErr (indicating problems) // will be excluded Float_t shift=0; for(Int_t s=0;s= 0) { Float_t off = mbo[c].getOffset(); off+=shift; mbo[c].setOffset(off); } } } } } } void HMdcCalParRaw::setSlopes(Float_t sl0,Float_t sl1,Float_t sl2,Float_t sl3) { // set global slopes per module // if slx < 0 it is not used for(Int_t s=0;s 0) slope = sl0; else if(m==1 && sl1 > 0) slope = sl1; else if(m==2 && sl2 > 0) slope = sl2; else if(m==3 && sl3 > 0) slope = sl3; if(slope < 0) continue; for(Int_t l=0;l> array; fAuthor.Streamer(R__b); fDescription.Streamer(R__b); fRunsUsed.Streamer(R__b); fValidity.Streamer(R__b); R__b.CheckByteCount(R__s, R__c, HMdcCalParRaw::IsA()); } else if(R__v==2) { HParSet::Streamer(R__b); R__b >> array; R__b.CheckByteCount(R__s, R__c, HMdcCalParRaw::IsA()); } else{Error("HMdcCalParRaw:Streamer()","Read version not known!");} } else { HMdcCalParRaw::Class()->WriteBuffer(R__b,this); } }