38 : _cacheMgr(this,10,true,true), _curNormSet(0), _mref(0), _M(0), _useHorizMorph(true)
56 _varList(
"varList",
"List of variables",this),
57 _pdfList(
"pdfList",
"List of pdfs",this),
66 coutE(InputArguments) <<
"RooMomentMorph::ctor(" <<
GetName() <<
") ERROR: variable " << var->
GetName() <<
" is not of type RooAbsReal" << endl ;
67 throw string(
"RooPolyMorh::ctor() ERROR variable is not of type RooAbsReal") ;
78 coutE(InputArguments) <<
"RooMomentMorph::ctor(" <<
GetName() <<
") ERROR: pdf " << pdf->
GetName() <<
" is not of type RooAbsPdf" << endl ;
79 throw string(
"RooPolyMorh::ctor() ERROR pdf is not of type RooAbsPdf") ;
105 _varList(
"varList",
"List of variables",this),
106 _pdfList(
"pdfList",
"List of pdfs",this),
115 coutE(InputArguments) <<
"RooMomentMorph::ctor(" <<
GetName() <<
") ERROR: variable " << var->
GetName() <<
" is not of type RooAbsReal" << endl ;
116 throw string(
"RooPolyMorh::ctor() ERROR variable is not of type RooAbsReal") ;
127 coutE(InputArguments) <<
"RooMomentMorph::ctor(" <<
GetName() <<
") ERROR: pdf " << pdf->
GetName() <<
" is not of type RooAbsPdf" << endl ;
128 throw string(
"RooPolyMorh::ctor() ERROR pdf is not of type RooAbsPdf") ;
140 coutE(InputArguments) <<
"RooMomentMorph::ctor(" <<
GetName() <<
") ERROR: mref " << mref->
GetName() <<
" is not of type RooAbsReal" << endl ;
141 throw string(
"RooPolyMorh::ctor() ERROR mref is not of type RooAbsReal") ;
144 coutW(InputArguments) <<
"RooMomentMorph::ctor(" <<
GetName() <<
") WARNING mref point " << i <<
" is not a constant, taking a snapshot of its value" << endl ;
146 (*_mref)[i] = mref->
getVal() ;
161 _cacheMgr(other._cacheMgr,this),
164 _varList(
"varList",this,other._varList),
165 _pdfList(
"pdfList",this,other._pdfList),
166 _setting(other._setting),
167 _useHorizMorph(other._useHorizMorph)
195 coutE(InputArguments) <<
"RooMomentMorph::initialize(" <<
GetName() <<
") ERROR: nPdf != nRefPoints" << endl ;
205 (*dm)[i] = (*_mref)[i]-(*_mref)[0];
207 if (i>0) M(0,i) = 0.;
231 vector<RooAbsReal*> meanrv(nPdf*nVar,null);
232 vector<RooAbsReal*> sigmarv(nPdf*nVar,null);
233 vector<RooAbsReal*> myrms(nVar,null);
234 vector<RooAbsReal*> mypos(nVar,null);
235 vector<RooAbsReal*> slope(nPdf*nVar,null);
236 vector<RooAbsReal*> offs(nPdf*nVar,null);
237 vector<RooAbsReal*> transVar(nPdf*nVar,null);
238 vector<RooAbsReal*> transPdf(nPdf,null);
247 for (
Int_t i=0; i<2*nPdf; ++i) {
248 std::string fracName =
Form(
"frac_%d",i);
259 std::string sumpdfName =
Form(
"%s_sumpdf",
GetName());
264 for (
Int_t i=0; i<nPdf; ++i) {
265 for (
Int_t j=0; j<nVar; ++j) {
267 std::string meanName =
Form(
"%s_mean_%d_%d",
GetName(),i,j);
268 std::string sigmaName =
Form(
"%s_sigma_%d_%d",
GetName(),i,j);
277 sigmarv[
ij(i,j)] = mom ;
278 meanrv[
ij(i,j)] = mom->
mean() ;
280 ownedComps.
add(*sigmarv[
ij(i,j)]) ;
285 for (
Int_t j=0; j<nVar; ++j) {
288 for (
Int_t i=0; i<nPdf; ++i) {
289 meanList.
add(*meanrv[
ij(i,j)]);
290 rmsList.
add(*sigmarv[
ij(i,j)]);
292 std::string myrmsName =
Form(
"%s_rms_%d",
GetName(),j);
293 std::string myposName =
Form(
"%s_pos_%d",
GetName(),j);
294 myrms[j] =
new RooAddition(myrmsName.c_str(),myrmsName.c_str(),rmsList,coefList2);
295 mypos[j] =
new RooAddition(myposName.c_str(),myposName.c_str(),meanList,coefList2);
304 for (
Int_t i=0; i<nPdf; ++i) {
309 std::string pdfName =
Form(
"pdf_%d",i);
312 for (
Int_t j=0; j<nVar; ++j) {
314 std::string slopeName =
Form(
"%s_slope_%d_%d",
GetName(),i,j);
315 std::string offsetName =
Form(
"%s_offset_%d_%d",
GetName(),i,j);
321 std::string transVarName =
Form(
"%s_transVar_%d_%d",
GetName(),i,j);
324 transVar[
ij(i,j)] =
new RooLinearVar(transVarName.c_str(),transVarName.c_str(),*var,*slope[
ij(i,j)],*offs[
ij(i,j)]);
330 ownedComps.
add(*transVar[
ij(i,j)]) ;
334 transPdfList.
add(*transPdf[i]);
335 ownedComps.
add(*transPdf[i]) ;
338 theSumPdf =
new RooAddPdf(sumpdfName.c_str(),sumpdfName.c_str(),transPdfList,coefList);
341 theSumPdf =
new RooAddPdf(sumpdfName.c_str(),sumpdfName.c_str(),
_pdfList,coefList);
350 std::string trackerName =
Form(
"%s_frac_tracker",
GetName()) ;
354 cache =
new CacheElem(*theSumPdf,*tracker,fracl) ;
435 double sumposfrac=0.;
436 for (
Int_t i=0; i<nPdf; ++i) {
438 for (
Int_t j=0; j<nPdf; ++j) { ffrac += (*self.
_M)(j,i) * (j==0?1.:
TMath::Power(dm,(
double)j)); }
439 if (ffrac>=0) sumposfrac+=ffrac;
444 if (verbose) { cout << ffrac << endl; }
448 int imin = self.
idxmin(self.
m);
449 int imax = self.
idxmax(self.
m);
450 double mfrac = (self.
m-(*self.
_mref)[imin])/((*self.
_mref)[imax]-(*self.
_mref)[imin]);
462 for (
Int_t i=0; i<2*nPdf; ++i)
466 ((
RooRealVar*)frac(nPdf+imin))->setVal(1.-mfrac);
468 ((
RooRealVar*)frac(nPdf+imax))->setVal(mfrac);
469 }
else if (imax==imin) {
475 for (
Int_t i=0; i<nPdf; ++i)
480 }
else if (imax==imin) {
485 for (
Int_t i=0; i<nPdf; ++i) {
500 double mmin=-DBL_MAX;
501 for (
Int_t i=0; i<nPdf; ++i)
502 if ( (*
_mref)[i]>mmin && (*
_mref)[i]<=mval ) { mmin=(*_mref)[i]; imin=i; }
514 for (
Int_t i=0; i<nPdf; ++i)
515 if ( (*
_mref)[i]<mmax && (*
_mref)[i]>=mval ) { mmax=(*_mref)[i]; imax=i; }
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
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
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)
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 RooMomentMorph &self, Bool_t verbose=kTRUE) const
RooRealVar * frac(Int_t i)
virtual RooArgList containedArgs(Action)
RooChangeTracker * _tracker
RooObjCacheManager _cacheMgr
TIterator * _pdfItr
do not persist
Double_t evaluate() const
Evaluate this PDF / function / constant. Needs to be overridden by all derived classes.
virtual ~RooMomentMorph()
RooMomentMorph()
coverity[UNINIT_CTOR]
RooAbsPdf * sumPdf(const RooArgSet *nset)
Int_t ij(const Int_t &i, const Int_t &j) const
RooArgSet * _curNormSet
The cache manager.
int idxmin(const double &m) const
virtual Double_t getVal(const RooArgSet *set=0) const
Special version of getVal() overrides RooAbsReal::getVal() to save value of current normalization set...
int idxmax(const double &m) const
CacheElem * getCache(const RooArgSet *nset) const
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)