14 #include "G4SystemOfUnits.hh"
19 _messenger =
new G4GenericMessenger(
this,
"/GGS/generatorActions/multiParticle/");
20 _messenger->DeclareMethod(
"file", &GGSMultiParticleGeneratorAction::SetEventsFile,
21 "Set the name of the file containing the definitions of the events").SetStates(G4State_Idle);
26 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 >> VHEP3
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 Particle* hepParticle =
new Particle;
84 hepParticle->theParticle = particle;
85 hepParticle->ISTHEP = ISTHEP;
86 hepParticle->JDAHEP1 = JDAHEP1;
87 hepParticle->JDAHEP2 = JDAHEP2;
88 hepParticle->theVertex = vertex;
91 _particles.push_back(hepParticle);
95 if (_particles.size() == 0)
100 for (
size_t i = 0; i < _particles.size(); i++) {
101 if (_particles[i]->JDAHEP1 > 0)
103 G4int jda1 = _particles[i]->JDAHEP1 - 1;
104 G4int jda2 = _particles[i]->JDAHEP2 - 1;
105 G4PrimaryParticle* mother = _particles[i]->theParticle;
106 for (G4int j = jda1; j <= jda2; j++) {
107 G4PrimaryParticle* daughter = _particles[j]->theParticle;
108 if (_particles[j]->ISTHEP > 0) {
109 mother->SetDaughter(daughter);
110 _particles[j]->ISTHEP *= -1;
118 for (
size_t ii = 0; ii < _particles.size(); ii++) {
119 if (_particles[ii]->ISTHEP > 0)
122 _particles[ii]->theVertex->SetPrimary(_particles[ii]->theParticle);
123 anEvent->AddPrimaryVertex(_particles[ii]->theVertex);
129 for (
size_t iii = 0; iii < _particles.size(); iii++) {
130 delete _particles[iii];
A multi-particle generator action.
~GGSMultiParticleGeneratorAction()
Destructor.
#define RegisterGA(gaClassName, gaName)
Macro for registration of user generator actions.
void GeneratePrimaries(G4Event *anEvent)
Override of GeneratePrimaries method.
GGSMultiParticleGeneratorAction()
Constructor.