RooParticle
Particle scattering simulator with ROOT
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
recorder< Element > Class Template Reference

Remembers one value of type Element, optionally pulled from a watched variable. More...

#include <recorder.hpp>

Public Member Functions

 recorder ()
 Empty recorder: no watched variable, stored value uninitialised (for built-in types).
 
 recorder (Element data_)
 Recorder with an initial stored value.
 
 recorder (Element *addr_)
 Recorder watching a variable; the stored value is left uninitialised until Save().
 
 ~recorder ()
 
void SetAddress (Element *addr_)
 Set or change the watched variable.
 
Element GetData ()
 The stored value.
 
void Save ()
 Store the current value of the watched variable unconditionally; does nothing if no address is set.
 
void Save (const Element data_)
 Store the given value unconditionally.
 
Bool_t MaxSave ()
 Store the watched variable if it is larger than the stored value.
 
Bool_t MaxSave (const Element data_)
 Same as MaxSave() for a given value, not the watched variable.
 
Bool_t MinSave ()
 Store the watched variable if it is smaller than the stored value.
 
Bool_t MinSave (const Element data_)
 Store data_ if it is smaller than the stored value.
 
void Print ()
 Print the watched variable's value and the stored value on std::cout (a note is printed if no address is set).
 

Protected Member Functions

Bool_t CMPSave (const Bool_t sgn)
 Compare the watched variable with the stored value and save it (shared by MaxSave and MinSave).
 
Bool_t CMPSave (const Bool_t sgn, const Element data_)
 Compare data_ with the stored value and save it if the test passes.
 

Private Attributes

Element data
 stored value
 
Element * addr = nullptr
 watched variable, not owned
 

Detailed Description

template<typename Element>
class recorder< Element >

Remembers one value of type Element, optionally pulled from a watched variable.

Intended use: keep the extreme of a quantity over a run (for example the minimum distance of closest approach). The member functions are defined in recorder.cpp and instantiated there only for the typedefs recorderB (Bool_t), recorderI (Int_t), recorderL (Long_t), recorderF (Float_t) and recorderD (Double_t); other element types fail to link. All declared members are defined. The recorder does not own the watched variable.

For a minimum search start the recorder with the largest possible value (std::numeric_limits<Double_t>::max()) and feed it with MinSave(), as test/main_3body_oneline.cpp and test/main_rutherford_recorder.cpp do.

Note
Until 2026-11 a typo in the comparison made MinSave() never save and MaxSave() save any differing value; output written before that holds the initial value instead of the minimum.

Definition at line 28 of file recorder.hpp.

Constructor & Destructor Documentation

◆ recorder() [1/3]

template<typename Element >
recorder< Element >::recorder ( )
inline

Empty recorder: no watched variable, stored value uninitialised (for built-in types).

Definition at line 31 of file recorder.hpp.

◆ recorder() [2/3]

template<typename Element >
recorder< Element >::recorder ( Element  data_)
inline

Recorder with an initial stored value.

Parameters
data_initial value (for a minimum search use the largest possible value)

Definition at line 34 of file recorder.hpp.

◆ recorder() [3/3]

template<typename Element >
recorder< Element >::recorder ( Element *  addr_)
inline

Recorder watching a variable; the stored value is left uninitialised until Save().

Parameters
addr_address of the variable (not owned; must stay valid)

Definition at line 37 of file recorder.hpp.

◆ ~recorder()

template<typename Element >
recorder< Element >::~recorder ( )
inline

Definition at line 38 of file recorder.hpp.

Member Function Documentation

◆ CMPSave() [1/2]

template<typename Element >
Bool_t recorder< Element >::CMPSave ( const Bool_t  sgn)
protected

Compare the watched variable with the stored value and save it (shared by MaxSave and MinSave).

Parameters
sgntrue for the maximum variant, false for the minimum variant
Returns
true if saved

Definition at line 31 of file recorder.cpp.

◆ CMPSave() [2/2]

template<typename Element >
Bool_t recorder< Element >::CMPSave ( const Bool_t  sgn,
const Element  data_ 
)
protected

Compare data_ with the stored value and save it if the test passes.

Parameters
sgntrue for the maximum variant, false for the minimum variant
data_candidate value
Returns
true if saved

Definition at line 21 of file recorder.cpp.

◆ GetData()

template<typename Element >
Element recorder< Element >::GetData ( )
inline

The stored value.

Definition at line 43 of file recorder.hpp.

◆ MaxSave() [1/2]

template<typename Element >
Bool_t recorder< Element >::MaxSave ( )

Store the watched variable if it is larger than the stored value.

Returns
true if saved
Warning
Dereferences the address without checking: crashes if none was set.

Definition at line 41 of file recorder.cpp.

◆ MaxSave() [2/2]

template<typename Element >
Bool_t recorder< Element >::MaxSave ( const Element  data_)

Same as MaxSave() for a given value, not the watched variable.

Parameters
data_candidate value
Returns
true if saved

Definition at line 36 of file recorder.cpp.

◆ MinSave() [1/2]

template<typename Element >
Bool_t recorder< Element >::MinSave ( )

Store the watched variable if it is smaller than the stored value.

Returns
true if saved
Warning
Dereferences the address without checking: crashes if none was set.

Definition at line 51 of file recorder.cpp.

◆ MinSave() [2/2]

template<typename Element >
Bool_t recorder< Element >::MinSave ( const Element  data_)

Store data_ if it is smaller than the stored value.

Parameters
data_candidate value
Returns
true if saved

Definition at line 46 of file recorder.cpp.

◆ Print()

template<typename Element >
void recorder< Element >::Print ( )

Print the watched variable's value and the stored value on std::cout (a note is printed if no address is set).

Definition at line 7 of file recorder.cpp.

◆ Save() [1/2]

template<typename Element >
void recorder< Element >::Save ( )
inline

Store the current value of the watched variable unconditionally; does nothing if no address is set.

Definition at line 45 of file recorder.hpp.

◆ Save() [2/2]

template<typename Element >
void recorder< Element >::Save ( const Element  data_)
inline

Store the given value unconditionally.

Parameters
data_value to store

Definition at line 48 of file recorder.hpp.

◆ SetAddress()

template<typename Element >
void recorder< Element >::SetAddress ( Element *  addr_)
inline

Set or change the watched variable.

Parameters
addr_address of the variable (not owned)

Definition at line 41 of file recorder.hpp.

Member Data Documentation

◆ addr

template<typename Element >
Element* recorder< Element >::addr = nullptr
private

watched variable, not owned

Definition at line 79 of file recorder.hpp.

◆ data

template<typename Element >
Element recorder< Element >::data
private

stored value

Definition at line 78 of file recorder.hpp.


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