33 : _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),
53 if (!dynamic_cast<RooAbsReal *>(var)) {
55 <<
" is not of type RooAbsReal" << endl;
56 throw string(
"RooPolyMorh::ctor() ERROR variable is not of type RooAbsReal");
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),
96 if (!dynamic_cast<RooAbsReal *>(var)) {
98 <<
" is not of type RooAbsReal" << endl;
99 throw string(
"RooMomentMorh::ctor() ERROR variable is not of type RooAbsReal");
111 <<
" is not of type RooAbsReal" << endl;
112 throw string(
"RooMomentMorh::ctor() ERROR function is not of type RooAbsReal");
122 for (
Int_t i = 0; (mref =
dynamic_cast<RooAbsReal *
>(mrefItr->Next())); ++i) {
125 <<
" is not of type RooAbsReal" << endl;
126 throw string(
"RooPolyMorh::ctor() ERROR mref is not of type RooAbsReal");
128 if (!dynamic_cast<RooConstVar *>(mref)) {
130 <<
" is not a constant, taking a snapshot of its value" << endl;
132 (*_mref)[i] = mref->
getVal();
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)]);
318 cust.replaceArg(*var, *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);
419 Int_t nPdf =
self._pdfList.getSize();
421 Double_t dm =
self.m - (*
self._mref)[0];
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) {
virtual const char * GetName() const
Returns name of object.
TIterator * createIterator(Bool_t dir=kIterForward) const
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
virtual Bool_t add(const RooAbsCollection &col, Bool_t silent=kFALSE)
Add a collection of arguments to this collection by calling add() for each element in the source coll...
RooAbsReal * sumFunc(const RooArgSet *nset)
Double_t getVal(const RooArgSet *set=0) const
int idxmax(const double &m) const
virtual std::list< Double_t > * binBoundaries(RooAbsRealLValue &, Double_t, Double_t) const
Bool_t hasChanged(Bool_t clearState)
Returns true if state has changes since last call with clearState=kTRUE If clearState is true...
Bool_t addOwnedComponents(const RooArgSet &comps)
Take ownership of the contents of 'comps'.
RooAbsMoment represents the first, second, or third order derivative of any RooAbsReal as calculated ...
RooObjCacheManager _cacheMgr
Iterator abstract base class.
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
RooRealVar * frac(Int_t i)
T * getObj(const RooArgSet *nset, Int_t *sterileIndex=0, const TNamed *isetRangeName=0)
RooAbsMoment * sigma(RooRealVar &obs)
Bool_t isBinnedDistribution(const RooArgSet &obs) const
TVectorT< Double_t > TVectorD
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Reimplementation of standard RooArgList::add()
friend class CacheElem
Current normalization set.
TMatrixT< Element > & Invert(Double_t *det=0)
Invert the matrix and calculate its determinant.
const RooArgSet * nset() const
virtual std::list< Double_t > * plotSamplingHint(RooAbsRealLValue &obs, Double_t xlo, Double_t xhi) const
RooRealVar represents a fundamental (non-derived) real valued object.
TMatrixT< Double_t > TMatrixD
int idxmin(const double &m) const
virtual Double_t getVal(const RooArgSet *set=0) const
friend class RooRealSumFunc
virtual RooArgList containedArgs(Action)
RooAbsArg * at(Int_t idx) const
virtual ~RooMomentMorphFunc()
RooChangeTracker * _tracker
char * Form(const char *fmt,...)
Int_t ij(const Int_t &i, const Int_t &j) const
virtual Bool_t isBinnedDistribution(const RooArgSet &) const
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
virtual std::list< Double_t > * binBoundaries(RooAbsRealLValue &, Double_t, Double_t) const
CacheElem * getCache(const RooArgSet *nset) const
RooChangeTracker is a meta object that tracks value changes in a given set of RooAbsArgs by registeri...
virtual std::list< Double_t > * plotSamplingHint(RooAbsRealLValue &, Double_t, Double_t) const
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
RooAbsPdf is the abstract interface for all probability density functions The class provides hybrid a...
RooArgSet * _curNormSet
The cache manager.
virtual TObject * Next()=0
Double_t evaluate() const
Int_t setObj(const RooArgSet *nset, T *obj, const TNamed *isetRangeName=0)
RooAddition calculates the sum of a set of RooAbsReal terms, or when constructed with two sets...
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
void setLocalNoDirtyInhibit(Bool_t flag) const
TIterator * _pdfItr
do not persist
const RooAbsReal & arg() const
void addServer(RooAbsArg &server, Bool_t valueProp=kTRUE, Bool_t shapeProp=kFALSE)
Register another RooAbsArg as a server to us, ie, declare that we depend on it.
void calculateFractions(const RooMomentMorphFunc &self, Bool_t verbose=kTRUE) const
constexpr Double_t PiOver2()
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Overloaded RooArgSet::add() method inserts 'var' into set and registers 'var' as server to owner with...