Logo ROOT  
Reference Guide
BatchHelpers::RunContext Struct Reference

Data that has to be passed around when evaluating functions / PDFs.

Definition at line 32 of file RunContext.h.

Public Member Functions

 RunContext ()
 
 RunContext (const RunContext &)=delete
 Deleted because copying the owned memory is expensive. More...
 
 RunContext (RunContext &&)=default
 
void clear ()
 Clear all computation results without freeing memory. More...
 
RooSpan< const doublegetBatch (const RooAbsReal *owner) const
 Check if there is a span of data corresponding to the object passed as owner. More...
 
RooSpan< const doublegetBatch (const RooArgProxy &proxy) const
 Check if there is a span of data corresponding to the variable in this proxy. More...
 
RooSpan< doublegetWritableBatch (const RooAbsReal *owner)
 Check if there is a writable span of data corresponding to the object passed as owner. More...
 
RooSpan< doublemakeBatch (const RooAbsReal *owner, std::size_t size)
 Create a writable batch. More...
 
RooSpan< const doubleoperator[] (const RooAbsReal *owner) const
 Retrieve a batch of data corresponding to the element passed as owner. More...
 

Public Attributes

std::vector< doublelogProbabilities
 If evaluation should only occur in a range, the range name can be passed here. More...
 
std::unordered_map< const RooAbsReal *, std::vector< double > > ownedMemory
 Memory owned by this struct. It is associated to nodes in the computation graph using their pointers. More...
 
const char * rangeName {nullptr}
 
std::unordered_map< const RooAbsReal *, RooSpan< const double > > spans
 Once an object has computed its value(s), the span pointing to the results is registered here. More...
 

#include <RunContext.h>

Constructor & Destructor Documentation

◆ RunContext() [1/3]

BatchHelpers::RunContext::RunContext ( )
inline

Definition at line 33 of file RunContext.h.

◆ RunContext() [2/3]

BatchHelpers::RunContext::RunContext ( const RunContext )
delete

Deleted because copying the owned memory is expensive.

If needed, it can be implemented, though.

Warning
Remember to relocate all spans in spans to new location in ownedMemory after data have been copied!

◆ RunContext() [3/3]

BatchHelpers::RunContext::RunContext ( RunContext &&  )
default

Member Function Documentation

◆ clear()

void BatchHelpers::RunContext::clear ( )
inline

Clear all computation results without freeing memory.

Definition at line 48 of file RunContext.h.

◆ getBatch() [1/2]

RooSpan< const double > BatchHelpers::RunContext::getBatch ( const RooAbsReal owner) const

Check if there is a span of data corresponding to the object passed as owner.

Definition at line 31 of file RunContext.cxx.

◆ getBatch() [2/2]

RooSpan< const double > BatchHelpers::RunContext::getBatch ( const RooArgProxy proxy) const

Check if there is a span of data corresponding to the variable in this proxy.

Definition at line 25 of file RunContext.cxx.

◆ getWritableBatch()

RooSpan< double > BatchHelpers::RunContext::getWritableBatch ( const RooAbsReal owner)

Check if there is a writable span of data corresponding to the object passed as owner.

The span can be used both for reading and writing.

Definition at line 42 of file RunContext.cxx.

◆ makeBatch()

RooSpan< double > BatchHelpers::RunContext::makeBatch ( const RooAbsReal owner,
std::size_t  size 
)

Create a writable batch.

If the RunContext already owns memory for the object owner, just resize the memory. If it doesn't exist yet, allocate it.

Warning
The memory will be uninitialised, so every entry must be overwritten. On first use, all values are initialised to NaN to help detect such errors.

A read-only reference to the memory will be stored in spans.

Parameters
ownerRooFit object whose value should be written into the memory.
sizeRequested size of the span.
Returns
A writeable RooSpan of the requested size, whose memory is owned by the RunContext.

Definition at line 63 of file RunContext.cxx.

◆ operator[]()

RooSpan<const double> BatchHelpers::RunContext::operator[] ( const RooAbsReal owner) const
inline

Retrieve a batch of data corresponding to the element passed as owner.

Definition at line 43 of file RunContext.h.

Member Data Documentation

◆ logProbabilities

std::vector<double> BatchHelpers::RunContext::logProbabilities

If evaluation should only occur in a range, the range name can be passed here.

Definition at line 55 of file RunContext.h.

◆ ownedMemory

std::unordered_map<const RooAbsReal*, std::vector<double> > BatchHelpers::RunContext::ownedMemory

Memory owned by this struct. It is associated to nodes in the computation graph using their pointers.

Definition at line 53 of file RunContext.h.

◆ rangeName

const char* BatchHelpers::RunContext::rangeName {nullptr}

Definition at line 54 of file RunContext.h.

◆ spans

std::unordered_map<const RooAbsReal*, RooSpan<const double> > BatchHelpers::RunContext::spans

Once an object has computed its value(s), the span pointing to the results is registered here.

Definition at line 51 of file RunContext.h.

Collaboration diagram for BatchHelpers::RunContext:
[legend]

The documentation for this struct was generated from the following files: