Skip to content

Commit d7c2dbb

Browse files
committed
Renamed the geant4 example and included MIT license explicitly inside it via comments
1 parent d45bb13 commit d7c2dbb

File tree

2 files changed

+68
-14
lines changed

2 files changed

+68
-14
lines changed

examples/geant4/ParticleZooPrimaryGeneratorAction.cc renamed to examples/geant4/G4PHSPSourceAction.cc

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,32 @@
11

2-
#include "ParticleZooPrimaryGeneratorAction.hh"
2+
/*
3+
* Example Geant4 Primary Generator Action using ParticleZoo phase space files.
4+
* Distributed as part of ParticleZoo. https://www.github.com/dobrienphd/ParticleZoo
5+
*
6+
* MIT License
7+
*
8+
* Copyright (c) 2025 Daniel O'Brien
9+
*
10+
* Permission is hereby granted, free of charge, to any person obtaining a copy
11+
* of this software and associated documentation files (the "Software"), to deal
12+
* in the Software without restriction, including without limitation the rights
13+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14+
* copies of the Software, and to permit persons to whom the Software is
15+
* furnished to do so, subject to the following conditions:
16+
*
17+
* The above copyright notice and this permission notice shall be included in all
18+
* copies or substantial portions of the Software.
19+
*
20+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26+
* SOFTWARE.
27+
*/
28+
29+
#include "G4PHSPSourceAction.hh"
330

431
#include "G4GlobalConfig.hh"
532
#include "G4Event.hh"
@@ -9,7 +36,7 @@ namespace ParticleZoo
936

1037
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
1138

12-
G4PrimaryGeneratorAction::G4PrimaryGeneratorAction(std::shared_ptr<ParticleZoo::ParticleBalancedParallelReader> parallelReader, std::size_t threadIndex)
39+
G4PHSPSourceAction::G4PHSPSourceAction(std::shared_ptr<ParticleZoo::ParticleBalancedParallelReader> parallelReader, std::size_t threadIndex)
1340
: parallelReader(parallelReader),
1441
threadIndex(threadIndex),
1542
globalTranslation(G4ThreeVector(0,0,0)),
@@ -18,19 +45,19 @@ namespace ParticleZoo
1845
historiesToWait(0),
1946
historiesWaited(0)
2047
{
21-
G4cout << "ParticleZoo::G4PrimaryGeneratorAction: Initialized for thread index " << threadIndex << G4endl;
48+
G4cout << "ParticleZoo::G4PHSPSourceAction: Initialized for thread index " << threadIndex << G4endl;
2249
}
2350

2451
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
2552

26-
G4PrimaryGeneratorAction::~G4PrimaryGeneratorAction()
53+
G4PHSPSourceAction::~G4PHSPSourceAction()
2754
{
2855
// Note: parallelReader is shared and will be closed when the last reference is released
2956
}
3057

3158
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
3259

33-
void G4PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
60+
void G4PHSPSourceAction::GeneratePrimaries(G4Event* anEvent)
3461
{
3562
// Ensure the reader is valid
3663
if (!parallelReader) return;

examples/geant4/ParticleZooPrimaryGeneratorAction.hh renamed to examples/geant4/G4PHSPSourceAction.hh

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,30 @@
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

Comments
 (0)