#include <VerticalInterpHistPdf.h>
Classes | |
struct | Morph |
Must be public, for serialization. More... | |
Public Member Functions | |
virtual TObject * | clone (const char *newname) const =0 |
const RooArgList & | coefList () const |
Double_t | evaluate () const =0 |
FastVerticalInterpHistPdfBase (const char *name, const char *title, const RooArgSet &obs, const RooArgList &funcList, const RooArgList &coefList, Double_t smoothRegion=1., Int_t smoothAlgo=1) | |
FastVerticalInterpHistPdfBase () | |
FastVerticalInterpHistPdfBase (const FastVerticalInterpHistPdfBase &other, const char *name=0) | |
const RooArgList & | funcList () const |
Bool_t | selfNormalized () const |
virtual | ~FastVerticalInterpHistPdfBase () |
Protected Member Functions | |
double | smoothStepFunc (double x) const |
void | syncMorph (Morph &out, const FastTemplate &nominal, FastTemplate &lo, FastTemplate &hi) const |
not to be serialized | |
void | syncTotal (FastTemplate &cache, const FastTemplate &cacheNominal, const FastTemplate &cacheNominalLog) const |
Protected Attributes | |
TIterator * | _coefIter |
Iterator over FUNC list. | |
RooListProxy | _coefList |
TIterator * | _funcIter |
RooListProxy | _funcList |
bool | _init |
Iterator over coefficient list. | |
std::vector< RooAbsReal * > | _morphParams |
not to be serialized | |
std::vector< Morph > | _morphs |
not to be serialized | |
SimpleCacheSentry | _sentry |
not to be serialized | |
Int_t | _smoothAlgo |
Double_t | _smoothRegion |
RooRealProxy | _x |
Definition at line 70 of file VerticalInterpHistPdf.h.
FastVerticalInterpHistPdfBase::FastVerticalInterpHistPdfBase | ( | ) |
FastVerticalInterpHistPdfBase::FastVerticalInterpHistPdfBase | ( | const char * | name, |
const char * | title, | ||
const RooArgSet & | obs, | ||
const RooArgList & | funcList, | ||
const RooArgList & | coefList, | ||
Double_t | smoothRegion = 1. , |
||
Int_t | smoothAlgo = 1 |
||
) |
Definition at line 239 of file VerticalInterpHistPdf.cc.
References _coefIter, _coefList, _funcIter, _funcList, and TRACEME.
: RooAbsPdf(name,title), _funcList("funcList","List of pdfs",this), _coefList("coefList","List of coefficients",this), // we should get shapeDirty when coefficients change _smoothRegion(smoothRegion), _smoothAlgo(smoothAlgo), _init(false), _morphs(), _morphParams() { TRACEME() if (inFuncList.getSize()!=2*inCoefList.getSize()+1) { coutE(InputArguments) << "VerticalInterpHistPdf::VerticalInterpHistPdf(" << GetName() << ") number of pdfs and coefficients inconsistent, must have Nfunc=1+2*Ncoef" << endl ; assert(0); } TIterator* funcIter = inFuncList.createIterator() ; RooAbsArg* func; while((func = (RooAbsArg*)funcIter->Next())) { RooAbsPdf *pdf = dynamic_cast<RooAbsPdf*>(func); if (!pdf) { coutE(InputArguments) << "ERROR: VerticalInterpHistPdf::VerticalInterpHistPdf(" << GetName() << ") function " << func->GetName() << " is not of type RooAbsPdf" << endl; assert(0); } RooArgSet *params = pdf->getParameters(obs); if (params->getSize() > 0) { coutE(InputArguments) << "ERROR: VerticalInterpHistPdf::VerticalInterpHistPdf(" << GetName() << ") pdf " << func->GetName() << " has some parameters." << endl; assert(0); } delete params; _funcList.add(*func) ; } delete funcIter; TIterator* coefIter = inCoefList.createIterator() ; RooAbsArg* coef; while((coef = (RooAbsArg*)coefIter->Next())) { if (!dynamic_cast<RooAbsReal*>(coef)) { coutE(InputArguments) << "ERROR: VerticalInterpHistPdf::VerticalInterpHistPdf(" << GetName() << ") coefficient " << coef->GetName() << " is not of type RooAbsReal" << endl; assert(0); } _coefList.add(*coef) ; } delete coefIter; _funcIter = _funcList.createIterator() ; _coefIter = _coefList.createIterator() ; }
FastVerticalInterpHistPdfBase::FastVerticalInterpHistPdfBase | ( | const FastVerticalInterpHistPdfBase & | other, |
const char * | name = 0 |
||
) |
Definition at line 291 of file VerticalInterpHistPdf.cc.
References _coefIter, _coefList, _funcIter, _funcList, _sentry, and SimpleCacheSentry::addVars().
: RooAbsPdf(other,name), _funcList("funcList",this,other._funcList), _coefList("coefList",this,other._coefList), _smoothRegion(other._smoothRegion), _smoothAlgo(other._smoothAlgo), _init(false), #ifdef FastVerticalInterpHistPdf_CopyConstructor _morphs(other._morphs), _morphParams(other._morphParams) #else _morphs(), _morphParams() #endif { // Copy constructor _funcIter = _funcList.createIterator() ; _coefIter = _coefList.createIterator() ; #ifdef FastVerticalInterpHistPdf_CopyConstructor _sentry.addVars(_coefList); _sentry.setValueDirty(); #endif }
FastVerticalInterpHistPdfBase::~FastVerticalInterpHistPdfBase | ( | ) | [virtual] |
virtual TObject* FastVerticalInterpHistPdfBase::clone | ( | const char * | newname | ) | const [pure virtual] |
Implemented in FastVerticalInterpHistPdf, and FastVerticalInterpHistPdf2D.
const RooArgList& FastVerticalInterpHistPdfBase::coefList | ( | ) | const [inline] |
Double_t FastVerticalInterpHistPdfBase::evaluate | ( | ) | const [pure virtual] |
Implemented in FastVerticalInterpHistPdf, and FastVerticalInterpHistPdf2D.
const RooArgList& FastVerticalInterpHistPdfBase::funcList | ( | ) | const [inline] |
Bool_t FastVerticalInterpHistPdfBase::selfNormalized | ( | ) | const [inline] |
Reimplemented in FastVerticalInterpHistPdf2D.
Definition at line 79 of file VerticalInterpHistPdf.h.
{ return kTRUE; }
double FastVerticalInterpHistPdfBase::smoothStepFunc | ( | double | x | ) | const [inline, protected] |
Definition at line 114 of file VerticalInterpHistPdf.h.
References _smoothRegion.
Referenced by syncTotal().
{ if (fabs(x) >= _smoothRegion) return x > 0 ? +1 : -1; double xnorm = x/_smoothRegion, xnorm2 = xnorm*xnorm; return 0.125 * xnorm * (xnorm2 * (3.*xnorm2 - 10.) + 15); }
void FastVerticalInterpHistPdfBase::syncMorph | ( | Morph & | out, |
const FastTemplate & | nominal, | ||
FastTemplate & | lo, | ||
FastTemplate & | hi | ||
) | const [protected] |
not to be serialized
Definition at line 380 of file VerticalInterpHistPdf.cc.
References _smoothAlgo, FastVerticalInterpHistPdfBase::Morph::diff, FastTemplate::LogRatio(), FastTemplate::Subtract(), FastVerticalInterpHistPdfBase::Morph::sum, and FastTemplate::SumDiff().
Referenced by FastVerticalInterpHistPdf2D::syncComponents(), and FastVerticalInterpHistPdf::syncComponents().
{ if (_smoothAlgo < 0) { hi.LogRatio(nominal); lo.LogRatio(nominal); //printf("Log-ratios for dimension %d: \n", dim); hi.Dump(); lo.Dump(); } else { hi.Subtract(nominal); lo.Subtract(nominal); //printf("Differences for dimension %d: \n", dim); hi.Dump(); lo.Dump(); } FastTemplate::SumDiff(hi, lo, out.sum, out.diff); //printf("Sum and diff for dimension %d: \n", dim); out.sum.Dump(); out.diff.Dump(); }
void FastVerticalInterpHistPdfBase::syncTotal | ( | FastTemplate & | cache, |
const FastTemplate & | cacheNominal, | ||
const FastTemplate & | cacheNominalLog | ||
) | const [protected] |
Definition at line 427 of file VerticalInterpHistPdf.cc.
References _coefList, _init, _morphParams, _morphs, _sentry, _smoothAlgo, a, b, FastTemplate::CopyValues(), FastTemplate::CropUnderflows(), diffTreeTool::diff, FastTemplate::Exp(), i, FastTemplate::Meld(), SimpleCacheSentry::reset(), smoothStepFunc(), TRACEME, and x.
{ TRACEME() /* === how the algorithm works, in theory === * let dhi = h_hi - h_nominal * dlo = h_lo - h_nominal * and x be the morphing parameter * we define alpha = x * 0.5 * ((dhi-dlo) + (dhi+dlo)*smoothStepFunc(x)); * which satisfies: * alpha(0) = 0 * alpha(+1) = dhi * alpha(-1) = dlo * alpha(x >= +1) = |x|*dhi * alpha(x <= -1) = |x|*dlo * alpha is continuous and has continuous first and second derivative, as smoothStepFunc has them * === and in practice === * we already have computed the histogram for diff=(dhi-dlo) and sum=(dhi+dlo) * so we just do template += (0.5 * x) * (diff + smoothStepFunc(x) * sum) * ========================================== */ // start from nominal cache.CopyValues(_smoothAlgo < 0 ? cacheNominalLog : cacheNominal); //printf("Cache initialized to nominal template: \n"); cacheNominal.Dump(); // apply all morphs one by one for (int i = 0, ndim = _coefList.getSize(); i < ndim; ++i) { double x = _morphParams[i]->getVal(); double a = 0.5*x, b = smoothStepFunc(x); cache.Meld(_morphs[i].diff, _morphs[i].sum, a, b); //printf("Merged transformation for dimension %d, x = %+5.3f, step = %.3f: \n", i, x, b); cache.Dump(); } // if necessary go back to linear scale if (_smoothAlgo < 0) { cache.Exp(); //printf("Done exponential tranformation\n"); cache.Dump(); } else { cache.CropUnderflows(); } // mark as done _sentry.reset(); _init = true; }
TIterator* FastVerticalInterpHistPdfBase::_coefIter [protected] |
Iterator over FUNC list.
Definition at line 95 of file VerticalInterpHistPdf.h.
Referenced by FastVerticalInterpHistPdfBase(), FastVerticalInterpHistPdf::setupCaches(), FastVerticalInterpHistPdf2D::setupCaches(), and ~FastVerticalInterpHistPdfBase().
RooListProxy FastVerticalInterpHistPdfBase::_coefList [protected] |
Definition at line 91 of file VerticalInterpHistPdf.h.
Referenced by coefList(), FastVerticalInterpHistPdfBase(), FastVerticalInterpHistPdf::setupCaches(), FastVerticalInterpHistPdf2D::setupCaches(), and syncTotal().
TIterator* FastVerticalInterpHistPdfBase::_funcIter [protected] |
Definition at line 94 of file VerticalInterpHistPdf.h.
Referenced by FastVerticalInterpHistPdfBase(), and ~FastVerticalInterpHistPdfBase().
RooListProxy FastVerticalInterpHistPdfBase::_funcList [protected] |
Definition at line 90 of file VerticalInterpHistPdf.h.
Referenced by FastVerticalInterpHistPdfBase(), funcList(), FastVerticalInterpHistPdf2D::syncComponents(), FastVerticalInterpHistPdf::syncComponents(), FastVerticalInterpHistPdf::syncNominal(), and FastVerticalInterpHistPdf2D::syncNominal().
bool FastVerticalInterpHistPdfBase::_init [mutable, protected] |
Iterator over coefficient list.
Definition at line 98 of file VerticalInterpHistPdf.h.
Referenced by FastVerticalInterpHistPdf2D::evaluate(), FastVerticalInterpHistPdf::evaluate(), FastVerticalInterpHistPdf::isCacheReady(), FastVerticalInterpHistPdf2D::isCacheReady(), and syncTotal().
std::vector<RooAbsReal *> FastVerticalInterpHistPdfBase::_morphParams [mutable, protected] |
not to be serialized
Definition at line 104 of file VerticalInterpHistPdf.h.
Referenced by FastVerticalInterpHistPdf::setupCaches(), FastVerticalInterpHistPdf2D::setupCaches(), and syncTotal().
std::vector<Morph> FastVerticalInterpHistPdfBase::_morphs [mutable, protected] |
not to be serialized
Definition at line 103 of file VerticalInterpHistPdf.h.
Referenced by FastVerticalInterpHistPdf::setupCaches(), FastVerticalInterpHistPdf2D::setupCaches(), FastVerticalInterpHistPdf2D::syncComponents(), FastVerticalInterpHistPdf::syncComponents(), and syncTotal().
SimpleCacheSentry FastVerticalInterpHistPdfBase::_sentry [mutable, protected] |
not to be serialized
Definition at line 99 of file VerticalInterpHistPdf.h.
Referenced by FastVerticalInterpHistPdf2D::evaluate(), FastVerticalInterpHistPdf::evaluate(), FastVerticalInterpHistPdfBase(), FastVerticalInterpHistPdf::setupCaches(), FastVerticalInterpHistPdf2D::setupCaches(), and syncTotal().
Int_t FastVerticalInterpHistPdfBase::_smoothAlgo [protected] |
Definition at line 93 of file VerticalInterpHistPdf.h.
Referenced by syncMorph(), FastVerticalInterpHistPdf::syncNominal(), FastVerticalInterpHistPdf2D::syncNominal(), and syncTotal().
Double_t FastVerticalInterpHistPdfBase::_smoothRegion [protected] |
Definition at line 92 of file VerticalInterpHistPdf.h.
Referenced by smoothStepFunc().
RooRealProxy FastVerticalInterpHistPdfBase::_x [protected] |
Reimplemented in FastVerticalInterpHistPdf, and FastVerticalInterpHistPdf2D.
Definition at line 89 of file VerticalInterpHistPdf.h.