Tomographer  v4.0
Tomographer C++ Framework Documentation
Tomographer::MHRWTasks::ValueHistogramTasks::ResultsCollectorSimple< CDataBaseType_, LoggerType_ > Struct Template Reference

Results collector, if no binning analysis is being used. More...

#include <tomographer/mhrw_valuehist_tasks.h>

+ Inheritance diagram for Tomographer::MHRWTasks::ValueHistogramTasks::ResultsCollectorSimple< CDataBaseType_, LoggerType_ >:
+ Collaboration diagram for Tomographer::MHRWTasks::ValueHistogramTasks::ResultsCollectorSimple< CDataBaseType_, LoggerType_ >:

Classes

struct  RunTaskResult
 Stores information about the result of a task run. More...
 

Public Types

typedef CDataBaseType_ CDataBaseType
 The structure which hold the constant shared data describing what we have to do.
 
typedef CDataBaseType::ValueCalculator ValueCalculator
 The class which calculates the value we are collecting a histogram of (ValueCalculator Interface compliant)
 
typedef CDataBaseType::CountRealType CountRealType
 The real type which serves to average histogram counts (typically double)
 
typedef CDataBaseType::IterCountIntType IterCountIntType
 The integer type which serves to count the number of iterations (see MHRWParams)
 
typedef CDataBaseType::StepRealType StepRealType
 The real type which serves to describe the step size of the random walk (typically double)
 
typedef LoggerType_ LoggerType
 The logger type we can send messages to.
 
typedef CDataBaseType::HistogramType HistogramType
 The histogram type corresponding to the result of a task. More...
 
typedef CDataBaseType::HistogramParams HistogramParams
 The parameters type used to describe our histogram range and number of bins.
 
typedef UniformBinsHistogram< typename HistogramType::Scalar, CountRealTypeScaledHistogramType
 The type of the histogram resulting from a single task, but scaled so that each bin value corresponds to the fraction of data points in bin.
 
typedef AveragedHistogram< ScaledHistogramType, CountRealTypeFinalHistogramType
 
typedef HistogramType MHRWStatsCollectorResultType
 The result type of our ValueHistogramMHRWStatsCollector.
 
typedef std::vector< RunTaskResult * > RunTaskResultList
 

Public Member Functions

 ResultsCollectorSimple (LoggerType &logger_)
 Constructor. More...
 
bool isFinalized () const
 Returns TRUE after all runs have finished and results processed. More...
 
FinalHistogramType finalHistogram () const
 The final histogram, with error bars. More...
 
std::size_t numTasks () const
 Return the number of tasks that were run. More...
 
const RunTaskResultListcollectedRunTaskResults () const
 Return a list of the resulting report of each run task. More...
 
const RunTaskResultcollectedRunTaskResult (std::size_t task_no) const
 Return a list of the resulting report of one specific run task. More...
 
template<typename RealType = double>
void printHistogramCsv (std::ostream &stream, std::string sep="\, std::string linesep="\", int precision=10)
 Produce a comma-separated-value (CSV) representation of the final histogram. More...
 
void printFinalReport (std::ostream &str, const CDataBaseType &cdata, int max_width=0, bool print_histogram=true)
 Produce a final, human-readable report of the whole procedure. More...
 
template<typename Cnt , typename CData >
void init (Cnt num_total_runs, Cnt, const CData *pcdata)
 In compliance with ResultsCollector Interface.
 
template<typename Cnt , typename TaskResultType , typename CData >
void collectResult (Cnt task_no, TaskResultType &&taskresult, const CData *)
 In compliance with ResultsCollector Interface.
 
template<typename Cnt , typename CData >
void runsFinished (Cnt, const CData *)
 In compliance with ResultsCollector Interface — finalizes the results. More...
 

Detailed Description

template<typename CDataBaseType_, typename LoggerType_>
struct Tomographer::MHRWTasks::ValueHistogramTasks::ResultsCollectorSimple< CDataBaseType_, LoggerType_ >

Results collector, if no binning analysis is being used.

This class takes care of collecting the results of the executed random walk tasks, and merges them together to provide a final, averaged histogram with error bars.

This class complies with the ResultsCollector Interface.

This class is to be used in conjunction with Tomographer::MHRWTasks::MHRandomWalkTask and a const-shared-data structure inheriting from Tomographer::MHRWTasks::ValueHistogramTasks::CData and complying with the MHRandomWalkTaskCData Interface.

This results collector should only be used if each task provides a "raw" histogram, ie. without any error bars. If you have tasks which already provide some error bars from a binning analysis, then you should be using the class ResultsCollectorWithBinningAnalysis.

Note that you can directly get the right ResultsCollector type by querying the type "CDataBase::ResultsCollectorType<..>::Type".

Definition at line 135 of file mhrw_valuehist_tasks.h.

Member Typedef Documentation

§ FinalHistogramType

template<typename CDataBaseType_ , typename LoggerType_ >
typedef AveragedHistogram<ScaledHistogramType, CountRealType> Tomographer::MHRWTasks::ValueHistogramTasks::ResultsCollectorSimple< CDataBaseType_, LoggerType_ >::FinalHistogramType

The type of the final resulting, averaged histogram

The scale of the histogram is chosen such that each bin value corresponds to the fraction of data points observed in this bin. To normalize the histogram to a unit probability density, use UniformBinsHistogram::normalized(). This scaling is the same as that used by the histogram produced using a binning analysis, see ValueHistogramWithBinningMHRWStatsCollectorResult.

Definition at line 174 of file mhrw_valuehist_tasks.h.

§ HistogramType

template<typename CDataBaseType_ , typename LoggerType_ >
typedef CDataBaseType::HistogramType Tomographer::MHRWTasks::ValueHistogramTasks::ResultsCollectorSimple< CDataBaseType_, LoggerType_ >::HistogramType

The histogram type corresponding to the result of a task.

Warning
This histogram type must not provide error bars.

Definition at line 159 of file mhrw_valuehist_tasks.h.

Constructor & Destructor Documentation

§ ResultsCollectorSimple()

template<typename CDataBaseType_ , typename LoggerType_ >
Tomographer::MHRWTasks::ValueHistogramTasks::ResultsCollectorSimple< CDataBaseType_, LoggerType_ >::ResultsCollectorSimple ( LoggerType logger_)
inline

Constructor.

Messages will be logged to the given logger.

Definition at line 225 of file mhrw_valuehist_tasks.h.

Member Function Documentation

§ collectedRunTaskResult()

template<typename CDataBaseType_ , typename LoggerType_ >
const RunTaskResult* Tomographer::MHRWTasks::ValueHistogramTasks::ResultsCollectorSimple< CDataBaseType_, LoggerType_ >::collectedRunTaskResult ( std::size_t  task_no) const
inline

Return a list of the resulting report of one specific run task.

The result (i.e. the individual task's final report) is stored in a RunTaskResult structure.

Parameters
task_nomust be an index such that task_no >= 0 && task_no < numTasks().

You may only call this function after the results have been finalized (see isFinalized()), i.e. after the task dispatcher has finished executing all tasks.

Definition at line 298 of file mhrw_valuehist_tasks.h.

§ collectedRunTaskResults()

template<typename CDataBaseType_ , typename LoggerType_ >
const RunTaskResultList& Tomographer::MHRWTasks::ValueHistogramTasks::ResultsCollectorSimple< CDataBaseType_, LoggerType_ >::collectedRunTaskResults ( ) const
inline

Return a list of the resulting report of each run task.

The result (i.e. the individual task's final report) is stored in a RunTaskResult structure.

You may only call this function after the results have been finalized (see isFinalized()), i.e. after the task dispatcher has finished executing all tasks.

Definition at line 282 of file mhrw_valuehist_tasks.h.

§ finalHistogram()

template<typename CDataBaseType_ , typename LoggerType_ >
FinalHistogramType Tomographer::MHRWTasks::ValueHistogramTasks::ResultsCollectorSimple< CDataBaseType_, LoggerType_ >::finalHistogram ( ) const
inline

The final histogram, with error bars.

The error bars are calculated from the standard devitation of the histogram values reported by the different tasks. Make sure enough tasks have been run in order for the error bars to be meaningful.

The scale of the histogram is chosen such that each bin value corresponds to the fraction of data points observed in this bin. To normalize the histogram to a unit probability density, use UniformBinsHistogram::normalized().

Definition at line 259 of file mhrw_valuehist_tasks.h.

§ isFinalized()

template<typename CDataBaseType_ , typename LoggerType_ >
bool Tomographer::MHRWTasks::ValueHistogramTasks::ResultsCollectorSimple< CDataBaseType_, LoggerType_ >::isFinalized ( ) const
inline

Returns TRUE after all runs have finished and results processed.

Note that it is the task of the multiprocessing task dispatcher (e.g. MultiProc::OMP::TaskDispatcher::run) to finalize the results, as required by the Multiprocessing Task Interfaces API).

Definition at line 247 of file mhrw_valuehist_tasks.h.

§ numTasks()

template<typename CDataBaseType_ , typename LoggerType_ >
std::size_t Tomographer::MHRWTasks::ValueHistogramTasks::ResultsCollectorSimple< CDataBaseType_, LoggerType_ >::numTasks ( ) const
inline

Return the number of tasks that were run.

You may only call this function after the results have been finalized (see isFinalized()), i.e. after the task dispatcher has finished executing all tasks.

Definition at line 269 of file mhrw_valuehist_tasks.h.

§ printFinalReport()

template<typename CDataBaseType_ , typename LoggerType_ >
void Tomographer::MHRWTasks::ValueHistogramTasks::ResultsCollectorSimple< CDataBaseType_, LoggerType_ >::printFinalReport ( std::ostream str,
const CDataBaseType cdata,
int  max_width = 0,
bool  print_histogram = true 
)
inline

Produce a final, human-readable report of the whole procedure.

The report is written in the C++ stream str. You should provide the shared constant data structure cdata used for the random walk, so that the random walk parameters can be displayed.

You may specify the maximum width of your terminal in max_width, in which case we try very hard not make lines longer than that, and to fill all available horizontal space.

If print_histogram is true, then the histogram is also printed in a human readable form, using UniformBinsHistogramWithErrorBars::prettyPrint().

Definition at line 343 of file mhrw_valuehist_tasks.h.

§ printHistogramCsv()

template<typename CDataBaseType_ , typename LoggerType_ >
template<typename RealType = double>
void Tomographer::MHRWTasks::ValueHistogramTasks::ResultsCollectorSimple< CDataBaseType_, LoggerType_ >::printHistogramCsv ( std::ostream stream,
std::string  sep = "\t",
std::string  linesep = "\n",
int  precision = 10 
)
inline

Produce a comma-separated-value (CSV) representation of the final histogram.

The histogram data is written in CSV format on the C++ output stream stream. You may specify the cell separator sep (by default a TAB char), the line separator (by default a simple newline), and the precision used when exporting the values. Numbers are written in scientific format (e.g. 1.205115485e-01).

Three columns are outputted. Titles are outputted on the first line. The first column holds the values, i.e., the x-axis of the histogram; the second column holds the counts (normalized to the number of samples); the third column the error bar on the counts.

Definition at line 317 of file mhrw_valuehist_tasks.h.

§ runsFinished()

template<typename CDataBaseType_ , typename LoggerType_ >
template<typename Cnt , typename CData >
void Tomographer::MHRWTasks::ValueHistogramTasks::ResultsCollectorSimple< CDataBaseType_, LoggerType_ >::runsFinished ( Cnt  ,
const CData *   
)
inline

In compliance with ResultsCollector Interface — finalizes the results.

After this function is called (which the task dispatcher does automatically), the results are finalized (isFinalized() now returns true) and the functions finalHistogram(), collectedRunTaskResults(), etc. may be called.

Definition at line 433 of file mhrw_valuehist_tasks.h.


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