//*-- AUTHOR : J. Kempter //*-- Modified : 17/01/2002 by I. Koenig //*-- Modified : 06/09/2004 by S. Lang //*-- Modified : 13/09/2004 by J. Wuestenfeld //_HADES_CLASS_DESCRIPTION //////////////////////////////////////////////////////////////////////////// // HMdcTdcThreshold // // Container class for the TDC threshold parameters of the MDC // //////////////////////////////////////////////////////////////////////////// using namespace std; #include #include "hmdctdcthreshold.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 ClassImp(HMdcTdcThresholdDbo) ClassImp(HMdcTdcThresholdMbo) ClassImp(HMdcTdcThresholdMod) ClassImp(HMdcTdcThresholdSec) ClassImp(HMdcTdcThreshold) void HMdcTdcThresholdDbo::fill(HMdcTdcThresholdDbo& r) { // copies the threshold threshold=r.getThreshold(); } HMdcTdcThresholdMbo::HMdcTdcThresholdMbo(Int_t dbo, const Text_t* name) { // constructor takes to number of DBOs and the name of the MBO SetName(name); array = new TObjArray(dbo); for (Int_t i=0; iAddAt(new HMdcTdcThresholdDbo(),i); } HMdcTdcThresholdMbo::~HMdcTdcThresholdMbo() { // destructor array->Delete(); delete array; } HMdcTdcThresholdMod::HMdcTdcThresholdMod(Int_t mbo) { // constructor takes the number of MBOs // The array objects of type HMdcThresholdMbo are created in the init function. array = new TObjArray(mbo); } HMdcTdcThresholdMod::~HMdcTdcThresholdMod() { // destructor array->Delete(); delete array; } void HMdcTdcThresholdMod::createMbo(Int_t mbo, Int_t nDbos, const Char_t* mboName) { // creates the array object of type HMdcTdcThresholdMbo if (mboGetSize() && array->At(mbo)==NULL) { array->AddAt(new HMdcTdcThresholdMbo(nDbos,mboName),mbo); } } HMdcTdcThresholdSec::HMdcTdcThresholdSec(Int_t mod) { // constructor takes the number of modules array = new TObjArray(mod); for (Int_t i=0; iAddAt(new HMdcTdcThresholdMod(),i); } HMdcTdcThresholdSec::~HMdcTdcThresholdSec() { // destructor array->Delete(); delete array; } HMdcTdcThreshold::HMdcTdcThreshold(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); for (Int_t i=0; iAddAt(new HMdcTdcThresholdSec(),i); pRawStruct=(HMdcRawStruct*)(gHades->getRuntimeDb()->getContainer("MdcRawStruct")); } HMdcTdcThreshold::~HMdcTdcThreshold() { // destructor array->Delete(); delete array; } Bool_t HMdcTdcThreshold::init(HParIo* inp,Int_t* set) { // creates the array objects of type HMdcTdcThresholdMbo using the data in the parameter container // MdcRawStruct and initializes the container from an input if (pRawStruct==NULL) { Error("HMdcTdcThreshold::init()","MdcTdcThreshold not initialized, container MdcRawStruct is NULL"); return kFALSE; } for(Int_t s=0;sgetDetParIo("HMdcParIo"); if (input) return (input->init(this,set)); return kFALSE; } Int_t HMdcTdcThreshold::write(HParIo* output) { // writes the container to an output HDetParIo* out=output->getDetParIo("HMdcParIo"); if (out) return out->write(this); return -1; } void HMdcTdcThreshold::readline(const Char_t* buf, Int_t* set) { // decodes one line read from ascii file I/O and calls HMdcTdcThresholdDbo::setThreshold(...) Int_t sec, mod, mbo, dbo; Int_t thresh; Char_t mboName[10]; sscanf(buf,"%i%i%i%s%i%x", &sec, &mod, &mbo, mboName, &dbo, &thresh); Int_t n=sec*4+mod; if (!set[n]) return; HMdcTdcThresholdMbo& rMbo=(*this)[sec][mod][mbo]; rMbo.SetName(mboName); HMdcTdcThresholdDbo& db=rMbo[dbo]; db.setThreshold(thresh); set[n]=999; } void HMdcTdcThreshold::readlinefromfile(const Char_t* buf) { // decodes one line read from ascii file and calls HMdcTdcThresholdDbo::setThreshold(...) Int_t sec, mod, mbo, dbo; Int_t thresh; sscanf(buf,"%i%i%i%i%x", &mod, &sec, &mbo, &dbo, &thresh); HMdcRawModStru & rawMod=(*pRawStruct)[sec][mod]; // cout << rawMod.getSize() << endl; if(rawMod.getSize()>mbo) { HMdcRawMothStru &rawMbo=rawMod[mbo]; // cout << rawMbo.getNTdcs() << endl; if (rawMbo.getNTdcs() > dbo*16 ) { HMdcTdcThresholdMbo& rMbo=(*this)[sec][mod][mbo]; HMdcTdcThresholdDbo& db=rMbo[dbo]; db.setThreshold(thresh); } // else{cout<<"dbo number to big"<mbo) { HMdcRawMothStru &rawMbo=rawMod[mbo]; //cout << rawMbo.getNTdcs() << endl; if (rawMbo.getNTdcs() > dbo*16 ) { HMdcTdcThresholdMbo& rMbo=(*this)[sec][mod][mbo]; HMdcTdcThresholdDbo& db=rMbo[dbo]; thresh = db.getThreshold(); sprintf(buf, "%i %i %i %i %x", mod, sec, mbo, dbo, thresh); } else sprintf(buf,"%i %i %i %i 60",mod,sec,mbo,dbo); //else{cout<<"dbo number to big"<getMsg()->info(10,HMessageMgr::DET_MDC,GetName(), "%1i %1i %2i %s % 1i %3x", s, m, l, mbo.GetName(), c, mbo[c].getThreshold()); } } } } SEPERATOR_msg("-",60); } void HMdcTdcThreshold::Streamer(TBuffer &R__b) { // Stream an object of class HMdcTdcThreshold. UInt_t R__s, R__c; if (R__b.IsReading()) { Version_t R__v = R__b.ReadVersion(&R__s, &R__c); if (R__v) { } HParSet::Streamer(R__b); R__b >> array; R__b >> oraVersion; if (R__v==3) { Int_t* dummy; R__b >> dummy; // HMdcRawStruct* R__b >> dummy; // HMdcRawSecStru* R__b >> dummy; // HMdcMboReadout* } R__b.CheckByteCount(R__s, R__c, HMdcTdcThreshold::IsA()); } else { R__c = R__b.WriteVersion(HMdcTdcThreshold::IsA(), kTRUE); HParSet::Streamer(R__b); R__b << array; R__b << oraVersion; R__b.SetByteCount(R__c, kTRUE); } }