#include "RooFit.h"
#include "Riostream.h"
#include "RooHistPdf.h"
#include "RooHistPdf.h"
#include "RooDataHist.h"
#include "RooMsgService.h"
ClassImp(RooHistPdf)
;
RooHistPdf::RooHistPdf() : _dataHist(0)
{
}
RooHistPdf::RooHistPdf(const char *name, const char *title, const RooArgSet& vars,
const RooDataHist& dhist, Int_t intOrder) :
RooAbsPdf(name,title),
_depList("depList","List of dependents",this),
_dataHist((RooDataHist*)&dhist),
_codeReg(10),
_intOrder(intOrder)
{
_depList.add(vars) ;
const RooArgSet* dvars = dhist.get() ;
if (vars.getSize()!=dvars->getSize()) {
coutE(InputArguments) << "RooHistPdf::ctor(" << GetName()
<< ") ERROR variable list and RooDataHist must contain the same variables." << endl ;
assert(0) ;
}
TIterator* iter = vars.createIterator() ;
RooAbsArg* arg ;
while((arg=(RooAbsArg*)iter->Next())) {
if (!dvars->find(arg->GetName())) {
coutE(InputArguments) << "RooHistPdf::ctor(" << GetName()
<< ") ERROR variable list and RooDataHist must contain the same variables." << endl ;
assert(0) ;
}
}
delete iter ;
}
RooHistPdf::RooHistPdf(const RooHistPdf& other, const char* name) :
RooAbsPdf(other,name),
_depList("depList",this,other._depList),
_dataHist(other._dataHist),
_codeReg(other._codeReg),
_intOrder(other._intOrder)
{
}
Double_t RooHistPdf::evaluate() const
{
Double_t ret = _dataHist->weight(_depList,_intOrder,kTRUE) ;
return ret ;
}
Int_t RooHistPdf::getAnalyticalIntegral(RooArgSet& allVars, RooArgSet& analVars, const char* rangeName) const
{
if (rangeName!=0) {
return 0 ;
}
if ((allVars.getSize()==_depList.getSize()) &&
matchArgs(allVars,analVars,_depList)) return 1000 ;
if (_intOrder>0) {
return 0 ;
}
RooArgSet* allVarsSel = (RooArgSet*) allVars.selectCommon(_depList) ;
if (allVarsSel->getSize()==0) {
delete allVarsSel ;
return 0 ;
}
Int_t code(0),n(0) ;
TIterator* iter = _depList.createIterator() ;
RooAbsArg* arg ;
while((arg=(RooAbsArg*)iter->Next())) {
if (allVars.find(arg->GetName())) code |= (1<<n) ;
n++ ;
}
delete iter ;
analVars.add(*allVarsSel) ;
Int_t masterCode = _codeReg.store(&code,1,new RooArgSet(*allVarsSel))+1 ;
delete allVarsSel ;
return masterCode ;
}
Double_t RooHistPdf::analyticalIntegral(Int_t code, const char* ) const
{
if (code==1000) return _dataHist->sum(kFALSE) ;
RooArgSet* intSet = 0;
_codeReg.retrieve(code-1,intSet) ;
return _dataHist->sum(*intSet,_depList,kTRUE) ;
}
Last update: Thu Jan 17 08:44:59 2008
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.