Dear all,
I am a bleeding beginner, so it is completely possible for me to have missed something obvious. Please keep this in mind.
What I wanted to do is scatter a neutron beam, as coming from a reactor or spallation source from a particle beam going into the opposite direction (starting with protons, but I want to be able to change the nature of the oncoming particles).
To that end, I modified the B1 example, set all logical volumes to vacuum and introduced a second G4ParticleGun instance in B1 PrimaryGeneratorAction. This works and compiles very well.
Changed code sections are:
in B1DetectorConstruction.cc
//vacuum
G4double vacLevel = 1e-7; //1 for normal pressure, 1e-3 for mbar …
density = vacLevel1.25kg/m3;
molWt = 14.0067g/mole;
G4Material vac = new G4Material(name=“vacuum”, density, ncomponents=1);
vac->AddElement(elN, natoms=2);
and setting all materials to vac.
and in B1PrimaryGeneratorAction.hh
private:
G4ParticleGun* fneutronGun;
in B1PrimaryGeneratorAction.cc
// default particle kinematic for neutrons
G4ParticleDefinition* neutron
= particleTable->FindParticle(particleName=“neutron”);
fneutronGun->SetParticleDefinition(neutron);
fneutronGun->SetParticleMomentumDirection(G4ThreeVector(0.,0.,-1.));
fneutronGun->SetParticleEnergy(.1*eV);
and
fParticleGun->SetParticlePosition(G4ThreeVector(x0,y0,z0));
fneutronGun->SetParticlePosition(G4ThreeVector(x0,y0,-z0));
fParticleGun->GeneratePrimaryVertex(anEvent);
fneutronGun->GeneratePrimaryVertex(anEvent);
What I noticed is, that obviously the events are worked through sequentially, i.e. one of the particle guns fires, the particle is tracked until it is out of world and then the other particle gun fires, meaning that the two beams that I want to meet head-on are never in the simulation at the same time.
Is there another way to do this, am I doing this completely wrong or is it something obvious that I missed?
Thanks for any help.
Best
Sebastian