# Way more deposited energy when using only one particle source instead of two

Hi,

I have the weird situation that when I de-activate one of two particle guns, I receive much more energy inside three detectors than when using both of them. In case the geometry matters I will provide it but from my understanding I’d assume that I simply shut off one particle gun which removes its amount of deposited energy inside the detectors so in the end when using only one particle gun the deposited energy in total must be (much) less than when using two of them. Or not?
I’m always generating the same amount of photons via run.mac with the command line `/run/beamOn 100000000`.
Below is the code I’m using to set up the generators:

``````int reduce_sampling = 0;

void MyPrimaryGenerator::GeneratePrimaries(G4Event *anEvent)
{

bool gen_1 = true;
bool gen_2 = true;
int z = 0;

// position of generator 1

if(gen_1)
{
G4ThreeVector pos1(-(1010/2 - 30)*mm, -30*cm - 1.8*mm, z*mm);
fParticleGun->SetParticlePosition(pos1);
G4double phi = 78*deg;
G4double a = phi*G4UniformRand() + 90*deg - phi;
G4double b = 2*deg*G4UniformRand() - 1*deg;
G4ThreeVector v(std::cos(a), std::sin(a), b);
fParticleGun->SetParticleMomentumDirection(v);
}

G4double energy = InverseCumul();
fParticleGun->SetParticleEnergy(energy);
fParticleGun->GeneratePrimaryVertex(anEvent);

// position of generator 2
if(gen_2)
{
if(reduce_sampling > 18)
{
// 1001002VS
G4ThreeVector pos4((1010/2 + 230)*mm, +1.8*mm, z*mm);
fParticleGun->SetParticlePosition(pos4);
G4double phi = (78/10/2)*deg;
G4double a = phi*G4UniformRand() + 180*deg - phi;
G4double b = 2*deg*G4UniformRand() - 1*deg;
G4ThreeVector w(std::cos(a), std::sin(a), b);
fParticleGun->SetParticleMomentumDirection(w);
fParticleGun->GeneratePrimaryVertex(anEvent);
reduce_sampling = 0;
}
reduce_sampling += 1;
}

}
``````

What is the issue?
Thanks a lot for any input!

Could it be that when I comment out the generator 1 and I run the simulation always for the same amount of photons that, thus, way more photons are generated from generator 2 than when using both of them in parallel?