38 : _cacheMgr(this,10,true,true), _curNormSet(0), _mref(0), _M(0), _useHorizMorph(true)
52 _cacheMgr(this,10,true,true),
54 _varList(
"varList",
"List of variables",this),
55 _pdfList(
"pdfList",
"List of pdfs",this),
60 for (
auto *var : varList) {
62 coutE(
InputArguments) <<
"RooMomentMorph::ctor(" <<
GetName() <<
") ERROR: variable " << var->GetName() <<
" is not of type RooAbsReal" << endl ;
63 throw string(
"RooPolyMorh::ctor() ERROR variable is not of type RooAbsReal") ;
70 for (
auto const *pdf : pdfList) {
71 if (!
dynamic_cast<RooAbsPdf const*
>(pdf)) {
72 coutE(
InputArguments) <<
"RooMomentMorph::ctor(" <<
GetName() <<
") ERROR: pdf " << pdf->GetName() <<
" is not of type RooAbsPdf" << endl ;
73 throw string(
"RooPolyMorh::ctor() ERROR pdf is not of type RooAbsPdf") ;
94 _cacheMgr(this,10,true,true),
96 _varList(
"varList",
"List of variables",this),
97 _pdfList(
"pdfList",
"List of pdfs",this),
102 for (
auto *var : varList) {
104 coutE(
InputArguments) <<
"RooMomentMorph::ctor(" <<
GetName() <<
") ERROR: variable " << var->GetName() <<
" is not of type RooAbsReal" << endl ;
105 throw string(
"RooPolyMorh::ctor() ERROR variable is not of type RooAbsReal") ;
111 for (
auto const *pdf : pdfList) {
112 if (!
dynamic_cast<RooAbsPdf const*
>(pdf)) {
113 coutE(
InputArguments) <<
"RooMomentMorph::ctor(" <<
GetName() <<
") ERROR: pdf " << pdf->GetName() <<
" is not of type RooAbsPdf" << endl ;
114 throw string(
"RooPolyMorh::ctor() ERROR pdf is not of type RooAbsPdf") ;
122 for (
auto *mref : mrefList) {
124 coutE(
InputArguments) <<
"RooMomentMorph::ctor(" <<
GetName() <<
") ERROR: mref " << mref->GetName() <<
" is not of type RooAbsReal" << endl ;
125 throw string(
"RooPolyMorh::ctor() ERROR mref is not of type RooAbsReal") ;
128 coutW(
InputArguments) <<
"RooMomentMorph::ctor(" <<
GetName() <<
") WARNING mref point " << i <<
" is not a constant, taking a snapshot of its value" << endl ;
142 _cacheMgr(other._cacheMgr,this),
145 _varList(
"varList",this,other._varList),
146 _pdfList(
"pdfList",this,other._pdfList),
147 _setting(other._setting),
148 _useHorizMorph(other._useHorizMorph)
184 (*dm)[i] = (*_mref)[i]-(*_mref)[0];
186 if (i>0) M(0,i) = 0.;
210 vector<RooAbsReal*> meanrv(nPdf*nVar,
null);
211 vector<RooAbsReal*> sigmarv(nPdf*nVar,
null);
212 vector<RooAbsReal*> myrms(nVar,
null);
213 vector<RooAbsReal*> mypos(nVar,
null);
214 vector<RooAbsReal*> slope(nPdf*nVar,
null);
215 vector<RooAbsReal*> offs(nPdf*nVar,
null);
216 vector<RooAbsReal*> transVar(nPdf*nVar,
null);
217 vector<RooAbsReal*> transPdf(nPdf,
null);
226 for (
Int_t i=0; i<2*nPdf; ++i) {
227 std::string fracName =
Form(
"frac_%d",i);
238 std::string sumpdfName =
Form(
"%s_sumpdf",
GetName());
243 for (
Int_t i=0; i<nPdf; ++i) {
244 for (
Int_t j=0; j<nVar; ++j) {
246 std::string meanName =
Form(
"%s_mean_%d_%d",
GetName(),i,j);
247 std::string sigmaName =
Form(
"%s_sigma_%d_%d",
GetName(),i,j);
256 sigmarv[
ij(i,j)] = mom ;
257 meanrv[
ij(i,j)] = mom->
mean() ;
259 ownedComps.
add(*sigmarv[
ij(i,j)]) ;
264 for (
Int_t j=0; j<nVar; ++j) {
267 for (
Int_t i=0; i<nPdf; ++i) {
268 meanList.
add(*meanrv[
ij(i,j)]);
269 rmsList.
add(*sigmarv[
ij(i,j)]);
271 std::string myrmsName =
Form(
"%s_rms_%d",
GetName(),j);
272 std::string myposName =
Form(
"%s_pos_%d",
GetName(),j);
273 myrms[j] =
new RooAddition(myrmsName.c_str(),myrmsName.c_str(),rmsList,coefList2);
274 mypos[j] =
new RooAddition(myposName.c_str(),myposName.c_str(),meanList,coefList2);
283 for (
Int_t i=0; i<nPdf; ++i) {
288 std::string pdfName =
Form(
"pdf_%d",i);
291 for (
Int_t j=0; j<nVar; ++j) {
293 std::string slopeName =
Form(
"%s_slope_%d_%d",
GetName(),i,j);
294 std::string offsetName =
Form(
"%s_offset_%d_%d",
GetName(),i,j);
300 std::string transVarName =
Form(
"%s_transVar_%d_%d",
GetName(),i,j);
303 transVar[
ij(i,j)] =
new RooLinearVar(transVarName.c_str(),transVarName.c_str(),*var,*slope[
ij(i,j)],*offs[
ij(i,j)]);
309 ownedComps.
add(*transVar[
ij(i,j)]) ;
313 transPdfList.
add(*transPdf[i]);
314 ownedComps.
add(*transPdf[i]) ;
317 theSumPdf =
new RooAddPdf(sumpdfName.c_str(),sumpdfName.c_str(),transPdfList,coefList);
320 theSumPdf =
new RooAddPdf(sumpdfName.c_str(),sumpdfName.c_str(),
_pdfList,coefList);
329 std::string trackerName =
Form(
"%s_frac_tracker",
GetName()) ;
333 cache =
new CacheElem(*theSumPdf,*tracker,fracl) ;
411 double dm = self.
m - (*self.
_mref)[0];
414 double sumposfrac=0.;
415 for (
Int_t i=0; i<nPdf; ++i) {
417 for (
Int_t j=0; j<nPdf; ++j) { ffrac += (*self.
_M)(j,i) * (j==0?1.:
TMath::Power(dm,(
double)j)); }
418 if (ffrac>=0) sumposfrac+=ffrac;
423 if (
verbose) { cout << ffrac << endl; }
427 int imin = self.
idxmin(self.
m);
428 int imax = self.
idxmax(self.
m);
429 double mfrac = (self.
m-(*self.
_mref)[imin])/((*self.
_mref)[imax]-(*self.
_mref)[imin]);
441 for (
Int_t i=0; i<2*nPdf; ++i)
445 ((
RooRealVar*)frac(nPdf+imin))->setVal(1.-mfrac);
447 ((
RooRealVar*)frac(nPdf+imax))->setVal(mfrac);
448 }
else if (imax==imin) {
454 for (
Int_t i=0; i<nPdf; ++i)
459 }
else if (imax==imin) {
464 for (
Int_t i=0; i<nPdf; ++i) {
479 double mmin=-DBL_MAX;
480 for (
Int_t i=0; i<nPdf; ++i)
481 if ( (*
_mref)[i]>mmin && (*
_mref)[i]<=mval ) { mmin=(*_mref)[i]; imin=i; }
493 for (
Int_t i=0; i<nPdf; ++i)
494 if ( (*
_mref)[i]<mmax && (*
_mref)[i]>=mval ) { mmax=(*_mref)[i]; imax=i; }
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
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
RooAbsMoment * sigma(RooRealVar &obs)
RooAddPdf is an efficient implementation of a sum of PDFs of the form.
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...
RooArgList containedArgs(Action) override
RooRealVar * frac(Int_t i)
void calculateFractions(const RooMomentMorph &self, bool verbose=true) const
RooChangeTracker * _tracker
RooObjCacheManager _cacheMgr
friend class CacheElem
Current normalization set.
~RooMomentMorph() override
TIterator * _pdfItr
do not persist
double evaluate() const override
Evaluate this PDF / function / constant. Needs to be overridden by all derived classes.
RooMomentMorph()
coverity[UNINIT_CTOR]
RooAbsPdf * sumPdf(const RooArgSet *nset)
Int_t ij(const Int_t &i, const Int_t &j) const
virtual double getVal(const RooArgSet *set=0) const
Special version of getVal() overrides RooAbsReal::getVal() to save value of current normalization set...
RooArgSet * _curNormSet
The cache manager.
int idxmin(const double &m) const
int idxmax(const double &m) const
CacheElem * getCache(const RooArgSet *nset) 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.