100 _model(
"!model",
"Original resolution model",this,(
RooResolutionModel&)model,false,false),
101 _convVar(
"!convVar",
"Convolution variable",this,cVar,false,false),
102 _convSet(
"!convSet",
"Set of resModel X basisFunc convolutions",this),
103 _coefNormMgr(this,10),
115 _model(
"!model",this,other._model),
116 _convVar(
"!convVar",this,other._convVar),
117 _convSet(
"!convSet",this,other._convSet),
118 _coefNormMgr(other._coefNormMgr,this),
119 _codeReg(other._codeReg)
138 for (
auto arg : tmp) {
163 coutE(InputArguments) <<
"RooAbsAnaConvPdf::declareBasis(" <<
GetName() <<
"): ERROR attempt to "
164 <<
" declare basis functions in a copied RooAbsAnaConvPdf" << endl ;
170 coutE(InputArguments) <<
"RooAbsAnaConvPdf::declareBasis(" <<
GetName() <<
"): resolution model "
172 <<
" doesn't support basis function " << expression << endl ;
178 basisArgs.
add(params) ;
180 TString basisName(expression) ;
181 for (
const auto arg : basisArgs) {
183 basisName.
Append(arg->GetName()) ;
186 auto basisFunc = std::make_unique<RooFormulaVar>(basisName, expression, basisArgs);
187 basisFunc->setAttribute(
"RooWorkspace::Recycle") ;
188 basisFunc->setAttribute(
"NOCacheAndTrack") ;
189 basisFunc->setOperMode(
operMode()) ;
195 coutE(InputArguments) <<
"RooAbsAnaConvPdf::declareBasis(" <<
GetName() <<
"): unable to construct convolution with basis function '"
196 << expression <<
"'" << endl ;
218 if (!newConvSet.
addOwned(std::move(newConv))) {
233 const std::string attrib = std::string(
"ORIGNAME:") +
_model->
GetName();
234 const bool oldAttrib = newModel.
getAttribute(attrib.c_str());
256 const RooArgSet* auxProto,
bool verbose)
const
263 modelDep->remove(*
convVar(),
true,
true) ;
264 Int_t numAddDep = modelDep->getSize() ;
271 if (numAddDep>0 || !pdfCanDir || !resCanDir) {
275 if (numAddDep>0) reason +=
"Resolution model has more observables than the convolution variable. " ;
276 if (!pdfCanDir) reason +=
"PDF does not support internal generation of convolution observable. " ;
277 if (!resCanDir) reason +=
"Resolution model does not support internal generation of convolution observable. " ;
279 coutI(Generation) <<
"RooAbsAnaConvPdf::genContext(" <<
GetName() <<
") Using regular accept/reject generator for convolution p.d.f because: " << reason.c_str() << endl ;
280 return new RooGenContext(*
this,vars,prototype,auxProto,verbose) ;
284 if (context)
return context;
317 if (!conv)
return nullptr;
335 auto conv =
static_cast<RooAbsPdf*
>(convArg);
338 const double c = conv->getVal(
nullptr);
339 cxcoutD(Eval) <<
"RooAbsAnaConvPdf::evaluate(" <<
GetName() <<
") val += coef*conv [" <<
index-1 <<
"/"
340 <<
_convSet.
size() <<
"] coef = " << coef <<
" conv = " <<
c << endl ;
369 if (allVars.
empty())
return 0 ;
376 std::unique_ptr<RooArgSet> normSet{normSet2 ?
getObservables(normSet2) :
nullptr};
378 RooArgSet intSetAll{allDeps,
"intSetAll"};
381 auto intCoefSet = std::make_unique<RooArgSet>(
"intCoefSet");
382 auto intConvSet = std::make_unique<RooArgSet>(
"intConvSet");
387 if (conv->dependsOn(*arg)) ok=
false ;
391 intCoefSet->add(*arg) ;
393 intConvSet->add(*arg) ;
399 auto normCoefSet = std::make_unique<RooArgSet>(
"normCoefSet");
400 auto normConvSet = std::make_unique<RooArgSet>(
"normConvSet");
405 if (conv->dependsOn(*arg)) ok=
false ;
409 normCoefSet->add(*arg) ;
411 normConvSet->add(*arg) ;
417 if (intCoefSet->empty()) intCoefSet.reset();
418 if (intConvSet->empty()) intConvSet.reset();
419 if (normCoefSet->empty()) normCoefSet.reset();
420 if (normConvSet->empty()) normConvSet.reset();
424 Int_t masterCode(0) ;
425 std::vector<Int_t> tmp(1, 0) ;
429 intCoefSet.release(),
430 intConvSet.release(),
431 normCoefSet.release(),
432 normConvSet.release()) + 1;
434 analVars.
add(allDeps) ;
475 if (code==0)
return getVal(normSet) ;
478 RooArgSet *intCoefSet, *intConvSet, *normCoefSet, *normConvSet ;
484 if (normCoefSet==0&&normConvSet==0) {
490 auto conv =
static_cast<RooAbsPdf*
>(convArg);
494 integral += coef* conv->getNormObj(0,intConvSet,_rangeName)->getVal();
495 cxcoutD(Eval) <<
"RooAbsAnaConv::aiWN(" <<
GetName() <<
") [" <<
index-1 <<
"] integral += " << conv->getNorm(intConvSet) << endl ;
508 auto conv =
static_cast<RooAbsPdf*
>(convArg);
513 double term = conv->getNormObj(0,intConvSet,_rangeName)->getVal();
514 integral += coefInt*term ;
520 double term = conv->getNormObj(0,normConvSet)->getVal();
521 norm += coefNorm*term ;
526 answer = integral/norm ;
555 coutE(InputArguments) <<
"RooAbsAnaConvPdf::coefAnalyticalIntegral(" <<
GetName() <<
") ERROR: unrecognized integration code: " << code << endl ;
616 varList.
addOwned(std::make_unique<RooConvCoefVar>(
Form(
"%s_coefVar_%d",
GetName(),i),
"coefVar",*
this,i,&*cvars));
628 std::vector<RooAbsArg*> tmp;
629 for (
auto arg : *cVars) {
631 if (convSetArg->dependsOn(*arg)) {
637 cVars->remove(tmp.begin(), tmp.end(),
true,
true);
655 os <<
indent <<
"--- RooAbsAnaConvPdf ---" << endl;
657 conv->printMultiline(os,contents,verbose,
indent) ;
666 for (
auto const* carg : static_range_cast<RooAbsArg*>(
_convSet)) {
667 if (carg->canNodeBeCached()==
Always) {
668 trackNodes.
add(*carg) ;
674std::unique_ptr<RooAbsArg>
680 if (normSet.
empty()) {
681 return _convSet[0].compileForNormSet(normSet, ctx);
686 auto newArg = std::make_unique<RooNormalizedPdf>(*pdfClone, normSet);
690 for (
RooAbsArg *server : newArg->servers()) {
691 server->setAttribute(
"_COMPILED");
693 newArg->setAttribute(
"_COMPILED");
694 newArg->addOwnedComponents(std::move(pdfClone));
702 if (normSet.
empty()) {
710 pdfClone->removeServer(
const_cast<RooAbsReal &
>(pdfClone->_model.arg()),
true);
716 if (
auto convArgClone = ctx.
compile(*convArg, *pdfClone, {})) {
717 convArgClones.
add(*convArgClone);
720 pdfClone->redirectServers(convArgClones,
false,
true);
726 auto newArg = std::make_unique<RooNormalizedPdf>(*pdfClone, normSet);
730 for (
RooAbsArg *server : newArg->servers()) {
731 server->setAttribute(
"_COMPILED");
733 newArg->setAttribute(
"_COMPILED");
734 newArg->addOwnedComponents(std::move(pdfClone));
static void indent(ostringstream &buf, int indent_level)
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
const std::vector< Int_t > & retrieve(Int_t masterCode) const
Retrieve the array of integer codes associated with the given master code.
Int_t store(const std::vector< Int_t > &codeList, RooArgSet *set1=nullptr, RooArgSet *set2=nullptr, RooArgSet *set3=nullptr, RooArgSet *set4=nullptr)
Store given arrays of integer codes, and up to four RooArgSets in the registry (each setX pointer may...
RooAbsAnaConvPdf is the base class for PDFs that represent a physics model that can be analytically c...
friend class RooConvGenContext
Int_t getAnalyticalIntegralWN(RooArgSet &allVars, RooArgSet &analVars, const RooArgSet *normSet, const char *rangeName=nullptr) const override
Advertise capability to perform (analytical) integrals internally.
double analyticalIntegralWN(Int_t code, const RooArgSet *normSet, const char *rangeName=nullptr) const override
Return analytical integral defined by given code, which is returned by getAnalyticalIntegralWN()
virtual double coefAnalyticalIntegral(Int_t coef, Int_t code, const char *rangeName=nullptr) const
Default implementation of function implementing advertised integrals.
virtual bool changeModel(const RooResolutionModel &newModel)
Change the current resolution model to newModel.
double getCoefNorm(Int_t coefIdx, const RooArgSet &nset, const char *rangeName) const
void setCacheAndTrackHints(RooArgSet &) override
Label OK'ed components with cache-and-track.
bool forceAnalyticalInt(const RooAbsArg &dep) const override
This function forces RooRealIntegral to offer all integration dependents to RooAbsAnaConvPdf::getAnal...
RooAbsGenContext * genContext(const RooArgSet &vars, const RooDataSet *prototype=nullptr, const RooArgSet *auxProto=nullptr, bool verbose=false) const override
Create a generator context for this p.d.f.
virtual double coefficient(Int_t basisIndex) const =0
RooArgList _basisList
! List of created basis functions
RooObjCacheManager _coefNormMgr
! Coefficient normalization manager
void makeCoefVarList(RooArgList &) const
Build complete list of coefficient variables.
RooAICRegistry _codeReg
! Registry of analytical integration codes
virtual Int_t getCoefAnalyticalIntegral(Int_t coef, RooArgSet &allVars, RooArgSet &analVars, const char *rangeName=nullptr) const
Default implementation of function advertising integration capabilities.
~RooAbsAnaConvPdf() override
Destructor.
bool isDirectGenSafe(const RooAbsArg &arg) const override
Return true if it is safe to generate the convolution observable from the internal generator (this is...
RooAbsRealLValue * convVar()
Retrieve the convolution variable.
double evaluate() const override
Calculate the current unnormalized value of the PDF.
RooRealProxy _model
Original model.
void printMultiline(std::ostream &stream, Int_t contents, bool verbose=false, TString indent="") const override
Print info about this object to the specified stream.
RooRealProxy _convVar
Convolution variable.
RooAbsAnaConvPdf()
Default constructor, required for persistence.
Int_t declareBasis(const char *expression, const RooArgList ¶ms)
Declare a basis function for use in this physics model.
RooListProxy _convSet
Set of (resModel (x) basisFunc) convolution objects.
virtual RooFit::OwningPtr< RooArgSet > coefVars(Int_t coefIdx) const
Return set of parameters with are used exclusively by the coefficient functions.
std::unique_ptr< RooAbsArg > compileForNormSet(RooArgSet const &normSet, RooFit::Detail::CompileContext &ctx) const override
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
RooFit::OwningPtr< RooArgSet > getParameters(const RooAbsData *data, bool stripDisconnected=true) const
Create a list of leaf nodes in the arg tree starting with ourself as top node that don't match any of...
RooFit::OwningPtr< RooArgSet > getObservables(const RooArgSet &set, bool valueOnly=true) const
Given a set of possible observables, return the observables that this PDF depends on.
bool redirectServers(const RooAbsCollection &newServerList, bool mustReplaceAll=false, bool nameChange=false, bool isRecursionStep=false)
Replace all direct servers of this object with the new servers in newServerList.
bool getAttribute(const Text_t *name) const
Check if a named attribute is set. By default, all attributes are unset.
void setAttribute(const Text_t *name, bool value=true)
Set (default) or clear a named boolean attribute of this object.
TObject * Clone(const char *newname=nullptr) const override
Make a clone of an object using the Streamer facility.
OperMode operMode() const
Query the operation mode of this node.
RooAbsCollection * snapshot(bool deepCopy=true) const
Take a snap shot of current collection contents.
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.
Int_t index(const RooAbsArg *arg) const
Returns index of given arg, or -1 if arg is not in the collection.
const_iterator end() const
Storage_t::size_type size() const
virtual bool addOwned(RooAbsArg &var, bool silent=false)
Add an argument and transfer the ownership to the collection.
const_iterator begin() const
RooAbsGenContext is the abstract base class for generator contexts of RooAbsPdf objects.
std::unique_ptr< RooAbsArg > compileForNormSet(RooArgSet const &normSet, RooFit::Detail::CompileContext &ctx) const override
virtual bool isDirectGenSafe(const RooAbsArg &arg) const
Check if given observable can be safely generated using the pdfs internal generator mechanism (if tha...
void printMultiline(std::ostream &os, Int_t contents, bool verbose=false, TString indent="") const override
Print multi line detailed information of this RooAbsPdf.
virtual Int_t getGenerator(const RooArgSet &directVars, RooArgSet &generateVars, bool staticInitOK=true) const
Load generatedVars with the subset of directVars that we can generate events for, and return a code t...
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
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.
RooFit::OwningPtr< RooAbsReal > createIntegral(const RooArgSet &iset, const RooCmdArg &arg1, const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none(), const RooCmdArg &arg6=RooCmdArg::none(), const RooCmdArg &arg7=RooCmdArg::none(), const RooCmdArg &arg8=RooCmdArg::none()) const
Create an object that represents the integral of the function over one or more observables std::liste...
bool _forceNumInt
Force numerical integration if flag set.
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.
RooAbsArg * absArg() const
Return pointer to contained argument.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Int_t setObj(const RooArgSet *nset, T *obj, const TNamed *isetRangeName=nullptr)
Setter function without integration set.
T * getObj(const RooArgSet *nset, Int_t *sterileIndex=nullptr, const TNamed *isetRangeName=nullptr)
Getter function without integration set.
void removeAll() override
Remove all argument inset using remove(const RooAbsArg&).
bool addOwned(RooAbsArg &var, bool silent=false) override
Overloaded RooCollection_t::addOwned() method insert object into owning set and registers object as s...
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...
bool remove(const RooAbsArg &var, bool silent=false, bool matchByNameOnly=false) override
Remove object 'var' from set and deregister 'var' as server to owner.
RooDataSet is a container class to hold unbinned data.
void compileServers(RooAbsArg &arg, RooArgSet const &normSet)
T * compile(T &arg, RooAbsArg &owner, RooArgSet const &normSet)
Class RooGenContext implement a universal generator context for all RooAbsPdf classes that do not hav...
static const char * str(const TNamed *ptr)
Return C++ string corresponding to given TNamed pointer.
static const TNamed * ptr(const char *stringPtr)
Return a unique TNamed pointer for given C++ string.
RooRealVar represents a variable that can be changed from the outside.
RooResolutionModel is the base class for PDFs that represent a resolution model that can be convolute...
virtual RooResolutionModel * convolution(RooFormulaVar *basis, RooAbsArg *owner) const
Instantiate a clone of this resolution model representing a convolution with given basis function.
virtual RooAbsGenContext * modelGenContext(const RooAbsAnaConvPdf &, const RooArgSet &, const RooDataSet *, const RooArgSet *, bool) const
RooAbsRealLValue & convVar() const
Return the convolution variable of the resolution model.
const T & arg() const
Return reference to object held in proxy.
RooTruthModel is an implementation of RooResolution model that provides a delta-function resolution m...
The TNamed class is the base class for all named ROOT classes.
const char * GetName() const override
Returns name of object.
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
TString & Append(const char *cs)
T * OwningPtr
An alias for raw pointers for indicating that the return type of a RooFit function is an owning point...