From a13b7b702e36c5c1dd434affed5f56c4f558cb4f Mon Sep 17 00:00:00 2001 From: Richard Jones Date: Mon, 10 Aug 2020 14:57:46 -0400 Subject: [PATCH] * add checks that fPrimaryGenerator and fPhotonBeamGenerator are defined whenever we go to use them [rtj] --- src/GlueXPrimaryGeneratorAction.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/GlueXPrimaryGeneratorAction.cc b/src/GlueXPrimaryGeneratorAction.cc index 50576d9..aaace11 100644 --- a/src/GlueXPrimaryGeneratorAction.cc +++ b/src/GlueXPrimaryGeneratorAction.cc @@ -490,12 +490,12 @@ GlueXPrimaryGeneratorAction &GlueXPrimaryGeneratorAction::operator=(const if (fSourceType == SOURCE_TYPE_HDDM) { fPrimaryGenerator = new GlueXPrimaryGenerator(fHDDMistream); } - else if (fSourceType == SOURCE_TYPE_COBREMS_GEN) { - clone_photon_beam_generator(); - } else if (fSourceType == SOURCE_TYPE_PARTICLE_GUN) { fParticleGun->SetParticleDefinition(fGunParticle.partDef); } + if (fPhotonBeamGenerator) { + clone_photon_beam_generator(); + } fBeamvertex = src.fBeamvertex; fBeamvertex_activated = src.fBeamvertex_activated; return *this; @@ -882,6 +882,8 @@ void GlueXPrimaryGeneratorAction::GeneratePrimariesHDDM(G4Event* anEvent) } z = fTargetCenterZ + (G4UniformRand() - 0.5) * fTargetLength; } + assert (fPrimaryGenerator != 0); + assert (fPhotonBeamGenerator != 0); double ttag = fPhotonBeamGenerator->GenerateTriggerTime(anEvent); double trel = (z - fRFreferencePlaneZ) / beamVelocity; fPrimaryGenerator->SetParticlePosition(G4ThreeVector(x,y,z));