//*-- AUTHOR Diego Gonzalez-Diaz //*-- created : 01/02/2008 by Diego Gonzalez-Diaz //_HADES_CLASS_DESCRIPTION /////////////////////////////////////////////////////////////////////// // HRpcThresPar // // Container class for RPC thresholds // /////////////////////////////////////////////////////////////////////// using namespace std; #include "hrpcthrespar.h" #include "hpario.h" #include "hdetpario.h" #include #include #include #include ClassImp(HRpcThresChan) ClassImp(HRpcThresBoard) ClassImp(HRpcThresPar) HRpcThresBoard::HRpcThresBoard() { // constructor creates an array of 128 channels array = new TObjArray(128); for(Int_t i=0;i<128;i++) array->AddAt(new HRpcThresChan(),i); } HRpcThresBoard::~HRpcThresBoard() { // destructor deletes the array of channels array->Delete(); delete array; } void HRpcThresBoard::clear() { // calls the clear function for each channel for(Int_t i=0;i<128;i++) (*this)[i].clear(); } HRpcThresPar::HRpcThresPar(const Char_t* name, const Char_t* title, const Char_t* context, Int_t a_offset, Int_t a_nBoards) : HParSet(name,title,context) { offset = a_offset; nBoards = a_nBoards; // constructor creates an empty array of size nBoards array = new TObjArray(nBoards); for(Int_t i=0; iAddAt(new HRpcThresBoard(),i); } HRpcThresPar::~HRpcThresPar() { // destructor array->Delete(); delete array; } Bool_t HRpcThresPar::init(HParIo* inp,Int_t* set) { // initializes the container from an input HDetParIo* input=inp->getDetParIo("HRpcParIo"); if (input) return (input->init(this,set)); return kFALSE; } Int_t HRpcThresPar::write(HParIo* output) { // writes the container to an output HDetParIo* out=output->getDetParIo("HRpcParIo"); if (out) return out->write(this); return -1; } void HRpcThresPar::clear() { // deletes all HRpcThresBoard objects from the array and resets the input versions array->Delete(); status=kFALSE; resetInputVersions(); } void HRpcThresPar::fill(Int_t id,Int_t chan, Float_t TofTh, Float_t TotTh) { // creates the HRpcThresBoard objects, if not existing, and fills the channel HRpcThresBoard* p=getBoard(id); if (!p) { p=new HRpcThresBoard(); array->AddAt(p,id-offset); } HRpcThresChan* c=p->getChannel(chan); if (c) { c->fill(TofTh,TotTh); } else { Error("Thresholds filling","Invalid channel number %i (ignore)",chan); } } void HRpcThresPar::readline(const Char_t *buf, Int_t *set) { // reads one line from ASCII file I/O and fills the channel Int_t id, chan; Float_t TofTh, TotTh; sscanf(buf,"%i%i %f%f",&id,&chan,&TofTh,&TotTh); fill(id,chan,TofTh,TotTh); } void HRpcThresPar::putAsciiHeader(TString& header) { header= "#Parameter container for the thresholds\n" "#Format:\n" "#subeventId TrbChannel threshold_tof threshold_tot\n"; } void HRpcThresPar::write(fstream& fout) { // writes the information of all non-zero HRpcThresBoard objects to the ASCII file for(Int_t i=0;i=-100 && chan.getTotTh()>=-100) {//In principle only positive values are used fout<