33 : _cacheMgr(this, 10, true, true), _curNormSet(0), _mref(0), _M(0), _useHorizMorph(true)
36 _varItr = _varList.createIterator();
37 _pdfItr = _pdfList.createIterator();
43 :
RooAbsReal(
name, title), _cacheMgr(this, 10,
kTRUE,
kTRUE),
m(
"m",
"m", this, _m),
44 _varList(
"varList",
"List of variables", this), _pdfList(
"pdfList",
"List of pdfs", this), _setting(setting),
54 coutE(InputArguments) <<
"RooMomentMorphFunc::ctor(" <<
GetName() <<
") ERROR: variable " << var->
GetName()
55 <<
" is not of type RooAbsReal" << endl;
56 throw string(
"RooPolyMorh::ctor() ERROR variable is not of type RooAbsReal");
67 coutE(InputArguments) <<
"RooMomentMorphFunc::ctor(" <<
GetName() <<
") ERROR: func " << pdf->
GetName()
68 <<
" is not of type RooAbsReal" << endl;
69 throw string(
"RooMomentMorhFunc::ctor() ERROR func is not of type RooAbsReal");
86 :
RooAbsReal(
name, title), _cacheMgr(this, 10,
kTRUE,
kTRUE),
m(
"m",
"m", this, _m),
87 _varList(
"varList",
"List of variables", this), _pdfList(
"pdfList",
"List of pdfs", this), _setting(setting),
97 coutE(InputArguments) <<
"RooMomentMorphFunc::ctor(" <<
GetName() <<
") ERROR: variable " << var->
GetName()
98 <<
" is not of type RooAbsReal" << endl;
99 throw string(
"RooMomentMorh::ctor() ERROR variable is not of type RooAbsReal");
110 coutE(InputArguments) <<
"RooMomentMorphFunc::ctor(" <<
GetName() <<
") ERROR: function " << pdf->
GetName()
111 <<
" is not of type RooAbsReal" << endl;
112 throw string(
"RooMomentMorh::ctor() ERROR function is not of type RooAbsReal");
124 coutE(InputArguments) <<
"RooMomentMorphFunc::ctor(" <<
GetName() <<
") ERROR: mref " << mref->
GetName()
125 <<
" is not of type RooAbsReal" << endl;
126 throw string(
"RooPolyMorh::ctor() ERROR mref is not of type RooAbsReal");
129 coutW(InputArguments) <<
"RooMomentMorphFunc::ctor(" <<
GetName() <<
") WARNING mref point " << i
130 <<
" is not a constant, taking a snapshot of its value" << endl;
132 (*_mref)[i] = mref->
getVal();
145 :
RooAbsReal(other,
name), _cacheMgr(other._cacheMgr, this), _curNormSet(0),
m(
"m", this, other.
m),
146 _varList(
"varList", this, other._varList), _pdfList(
"pdfList", this, other._pdfList), _setting(other._setting),
147 _useHorizMorph(other._useHorizMorph)
178 coutE(InputArguments) <<
"RooMomentMorphFunc::initialize(" <<
GetName() <<
") ERROR: nPdf != nRefPoints" << endl;
188 (*dm)[i] = (*_mref)[i] - (*_mref)[0];
214 vector<RooAbsReal *> meanrv(nPdf * nVar, null);
215 vector<RooAbsReal *> sigmarv(nPdf * nVar, null);
216 vector<RooAbsReal *> myrms(nVar, null);
217 vector<RooAbsReal *> mypos(nVar, null);
218 vector<RooAbsReal *> slope(nPdf * nVar, null);
219 vector<RooAbsReal *> offs(nPdf * nVar, null);
220 vector<RooAbsReal *> transVar(nPdf * nVar, null);
221 vector<RooAbsReal *> transPdf(nPdf, null);
230 for (
Int_t i = 0; i < 2 * nPdf; ++i) {
231 std::string fracName =
Form(
"frac_%d", i);
244 std::string sumfuncName =
Form(
"%s_sumfunc",
GetName());
249 for (
Int_t i = 0; i < nPdf; ++i) {
250 for (
Int_t j = 0; j < nVar; ++j) {
252 std::string meanName =
Form(
"%s_mean_%d_%d",
GetName(), i, j);
253 std::string sigmaName =
Form(
"%s_sigma_%d_%d",
GetName(), i, j);
261 sigmarv[
ij(i, j)] = mom;
262 meanrv[
ij(i, j)] = mom->
mean();
264 ownedComps.
add(*sigmarv[
ij(i, j)]);
269 for (
Int_t j = 0; j < nVar; ++j) {
272 for (
Int_t i = 0; i < nPdf; ++i) {
273 meanList.
add(*meanrv[
ij(i, j)]);
274 rmsList.
add(*sigmarv[
ij(i, j)]);
276 std::string myrmsName =
Form(
"%s_rms_%d",
GetName(), j);
277 std::string myposName =
Form(
"%s_pos_%d",
GetName(), j);
278 myrms[j] =
new RooAddition(myrmsName.c_str(), myrmsName.c_str(), rmsList, coefList2);
279 mypos[j] =
new RooAddition(myposName.c_str(), myposName.c_str(), meanList, coefList2);
288 for (
Int_t i = 0; i < nPdf; ++i) {
293 std::string pdfName =
Form(
"pdf_%d", i);
296 for (
Int_t j = 0; j < nVar; ++j) {
298 std::string slopeName =
Form(
"%s_slope_%d_%d",
GetName(), i, j);
299 std::string offsetName =
Form(
"%s_offset_%d_%d",
GetName(), i, j);
306 std::string transVarName =
Form(
"%s_transVar_%d_%d",
GetName(), i, j);
311 new RooLinearVar(transVarName.c_str(), transVarName.c_str(), *var, *slope[
ij(i, j)], *offs[
ij(i, j)]);
317 ownedComps.
add(*transVar[
ij(i, j)]);
321 transPdfList.
add(*transPdf[i]);
322 ownedComps.
add(*transPdf[i]);
325 theSumFunc =
new RooRealSumFunc(sumfuncName.c_str(), sumfuncName.c_str(), transPdfList, coefList);
336 std::string trackerName =
Form(
"%s_frac_tracker",
GetName());
340 cache =
new CacheElem(*theSumFunc, *tracker, fracl);
424 double sumposfrac = 0.;
425 for (
Int_t i = 0; i < nPdf; ++i) {
427 for (
Int_t j = 0; j < nPdf; ++j) {
428 ffrac += (*self.
_M)(j, i) * (j == 0 ? 1. :
TMath::Power(dm, (
double)j));
435 ((
RooRealVar *)frac(nPdf + i))->setVal(ffrac);
437 cout << ffrac << endl;
442 int imin = self.
idxmin(self.
m);
443 int imax = self.
idxmax(self.
m);
444 double mfrac = (self.
m - (*self.
_mref)[imin]) / ((*self.
_mref)[imax] - (*self.
_mref)[imin]);
457 for (
Int_t i = 0; i < 2 * nPdf; ++i) ((
RooRealVar *)frac(i))->setVal(0.);
459 ((
RooRealVar *)frac(imin))->setVal(1. - mfrac);
460 ((
RooRealVar *)frac(nPdf + imin))->setVal(1. - mfrac);
462 ((
RooRealVar *)frac(nPdf + imax))->setVal(mfrac);
463 }
else if (imax == imin) {
465 ((
RooRealVar *)frac(nPdf + imin))->setVal(1.);
471 ((
RooRealVar *)frac(imin))->setVal(1. - mfrac);
473 }
else if (imax == imin) {
478 for (
Int_t i = 0; i < nPdf; ++i) {
492 double mmin = -DBL_MAX;
493 for (
Int_t i = 0; i < nPdf; ++i)
494 if ((*
_mref)[i] > mmin && (*
_mref)[i] <= mval) {
506 double mmax = DBL_MAX;
507 for (
Int_t i = 0; i < nPdf; ++i)
508 if ((*
_mref)[i] < mmax && (*
_mref)[i] >= mval) {
TMatrixT< Double_t > TMatrixD
char * Form(const char *fmt,...)
TVectorT< Double_t > TVectorD
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
void addServer(RooAbsArg &server, Bool_t valueProp=kTRUE, Bool_t shapeProp=kFALSE, std::size_t refCount=1)
Register another RooAbsArg as a server to us, ie, declare that we depend on it.
bool addOwnedComponents(const RooAbsCollection &comps)
Take ownership of the contents of 'comps'.
void setLocalNoDirtyInhibit(Bool_t flag) const
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
TIterator * createIterator(Bool_t dir=kIterForward) const
TIterator-style iteration over contained elements.
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_t > * binBoundaries(RooAbsRealLValue &obs, Double_t xlo, Double_t xhi) const
Retrieve bin boundaries if this distribution is binned in obs.
friend class RooRealSumFunc
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
virtual std::list< Double_t > * plotSamplingHint(RooAbsRealLValue &obs, Double_t xlo, Double_t xhi) const
Interface for returning an optional hint for initial sampling points when constructing a curve projec...
virtual Bool_t isBinnedDistribution(const RooArgSet &) const
Tests if the distribution is binned. Unless overridden by derived classes, this always returns false.
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)
Int_t setObj(const RooArgSet *nset, T *obj, const TNamed *isetRangeName=0)
RooChangeTracker is a meta object that tracks value changes in a given set of RooAbsArgs by registeri...
Bool_t hasChanged(Bool_t clearState)
Returns true if state has changed since last call with clearState=kTRUE.
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_t verbose=kFALSE)
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...
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE) override
Reimplementation of standard RooArgList::add()
void calculateFractions(const RooMomentMorphFunc &self, Bool_t verbose=kTRUE) const
RooRealVar * frac(Int_t i)
RooChangeTracker * _tracker
virtual RooArgList containedArgs(Action)
virtual ~RooMomentMorphFunc()
TIterator * _pdfItr
do not persist
virtual Double_t getVal(const RooArgSet *set=0) const
RooArgSet * _curNormSet
The cache manager.
RooObjCacheManager _cacheMgr
CacheElem * getCache(const RooArgSet *nset) const
virtual std::list< Double_t > * binBoundaries(RooAbsRealLValue &, Double_t, Double_t) const
Retrieve bin boundaries if this distribution is binned in obs.
RooAbsReal * sumFunc(const RooArgSet *nset)
Bool_t isBinnedDistribution(const RooArgSet &obs) const
Tests if the distribution is binned. Unless overridden by derived classes, this always returns false.
int idxmin(const double &m) const
Double_t evaluate() const
Evaluate this PDF / function / constant. Needs to be overridden by all derived classes.
Int_t ij(const Int_t &i, const Int_t &j) const
int idxmax(const double &m) const
virtual std::list< Double_t > * plotSamplingHint(RooAbsRealLValue &obs, Double_t xlo, Double_t xhi) const
Interface for returning an optional hint for initial sampling points when constructing a curve projec...
RooRealVar represents a variable that can be changed from the outside.
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE) override
Overloaded RooArgSet::add() method inserts 'var' into set and registers 'var' as server to owner with...
const T & arg() const
Return reference to object held in proxy.
Iterator abstract base class.
virtual TObject * Next()=0
TMatrixT< Element > & Invert(Double_t *det=0)
Invert the matrix and calculate its determinant.
virtual const char * GetName() const
Returns name of object.
constexpr Double_t PiOver2()
LongDouble_t Power(LongDouble_t x, LongDouble_t y)