Hi @dnevill thank for your reply. I looked for the code
SetUserAction(new B1SteppingAction(eventAction));
and I found it in the B1ActionInitialization.cc file in the last function
void B1ActionInitialization::Build() const
{
SetUserAction(new B1PrimaryGeneratorAction);
B1RunAction* runAction = new B1RunAction;
SetUserAction(runAction);
B1EventAction* eventAction = new B1EventAction(runAction);
SetUserAction(eventAction);
SetUserAction(new B1SteppingAction(eventAction));
}
then I commented that line so currently the last function is:
void B1ActionInitialization::Build() const
{
SetUserAction(new B1PrimaryGeneratorAction);
B1RunAction* runAction = new B1RunAction;
SetUserAction(runAction);
B1EventAction* eventAction = new B1EventAction(runAction);
SetUserAction(eventAction);
//SetUserAction(new B1SteppingAction(eventAction));
}
I compiled the code and it worked, but I wasn’t sure to get what I want! I have to study the e-e+ —> mu-mu+ interaction. Then I want to simulate a 45GeV positron beam hitting a carbon fixed target having thickness 6cm. What I did is:
-
To simulate just a 45 positron beam I modified the exampleB1.in file as following:
#Macro file for example B1 test
/run/initialize
#positron 45 GeV
/gun/particle positron
/gun/energy 45 GeV
/run/printProgress 100
/run/beamOn 1000
#proton 210 MeV
#/gun/particle proton
#/gun/energy 210 MeV
#/run/beamOn 1000
-
To have a Carbon target 6cm thickness I modified the B1DetectorConstruction.cc file as following:
// Envelope parameters
//
G4double env_sizeXY = 20cm, env_sizeZ = 6cm;
G4Material* env_mat = nist->FindOrBuildMaterial(“G4_GRAPHITE”);
But during the run (see attachment first log.txt) I read, about gamma particles for example:
G4Track Information: Particle = gamma, Track ID = 1, Parent ID = 0
then it looked like to simulate gamma beam instead of positron beam! Then I also modified the B1PrimaryGeneratorAction.cc file as following:
{
G4int n_particle = 1;
fParticleGun = new G4ParticleGun(n_particle);
// default particle kinematic
G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
G4String particleName;
G4ParticleDefinition* particle
= particleTable->FindParticle(particleName="positron");
fParticleGun->SetParticleDefinition(particle);
fParticleGun->SetParticleMomentumDirection(G4ThreeVector(0.,0.,1.));
fParticleGun->SetParticleEnergy(45.*GeV);
}
I compiled the the code but when I runned the exe file, I got this error
*** G4Exception : Event0101
issued by : G4ParticleGun::SetParticleDefinition()
Null pointer is given.
*** Fatal Exception *** core dump ***
**** Track information is not available at this moment
**** Step information is not available at this moment
See attachment “second log.txt” for the full error.
first log.txt (37.8 KB) second log.txt (1.2 KB)