33 : _cacheMgr(this, 10, true, true), _curNormSet(
nullptr), _mref(
nullptr), _M(
nullptr), _useHorizMorph(true)
40 :
RooAbsReal(
name, title), _cacheMgr(this, 10, true, true),
m(
"m",
"m", this, _m),
41 _varList(
"varList",
"List of variables", this), _pdfList(
"pdfList",
"List of pdfs", this), _setting(setting),
47 for (
auto *var : varList) {
49 coutE(InputArguments) <<
"RooMomentMorphFunc::ctor(" <<
GetName() <<
") ERROR: variable " << var->
GetName()
50 <<
" is not of type RooAbsReal" << endl;
51 throw string(
"RooPolyMorh::ctor() ERROR variable is not of type RooAbsReal");
57 for (
auto const *pdf : pdfList) {
59 coutE(InputArguments) <<
"RooMomentMorphFunc::ctor(" <<
GetName() <<
") ERROR: func " << pdf->GetName()
60 <<
" is not of type RooAbsReal" << endl;
61 throw string(
"RooMomentMorhFunc::ctor() ERROR func is not of type RooAbsReal");
75 :
RooAbsReal(
name, title), _cacheMgr(this, 10, true, true),
m(
"m",
"m", this, _m),
76 _varList(
"varList",
"List of variables", this), _pdfList(
"pdfList",
"List of pdfs", this), _setting(setting),
82 for (
auto *var : varList) {
84 coutE(InputArguments) <<
"RooMomentMorphFunc::ctor(" <<
GetName() <<
") ERROR: variable " << var->
GetName()
85 <<
" is not of type RooAbsReal" << endl;
86 throw string(
"RooMomentMorh::ctor() ERROR variable is not of type RooAbsReal");
92 for (
auto const *pdf : pdfList){
93 if (!
dynamic_cast<RooAbsPdf const*
>(pdf)) {
94 coutE(InputArguments) <<
"RooMomentMorphFunc::ctor(" <<
GetName() <<
") ERROR: function " << pdf->GetName()
95 <<
" is not of type RooAbsReal" << endl;
96 throw string(
"RooMomentMorh::ctor() ERROR function is not of type RooAbsReal");
104 for (
auto *mref : mrefList) {
106 coutE(InputArguments) <<
"RooMomentMorphFunc::ctor(" <<
GetName() <<
") ERROR: mref " << mref->GetName()
107 <<
" is not of type RooAbsReal" << endl;
108 throw string(
"RooPolyMorh::ctor() ERROR mref is not of type RooAbsReal");
111 coutW(InputArguments) <<
"RooMomentMorphFunc::ctor(" <<
GetName() <<
") WARNING mref point " << i
112 <<
" is not a constant, taking a snapshot of its value" << endl;
124 :
RooAbsReal(other,
name), _cacheMgr(other._cacheMgr, this), _curNormSet(nullptr),
m(
"m", this, other.
m),
125 _varList(
"varList", this, other._varList), _pdfList(
"pdfList", this, other._pdfList), _setting(other._setting),
126 _useHorizMorph(other._useHorizMorph)
151 coutE(InputArguments) <<
"RooMomentMorphFunc::initialize(" <<
GetName() <<
") ERROR: nPdf != nRefPoints" << endl;
161 (*dm)[i] = (*_mref)[i] - (*_mref)[0];
187 vector<RooAbsReal *> meanrv(nPdf * nVar, null);
188 vector<RooAbsReal *> sigmarv(nPdf * nVar, null);
189 vector<RooAbsReal *> myrms(nVar, null);
190 vector<RooAbsReal *> mypos(nVar, null);
191 vector<RooAbsReal *> slope(nPdf * nVar, null);
192 vector<RooAbsReal *> offs(nPdf * nVar, null);
193 vector<RooAbsReal *> transVar(nPdf * nVar, null);
194 vector<RooAbsReal *> transPdf(nPdf, null);
203 for (
Int_t i = 0; i < 2 * nPdf; ++i) {
204 std::string fracName =
Form(
"frac_%d", i);
217 std::string sumfuncName =
Form(
"%s_sumfunc",
GetName());
222 for (
Int_t i = 0; i < nPdf; ++i) {
223 for (
Int_t j = 0; j < nVar; ++j) {
225 std::string meanName =
Form(
"%s_mean_%d_%d",
GetName(), i, j);
226 std::string sigmaName =
Form(
"%s_sigma_%d_%d",
GetName(), i, j);
234 sigmarv[
ij(i, j)] = mom;
235 meanrv[
ij(i, j)] = mom->
mean();
237 ownedComps.
add(*sigmarv[
ij(i, j)]);
242 for (
Int_t j = 0; j < nVar; ++j) {
245 for (
Int_t i = 0; i < nPdf; ++i) {
246 meanList.
add(*meanrv[
ij(i, j)]);
247 rmsList.
add(*sigmarv[
ij(i, j)]);
249 std::string myrmsName =
Form(
"%s_rms_%d",
GetName(), j);
250 std::string myposName =
Form(
"%s_pos_%d",
GetName(), j);
251 myrms[j] =
new RooAddition(myrmsName.c_str(), myrmsName.c_str(), rmsList, coefList2);
252 mypos[j] =
new RooAddition(myposName.c_str(), myposName.c_str(), meanList, coefList2);
259 for (
Int_t i = 0; i < nPdf; ++i) {
261 std::string pdfName =
Form(
"pdf_%d", i);
264 for (
Int_t j = 0; j < nVar; ++j) {
266 std::string slopeName =
Form(
"%s_slope_%d_%d",
GetName(), i, j);
267 std::string offsetName =
Form(
"%s_offset_%d_%d",
GetName(), i, j);
274 std::string transVarName =
Form(
"%s_transVar_%d_%d",
GetName(), i, j);
279 new RooLinearVar(transVarName.c_str(), transVarName.c_str(), var, *slope[
ij(i, j)], *offs[
ij(i, j)]);
285 ownedComps.
add(*transVar[
ij(i, j)]);
289 transPdfList.
add(*transPdf[i]);
290 ownedComps.
add(*transPdf[i]);
293 theSumFunc =
new RooRealSumFunc(sumfuncName.c_str(), sumfuncName.c_str(), transPdfList, coefList);
304 std::string trackerName =
Form(
"%s_frac_tracker",
GetName());
308 cache =
new CacheElem(*theSumFunc, *tracker, fracl);
389 double dm = self.
m - (*self.
_mref)[0];
392 double sumposfrac = 0.;
393 for (
Int_t i = 0; i < nPdf; ++i) {
395 for (
Int_t j = 0; j < nPdf; ++j) {
396 ffrac += (*self.
_M)(j, i) * (j == 0 ? 1. :
TMath::Power(dm, (
double)j));
403 ((
RooRealVar *)frac(nPdf + i))->setVal(ffrac);
405 cout << ffrac << endl;
410 int imin = self.
idxmin(self.
m);
411 int imax = self.
idxmax(self.
m);
412 double mfrac = (self.
m - (*self.
_mref)[imin]) / ((*self.
_mref)[imax] - (*self.
_mref)[imin]);
425 for (
Int_t i = 0; i < 2 * nPdf; ++i) ((
RooRealVar *)frac(i))->setVal(0.);
427 ((
RooRealVar *)frac(imin))->setVal(1. - mfrac);
428 ((
RooRealVar *)frac(nPdf + imin))->setVal(1. - mfrac);
430 ((
RooRealVar *)frac(nPdf + imax))->setVal(mfrac);
431 }
else if (imax == imin) {
433 ((
RooRealVar *)frac(nPdf + imin))->setVal(1.);
439 ((
RooRealVar *)frac(imin))->setVal(1. - mfrac);
441 }
else if (imax == imin) {
446 for (
Int_t i = 0; i < nPdf; ++i) {
460 double mmin = -DBL_MAX;
461 for (
Int_t i = 0; i < nPdf; ++i)
462 if ((*
_mref)[i] > mmin && (*
_mref)[i] <= mval) {
474 double mmax = DBL_MAX;
475 for (
Int_t i = 0; i < nPdf; ++i)
476 if ((*
_mref)[i] < mmax && (*
_mref)[i] >= mval) {
TMatrixT< Double_t > TMatrixD
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
TVectorT< Double_t > TVectorD
Common abstract base class for objects that represent a value and a "shape" in RooFit.
void setLocalNoDirtyInhibit(bool flag) const
bool addOwnedComponents(const RooAbsCollection &comps)
Take ownership of the contents of 'comps'.
void addServer(RooAbsArg &server, bool valueProp=true, bool shapeProp=false, std::size_t refCount=1)
Register another RooAbsArg as a server to us, ie, declare that we depend on it.
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.
RooAbsMoment represents the first, second, or third order derivative of any RooAbsReal as calculated ...
Abstract interface for all probability density functions.
const RooArgSet * nset() const
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
Abstract base class for objects that represent a real value and implements functionality common to al...
virtual std::list< double > * binBoundaries(RooAbsRealLValue &obs, double xlo, double xhi) const
Retrieve bin boundaries if this distribution is binned in obs.
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
friend class RooRealSumFunc
virtual bool isBinnedDistribution(const RooArgSet &) const
Tests if the distribution is binned. Unless overridden by derived classes, this always returns false.
virtual std::list< double > * plotSamplingHint(RooAbsRealLValue &obs, double xlo, double xhi) const
Interface for returning an optional hint for initial sampling points when constructing a curve projec...
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.
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.
Meta object that tracks value changes in a given set of RooAbsArgs by registering itself as value cli...
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 occurrence 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 RooMomentMorphFunc &self, bool verbose=true) const
RooRealVar * frac(Int_t i)
RooChangeTracker * _tracker
RooArgList containedArgs(Action) override
~RooMomentMorphFunc() override
RooArgSet * _curNormSet
The cache manager.
bool isBinnedDistribution(const RooArgSet &obs) const override
Tests if the distribution is binned. Unless overridden by derived classes, this always returns false.
RooObjCacheManager _cacheMgr
CacheElem * getCache(const RooArgSet *nset) const
double evaluate() const override
Evaluate this PDF / function / constant. Needs to be overridden by all derived classes.
RooAbsReal * sumFunc(const RooArgSet *nset)
int idxmin(const double &m) const
std::list< double > * binBoundaries(RooAbsRealLValue &, double, double) const override
Retrieve bin boundaries if this distribution is binned in obs.
std::list< double > * plotSamplingHint(RooAbsRealLValue &obs, double xlo, double xhi) const override
Interface for returning an optional hint for initial sampling points when constructing a curve projec...
virtual double getVal(const RooArgSet *set=nullptr) const
Int_t ij(const Int_t &i, const Int_t &j) const
int idxmax(const double &m) const
RooRealVar represents a variable that can be changed from the outside.
const T & arg() const
Return reference to object held in proxy.
TMatrixT< Element > & Invert(Double_t *det=nullptr)
Invert the matrix and calculate its determinant.
const char * GetName() const override
Returns name of object.
virtual const char * GetName() const
Returns name of object.
constexpr Double_t PiOver2()
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Returns x raised to the power y.
Double_t Sin(Double_t)
Returns the sine of an angle of x radians.