38 : _cacheMgr(this, 10, true, true), _curNormSet(0), _M(0), _MSqr(0), _setting(
RooMomentMorphND::
Linear), _useHorizMorph(true)
46 :
RooAbsPdf(
name, title), _cacheMgr(this, 10, true, true), _parList(
"parList",
"List of morph parameters", this),
47 _obsList(
"obsList",
"List of observables", this), _referenceGrid(referenceGrid),
48 _pdfList(
"pdfList",
"List of pdfs", this), _setting(setting), _useHorizMorph(true)
67 :
RooAbsPdf(
name, title), _cacheMgr(this, 10, true, true), _parList(
"parList",
"List of morph parameters", this),
68 _obsList(
"obsList",
"List of observables", this), _pdfList(
"pdfList",
"List of pdfs", this), _setting(setting),
75 for (
int i = 0; i < mrefpoints.
GetNrows(); ++i) {
77 if (mrefpoints[i] == grid.
array()[j]) {
103 :
RooAbsPdf(
name, title), _cacheMgr(this, 10, true, true), _parList(
"parList",
"List of morph parameters", this),
104 _obsList(
"obsList",
"List of observables", this), _pdfList(
"pdfList",
"List of pdfs", this), _setting(setting),
110 for (
auto *mref : mrefList) {
113 <<
" is not of type RooAbsReal" << endl;
114 throw string(
"RooMomentMorphND::ctor() ERROR mref is not of type RooAbsReal");
118 <<
" is not a constant, taking a snapshot of its value" << endl;
127 for (i = 0; i < mrefpoints.
GetNrows(); ++i) {
129 if (mrefpoints[i] == grid.
array()[j]) {
154 :
RooAbsPdf(other,
name), _cacheMgr(other._cacheMgr, this), _curNormSet(0),
155 _parList(
"parList", this, other._parList), _obsList(
"obsList", this, other._obsList),
156 _referenceGrid(other._referenceGrid), _pdfList(
"pdfList", this, other._pdfList), _M(0), _MSqr(0),
157 _setting(other._setting), _useHorizMorph(other._useHorizMorph)
183 for (
auto *par : parList) {
186 <<
" is not of type RooAbsReal" << endl;
187 throw string(
"RooMomentMorphND::initializeParameters() ERROR parameter is not of type RooAbsReal");
196 for (
auto *var : obsList){
199 <<
" is not of type RooAbsReal" << endl;
200 throw string(
"RooMomentMorphND::initializeObservables() ERROR variable is not of type RooAbsReal");
210 typename vector<T>::const_iterator
begin;
211 typename vector<T>::const_iterator
end;
212 typename vector<T>::const_iterator
me;
218 vector<Digits<T>> vd;
220 for (
typename vector<vector<T>>::const_iterator it = in.begin(); it != in.end(); ++it) {
221 Digits<T> d = {(*it).begin(), (*it).end(), (*it).begin()};
227 for (
typename vector<
Digits<T>>::const_iterator it = vd.
begin(); it != vd.end(); ++it) {
228 result.push_back(*(it->me));
234 if (it->me == it->end) {
235 if (it + 1 == vd.end()) {
264 <<
": " << nPar <<
" !=" << nDim << endl;
270 <<
": " << nPdf <<
" !=" << nRef << endl;
280 vector<vector<double>> dm(nPdf);
281 for (
int k = 0; k < nPdf; ++k) {
283 for (
int idim = 0; idim < nPar; idim++) {
285 dm2.push_back(delta);
290 vector<vector<int>> powers;
291 for (
int idim = 0; idim < nPar; idim++) {
296 powers.push_back(xtmp);
299 vector<vector<int>>
output;
301 int nCombs =
output.size();
303 for (
int k = 0; k < nPdf; ++k) {
305 for (
int i = 0; i < nCombs; i++) {
307 for (
int ix = 0; ix < nPar; ix++) {
308 double delta = dm[k][ix];
327 : _grid(other._grid), _pdfList(other._pdfList), _pdfMap(other._pdfMap), _nref(other._nref)
339 vector<int> thisBoundaries;
340 vector<double> thisBoundaryCoordinates;
341 thisBoundaries.push_back(bin_x);
342 thisBoundaryCoordinates.push_back(_grid[0]->array()[bin_x]);
345 _nref.push_back(thisBoundaryCoordinates);
351 vector<int> thisBoundaries;
352 vector<double> thisBoundaryCoordinates;
353 thisBoundaries.push_back(bin_x);
354 thisBoundaryCoordinates.push_back(_grid[0]->array()[bin_x]);
355 thisBoundaries.push_back(bin_y);
356 thisBoundaryCoordinates.push_back(_grid[1]->array()[bin_y]);
359 _nref.push_back(thisBoundaryCoordinates);
365 vector<int> thisBoundaries;
366 vector<double> thisBoundaryCoordinates;
367 thisBoundaries.push_back(bin_x);
368 thisBoundaryCoordinates.push_back(_grid[0]->array()[bin_x]);
369 thisBoundaries.push_back(bin_y);
370 thisBoundaryCoordinates.push_back(_grid[1]->array()[bin_y]);
371 thisBoundaries.push_back(bin_z);
372 thisBoundaryCoordinates.push_back(_grid[2]->array()[bin_z]);
375 _nref.push_back(thisBoundaryCoordinates);
381 vector<double> thisBoundaryCoordinates;
382 int nBins = bins.size();
383 for (
int i = 0; i < nBins; i++) {
384 thisBoundaryCoordinates.push_back(_grid[i]->array()[bins[i]]);
388 _nref.push_back(thisBoundaryCoordinates);
403 vector<RooAbsReal *> meanrv(nPdf * nObs,
null);
404 vector<RooAbsReal *> sigmarv(nPdf * nObs,
null);
405 vector<RooAbsReal *> myrms(nObs,
null);
406 vector<RooAbsReal *> mypos(nObs,
null);
407 vector<RooAbsReal *> slope(nPdf * nObs,
null);
408 vector<RooAbsReal *> offsetrv(nPdf * nObs,
null);
409 vector<RooAbsReal *> transVar(nPdf * nObs,
null);
410 vector<RooAbsReal *> transPdf(nPdf,
null);
420 for (
int i = 0; i < 3 * nPdf; ++i) {
421 string fracName =
Form(
"frac_%d", i);
427 else if (i < 2 * nPdf)
440 for (
int i = 0; i < nPdf; ++i) {
441 for (
int j = 0; j < nObs; ++j) {
448 sigmarv[
sij(i, j)] = mom;
449 meanrv[
sij(i, j)] = mom->
mean();
451 ownedComps.
add(*sigmarv[
sij(i, j)]);
456 for (
int j = 0; j < nObs; ++j) {
459 for (
int i = 0; i < nPdf; ++i) {
460 meanList.
add(*meanrv[
sij(i, j)]);
461 rmsList.
add(*sigmarv[
sij(i, j)]);
463 string myrmsName =
Form(
"%s_rms_%d",
GetName(), j);
464 string myposName =
Form(
"%s_pos_%d",
GetName(), j);
465 mypos[j] =
new RooAddition(myposName.c_str(), myposName.c_str(), meanList, coefList2);
466 myrms[j] =
new RooAddition(myrmsName.c_str(), myrmsName.c_str(), rmsList, coefList3);
474 for (
auto const *pdf : static_range_cast<RooRealVar *>(
_pdfList)) {
476 string pdfName =
Form(
"pdf_%d", i);
480 for (
auto *var : static_range_cast<RooRealVar *>(obsList)) {
482 string slopeName =
Form(
"%s_slope_%d_%d",
GetName(), i, j);
483 string offsetName =
Form(
"%s_offset_%d_%d",
GetName(), i, j);
492 string transVarName =
Form(
"%s_transVar_%d_%d",
GetName(), i, j);
493 transVar[
sij(i, j)] =
new RooLinearVar(transVarName.c_str(), transVarName.c_str(), *var, *slope[
sij(i, j)],
494 *offsetrv[
sij(i, j)]);
500 ownedComps.
add(*transVar[
sij(i, j)]);
505 transPdfList.
add(*transPdf[i]);
506 ownedComps.
add(*transPdf[i]);
511 theSumPdf =
new RooAddPdf(sumpdfName.c_str(), sumpdfName.c_str(), transPdfList, coefList);
513 theSumPdf =
new RooAddPdf(sumpdfName.c_str(), sumpdfName.c_str(),
_pdfList, coefList);
522 string trackerName =
Form(
"%s_frac_tracker",
GetName());
526 cache =
new CacheElem(*theSumPdf, *tracker, fracl);
593template <
typename Iterator>
596 if ((
first == last) || (
first == k) || (last == k)) {
599 Iterator itr1 =
first;
600 Iterator itr2 = last;
609 while (
first != itr1) {
610 if (*--itr1 < *itr2) {
612 while (!(*itr1 < *j)) ++j;
617 rotate(itr1, j, last);
622 rotate(k, itr2, last);
626 rotate(
first, k, last);
636 double fracLinear(1.);
637 double fracNonLinear(1.);
642 for (
int idim = 0; idim < nPar; idim++) {
644 dm2.push_back(delta);
647 vector<vector<int>> powers;
648 for (
int idim = 0; idim < nPar; idim++) {
653 powers.push_back(xtmp);
656 vector<vector<int>>
output;
658 int nCombs =
output.size();
660 vector<double> deltavec(nPdf, 1.0);
663 for (
int i = 0; i < nCombs; i++) {
665 for (
int ix = 0; ix < nPar; ix++) {
666 double delta = dm2[ix];
669 deltavec[nperm] = tmpDm;
673 double sumposfrac = 0.0;
674 for (
int i = 0; i < nPdf; ++i) {
677 for (
int j = 0; j < nPdf; ++j) {
678 ffrac += (*self.
_M)(j, i) * deltavec[j] * fracNonLinear;
691 ((
RooRealVar *)frac(nPdf + i))->setVal(ffrac);
692 ((
RooRealVar *)frac(2 * nPdf + i))->setVal(ffrac);
695 cout <<
"NonLinear fraction " << ffrac << endl;
697 frac(nPdf + i)->Print();
698 frac(2 * nPdf + i)->Print();
703 for (
int i = 0; i < nPdf; ++i) {
717 for (
int i = 0; i < nPdf; ++i) {
720 ((
RooRealVar *)frac(nPdf + i))->setVal(initval);
721 ((
RooRealVar *)frac(2 * nPdf + i))->setVal(initval);
726 for (
int j = 0; j < nPar; j++) {
728 mtmp.push_back(
m->getVal());
734 vector<double> deltavec(depth, 1.0);
739 for (
int ix = 0; ix < nPar; ix++) {
743 for (
int iperm = 1; iperm <= nPar; ++iperm) {
745 double dtmp = mtmp[xtmp[0]] - self.
_squareVec[0][xtmp[0]];
746 for (
int itmp = 1; itmp < iperm; ++itmp) {
747 dtmp *= mtmp[xtmp[itmp]] - self.
_squareVec[0][xtmp[itmp]];
749 deltavec[nperm + 1] = dtmp;
754 double origFrac1(0.), origFrac2(0.);
755 for (
int i = 0; i < depth; ++i) {
757 for (
int j = 0; j < depth; ++j) {
758 ffrac += (*self.
_MSqr)(j, i) * deltavec[j] * fracLinear;
774 cout <<
"Linear fraction " << ffrac << endl;
802 vector<vector<double>> boundaries(nPar);
803 for (
int idim = 0; idim < nPar; idim++) {
807 boundaries[idim].push_back(lo);
808 boundaries[idim].push_back(
hi);
811 vector<vector<double>>
output;
815 for (
int isq = 0; isq < depth; isq++) {
816 for (
int iref = 0; iref < nRef; iref++) {
839 for (
int ix = 0; ix < nPar; ix++) {
843 for (
int k = 0; k < depth; ++k) {
849 for (
int iperm = 1; iperm <= nPar; ++iperm) {
851 double dtmp =
_squareVec[k][xtmp[0]] - squareBase[xtmp[0]];
852 for (
int itmp = 1; itmp < iperm; ++itmp) {
853 dtmp *=
_squareVec[k][xtmp[itmp]] - squareBase[xtmp[itmp]];
855 M(k, nperm + 1) = dtmp;
875 cout <<
"Currently BinIntegrator only knows how to deal with 1-d " << endl;
bool next_combination(const Iterator first, Iterator k, const Iterator last)
void cartesian_product(vector< vector< T > > &out, vector< vector< T > > &in)
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
TMatrixT< Double_t > TMatrixD
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.
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.
bool setRealValue(const char *name, double newVal=0, bool verbose=false)
Set value of a RooAbsRealLValye stored in set with given name to newVal No error messages are printed...
RooAbsArg * first() const
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.
RooAbsMoment * sigma(RooRealVar &obs)
RooAddPdf is an efficient implementation of a sum of PDFs of the form.
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.
T * getObj(const RooArgSet *nset, Int_t *sterileIndex=0, const TNamed *isetRangeName=0)
Getter function without integration set.
Int_t setObj(const RooArgSet *nset, T *obj, const TNamed *isetRangeName=0)
Setter 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...
RooChangeTracker * _tracker
void calculateFractions(const RooMomentMorphND &self, bool verbose=true) const
RooArgList containedArgs(Action) override
void addBinning(const RooAbsBinning &binning)
std::vector< std::vector< double > > _nref
std::vector< RooAbsBinning * > _grid
void addPdf(const RooAbsPdf &pdf, int bin_x)
std::vector< int > _nnuis
std::vector< int > _squareIdx
Grid _referenceGrid
Do not persist.
CacheElem * getCache(const RooArgSet *nset) const
bool setBinIntegrator(RooArgSet &allVars)
RooObjCacheManager _cacheMgr
! Transient cache manager
std::vector< std::vector< double > > _squareVec
void initializeObservables(const RooArgList &obsList)
double evaluate() const override
Evaluate this PDF / function / constant. Needs to be overridden by all derived classes.
int sij(const int &i, const int &j) const
void findShape(const std::vector< double > &x) const
virtual double getVal(const RooArgSet *set=0) const
TIterator * _obsItr
Do not persist.
RooAbsPdf * sumPdf(const RooArgSet *nset)
void initializeParameters(const RooArgList &parList)
~RooMomentMorphND() override
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.
virtual TObject * Next()=0
TMatrixT< Element > & Invert(Double_t *det=0)
Invert the matrix and calculate its determinant.
const char * GetName() const override
Returns name of object.
Element * GetMatrixArray()
std::shared_ptr< std::function< double(double)> > Linear
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Returns x raised to the power y.
vector< T >::const_iterator begin
vector< T >::const_iterator end
vector< T >::const_iterator me