gambit is hosted by Hepforge, IPPP Durham
GAMBIT  v1.5.0-2191-ga4742ac
a Global And Modular Bsm Inference Tool
Gambit::Printers::BaseBaseReader Class Referenceabstract

So, need: More...

#include <basebaseprinter.hpp>

Inheritance diagram for Gambit::Printers::BaseBaseReader:

Public Member Functions

virtual ~BaseBaseReader ()
 
virtual void reset ()=0
 
virtual ulong get_dataset_length ()=0
 
virtual PPIDpair get_current_point ()=0
 
virtual ulong get_current_index ()=0
 
virtual PPIDpair get_next_point ()=0
 
virtual bool eoi ()=0
 
template<typename T >
bool retrieve (T &out, const std::string &label, const uint rank, const ulong pointID)
 Printer-retrieve dispatch function. More...
 
template<typename T >
bool retrieve (T &out, const std::string &label)
 Overload for 'retrieve' that uses the current point as the input for rank/pointID. More...
 
bool retrieve_and_print (const std::string &label, BaseBasePrinter &printer, const uint rank, const ulong pointID)
 Retrieve and directly print data to new output. More...
 
virtual bool retrieve_and_print (const std::string &in_label, const std::string &out_label, BaseBasePrinter &printer, const uint rank, const ulong pointID)=0
 Retrieve and directly print data to new output, renaming the output to something new Implemented in BasePrinter where complete type info is available. More...
 
bool retrieve_and_print (const std::string &label, BaseBasePrinter &printer)
 Overload for 'retrieve_and_print' that uses the current point as the input for rank/pointID. More...
 
bool retrieve_and_print (const std::string &in_label, const std::string &out_label, BaseBasePrinter &printer)
 As above, but allows for different input/output labels. More...
 
virtual std::size_t get_type (const std::string &label)=0
 Get type information for a data entry, i.e. More...
 
virtual std::set< std::string > get_all_labels ()=0
 Get list of output labels that can be retrieved by this printer. More...
 

Protected Member Functions

template<typename T >
bool _retrieve (T &, const std::string &label, const uint, const ulong)
 Default _retrieve function. More...
 

Detailed Description

So, need:

Printer READ interface For reading data back into Gambit from a printer output file. This is mainly designed for performing "reweighting" of scans, e.g. loading up previously scanned points in order to recompute some new observables or likelihoods.

It is pretty hard to permit generic read-in of ALL data, so for now I will focus on just getting the parameter data. If we read in other data we will have to do some gnarly stuff like automatically wrap it into functors, and to appropriate capabilities etc, in order for it to be usable in other in other calculations. So for now, the idea will simply be to take the parameter values and recompute everything anew that is needed for calculating the new likelihoods or whatever. Otherwise it is kind of a nightmare to e.g. reconstruct a Spectrum object from printer data, would need special module functions and so on that know how to put all the data back together. I guess it is possible if we give module writers access to the printer read interface so that they can do this task themselves... but will leave this aside for now. 1. some way to iterate through printer output

  1. a generic function that can read in a particular entry, knowing e.g. the following:

    Column 6: #NormalDist_parameters @NormalDist::primary_parameters::mu

    and can put it back into some Gambit object, e.g. Parameters: NormalDist: mu: sigma:

    I guess this latter part is scannerbits responsibility, i.e. it will have the parameter object and need to fill it with numbers that it gets from the printer.

         functor (model) name    parameter name
    

    str key = act_it->first + "::" + *par_it;

Definition at line 277 of file basebaseprinter.hpp.

Constructor & Destructor Documentation

◆ ~BaseBaseReader()

virtual Gambit::Printers::BaseBaseReader::~BaseBaseReader ( )
inlinevirtual

Definition at line 280 of file basebaseprinter.hpp.

References Gambit::Printers::BaseBasePrinter::reset().

280 {};
Here is the call graph for this function:

Member Function Documentation

◆ _retrieve()

template<typename T >
bool Gambit::Printers::BaseBaseReader::_retrieve ( T &  ,
const std::string &  label,
const uint  ,
const ulong   
)
inlineprotected

Default _retrieve function.

Throws an error if no virtual function matching the type of the attempted retrieval is found.

Definition at line 381 of file basebaseprinter.hpp.

References Gambit::LogTags::err, LOCAL_INFO, Gambit::Printers::printer_error(), and STRINGIFY.

Referenced by Gambit::Printers::asciiReader::get_type(), Gambit::Printers::BaseReader::retrieve(), and Gambit::Printers::HDF5Reader::retrieve_and_add_to_SLHAea().

382  {
383  std::ostringstream err;
384 
385  err << "Attempted to retrieve a print result as an unregistered type!"
386  << "If you really want to retrieve a result as this type, you must "
387  << "add the type to the RETRIEVABLE_TYPES sequence "
388  << "in \"gambit/Elements/printable_types.hpp\". You will then have "
389  << "to define a retrieve function for it in whatever printer "
390  << "you are using (see documentation for GAMBIT printers)."
391  << "\n Available info for this retrieve attempt..."
392  << "\n Label : " << label
393  << "\n Type : " << STRINGIFY(T);
394  printer_error().raise(LOCAL_INFO,err.str());
395  return false;
396  }
#define STRINGIFY(X)
Definition: stringify.hpp:29
EXPORT_SYMBOLS error & printer_error()
Printer errors.
#define LOCAL_INFO
Definition: local_info.hpp:34
Here is the call graph for this function:
Here is the caller graph for this function:

◆ eoi()

virtual bool Gambit::Printers::BaseBaseReader::eoi ( )
pure virtual

Implemented in Gambit::Printers::HDF5Reader, Gambit::Printers::SQLiteReader, and Gambit::Printers::asciiReader.

Referenced by Gambit::PostProcessor::get_done_points().

Here is the caller graph for this function:

◆ get_all_labels()

virtual std::set<std::string> Gambit::Printers::BaseBaseReader::get_all_labels ( )
pure virtual

Get list of output labels that can be retrieved by this printer.

Needs to be implemented in each complete derived Reader class

Implemented in Gambit::Printers::HDF5Reader, Gambit::Printers::SQLiteReader, and Gambit::Printers::asciiReader.

Referenced by scanner_plugin().

Here is the caller graph for this function:

◆ get_current_index()

virtual ulong Gambit::Printers::BaseBaseReader::get_current_index ( )
pure virtual

◆ get_current_point()

virtual PPIDpair Gambit::Printers::BaseBaseReader::get_current_point ( )
pure virtual

◆ get_dataset_length()

virtual ulong Gambit::Printers::BaseBaseReader::get_dataset_length ( )
pure virtual

◆ get_next_point()

virtual PPIDpair Gambit::Printers::BaseBaseReader::get_next_point ( )
pure virtual

◆ get_type()

virtual std::size_t Gambit::Printers::BaseBaseReader::get_type ( const std::string &  label)
pure virtual

Get type information for a data entry, i.e.

defines the C++ type which this should be retrieved as, not what it is necessarily literally stored as in the output. It isn't human readable, it is just for matching retrieved data to a print type, mainly for the 'retrieve_and_print' function. Needs to be implemented in each complete derived Reader class

Implemented in Gambit::Printers::HDF5Reader, Gambit::Printers::SQLiteReader, and Gambit::Printers::asciiReader.

Referenced by Gambit::PostProcessor::PPDriver::check_settings(), Gambit::PostProcessor::get_done_points(), and Gambit::PostProcessor::PPDriver::run_main_loop().

Here is the caller graph for this function:

◆ reset()

virtual void Gambit::Printers::BaseBaseReader::reset ( )
pure virtual

◆ retrieve() [1/2]

template<typename T >
bool Gambit::Printers::BaseBaseReader::retrieve ( T &  out,
const std::string &  label,
const uint  rank,
const ulong  pointID 
)
inline

Printer-retrieve dispatch function.

If a virtual function override exists for the retrieve type, info is passed on, otherwise the function call is resolved to a default function which raises an informative runtime error explaining that the type is not retrievable.

Note; this is not quite enough because the entries in the printer output need not be one-to-one with the printed object, e.g. vectors currently go into a series of indexed output slots. Hard for e.g. scanner plugins to know the label that they need to ask for...

Perhaps return a map of results matching the label? Or vector? Perhaps both in different cases...

Note, cannot overload based on return type, so need to use an "out" parameter In addition, there may not be a valid result printed for a given entry, so an extra output flag "out_valid" must be set to indicate whether the entry was marked invalid in the old output. Use the return value for this.

Definition at line 307 of file basebaseprinter.hpp.

Referenced by Gambit::PostProcessor::get_done_points(), Gambit::PostProcessor::PPDriver::get_ModelParameters(), and Gambit::PostProcessor::PPDriver::run_main_loop().

308  {
309  return _retrieve(out, label, rank, pointID);
310  }
bool _retrieve(T &, const std::string &label, const uint, const ulong)
Default _retrieve function.
Here is the caller graph for this function:

◆ retrieve() [2/2]

template<typename T >
bool Gambit::Printers::BaseBaseReader::retrieve ( T &  out,
const std::string &  label 
)
inline

Overload for 'retrieve' that uses the current point as the input for rank/pointID.

Definition at line 314 of file basebaseprinter.hpp.

References Gambit::Printers::nullpoint, Gambit::Printers::PPIDpair::pointID, and Gambit::Printers::PPIDpair::rank.

315  {
316  bool valid;
317  PPIDpair pt = get_current_point();
318  // Need to check if the current rank/pointID pair is valid before trying to retrieve from it
319  if(pt==nullpoint)
320  {
321  valid = false;
322  }
323  else
324  {
325  valid = retrieve(out, label, pt.rank, pt.pointID);
326  }
327  return valid;
328  }
virtual PPIDpair get_current_point()=0
bool retrieve(T &out, const std::string &label, const uint rank, const ulong pointID)
Printer-retrieve dispatch function.
EXPORT_SYMBOLS const PPIDpair nullpoint
Define &#39;nullpoint&#39; const.

◆ retrieve_and_print() [1/4]

bool Gambit::Printers::BaseBaseReader::retrieve_and_print ( const std::string &  label,
BaseBasePrinter printer,
const uint  rank,
const ulong  pointID 
)
inline

Retrieve and directly print data to new output.

Just use the same label for input and output

Definition at line 331 of file basebaseprinter.hpp.

References Gambit::Printers::BaseBasePrinter::rank.

Referenced by Gambit::PostProcessor::PPDriver::run_main_loop().

332  {
334  return retrieve_and_print(label, label, printer, rank, pointID);
335  }
Printers::BaseBasePrinter printer
Type of the printer objects.
bool retrieve_and_print(const std::string &label, BaseBasePrinter &printer, const uint rank, const ulong pointID)
Retrieve and directly print data to new output.
Here is the caller graph for this function:

◆ retrieve_and_print() [2/4]

virtual bool Gambit::Printers::BaseBaseReader::retrieve_and_print ( const std::string &  in_label,
const std::string &  out_label,
BaseBasePrinter printer,
const uint  rank,
const ulong  pointID 
)
pure virtual

Retrieve and directly print data to new output, renaming the output to something new Implemented in BasePrinter where complete type info is available.

Implemented in Gambit::Printers::BaseReader.

◆ retrieve_and_print() [3/4]

bool Gambit::Printers::BaseBaseReader::retrieve_and_print ( const std::string &  label,
BaseBasePrinter printer 
)
inline

Overload for 'retrieve_and_print' that uses the current point as the input for rank/pointID.

Uses same label for input and output

Definition at line 342 of file basebaseprinter.hpp.

343  {
345  return retrieve_and_print(label, label, printer);
346  }
Printers::BaseBasePrinter printer
Type of the printer objects.
bool retrieve_and_print(const std::string &label, BaseBasePrinter &printer, const uint rank, const ulong pointID)
Retrieve and directly print data to new output.

◆ retrieve_and_print() [4/4]

bool Gambit::Printers::BaseBaseReader::retrieve_and_print ( const std::string &  in_label,
const std::string &  out_label,
BaseBasePrinter printer 
)
inline

As above, but allows for different input/output labels.

Definition at line 349 of file basebaseprinter.hpp.

References Gambit::Printers::nullpoint, Gambit::Printers::PPIDpair::pointID, and Gambit::Printers::PPIDpair::rank.

350  {
351  bool valid;
352  PPIDpair pt = get_current_point();
353  // Need to check if the current rank/pointID pair is valid before trying to retrieve from it
354  if(pt==nullpoint)
355  {
356  valid = false;
357  }
358  else
359  {
360  valid = retrieve_and_print(in_label, out_label, printer, pt.rank, pt.pointID);
361  }
362  return valid;
363  }
virtual PPIDpair get_current_point()=0
Printers::BaseBasePrinter printer
Type of the printer objects.
EXPORT_SYMBOLS const PPIDpair nullpoint
Define &#39;nullpoint&#39; const.
bool retrieve_and_print(const std::string &label, BaseBasePrinter &printer, const uint rank, const ulong pointID)
Retrieve and directly print data to new output.

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