### VCOptions Input Configuration Example Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/classvolcor_1_1VCOptions.html Example of the input block format required for initializing volume correction parameters. ```text :start region discovery: action = discovery # discover, discover and correct volume, discover and zero volume density of random points (cm^-3) = 1E6 # Defaults to 1E8 :start shape: type = cylinder radius = 0.04 height = 0.45 # volume = 123456 # use volume key for shapes other than cylinder, sphere, or box :stop shape: :stop region discovery: ``` -------------------------------- ### Simple Example Usage Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/classEGS__CollimatedSource.html A simple, concrete example demonstrating the configuration of an EGS_CollimatedSource. ```APIDOC ## A simple example: ``` :start source definition: :start source: library = egs_collimated_source name = my_source :start source shape: type = point position = 0 0 5 :stop source shape: :start target shape: library = egs_rectangle rectangle = -1 -1 1 1 :stop target shape: distance = 5 charge = -1 :start spectrum: type = monoenergetic energy = 20 :stop spectrum: :stop source: simulation source = my_source :stop source definition: ``` ``` -------------------------------- ### Example source definition block Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/classIAEA__PhspSource.html A practical example of setting up a source definition block for a simulation. ```text :start source definition: :start source: name = my_source library = iaea_phsp_source iaea phase space file = your phase space file (no extension) particle type = all cutout = -1 1 -2 2 recycle photons = 10 recycle electrons = 10 :stop source: simulation source = my_source :stop source definition: ``` -------------------------------- ### Example Prism Definition Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/classEGS__PrismT.html A practical example demonstrating how to define a prism geometry in the configuration file. ```APIDOC ### Example ``` :start geometry definition: :start geometry: name = my_prism library = egs_prism type = EGS_PrismZ points = 1 1 -1 1 -1 -1 4 -1 closed = 1 4 :start media input: media = water :stop media input: :stop geometry: simulation geometry = my_prism :stop geometry definition: ``` ``` -------------------------------- ### Simple Phase-Space Source Example Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/classEGS__PhspSource.html A basic example demonstrating how to set up a phase-space source named 'my_source' using a specific .egsphsp file and defining cutout and recycling parameters. ```plaintext :start source definition: :start source: name = my_source library = egs_phsp_source phase space file = ../BEAM_EX16MVp/EX16MVp.egsphsp1 particle type = all cutout = -1 1 -2 2 recycle photons = 10 recycle electrons = 10 :stop source: simulation source = my_source :stop source definition: ``` -------------------------------- ### Complete CD Geometry Configuration Example Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/classEGS__CDGeometry.html A full example showing the definition of base geometries and their integration into a composite CD geometry. ```text :start geometry definition: # The base geometry, this will be the Chopping Device (CD) # The base geometry can be any geometry, even a composite one :start geometry: name = my_cd_planes library = egs_planes type = EGS_Zplanes positions = -3 3 5 # No media required :stop geometry: :start geometry: name = my_cd_cylinder library = egs_cylinders type = EGS_ZCylinders radii = 1.6 2 :start media input: media = air water set medium = 1 1 :stop media input: :stop geometry: :start geometry: name = my_cd_sphere library = egs_spheres midpoint = 0 0 3 radii = 1.6 2 :start media input: media = air water set medium = 1 1 :stop media input: :stop geometry: # The composite geometry :start geometry: name = my_cd library = egs_cdgeometry base geometry = my_cd_planes # set geometry = 1 geom means: # "in region 1 of the basegeometry, use geometry "geom" set geometry = 0 my_cd_cylinder set geometry = 1 my_cd_sphere # The final region numbers are attributed by the cd geometry object; # Use the viewer to determine region numbers :stop geometry: simulation geometry = my_cd :stop geometry definition: ``` -------------------------------- ### Example Dynamic Source Configuration Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/classEGS__DynamicSource.html A complete example defining a parallel beam source and applying dynamic motion through four control points. ```text :start source definition: :start source: library = egs_parallel_beam name = my_parallel_source :start shape: library = egs_rectangle rectangle = -.1 -.1 .1 .1 :stop shape: direction = 0 0 1 charge = 0 :start spectrum: type = monoenergetic energy = 1.0 :stop spectrum: :stop source: :start source: library = egs_dynamic_source name = my_source source name = my_parallel_source :start motion: control point = 0 0 0 100 0 0 0 0 control point = 0 0 0 100 360 0 0 0.5 control point = 0 0 0 100 90 0 0 0.5 control point = 0 0 0 100 90 360 0 1.0 :stop motion: :stop source: simulation source = my_source :stop source definition: ``` -------------------------------- ### Example source collection configuration Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/classEGS__SourceCollection.html A complete example showing the definition of two point sources and their combination into a single source collection. ```text :start source definition: :start source: library = egs_point_source name = p1 position = -2 0 0 :start spectrum: type = monoenergetic energy = 1 :stop spectrum: charge = 0 :stop source: :start source: library = egs_point_source name = p2 position = 2 0 0 :start spectrum: type = monoenergetic energy = 1 :stop spectrum: charge = 0 :stop source: :start source: library = egs_source_collection name = my_source source names = p1 p2 weights = 0.1 0.9 :stop source: simulation source = my_source :stop source definition: ``` -------------------------------- ### EGS Fano Source Setup Function Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/egs__fano__source_8cpp_source.html The setUp function initializes the Fano source's properties, including its object type, description, and physical characteristics based on input parameters and associated objects. ```cpp void EGS_FanoSource::setUp() { otype = "EGS_FanoSource"; if (!isValid()) { description = "Invalid Fano source"; } else { description = "Fano source from a shape of type "; description += shape->getObjectType(); description += " with "; description += s->getType(); if (q == -1) { description += ", electrons"; } else if (q == 0) { description += ", photons"; } else if (q == 1) { description += ", positrons"; } else { description += ", unknown particle type"; } ostringstream str_density; str_density << scientific << max_mass_density; description += "\n maximum density = " + str_density.str() + " g/cm3"; description += "\n Fano geometry = " + geom->getName(); if (geom) { geom->ref(); } } } ``` -------------------------------- ### Setup XYZ Geometry Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/classEGS__DeformedXYZ.html Performs setup operations for an XYZ geometry. This is a member function of EGS_XYZGeometry. ```cpp void | **setup** () ``` -------------------------------- ### Example Input: Monoenergetic Photon Beam Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs3100/index.html An example input file configuration for the 'g' application, setting up a monoenergetic 30 keV photon beam with verbose output and a desired precision. ```plaintext # Example input file for the g application: # # - Monoenergetic 30 keV photon beam # - Calculation type 1 (photon beam only) # - Verbose output # - Desired precision 0.1% # ########################################### ############################## ``` -------------------------------- ### EGS_BeamSource Configuration Example Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/classEGS__BeamSource.html This example demonstrates how to define an EGS_BeamSource in an input file, specifying the library, beam code, PEGS file, input file, and particle type. ```input :start source definition: :start source: library = egs_beam_source name = my_source beam code = BEAM_EX10MeVe pegs file = 521icru input file = EX10MeVe particle type = all :stop source: simulation source = my_source :stop source definition: ``` -------------------------------- ### Simple EGS Point Source Example Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/classEGS__PointSource.html A basic example demonstrating the configuration of a point source named 'my_source' at the origin with a monoenergetic spectrum. ```plaintext :start source definition: :start source: library = egs_point_source name = my_source position = 0 0 0 :start spectrum: type = monoenergetic energy = 1 :stop spectrum: charge = 0 :stop source: simulation source = my_source :stop source definition: ``` -------------------------------- ### EGS_SourceCollection Constructor and Setup Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/egs__source__collection_8cpp_source.html Details the constructor for EGS_SourceCollection, which initializes sources from input and sets up weights. It also includes the setUp method for configuring the source collection. ```APIDOC ## EGS_SourceCollection Constructor and Setup ### Description This section describes the constructor of the `EGS_SourceCollection` class and its associated `setUp` method. The constructor initializes the source collection by reading source definitions and their corresponding weights from an input object. It supports creating sources directly from input items or by referencing existing sources by name. The `setUp` method then finalizes the initialization using the provided sources and probabilities. ### Method `EGS_SourceCollection::EGS_SourceCollection(EGS_Input *input, EGS_ObjectFactory *f)` `void EGS_SourceCollection::setUp(const vector &S, const vector &prob)` ### Parameters #### Constructor Parameters - **input** (EGS_Input *) - Pointer to the input object containing source definitions and weights. - **f** (EGS_ObjectFactory *) - Pointer to the object factory. #### setUp Parameters - **S** (const vector &) - A vector of pointers to `EGS_BaseSource` objects. - **prob** (const vector &) - A vector of weights corresponding to each source in `S`. ### Request Body (Not applicable for constructor and setup methods, as they operate on provided parameters and input objects) ### Response (Not applicable for constructor and setup methods) ### Error Handling - Warnings are issued if no sources are found, if source names are missing, or if the number of sources does not match the number of provided weights. ``` -------------------------------- ### EGSnrc Class Library - Specific Class Members (Example: 'g') Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/functions_vars_g.html This snippet shows an example of how class members are listed alphabetically, focusing on members starting with 'g'. ```APIDOC ## Class Members starting with 'g' ### Classes - EGS_DynamicGeometry - EGS_EnvelopeGeometry - EGS_FastEnvelope - EGS_NDGeometry - EGS_SimpleApplication - EGS_SmartEnvelope - EGS_TransformedGeometry - EGS_UnionGeometry ### Related Terms - **gap**: EGS_Hexagonal_Lattice - **geometries**: EGS_EnvelopeGeometry, EGS_FastEnvelope, EGS_SmartEnvelope - **geometry**: EGS_Application - **gindex**: EGS_SmartEnvelope - **gle**: EGS_Epcont ``` -------------------------------- ### Set Up Source Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/classEGS__DynamicSource.html Performs internal setup operations for the source. This function should be called before generating particles. ```cpp void setUp () ``` -------------------------------- ### Get Host Name Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/egs__functions_8cpp_source.html Retrieves the name of the host machine where the program is running. Requires no special setup. ```cpp string egsHostName() { #ifdef WIN32 char buf[1024]; if (gethostname(buf,1023) != 0) { return "unknown"; } return buf; #else char buf[1024]; int err = gethostname(buf,1023); if (err) { return "unknown"; } return buf; #endif } ``` -------------------------------- ### egsCpuTime Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/egs__interface2_8h.html Gets the CPU time used since the process started. For C++ applications, using an EGS_Timer object is recommended. ```APIDOC ## egsCpuTime ### Description Get the CPU time used since the process started. ### Method EGS_Float ### Endpoint N/A (Function call) ### Parameters None ### Request Example N/A ### Response CPU time used (EGS_Float) ### Notes A better way to measure the CPU time in C++ applications is to use an EGS_Timer object. Shorthand notation for the `egs_etime` mortran function. Definition at line 847 of file egs_interface2.h. ``` -------------------------------- ### startSimulation() Method Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/classEGS__RunControl.html Initiates the simulation process. Returns status codes indicating success, completion without running histories, or errors. ```APIDOC ## Member Function Documentation ## ◆ startSimulation() | int EGS_RunControl::startSimulation | ( | | ) | --- virtual Starts the simulation. Returns zero if the simulation was successfully started, a positive value if no error occured but no histories are to be run (e.g. combine and analyze runs) and a negative value if some error occured. Definition at line 185 of file egs_run_control.cpp. References EGS_Application::combineResults(), EGS_Application::describeSimulation(), egsInformation, EGS_Application::readData(), and EGS_Timer::start(). ``` -------------------------------- ### EGS_ASwitchedEnvelope Usage Example Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/classEGS__ASwitchedEnvelope.html Demonstrates how to get an EGS_ASwitchedEnvelope geometry and manipulate its active inscribed geometries using various methods. ```cpp EGS_BaseGeometry *tmp_switch = EGS_BaseGeometry::getGeometry(your_geom_name); EGS_ASwitchedEnvelope *switched_geom = static_cast(tmp_switch); // activate only the ith geometry (deactivate the rest) switched_geom->setActiveByIndex(i); // add ith geometry to currently active list switched_geom->activateByIndex(i); // remove ith geometry from currently active list switched_geom->deactivateByIndex(i); // activate multipe geoms by index vector to_activate; to_activate.push_back(i); to_activate.push_back(j); switched_geom->setActiveGeometries(to_activate); // activate multipe geoms by pointer vector to_activate; to_activate.push_back(pointer_to_inscribed_i); to_activate.push_back(pointer_to_inscribed_j); switched_geom->setActiveGeometries(to_activate); // cycle through activating one geometry at a time // and deactivating the rest switched_geom->cycleActive(); switched_geom->cycleActive(); switched_geom->cycleActive(); ``` -------------------------------- ### Initialize and Run Application Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/tutor7pp_8cpp-example.html Initialize the application, handling potential errors, and then run the simulation. ```cpp int main(int argc, char* argv[]) { Tutor7_Application app(argc, argv); int error = app.Initialize(); if (error) return error; error = app.Run(); if (error) return error; return app.Finish(); } ``` -------------------------------- ### Get CPU Time Measurement Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/classEGS__Timer.html Returns the CPU time in seconds that has elapsed since the start() method was called. This provides the measured execution time. ```cpp EGS_Float time () ``` -------------------------------- ### Get Z Planes by Slabs Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/egs__rz_8cpp_source.html Calculates Z-plane positions based on the number of slabs and their thicknesses, starting from an initial Z-plane. Returns an empty vector on error. ```cpp vector EGS_RZ_LOCAL getZPlanesBySlabs(EGS_Input *input) { vector zplanes; EGS_Float zo = 0; int err = input->getInput("first plane", zo); if (err) { egasWarning("RZ: missing 'first plane' input. Assuming zo=0"); zo = 0; } vector nslabs; err = input->getInput("number of slabs", nslabs); if (err) { return zplanes; } vector thick; err = input->getInput("slab thickness", thick); if (err) { return zplanes; } EGS_Float cur_z = zo; zplanes.push_back(zo); for (size_t slab_group=0; slab_group < min(thick.size(), nslabs.size()); slab_group++) { for (int slab = 0; slab < nslabs[slab_group]; slab++) { cur_z += thick[slab_group]; zplanes.push_back(cur_z); } } return zplanes; } ``` -------------------------------- ### Initialize Application with Input Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/egs__advanced__application_8h_source.html Initializes the application with provided input parameters and a hatch flag. Used for setting up simulation configurations. ```cpp int helpInit(EGS_Input *, bool do_hatch); ``` -------------------------------- ### EGS_ParallelBeam::setUp() Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/egs__parallel__beam_8cpp_source.html Sets up the description string for the EGS_ParallelBeam object based on its properties. ```APIDOC ## EGS_ParallelBeam::setUp() ### Description This method configures the `description` member variable of the `EGS_ParallelBeam` object. It populates the description with information about the source's shape type, particle type, and validity status. ### Method void EGS_ParallelBeam::setUp() ### Endpoint (Not applicable for this method) ### Parameters (None) ### Request Body (Not applicable) ### Response (None - modifies internal state) ### Notes - Sets `description` to "Invalid parallel beam" if `isValid()` returns false. - Otherwise, appends the shape type, particle type (electrons, photons, positrons, or unknown), and other relevant details to the description. ``` -------------------------------- ### Start CPU Time Measurement Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/classEGS__Timer.html Starts the CPU time measurement for the EGS_Timer. Call this method before starting the code segment you want to time. ```cpp void start () ``` -------------------------------- ### Initialization and Setup Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/egs__interface2_8h_source.html Functions for initializing and configuring the EGSnrc simulation environment. ```APIDOC ## egsInit ### Description Initializes the EGSnrc mortran back-end. ### Method `void` ### Endpoint `egsInit(int argc, char **argv)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` ```APIDOC ## egsRandomInit ### Description Initializes the random number generator. ### Method `void` ### Endpoint `egsRandomInit()` ### Parameters None ### Request Example None ### Response None ``` ```APIDOC ## egsRandomDefaultInit ### Description Initialize the EGSnrc RNG using default values. ### Method `void` ### Endpoint `egsRandomDefaultInit()` ### Parameters None ### Request Example None ### Response None ``` ```APIDOC ## egsHatch ### Description Initialize cross section data from a PEGS4 data file. ### Method `void` ### Endpoint `egsHatch()` ### Parameters None ### Request Example None ### Response None ``` ```APIDOC ## egsAddMedium ### Description Adds a medium to the simulation. ### Method `void` ### Endpoint `egsAddMedium()` ### Parameters None ### Request Example None ### Response None ``` -------------------------------- ### EGS_TransformedSource Configuration Example Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/classEGS__TransformedSource.html Example configuration for an EGS_TransformedSource. ```APIDOC ## Configuration Example A transformed source is a source that takes a particle from any other source and then applies an affine transformation. ``` :start source: library = egs_transformed_source name = some_name source name = the name of a previously defined source :start transformation: input defining a transformation :stop transformation: :stop source: ``` See EGS_AffineTransform::getTransformation() for details on the definition of an affine transformation. A simple example: ``` :start source definition: :start source: library = egs_parallel_beam name = my_parallel_source :start shape: library = egs_rectangle rectangle = -.1 -.1 .1 .1 :stop shape: direction = 0 -1 0 charge = 0 :start spectrum: type = monoenergetic energy = 1.0 :stop spectrum: :stop source: :start source: library = egs_transformed_source name = my_source source name = my_parallel_source :start transformation: rotation vector = 0 -1 1 :stop transformation: :stop source: simulation source = my_source :stop source definition: ``` ``` -------------------------------- ### Example Input File Header Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/egs_kerma.html Initial lines of a sample input file for the egs_kerma application. ```text ############################################################################### # # A simple example input file for the egs_kerma C++ application. # # Simulates a point source at the origin of a 15 cm radius water sphere emitting ``` -------------------------------- ### EGSnrc C++ Class Library Examples Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/examples.html This section lists the available coding examples for the EGSnrc C++ class library. These examples demonstrate various functionalities and usage patterns. ```cpp // tutor7pp.cpp // Example for tutor7pp ``` ```cpp // geometry/egs_box/egs_box.cpp // Example for egs_box ``` ```cpp // sources/egs_point_source/egs_point_source.cpp // Example for egs_point_source ``` ```cpp // tutor2pp.cpp // Example for tutor2pp ``` -------------------------------- ### EGS_SimpleApplication Constructor Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/egs__simple__application_8h_source.html Initializes the EGS_SimpleApplication with command-line arguments. This is the entry point for setting up the simulation environment. ```cpp EGS_SimpleApplication(int argc, char **argv); ``` -------------------------------- ### Class Members Starting with 'o' Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/functions_vars_o.html Details on class members whose names start with the letter 'o'. ```APIDOC ## Class Members Starting with 'o' ### Description This section lists class members (objects, functions, etc.) within the EGSnrc C++ library that begin with the letter 'o'. ### Members - **objects**: EGS_ObjectFactory - **open**: EGS_PrismT< T >, EGS_PyramidT< T > - **opts**: EGS_AEnvelope - **ortho**: EGS_NDGeometry - **otype**: EGS_Object - **output_file**: EGS_Application ``` -------------------------------- ### Get Fluence from Transformed Source Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/classEGS__TransformedSource.html Get the fluence of the transformed source. This is a const method. ```cpp EGS_Float **getFluence** () const ``` -------------------------------- ### startBatch() Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/classEGS__RunControl.html Starts a new batch of simulations. Returns true to proceed or false to terminate. ```APIDOC ## startBatch() ### Description Start a new batch. This function is called from within the shower loop before starting each new batch. Returns `true`, if the simulation is to proceed, `false` if the simulation is to be terminated immediately. ### Method virtual ### Endpoint N/A (Class method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (bool) - **Return Value** (bool) - `true` if the simulation should proceed, `false` if the simulation should be terminated. #### Response Example ``` true ``` ``` -------------------------------- ### EGS_PointSource::setUp() Implementation Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/sources_2egs_point_source_2egs_point_source_8cpp-example.html Sets up the source type and description for an EGS_PointSource object. It initializes the type to 'EGS_PointSource' and sets a description based on validity and source properties. ```cpp void EGS_PointSource::setUp() { otype = "EGS_PointSource"; if (!isValid()) { description = "Invalid point source"; } } ``` -------------------------------- ### Start Particle Hatching Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/egs__interface2_8h_source.html Initiates the particle hatching process in EGSnrc. This is a core function for starting a simulation. ```c #define egsHatch F77_OBJ_(egs_hatch,EGS_HATCH) extern __extc__ void egsHatch(void); ``` -------------------------------- ### Example Geometry Definition Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/classEGS__TransformedGeometry.html A complete example showing the definition of a base box geometry and its subsequent transformation. ```text :start geometry definition: :start geometry: name = my_box library = egs_box box size = 1 2 3 :start media input: media = water :stop media input: :stop geometry: :start geometry: name = my_transform library = egs_gtransformed my geometry = my_box :start transformation: translation = 0 0.5 0 rotation = 0.5 0 -1 ## rotation is first! :stop transformation: :stop geometry: simulation geometry = my_transform :stop geometry definition: ``` -------------------------------- ### EGS_PointSource::setUp() Function Signature Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/sources_2egs_point_source_2egs_point_source_8cpp-example.html Declares the setUp function for the EGS_PointSource class, which is responsible for setting up the source type and description. ```cpp void setUp() Sets up the source type and description. **Definition:** egs_point_source.cpp:54 ``` -------------------------------- ### EGS_Pyramid Geometry Example Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/classEGS__PyramidT.html A simple example demonstrating the definition of a closed Z-pyramid geometry with media input. ```text :start geometry definition: :start geometry: name = my_pyramid library = egs_pyramid type = EGS_PyramidZ points = 1 1 -1 1 -1 -1 4 -1 tip = 0 0 2 closed = 1 :start media input: media = water :stop media input: :stop geometry: simulation geometry = my_pyramid :stop geometry definition: ``` -------------------------------- ### EGS_CollimatedSource Configuration Example Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/classEGS__CollimatedSource.html Example configuration block for defining an EGS_CollimatedSource within a simulation input file. ```APIDOC ## Detailed Description A collimated source is defined as follows: ``` :start source: library = egs_collimated_source name = some_name :start source shape: definition of the source shape :stop source shape: :start target shape: definition of the target shape :stop target shape: :start spectrum: definition of the spectrum :stop spectrum: distance = source-target shape min. distance charge = -1 or 0 or 1 for electrons or photons or positrons :stop source: ``` ``` -------------------------------- ### POST /simulation/start Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/egs__advanced__application_8cpp_source.html Starts the transport of a new particle in the simulation. ```APIDOC ## POST /simulation/start ### Description Starts the transport of a new particle within the EGS_AdvancedApplication context. ### Method POST ### Endpoint /simulation/start ``` -------------------------------- ### Setup Method for EGS_DynamicSource Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/egs__dynamic__source_8cpp_source.html Initializes the description for the EGS_DynamicSource object based on its validity and the description of the underlying source. It also indicates if the source will be synchronized with time values. ```cpp void EGS_DynamicSource::setUp() { //most setup done in constructor otype="EGS_DynamicSource"; if (!isValid()) { description = "Invalid dynamic source"; } else { description = "Dynamic source based on\n"; description += source->getSourceDescription(); if (sync) { description += "\n Source will be synched with time values read in (if available)."; } } } ``` -------------------------------- ### Get Medium Index by Name Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/classEGS__BaseGeometry.html Gets the index of a medium named _medname_. Returns -1 if the medium is not found. ```cpp int EGS_BaseGeometry::getMediumIndex ( const string & _medname_ ) ``` -------------------------------- ### Get Number of Geometries in EGS_BaseGeometry Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/classEGS__FastEnvelope-members.html A static method to get the total number of geometries currently managed by EGS_BaseGeometry. ```cpp getNGeometries() ``` -------------------------------- ### Start New Shower Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/egs__application_8h_source.html Virtual function to start a new particle shower simulation. Returns an integer status code. ```cpp virtual int startNewShower(); ``` -------------------------------- ### EGS_SimpleApplication egsHome() Method Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/classEGS__SimpleApplication.html Gets the EGS_HOME directory. ```cpp const char * EGS_SimpleApplication::egsHome ( ) const ``` -------------------------------- ### EGSnrc C++ Class Library Coding Examples Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/examples.html List of available coding examples for the EGSnrc C++ class library. ```APIDOC ## EGSnrc C++ Class Library Coding Examples ### Description This section lists the available coding examples that demonstrate the functionality and usage of the EGSnrc C++ class library. ### Examples - tutor7pp.cpp - geometry/egs_box/egs_box.cpp - sources/egs_point_source/egs_point_source.cpp - tutor2pp.cpp ``` -------------------------------- ### EGS_SourceCollection Setup Method Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/egs__source__collection_8cpp_source.html Configures the EGS_SourceCollection with a list of sources and their corresponding probabilities. Initializes internal structures for managing multiple sources. ```cpp void EGS_SourceCollection::setUp(const vector &S, const vector &prob) { otype = "EGS_SourceCollection"; nsource = S.size(); if (prob.size() < nsource) { nsource = prob.size(); } description = "Invalid source collection"; if (isValid()) { p = new EGS_Float [nsource]; ``` -------------------------------- ### Example parallel beam source definition Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/classEGS__ParallelBeam.html A concrete example of a monoenergetic parallel beam source using a cylindrical shape. ```text :start source definition: :start source: library = egs_parallel_beam name = my_source :start shape: type = cylinder radius = 1 height = 2 axis = 0 0 1 midpoint = 0 :stop shape: direction = 0 0 1 charge = 0 :start spectrum: type = monoenergetic energy = 6 :stop spectrum: :stop source: simulation source = my_source :stop source definition: ``` -------------------------------- ### Get Steps Function Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/egs__advanced__application_8cpp.html Retrieves the current step size information. This function is used to get the current step parameters. ```cpp __extc__ void egsGetSteps (double *, double *) ``` -------------------------------- ### initEGSnrcBackEnd() Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/classEGS__AdvancedApplication.html Initializes the EGSnrc mortran back-end, transferring simulation parameters and calling the egs_init1 subroutine. ```APIDOC ## initEGSnrcBackEnd() ### Description Initializes the EGSnrc mortran back-end. This function transfers the various file and directory names, number of parallel jobs, parallel job index and the batch vs. interactive run flag, obtained from the command line arguments, to the appropriate EGSnrc common block and calls the `egs_init1` mortran subroutine. If the simulation is a batch run, output redirection is handled. ### Method int ### Endpoint N/A (Method within a class) ### Parameters None ### Request Example N/A ### Response #### Success Response (int) An integer indicating the success or status of the initialization. #### Response Example ```json { "status": 0 } ``` ``` -------------------------------- ### Get Maximum Energy from Transformed Source Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/classEGS__TransformedSource.html Get the maximum energy (Emax) that can be emitted by the transformed source. This is a const method. ```cpp EGS_Float **getEmax** () const ``` -------------------------------- ### Example cavity Input File Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/cavity.html This is a sample input file for the cavity C++ application. It defines the simulation geometry, source, run control, scoring, and variance reduction techniques. ```text ############################################################################### # # $Id: cavity.doxy,v 1.12 2009/06/05 19:15:15 mainegra Exp $ # # A simple example input file for the cavity C++ application. # ############################################################################### :start geometry definition: ################################### define the simulation geometry: # a simple pancake # chamber with graphite walls :start geometry: library = egs_planes type = EGS_Zplanes name = c_planes positions = 0 0.3 0.5 0.8 :stop geometry: :start geometry: library = egs_cylinders type = EGS_ZCylinders name = c_cyls radii = 1 1.3 :stop geometry: :start geometry: library = egs_ndgeometry name = chamber dimensions = c_planes c_cyls :start media input: media = 170C521ICRU AIR521ICRU set medium = 1 1 :stop media input: :stop geometry: ############################################ define the cavity geometry # (to be used for Russian Roulette) :start geometry: library = egs_planes type = EGS_Zplanes name = cav_planes positions = 0.3 0.5 :stop geometry: :start geometry: library = egs_cylinders type = EGS_ZCylinders name = cav_cyls radii = 1 :stop geometry: :start geometry: library = egs_ndgeometry name = cavity dimensions = cav_planes cav_cyls :stop geometry: simulation geometry = chamber :stop geometry definition: :start source definition: ########################################### define the source: # a Co-60 parallel beam :start source: library = egs_parallel_beam name = the_source charge = 0 :start shape: library = egs_circle radius = 1.3 :stop shape: :start spectrum: type = monoenergetic energy = 1.25 # we approximate the Co-60 spectrum by monoenergetic # 1.25 MeV photons :stop spectrum: :stop source: simulation source = the_source :stop source definition: ##################################### Run control :start run control: ncase = 100000 :stop run control: ##################################### Scoring options :start scoring options: calculation type = dose :start calculation geometry: geometry name = chamber cavity regions = 1 cavity mass = 0.0007569981658089966 :stop calculation geometry: :stop scoring options: ####################################### variance reduction :start variance reduction: photon splitting = 50 :start range rejection: rejection = 100 Esave = 1 cavity geometry = cavity rejection range medium = 170C521ICRU :stop range rejection: :stop variance reduction: ###################################### Transport parameters :start MC transport parameter: # You can include here any of the transport parameter options # understood by EGSnrc :stop MC transport parameter: ``` -------------------------------- ### Find Start Position in Input String Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/egs__input_8cpp_source.html Searches for a start key within a specified range and extracts the content up to the end key. ```cpp int EGS_InputPrivate::findStart(int start, int stop, const string &start_key, const string &end_key, const string &input, string &what, int &end) { string::size_type pos = start; unsigned int ns=0; for (EGS_I64 loopCount=0; loopCount<=loopMax; ++loopCount) { if (loopCount == loopMax) { egsFatal("EGS_InputPrivate::findStart: Too many iterations were required! Input may be invalid, or consider increasing loopMax."); return -2; } if (pos >= stop) { return -1; } char c = ::toupper(input[pos++]); if (start_key[ns] == c) { ns++; } else { ns=0; if (start_key[ns] == c) { ns++; } } if (ns == start_key.size()) { break; } } string::size_type epos = input.find(end_key,pos); if (epos < stop) { what.assign(input,pos,epos-pos); end = epos + end_key.size(); return pos-start_key.size(); } return -2; } ``` -------------------------------- ### IAEA_PhspSource Constructor Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/iaea__phsp__source_8cpp_source.html Initializes the IAEA phase-space source and opens the specified phase-space file. Requires a file path, a name for the source object, and an object factory. ```cpp IAEA_PhspSource::IAEA_PhspSource(const string &phsp_file, const string &Name, EGS_ObjectFactory *f) : EGS_BaseSource(Name,f) { init(); openFile(phsp_file); } ``` -------------------------------- ### Start New Particle Simulation Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/egs__advanced__application_8cpp_source.html Initializes simulation parameters for a new particle, applying density and B-field scaling if enabled by the geometry. ```cpp void EGS_AdvancedApplication::startNewParticle() { if (geometry->hasRhoScaling()) { int ireg = the_stack->ir[the_stack->np-1] - 2; EGS_Float rho = geometry->getRelativeRho(ireg); the_useful->rhor = rho; the_useful->rhor_new = rho; } else { the_useful->rhor = 1; the_useful->rhor_new = 1; } if (geometry->hasBScaling()) { int ireg = the_stack->ir[the_stack->np-1] - 2; EGS_Float bf = geometry->getBScaling(ireg); the_emf->Bx = bf*the_emf->BxIN; the_emf->By = bf*the_emf->ByIN; the_emf->Bz = bf*the_emf->BzIN; the_emf->Bx_new = the_emf->Bx; the_emf->By_new = the_emf->By; the_emf->Bz_new = the_emf->Bz; } else { the_emf->Bx = the_emf->BxIN; the_emf->By = the_emf->ByIN; the_emf->Bz = the_emf->BzIN; the_emf->Bx_new = the_emf->Bx; the_emf->By_new = the_emf->By; the_emf->Bz_new = the_emf->Bz; } } ``` -------------------------------- ### EGS_NDGeometry Setup Method Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/egs__nd__geometry_8cpp_source.html Allocates memory for the geometry dimensions and base geometry pointers. ```cpp void EGS_NDGeometry::setup() { n = new int [N+1]; g = new EGS_BaseGeometry* [N]; } ``` -------------------------------- ### Example EGS_ParallelCones Geometry Definition Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/classEGS__ParallelCones.html A complete example showing the definition of parallel cones combined with a sphere geometry using egs_ndgeometry. ```text :start geometry definition: :start geometry: name = my_parallel_cones library = egs_cones type = EGS_ParallelCones apex = 0 0 6 axis = 0 0 -1 apex distances = 1 2 3 opening angle = 30 # deg :stop geometry: # This sphere will be used to limit # the size of the conical regions by a rounded end :start geometry: library = egs_spheres name = sphere midpoint = 0 0 0 radii = 5 :stop geometry: # Now the actual geometry made from the # parallel cones and the above sphere. :start geometry: library = egs_ndgeometry name = cones dimensions = sphere my_parallel_cones hownear method = 1 :start media input: media = water air set medium = 0 0 set medium = 1 1 set medium = 2 0 set medium = 3 1 :stop media input: :stop geometry: simulation geometry = cones :stop geometry definition: ``` -------------------------------- ### EGS_PhspSource Constructor and Initialization Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/egs__phsp__source_8cpp_source.html Initializes the EGS_PhspSource object, reads the phase space file name from input, and opens the file. It then processes various input parameters like cutout, particle type, filter settings, weight window, and photon/electron recycling. ```cpp EGS_PhspSource::EGS_PhspSource(EGS_Input *input, EGS_ObjectFactory *f) : EGS_BaseSource(input,f) { init(); string fname; int err = input->getInput("phase space file",fname); if (err) { egsWarning("EGS_PhspSource: no 'phase space file' input\n"); return; } openFile(fname); if (!isValid()) { egsWarning("EGS_PhspSource: errors while opening the phase space file\" %s\n",fname.c_str()); return; } vector cutout; err = input->getInput("cutout",cutout); if (!err && cutout.size() == 4) { setCutout(cutout[0],cutout[1],cutout[2],cutout[3]); } vector ptype; ptype.push_back("electrons"); ptype.push_back("photons"); ptype.push_back("positrons"); ptype.push_back("all"); ptype.push_back("charged"); particle_type = input->getInput("particle type",ptype,3)-1; vector the_filter; vector the_latch; err = input->getInput("filter type",the_filter); int err1 = input->getInput("latch setting",the_latch); if (!err && !err1) { if (the_filter[0] >= 0 && the_filter[0] <= 3) { int nbit1 = the_latch[0].size(); int nbit2 = 0; if (!the_filter[0]) { nbit2 = the_latch[1].size(); } if (nbit1 + nbit2 > 0) { int *the_bits = new int [nbit1+nbit2]; for (int j=0; j wwindow; err = input->getInput("weight window",wwindow); if (!err && wwindow.size() == 2) { wmin = wwindow[0]; wmax = wwindow[1]; } int ntmp; err = input->getInput("reuse photons",ntmp); if (!err && ntmp > 0) { Nrecycle_g = ntmp; } else { err = input->getInput("recycle photons",ntmp); if (!err && ntmp > 0) { Nrecycle_g = ntmp; } } err = input->getInput("reuse electrons",ntmp); if (!err && ntmp > 0) { Nrecycle_e = ntmp; } else { err = input->getInput("recycle electrons",ntmp); if (!err && ntmp > 0) { Nrecycle_e = ntmp; } } description = "Phase space source from "; } ``` -------------------------------- ### Initialize Geometry Object Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/egs__spheres_8cpp_source.html Example of allocating and configuring a geometry object based on input parameters. ```cpp 707 return 0; 708 } 709 710 EGS_Float *r = new EGS_Float [radii.size()]; 711 for (int j=0; jsetName(input); 723 result->setBoundaryTolerance(input); 724 result->setMedia(input); 725 result->setLabels(input); 726 return result; 727 } ``` -------------------------------- ### EGSnrc Class Library - Coding Examples Source: https://nrc-cnrc.github.io/EGSnrc/doc/pirs898/functions_vars_g.html This section provides practical coding examples demonstrating the usage of the EGSnrc C++ class library. ```APIDOC ## Coding Examples This section contains practical examples illustrating how to use various components of the EGSnrc C++ class library. These examples are intended to help users understand and implement the library's functionalities in their own projects. ```