43using std::string, std::vector;
56 _parList(
"parList",
"List of morph parameters",
this),
57 _obsList(
"obsList",
"List of observables",
this),
59 _pdfList(
"pdfList",
"List of pdfs",
this),
81 _parList(
"parList",
"List of morph parameters",
this),
82 _obsList(
"obsList",
"List of observables",
this),
83 _pdfList(
"pdfList",
"List of pdfs",
this),
91 for (
int i = 0; i <
mrefpoints.GetNrows(); ++i) {
92 for (
int j = 0;
j <
grid.numBoundaries(); ++
j) {
120 _parList(
"parList",
"List of morph parameters",
this),
121 _obsList(
"obsList",
"List of observables",
this),
122 _pdfList(
"pdfList",
"List of pdfs",
this),
131 coutE(InputArguments) <<
"RooMomentMorphFuncND::ctor(" <<
GetName() <<
") ERROR: mref " <<
mref->GetName()
132 <<
" is not of type RooAbsReal" << std::endl;
133 throw string(
"RooMomentMorphFuncND::ctor() ERROR mref is not of type RooAbsReal");
136 coutW(InputArguments) <<
"RooMomentMorphFuncND::ctor(" <<
GetName() <<
") WARNING mref point " << i
137 <<
" is not a constant, taking a snapshot of its value" << std::endl;
146 for (
int j = 0;
j <
grid.numBoundaries(); ++
j) {
173 _parList(
"parList",
this,
other._parList),
174 _obsList(
"obsList",
this,
other._obsList),
175 _referenceGrid(
other._referenceGrid),
176 _pdfList(
"pdfList",
this,
other._pdfList),
177 _setting(
other._setting),
178 _useHorizMorph(
other._useHorizMorph),
179 _isPdfMode{
other._isPdfMode}
203 int depth = std::pow(2, nPar);
206 coutE(InputArguments) <<
"RooMomentMorphFuncND::initialize(" <<
GetName() <<
") ERROR: nPar != nDim"
207 <<
": " << nPar <<
" !=" <<
nDim << std::endl;
212 coutE(InputArguments) <<
"RooMomentMorphFuncND::initialize(" <<
GetName() <<
") ERROR: nPdf != nRef"
213 <<
": " <<
nPdf <<
" !=" <<
nRef << std::endl;
224 for (
int k = 0; k <
nPdf; ++k) {
228 dm2.push_back(delta);
245 int nCombs = output.size();
247 for (
int k = 0; k <
nPdf; ++k) {
249 for (
int i = 0; i <
nCombs; i++) {
251 for (
int ix = 0; ix < nPar; ix++) {
252 double delta = dm[k][ix];
253 tmpDm *= std::pow(delta,
static_cast<double>(output[i][ix]));
273 for (
unsigned int i = 0; i <
other._grid.size(); i++) {
332 int nBins = bins.size();
334 for (
int i = 0; i < nBins; i++) {
343std::unique_ptr<RooAbsArg>
367 for (
auto const &
attr :
b->attributes()) {
368 if (
attr.rfind(
"ORIGNAME:", 0) == 0)
372 b->setAttribute(
attr.c_str(),
false);
383 for (
int i = 0; i <
nFrac; ++i) {
385 std::string
newName = std::string{frac->GetName()} +
"_compiled";
387 std::make_unique<RooFit::Detail::RooMomentMorphFraction>(
newName.c_str(), frac->GetTitle(), *
this, i));
393 for (
int i = 0; i <
nFrac; ++i) {
443 auto *cache =
_parent->getCache(
nullptr);
444 if (cache->_tracker->hasChanged(
true)) {
445 cache->calculateFractions(*
_parent,
false);
447 return cache->frac(
_index)->getVal();
482 for (
int i = 0; i < 3 *
nPdf; ++i) {
490 }
else if (i < 2 *
nPdf) {
498 std::unique_ptr<RooAbsReal>
theSum;
505 for (
int i = 0; i <
nPdf; ++i) {
506 for (
int j = 0;
j < nObs; ++
j) {
510 mom->setLocalNoDirtyInhibit(
true);
511 mom->mean()->setLocalNoDirtyInhibit(
true);
521 for (
int j = 0;
j < nObs; ++
j) {
524 for (
int i = 0; i <
nPdf; ++i) {
558 *offsets[
sij(i,
j)]);
629 if (cache->
_tracker->hasChanged(
true)) {
632 return cache->
_sum.get();
640 if (cache->
_tracker->hasChanged(
true)) {
652 return static_cast<RooRealVar *
>(_frac.at(i));
658 return static_cast<RooRealVar *
>(_frac.at(i));
665 int nPar =
self._parList.size();
675 dm2.push_back(delta);
682 for (
int ix = 0; ix <
self._referenceGrid._nnuis[
idim]; ix++) {
690 int nCombs = output.size();
695 for (
int i = 0; i <
nCombs; i++) {
697 for (
int ix = 0; ix < nPar; ix++) {
698 double delta =
dm2[ix];
699 tmpDm *= std::pow(delta,
static_cast<double>(output[i][ix]));
706 for (
int i = 0; i <
nPdf; ++i) {
709 for (
int j = 0;
j <
nPdf; ++
j) {
727 std::cout <<
"NonLinear fraction " <<
ffrac << std::endl;
729 frac(
nPdf + i)->Print();
730 frac(2 *
nPdf + i)->Print();
735 for (
int i = 0; i <
nPdf; ++i) {
736 if (frac(i)->
getVal() < 0)
737 const_cast<RooRealVar *
>(frac(i))->setVal(0.);
746 for (
int i = 0; i <
nPdf; ++i) {
753 std::vector<double>
mtmp;
757 mtmp.push_back(
m->getVal());
762 int depth = std::pow(2, nPar);
769 for (
int ix = 0; ix < nPar; ix++) {
786 for (
int i = 0; i <
depth; ++i) {
799 frac(
nPdf +
self._squareIdx[i])->getVal();
805 std::cout <<
"Linear fraction " <<
ffrac << std::endl;
806 frac(
self._squareIdx[i])->Print();
807 frac(
nPdf +
self._squareIdx[i])->Print();
808 frac(2 *
nPdf +
self._squareIdx[i])->Print();
831 int depth = std::pow(2, nPar);
838 boundaries[
idim].push_back(lo);
839 boundaries[
idim].push_back(
hi);
861 coutE(InputArguments) <<
"RooMomentMorphFuncND::findShape(" <<
GetName()
862 <<
") ERROR: no reference pdf found for grid corner (";
863 for (
unsigned int ix = 0; ix <
_squareVec[
isq].size(); ++ix) {
866 ccoutE(InputArguments) <<
") of the hypercube enclosing the current morphing "
867 <<
"parameter point. The reference grid is missing a pdf at this "
868 <<
"coordinate -- check that RooMomentMorphFuncND::Grid::addPdf() was "
869 <<
"called for every corner of the parameter range." << std::endl;
870 throw string(
"RooMomentMorphFuncND::findShape() ERROR: incomplete reference grid");
890 for (
int ix = 0; ix < nPar; ix++) {
894 for (
int k = 0; k <
depth; ++k) {
913 (*_MSqr) = M.Invert();
919 if (allVars.
size() == 1) {
926 std::cout <<
"Currently BinIntegrator only knows how to deal with 1-d " << std::endl;
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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 char Point_t Rectangle_t WindowAttributes_t attr
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
const_iterator begin() const
const_iterator end() const
Abstract base class for RooRealVar binning definitions.
Abstract container object that can hold multiple RooAbsArg objects.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
Storage_t::size_type size() const
RooAbsArg * first() const
bool addTyped(const RooAbsCollection &list, bool silent=false)
Adds elements of a given RooAbsCollection to the container if they match the specified type.
const RooArgSet * nset() const
Abstract base class for objects that represent a real value and implements functionality common to al...
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
virtual double getValV(const RooArgSet *normalisationSet=nullptr) const
Return value of object.
RooNumIntConfig * specialIntegratorConfig() const
Returns the specialized integrator configuration for this RooAbsReal.
Calculates the sum of a set of RooAbsReal terms, or when constructed with two sets,...
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.
Implements a RooAbsBinning in terms of an array of boundary values, posing no constraints on the choi...
Int_t setObj(const RooArgSet *nset, T *obj, const TNamed *isetRangeName=nullptr)
Setter function without integration set.
T * getObj(const RooArgSet *nset, Int_t *sterileIndex=nullptr, const TNamed *isetRangeName=nullptr)
Getter function without integration set.
bool setLabel(const char *label, bool printError=true) override
Set value by specifying the name of the desired state.
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...
Represents a constant real-valued object.
RooCustomizer is a factory class to produce clones of a prototype composite PDF object with the same ...
void markAsCompiled(RooAbsArg &arg) const
void compileServers(RooAbsArg &arg, RooArgSet const &normSet)
void markSubtreeAsCompiled(RooAbsArg &arg) const
Mark arg and every branch node reachable through its server tree as already compiled.
Helper compute-graph node that exposes one of the morph mixing fractions to the RooFit::Evaluator.
const RooMomentMorphFuncND * _parent
! morph that owns the cache (not owned)
double evaluate() const override
Evaluate this PDF / function / constant. Needs to be overridden by all derived classes.
RooLinearVar is the most general form of a derived real-valued object that can be used by RooRealInte...
void calculateFractions(const RooMomentMorphFuncND &self, bool verbose=true) const
std::unique_ptr< RooChangeTracker > _tracker
std::unique_ptr< RooAbsReal > _sum
RooArgList containedArgs(Action) override
CacheElem(std::unique_ptr< RooAbsReal > &&sumFunc, std::unique_ptr< RooChangeTracker > &&tracker, const RooArgList &flist)
std::vector< int > _nnuis
void addBinning(const RooAbsBinning &binning)
std::vector< RooAbsBinning * > _grid
std::vector< std::vector< double > > _nref
void addPdf(const RooAbsReal &func, int bin_x)
RooObjCacheManager _cacheMgr
! Transient cache manager
std::unique_ptr< TMatrixD > _MSqr
void findShape(const std::vector< double > &x) const
double evaluate() const override
Evaluate this PDF / function / constant. Needs to be overridden by all derived classes.
RooAbsReal * sumFunc(const RooArgSet *nset)
CacheElem * getCache(const RooArgSet *nset) const
std::unique_ptr< TMatrixD > _M
RooArgSet * _curNormSet
! Transient cache manager
bool setBinIntegrator(RooArgSet &allVars)
double getValV(const RooArgSet *set=nullptr) const override
Return value of object.
std::vector< std::vector< double > > _squareVec
int sij(const int &i, const int &j) const
std::unique_ptr< RooAbsArg > compileForNormSet(RooArgSet const &normSet, RooFit::Detail::CompileContext &ctx) const override
~RooMomentMorphFuncND() override
std::vector< int > _squareIdx
const RooArgSet & getConfigSection(const char *name) const
Retrieve configuration information specific to integrator with given name.
Variable that can be changed from the outside.
const char * GetName() const override
Returns name of object.
void cartesianProduct(std::vector< std::vector< T > > &out, std::vector< std::vector< T > > &in)
bool nextCombination(const Iterator first, Iterator k, const Iterator last)
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...