I am working on simulating a scintillation detector using GEANT4 but getting confused when we mention energy in detector construction class and PrimaryGeneratorAction class. Why do we mention it two times and what is the difference between these two ?
PrimaryGeneratorAction::PrimaryGeneratorAction()
{
G4int n_particle = 1;
fParticleGun = new G4ParticleGun(n_particle);
// default particle kinematic
G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
G4String particleName;
G4ParticleDefinition* particle
= particleTable->FindParticle(particleName="gamma");
fParticleGun->SetParticleDefinition(particle);
fParticleGun->SetParticleMomentumDirection(G4ThreeVector(0.,0.,1.));
**fParticleGun->SetParticleEnergy(6.*MeV);** //ENERGY
and in detector class we have
void DetectorConstruction::DefineMaterial()
{
G4NistManager *nist = G4NistManager::Instance();
G4Material *worldMat = nist->FindOrBuildMaterial("G4_AIR");
G4MaterialPropertiesTable *mptWorld = new G4MaterialPropertiesTable();
G4Element* Na = nist->FindOrBuildElement("Na");
G4Element* I = nist->FindOrBuildElement("I");
G4Material* NaI = new G4Material("NaI", 3.67*g/cm3, 2);
NaI->AddElement(Na, 1);
NaI->AddElement(I, 1);
G4double fraction[2] = {1.0, 1.0};
G4double rindexNaI[2] = {1.78, 1.78};
**G4double energy[2] = {1.0*eV,7.0*eV};** //ENERGY
}