Difference in energies mentioned in different files of a detector

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 ?

  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->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

The particle energy is the kinetic energy you are assigning to your beam (primary) particle.

The array of “energies” in your material definition is used to define bins of wavelength-dependent index of refraction. As you know, wavelength, frequency, and energy of photons are all related. Genat4 has chosen to do the optical properties binning in energy, rather than in wavelength.

1 Like

Got it. Thank you so much for your valuable time and response !

So how does these bins are calculated ? If I am deciding the energy of my gamma ray then how these bins would vary ?

They are determined by the properties of the material you are using your simulation. If it’s glass, then you should look up how the index of refraction of glass varies with wavelength. If it’s teflon, you should look up the index of refraction of teflon. And so on.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.