Skip to content

Commit

Permalink
Adding support for AddPdfs in RooMultiPdf
Browse files Browse the repository at this point in the history
  • Loading branch information
nucleosynthesis committed Sep 20, 2013
1 parent a549331 commit 4040d38
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 2 additions & 0 deletions interface/RooMultiPdf.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ arg8=RooCmdArg::none());
*/
bool checkIndexDirty() const;
double getCorrection() const;
RooAbsPdf *getCurrentPdf() const;
int getNumPdfs(){return nPdfs;};
void setCorrectionFactor(PenatlyScheme penal);

Expand All @@ -75,6 +76,7 @@ arg8=RooCmdArg::none());
mutable Int_t _oldIndex;

Double_t evaluate() const;
Double_t getLogVal(const RooArgSet *set = 0) const;
//std::string createCorrectionString(); // should only do this once really
double cFactor;

Expand Down
33 changes: 32 additions & 1 deletion src/RooMultiPdf.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include "../interface/RooMultiPdf.h"
#include "RooRealVar.h"
#include "RooAddPdf.h"

ClassImp(RooMultiPdf)

Expand Down Expand Up @@ -82,12 +83,42 @@ double RooMultiPdf::getCorrection() const {
return cFactor*val; //PVAL correction
}
//_____________________________________________________________________________
RooAbsPdf* RooMultiPdf::getCurrentPdf() const {

RooAbsPdf *cPdf = ((RooAbsPdf*)c.at(x));
return cPdf;
}
//_____________________________________________________________________________
Double_t RooMultiPdf::evaluate() const{

double val=0;
RooAbsPdf *cPdf = ((RooAbsPdf*)c.at(x));
double val = cPdf->getVal();
if (cPdf->IsA()->InheritsFrom(RooAddPdf::Class()))
{
const RooAddPdf *aPdf = dynamic_cast<const RooAddPdf*>(cPdf);
val = aPdf->evaluate();
} else {
val = cPdf->getVal();
}
// val = cPdf->getVal();
_oldIndex=x;
return val;

}

//_____________________________________________________________________________
Double_t RooMultiPdf::getLogVal(const RooArgSet* nset) const{

double logval=0;
RooAbsPdf *cPdf = ((RooAbsPdf*)c.at(x));
if (cPdf->IsA()->InheritsFrom(RooAddPdf::Class()))
{
const RooAddPdf *aPdf = dynamic_cast<const RooAddPdf*>(cPdf);
logval = aPdf->getLogVal(nset);
} else {
logval = cPdf->getLogVal(nset);
}
_oldIndex=x;
return logval;//cPdf->getLogVal(nset);
}

0 comments on commit 4040d38

Please sign in to comment.