42 _gamma(
"gamma",
"gamma",this),
43 _nominal(
"nominal",
"nominal",this),
59 <<
") ERROR: input object must be a RooParamHistFunc" << endl ;
60 throw std::string(
"RooHistConstraint::ctor ERROR incongruent input arguments") ;
68 const char* vname =
Form(
"%s_nominal_bin_%i",
GetName(),i) ;
91 vector<RooParamHistFunc*> phvec ;
94 for (
const auto arg : phfSet) {
98 phvec.push_back(phfComp) ;
102 gammaSet.
add(phfComp->
_p) ;
106 <<
") ERROR: incongruent input arguments: all input RooParamHistFuncs should have same #bins" << endl ;
107 throw std::string(
"RooHistConstraint::ctor ERROR incongruent input arguments") ;
111 <<
") ERROR: incongruent input arguments: all input RooParamHistFuncs should have the same bin parameters.\n"
112 <<
"Previously found " << bin0_name <<
", now found " << phfComp->
_p.
at(0)->
GetName() <<
".\n"
113 <<
"Check that the right RooParamHistFuncs have been passed to this RooHistConstraint." << std::endl;
114 throw std::string(
"RooHistConstraint::ctor ERROR incongruent input arguments") ;
120 <<
") WARNING: ignoring input argument " << arg->GetName() <<
" which is not of type RooParamHistFunc" << endl;
128 for (
Int_t i=0 ; i<nbins ; i++) {
131 for (
const auto phfunc : phvec) {
132 sumVal += phfunc->getNominal(i);
135 if (sumVal<threshold && sumVal != 0.) {
137 const char* vname =
Form(
"%s_nominal_bin_%i",
GetName(),i) ;
141 for (vector<RooParamHistFunc*>::iterator iter = phvec.begin() ; iter != phvec.end() ; ++iter) {
142 sumVal2 += (*iter)->getNominal(i) ;
147 vname =
Form(
"%s_nominal_error_bin_%i",
GetName(),i) ;
151 for (vector<RooParamHistFunc*>::iterator iter = phvec.begin() ; iter != phvec.end() ; ++iter) {
152 sumErr2 +=
pow((*iter)->getNominalError(i),2) ;
172 _gamma(
"gamma",this,other._gamma),
173 _nominal(
"nominal",this,other._nominal),
174 _relParam(other._relParam)
188 double gamVal =
gamma.getVal();
190 gamVal *= nominal.getVal();
207 double gam =
gamma.getVal();
214 const double logPoisson = nom *
log(gam) - gam -
std::lgamma(nom+1);
217 cerr <<
"ERROR in RooHistConstraint: gam=0 and nom>0" << endl ;
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
bool addOwnedComponents(const RooAbsCollection &comps)
Take ownership of the contents of 'comps'.
Int_t getSize() const
Return the number of elements in the collection.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
Storage_t::size_type size() const
RooAbsArg * first() const
void setConstant(bool value=true)
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
RooAbsArg * at(Int_t idx) const
Return object at given index, or nullptr if index is out of range.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
bool add(const RooAbsArg &var, bool valueServer, bool shapeServer, bool silent)
Overloaded RooCollection_t::add() method insert object into set and registers object as server to own...
double weight(std::size_t i) const
Return weight of i-th bin.
Int_t numEntries() const override
Return the number of bins.
const RooArgSet * get() const override
Get bin centre of current bin.
The RooHistConstraint implements constraint terms for a binned PDF with statistical uncertainties.
double getLogVal(const RooArgSet *set=0) const override
Return the log of the current value with given normalization An error message is printed if the argum...
double evaluate() const override
Evaluate this PDF / function / constant. Needs to be overridden by all derived classes.
A histogram function that assigns scale parameters to every bin.
RooRealVar represents a variable that can be changed from the outside.
void setVal(double value) override
Set value of variable to 'value'.
const char * GetName() const override
Returns name of object.
double lgamma(double x)
Calculates the logarithm of the gamma function.
RVec< PromoteTypes< T0, T1 > > pow(const T0 &x, const RVec< T1 > &v)
RVec< PromoteType< T > > log(const RVec< T > &v)
VecExpr< UnaryOp< Sqrt< T >, VecExpr< A, T, D >, T >, T, D > sqrt(const VecExpr< A, T, D > &rhs)
Double_t Poisson(Double_t x, Double_t par)
Computes the Poisson distribution function for (x,par).
static uint64_t sum(uint64_t i)