gparticle
Loading...
Searching...
No Matches
GParticleReader Class Referenceabstract

Abstract base class for gparticle file readers. More...

#include <gparticle_reader.h>

Public Member Functions

 GParticleReader (const std::shared_ptr< GOptions > &gopts)
 Constructs a reader with the shared options container.
 
 ~GParticleReader () override=default
 Virtual destructor for plugin use through base pointers.
 
virtual std::vector< GparticlePtrloadParticles (const GParticleSourceDefinition &source, const std::shared_ptr< GLogger > &logger)=0
 Loads all propagated particles as one flattened list.
 
virtual GParticleEvents loadParticleEvents (const GParticleSourceDefinition &source, const std::shared_ptr< GLogger > &logger, bool propagated_only=true)
 Loads file-backed events as Gparticle objects.
 
virtual GParticleRecordEvents loadParticleRecordEvents (const GParticleSourceDefinition &source, const std::shared_ptr< GLogger > &logger)
 Loads file-backed events as output-bank records.
 
void set_loggers (const std::shared_ptr< GOptions > &gopts)
 Reader plugins currently share the base logger setup.
 
- Public Member Functions inherited from GBase< GParticleReader >
 GBase (const std::shared_ptr< GOptions > &gopt, std::string logger_name="")
 
 GBase (const std::shared_ptr< GLogger > &logger)
 
 GBase (const GBase &)=default
 
 GBase (GBase &&) noexcept=default
 
virtual ~GBase ()
 
GBaseoperator= (const GBase &)=default
 
GBaseoperator= (GBase &&) noexcept=default
 

Static Public Member Functions

static GParticleReaderinstantiate (dlhandle h, std::shared_ptr< GOptions > gopts)
 Instantiates a dynamic reader plugin from a library handle.
 

Additional Inherited Members

- Protected Attributes inherited from GBase< GParticleReader >
std::shared_ptr< GLoggerlog
 

Detailed Description

Reader plugins translate file-backed generator input into two related views:

  • GParticleEvents for particles that are propagated to Geant4.
  • GParticleRecordEvents for generated-particle output banks, including particles that cannot or should not be propagated.

Built-in and dynamic readers share the same factory contract through GBase and instantiate().

Definition at line 138 of file gparticle_reader.h.

Constructor & Destructor Documentation

◆ GParticleReader()

GParticleReader::GParticleReader ( const std::shared_ptr< GOptions > & gopts)
explicit
Parameters
goptsParsed options used by base logging and derived readers.

Definition at line 14 of file gparticle_reader.cc.

◆ ~GParticleReader()

GParticleReader::~GParticleReader ( )
overridedefault

Member Function Documentation

◆ instantiate()

GParticleReader * GParticleReader::instantiate ( dlhandle h,
std::shared_ptr< GOptions > gopts )
static

The plugin must export GParticleReaderFactory.

Parameters
hDynamic library handle.
goptsParsed options passed to the plugin factory.
Returns
Newly allocated reader instance owned by the caller.

Definition at line 53 of file gparticle_reader.cc.

◆ loadParticleEvents()

GParticleEvents GParticleReader::loadParticleEvents ( const GParticleSourceDefinition & source,
const std::shared_ptr< GLogger > & logger,
bool propagated_only = true )
virtual

Readers should return only rows that can be represented as Gparticle objects and shot by Geant4 when propagated_only is true. Formats that carry a source type field may include additional rows when propagated_only is false, provided those rows are still valid Geant4 particles.

Parameters
sourceSource definition to read.
loggerLogger used for diagnostics.
propagated_onlyWhether to restrict the result to particles propagated in Geant4.
Returns
File-backed generated events as Geant4-shootable particles.

Reimplemented in GParticleLundReader.

Definition at line 17 of file gparticle_reader.cc.

◆ loadParticleRecordEvents()

GParticleRecordEvents GParticleReader::loadParticleRecordEvents ( const GParticleSourceDefinition & source,
const std::shared_ptr< GLogger > & logger )
virtual

This view preserves all generator rows that can be parsed from the source file, including rows that are not propagated in Geant4 and rows whose ids are not known to G4ParticleTable.

Parameters
sourceSource definition to read.
loggerLogger used for diagnostics.
Returns
File-backed generated events as serialization records.

Reimplemented in GParticleLundReader.

Definition at line 26 of file gparticle_reader.cc.

◆ loadParticles()

virtual std::vector< GparticlePtr > GParticleReader::loadParticles ( const GParticleSourceDefinition & source,
const std::shared_ptr< GLogger > & logger )
pure virtual

This legacy view is equivalent to flattening loadParticleEvents() with the default propagated-only behavior.

Parameters
sourceSource definition to read.
loggerLogger used for diagnostics.
Returns
Vector of Geant4-propagated particles.

Implemented in GParticleLundReader.

◆ set_loggers()

void GParticleReader::set_loggers ( const std::shared_ptr< GOptions > & gopts)
inline

Definition at line 197 of file gparticle_reader.h.


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