#include "hhyprecpar.h"
#include "hpario.h"
#include "hdetpario.h"
#include "hparamlist.h"
ClassImp(HHypRecPar)
HHypRecPar::HHypRecPar(const Char_t *name, const Char_t *title, const Char_t *context):HParCond(name, title,
context)
{
clear();
}
HHypRecPar::~HHypRecPar(void)
{
for (Int_t i = 0; i < numofparams; i++) delete hypCutID[i];
numofparams=0;
}
Bool_t HHypRecPar::init(HParIo * inp, Int_t * set)
{
HDetParIo *input = inp->getDetParIo("HCondParIo");
if (input)
return (input->init(this, set));
return kFALSE;
}
Int_t HHypRecPar::write(HParIo * output)
{
HDetParIo *out = output->getDetParIo("HCondParIo");
if (out)
return out->write(this);
return kFALSE;
}
void HHypRecPar::clear(void)
{
numofparams = 0;
hypCutValue.Set(numofparams);
}
void HHypRecPar::registerCut(const Char_t * cutID) {
setCut(cutID,0);
}
Bool_t HHypRecPar::getCut(const Char_t * cutID, Float_t & cutValue)
{
for (Int_t i = 0; i < numofparams; i++)
if (strcmp(hypCutID[i]->Data(),cutID) == 0) {
cutValue = hypCutValue[i];
return kTRUE;
}
return kFALSE;
}
void HHypRecPar::setCut(const Char_t * cutID, Float_t cutValue)
{
for (Int_t i = 0; i < numofparams; i++)
if (hypCutID[i]->CompareTo(cutID)==0) {
hypCutValue[i] = cutValue;
return;
}
numofparams++;
hypCutValue.Set(numofparams);
if (numofparams == MAX_PARAM_VALUES) {
std::cout << "HHypRecPar::setCut: MAX_PARAM_VALUES reached" << std::endl;
return;
}
hypCutID[numofparams-1] = new TString(cutID);
hypCutValue[numofparams-1] = cutValue;
}
void HHypRecPar::putParams(HParamList * l)
{
if (!l)
return;
for (Int_t i = 0; i < numofparams; i++) l->add(hypCutID[i]->Data(), hypCutValue[i]);
}
void HHypRecPar::print(void)
{
HParSet::print();
for (Int_t i = 0; i < numofparams; i++) cout << hypCutID[i]->Data() << ":" << hypCutValue[i] << endl;
}
Bool_t HHypRecPar::getParams(HParamList * l)
{
if (!l)
return kFALSE;
for (Int_t i = 0; i < numofparams; i++) {
if (!(l->fill(hypCutID[i]->Data(),&hypCutValue[i]))) {
cout << "parameter " << hypCutID[i]->Data() << " registered but not found in param source" << endl;
return kFALSE;
}
}
return kTRUE;
}
#if 1
void HHypRecPar::Streamer(TBuffer & R__b)
{
if (R__b.IsReading())
{
Version_t R__v = R__b.ReadVersion();
if (R__v != 2) {
cout << "Version 1 not supported" << endl;
return;
}
TObject::Streamer(R__b);
HParCond::Streamer(R__b);
Int_t tmp_numofparams;
R__b >> tmp_numofparams;
for (Int_t i=0; i<tmp_numofparams; i++) {
TString tmp_hypCutID;
Float_t tmp_hypCutValue;
R__b >> tmp_hypCutValue;
R__b >> tmp_hypCutID;
setCut((Char_t*)tmp_hypCutID.Data(),tmp_hypCutValue);
}
} else {
R__b.WriteVersion(HHypRecPar::IsA());
TObject::Streamer(R__b);
HParCond::Streamer(R__b);
R__b << numofparams;
for (Int_t i=0; i<numofparams; i++) {
R__b << (Float_t)hypCutValue[i];
R__b << *hypCutID[i];
}
}
}
#endif
Last change: Sat May 22 12:58:07 2010
Last generated: 2010-05-22 12:58
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.