61 throw std::runtime_error(
"You requested the result of a vector observable outside a loop scope for it!");
85 arrDecl +=
"double auxArr[" + std::to_string(
_xlArr.size()) +
"];\n";
86 arrDecl +=
"for (int i = 0; i < " + std::to_string(
_xlArr.size()) +
"; i++) auxArr[i] = xlArr[i];\n";
136 std::string idx =
"loopIdx" + std::to_string(
_loopLevel);
138 std::vector<TNamed const *> vars;
144 vars.push_back(it.first);
145 _nodeNames[it.first] =
"obs[" + std::to_string(it.second) +
" + " + idx +
"]";
151 std::size_t numEntries = 1;
152 for (
auto &it : vars) {
154 if (
n > 1 && numEntries > 1 &&
n != numEntries) {
155 throw std::runtime_error(
"Trying to loop over variables with different sizes!");
157 numEntries = std::max(
n, numEntries);
164 addToCodeBody(in,
"for(int " + idx +
" = 0; " + idx +
" < " + std::to_string(numEntries) +
"; " + idx +
"++) {\n");
167 return std::make_unique<LoopScope>(*
this, std::move(vars));
180 for (
auto const &ptr : scope.
vars()) {
202 bool hasOperations = valueToSave.find_first_of(
":-+/*") != std::string::npos;
209 std::string outVarDecl =
"const double " + savedName +
" = " + valueToSave +
";\n";
212 savedName = valueToSave;
228 bool canSaveOutside =
true;
230 std::stringstream declStrm;
231 declStrm <<
"double " << savedName <<
"[] = {";
232 for (
const auto arg : in) {
236 declStrm.seekp(-1, declStrm.cur);
247 unsigned int n = arr.size();
250 for (
unsigned int i = 0; i <
n; i++) {
253 return "auxArr + " +
offset;
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 Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Common abstract base class for objects that represent a value and a "shape" in RooFit.
bool dependsOn(const RooAbsCollection &serverList, const RooAbsArg *ignoreArg=nullptr, bool valueOnly=false) const
Test whether we depend on (ie, are served by) any object in the specified collection.
const TNamed * namePtr() const
De-duplicated pointer to this object's name.
virtual void translate(RooFit::Detail::CodeSquashContext &ctx) const
This function defines a translation for each RooAbsReal based object that can be used to express the ...
virtual bool isReducerNode() const
Abstract container object that can hold multiple RooAbsArg objects.
RooFit::UniqueId< RooAbsCollection > const & uniqueId() const
Returns a unique ID that is different for every instantiated RooAbsCollection.
A class to manage loop scopes using the RAII technique.
std::vector< TNamed const * > const & vars() const
std::string assembleCode(std::string const &returnExpr)
Assemble and return the final code with the return expression and global statements.
std::string _tempScope
Stores code that eventually gets injected into main code body.
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 endLoop(LoopScope const &scope)
std::unordered_map< const TNamed *, int > _vecObsIndices
A map to keep track of the observable indices if they are non scalar.
int _loopLevel
The current number of for loops the started.
int _tmpVarIdx
Index to get unique names for temporary variables.
std::size_t outputSize(RooFit::Detail::DataKey key) const
Figure out the output size of a node.
std::unordered_map< const TNamed *, std::string > _nodeNames
Map of node names to their result strings.
void addToCodeBody(RooAbsArg const *klass, std::string const &in)
Adds the input string to the squashed code body.
void addVecObs(const char *key, int idx)
Since the squashed code represents all observables as a single flattened array, it is important to ke...
bool isScopeIndependent(RooAbsArg const *in) const
std::string getTmpVarName() const
Get a unique variable name to be used in the generated code.
std::string const & getResult(RooAbsArg const &arg)
Gets the result for the given node using the node name.
std::string _code
Stores the squashed code body.
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.
std::unordered_map< RooFit::UniqueId< RooAbsCollection >::Value_t, std::string > listNames
A map to keep track of list names as assigned by addResult.
std::string buildArg(RooAbsCollection const &x)
Function to save a RooListProxy as an array in the squashed code.
int _scopePtr
Keeps track of the position to go back and insert code to.
std::string _globalScope
Block of code that is placed before the rest of the function body.
std::vector< double > & _xlArr
std::unique_ptr< LoopScope > beginLoop(RooAbsArg const *in)
Create a RAII scope for iterating over vector observables.
static const TNamed * known(const char *stringPtr)
If the name is already known, return its TNamed pointer. Otherwise return 0 (don't register the name)...
The TNamed class is the base class for all named ROOT classes.
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
constexpr Value_t value() const
Return numerical value of ID.