Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
144 commits
Select commit Hold shift + click to select a range
863ecc1
Remove unused header
wkrzemien Sep 11, 2025
3d264e3
Remove commented code
wkrzemien Sep 11, 2025
e43e51c
Small refactoring of GateParaPositronium
wkrzemien Sep 11, 2025
2d850ee
Small refactorization of Positronium classes
wkrzemien Sep 11, 2025
3c0cf21
Small refactorization of PositroniumDecayChannel
wkrzemien Sep 11, 2025
c93e9d9
Remove unecessary & while passing basic types
wkrzemien Sep 11, 2025
cef56fb
Refactor ExtendedVSource
wkrzemien Sep 11, 2025
a6700d3
Just reformatting
wkrzemien Oct 6, 2025
90aba86
Small improvement and formatting
wkrzemien Oct 6, 2025
2767e62
Fix missing braces
wkrzemien Oct 6, 2025
bec4acb
Add smart pointers
wkrzemien Oct 6, 2025
837328c
Ordering the header list
wkrzemien Oct 6, 2025
e63f8dd
Starting refactorization of Positronium Decay Model
wkrzemien Oct 6, 2025
d3233d4
Add stub of two unit tests that can be run with ctest
wkrzemien Oct 9, 2025
6d9f2d8
Remove unused includes
wkrzemien Oct 10, 2025
8006a6d
Extend the test for GatePositroniumDecayModel
wkrzemien Oct 10, 2025
b6daec2
Add new functionality to GetPositroniumDecayModel
wkrzemien Oct 10, 2025
924e161
Improve the test
wkrzemien Oct 10, 2025
0828e8e
Small refactoring
wkrzemien Oct 14, 2025
a5ac434
Extension of the decay model to include the excitation function
wkrzemien Oct 14, 2025
c02abed
Remove obsolete comment
wkrzemien Oct 14, 2025
8d91198
Add separate include file for positronium model parameters
wkrzemien Oct 22, 2025
331906a
Add commands to set positronium values from macros
wkrzemien Oct 23, 2025
73286fa
Add separated GatePositronium class
wkrzemien Oct 26, 2025
e156123
Add non-copy and move logic to GatePositronium
wkrzemien Oct 26, 2025
61d4b38
Add tests of GatePositronium
wkrzemien Oct 26, 2025
b6ecfa6
Remove commented code
wkrzemien Oct 26, 2025
9cf74c0
Add tests to ctest in CMakeLists.txt
wkrzemien Oct 26, 2025
79c5a57
Extract separated GateMiniPositroniumDecayModel
wkrzemien Oct 26, 2025
bce7ba0
Extend GatePositronium test
wkrzemien Oct 26, 2025
24b4b90
Add explicit cast to GAtePositroniumDecayChannel in GatePositrionum
wkrzemien Oct 27, 2025
b83c7e1
Small code fixes and formatting
wkrzemien Oct 27, 2025
8cbb27e
Add a function generatePositroniumDecayParams()
wkrzemien Oct 27, 2025
0d02eea
Add missing include
wkrzemien Oct 27, 2025
695ae37
Remove commented coded
wkrzemien Oct 27, 2025
5d34771
Fix reading bool argument as true and false
wkrzemien Oct 27, 2025
b8e3f79
Add separated class GatePositroniumDecayParamsGenerator
wkrzemien Nov 4, 2025
9019cb4
ParaPositronium and OrthoPositronium handling by Mini model
wkrzemien Nov 4, 2025
a5f5444
Remove commented include
wkrzemien Nov 4, 2025
3356f90
Remove commented code
wkrzemien Nov 4, 2025
66cc1eb
Remove repeated line
wkrzemien Nov 4, 2025
39763f8
Fix missing argument passing in function generating params
wkrzemien Nov 4, 2025
b296291
Remove include to GatePositroniumDecayModel
wkrzemien Nov 4, 2025
16991aa
Add test_GatePositroniumDecayParamsGenerator
wkrzemien Nov 4, 2025
24629b3
Fix typo in SetPositroniumLifetimes function
wkrzemien Nov 4, 2025
3bd2b3b
Fix orthopositronium default lifetime to 142 ns
wkrzemien Nov 4, 2025
33fa86e
Add comment that the failure is not caught, cause GateError returns
wkrzemien Nov 4, 2025
3bcd946
Improve and unify tests of GatePositronium
wkrzemien Nov 4, 2025
359abaa
Remove unused field
wkrzemien Nov 4, 2025
f9e7cc9
Rename SetEnableDeexcitation to SetEnablePromptGamma
wkrzemien Nov 14, 2025
9c00667
Change fPromptPhoton to PromptGamma for consistency
wkrzemien Nov 14, 2025
2184369
Add checks if the number of parameters provides are equal
wkrzemien Nov 14, 2025
fdcd801
Remove setting seed
wkrzemien Nov 14, 2025
b347894
Remove Single Gamma model
wkrzemien Nov 14, 2025
590bda2
Remove miniPositronium name of the model and leave only Ps model
wkrzemien Nov 14, 2025
4292cf6
Remove unused fields and function declarations
wkrzemien Nov 14, 2025
9808a44
Implementing positronium helper into param generator / changing setti…
kdulski Nov 28, 2025
3b3a359
Fixing compile errors
kdulski Dec 1, 2025
0884d42
Small fixes for safe use
kdulski Dec 15, 2025
b209c5b
Applying corrections
kdulski Jan 16, 2026
4def586
Remove unused include headers
wkrzemien Jan 21, 2026
d258cea
Fix naming of the variables.
wkrzemien Jan 21, 2026
cf675a6
Change to constexpt from float
wkrzemien Jan 21, 2026
7abed5c
Extract constants to namespace
wkrzemien Jan 21, 2026
c96dea5
Fix tests
wkrzemien Jan 21, 2026
cf77b91
Add GatePositroniumSource
wkrzemien Jan 15, 2026
00671fa
Remove commented code
wkrzemien Jan 21, 2026
c27793e
Small fixes in ParamsGenerator
wkrzemien Jan 21, 2026
8aa09cf
Add handling prompt probabilities to GatePositroniumSourceMessenger
wkrzemien Jan 21, 2026
0d547a2
Add using prompt probabilities in DecayModel
wkrzemien Jan 21, 2026
0fa879a
Rename PositroniumDecayModel to GatePositroniumDecayModel
wkrzemien Jan 21, 2026
b4a3dbd
Fix name of the variable
wkrzemien Jan 21, 2026
077e0f5
Change the decay time of pPs to 0.1244 ns in constants
wkrzemien Jan 21, 2026
3dfd7ee
Fix error in the GatePositroniumDecayModel constructor
wkrzemien Jan 21, 2026
dda5632
Fix and enable test for test_GatePositroniumDecayParamsGenerator
wkrzemien Jan 22, 2026
e5163c1
Update an outdated comment
wkrzemien Jan 22, 2026
d938317
Add test of GatePositronium that number of daughters are 3
wkrzemien Jan 23, 2026
8c4bc87
Change name of namespace to be conformed with GATE
wkrzemien Jan 23, 2026
140e488
Add registration of new positronium source into GateMgr
wkrzemien Jan 23, 2026
7d36eb2
Remove comment about docs
wkrzemien Jan 27, 2026
092432d
Remove unnecessary public keyword
wkrzemien Jan 27, 2026
8582cdc
Fix formatting
wkrzemien Jan 27, 2026
f0b71e9
Fix formatting 2
wkrzemien Jan 27, 2026
882c1a4
Rename kpPs to kParaPs and koPs to kOrthoPs
wkrzemien Jan 27, 2026
0f3cdda
Fix formatting
wkrzemien Jan 27, 2026
18ef5d7
Remove behaveLikeVSource variable
wkrzemien Jan 27, 2026
1424e87
Remove obsolete comments
wkrzemien Jan 27, 2026
76261be
Add missing _ in strings.
wkrzemien Jan 27, 2026
1b0ce81
Add missing explanation to macro command
wkrzemien Jan 27, 2026
1427378
Explicit check for k3Gamma string
wkrzemien Jan 27, 2026
917382b
Add another _ in string
wkrzemien Jan 27, 2026
d46f79c
Add handling of command SetPositronInteractions
wkrzemien Jan 27, 2026
3084b97
Add legacy version of GatePositroniumDecayModel
wkrzemien Jan 23, 2026
fcaa523
Add legacy ExtendedVSource
wkrzemien Jan 23, 2026
70338f0
Remove obsolete headers from include
wkrzemien Jan 23, 2026
b2b5e26
Add legacy GateExtendedVSource and Messenger cc
wkrzemien Jan 23, 2026
bfd974b
Remove obsolete GateExtendedVSource impl
wkrzemien Jan 28, 2026
f60493f
Change to legacy version in GateSourceMgr
wkrzemien Jan 23, 2026
e9e11b4
Remove setting seed
wkrzemien Jan 23, 2026
4845222
Add legacy GatePositroniumDecayModel
wkrzemien Jan 23, 2026
04c3eae
Add legacy code in CMakeLists
wkrzemien Jan 23, 2026
529a439
Move positronium code to legacy
wkrzemien Jan 23, 2026
b4b983c
feat: reduce GatePositroniumSource structure
MateuszBala Feb 5, 2026
9a8160d
Adding test if the last argument in setting lifetime or energy is a unit
kdulski Feb 19, 2026
e7375f3
Add definition of unitVal that will make the code compile :P
wkrzemien Feb 20, 2026
acf6abb
Uncomment messanger test
wkrzemien Feb 20, 2026
b245c5b
Add tests of PositroniumMessenger that passes in master
wkrzemien Feb 20, 2026
5e5d61a
Add helper function to parse list of params with units
wkrzemien Feb 20, 2026
ec9a1a5
Update tests to use units for prompt energies and lifetimes
wkrzemien Feb 20, 2026
e3421e9
Remove unused code
wkrzemien Feb 20, 2026
a67d094
Remove unused include
wkrzemien Feb 20, 2026
bcdf018
Remove unused variable
wkrzemien Feb 20, 2026
655b1a6
Add some basic error handling
wkrzemien Feb 20, 2026
f3ba12a
Add parsing function as method
wkrzemien Feb 20, 2026
5f910ca
Remove commented code
wkrzemien Feb 20, 2026
4a5ec10
Add const to the method
wkrzemien Feb 23, 2026
2667f11
Fix formatting
wkrzemien Feb 23, 2026
dd6fcc3
feat: add decayInex propagation from decay to root file
MateuszBala Mar 17, 2026
527eb6d
Add legacy versions of GateEmittedGammaInformation
wkrzemien Feb 23, 2026
b94236d
Add missing GateEmittedGammaInformation.cc to legacy
wkrzemien Feb 23, 2026
7d9e11d
Fix include by adding legacy.
wkrzemien Apr 10, 2026
0d75d47
Add function introducing vertex shift due to positron range
wkrzemien Mar 20, 2026
fa86011
Add test of expected range
wkrzemien Mar 20, 2026
0890ed5
Add const instead of a magic number
wkrzemien Mar 20, 2026
a6c1ad8
Add handling of the positron range parameter by Messanger
wkrzemien Mar 20, 2026
a221848
Add tests of handling mean positron range macro commands
wkrzemien Mar 20, 2026
7156f0c
Fix wrong error message in the test
wkrzemien Apr 15, 2026
e9d0a83
Fix error command in the test
wkrzemien Apr 17, 2026
3d32889
Add handling of Electron Capture
wkrzemien Mar 6, 2026
cf5e0ef
Add following fix for electron capture case
wkrzemien Mar 6, 2026
397cc2d
Fix typo in the command name
wkrzemien Apr 17, 2026
4b144c5
Make positron capture as optional
wkrzemien Apr 17, 2026
c71770b
Add cross-check of Electron Capture number of elements
wkrzemien Apr 17, 2026
28247df
Add a dedicated validation method to check generated parameters
wkrzemien Apr 17, 2026
8716d34
Refactor the if conditions for clarity
wkrzemien Apr 17, 2026
2ad4024
Fix errors due to the unremoved git markers pointing to the conflict
wkrzemien Apr 24, 2026
968ae90
Add headers and some generated description fo the classes
wkrzemien Apr 24, 2026
fc66f7f
Fix the warning condition for EC and no prompt
wkrzemien Apr 27, 2026
b1b335e
Change return -1 from getPositorniumDecayIndex to return static_cast<…
wkrzemien Apr 27, 2026
86adfbe
Add two tests that show two bug that are already fixed
wkrzemien Apr 27, 2026
9fbc396
fix: positronium source set correct source and decay type
MateuszBala May 8, 2026
0b3916f
Remove unused decayModel arguments
wkrzemien May 8, 2026
bfde960
feat: add multiphoton analysis
MateuszBala May 8, 2026
bcab129
format: remove tab
MateuszBala May 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ CMAKE_POLICY(SET CMP0012 NEW) # if() recognizes numbers and boolean constants.
CMAKE_POLICY(SET CMP0025 NEW) # Compiler id for Apple Clang is now AppleClang.
CMAKE_POLICY(SET CMP0057 NEW) # Support new if() IN_LIST operator.
CMAKE_POLICY(SET CMP0072 NEW) # FindOpenGL prefers GLVND by default when available.
#=========================================================
#set(CMAKE_CXX_COMPILER "/usr/bin/x86_64-linux-gnu-g++-13")
#set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

#=========================================================
PROJECT(Gate)
Expand All @@ -20,6 +23,37 @@ IF(BUILD_TESTING)
ENABLE_TESTING()
SET(BUILDNAME "${BUILDNAME}" CACHE STRING "Name of build on the dashboard")
MARK_AS_ADVANCED(BUILDNAME)
#Stupid solution cause it links to everything but for now on
ADD_EXECUTABLE(test_dummy tests/test_dummy.cpp)
TARGET_LINK_LIBRARIES(test_dummy GateLib)

ADD_TEST(NAME test_dummy COMMAND test_dummy)

ADD_EXECUTABLE(test_GatePositroniumDecayModel tests/test_GatePositroniumDecayModel.cpp)
TARGET_LINK_LIBRARIES(test_GatePositroniumDecayModel GateLib)

ADD_TEST(NAME test_GatePositroniumDecayModel COMMAND test_GatePositroniumDecayModel)

ADD_EXECUTABLE(test_GatePositronium tests/test_GatePositronium.cpp)
TARGET_LINK_LIBRARIES(test_GatePositronium GateLib)

ADD_TEST(NAME test_GatePositronium COMMAND test_GatePositronium)

ADD_EXECUTABLE(test_GatePositroniumHelper tests/test_GatePositroniumHelper.cpp)
TARGET_LINK_LIBRARIES(test_GatePositroniumHelper GateLib)

ADD_TEST(NAME test_GatePositroniumHelper COMMAND test_GatePositroniumHelper)

ADD_EXECUTABLE(test_GatePositroniumDecyParamsGenerator tests/test_GatePositroniumDecayParamsGenerator.cpp)
TARGET_LINK_LIBRARIES(test_GatePositroniumDecyParamsGenerator GateLib)

ADD_TEST(NAME test_GatePositroniumDecyParamsGenerator COMMAND test_GatePositroniumDecayParamsGenerator)

ADD_EXECUTABLE(test_GatePositroniumSourceMessenger tests/test_GatePositroniumSourceMessenger.cpp)
TARGET_LINK_LIBRARIES(test_GatePositroniumSourceMessenger GateLib)

ADD_TEST(NAME test_GatePositroniumSourceMessenger COMMAND test_GatePositroniumSourceMessenger)

ENDIF(BUILD_TESTING)
#=========================================================

Expand Down Expand Up @@ -226,6 +260,7 @@ FILE(GLOB sources
${PROJECT_SOURCE_DIR}/source/geometry/src/*.cc
${PROJECT_SOURCE_DIR}/source/digits_hits/src/*.cc
${PROJECT_SOURCE_DIR}/source/physics/src/*.cc
${PROJECT_SOURCE_DIR}/source/physics/src/legacy/*.cc
${PROJECT_SOURCE_DIR}/source/general/src/*.cc
${PROJECT_SOURCE_DIR}/source/externals/clhep/src/CLHEP/Matrix/*.cc
${PROJECT_SOURCE_DIR}/source/externals/clhep/src/CLHEP/RandomObjects/*.cc)
Expand All @@ -235,6 +270,7 @@ FILE(GLOB headers
${PROJECT_SOURCE_DIR}/source/arf/include/*.hh
${PROJECT_SOURCE_DIR}/source/geometry/include/*.hh
${PROJECT_SOURCE_DIR}/source/physics/include/*.hh
${PROJECT_SOURCE_DIR}/source/physics/include/legacy/*.hh
${PROJECT_SOURCE_DIR}/source/digits_hits/include/*.hh
${PROJECT_SOURCE_DIR}/source/general/include/*.hh
${PROJECT_SOURCE_DIR}/source/externals/clhep/include/*.hh)
Expand Down
8 changes: 8 additions & 0 deletions source/digits_hits/include/GateHit.hh
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public:
G4int m_nCrystalCompton; // # of compton processes in the crystal occurred to the photon
G4int m_nPhantomRayleigh; // # of Rayleigh processes in the phantom occurred to the photon
G4int m_nCrystalRayleigh; // # of Rayleigh processes in the crystal occurred to the photon
G4int m_nInteractions; // # of non-Transportation interactions in phantom + crystal; -1 when not computed
G4String m_comptonVolumeName; // name of the volume of the last (if any) compton scattering
G4String m_RayleighVolumeName; // name of the volume of the last (if any) Rayleigh scattering
G4int m_primaryID; // primary that caused the hit
Expand Down Expand Up @@ -108,6 +109,7 @@ public:
G4int m_sourceType = 0;//0 means 'by default not known'; sourceType says what type of positronium (Ps) is used: pPs, oPs
G4int m_decayType = 0;//0 means 'by default not known'; decayType says what type of Ps decay is used: standard (without prompt gamma), deexcitation (with prompt gamma)
G4int m_gammaType = 0;//0 means 'by default not known'; gammaType says what type of gamma is emitted: annihilation, prompt, other
G4int m_decayIndex = -1;//decay channel index; -1 means 'by default not known'

public:
inline void SetEdep(G4double de) { m_edep = de; }
Expand Down Expand Up @@ -170,6 +172,9 @@ public:
inline void SetNCrystalRayleigh(G4int j) { m_nCrystalRayleigh = j; }
inline G4int GetNCrystalRayleigh() const { return m_nCrystalRayleigh; }

inline void SetNInteractions(G4int j) { m_nInteractions = j; }
inline G4int GetNInteractions() const { return m_nInteractions; }

inline void SetComptonVolumeName(G4String name) { m_comptonVolumeName = name; }
inline G4String GetComptonVolumeName() const { return m_comptonVolumeName; }

Expand Down Expand Up @@ -256,6 +261,9 @@ public:

inline void SetGammaType(G4int value){ m_gammaType = value; }
inline G4int GetGammaType() const { return m_gammaType; }

inline void SetDecayIndex(G4int value){ m_decayIndex = value; }
inline G4int GetDecayIndex() const { return m_decayIndex; }
};


Expand Down
166 changes: 166 additions & 0 deletions source/digits_hits/include/GateMultiPhotonAnalysis.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
/*----------------------
Copyright (C): OpenGATE Collaboration

This software is distributed under the terms
of the GNU Lesser General Public Licence (LGPL)
See LICENSE.md for further details
----------------------*/

#ifndef GateMultiPhotonAnalysis_h
#define GateMultiPhotonAnalysis_h

#include "GateMultiPhotonAnalysisHelpers.hh"
#include "GateVOutputModule.hh"

#include <vector>

/** Authors: Wojciech Krzemień, Mateusz Bała and Kamil Dulski
* Emails: wojciech.krzemien@ncbj.gov.pl, mateusz.bala@ncbj.gov.pl and kamil.dulski@gmail.com
* Organization: National Centre For Nuclear Research (NCBJ, https://ncbj.gov.pl), Poland
* Developed within the IMPET project: https://pet.ncbj.gov.pl/
* About: Multi-photon analysis output-module interface with event processing callbacks and trajectory-missing policies.
**/

class GateVVolume;
class GateMultiPhotonTrajectoryNavigator;
class GateMultiPhotonAnalysisMessenger;

/**
* @brief Multi-photon variant of event-end hit analysis.
*
* The class mirrors the legacy GateAnalysis role while removing the hardcoded
* two-photon mapping assumption. It aggregates per-photon interaction counters
* and assigns resolved values to crystal hits.
*
* Notes:
* - Iteration 1 supports TrackingMode::kBoth only.
* - Tracker/detector split mode handling is explicitly deferred.
*/
class GateMultiPhotonAnalysis : public GateVOutputModule {
public:
/** @brief Policy for handling missing trajectory containers. */
enum MissingTrajectoryPolicy {
kStrict,
kResilient
};

/**
* @brief Constructs the output module.
*
* Args:
* name: Output module name.
* outputMgr: Output manager owner.
* digiMode: Runtime/offline mode.
*/
GateMultiPhotonAnalysis(const G4String &name, GateOutputMgr *outputMgr, DigiMode digiMode);

virtual ~GateMultiPhotonAnalysis();

/**
* @brief Returns module file name placeholder.
*
* Returns:
* Dummy name since this module does not own a file.
*/
const G4String &GiveNameOfFile();

/** @brief Acquisition-begin callback. */
void RecordBeginOfAcquisition();
/** @brief Acquisition-end callback. */
void RecordEndOfAcquisition();
/** @brief Run-begin callback. */
void RecordBeginOfRun(const G4Run *);
/** @brief Run-end callback. */
void RecordEndOfRun(const G4Run *);
/** @brief Event-begin callback. */
void RecordBeginOfEvent(const G4Event *);

/**
* @brief Performs event-end multi-photon aggregation and hit assignment.
*
* Args:
* event: Event carrying trajectory and hit collections.
*/
void RecordEndOfEvent(const G4Event *event);

/**
* @brief Step callback (unused by this module).
*
* Args:
* v: Current volume.
* step: Current step.
*/
void RecordStepWithVolume(const GateVVolume *v, const G4Step *step);

/** @brief Voxel callback (not used). */
void RecordVoxels(GateVGeometryVoxelStore *) {}

/**
* @brief Sets module and navigator verbosity.
*
* Args:
* val: Verbose level.
*/
virtual void SetVerboseLevel(G4int val);

/**
* @brief Sets policy for missing trajectory container handling.
*
* Args:
* policy: Desired behavior policy.
*/
void SetMissingTrajectoryPolicy(MissingTrajectoryPolicy policy);

/**
* @brief Parses and applies missing trajectory policy from text.
*
* Args:
* policyName: Policy name (`strict` or `resilient`).
*/
void SetMissingTrajectoryPolicyFromString(const G4String &policyName);

/**
* @brief Returns current missing trajectory policy.
*
* Returns:
* Active policy value.
*/
MissingTrajectoryPolicy GetMissingTrajectoryPolicy() const;

/**
* @brief Returns current missing trajectory policy as string.
*
* Returns:
* `strict` or `resilient`.
*/
G4String GetMissingTrajectoryPolicyName() const;

private:
/**
* @brief Checks whether current tracking mode is supported.
*
* Args:
* tracking_mode_code: Integer value of TrackingMode.
*
* Returns:
* True when event processing should continue for the current mode.
*/
bool IsTrackingModeSupported(int tracking_mode_code) const;

/**
* @brief Returns policy value for legacy photonID field.
*
* Returns:
* Always 0 in multiphoton mode (explicit policy for iteration 1).
*/
int ResolveLegacyPhotonIDPolicy() const;

GateMultiPhotonTrajectoryNavigator *m_trajectoryNavigator;
GateMultiPhotonAnalysisMessenger *m_messenger;
G4String m_noFileName;
MissingTrajectoryPolicy m_missingTrajectoryPolicy;
G4int m_missingTrajectoryEventCount;
G4int m_missingTrajectoryWithHitsCount;
};

#endif
117 changes: 117 additions & 0 deletions source/digits_hits/include/GateMultiPhotonAnalysisHelpers.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/** ----------------------
Copyright (C): OpenGATE Collaboration
This software is distributed under the terms
of the GNU Lesser General Public Licence (LGPL)
See LICENSE.md for further details
----------------------*/

#ifndef GateMultiPhotonAnalysisHelpers_h
#define GateMultiPhotonAnalysisHelpers_h

#include <string>
#include <string_view>

/** Authors: Wojciech Krzemień, Mateusz Bała and Kamil Dulski
* Emails: wojciech.krzemien@ncbj.gov.pl, mateusz.bala@ncbj.gov.pl and kamil.dulski@gmail.com
* Organization: National Centre For Nuclear Research (NCBJ, https://ncbj.gov.pl), Poland
* Developed within the IMPET project: https://pet.ncbj.gov.pl/
* About namespace: Helper functions for multi-photon analysis, including a structure to hold gamma interaction statistics and functions to accumulate statistics based on interaction process names.
**/
namespace MultiPhotonAnalysisHelpers {

/** @brief Aggregated interaction counters for a single tracked gamma. */
struct GammaStatistics {
int phantomCompton = 0;
int phantomRayleigh = 0;
int crystalCompton = 0;
int crystalRayleigh = 0;
int phantomInteractions = 0;
int crystalInteractions = 0;
std::string comptonVolumeName = "NULL";
std::string rayleighVolumeName = "NULL";
};

/** @brief Interaction process classes used by multi-photon analysis. */
enum class InteractionProcess {
Unknown,
Compton,
Rayleigh,
Transportation
};

/**
* @brief Classifies process name into a compact process category.
*
* Args:
* processName: Geant4 process name.
*
* Returns:
* Recognized interaction category or Unknown.
*/
constexpr InteractionProcess GetInteractionProcess(const std::string_view processName) {
if (processName.size() >= 4) {
if (processName.substr(0, 4) == "Tran") {
return InteractionProcess::Transportation;
}
if (processName.substr(0, 4) == "Comp" || processName.substr(0, 4) == "comp") {
return InteractionProcess::Compton;
}
if (processName.substr(0, 4) == "Rayl" || processName.substr(0, 4) == "rayl") {
return InteractionProcess::Rayleigh;
}
}
return InteractionProcess::Unknown;
}

/**
* @brief Accumulates crystal-side interaction statistics.
*
* Args:
* processName: Geant4 process name at crystal hit.
* gammaStatistics: Statistics object to update.
*/
inline void AccumulateCrystal(const std::string_view processName, GammaStatistics& gammaStatistics) {
const InteractionProcess process = GetInteractionProcess(processName);
if (process != InteractionProcess::Transportation) {
gammaStatistics.crystalInteractions++;
switch (process) {
case InteractionProcess::Compton:
gammaStatistics.crystalCompton++;
break;
case InteractionProcess::Rayleigh:
gammaStatistics.crystalRayleigh++;
break;
default:
break;
}
}
}

/**
* @brief Accumulates phantom-side interaction statistics.
*
* Args:
* processName: Geant4 process name at phantom hit.
* gammaStatistics: Statistics object to update.
*/
inline void AccumulatePhantom(const std::string_view processName, GammaStatistics& gammaStatistics) {
const InteractionProcess process = GetInteractionProcess(processName);
if (process != InteractionProcess::Transportation) {
gammaStatistics.phantomInteractions++;
switch (process) {
case InteractionProcess::Compton:
gammaStatistics.phantomCompton++;
break;
case InteractionProcess::Rayleigh:
gammaStatistics.phantomRayleigh++;
break;
default:
break;
}
}
}

}// namespace MultiPhotonAnalysisHelpers


#endif // GateMultiPhotonAnalysisHelpers_h
Loading