1+ /*
2+ * Example Geant4 Primary Generator Action using ParticleZoo phase space files.
3+ * Distributed as part of ParticleZoo. https://www.github.com/dobrienphd/ParticleZoo
4+ *
5+ * MIT License
6+ *
7+ * Copyright (c) 2025 Daniel O'Brien
8+ *
9+ * Permission is hereby granted, free of charge, to any person obtaining a copy
10+ * of this software and associated documentation files (the "Software"), to deal
11+ * in the Software without restriction, including without limitation the rights
12+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13+ * copies of the Software, and to permit persons to whom the Software is
14+ * furnished to do so, subject to the following conditions:
15+ *
16+ * The above copyright notice and this permission notice shall be included in all
17+ * copies or substantial portions of the Software.
18+ *
19+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25+ * SOFTWARE.
26+ */
27+
128#pragma once
229
330#include " G4VUserPrimaryGeneratorAction.hh"
@@ -12,7 +39,7 @@ namespace ParticleZoo
1239{
1340
1441 /* *
15- * @class G4PrimaryGeneratorAction
42+ * @class G4PHSPSourceAction
1643 * @brief Primary generator action for ParticleZoo phase space files.
1744 *
1845 * This class reads particles from a ParticleZoo phase space file and
@@ -25,9 +52,9 @@ namespace ParticleZoo
2552 *
2653 * Usage:
2754 * 1. Create a shared ParticleBalancedParallelReader in the master thread
28- * 2. Pass the shared reader to each worker thread's G4PrimaryGeneratorAction along with the thread index
55+ * 2. Pass the shared reader to each worker thread's G4PHSPSourceAction along with the thread index
2956 */
30- class G4PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction
57+ class G4PHSPSourceAction : public G4VUserPrimaryGeneratorAction
3158 {
3259 public:
3360 /* *
@@ -36,8 +63,8 @@ namespace ParticleZoo
3663 * The reader must be configured with the appropriate number of threads.
3764 * @param threadIndex Index of the worker thread (0-based).
3865 */
39- G4PrimaryGeneratorAction (std::shared_ptr<ParticleZoo::ParticleBalancedParallelReader> parallelReader, std::size_t threadIndex = 0 );
40- ~G4PrimaryGeneratorAction () override ;
66+ G4PHSPSourceAction (std::shared_ptr<ParticleZoo::ParticleBalancedParallelReader> parallelReader, std::size_t threadIndex = 0 );
67+ ~G4PHSPSourceAction () override ;
4168
4269 /* *
4370 * @brief Generate primary vertices for the given event.
@@ -78,20 +105,20 @@ namespace ParticleZoo
78105
79106 // ....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
80107
81- inline void G4PrimaryGeneratorAction ::SetTranslation (const G4ThreeVector & translation)
108+ inline void G4PHSPSourceAction ::SetTranslation (const G4ThreeVector & translation)
82109 {
83110 globalTranslation = translation;
84- G4cout << " ParticleZoo::G4PrimaryGeneratorAction : Set global translation to "
111+ G4cout << " ParticleZoo::G4PHSPSourceAction : Set global translation to "
85112 << globalTranslation << G4endl;
86113 }
87114
88115 // ....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
89116
90- inline void G4PrimaryGeneratorAction ::SetRecycleNumber (std::uint32_t n)
117+ inline void G4PHSPSourceAction ::SetRecycleNumber (std::uint32_t n)
91118 {
92119 recycleNumber = n;
93120 recycleWeightFactor = 1.0 / static_cast <G4double>(recycleNumber + 1 );
94- G4cout << " ParticleZoo::G4PrimaryGeneratorAction : Set recycle number to "
121+ G4cout << " ParticleZoo::G4PHSPSourceAction : Set recycle number to "
95122 << recycleNumber << " , weight factor: " << recycleWeightFactor << G4endl;
96123 }
97124
0 commit comments