// RooRealConstant provides static functions to create and keep track
// of RooRealVar constants. Instead of creating such constants by
// hand (e.g. RooRealVar one("one","one",1)), simply use
// <pre>
// RooRealConstant::value(1.0)
// </pre>
// whenever a reference to RooRealVar with constant value 1.0 is needed.
// RooRealConstant keeps an internal database of previously created
// RooRealVar objects and will recycle them as appropriate.
// END_HTML
#include "RooFit.h"
#include "RooRealConstant.h"
#include "RooRealConstant.h"
#include "RooConstVar.h"
#include "RooArgList.h"
#include "RooSentinel.h"
ClassImp(RooRealConstant)
;
RooArgList* RooRealConstant::_constDB = 0;
TIterator* RooRealConstant::_constDBIter = 0;
void RooRealConstant::cleanup()
{
if (_constDB) {
delete _constDB ;
delete _constDBIter ;
_constDB = 0 ;
}
}
RooConstVar& RooRealConstant::value(Double_t value)
{
init() ;
RooConstVar* var ;
while((var=(RooConstVar*)_constDBIter->Next())) {
if (var->getVal()==value) return *var ;
}
char label[128] ;
sprintf(label,"%8.6f",value) ;
var = new RooConstVar(label,label,value) ;
var->setAttribute("RooRealConstant_Factory_Object",kTRUE) ;
_constDB->addOwned(*var) ;
return *var ;
}
void RooRealConstant::init()
{
if (!_constDB) {
_constDB = new RooArgList("RooRealVar Constants Database") ;
_constDBIter = _constDB->createIterator() ;
RooSentinel::activate() ;
} else {
_constDBIter->Reset() ;
}
}
Last change: Wed Jun 25 08:33:58 2008
Last generated: 2008-06-25 08:33
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.