33 : _cacheMgr(this, 10, true, true), _curNormSet(0), _mref(0), _M(0), _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) {
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) {
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) {
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)) {
95 <<
" is not of type RooAbsReal" << endl;
96 throw string(
"RooMomentMorh::ctor() ERROR function is not of type RooAbsReal");
104 for (
auto *mref : mrefList) {
107 <<
" is not of type RooAbsReal" << endl;
108 throw string(
"RooPolyMorh::ctor() ERROR mref is not of type RooAbsReal");
112 <<
" is not a constant, taking a snapshot of its value" << endl;
124 :
RooAbsReal(other,
name), _cacheMgr(other._cacheMgr, this), _curNormSet(0),
m(
"m", this, other.
m),
125 _varList(
"varList", this, other._varList), _pdfList(
"pdfList", this, other._pdfList), _setting(other._setting),
126 _useHorizMorph(other._useHorizMorph)
165 (*dm)[i] = (*_mref)[i] - (*_mref)[0];
191 vector<RooAbsReal *> meanrv(nPdf * nVar,
null);
192 vector<RooAbsReal *> sigmarv(nPdf * nVar,
null);
193 vector<RooAbsReal *> myrms(nVar,
null);
194 vector<RooAbsReal *> mypos(nVar,
null);
195 vector<RooAbsReal *> slope(nPdf * nVar,
null);
196 vector<RooAbsReal *> offs(nPdf * nVar,
null);
197 vector<RooAbsReal *> transVar(nPdf * nVar,
null);
198 vector<RooAbsReal *> transPdf(nPdf,
null);
207 for (
Int_t i = 0; i < 2 * nPdf; ++i) {
208 std::string fracName =
Form(
"frac_%d", i);
221 std::string sumfuncName =
Form(
"%s_sumfunc",
GetName());
226 for (
Int_t i = 0; i < nPdf; ++i) {
227 for (
Int_t j = 0; j < nVar; ++j) {
229 std::string meanName =
Form(
"%s_mean_%d_%d",
GetName(), i, j);
230 std::string sigmaName =
Form(
"%s_sigma_%d_%d",
GetName(), i, j);
238 sigmarv[
ij(i, j)] = mom;
239 meanrv[
ij(i, j)] = mom->
mean();
241 ownedComps.
add(*sigmarv[
ij(i, j)]);
246 for (
Int_t j = 0; j < nVar; ++j) {
249 for (
Int_t i = 0; i < nPdf; ++i) {
250 meanList.
add(*meanrv[
ij(i, j)]);
251 rmsList.
add(*sigmarv[
ij(i, j)]);
253 std::string myrmsName =
Form(
"%s_rms_%d",
GetName(), j);
254 std::string myposName =
Form(
"%s_pos_%d",
GetName(), j);
255 myrms[j] =
new RooAddition(myrmsName.c_str(), myrmsName.c_str(), rmsList, coefList2);
256 mypos[j] =
new RooAddition(myposName.c_str(), myposName.c_str(), meanList, coefList2);
265 for (
Int_t i = 0; i < nPdf; ++i) {
270 std::string pdfName =
Form(
"pdf_%d", i);
273 for (
Int_t j = 0; j < nVar; ++j) {
275 std::string slopeName =
Form(
"%s_slope_%d_%d",
GetName(), i, j);
276 std::string offsetName =
Form(
"%s_offset_%d_%d",
GetName(), i, j);
283 std::string transVarName =
Form(
"%s_transVar_%d_%d",
GetName(), i, j);
288 new RooLinearVar(transVarName.c_str(), transVarName.c_str(), *var, *slope[
ij(i, j)], *offs[
ij(i, j)]);
294 ownedComps.
add(*transVar[
ij(i, j)]);
298 transPdfList.
add(*transPdf[i]);
299 ownedComps.
add(*transPdf[i]);
302 theSumFunc =
new RooRealSumFunc(sumfuncName.c_str(), sumfuncName.c_str(), transPdfList, coefList);
313 std::string trackerName =
Form(
"%s_frac_tracker",
GetName());
317 cache =
new CacheElem(*theSumFunc, *tracker, fracl);
398 double dm = self.
m - (*self.
_mref)[0];
401 double sumposfrac = 0.;
402 for (
Int_t i = 0; i < nPdf; ++i) {
404 for (
Int_t j = 0; j < nPdf; ++j) {
405 ffrac += (*self.
_M)(j, i) * (j == 0 ? 1. :
TMath::Power(dm, (
double)j));
412 ((
RooRealVar *)frac(nPdf + i))->setVal(ffrac);
414 cout << ffrac << endl;
419 int imin = self.
idxmin(self.
m);
420 int imax = self.
idxmax(self.
m);
421 double mfrac = (self.
m - (*self.
_mref)[imin]) / ((*self.
_mref)[imax] - (*self.
_mref)[imin]);
434 for (
Int_t i = 0; i < 2 * nPdf; ++i) ((
RooRealVar *)frac(i))->setVal(0.);
436 ((
RooRealVar *)frac(imin))->setVal(1. - mfrac);
437 ((
RooRealVar *)frac(nPdf + imin))->setVal(1. - mfrac);
439 ((
RooRealVar *)frac(nPdf + imax))->setVal(mfrac);
440 }
else if (imax == imin) {
442 ((
RooRealVar *)frac(nPdf + imin))->setVal(1.);
448 ((
RooRealVar *)frac(imin))->setVal(1. - mfrac);
450 }
else if (imax == imin) {
455 for (
Int_t i = 0; i < nPdf; ++i) {
469 double mmin = -DBL_MAX;
470 for (
Int_t i = 0; i < nPdf; ++i)
471 if ((*
_mref)[i] > mmin && (*
_mref)[i] <= mval) {
483 double mmax = DBL_MAX;
484 for (
Int_t i = 0; i < nPdf; ++i)
485 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
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
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 ...
const RooArgSet * nset() const
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
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...
RooAbsMoment * sigma(RooRealVar &obs)
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.
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.
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 RooMomentMorphFunc &self, bool verbose=true) const
RooRealVar * frac(Int_t i)
RooChangeTracker * _tracker
RooArgList containedArgs(Action) override
~RooMomentMorphFunc() override
TIterator * _pdfItr
do not persist
friend class CacheElem
Current normalization set.
RooArgSet * _curNormSet
The cache manager.
virtual double getVal(const RooArgSet *set=0) const
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...
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.
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.
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.