Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooNaNPacker Struct Reference

Little struct that can pack a float into the unused bits of the mantissa of a NaN double.

This can be used to transport information about violation of function definition ranges, negative PDFs or other computation problems in RooFit. To separate NaNs that contain packed floats from regular NaNs, a tag is written into the upper bits of the mantissa. If this tag is found, a payload can be recovered. Otherwise, the NaN is assumed to originate from other sources than a RooFit class that wants to signal to the minimiser.

Definition at line 35 of file RooNaNPacker.h.

Public Member Functions

constexpr RooNaNPacker ()
 
 RooNaNPacker (float value)
 Create NaN with a packed floating point number.
 
void accumulate (double val)
 Accumulate a packed float from another NaN into this.
 
double getNaNWithPayload () const
 Retrieve a NaN with the current float payload packed into the mantissa.
 
float getPayload () const
 Retrieve packed float.
 
bool isNaNWithPayload () const
 Test if this struct has a float packed into its mantissa.
 
RooNaNPackeroperator*= (float val)
 Multiply the packed float.
 
RooNaNPackeroperator+= (float val)
 Add to the packed float.
 
void setPayload (float payload)
 Pack float into mantissa of NaN.
 

Static Public Member Functions

template<class It_t >
static double accumulatePayloads (It_t begin, It_t end)
 Unpack floats from NaNs, and sum the packed values.
 
static bool isNaNWithPayload (double val)
 Test if val has a float packed into its mantissa.
 
__roodevice__ static __roohost__ double packFloatIntoNaN (float payload)
 Pack float into mantissa of a NaN.
 
static float unpackNaN (double val)
 If val is NaN and a this NaN has been tagged as containing a payload, unpack the float from the mantissa.
 
static void warn ()
 Warn that packing only works on little-endian machines.
 

Public Attributes

double _payload
 

Static Public Attributes

static constexpr uint64_t magicTag = 0x321ab00000000
 
static constexpr uint64_t magicTagMask = 0x3ffff00000000
 

#include </home/sftnight/build/workspace/root-makedoc-v632/rootspi/rdoc/src/v6-32-00-patches/roofit/batchcompute/res/RooNaNPacker.h>

Constructor & Destructor Documentation

◆ RooNaNPacker() [1/2]

constexpr RooNaNPacker::RooNaNPacker ( )
inlineconstexpr

Definition at line 45 of file RooNaNPacker.h.

◆ RooNaNPacker() [2/2]

RooNaNPacker::RooNaNPacker ( float  value)
inlineexplicit

Create NaN with a packed floating point number.

Definition at line 48 of file RooNaNPacker.h.

Member Function Documentation

◆ accumulate()

void RooNaNPacker::accumulate ( double  val)
inline

Accumulate a packed float from another NaN into this.

Definition at line 63 of file RooNaNPacker.h.

◆ accumulatePayloads()

template<class It_t >
static double RooNaNPacker::accumulatePayloads ( It_t  begin,
It_t  end 
)
inlinestatic

Unpack floats from NaNs, and sum the packed values.

Definition at line 67 of file RooNaNPacker.h.

◆ getNaNWithPayload()

double RooNaNPacker::getNaNWithPayload ( ) const
inline

Retrieve a NaN with the current float payload packed into the mantissa.

Definition at line 93 of file RooNaNPacker.h.

◆ getPayload()

float RooNaNPacker::getPayload ( ) const
inline

Retrieve packed float.

Returns zero if number is not NaN or if float wasn't packed by this class.

Definition at line 90 of file RooNaNPacker.h.

◆ isNaNWithPayload() [1/2]

bool RooNaNPacker::isNaNWithPayload ( ) const
inline

Test if this struct has a float packed into its mantissa.

Definition at line 96 of file RooNaNPacker.h.

◆ isNaNWithPayload() [2/2]

static bool RooNaNPacker::isNaNWithPayload ( double  val)
inlinestatic

Test if val has a float packed into its mantissa.

Definition at line 99 of file RooNaNPacker.h.

◆ operator*=()

RooNaNPacker & RooNaNPacker::operator*= ( float  val)
inline

Multiply the packed float.

Definition at line 82 of file RooNaNPacker.h.

◆ operator+=()

RooNaNPacker & RooNaNPacker::operator+= ( float  val)
inline

Add to the packed float.

Definition at line 75 of file RooNaNPacker.h.

◆ packFloatIntoNaN()

__roodevice__ static __roohost__ double RooNaNPacker::packFloatIntoNaN ( float  payload)
inlinestatic

Pack float into mantissa of a NaN.

Adds a tag to the upper bits of the mantissa, so a "normal" NaN can be differentiated from a NaN with a payload.

Definition at line 109 of file RooNaNPacker.h.

◆ setPayload()

void RooNaNPacker::setPayload ( float  payload)
inline

Pack float into mantissa of NaN.

Definition at line 51 of file RooNaNPacker.h.

◆ unpackNaN()

static float RooNaNPacker::unpackNaN ( double  val)
inlinestatic

If val is NaN and a this NaN has been tagged as containing a payload, unpack the float from the mantissa.

Return 0 otherwise.

Definition at line 123 of file RooNaNPacker.h.

◆ warn()

static void RooNaNPacker::warn ( )
inlinestatic

Warn that packing only works on little-endian machines.

Definition at line 131 of file RooNaNPacker.h.

Member Data Documentation

◆ _payload

double RooNaNPacker::_payload

Definition at line 36 of file RooNaNPacker.h.

◆ magicTag

constexpr uint64_t RooNaNPacker::magicTag = 0x321ab00000000
staticconstexpr

Definition at line 43 of file RooNaNPacker.h.

◆ magicTagMask

constexpr uint64_t RooNaNPacker::magicTagMask = 0x3ffff00000000
staticconstexpr

Definition at line 42 of file RooNaNPacker.h.

Collaboration diagram for RooNaNPacker:
[legend]

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