37 _varItr = _varList.createIterator() ;
38 _pdfItr = _pdfList.createIterator() ;
55 _varList(
"varList",
"List of variables",this),
56 _pdfList(
"pdfList",
"List of pdfs",this),
64 if (!dynamic_cast<RooAbsReal*>(var)) {
66 throw string(
"RooPolyMorh::ctor() ERROR variable is not of type RooAbsReal") ;
78 throw string(
"RooPolyMorh::ctor() ERROR pdf is not of type RooAbsPdf") ;
106 _varList(
"varList",
"List of variables",this),
107 _pdfList(
"pdfList",
"List of pdfs",this),
115 if (!dynamic_cast<RooAbsReal*>(var)) {
117 throw string(
"RooPolyMorh::ctor() ERROR variable is not of type RooAbsReal") ;
129 throw string(
"RooPolyMorh::ctor() ERROR pdf is not of type RooAbsPdf") ;
139 for (
Int_t i=0; (mref =
dynamic_cast<RooAbsReal*
>(mrefItr->Next())); ++i) {
142 throw string(
"RooPolyMorh::ctor() ERROR mref is not of type RooAbsReal") ;
144 if (!dynamic_cast<RooConstVar*>(mref)) {
145 coutW(
InputArguments) <<
"RooMomentMorph::ctor(" <<
GetName() <<
") WARNING mref point " << i <<
" is not a constant, taking a snapshot of its value" << endl ;
147 (*_mref)[i] = mref->
getVal() ;
210 (*dm)[i] = (*_mref)[i]-(*_mref)[0];
212 if (i>0) M(0,i) = 0.;
236 vector<RooAbsReal*> meanrv(nPdf*nVar,null);
237 vector<RooAbsReal*> sigmarv(nPdf*nVar,null);
238 vector<RooAbsReal*> myrms(nVar,null);
239 vector<RooAbsReal*> mypos(nVar,null);
240 vector<RooAbsReal*> slope(nPdf*nVar,null);
241 vector<RooAbsReal*> offs(nPdf*nVar,null);
242 vector<RooAbsReal*> transVar(nPdf*nVar,null);
243 vector<RooAbsReal*> transPdf(nPdf,null);
252 for (
Int_t i=0; i<2*nPdf; ++i) {
253 std::string fracName =
Form(
"frac_%d",i);
264 std::string sumpdfName =
Form(
"%s_sumpdf",
GetName());
269 for (
Int_t i=0; i<nPdf; ++i) {
270 for (
Int_t j=0; j<nVar; ++j) {
272 std::string meanName =
Form(
"%s_mean_%d_%d",
GetName(),i,j);
273 std::string sigmaName =
Form(
"%s_sigma_%d_%d",
GetName(),i,j);
282 sigmarv[
ij(i,j)] = mom ;
283 meanrv[
ij(i,j)] = mom->
mean() ;
285 ownedComps.
add(*sigmarv[
ij(i,j)]) ;
290 for (
Int_t j=0; j<nVar; ++j) {
293 for (
Int_t i=0; i<nPdf; ++i) {
294 meanList.
add(*meanrv[
ij(i,j)]);
295 rmsList.
add(*sigmarv[
ij(i,j)]);
297 std::string myrmsName =
Form(
"%s_rms_%d",
GetName(),j);
298 std::string myposName =
Form(
"%s_pos_%d",
GetName(),j);
299 myrms[j] =
new RooAddition(myrmsName.c_str(),myrmsName.c_str(),rmsList,coefList2);
300 mypos[j] =
new RooAddition(myposName.c_str(),myposName.c_str(),meanList,coefList2);
309 for (
Int_t i=0; i<nPdf; ++i) {
314 std::string pdfName =
Form(
"pdf_%d",i);
317 for (
Int_t j=0; j<nVar; ++j) {
319 std::string slopeName =
Form(
"%s_slope_%d_%d",
GetName(),i,j);
320 std::string offsetName =
Form(
"%s_offset_%d_%d",
GetName(),i,j);
326 std::string transVarName =
Form(
"%s_transVar_%d_%d",
GetName(),i,j);
329 transVar[
ij(i,j)] =
new RooLinearVar(transVarName.c_str(),transVarName.c_str(),*var,*slope[
ij(i,j)],*offs[
ij(i,j)]);
335 ownedComps.
add(*transVar[
ij(i,j)]) ;
336 cust.replaceArg(*var,*transVar[
ij(i,j)]);
338 transPdf[i] = (
RooAbsPdf*) cust.build() ;
339 transPdfList.
add(*transPdf[i]);
340 ownedComps.
add(*transPdf[i]) ;
343 theSumPdf =
new RooAddPdf(sumpdfName.c_str(),sumpdfName.c_str(),transPdfList,coefList);
346 theSumPdf =
new RooAddPdf(sumpdfName.c_str(),sumpdfName.c_str(),
_pdfList,coefList);
355 std::string trackerName =
Form(
"%s_frac_tracker",
GetName()) ;
359 cache =
new CacheElem(*theSumPdf,*tracker,fracl) ;
446 Int_t nPdf =
self._pdfList.getSize();
448 Double_t dm =
self.m - (*
self._mref)[0];
451 double sumposfrac=0.;
452 for (
Int_t i=0; i<nPdf; ++i) {
454 for (
Int_t j=0; j<nPdf; ++j) { ffrac += (*
self._M)(j,i) * (j==0?1.:
TMath::Power(dm,(
double)j)); }
455 if (ffrac>=0) sumposfrac+=ffrac;
460 if (verbose) { cout << ffrac << endl; }
464 int imin =
self.idxmin(
self.
m);
465 int imax =
self.idxmax(
self.
m);
466 double mfrac = (
self.m-(*
self._mref)[imin])/((*
self._mref)[imax]-(*
self.
_mref)[imin]);
478 for (
Int_t i=0; i<2*nPdf; ++i)
482 ((
RooRealVar*)frac(nPdf+imin))->setVal(1.-mfrac);
484 ((
RooRealVar*)frac(nPdf+imax))->setVal(mfrac);
485 }
else if (imax==imin) {
491 for (
Int_t i=0; i<nPdf; ++i)
496 }
else if (imax==imin) {
501 for (
Int_t i=0; i<nPdf; ++i) {
516 double mmin=-DBL_MAX;
517 for (
Int_t i=0; i<nPdf; ++i)
518 if ( (*
_mref)[i]>mmin && (*
_mref)[i]<=mval ) { mmin=(*_mref)[i]; imin=i; }
530 for (
Int_t i=0; i<nPdf; ++i)
531 if ( (*
_mref)[i]<mmax && (*
_mref)[i]>=mval ) { mmax=(*_mref)[i]; imax=i; }
virtual const char * GetName() const
Returns name of object.
virtual Double_t getVal(const RooArgSet *set=0) const
Special version of getVal() overrides RooAbsReal::getVal() to save value of current normalization set...
RooAddPdf is an efficient implementation of a sum of PDFs of the form.
TIterator * createIterator(Bool_t dir=kIterForward) const
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
CacheElem * getCache(const RooArgSet *nset) const
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...
Double_t evaluate() const
Double_t getVal(const RooArgSet *set=0) const
Bool_t hasChanged(Bool_t clearState)
Returns true if state has changes since last call with clearState=kTRUE If clearState is true...
RooAbsPdf * sumPdf(const RooArgSet *nset)
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 ...
Iterator abstract base class.
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
TIterator * _pdfItr
do not persist
T * getObj(const RooArgSet *nset, Int_t *sterileIndex=0, const TNamed *isetRangeName=0)
RooAbsMoment * sigma(RooRealVar &obs)
RooArgSet * _curNormSet
The cache manager.
TVectorT< Double_t > TVectorD
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Reimplementation of standard RooArgList::add()
TMatrixT< Element > & Invert(Double_t *det=0)
Invert the matrix and calculate its determinant.
friend class CacheElem
Current normalization set.
const RooArgSet * nset() const
RooRealVar represents a fundamental (non-derived) real valued object.
TMatrixT< Double_t > TMatrixD
RooChangeTracker * _tracker
int idxmax(const double &m) const
RooRealVar * frac(Int_t i)
RooAbsArg * at(Int_t idx) const
char * Form(const char *fmt,...)
int idxmin(const double &m) const
RooObjCacheManager _cacheMgr
Int_t ij(const Int_t &i, const Int_t &j) const
virtual ~RooMomentMorph()
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
RooChangeTracker is a meta object that tracks value changes in a given set of RooAbsArgs by registeri...
RooAbsPdf is the abstract interface for all probability density functions The class provides hybrid a...
virtual TObject * Next()=0
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
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 RooMomentMorph &self, Bool_t verbose=kTRUE) const
RooMomentMorph()
coverity[UNINIT_CTOR]
virtual RooArgList containedArgs(Action)
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...