Tomographer  v4.0
Tomographer C++ Framework Documentation
Tomographer::MHRWTasks::ValueHistogramTasks::CDataBase< ValueCalculator_, UseBinningAnalysis_, IterCountIntType_, StepRealType_, CountRealType_, HistCountIntType_ > Struct Template Reference

Constant data structure for MH random walk tasks with a value histogram stats collector. More...

#include <tomographer/mhrw_valuehist_tasks.h>

+ Inheritance diagram for Tomographer::MHRWTasks::ValueHistogramTasks::CDataBase< ValueCalculator_, UseBinningAnalysis_, IterCountIntType_, StepRealType_, CountRealType_, HistCountIntType_ >:
+ Collaboration diagram for Tomographer::MHRWTasks::ValueHistogramTasks::CDataBase< ValueCalculator_, UseBinningAnalysis_, IterCountIntType_, StepRealType_, CountRealType_, HistCountIntType_ >:

Classes

struct  ResultsCollectorType
 Helper to get the results collector type. More...
 

Public Types

typedef MHRWTasks::CDataBase< IterCountIntType_, StepRealType_ > Base
 The MHRWTasks::CDataBase base class.
 
typedef Base::IterCountIntType IterCountIntType
 The integer type which serves to count the number of iterations (see MHRWParams)
 
typedef Base::StepRealType StepRealType
 The real type which serves to describe the step size of the random walk (typically double)
 
typedef HistCountIntType_ HistCountIntType
 The integer counting type in our underlying raw histogram type.
 
typedef ValueCalculator_ ValueCalculator
 The class which calculates the value we are collecting a histogram of (ValueCalculator Interface compliant)
 
typedef CountRealType_ CountRealType
 The real type which serves to average histogram counts (typically double)
 
typedef tomo_internal::histogram_types< CDataBase, UseBinningAnalysis >::MHRWStatsCollectorResultType MHRWStatsCollectorResultType
 The result type of our stats collector. More...
 
typedef tomo_internal::histogram_types< CDataBase, UseBinningAnalysis >::HistogramType HistogramType
 The histogram type reported by the task. More...
 
typedef tomo_internal::histogram_types< CDataBase, UseBinningAnalysis >::HistogramParams HistogramParams
 The appropriate parameters type for the histogram reported by the task.
 
typedef MHRWParams< IterCountIntType, StepRealTypeMHRWParamsType
 Type for the parameters of the random walk.
 
- Public Types inherited from Tomographer::MHRWTasks::CDataBase< IterCountIntType_, StepRealType_ >
typedef IterCountIntType_ IterCountIntType
 Type used to count the number of iterations.
 
typedef StepRealType_ StepRealType
 Type used to specify the step size.
 
typedef MHRWParams< IterCountIntType, StepRealTypeMHRWParamsType
 Type to store the parameters of the Metropolis-Hastings random walk (number of runs, sweep size, etc.) More...
 

Public Member Functions

template<ENABLED_IF( !UseBinningAnalysis) >
 CDataBase (const ValueCalculator &valcalc_, HistogramParams histogram_params_, MHRWParamsType p, int base_seed=0)
 Constructor (only for without binning analysis)
 
template<ENABLED_IF( UseBinningAnalysis) >
 CDataBase (const ValueCalculator &valcalc_, HistogramParams histogram_params_, int binning_num_levels_, MHRWParamsType p, int base_seed=0)
 Constructor (only for with binning analysis)
 
template<typename LoggerType , ENABLED_IF( !UseBinningAnalysis) >
ValueHistogramMHRWStatsCollector< ValueCalculator, LoggerType, HistogramTypecreateStatsCollector (LoggerType &logger) const
 Create the stats collector (without binning analysis) More...
 
template<typename LoggerType , ENABLED_IF( UseBinningAnalysis) >
ValueHistogramWithBinningMHRWStatsCollector< typename tomo_internal::histogram_types< CDataBase, true >::BinningMHRWStatsCollectorParams, LoggerType > createStatsCollector (LoggerType &logger) const
 Create the stats collector (with binning analysis) More...
 
- Public Member Functions inherited from Tomographer::MHRWTasks::CDataBase< IterCountIntType_, StepRealType_ >
template<typename MHRWParamsType >
 CDataBase (MHRWParamsType &&p, int base_seed_=0)
 Constructor. More...
 
int getTaskInput (int k) const
 Returns a random seed to seed the random number generator with for run number k. More...
 
void printBasicCDataMHRWInfo (std::ostream &str) const
 Get some human-readable info about the random walk as a string.
 
std::string getBasicCDataMHRWInfo () const
 Get some human-readable info about the random walk as a string, see printBasicCDataMHRWInfo()
 

Public Attributes

const ValueCalculator valcalc
 The value calculator instance.
 
const HistogramParams histogram_params
 The parameters of the histogram that we are collecting.
 
const Tools::StoreIfEnabled< int, UseBinningAnalysisbinningNumLevels
 The number of levels in the binning analysis (only if we are using a binning analysis)
 
- Public Attributes inherited from Tomographer::MHRWTasks::CDataBase< IterCountIntType_, StepRealType_ >
const MHRWParamsType mhrw_params
 Parameters of the random walk. More...
 
const int base_seed
 A base random seed from which each run seed will be derived. More...
 

Static Public Attributes

static constexpr bool UseBinningAnalysis = UseBinningAnalysis_
 Whether or not we are to use a binning analysis for calculating the error bars.
 

Detailed Description

template<typename ValueCalculator_, bool UseBinningAnalysis_ = true, typename IterCountIntType_ = int, typename StepRealType_ = double, typename CountRealType_ = double, typename HistCountIntType_ = IterCountIntType_>
struct Tomographer::MHRWTasks::ValueHistogramTasks::CDataBase< ValueCalculator_, UseBinningAnalysis_, IterCountIntType_, StepRealType_, CountRealType_, HistCountIntType_ >

Constant data structure for MH random walk tasks with a value histogram stats collector.

You should define your TaskCData class to inherit this class, and be compliant with the MHRandomWalkTaskCData Interface. This class already inherits MHRWTasks::CDataBase, so you only have to inherit this class and provide a createMHWalker() method (see MHRandomWalkTaskCData Interface). (Note that your class will automatically be compliant with the TaskCData Interface in this way.)

Look at the file test/minimal_tomorun.cxx for an example of you to define your cdata class.

This class should be used in conjunction with a ResultsCollectorSimple or ResultsCollectorWithBinningAnalysis. For convenience, you can query the member ResultsCollectorType to get the correct results collector type according to whether we are using a binning analysis and with the correct parameters type.

We provide some useful typedefs, as well as the createStatsCollector() required by the MHRandomWalkTaskCData Interface.

Template Parameters
ValueCalculatorthe value calculator type you wish to use; defining which value you are interested in collecting a histogram of during the random walk;
UseBinningAnalysiswhether or not to use a binning analysis to obtain reliable error bars during the random walk.
IterCountIntTypethe integer type to use for counting iterations.
StepRealTypethe real type to use for representing a step size in the random walk.
CountRealTypethe real type to use when calculating the scaled histogram with error bars.
HistCountIntTypethe integer type to record the histogram counts in the underlying raw histogram.

Note: if your subclass also takes a template parameter to allow or not the use of a binning analysis, then you'll have to define two conditionally enabled constructors to cover both cases. For instance (see also the code in tomorun/tomorun_dispatch.h for another example):

struct MyCData
{
TOMOGRAPHER_ENABLED_IF(!BinningAnalysisEnabled)
MyCData(ValueCalculator valcalc, int base_seed, ...)
: Base(valcalc,
typename Base::HistogramParams(...),
typename Base::MHRWParamsType(...),
base_seed)
{ ... }
TOMOGRAPHER_ENABLED_IF(BinningAnalysisEnabled)
MyCData(ValueCalculator valcalc, int base_seed, int binning_analysis_num_levels, ...)
: Base(valcalc,
typename Base::HistogramParams(...),
binning_analysis_num_levels,
typename Base::MHRWParamsType(...),
base_seed)
{ ... }
...
};

Definition at line 941 of file mhrw_valuehist_tasks.h.

Member Typedef Documentation

§ HistogramType

template<typename ValueCalculator_ , bool UseBinningAnalysis_ = true, typename IterCountIntType_ = int, typename StepRealType_ = double, typename CountRealType_ = double, typename HistCountIntType_ = IterCountIntType_>
typedef tomo_internal::histogram_types<CDataBase,UseBinningAnalysis>::HistogramType Tomographer::MHRWTasks::ValueHistogramTasks::CDataBase< ValueCalculator_, UseBinningAnalysis_, IterCountIntType_, StepRealType_, CountRealType_, HistCountIntType_ >::HistogramType

The histogram type reported by the task.

Depending on whether we are using a binning analysis, this histogram type will have error bars.

It is either:

Definition at line 990 of file mhrw_valuehist_tasks.h.

§ MHRWStatsCollectorResultType

template<typename ValueCalculator_ , bool UseBinningAnalysis_ = true, typename IterCountIntType_ = int, typename StepRealType_ = double, typename CountRealType_ = double, typename HistCountIntType_ = IterCountIntType_>
typedef tomo_internal::histogram_types<CDataBase,UseBinningAnalysis>::MHRWStatsCollectorResultType Tomographer::MHRWTasks::ValueHistogramTasks::CDataBase< ValueCalculator_, UseBinningAnalysis_, IterCountIntType_, StepRealType_, CountRealType_, HistCountIntType_ >::MHRWStatsCollectorResultType

The result type of our stats collector.

This is either:

  • (without binning analysis): a simple histogram type, without error bars
  • (with binning analysis): a structure containing a histogram with error bars, along with a convergence analysis of the errors. It is a ValueHistogramWithBinningMHRWStatsCollectorResult type.

Definition at line 975 of file mhrw_valuehist_tasks.h.

Member Function Documentation

§ createStatsCollector() [1/2]

template<typename ValueCalculator_ , bool UseBinningAnalysis_ = true, typename IterCountIntType_ = int, typename StepRealType_ = double, typename CountRealType_ = double, typename HistCountIntType_ = IterCountIntType_>
template<typename LoggerType , ENABLED_IF( !UseBinningAnalysis) >
ValueHistogramMHRWStatsCollector<ValueCalculator,LoggerType,HistogramType> Tomographer::MHRWTasks::ValueHistogramTasks::CDataBase< ValueCalculator_, UseBinningAnalysis_, IterCountIntType_, StepRealType_, CountRealType_, HistCountIntType_ >::createStatsCollector ( LoggerType &  logger) const
inline

Create the stats collector (without binning analysis)

This method is provided in compliance with the MHRandomWalkTaskCData Interface for MHRandomWalkTask.

Definition at line 1033 of file mhrw_valuehist_tasks.h.

§ createStatsCollector() [2/2]

template<typename ValueCalculator_ , bool UseBinningAnalysis_ = true, typename IterCountIntType_ = int, typename StepRealType_ = double, typename CountRealType_ = double, typename HistCountIntType_ = IterCountIntType_>
template<typename LoggerType , ENABLED_IF( UseBinningAnalysis) >
ValueHistogramWithBinningMHRWStatsCollector< typename tomo_internal::histogram_types<CDataBase, true>::BinningMHRWStatsCollectorParams, LoggerType> Tomographer::MHRWTasks::ValueHistogramTasks::CDataBase< ValueCalculator_, UseBinningAnalysis_, IterCountIntType_, StepRealType_, CountRealType_, HistCountIntType_ >::createStatsCollector ( LoggerType &  logger) const
inline

Create the stats collector (with binning analysis)

This method is provided in compliance with the MHRandomWalkTaskCData Interface for MHRandomWalkTask.

Definition at line 1051 of file mhrw_valuehist_tasks.h.


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