85 _dataVars(
"!dataVars",
"data Vars", this),
86 _paramSet(
"!paramSet",
"bin parameters", this),
87 _dataSet( (std::string(
name)+
"_dataSet").c_str(),
"", vars)
130 _dataVars(
"!dataVars",
"data Vars", this),
131 _paramSet(
"!paramSet",
"bin parameters", this),
132 _dataSet( (std::string(
name)+
"_dataSet").c_str(),
"", vars, Hist)
150 if( vars.
empty() )
return 0;
154 for (
auto comp : vars) {
156 auto errorMsg = std::string(
"ParamHistFunc::GetNumBins") + vars.
GetName() +
") ERROR: component "
157 + comp->GetName() +
" in vars list is not of type RooRealVar";
158 oocoutE(
nullptr, InputArguments) << errorMsg << std::endl;
159 throw std::runtime_error(errorMsg);
163 Int_t varNumBins = var->numBins();
175 _normIntMgr(other._normIntMgr, this),
176 _dataVars(
"!dataVars", this, other._dataVars ),
177 _paramSet(
"!paramSet", this, other._paramSet),
178 _numBins( other._numBins ),
179 _dataSet( other._dataSet )
206 const int i =
index /
n.yz;
207 const int tmp =
index %
n.yz;
208 const int j = tmp /
n.z;
209 const int k = tmp %
n.z;
230 for(
int i=0; i <
numBins(); ++i) {
241 if( num_hist_bins !=
numBins() ) {
242 std::cout <<
"Error - ParamHistFunc: cannot set Shape of ParamHistFunc: " <<
GetName()
243 <<
" using histogram: " << shape->
GetName()
244 <<
". Bins don't match" << std::endl;
245 throw std::runtime_error(
"setShape");
249 Int_t TH1BinNumber = 0;
260 std::cout <<
"Error - ParamHisFunc: cannot set Shape of ParamHistFunc: " <<
GetName()
261 <<
" - param is not RooRealVar" << std::endl;
262 throw std::runtime_error(
"setShape");
296 std::cout <<
"Warning - ParamHistFunc::createParamSet() :"
297 <<
" No Variables provided. Not making constraint terms."
302 else if( numVars == 1 ) {
307 std::stringstream VarNameStream;
308 VarNameStream <<
Prefix <<
"_bin_" << i;
309 std::string VarName = VarNameStream.str();
311 RooRealVar gamma( VarName.c_str(), VarName.c_str(), 1.0 );
314 gamma.setConstant(
false );
319 paramSet.
add( *gamma_wspace );
324 else if( numVars == 2 ) {
328 std::vector< Int_t > Indices(numVars, 0);
341 std::stringstream VarNameStream;
342 VarNameStream <<
Prefix <<
"_bin_" << i <<
"_" << j;
343 std::string VarName = VarNameStream.str();
345 RooRealVar gamma( VarName.c_str(), VarName.c_str(), 1.0 );
348 gamma.setConstant(
false );
353 paramSet.
add( *gamma_wspace );
359 else if( numVars == 3 ) {
363 std::vector< Int_t > Indices(numVars, 0);
378 std::stringstream VarNameStream;
379 VarNameStream <<
Prefix <<
"_bin_" << i <<
"_" << j <<
"_" << k;
380 std::string VarName = VarNameStream.str();
382 RooRealVar gamma( VarName.c_str(), VarName.c_str(), 1.0 );
385 gamma.setConstant(
false );
390 paramSet.
add( *gamma_wspace );
398 std::cout <<
" Error: ParamHistFunc doesn't support dimensions > 3D " << std::endl;
424 double gamma_min,
double gamma_max) {
430 for (
auto comp : params) {
434 var->setMax( gamma_max );
448 double gamma_min,
double gamma_max) {
455 if( gamma_max <= gamma_min ) {
457 std::cout <<
"Warning: gamma_min <= gamma_max: Using default values (0, 10)" << std::endl;
464 double gamma_nominal = 1.0;
466 if( gamma_nominal < gamma_min ) {
467 gamma_nominal = gamma_min;
470 if( gamma_nominal > gamma_max ) {
471 gamma_nominal = gamma_max;
477 std::stringstream VarNameStream;
478 VarNameStream <<
Prefix <<
"_bin_" << i;
479 std::string VarName = VarNameStream.str();
482 gamma_nominal, gamma_min, gamma_max );
483 gamma->setConstant(
false );
484 paramSet.
add( *gamma );
494 int numVars = vars.
size();
496 if (numVars > 3 || numVars < 1) {
497 std::cout <<
"ParamHistFunc() - Only works for 1-3 variables (1d-3d)" << std::endl;
501 int numBinsX = numVars >= 1 ?
static_cast<RooRealVar const&
>(*vars[0]).
numBins() : 1;
502 int numBinsY = numVars >= 2 ?
static_cast<RooRealVar const&
>(*vars[1]).
numBins() : 1;
503 int numBinsZ = numVars >= 3 ?
static_cast<RooRealVar const&
>(*vars[2]).
numBins() : 1;
505 return {numBinsX, numBinsY, numBinsZ};
526 for(
auto const& comp : vars) {
528 auto errorMsg = std::string(
"ParamHistFunc::(") +
GetName() +
") ERROR: component "
529 + comp->GetName() +
" in variables list is not of type RooRealVar";
530 coutE(InputArguments) << errorMsg << std::endl;
531 throw std::runtime_error(errorMsg);
551 if( numVarBins != numElements ) {
552 std::cout <<
"ParamHistFunc::addParamSet - ERROR - "
553 <<
"Supplied list of parameters " << params.
GetName()
554 <<
" has " << numElements <<
" elements but the ParamHistFunc"
555 <<
GetName() <<
" has " << numVarBins <<
" bins."
566 for (
const auto comp : params) {
568 auto errorMsg = std::string(
"ParamHistFunc::(") +
GetName() +
") ERROR: component "
569 + comp->GetName() +
" in parameter list is not of type RooAbsReal.";
570 coutE(InputArguments) << errorMsg << std::endl;
571 throw std::runtime_error(errorMsg);
606 std::array<int, 3> idxMult{{1,
n.x,
n.xy}};
612 std::fill(indexBuffer, indexBuffer +
size, 0);
617 for (std::size_t iVar = 0; iVar <
_dataVars.
size(); ++iVar) {
622 for (std::size_t i = 0; i <
size; ++i) {
635 if (allVars.
empty())
return 0 ;
640 analVars.
add(allVars) ;
643 Int_t sterileIdx(-1) ;
678 const double paramVal = param.
getVal();
681 value += paramVal * binVolumes[i];
703 double* boundaries = binning->
array() ;
705 std::list<double>* hint =
new std::list<double> ;
708 xlo = xlo - 0.01*(xhi-xlo) ;
709 xhi = xhi + 0.01*(xhi-xlo) ;
711 double delta = (xhi-xlo)*1
e-8 ;
716 if (boundaries[i]>=xlo && boundaries[i]<=xhi) {
717 hint->push_back(boundaries[i]-delta) ;
718 hint->push_back(boundaries[i]+delta) ;
738 double* boundaries = binning->
array() ;
740 std::list<double>* hint =
new std::list<double> ;
745 if (boundaries[i]>=xlo && boundaries[i]<=xhi) {
746 hint->push_back(boundaries[i]) ;
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
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)
std::list< double > * binBoundaries(RooAbsRealLValue &, double, double) const override
Return sampling hint for making curves of (projections) of this function as the recursive division st...
static Int_t GetNumBins(const RooArgSet &vars)
double analyticalIntegralWN(Int_t code, const RooArgSet *normSet, const char *rangeName=nullptr) const override
Implement analytical integrations by doing appropriate weighting from component integrals functions t...
void setConstant(bool constant)
Int_t getCurrentBin() const
Get the index of the gamma parameter associated with the current bin.
Int_t getAnalyticalIntegralWN(RooArgSet &allVars, RooArgSet &analVars, const RooArgSet *normSet, const char *rangeName=nullptr) const override
Advertise that all integrals can be handled internally.
RooObjCacheManager _normIntMgr
! The integration cache manager
double evaluate() const override
Find the bin corresponding to the current value of the observable, and evaluate the associated parame...
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)
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.
void setParamConst(Int_t, bool=true)
std::list< double > * plotSamplingHint(RooAbsRealLValue &obs, double xlo, double 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 value=true)
Set (default) or clear a named boolean attribute of this object.
RooAbsBinning is the abstract base class for RooRealVar binning definitions.
virtual Int_t numBoundaries() const =0
virtual double * array() const =0
RooAbsCacheElement is the abstract base class for objects to be stored in RooAbsCache cache manager o...
Int_t getSize() const
Return the number of elements in the collection.
const char * GetName() const override
Returns name of object.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
Storage_t::size_type size() const
virtual Int_t numEntries() const
Return number of entries in dataset, i.e., count unweighted entries.
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...
Int_t numBins(const char *rangeName=nullptr) const override
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.
bool _forceNumInt
Force numerical integration if flag set.
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.
Int_t setObj(const RooArgSet *nset, T *obj, const TNamed *isetRangeName=nullptr)
Setter function without integration set.
Int_t lastIndex() const
Return index of slot used in last get or set operation.
T * getObj(const RooArgSet *nset, Int_t *sterileIndex=nullptr, const TNamed *isetRangeName=nullptr)
Getter function without integration set.
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...
std::vector< std::unique_ptr< const RooAbsBinning > > const & getBinnings() const
Int_t getIndex(const RooAbsCollection &coord, bool 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().
RooSpan< const double > at(RooAbsArg const *arg, RooAbsArg const *caller=nullptr)
RooRealVar represents a variable that can be changed from the outside.
void setVal(double value) override
Set value of variable to 'value'.
void setMin(const char *name, double value)
Set minimum of name range to given value.
The RooWorkspace is a persistable container for RooFit projects.
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.
const char * GetName() const override
Returns name of object.
RooCmdArg RecycleConflictNodes(bool flag=true)