55 _varList(
"varList",
"List of variables",this),
56 _pdfList(
"pdfList",
"List of pdfs",this),
65 coutE(InputArguments) <<
"RooMomentMorph::ctor(" <<
GetName() <<
") ERROR: variable " << var->
GetName() <<
" is not of type RooAbsReal" << endl ;
66 throw string(
"RooPolyMorh::ctor() ERROR variable is not of type RooAbsReal") ;
77 coutE(InputArguments) <<
"RooMomentMorph::ctor(" <<
GetName() <<
") ERROR: pdf " << pdf->
GetName() <<
" is not of type RooAbsPdf" << endl ;
78 throw string(
"RooPolyMorh::ctor() ERROR pdf is not of type RooAbsPdf") ;
104 _varList(
"varList",
"List of variables",this),
105 _pdfList(
"pdfList",
"List of pdfs",this),
114 coutE(InputArguments) <<
"RooMomentMorph::ctor(" <<
GetName() <<
") ERROR: variable " << var->
GetName() <<
" is not of type RooAbsReal" << endl ;
115 throw string(
"RooPolyMorh::ctor() ERROR variable is not of type RooAbsReal") ;
126 coutE(InputArguments) <<
"RooMomentMorph::ctor(" <<
GetName() <<
") ERROR: pdf " << pdf->
GetName() <<
" is not of type RooAbsPdf" << endl ;
127 throw string(
"RooPolyMorh::ctor() ERROR pdf is not of type RooAbsPdf") ;
139 coutE(InputArguments) <<
"RooMomentMorph::ctor(" <<
GetName() <<
") ERROR: mref " << mref->
GetName() <<
" is not of type RooAbsReal" << endl ;
140 throw string(
"RooPolyMorh::ctor() ERROR mref is not of type RooAbsReal") ;
143 coutW(InputArguments) <<
"RooMomentMorph::ctor(" <<
GetName() <<
") WARNING mref point " << i <<
" is not a constant, taking a snapshot of its value" << endl ;
145 (*_mref)[i] = mref->
getVal() ;
160 _cacheMgr(other._cacheMgr,this),
163 _varList(
"varList",this,other._varList),
164 _pdfList(
"pdfList",this,other._pdfList),
165 _setting(other._setting),
166 _useHorizMorph(other._useHorizMorph)
194 coutE(InputArguments) <<
"RooMomentMorph::initialize(" <<
GetName() <<
") ERROR: nPdf != nRefPoints" << endl ;
204 (*dm)[i] = (*_mref)[i]-(*_mref)[0];
206 if (i>0) M(0,i) = 0.;
230 vector<RooAbsReal*> meanrv(nPdf*nVar,null);
231 vector<RooAbsReal*> sigmarv(nPdf*nVar,null);
232 vector<RooAbsReal*> myrms(nVar,null);
233 vector<RooAbsReal*> mypos(nVar,null);
234 vector<RooAbsReal*> slope(nPdf*nVar,null);
235 vector<RooAbsReal*> offs(nPdf*nVar,null);
236 vector<RooAbsReal*> transVar(nPdf*nVar,null);
237 vector<RooAbsReal*> transPdf(nPdf,null);
246 for (
Int_t i=0; i<2*nPdf; ++i) {
247 std::string fracName =
Form(
"frac_%d",i);
258 std::string sumpdfName =
Form(
"%s_sumpdf",
GetName());
263 for (
Int_t i=0; i<nPdf; ++i) {
264 for (
Int_t j=0; j<nVar; ++j) {
266 std::string meanName =
Form(
"%s_mean_%d_%d",
GetName(),i,j);
267 std::string sigmaName =
Form(
"%s_sigma_%d_%d",
GetName(),i,j);
276 sigmarv[
ij(i,j)] = mom ;
277 meanrv[
ij(i,j)] = mom->
mean() ;
279 ownedComps.
add(*sigmarv[
ij(i,j)]) ;
284 for (
Int_t j=0; j<nVar; ++j) {
287 for (
Int_t i=0; i<nPdf; ++i) {
288 meanList.
add(*meanrv[
ij(i,j)]);
289 rmsList.
add(*sigmarv[
ij(i,j)]);
291 std::string myrmsName =
Form(
"%s_rms_%d",
GetName(),j);
292 std::string myposName =
Form(
"%s_pos_%d",
GetName(),j);
293 myrms[j] =
new RooAddition(myrmsName.c_str(),myrmsName.c_str(),rmsList,coefList2);
294 mypos[j] =
new RooAddition(myposName.c_str(),myposName.c_str(),meanList,coefList2);
303 for (
Int_t i=0; i<nPdf; ++i) {
308 std::string pdfName =
Form(
"pdf_%d",i);
311 for (
Int_t j=0; j<nVar; ++j) {
313 std::string slopeName =
Form(
"%s_slope_%d_%d",
GetName(),i,j);
314 std::string offsetName =
Form(
"%s_offset_%d_%d",
GetName(),i,j);
320 std::string transVarName =
Form(
"%s_transVar_%d_%d",
GetName(),i,j);
323 transVar[
ij(i,j)] =
new RooLinearVar(transVarName.c_str(),transVarName.c_str(),*var,*slope[
ij(i,j)],*offs[
ij(i,j)]);
329 ownedComps.
add(*transVar[
ij(i,j)]) ;
333 transPdfList.
add(*transPdf[i]);
334 ownedComps.
add(*transPdf[i]) ;
337 theSumPdf =
new RooAddPdf(sumpdfName.c_str(),sumpdfName.c_str(),transPdfList,coefList);
340 theSumPdf =
new RooAddPdf(sumpdfName.c_str(),sumpdfName.c_str(),
_pdfList,coefList);
349 std::string trackerName =
Form(
"%s_frac_tracker",
GetName()) ;
353 cache =
new CacheElem(*theSumPdf,*tracker,fracl) ;
434 double sumposfrac=0.;
435 for (
Int_t i=0; i<nPdf; ++i) {
437 for (
Int_t j=0; j<nPdf; ++j) { ffrac += (*self.
_M)(j,i) * (j==0?1.:
TMath::Power(dm,(
double)j)); }
438 if (ffrac>=0) sumposfrac+=ffrac;
443 if (verbose) { cout << ffrac << endl; }
447 int imin = self.
idxmin(self.
m);
448 int imax = self.
idxmax(self.
m);
449 double mfrac = (self.
m-(*self.
_mref)[imin])/((*self.
_mref)[imax]-(*self.
_mref)[imin]);
461 for (
Int_t i=0; i<2*nPdf; ++i)
465 ((
RooRealVar*)frac(nPdf+imin))->setVal(1.-mfrac);
467 ((
RooRealVar*)frac(nPdf+imax))->setVal(mfrac);
468 }
else if (imax==imin) {
474 for (
Int_t i=0; i<nPdf; ++i)
479 }
else if (imax==imin) {
484 for (
Int_t i=0; i<nPdf; ++i) {
499 double mmin=-DBL_MAX;
500 for (
Int_t i=0; i<nPdf; ++i)
501 if ( (*
_mref)[i]>mmin && (*
_mref)[i]<=mval ) { mmin=(*_mref)[i]; imin=i; }
513 for (
Int_t i=0; i<nPdf; ++i)
514 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_t addOwnedComponents(const RooArgSet &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.
Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE) override
Add element to non-owning set.
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)