51 _parList(
"parList",
"List of morph parameters", this), _obsList(
"obsList",
"List of observables", this),
52 _referenceGrid(referenceGrid), _pdfList(
"pdfList",
"List of pdfs", this), _setting(setting), _useHorizMorph(true)
73 _parList(
"parList",
"List of morph parameters", this), _obsList(
"obsList",
"List of observables", this),
74 _pdfList(
"pdfList",
"List of pdfs", this), _setting(setting), _useHorizMorph(true)
80 for (
int i = 0; i < mrefpoints.
GetNrows(); ++i) {
82 if (mrefpoints[i] == grid.
array()[j]) {
110 _parList(
"parList",
"List of morph parameters", this), _obsList(
"obsList",
"List of observables", this),
111 _pdfList(
"pdfList",
"List of pdfs", this), _setting(setting), _useHorizMorph(true)
116 for (
auto *mref : mrefList) {
118 coutE(InputArguments) <<
"RooMomentMorphFuncND::ctor(" <<
GetName() <<
") ERROR: mref " << mref->GetName()
119 <<
" is not of type RooAbsReal" << endl;
120 throw string(
"RooMomentMorphFuncND::ctor() ERROR mref is not of type RooAbsReal");
123 coutW(InputArguments) <<
"RooMomentMorphFuncND::ctor(" <<
GetName() <<
") WARNING mref point " << i
124 <<
" is not a constant, taking a snapshot of its value" << endl;
132 for (i = 0; i < mrefpoints.
GetNrows(); ++i) {
134 if (mrefpoints[i] == grid.
array()[j]) {
160 _parList(
"parList", this, other._parList), _obsList(
"obsList", this, other._obsList),
161 _referenceGrid(other._referenceGrid), _pdfList(
"pdfList", this, other._pdfList), _setting(other._setting),
162 _useHorizMorph(other._useHorizMorph)
179 for (
auto *par : parList) {
181 coutE(InputArguments) <<
"RooMomentMorphFuncND::ctor(" <<
GetName() <<
") ERROR: parameter " << par->GetName()
182 <<
" is not of type RooAbsReal" << endl;
183 throw string(
"RooMomentMorphFuncND::initializeParameters() ERROR parameter is not of type RooAbsReal");
192 for (
auto *var : obsList) {
194 coutE(InputArguments) <<
"RooMomentMorphFuncND::ctor(" <<
GetName() <<
") ERROR: variable " << var->GetName()
195 <<
" is not of type RooAbsReal" << endl;
196 throw string(
"RooMomentMorphFuncND::initializeObservables() ERROR variable is not of type RooAbsReal");
217 coutE(InputArguments) <<
"RooMomentMorphFuncND::initialize(" <<
GetName() <<
") ERROR: nPar != nDim"
218 <<
": " << nPar <<
" !=" << nDim << endl;
223 coutE(InputArguments) <<
"RooMomentMorphFuncND::initialize(" <<
GetName() <<
") ERROR: nPdf != nRef"
224 <<
": " << nPdf <<
" !=" << nRef << endl;
229 _M = std::make_unique<TMatrixD>(nPdf, nPdf);
230 _MSqr = std::make_unique<TMatrixD>(depth, depth);
234 vector<vector<double>> dm(nPdf);
235 for (
int k = 0; k < nPdf; ++k) {
237 for (
int idim = 0; idim < nPar; idim++) {
239 dm2.push_back(delta);
244 vector<vector<int>> powers;
245 for (
int idim = 0; idim < nPar; idim++) {
250 powers.push_back(xtmp);
253 vector<vector<int>>
output;
255 int nCombs =
output.size();
257 for (
int k = 0; k < nPdf; ++k) {
259 for (
int i = 0; i < nCombs; i++) {
261 for (
int ix = 0; ix < nPar; ix++) {
262 double delta = dm[k][ix];
281 : _pdfList(other._pdfList), _pdfMap(other._pdfMap), _nref(other._nref)
283 for (
unsigned int i = 0; i < other.
_grid.size(); i++) {
299 vector<int> thisBoundaries;
300 vector<double> thisBoundaryCoordinates;
301 thisBoundaries.push_back(bin_x);
302 thisBoundaryCoordinates.push_back(_grid[0]->array()[bin_x]);
305 _nref.push_back(thisBoundaryCoordinates);
311 vector<int> thisBoundaries;
312 vector<double> thisBoundaryCoordinates;
313 thisBoundaries.push_back(bin_x);
314 thisBoundaryCoordinates.push_back(_grid[0]->array()[bin_x]);
315 thisBoundaries.push_back(bin_y);
316 thisBoundaryCoordinates.push_back(_grid[1]->array()[bin_y]);
319 _nref.push_back(thisBoundaryCoordinates);
325 vector<int> thisBoundaries;
326 vector<double> thisBoundaryCoordinates;
327 thisBoundaries.push_back(bin_x);
328 thisBoundaryCoordinates.push_back(_grid[0]->array()[bin_x]);
329 thisBoundaries.push_back(bin_y);
330 thisBoundaryCoordinates.push_back(_grid[1]->array()[bin_y]);
331 thisBoundaries.push_back(bin_z);
332 thisBoundaryCoordinates.push_back(_grid[2]->array()[bin_z]);
335 _nref.push_back(thisBoundaryCoordinates);
341 vector<double> thisBoundaryCoordinates;
342 int nBins = bins.size();
343 for (
int i = 0; i < nBins; i++) {
344 thisBoundaryCoordinates.push_back(_grid[i]->array()[bins[i]]);
348 _nref.push_back(thisBoundaryCoordinates);
363 vector<RooAbsReal *> meanrv(nPdf * nObs, null);
364 vector<RooAbsReal *> sigmarv(nPdf * nObs, null);
365 vector<RooAbsReal *> myrms(nObs, null);
366 vector<RooAbsReal *> mypos(nObs, null);
367 vector<RooAbsReal *> slope(nPdf * nObs, null);
368 vector<RooAbsReal *> offsets(nPdf * nObs, null);
369 vector<RooAbsReal *> transVar(nPdf * nObs, null);
370 vector<RooAbsReal *> transPdf(nPdf, null);
380 for (
int i = 0; i < 3 * nPdf; ++i) {
381 string fracName =
Form(
"frac_%d", i);
382 double initval = 0.0;
388 else if (i < 2 * nPdf)
395 Sum_t *theSum =
nullptr;
401 for (
int i = 0; i < nPdf; ++i) {
402 for (
int j = 0; j < nObs; ++j) {
409 sigmarv[
sij(i, j)] = mom;
410 meanrv[
sij(i, j)] = mom->
mean();
412 ownedComps.
add(*sigmarv[
sij(i, j)]);
417 for (
int j = 0; j < nObs; ++j) {
420 for (
int i = 0; i < nPdf; ++i) {
421 meanList.
add(*meanrv[
sij(i, j)]);
422 rmsList.
add(*sigmarv[
sij(i, j)]);
424 string myrmsName =
Form(
"%s_rms_%d",
GetName(), j);
425 string myposName =
Form(
"%s_pos_%d",
GetName(), j);
426 mypos[j] =
new RooAddition(myposName.c_str(), myposName.c_str(), meanList, coefList2);
427 myrms[j] =
new RooAddition(myrmsName.c_str(), myrmsName.c_str(), rmsList, coefList3);
435 for (
auto const *pdf : static_range_cast<Base_t *>(
_pdfList)) {
437 string pdfName =
Form(
"pdf_%d", i);
441 for (
auto *var : static_range_cast<RooRealVar *>(obsList)) {
443 string slopeName =
Form(
"%s_slope_%d_%d",
GetName(), i, j);
444 string offsetName =
Form(
"%s_offset_%d_%d",
GetName(), i, j);
453 string transVarName =
Form(
"%s_transVar_%d_%d",
GetName(), i, j);
454 transVar[
sij(i, j)] =
new RooLinearVar(transVarName.c_str(), transVarName.c_str(), *var, *slope[
sij(i, j)],
455 *offsets[
sij(i, j)]);
461 ownedComps.
add(*transVar[
sij(i, j)]);
466 transPdfList.
add(*transPdf[i]);
467 ownedComps.
add(*transPdf[i]);
472 theSum =
new Sum_t(sumName.c_str(), sumName.c_str(), transPdfList, coefList);
474 theSum =
new Sum_t(sumName.c_str(), sumName.c_str(),
_pdfList, coefList);
483 string trackerName =
Form(
"%s_frac_tracker",
GetName());
487 cache =
new CacheElem(*theSum, *tracker, fracl);
557 double fracLinear(1.);
558 double fracNonLinear(1.);
563 for (
int idim = 0; idim < nPar; idim++) {
565 dm2.push_back(delta);
568 vector<vector<int>> powers;
569 for (
int idim = 0; idim < nPar; idim++) {
574 powers.push_back(xtmp);
577 vector<vector<int>>
output;
579 int nCombs =
output.size();
581 vector<double> deltavec(nPdf, 1.0);
584 for (
int i = 0; i < nCombs; i++) {
586 for (
int ix = 0; ix < nPar; ix++) {
587 double delta = dm2[ix];
590 deltavec[nperm] = tmpDm;
594 double sumposfrac = 0.0;
595 for (
int i = 0; i < nPdf; ++i) {
598 for (
int j = 0; j < nPdf; ++j) {
599 ffrac += (*self.
_M)(j, i) * deltavec[j] * fracNonLinear;
612 ((
RooRealVar *)frac(nPdf + i))->setVal(ffrac);
613 ((
RooRealVar *)frac(2 * nPdf + i))->setVal(ffrac);
616 cout <<
"NonLinear fraction " << ffrac << endl;
618 frac(nPdf + i)->Print();
619 frac(2 * nPdf + i)->Print();
624 for (
int i = 0; i < nPdf; ++i) {
635 for (
int i = 0; i < nPdf; ++i) {
638 ((
RooRealVar *)frac(nPdf + i))->setVal(initval);
639 ((
RooRealVar *)frac(2 * nPdf + i))->setVal(initval);
642 std::vector<double> mtmp;
645 for (
auto *
m : static_range_cast<RooRealVar *>(self.
_parList)) {
646 mtmp.push_back(
m->getVal());
652 vector<double> deltavec(depth, 1.0);
657 for (
int ix = 0; ix < nPar; ix++) {
661 for (
int iperm = 1; iperm <= nPar; ++iperm) {
663 double dtmp = mtmp[xtmp[0]] - self.
_squareVec[0][xtmp[0]];
664 for (
int itmp = 1; itmp < iperm; ++itmp) {
665 dtmp *= mtmp[xtmp[itmp]] - self.
_squareVec[0][xtmp[itmp]];
667 deltavec[nperm + 1] = dtmp;
672 double origFrac1(0.), origFrac2(0.);
673 for (
int i = 0; i < depth; ++i) {
675 for (
int j = 0; j < depth; ++j) {
676 ffrac += (*self.
_MSqr)(j, i) * deltavec[j] * fracLinear;
692 cout <<
"Linear fraction " << ffrac << endl;
720 vector<vector<double>> boundaries(nPar);
721 for (
int idim = 0; idim < nPar; idim++) {
725 boundaries[idim].push_back(lo);
726 boundaries[idim].push_back(
hi);
729 vector<vector<double>>
output;
733 for (
int isq = 0; isq < depth; isq++) {
734 for (
int iref = 0; iref < nRef; iref++) {
757 for (
int ix = 0; ix < nPar; ix++) {
761 for (
int k = 0; k < depth; ++k) {
767 for (
int iperm = 1; iperm <= nPar; ++iperm) {
769 double dtmp =
_squareVec[k][xtmp[0]] - squareBase[xtmp[0]];
770 for (
int itmp = 1; itmp < iperm; ++itmp) {
771 dtmp *=
_squareVec[k][xtmp[itmp]] - squareBase[xtmp[itmp]];
773 M(k, nperm + 1) = dtmp;
793 cout <<
"Currently BinIntegrator only knows how to deal with 1-d " << endl;
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
void setLocalNoDirtyInhibit(bool flag) const
bool addOwnedComponents(const RooAbsCollection &comps)
Take ownership of the contents of 'comps'.
void addServerList(RooAbsCollection &serverList, bool valueProp=true, bool shapeProp=false)
Register a list of RooAbsArg as servers to us by calling addServer() for each arg in the list.
RooAbsBinning is the abstract base class for RooRealVar binning definitions.
RooAbsCollection is an abstract container object that can hold multiple RooAbsArg objects.
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.
RooAbsArg * first() const
bool setRealValue(const char *name, double newVal=0.0, bool verbose=false)
Set value of a RooAbsRealLValye stored in set with given name to newVal No error messages are printed...
RooAbsMoment represents the first, second, or third order derivative of any RooAbsReal as calculated ...
const RooArgSet * nset() const
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.
RooNumIntConfig * specialIntegratorConfig() const
Returns the specialized integrator configuration for this RooAbsReal.
RooAddition 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.
Class RooBinning is an implements RooAbsBinning in terms of an array of boundary values,...
double * array() const override
Return array of boundary values.
Int_t numBoundaries() const override
Return the number boundaries.
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.
RooChangeTracker is a meta object that tracks value changes in a given set of RooAbsArgs by registeri...
bool hasChanged(bool clearState)
Returns true if state has changed since last call with clearState=true.
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...
RooConstVar represent a constant real-valued object.
RooCustomizer is a factory class to produce clones of a prototype composite PDF object with the same ...
void replaceArg(const RooAbsArg &orig, const RooAbsArg &subst)
Replace any occurence of arg 'orig' with arg 'subst'.
RooAbsArg * build(const char *masterCatState, bool verbose=false)
Build a clone of the prototype executing all registered 'replace' rules and 'split' rules for the mas...
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
RooChangeTracker * _tracker
RooArgList containedArgs(Action) override
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.
void initializeParameters(const RooArgList &parList)
RooAbsReal * sumFunc(const RooArgSet *nset)
CacheElem * getCache(const RooArgSet *nset) const
std::unique_ptr< TMatrixD > _M
RooArgSet * _curNormSet
! Transient cache manager
void initializeObservables(const RooArgList &obsList)
virtual double getVal(const RooArgSet *set=nullptr) const
bool setBinIntegrator(RooArgSet &allVars)
std::vector< std::vector< double > > _squareVec
int sij(const int &i, const int &j) const
~RooMomentMorphFuncND() override
std::vector< int > _squareIdx
const RooArgSet & getConfigSection(const char *name) const
Retrieve configuration information specific to integrator with given name.
RooRealVar represents a variable that can be changed from the outside.
TMatrixT< Element > & Invert(Double_t *det=nullptr)
Invert the matrix and calculate its determinant.
const char * GetName() const override
Returns name of object.
Element * GetMatrixArray()
void cartesianProduct(std::vector< std::vector< T > > &out, std::vector< std::vector< T > > &in)
bool nextCombination(const Iterator first, Iterator k, const Iterator last)
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Returns x raised to the power y.