56#ifndef ROOFIT_MEMORY_SAFE_INTERFACES
61 , _set(
"!set",
"set of components",this)
66 coutE(InputArguments) <<
"RooAddition::ctor(" <<
GetName() <<
") ERROR: component " << comp->
GetName()
67 <<
" is not of type RooAbsReal" << std::endl;
71#ifndef ROOFIT_MEMORY_SAFE_INTERFACES
95#ifndef ROOFIT_MEMORY_SAFE_INTERFACES
100 , _set(
"!set",
"set of components",this)
103 if (sumSet1.
getSize() != sumSet2.getSize()) {
104 coutE(InputArguments) <<
"RooAddition::ctor(" <<
GetName() <<
") ERROR: input lists should be of equal length" << std::endl;
108 for (
unsigned int i = 0; i < sumSet1.
size(); ++i) {
109 const auto comp1 = &sumSet1[i];
110 const auto comp2 = &sumSet2[i];
113 coutE(InputArguments) <<
"RooAddition::ctor(" <<
GetName() <<
") ERROR: component " << comp1->
GetName()
114 <<
" in first list is not of type RooAbsReal" << std::endl;
119 coutE(InputArguments) <<
"RooAddition::ctor(" <<
GetName() <<
") ERROR: component " << comp2->GetName()
120 <<
" in first list is not of type RooAbsReal" << std::endl;
125 _name.
Append(comp1->GetName());
127 _name.
Append(comp2->GetName());
129 auto prod = std::make_unique<RooProduct>( _name, _name ,
RooArgSet(*comp1, *comp2));
132#ifndef ROOFIT_MEMORY_SAFE_INTERFACES
148 , _set(
"!set",this,other._set)
149 , _cacheMgr(other._cacheMgr,this)
162 for (
auto* comp : static_range_cast<RooAbsReal*>(
_set)) {
163 const double tmp = comp->getVal(nset);
178 for (
const auto arg :
_set)
180 pdfs.push_back(dataMap.
at(arg));
181 coefs.push_back(1.0);
195 std::string className =
GetName();
196 std::string varName =
"elements" + className;
197 std::string sumName =
"sum" + className;
198 std::string code =
"";
199 std::string decl =
"double " + varName +
"[" + std::to_string(eleSize) +
"]{";
203 ctx.
addResult(it, varName +
"[" + std::to_string(idx) +
"]");
207 code += decl +
";\n";
210 std::string iterator =
"i_" + className;
211 code +=
"for(int " + iterator +
" = 0; " + iterator +
" < " + std::to_string(eleSize) +
"; " + iterator +
212 "++) {\n" + sumName +
" += " + varName +
"[" + iterator +
"];\n}\n";
251 if (nllArg && !chi2Arg) {
252 coutI(Fitting) <<
"RooAddition::defaultErrorLevel(" <<
GetName()
253 <<
") Summation contains a RooNLLVar, using its error level" << std::endl;
255 }
else if (chi2Arg && !nllArg) {
256 coutI(Fitting) <<
"RooAddition::defaultErrorLevel(" <<
GetName()
257 <<
") Summation contains a RooChi2Var, using its error level" << std::endl;
259 }
else if (!nllArg && !chi2Arg) {
260 coutI(Fitting) <<
"RooAddition::defaultErrorLevel(" <<
GetName() <<
") WARNING: "
261 <<
"Summation contains neither RooNLLVar nor RooChi2Var server, using default level of 1.0" << std::endl;
263 coutI(Fitting) <<
"RooAddition::defaultErrorLevel(" <<
GetName() <<
") WARNING: "
264 <<
"Summation contains BOTH RooNLLVar and RooChi2Var server, using default level of 1.0" << std::endl;
276 for (
const auto arg :
_set) {
298 analVars.
add(allVars);
301 Int_t sterileIndex(-1);
303 if (cache!=
nullptr) {
310 for (
auto *arg : static_range_cast<RooAbsReal const*>(
_set)) {
311 cache->
_I.
addOwned(std::unique_ptr<RooAbsReal>{arg->createIntegral(analVars,rangeName)});
325 if (cache==
nullptr) {
334 assert(cache!=
nullptr);
338 for (
auto I : cache->
_I) {
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
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
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 > getComponents() const
Create a RooArgSet with all components (branch nodes) of the expression tree headed by this object.
RooAbsCacheElement is the abstract base class for objects to be stored in RooAbsCache cache manager o...
Int_t getSize() const
Return the number of elements in the collection.
const char * GetName() const override
Returns name of object.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
Storage_t::size_type size() const
virtual bool addOwned(RooAbsArg &var, bool silent=false)
Add an argument and transfer the ownership to the collection.
RooAbsData is the common abstract base class for binned and unbinned datasets.
const RooArgSet * nset() const
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.
virtual double defaultErrorLevel() const
RooAddition calculates the sum of a set of RooAbsReal terms, or when constructed with two sets,...
RooArgList _ownedList
List of owned components.
Int_t getAnalyticalIntegral(RooArgSet &allVars, RooArgSet &numVars, const char *rangeName=nullptr) const override
Interface function getAnalyticalIntergral advertises the analytical integrals that are supported.
void computeBatch(double *output, size_t nEvents, RooFit::Detail::DataMap const &) const override
Compute addition of PDFs in batches.
std::list< double > * binBoundaries(RooAbsRealLValue &, double, double) const override
Retrieve bin boundaries if this distribution is binned in obs.
RooListProxy _set
set of terms to be summed
void printMetaArgs(std::ostream &os) const override
bool setData(RooAbsData &data, bool cloneData=true) override
double analyticalIntegral(Int_t code, const char *rangeName=nullptr) const override
Calculate integral internally from appropriate integral cache.
RooObjCacheManager _cacheMgr
! The cache manager
double defaultErrorLevel() const override
Return the default error level for MINUIT error analysis If the addition contains one or more RooNLLV...
double evaluate() const override
Calculate and return current value of self.
std::list< double > * plotSamplingHint(RooAbsRealLValue &, double, double) const override
Interface for returning an optional hint for initial sampling points when constructing a curve projec...
bool isBinnedDistribution(const RooArgSet &obs) const override
Tests if the distribution is binned. Unless overridden by derived classes, this always returns false.
void translate(RooFit::Detail::CodeSquashContext &ctx) const override
This function defines a translation for each RooAbsReal based object that can be used to express the ...
RooArgList is a container object that can hold multiple RooAbsArg objects.
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 * getObjByIndex(Int_t index) const
Retrieve payload object by slot index.
RooArgSet selectFromSet2(RooArgSet const &argSet, int index) const
Create RooArgSet containing the objects that are both in the cached set 2.
Int_t lastIndex() const
Return index of slot used in last get or set operation.
T * getObj(const RooArgSet *nset, Int_t *sterileIndex=nullptr, const TNamed *isetRangeName=nullptr)
Getter function without integration set.
RooChi2Var implements a simple calculation from a binned dataset and a PDF.
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...
static void softAbort()
Soft abort function that interrupts macro execution but doesn't kill ROOT.
A class to maintain the context for squashing of RooFit models into code.
void addResult(RooAbsArg const *key, std::string const &value)
A function to save an expression that includes/depends on the result of the input node.
void addToCodeBody(RooAbsArg const *klass, std::string const &in)
Adds the input string to the squashed code body.
std::string const & getResult(RooAbsArg const &arg)
Gets the result for the given node using the node name.
void addToGlobalScope(std::string const &str)
Adds the given string to the string block that will be emitted at the top of the squashed function.
RooBatchCompute::Config config(RooAbsArg const *arg) const
std::span< const double > at(RooAbsArg const *arg, RooAbsArg const *caller=nullptr)
This is a simple class designed to produce the nll values needed by the fitter.
Class RooNLLVar implements a -log(likelihood) calculation from a dataset and a PDF.
static const TNamed * ptr(const char *stringPtr)
Return a unique TNamed pointer for given C++ string.
std::list< double > * plotSamplingHint(RooAbsRealLValue &, double, double) const override
Interface for returning an optional hint for initial sampling points when constructing a curve projec...
std::list< double > * binBoundaries(RooAbsRealLValue &, double, double) const override
Retrieve bin boundaries if this distribution is binned in obs.
void printMetaArgs(std::ostream &os) const override
Customized printing of arguments of a RooRealSumPdf to more intuitively reflect the contents of the p...
bool isBinnedDistribution(const RooArgSet &obs) const override
Check if all components that depend on obs are binned.
const char * GetName() const override
Returns name of object.
TString & Append(const char *cs)
std::vector< std::span< const double > > VarVector
std::vector< double > ArgVector
void compute(Config cfg, Computer comp, RestrictArr output, size_t size, const VarVector &vars, ArgVector &extraArgs)
static uint64_t sum(uint64_t i)