63 : _normIntMgr(this), _numBins(0)
85 _dataVars(
"!dataVars",
"data Vars", this),
86 _paramSet(
"!paramSet",
"bin parameters", this),
88 _dataSet( (std::string(
name)+
"_dataSet").c_str(),
"", vars)
131 _dataVars(
"!dataVars",
"data Vars", this),
132 _paramSet(
"!paramSet",
"bin parameters", this),
134 _dataSet( (std::string(
name)+
"_dataSet").c_str(),
"", vars, Hist)
152 if( vars.
getSize() == 0 )
return 0;
156 for (
auto comp : vars) {
158 auto errorMsg = std::string(
"ParamHistFunc::GetNumBins") + vars.
GetName() +
") ERROR: component "
159 + comp->GetName() +
" in vars list is not of type RooRealVar";
160 oocoutE(
static_cast<TObject*
>(
nullptr), InputArguments) << errorMsg << std::endl;
161 throw std::runtime_error(errorMsg);
165 Int_t varNumBins = var->numBins();
177 _normIntMgr(other._normIntMgr, this),
178 _dataVars(
"!dataVars", this, other._dataVars ),
179 _paramSet(
"!paramSet", this, other._paramSet),
180 _numBins( other._numBins ),
181 _dataSet( other._dataSet )
216 const int i = index /
n.yz;
217 const int tmp = index %
n.yz;
218 const int j = tmp /
n.z;
219 const int k = tmp %
n.z;
240 for(
int i=0; i <
numBins(); ++i) {
251 if( num_hist_bins !=
numBins() ) {
252 std::cout <<
"Error - ParamHistFunc: cannot set Shape of ParamHistFunc: " <<
GetName()
253 <<
" using histogram: " << shape->
GetName()
254 <<
". Bins don't match" << std::endl;
255 throw std::runtime_error(
"setShape");
259 Int_t TH1BinNumber = 0;
270 std::cout <<
"Error - ParamHisFunc: cannot set Shape of ParamHistFunc: " <<
GetName()
271 <<
" - param is not RooRealVar" << std::endl;
272 throw std::runtime_error(
"setShape");
306 std::cout <<
"Warning - ParamHistFunc::createParamSet() :"
307 <<
" No Variables provided. Not making constraint terms."
312 else if( numVars == 1 ) {
317 std::stringstream VarNameStream;
318 VarNameStream <<
Prefix <<
"_bin_" << i;
319 std::string VarName = VarNameStream.str();
321 RooRealVar gamma( VarName.c_str(), VarName.c_str(), 1.0 );
324 gamma.setConstant(
false );
329 paramSet.
add( *gamma_wspace );
334 else if( numVars == 2 ) {
338 std::vector< Int_t > Indices(numVars, 0);
351 std::stringstream VarNameStream;
352 VarNameStream <<
Prefix <<
"_bin_" << i <<
"_" << j;
353 std::string VarName = VarNameStream.str();
355 RooRealVar gamma( VarName.c_str(), VarName.c_str(), 1.0 );
358 gamma.setConstant(
false );
363 paramSet.
add( *gamma_wspace );
369 else if( numVars == 3 ) {
373 std::vector< Int_t > Indices(numVars, 0);
388 std::stringstream VarNameStream;
389 VarNameStream <<
Prefix <<
"_bin_" << i <<
"_" << j <<
"_" << k;
390 std::string VarName = VarNameStream.str();
392 RooRealVar gamma( VarName.c_str(), VarName.c_str(), 1.0 );
395 gamma.setConstant(
false );
400 paramSet.
add( *gamma_wspace );
408 std::cout <<
" Error: ParamHistFunc doesn't support dimensions > 3D " << std::endl;
440 for (
auto comp : params) {
444 var->setMax( gamma_max );
465 if( gamma_max <= gamma_min ) {
467 std::cout <<
"Warning: gamma_min <= gamma_max: Using default values (0, 10)" << std::endl;
476 if( gamma_nominal < gamma_min ) {
477 gamma_nominal = gamma_min;
480 if( gamma_nominal > gamma_max ) {
481 gamma_nominal = gamma_max;
487 std::stringstream VarNameStream;
488 VarNameStream <<
Prefix <<
"_bin_" << i;
489 std::string VarName = VarNameStream.str();
492 gamma_nominal, gamma_min, gamma_max );
493 gamma->setConstant(
false );
494 paramSet.
add( *gamma );
504 int numVars = vars.
size();
506 if (numVars > 3 || numVars < 1) {
507 std::cout <<
"ParamHistFunc() - Only works for 1-3 variables (1d-3d)" << std::endl;
511 int numBinsX = numVars >= 1 ?
static_cast<RooRealVar const&
>(*vars[0]).
numBins() : 1;
512 int numBinsY = numVars >= 2 ?
static_cast<RooRealVar const&
>(*vars[1]).
numBins() : 1;
513 int numBinsZ = numVars >= 3 ?
static_cast<RooRealVar const&
>(*vars[2]).
numBins() : 1;
515 return {numBinsX, numBinsY, numBinsZ};
536 for(
auto const& comp : vars) {
538 auto errorMsg = std::string(
"ParamHistFunc::(") +
GetName() +
") ERROR: component "
539 + comp->GetName() +
" in variables list is not of type RooRealVar";
540 coutE(InputArguments) << errorMsg << std::endl;
541 throw std::runtime_error(errorMsg);
561 if( numVarBins != numElements ) {
562 std::cout <<
"ParamHistFunc::addParamSet - ERROR - "
563 <<
"Supplied list of parameters " << params.
GetName()
564 <<
" has " << numElements <<
" elements but the ParamHistFunc"
565 <<
GetName() <<
" has " << numVarBins <<
" bins."
576 for (
const auto comp : params) {
578 auto errorMsg = std::string(
"ParamHistFunc::(") +
GetName() +
") ERROR: component "
579 + comp->GetName() +
" in parameter list is not of type RooAbsReal.";
580 coutE(InputArguments) << errorMsg << std::endl;
581 throw std::runtime_error(errorMsg);
606 std::vector<double> oldValues;
607 std::vector<RooSpan<const double>> data;
613 const auto* var =
static_cast<RooRealVar*
>(arg);
614 oldValues.push_back(var->getVal());
615 data.push_back(dataMap.
at(var));
619 for (std::size_t i = 0; i <
size; ++i) {
621 assert(i < data[j].
size());
646 if (allVars.
getSize()==0)
return 0 ;
651 analVars.
add(allVars) ;
654 Int_t sterileIdx(-1) ;
690 const double paramVal = param.getVal();
693 value += paramVal * binVolumes[i];
717 std::list<Double_t>* hint =
new std::list<Double_t> ;
720 xlo = xlo - 0.01*(xhi-xlo) ;
721 xhi = xhi + 0.01*(xhi-xlo) ;
728 if (boundaries[i]>=xlo && boundaries[i]<=xhi) {
729 hint->push_back(boundaries[i]-delta) ;
730 hint->push_back(boundaries[i]+delta) ;
752 std::list<Double_t>* hint =
new std::list<Double_t> ;
757 if (boundaries[i]>=xlo && boundaries[i]<=xhi) {
758 hint->push_back(boundaries[i]) ;
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
A class which maps the current values of a RooRealVar (or a set of RooRealVars) to one of a number of...
static NumBins getNumBinsPerDim(RooArgSet const &vars)
void setParamConst(Int_t, Bool_t=kTRUE)
static Int_t GetNumBins(const RooArgSet &vars)
void setConstant(bool constant)
std::list< Double_t > * binBoundaries(RooAbsRealLValue &, Double_t, Double_t) const override
Return sampling hint for making curves of (projections) of this function as the recursive division st...
Int_t getCurrentBin() const
Get the index of the gamma parameter associated with the current bin.
RooObjCacheManager _normIntMgr
! The integration cache manager
Int_t getAnalyticalIntegralWN(RooArgSet &allVars, RooArgSet &analVars, const RooArgSet *normSet, const char *rangeName=0) const override
Advertise that all integrals can be handled internally.
Int_t addVarSet(const RooArgList &vars)
return 0 for success return 1 for failure Check that the elements are actually RooRealVar's If so,...
RooAbsReal & getParameter() const
Int_t addParamSet(const RooArgList ¶ms)
double evaluate() const override
Find the bin corresponding to the current value of the observable, and evaluate the associated parame...
Double_t analyticalIntegralWN(Int_t code, const RooArgSet *normSet, const char *rangeName=0) const override
Implement analytical integrations by doing appropriate weighting from component integrals functions t...
static RooArgList createParamSet(RooWorkspace &w, const std::string &, const RooArgList &Vars)
Create the list of RooRealVar parameters which represent the height of the histogram bins.
std::list< Double_t > * plotSamplingHint(RooAbsRealLValue &obs, Double_t xlo, Double_t xhi) const override
Return sampling hint for making curves of (projections) of this function as the recursive division st...
RooListProxy _paramSet
interpolation parameters
void setShape(TH1 *shape)
RooListProxy _dataVars
The RooRealVars.
void computeBatch(cudaStream_t *, double *output, size_t size, RooFit::Detail::DataMap const &) const override
Find all bins corresponding to the values of the observables in evalData, and evaluate the associated...
void setAttribute(const Text_t *name, Bool_t value=kTRUE)
Set (default) or clear a named boolean attribute of this object.
RooAbsBinning is the abstract base class for RooRealVar binning definitions.
virtual Double_t * array() const =0
virtual Int_t numBoundaries() const =0
RooAbsCacheElement is the abstract base class for objects to be stored in RooAbsCache cache manager o...
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
Storage_t::size_type size() const
const char * GetName() const
Returns name of object.
Abstract base class for objects that are lvalues, i.e.
virtual const RooAbsBinning * getBinningPtr(const char *rangeName) const =0
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
virtual Int_t numBins(const char *rangeName=0) const
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
void setCachedValue(double value, bool notifyClients=true) final
Overwrite the value stored in this object's cache.
RooArgList is a container object that can hold multiple RooAbsArg objects.
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.
T * getObj(const RooArgSet *nset, Int_t *sterileIndex=0, const TNamed *isetRangeName=0)
Int_t setObj(const RooArgSet *nset, T *obj, const TNamed *isetRangeName=0)
Int_t getIndex(const RooAbsCollection &coord, Bool_t fast=false) const
Calculate bin number of the given coordinates.
RooSpan< const double > binVolumes(std::size_t first, std::size_t len) const
Retrieve all bin volumes. Bins are indexed according to getIndex().
Int_t numEntries() const override
Return the number of bins.
auto & at(RooAbsArg const *arg, RooAbsArg const *=nullptr)
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE) override
Reimplementation of standard RooArgList::add()
RooRealVar represents a variable that can be changed from the outside.
void setMin(const char *name, Double_t value)
Set minimum of name range to given value.
virtual void setVal(Double_t value)
Set value of variable to 'value'.
The RooWorkspace is a persistable container for RooFit projects.
Bool_t import(const RooAbsArg &arg, const RooCmdArg &arg1=RooCmdArg(), const RooCmdArg &arg2=RooCmdArg(), const RooCmdArg &arg3=RooCmdArg(), const RooCmdArg &arg4=RooCmdArg(), const RooCmdArg &arg5=RooCmdArg(), const RooCmdArg &arg6=RooCmdArg(), const RooCmdArg &arg7=RooCmdArg(), const RooCmdArg &arg8=RooCmdArg(), const RooCmdArg &arg9=RooCmdArg())
Import a RooAbsArg object, e.g.
RooRealVar * var(const char *name) const
Retrieve real-valued variable (RooRealVar) with given name. A null pointer is returned if not found.
TH1 is the base class of all histogram classes in ROOT.
virtual Int_t GetNbinsY() const
virtual Int_t GetNbinsZ() const
virtual Int_t GetNbinsX() const
Bool_t IsBinUnderflow(Int_t bin, Int_t axis=0) const
Return true if the bin is underflow.
Bool_t IsBinOverflow(Int_t bin, Int_t axis=0) const
Return true if the bin is overflow.
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
virtual const char * GetName() const
Returns name of object.
Mother of all ROOT objects.
RooCmdArg RecycleConflictNodes(Bool_t flag=kTRUE)
static void output(int code)