STIR 6.5.0
stir::InputStreamFromROOTFile Class Referenceabstract

A helper class to read data from a ROOT file Generated by GATE simulation toolkit. More...

#include "stir/IO/InputStreamFromROOTFile.h"

Inheritance diagram for stir::InputStreamFromROOTFile:

Public Types

typedef std::vector< longlongint >::size_type SavedPosition

Public Member Functions

 InputStreamFromROOTFile ()
 Default constructor.
virtual Succeeded get_next_record (CListRecordROOT &record)=0
Succeeded reset ()
 Go to the first event.
virtual Succeeded set_up (const std::string &header_path)
 Must be called before calling for the first event.
SavedPosition save_get_position ()
 Save current position in a vector.
Succeeded set_get_position (const SavedPosition &)
 Set current position.
std::vector< unsigned long int > get_saved_get_positions () const
 Get the vector with the saved positions.
void set_saved_get_positions (const std::vector< unsigned long int > &)
 Set a vector with saved positions.
unsigned long int get_total_number_of_events () const
 Returns the total number of events.
std::string get_ROOT_filename () const
virtual int get_num_rings () const =0
 Get the number of rings as calculated from the number of repeaters.
virtual int get_num_dets_per_ring () const =0
 Get the number of dets per ring as calculated from the number of repeaters.
virtual int get_num_axial_blocks_per_bucket_v () const =0
 Get the number of axial modules.
virtual int get_num_transaxial_blocks_per_bucket_v () const =0
 Get the number of transaxial modules.
int get_num_axial_crystals_per_block_v () const
 Get the axial number of crystals per module.
int get_num_transaxial_crystals_per_block_v () const
 Get the transaxial number of crystals per module.
virtual int get_num_axial_crystals_per_singles_unit () const =0
 Get the number of axial crystals per singles unit.
virtual int get_num_trans_crystals_per_singles_unit () const =0
 Get the number of transaxial crystals per singles unit.
Public Member Functions inherited from stir::RegisteredObjectBase
virtual std::string get_registered_name () const =0
 Returns the name of the type of the object.
Public Member Functions inherited from stir::ParsingObject
 ParsingObject (const ParsingObject &)
ParsingObject & operator= (const ParsingObject &)
bool parse (std::istream &f)
bool parse (const char *const filename)
void ask_parameters ()
virtual std::string parameter_info ()

Protected Attributes

repeaters
int crystal_repeater_x
int crystal_repeater_y
int crystal_repeater_z
ROOT Variables, i.e. to hold data from each entry.
TChain * stream_ptr
std::int32_t eventID1
std::int32_t eventID2
std::int32_t runID
std::int32_t sourceID1
std::int32_t sourceID2
double time1
double time2
float energy1
float energy2
float rotation_angle
float sinogramS
float sinogramTheta
float axialPos
int32_t comptonphantom1
int32_t comptonphantom2
float globalPosX1
float globalPosX2
float globalPosY1
float globalPosY2
float globalPosZ1
float globalPosZ2
float sourcePosX1
float sourcePosX2
float sourcePosY1
float sourcePosY2
float sourcePosZ1
float sourcePosZ2
ROOT Branch address variables.
TBranch * br_time1 = nullptr
TBranch * br_time2 = nullptr
TBranch * br_eventID1 = nullptr
TBranch * br_eventID2 = nullptr
TBranch * br_energy1 = nullptr
TBranch * br_energy2 = nullptr
TBranch * br_comptonPhantom1 = nullptr
TBranch * br_comptonPhantom2 = nullptr
TBranch * br_axialPos = nullptr
TBranch * br_globalPosX1 = nullptr
TBranch * br_globalPosX2 = nullptr
TBranch * br_globalPosY1 = nullptr
TBranch * br_globalPosY2 = nullptr
TBranch * br_globalPosZ1 = nullptr
TBranch * br_globalPosZ2 = nullptr
TBranch * br_rotation_angle = nullptr
TBranch * br_runID = nullptr
TBranch * br_sinogramS = nullptr
TBranch * br_sinogramTheta = nullptr
TBranch * br_sourceID1 = nullptr
TBranch * br_sourceID2 = nullptr
TBranch * br_sourcePosX1 = nullptr
TBranch * br_sourcePosX2 = nullptr
TBranch * br_sourcePosY1 = nullptr
TBranch * br_sourcePosY2 = nullptr
TBranch * br_sourcePosZ1 = nullptr
TBranch * br_sourcePosZ2 = nullptr
KeyParser parser

number of "fake" crystals per block, inserted by the scanner

std::string filename
 Input data file name.
unsigned long int starting_stream_position
 The starting position.
unsigned long int nentries
 The total number of entries.
unsigned long int current_position
 Current get position.
std::vector< unsigned long int > saved_get_positions
 A vector with saved position indices.
std::string chain_name
 The name of the ROOT chain to be read.
bool read_optional_root_fields
 This variable can be used to setBranchAddress to ROOT fields that currently are not used by STIR. Because they might be related to medical image reconstruction or because STIR does not support a relevant use. Of course, just activating this flag does not mean that something meaningfull will happen. Please edit get_next_record() function accordingly.
int num_virtual_axial_crystals_per_block
int num_virtual_transaxial_crystals_per_block
bool exclude_nonrandom
 Skip True events (eventID1 == eventID2). Default is false.
bool exclude_scattered
 Skip scattered events (comptonphantom1 > 0 && comptonphantom2 > 0). Default is false.
bool exclude_unscattered
 Skip unscattered events (comptonphantom1 == 0 && comptonphantom2 == 0)). Default is false.
bool exclude_randoms
 Skip random events (eventID1 != eventID2). Default is false.
bool check_energy_window_information
 Check energy window information (low_energy_window < energy < up_energy_window). Default is true.
float low_energy_window
 Lower energy threshold. Default is 1000 (keV).
float up_energy_window
 Upper energy threshold. Default is 0 (keV).
int singles_readout_depth
 For the singles_readout_depth from GATE's online documentation: (here ).
double least_significant_clock_bit
int get_num_virtual_axial_crystals_per_block () const
int get_num_virtual_transaxial_crystals_per_block () const
void set_num_virtual_axial_crystals_per_block (int)
void set_num_virtual_transaxial_crystals_per_block (int)
float get_low_energy_thres () const
 Lower energy threshold.
float get_up_energy_thres () const
 Upper energy threshold.
void set_singles_readout_depth (int)
 Set singles_readout_depth.
void set_input_filename (const std::string &)
void set_chain_name (const std::string &)
void set_exclude_true_events (bool)
void set_exclude_scattered_events (bool)
void set_exclude_unscattered_events (bool)
void set_exclude_random_events (bool)
void set_low_energy_window (float)
void set_upper_energy_window (float)
void set_optional_ROOT_fields (bool)
 Set the read_optional_root_fields flag.
void set_crystal_repeater_x (int)
void set_crystal_repeater_y (int)
void set_crystal_repeater_z (int)
void set_defaults () override
 Set defaults before parsing.
void initialise_keymap () override
 Initialise all keywords.
bool post_processing () override
 This will be called at the end of the parsing.
float get_energy1_in_keV () const
 OpenGATE output ROOT energy information is given in MeV, these methods convert to keV.
float get_energy2_in_keV () const
bool check_brentry_randoms_scatter_energy_conditions (long long int brentry)
 Checks brentry satisfies the randoms, scatter and energy conditions.
void GetEntryCheck (const int ret)
 Checks the return of branch->GetEntry(brentry) and errors if return <= 0.

Additional Inherited Members

Static Public Member Functions inherited from stir::RegisteredObject< InputStreamFromROOTFile >
static InputStreamFromROOTFile * read_registered_object (std::istream *in, const std::string &registered_name)
 Construct a new object (of a type derived from Root, its actual type determined by the registered_name parameter) by parsing the istream.
static InputStreamFromROOTFile * ask_type_and_parameters ()
 ask the user for the type, and then calls read_registered_object(0, type)
static void list_registered_names (std::ostream &stream)
 List all possible registered names to the stream.
Protected Types inherited from stir::RegisteredObject< InputStreamFromROOTFile >
typedef InputStreamFromROOTFile *(*) RootFactory(std::istream *)
 The type of a root factory is a function, taking an istream* as argument, and returning a Root*.
typedef FactoryRegistry< std::string, RootFactory, interfile_less > RegistryType
 The type of the registry.
virtual void set_key_values ()
 This will be called before parsing or parameter_info is called.
Static Protected Member Functions inherited from stir::RegisteredObject< InputStreamFromROOTFile >
static RegistryType & registry ()
 Static function returning the registry.

Detailed Description

A helper class to read data from a ROOT file Generated by GATE simulation toolkit.

Author
Nikos Efthimiou

This is an abstract base class for inputs from ROOT files. Primarily, information not related to the scanner's geometry is held here. InputStreamFromROOTFileForCylindricalPET is for cylindrical PET scanners (here ) and InputStreamFromROOTFileForECAT is for ECAT PET scanners (here ).

The follow bit of the header file refers to members stored here. For appropriate values please check your simulation macro file. For the singles_readout_depth from GATE's online documentation: (here )

the readout depth depends upon how the electronic readout functions.

    name of data file := ${INPUT_ROOT_FILE}
    name of input TChain := Coincidences
    Singles readout depth := 1
    exclude scattered events := ${EXCLUDE_SCATTERED}
    exclude random events := ${EXCLUDE_RANDOM}
    low energy window (keV) := 0
    upper energy window (keV):= 10000
Warning
The initial validation of the ROOT input was done with version 5.34.

Constructor & Destructor Documentation

◆ InputStreamFromROOTFile()

stir::InputStreamFromROOTFile::InputStreamFromROOTFile ( )

Default constructor.

References InputStreamFromROOTFile(), reset(), and set_defaults().

Referenced by InputStreamFromROOTFile().

Member Function Documentation

◆ get_next_record()

virtual Succeeded stir::InputStreamFromROOTFile::get_next_record ( CListRecordROOT & record)
pure virtual

Returns the next record in the ROOT file. The code is adapted from Sadek A. Nehmeh and CR Schmidtlein, downloaded from here

Implemented in stir::InputStreamFromROOTFileForCylindricalPET, and stir::InputStreamFromROOTFileForECATPET.

References get_saved_get_positions(), get_total_number_of_events(), reset(), save_get_position(), set_get_position(), set_saved_get_positions(), and set_up().

◆ reset()

Succeeded stir::InputStreamFromROOTFile::reset ( )
inline

Go to the first event.

References current_position, reset(), and starting_stream_position.

Referenced by get_next_record(), InputStreamFromROOTFile(), and reset().

◆ set_up()

◆ save_get_position()

InputStreamFromROOTFile::SavedPosition stir::InputStreamFromROOTFile::save_get_position ( )
inline

Save current position in a vector.

References current_position, nentries, save_get_position(), and saved_get_positions.

Referenced by get_next_record(), and save_get_position().

◆ set_get_position()

Succeeded stir::InputStreamFromROOTFile::set_get_position ( const SavedPosition & pos)
inline

Set current position.

References current_position, nentries, saved_get_positions, and set_get_position().

Referenced by get_next_record(), and set_get_position().

◆ get_saved_get_positions()

std::vector< unsigned long int > stir::InputStreamFromROOTFile::get_saved_get_positions ( ) const
inline

Get the vector with the saved positions.

References get_saved_get_positions(), and saved_get_positions.

Referenced by get_next_record(), and get_saved_get_positions().

◆ set_saved_get_positions()

void stir::InputStreamFromROOTFile::set_saved_get_positions ( const std::vector< unsigned long int > & )
inline

Set a vector with saved positions.

References saved_get_positions, and set_saved_get_positions().

Referenced by get_next_record(), and set_saved_get_positions().

◆ get_total_number_of_events()

unsigned long int stir::InputStreamFromROOTFile::get_total_number_of_events ( ) const
inline

Returns the total number of events.

References get_total_number_of_events(), and nentries.

Referenced by get_next_record(), and get_total_number_of_events().

◆ get_num_rings()

virtual int stir::InputStreamFromROOTFile::get_num_rings ( ) const
pure virtual

Get the number of rings as calculated from the number of repeaters.

Implemented in stir::InputStreamFromROOTFileForCylindricalPET, and stir::InputStreamFromROOTFileForECATPET.

◆ get_num_dets_per_ring()

virtual int stir::InputStreamFromROOTFile::get_num_dets_per_ring ( ) const
pure virtual

Get the number of dets per ring as calculated from the number of repeaters.

Implemented in stir::InputStreamFromROOTFileForCylindricalPET, and stir::InputStreamFromROOTFileForECATPET.

◆ get_num_axial_blocks_per_bucket_v()

virtual int stir::InputStreamFromROOTFile::get_num_axial_blocks_per_bucket_v ( ) const
pure virtual

Get the number of axial modules.

Implemented in stir::InputStreamFromROOTFileForCylindricalPET, and stir::InputStreamFromROOTFileForECATPET.

◆ get_num_transaxial_blocks_per_bucket_v()

virtual int stir::InputStreamFromROOTFile::get_num_transaxial_blocks_per_bucket_v ( ) const
pure virtual

◆ get_num_axial_crystals_per_block_v()

int stir::InputStreamFromROOTFile::get_num_axial_crystals_per_block_v ( ) const
inline

◆ get_num_transaxial_crystals_per_block_v()

int stir::InputStreamFromROOTFile::get_num_transaxial_crystals_per_block_v ( ) const
inline

◆ get_num_axial_crystals_per_singles_unit()

virtual int stir::InputStreamFromROOTFile::get_num_axial_crystals_per_singles_unit ( ) const
pure virtual

Get the number of axial crystals per singles unit.

Implemented in stir::InputStreamFromROOTFileForCylindricalPET, and stir::InputStreamFromROOTFileForECATPET.

◆ get_num_trans_crystals_per_singles_unit()

virtual int stir::InputStreamFromROOTFile::get_num_trans_crystals_per_singles_unit ( ) const
pure virtual

◆ get_num_virtual_axial_crystals_per_block()

int stir::InputStreamFromROOTFile::get_num_virtual_axial_crystals_per_block ( ) const
inline

Some scanners (including many Siemens scanners) insert virtual crystals in the sinogram data. The other members of the class return the size of the "virtual" block. With these functions you can find its true size (or set it).

References get_num_virtual_axial_crystals_per_block().

Referenced by get_num_trans_crystals_per_singles_unit(), and get_num_virtual_axial_crystals_per_block().

◆ get_low_energy_thres()

float stir::InputStreamFromROOTFile::get_low_energy_thres ( ) const
inline

◆ get_up_energy_thres()

float stir::InputStreamFromROOTFile::get_up_energy_thres ( ) const
inline

Upper energy threshold.

References get_up_energy_thres(), and up_energy_window.

Referenced by get_num_trans_crystals_per_singles_unit(), and get_up_energy_thres().

◆ set_singles_readout_depth()

void stir::InputStreamFromROOTFile::set_singles_readout_depth ( int val)
inline

◆ set_optional_ROOT_fields()

void stir::InputStreamFromROOTFile::set_optional_ROOT_fields ( bool val)
inline

Set the read_optional_root_fields flag.

References read_optional_root_fields, and set_optional_ROOT_fields().

Referenced by get_num_trans_crystals_per_singles_unit(), and set_optional_ROOT_fields().

◆ set_defaults()

◆ initialise_keymap()

◆ post_processing()

bool stir::InputStreamFromROOTFile::post_processing ( )
overrideprotectedvirtual

This will be called at the end of the parsing.

Returns
false if everything OK, true if not

Reimplemented from stir::ParsingObject.

Reimplemented in stir::InputStreamFromROOTFileForCylindricalPET, and stir::InputStreamFromROOTFileForECATPET.

Referenced by get_num_trans_crystals_per_singles_unit(), and stir::InputStreamFromROOTFileForCylindricalPET::post_processing().

◆ get_energy1_in_keV()

float stir::InputStreamFromROOTFile::get_energy1_in_keV ( ) const
inlineprotected

OpenGATE output ROOT energy information is given in MeV, these methods convert to keV.

Referenced by check_brentry_randoms_scatter_energy_conditions().

◆ check_brentry_randoms_scatter_energy_conditions()

bool stir::InputStreamFromROOTFile::check_brentry_randoms_scatter_energy_conditions ( long long int brentry)
protected

◆ GetEntryCheck()

void stir::InputStreamFromROOTFile::GetEntryCheck ( const int ret)
inlineprotected

Member Data Documentation

◆ filename

std::string stir::InputStreamFromROOTFile::filename
protected

Input data file name.

Referenced by initialise_keymap(), and set_up().

◆ starting_stream_position

unsigned long int stir::InputStreamFromROOTFile::starting_stream_position
protected

The starting position.

Referenced by reset(), and set_defaults().

◆ nentries

◆ current_position

unsigned long int stir::InputStreamFromROOTFile::current_position
protected

◆ saved_get_positions

std::vector<unsigned long int> stir::InputStreamFromROOTFile::saved_get_positions
protected

A vector with saved position indices.

Referenced by get_saved_get_positions(), save_get_position(), set_get_position(), and set_saved_get_positions().

◆ chain_name

std::string stir::InputStreamFromROOTFile::chain_name
protected

The name of the ROOT chain to be read.

Referenced by initialise_keymap(), and set_up().

◆ read_optional_root_fields

bool stir::InputStreamFromROOTFile::read_optional_root_fields
protected

This variable can be used to setBranchAddress to ROOT fields that currently are not used by STIR. Because they might be related to medical image reconstruction or because STIR does not support a relevant use. Of course, just activating this flag does not mean that something meaningfull will happen. Please edit get_next_record() function accordingly.

Referenced by initialise_keymap(), set_defaults(), set_optional_ROOT_fields(), and set_up().

◆ exclude_nonrandom

bool stir::InputStreamFromROOTFile::exclude_nonrandom
protected

Skip True events (eventID1 == eventID2). Default is false.

Referenced by check_brentry_randoms_scatter_energy_conditions(), initialise_keymap(), set_defaults(), and set_up().

◆ exclude_scattered

bool stir::InputStreamFromROOTFile::exclude_scattered
protected

Skip scattered events (comptonphantom1 > 0 && comptonphantom2 > 0). Default is false.

Referenced by check_brentry_randoms_scatter_energy_conditions(), initialise_keymap(), set_defaults(), and set_up().

◆ exclude_unscattered

bool stir::InputStreamFromROOTFile::exclude_unscattered
protected

Skip unscattered events (comptonphantom1 == 0 && comptonphantom2 == 0)). Default is false.

Referenced by check_brentry_randoms_scatter_energy_conditions(), initialise_keymap(), set_defaults(), and set_up().

◆ exclude_randoms

bool stir::InputStreamFromROOTFile::exclude_randoms
protected

Skip random events (eventID1 != eventID2). Default is false.

Referenced by check_brentry_randoms_scatter_energy_conditions(), initialise_keymap(), set_defaults(), and set_up().

◆ check_energy_window_information

bool stir::InputStreamFromROOTFile::check_energy_window_information
protected

Check energy window information (low_energy_window < energy < up_energy_window). Default is true.

Referenced by check_brentry_randoms_scatter_energy_conditions(), initialise_keymap(), and set_defaults().

◆ low_energy_window

float stir::InputStreamFromROOTFile::low_energy_window
protected

Lower energy threshold. Default is 1000 (keV).

Referenced by check_brentry_randoms_scatter_energy_conditions(), get_low_energy_thres(), initialise_keymap(), and set_defaults().

◆ up_energy_window

float stir::InputStreamFromROOTFile::up_energy_window
protected

Upper energy threshold. Default is 0 (keV).

Referenced by check_brentry_randoms_scatter_energy_conditions(), get_up_energy_thres(), initialise_keymap(), and set_defaults().

◆ singles_readout_depth

int stir::InputStreamFromROOTFile::singles_readout_depth
protected

For the singles_readout_depth from GATE's online documentation: (here ).

the readout depth depends upon how the electronic readout functions.

Referenced by stir::InputStreamFromROOTFileForCylindricalPET::get_num_axial_crystals_per_singles_unit(), stir::InputStreamFromROOTFileForCylindricalPET::get_num_trans_crystals_per_singles_unit(), initialise_keymap(), set_defaults(), and set_singles_readout_depth().


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