using namespace std;
#include "hrpcthrespar.h"
#include "hpario.h"
#include "hdetpario.h"
#include <iostream>
#include <iomanip>
#include <ctype.h>
#include <stdlib.h>
ClassImp(HRpcThresChan)
ClassImp(HRpcThresBoard)
ClassImp(HRpcThresPar)
HRpcThresBoard::HRpcThresBoard() {
array = new TObjArray(128);
for(Int_t i=0;i<128;i++) array->AddAt(new HRpcThresChan(),i);
}
HRpcThresBoard::~HRpcThresBoard() {
array->Delete();
delete array;
}
void HRpcThresBoard::clear() {
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;
array = new TObjArray(nBoards);
for(Int_t i=0; i<nBoards; i++) array->AddAt(new HRpcThresBoard(),i);
}
HRpcThresPar::~HRpcThresPar() {
array->Delete();
delete array;
}
Bool_t HRpcThresPar::init(HParIo* inp,Int_t* set) {
HDetParIo* input=inp->getDetParIo("HRpcParIo");
if (input) return (input->init(this,set));
return kFALSE;
}
Int_t HRpcThresPar::write(HParIo* output) {
HDetParIo* out=output->getDetParIo("HRpcParIo");
if (out) return out->write(this);
return -1;
}
void HRpcThresPar::clear() {
array->Delete();
status=kFALSE;
resetInputVersions();
}
void HRpcThresPar::fill(Int_t id,Int_t chan, Float_t TofTh, Float_t TotTh) {
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) {
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) {
for(Int_t i=0;i<nBoards;i++) {
HRpcThresBoard& b=(*this)[i];
if (b[0].getTofTh()<-100) continue;
for(Int_t j=0;j<b.getSize();j++) {
HRpcThresChan& chan = b[j];
if (chan.getTofTh()>=-100 && chan.getTotTh()>=-100) {
fout<<setw(3)<<(offset+i)<<setw(5)<<j<<" "
<<chan.getTofTh()<<setw(3)<<chan.getTotTh()<<"\n";
}
else fout<<"\n";
}
}
}
void HRpcThresPar::printParam() {
printf("Parameter container for the thresholds\n");
printf("Format:\n");
printf("subeventId TrbChannel threshold_tof threshold_tot\n");
Text_t buf[155];
Int_t n0 = getSize();
for(Int_t i0=0; i0<n0; i0++) {
Int_t n1 = (*this)[i0].getSize();
if((*this)[i0][0].getTofTh()<-100) continue;
for(Int_t i1=0; i1<n1; i1++) {
HRpcThresChan& pChan=(*this)[i0][i1];
sprintf(buf, "%4i %4i %5.1f %5.1f\n",i0+offset, i1, pChan.getTofTh(), pChan.getTotTh());
printf(buf,strlen(buf));
}
}
}
Last change: Sat May 22 13:11:25 2010
Last generated: 2010-05-22 13:11
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.