remage
Simulation framework for HPGe-based experiments
Toggle main menu visibility
Loading...
Searching...
No Matches
RMGGeneratorGPS.hh
1
// Copyright (C) 2022 Luigi Pertoldi <https://orcid.org/0000-0002-0467-2571>
2
//
3
// This program is free software: you can redistribute it and/or modify it under
4
// the terms of the GNU Lesser General Public License as published by the Free
5
// Software Foundation, either version 3 of the License, or (at your option) any
6
// later version.
7
//
8
// This program is distributed in the hope that it will be useful, but WITHOUT
9
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
11
// details.
12
//
13
// You should have received a copy of the GNU Lesser General Public License
14
// along with this program. If not, see <https://www.gnu.org/licenses/>.
15
16
#ifndef _RMG_GENERATOR_GPS_HH_
17
#define _RMG_GENERATOR_GPS_HH_
18
19
#include <memory>
20
21
#include "G4Event.hh"
22
#include "G4GeneralParticleSource.hh"
23
#include "G4ThreeVector.hh"
24
25
#include "RMGVGenerator.hh"
26
34
class
RMGGeneratorGPS :
public
RMGVGenerator {
35
36
public
:
37
38
RMGGeneratorGPS() : RMGVGenerator(
"GPS"
) {
39
fParticleSource = std::make_unique<G4GeneralParticleSource>();
40
}
41
42
~RMGGeneratorGPS() =
default
;
43
45
void
GeneratePrimaries
(
G4Event
* event)
override
{
46
// the GPS is inherently thread-unsafe: only one source can be used at a time, and all
47
// threads share the same internal global state. do not mutate that shared state (e.g.
48
// via SetCentreCoords) — instead translate the resulting vertices below.
49
auto
first_vertex =
event
->GetNumberOfPrimaryVertex();
50
fParticleSource->GeneratePrimaryVertex(event);
51
52
if
(fVertexPositionSet) {
53
auto
n_vertex =
event
->GetNumberOfPrimaryVertex();
54
for
(
auto
i = first_vertex; i < n_vertex; i++) {
55
auto
vertex =
event
->GetPrimaryVertex(i);
56
vertex->SetPosition(fVertexPosition.x(), fVertexPosition.y(), fVertexPosition.z());
57
}
58
}
59
}
60
62
void
SetParticlePosition
(G4ThreeVector vec)
override
{
63
fVertexPosition = vec;
64
fVertexPositionSet =
true
;
65
}
66
67
private
:
68
69
bool
fVertexPositionSet =
false
;
70
G4ThreeVector fVertexPosition;
71
72
std::unique_ptr<G4GeneralParticleSource> fParticleSource =
nullptr
;
73
};
74
75
#endif
76
77
// vim: tabstop=2 shiftwidth=2 expandtab
G4Event
RMGGeneratorGPS::SetParticlePosition
void SetParticlePosition(G4ThreeVector vec) override
Translate every GPS primary vertex to vec for the next event.
Definition
RMGGeneratorGPS.hh:62
RMGGeneratorGPS::GeneratePrimaries
void GeneratePrimaries(G4Event *event) override
Generate a primary vertex from the GPS, optionally overriding the vertex position.
Definition
RMGGeneratorGPS.hh:45
include
RMGGeneratorGPS.hh
Generated by
1.17.0