PlasmaMLPALLAS
Loading...
Searching...
No Matches
PlasmaMLPALLASPrimaryGeneratorAction.hh
Go to the documentation of this file.
1#ifndef PlasmaMLPALLASPrimaryGeneratorAction_h
2#define PlasmaMLPALLASPrimaryGeneratorAction_h 1
3
16#include "G4VUserPrimaryGeneratorAction.hh"
19#include "G4ParticleGun.hh"
20#include "G4GeneralParticleSource.hh"
23
24// Forward declarations
25class G4ParticleGun;
26class G4Event;
27
28class PlasmaMLPALLASPrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction
29{
30public:
31 PlasmaMLPALLASOnnxInference* GetOnnxInference() const { return onnxInference.get(); }
32
39 PlasmaMLPALLASPrimaryGeneratorAction(size_t N, size_t numThreads, bool pMT);
40
45
50 void GeneratePrimaries(G4Event *anEvent) override;
51
56
59 double GetML_Xoff() const { return OnnxParameters::Instance().GetXoff(); }
60 double GetML_A0() const { return OnnxParameters::Instance().GetA0(); }
61 double GetML_CN2() const { return OnnxParameters::Instance().GetCN2(); }
62 double GetML_Pressure() const { return OnnxParameters::Instance().GetPressure(); }
64
67 double GetEkin() const { return Ekin; }
68 double GetdEkin() const { return dEkin * 100.; }
69 double GetQ() const { return Q * 1e12; }
70 double GetEPSB() const { return epsb * 1e6; }
72
73
74private:
75 PlasmaMLPALLASPrimaryGeneratorMessenger* fPrimaryGeneratorMessenger = nullptr;
77 std::unique_ptr<PlasmaMLPALLASOnnxInference> onnxInference;
78 G4ParticleGun* particleGun = nullptr;
79 G4GeneralParticleSource* particleSource = nullptr;
80 G4ParticleDefinition* particleDefinition = nullptr;
87 static void ShowProgress(double progress, std::chrono::high_resolution_clock::time_point startTime);
88
89 size_t NEventsGenerated = 0;
90 size_t currentEvent = 0;
91 size_t numThreads = 0;
92 bool flag_MT = false;
93 int threadID = 0;
94 int eventID = 0;
95 int nEvent = 0;
96 std::chrono::duration<double> elapsedTime;
97 bool isStartTimeInitialized = false;
98 std::chrono::high_resolution_clock::time_point startTime;
99 double progressRemaining = 0.;
100 double averageTimePerProgress = 0.;
101 double estimatedRemainingTime = 0.;
103 // Beam physical parameters
104 double Ekin = 1.;
105 double dEkin = 1.;
106 double Q = 1.;
107 double epsb = 1.;
109 // ONNX session
110 std::unique_ptr<Ort::Session> fSession;
111 const OrtMemoryInfo* fMemory_info = nullptr;
112 std::vector<const char*> fInput_node_names = {"input"};
113 std::vector<const char*> fOutput_node_names = {"output"};
114};
115
116#endif
double GetPressure() const
Definition PlasmaMLPALLASOnnxParameters.hh:79
double GetXoff() const
Definition PlasmaMLPALLASOnnxParameters.hh:67
double GetCN2() const
Definition PlasmaMLPALLASOnnxParameters.hh:75
static OnnxParameters & Instance()
Access the singleton instance.
Definition PlasmaMLPALLASOnnxParameters.hh:23
double GetA0() const
Definition PlasmaMLPALLASOnnxParameters.hh:71
Interface for ONNX model inference for PALLAS plasma simulation beam generation.
Definition PlasmaMLPALLASOnnxInference.hh:37
Defines the primary generator action for the simulation.
Definition PlasmaMLPALLASPrimaryGeneratorAction.hh:29
PlasmaMLPALLASOnnxInference * GetOnnxInference() const
Definition PlasmaMLPALLASPrimaryGeneratorAction.hh:31
double GetML_Xoff() const
Definition PlasmaMLPALLASPrimaryGeneratorAction.hh:59
double GetEPSB() const
Definition PlasmaMLPALLASPrimaryGeneratorAction.hh:70
double GetdEkin() const
Definition PlasmaMLPALLASPrimaryGeneratorAction.hh:68
void UpdateParticleDefinition()
Update the particle definition based on current parameters.
Definition PlasmaMLPALLASPrimaryGeneratorAction.cc:73
double GetML_CN2() const
Definition PlasmaMLPALLASPrimaryGeneratorAction.hh:61
double GetML_Pressure() const
Definition PlasmaMLPALLASPrimaryGeneratorAction.hh:62
double GetML_A0() const
Definition PlasmaMLPALLASPrimaryGeneratorAction.hh:60
~PlasmaMLPALLASPrimaryGeneratorAction()
Destructor.
Definition PlasmaMLPALLASPrimaryGeneratorAction.cc:67
double GetEkin() const
Definition PlasmaMLPALLASPrimaryGeneratorAction.hh:67
double GetQ() const
Definition PlasmaMLPALLASPrimaryGeneratorAction.hh:69
void GeneratePrimaries(G4Event *anEvent) override
Generate primary particles for the event.
Definition PlasmaMLPALLASPrimaryGeneratorAction.cc:133
Provides UI commands to configure the primary generator.
Definition PlasmaMLPALLASPrimaryGeneratorMessenger.hh:32