Logo ROOT   master
Reference Guide
BatchHelpers::BatchData Class Reference

A class to store batches of data points that can be accessed via RooSpan.

Definition at line 30 of file BatchData.h.

Classes

struct  Batch
 

Public Types

enum  Status_t {
  kNoBatch, kDirty, kWriting, kReady,
  kReadyAndConstant
}
 Status of the batch. More...
 
enum  Tag_t { kUnspecified, kgetVal, kgetLogVal }
 

Public Member Functions

 BatchData ()
 
void attachForeignStorage (const std::vector< double > &vec)
 Attach a foreign storage. Batches coming from this storage will be read only. More...
 
void clear ()
 Discard all storage. More...
 
RooSpan< const doublegetBatch (std::size_t begin, std::size_t maxSize, const RooArgSet *const normSet=nullptr, Tag_t ownerTag=kUnspecified) const
 Retrieve an existing batch. More...
 
RooSpan< doublemakeWritableBatchInit (std::size_t begin, std::size_t batchSize, double value, const RooArgSet *const normSet=nullptr, Tag_t ownerTag=kUnspecified)
 Make a batch and return a span pointing to the pdf-local memory. More...
 
RooSpan< doublemakeWritableBatchUnInit (std::size_t begin, std::size_t batchSize, const RooArgSet *const normSet=nullptr, Tag_t ownerTag=kUnspecified)
 Make a batch and return a span pointing to the pdf-local memory. More...
 
void markDirty ()
 Mark all batches dirty. This will trigger recomputations. More...
 
void print (std::ostream &os, const std::string &indent) const
 Print to given output stream. More...
 
bool setStatus (std::size_t begin, std::size_t size, Status_t stat, const RooArgSet *const normSet=nullptr, Tag_t ownerTag=kUnspecified)
 Set the status of a batch with the given properties. More...
 
Status_t status (std::size_t begin, const RooArgSet *const normSet=nullptr, Tag_t ownerTag=kUnspecified) const
 Return the status of the batch starting at begin. More...
 

Private Types

using Key_t = std::tuple< std::size_t, const RooArgSet *const, Tag_t >
 Key type of map that holds the batch storage. More...
 
using Map_t = std::map< Key_t, Batch >
 Storage for batch data. More...
 

Private Member Functions

RooSpan< const doublecreateSpanInsideExistingBatch (std::size_t begin, std::size_t batchSize, const RooArgSet *const normSet, Tag_t ownerTag) const
 Create a span pointing to existing batch memory. More...
 
Map_t::const_iterator findEnclosingBatch (std::size_t evt, const RooArgSet *const normSet, Tag_t ownerTag) const
 Find the batch that contains the event with number evt. More...
 

Private Attributes

const std::vector< double > * _foreignData
 
Map_t _ownedBatches
 

#include <BatchData.h>

Member Typedef Documentation

◆ Key_t

using BatchHelpers::BatchData::Key_t = std::tuple<std::size_t, const RooArgSet* const, Tag_t>
private

Key type of map that holds the batch storage.

Definition at line 96 of file BatchData.h.

◆ Map_t

using BatchHelpers::BatchData::Map_t = std::map<Key_t, Batch>
private

Storage for batch data.

Definition at line 101 of file BatchData.h.

Member Enumeration Documentation

◆ Status_t

Status of the batch.

Make sure that everything that is readable has a status >= kReady.

Enumerator
kNoBatch 
kDirty 
kWriting 
kReady 
kReadyAndConstant 

Definition at line 34 of file BatchData.h.

◆ Tag_t

Enumerator
kUnspecified 
kgetVal 
kgetLogVal 

Definition at line 35 of file BatchData.h.

Constructor & Destructor Documentation

◆ BatchData()

BatchHelpers::BatchData::BatchData ( )
inline

Definition at line 37 of file BatchData.h.

Member Function Documentation

◆ attachForeignStorage()

void BatchHelpers::BatchData::attachForeignStorage ( const std::vector< double > &  vec)

Attach a foreign storage. Batches coming from this storage will be read only.

Definition at line 160 of file BatchData.cxx.

◆ clear()

void BatchHelpers::BatchData::clear ( )
inline

Discard all storage.

Definition at line 45 of file BatchData.h.

◆ createSpanInsideExistingBatch()

RooSpan< const double > BatchHelpers::BatchData::createSpanInsideExistingBatch ( std::size_t  begin,
std::size_t  batchSize,
const RooArgSet *const  normSet,
Tag_t  ownerTag 
) const
private

Create a span pointing to existing batch memory.

Parameters
[in]beginIndex of the event to find.
[in]batchSizeRequested size of the span. May come out smaller if no more data exists.
[in]normSetOptional normalisation set defining what this batch was normalised to.
[in]ownerTagOptional owner tag to prevent sharing of memory between e.g. getVal() and getLogVal().
Returns
RooSpan pointing inside an existing batch or an empty span if no such batch.

Definition at line 223 of file BatchData.cxx.

◆ findEnclosingBatch()

BatchData::Map_t::const_iterator BatchHelpers::BatchData::findEnclosingBatch ( std::size_t  evt,
const RooArgSet *const  normSet,
Tag_t  ownerTag 
) const
private

Find the batch that contains the event with number evt.

Parameters
[in]evtIndex of the event to find.
[in]normSetOptional normalisation set defining what this batch was normalised to.
[in]ownerTagOptional owner tag to prevent sharing of memory between e.g. getVal() and getLogVal().

Definition at line 204 of file BatchData.cxx.

◆ getBatch()

RooSpan< const double > BatchHelpers::BatchData::getBatch ( std::size_t  begin,
std::size_t  maxSize,
const RooArgSet *const  normSet = nullptr,
Tag_t  ownerTag = kUnspecified 
) const

Retrieve an existing batch.

Parameters
[in]beginBegin index of the batch.
[in]sizeRequested size. Batch may come out smaller than this.
[in]normSetOptional normSet pointer to distinguish differently normalised computations.
[in]ownerTagOptional owner tag. This avoids reusing batch memory for e.g. getVal() and getLogVal().
Returns
Non-mutable contiguous batch data.

Definition at line 80 of file BatchData.cxx.

◆ makeWritableBatchInit()

RooSpan< double > BatchHelpers::BatchData::makeWritableBatchInit ( std::size_t  begin,
std::size_t  batchSize,
double  value,
const RooArgSet *const  normSet = nullptr,
Tag_t  ownerTag = kUnspecified 
)

Make a batch and return a span pointing to the pdf-local memory.

Calls makeWritableBatchUnInit() and initialises the memory.

Parameters
[in]beginBegin of the batch.
[in]batchSizeEnd of the batch (not included)
[in]valueValue to initialise with (defaults to 0.).
[in]normSetOptional normSet pointer to distinguish differently normalised computations.
[in]ownerTagOptional owner tag. This avoids reusing batch memory for e.g. getVal() and getLogVal().
Returns
An initialised RooSpan starting at event begin.

Definition at line 148 of file BatchData.cxx.

◆ makeWritableBatchUnInit()

RooSpan< double > BatchHelpers::BatchData::makeWritableBatchUnInit ( std::size_t  begin,
std::size_t  batchSize,
const RooArgSet *const  normSet = nullptr,
Tag_t  ownerTag = kUnspecified 
)

Make a batch and return a span pointing to the pdf-local memory.

The batch status is switched to kWriting, but the batch is not initialised. If a batch at this start point exists, the storage will be resized to fit the required size.

Parameters
[in]beginBegin of the batch.
[in]batchSizeSize of the batch.
[in]normSetOptional normSet pointer to distinguish differently normalised computations.
[in]ownerTagOptional owner tag. This avoids reusing batch memory for e.g. getVal() and getLogVal().
Returns
An uninitialised RooSpan starting at event begin.

Definition at line 118 of file BatchData.cxx.

◆ markDirty()

void BatchHelpers::BatchData::markDirty ( )
inline

Mark all batches dirty. This will trigger recomputations.

Definition at line 55 of file BatchData.h.

◆ print()

void BatchHelpers::BatchData::print ( std::ostream &  os,
const std::string &  indent 
) const

Print to given output stream.

Definition at line 170 of file BatchData.cxx.

◆ setStatus()

bool BatchHelpers::BatchData::setStatus ( std::size_t  begin,
std::size_t  size,
Status_t  stat,
const RooArgSet *const  normSet = nullptr,
Tag_t  ownerTag = kUnspecified 
)

Set the status of a batch with the given properties.

The status of foreign read-only data will never change.

Parameters
[in]beginBegin index of the batch.
[in]sizeSize of the batch for checking that enough data is available.
[in]normSetOptional normSet pointer to destinguish differently normalised computations.
[in]ownerTagOptional owner tag. This avoids reusing batch memory for e.g. getVal() and getLogVal().
Returns
True if status successfully set, false if no such batch / not writable.

Definition at line 58 of file BatchData.cxx.

◆ status()

BatchData::Status_t BatchHelpers::BatchData::status ( std::size_t  begin,
const RooArgSet *const  normSet = nullptr,
Tag_t  ownerTag = kUnspecified 
) const

Return the status of the batch starting at begin.

Parameters
[in]beginStart of the batch.
[in]normSetOptional normSet pointer to distinguish differently normalised computations.
[in]ownerTagOptional owner tag. This avoids reusing batch memory for e.g. getVal() and getLogVal().
Returns
One state of the Status_t enum.

Definition at line 30 of file BatchData.cxx.

Member Data Documentation

◆ _foreignData

const std::vector<double>* BatchHelpers::BatchData::_foreignData
private

Definition at line 111 of file BatchData.h.

◆ _ownedBatches

Map_t BatchHelpers::BatchData::_ownedBatches
private

Definition at line 110 of file BatchData.h.

Libraries for BatchHelpers::BatchData:
[legend]

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