59void PrimaryGeneratorAction::GeneratePrimaries(G4Event* event) {
65 if (event->GetUserInformation()) {
68 "There was a UserEventInformation attached before beginning event."
69 "\nI don't know how this happend!!");
75 event->SetUserInformation(event_info);
77 PrimaryGenerator::Factory::get().apply([event](
const auto& generator) {
78 generator->GeneratePrimaryVertex(event);
82 int nPV =
event->GetNumberOfPrimaryVertex();
85 for (
int iPV = 0; iPV < nPV; ++iPV) {
86 G4PrimaryVertex* primary_vertex =
event->GetPrimaryVertex(iPV);
90 for (
int iparticle = 0; iparticle < primary_vertex->GetNumberOfParticle();
92 G4PrimaryParticle* primary = primary_vertex->GetPrimary(iparticle);
95 primary->GetUserInformation())};
96 if (not primary_info) {
100 primary->SetUserInformation(primary_info);
104 if (hepStatus <= 0) {
106 primary_info->setHepEvtStatus(1);
112 event_info->incWeight(primary_vertex->GetWeight());
116 double x0_i = primary_vertex->GetX0();
117 double y0_i = primary_vertex->GetY0();
118 double z0_i = primary_vertex->GetZ0();
126 double x0_f = beamspotXSize_ * (G4UniformRand() - 0.5) + x0_i;
127 double y0_f = beamspotYSize_ * (G4UniformRand() - 0.5) + y0_i;
128 double z0_f = beamspotZSize_ * (G4UniformRand() - 0.5) + z0_i;
129 primary_vertex->SetPosition(x0_f, y0_f, z0_f);
134 if (time_shift_primaries_) {
135 primary_vertex->SetT0(primary_vertex->GetT0() +
136 primary_vertex->GetZ0() / 299.702547);
143 "No primary vertices were produced by any of the generators.");