Hi,
I am trying to simulate 60keV gamma rays as source in ExampleB1. I tried using both gun and gps in a simple macro.
Macro file for example B1 - gps
/run/initialize
/gps/particle gamma
/gps/energy 60 keV
/run/printProgress 100
/run/beamOn 1000
Macro file for example B1 - gun
/run/initialize
/gun/particle gamma
/gun/energy 60 keV
/run/printProgress 1000
/run/beamOn 1000
I have modified primarygenerator.cc and runaction.cc accordingly for gps. I am attaching the results here:
exampleB1-gps.txt (48.2 KB)
exampleB1-gun.txt (49.4 KB)
Irrespective of the energy value provided with gps in the macro, the output files are always displaying " gamma of 1 MeV". This problem is not there when gun based macro is used. However, the tracking shows the energy 60 keV in both cases. Can anyone help me understand this?
Also, why is there a difference in scoring between both the cases?
Regards
Charubala
Hi Charubala
Did you find a fix this problem?
To understand this, I think we would have to see your PrimaryGeneratorAction.cc
.
John
Hi @allison ,
I haven’t solved the problem yet.
Here is PrimaryGeneratorAction.cc
for B1 with particle gun:
PrimaryGeneratorAction.cc (4.2 KB)
and gps:
PrimaryGeneratorAction.cc (3.2 KB)
Regards
Charubala
Hi Charubala
It could be because you have coded some behaviour in C++. Either do that or use commands – if you use both, there could be a mixup.
Here is what I use. A header file PrimaryGeneratorAction.hh
:
#ifndef PrimaryGeneratorAction_hh
#define PrimaryGeneratorAction_hh 1
#include "G4VUserPrimaryGeneratorAction.hh"
#include "G4GeneralParticleSource.hh"
class G4GeneralParticleSource;
class PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction
{
public:
PrimaryGeneratorAction();
virtual ~PrimaryGeneratorAction();
virtual void GeneratePrimaries(G4Event*);
private:
G4GeneralParticleSource* fpParticleGun;
};
#endif
and an implementation file PrimaryGeneratorAction.cc
:
#include "PrimaryGeneratorAction.hh"
#include "G4GeneralParticleSource.hh"
PrimaryGeneratorAction::PrimaryGeneratorAction()
{
fpParticleGun = new G4GeneralParticleSource;
}
PrimaryGeneratorAction::~PrimaryGeneratorAction()
{
delete fpParticleGun;
}
void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
{
fpParticleGun->GeneratePrimaryVertex(anEvent);
}
Let us know if you still have problems.
John
1 Like
Hi @allison ,
Thanks for helping. It worked.
Regards
Charubala
That’s great, Charubala. Thanks for letting us know.
system
Closed
June 23, 2024, 12:58pm
7
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.