14 #include "G4SystemOfUnits.hh"
19 : _messenger(this,
"/GGS/generatorActions/multiParticle/") {
22 .DeclareMethod(
"file", &GGSMultiParticleGeneratorAction::SetEventsFile,
23 "Set the name of the file containing the definitions of the events")
24 .SetStates(G4State_Idle);
28 if (_inputFile.is_open()) {
33 void GGSMultiParticleGeneratorAction::SetEventsFile(
const G4String &evFile) {
34 if (_inputFile.is_open()) {
37 _inputFile.open(evFile.data());
39 G4Exception(
"GGSMultiParticleGeneratorAction::GGSMultiParticleGeneratorAction",
"mp-nofile", FatalException,
50 if (_inputFile.eof()) {
51 G4Exception(
"GGSMultiParticleGeneratorAction::GeneratePrimaryVertex",
"mp-eof", JustWarning,
52 "End-Of-File: multi-particle input file");
70 for (G4int IHEP = 0; IHEP < NHEP; IHEP++) {
72 _inputFile >> ISTHEP >> IDHEP >> JDAHEP1 >> JDAHEP2 >> PHEP1 >> PHEP2 >> PHEP3 >> PHEP5 >> VHEP1 >> VHEP2 >>
76 G4PrimaryParticle *particle =
new G4PrimaryParticle(IDHEP, PHEP1 * GeV, PHEP2 * GeV, PHEP3 * GeV);
77 particle->SetMass(PHEP5 * GeV);
80 G4PrimaryVertex *vertex =
new G4PrimaryVertex(G4ThreeVector(VHEP1 * cm, VHEP2 * cm, VHEP3 * cm), VHEP4 * ns);
83 _particles.emplace_back(Particle());
84 Particle &hepParticle = _particles.back();
85 hepParticle.theParticle = particle;
86 hepParticle.ISTHEP = ISTHEP;
87 hepParticle.JDAHEP1 = JDAHEP1;
88 hepParticle.JDAHEP2 = JDAHEP2;
89 hepParticle.theVertex = vertex;
93 if (_particles.size() == 0)
98 for (
size_t iPart = 0; iPart < _particles.size(); ++iPart) {
99 if (_particles[iPart].JDAHEP1 > 0)
101 G4int jda1 = _particles[iPart].JDAHEP1 - 1;
102 G4int jda2 = _particles[iPart].JDAHEP2 - 1;
103 G4PrimaryParticle *mother = _particles[iPart].theParticle;
104 for (G4int jPart = jda1; jPart <= jda2; ++jPart) {
105 G4PrimaryParticle *daughter = _particles[jPart].theParticle;
106 if (_particles[jPart].ISTHEP > 0) {
107 mother->SetDaughter(daughter);
108 _particles[jPart].ISTHEP *= -1;
115 for (
size_t iPart = 0; iPart < _particles.size(); ++iPart) {
116 if (_particles[iPart].ISTHEP > 0) {
117 _particles[iPart].theVertex->SetPrimary(_particles[iPart].theParticle);
118 anEvent->AddPrimaryVertex(_particles[iPart].theVertex);
128 params.
SetParam(
"generator", std::string(
"multiParticle"));
A multi-particle generator action.
~GGSMultiParticleGeneratorAction()
Destructor.
void SetParam(const std::string &name, T value)
Sets a parameter.
Class for storing parameters.
GGSParameters GetParameters() const
Gets the generation parameters.
#define RegisterGA(gaClassName, gaName)
Macro for registration of user generator actions.
void GeneratePrimaries(G4Event *anEvent)
Override of GeneratePrimaries method.
GGSMultiParticleGeneratorAction()
Constructor.