33using std::string, std::vector;
47 m(
"m",
"m", this, _m),
48 _varList(
"varList",
"List of variables", this),
49 _pdfList(
"pdfList",
"List of pdfs", this),
68 m(
"m",
"m", this, _m),
69 _varList(
"varList",
"List of variables", this),
70 _pdfList(
"pdfList",
"List of pdfs", this),
83 for (
auto *mref : mrefList) {
85 coutE(InputArguments) <<
"RooMomentMorphFunc::ctor(" <<
GetName() <<
") ERROR: mref " << mref->GetName()
86 <<
" is not of type RooAbsReal" << std::endl;
87 throw string(
"RooPolyMorh::ctor() ERROR mref is not of type RooAbsReal");
90 coutW(InputArguments) <<
"RooMomentMorphFunc::ctor(" <<
GetName() <<
") WARNING mref point " << i
91 <<
" is not a constant, taking a snapshot of its value" << std::endl;
105 m(
"m", this, other.
m),
133 if (nPdf !=
_mref->GetNrows()) {
134 coutE(InputArguments) <<
"RooMomentMorphFunc::initialize(" <<
GetName() <<
") ERROR: nPdf != nRefPoints" << std::endl;
143 for (
Int_t i = 0; i <
_mref->GetNrows(); ++i) {
144 (*dm)[i] = (*_mref)[i] - (*_mref)[0];
149 for (
Int_t i = 1; i <
_mref->GetNrows(); ++i) {
150 for (
Int_t j = 1; j <
_mref->GetNrows(); ++j) {
151 M(i, j) = std::pow((*dm)[i], (
double)j);
170 vector<RooAbsReal *> meanrv(nPdf * nVar, null);
171 vector<RooAbsReal *> sigmarv(nPdf * nVar, null);
172 vector<RooAbsReal *> myrms(nVar, null);
173 vector<RooAbsReal *> mypos(nVar, null);
174 vector<RooAbsReal *> slope(nPdf * nVar, null);
175 vector<RooAbsReal *> offs(nPdf * nVar, null);
176 vector<RooAbsReal *> transVar(nPdf * nVar, null);
177 vector<RooAbsReal *> transPdf(nPdf, null);
186 for (
Int_t i = 0; i < 2 * nPdf; ++i) {
187 std::string fracName =
Form(
"frac_%d", i);
201 std::string sumfuncName =
Form(
"%s_sumfunc",
GetName());
206 for (
Int_t i = 0; i < nPdf; ++i) {
207 for (
Int_t j = 0; j < nVar; ++j) {
209 std::string meanName =
Form(
"%s_mean_%d_%d",
GetName(), i, j);
210 std::string sigmaName =
Form(
"%s_sigma_%d_%d",
GetName(), i, j);
218 sigmarv[
ij(i, j)] = mom;
219 meanrv[
ij(i, j)] = mom->
mean();
221 ownedComps.
add(*sigmarv[
ij(i, j)]);
226 for (
Int_t j = 0; j < nVar; ++j) {
229 for (
Int_t i = 0; i < nPdf; ++i) {
230 meanList.
add(*meanrv[
ij(i, j)]);
231 rmsList.
add(*sigmarv[
ij(i, j)]);
233 std::string myrmsName =
Form(
"%s_rms_%d",
GetName(), j);
234 std::string myposName =
Form(
"%s_pos_%d",
GetName(), j);
235 myrms[j] =
new RooAddition(myrmsName.c_str(), myrmsName.c_str(), rmsList, coefList2);
236 mypos[j] =
new RooAddition(myposName.c_str(), myposName.c_str(), meanList, coefList2);
243 for (
Int_t i = 0; i < nPdf; ++i) {
245 std::string pdfName =
Form(
"pdf_%d", i);
248 for (
Int_t j = 0; j < nVar; ++j) {
250 std::string slopeName =
Form(
"%s_slope_%d_%d",
GetName(), i, j);
251 std::string offsetName =
Form(
"%s_offset_%d_%d",
GetName(), i, j);
258 std::string transVarName =
Form(
"%s_transVar_%d_%d",
GetName(), i, j);
263 new RooLinearVar(transVarName.c_str(), transVarName.c_str(), var, *slope[
ij(i, j)], *offs[
ij(i, j)]);
269 ownedComps.
add(*transVar[
ij(i, j)]);
273 transPdfList.
add(*transPdf[i]);
274 ownedComps.
add(*transPdf[i]);
277 theSumFunc =
new RooRealSumFunc(sumfuncName.c_str(), sumfuncName.c_str(), transPdfList, coefList);
288 std::string trackerName =
Form(
"%s_frac_tracker",
GetName());
292 cache =
new CacheElem(*theSumFunc, *tracker, fracl);
293 _cacheMgr.setObj(
nullptr,
nullptr, cache,
nullptr);
373 double dm = self.
m - (*self.
_mref)[0];
376 double sumposfrac = 0.;
377 for (
Int_t i = 0; i < nPdf; ++i) {
379 for (
Int_t j = 0; j < nPdf; ++j) {
380 ffrac += (*self.
_M)(j, i) * (j == 0 ? 1. : std::pow(dm, (
double)j));
389 std::cout << ffrac << std::endl;
394 int imin = self.
idxmin(self.
m);
395 int imax = self.
idxmax(self.
m);
396 double mfrac = (self.
m - (*self.
_mref)[imin]) / ((*self.
_mref)[imax] - (*self.
_mref)[imin]);
409 for (
Int_t i = 0; i < 2 * nPdf; ++i) const_cast<RooRealVar *>(
frac(i))->setVal(0.);
415 }
else if (imax == imin) {
421 for (
Int_t i = 0; i < nPdf; ++i) const_cast<RooRealVar *>(
frac(i))->setVal(0.);
425 }
else if (imax == imin) {
430 for (
Int_t i = 0; i < nPdf; ++i) {
444 double mmin = -DBL_MAX;
445 for (
Int_t i = 0; i < nPdf; ++i) {
446 if ((*
_mref)[i] > mmin && (*
_mref)[i] <= mval) {
459 double mmax = DBL_MAX;
460 for (
Int_t i = 0; i < nPdf; ++i) {
461 if ((*
_mref)[i] < mmax && (*
_mref)[i] >= mval) {
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
int Int_t
Signed integer 4 bytes (int).
TMatrixT< Double_t > TMatrixD
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
TVectorT< Double_t > TVectorD
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.
RooAbsArg()
Default constructor.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
Storage_t::size_type size() const
Abstract interface for all probability density functions.
Abstract base class for objects that represent a real value that may appear on the left hand side of ...
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.
virtual double getValV(const RooArgSet *normalisationSet=nullptr) const
Return value of object.
RooAbsReal()
coverity[UNINIT_CTOR] Default constructor
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)
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.
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.
Represents 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
double getValV(const RooArgSet *set=nullptr) const override
Return value of object.
~RooMomentMorphFunc() override
RooArgSet * _curNormSet
! Current normalization set
bool isBinnedDistribution(const RooArgSet &obs) const override
Tests if the distribution is binned. Unless overridden by derived classes, this always returns false.
RooObjCacheManager _cacheMgr
! The cache manager
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
Variable that can be changed from the outside.
const char * GetName() const override
Returns name of object.
constexpr Double_t PiOver2()