From f82e7944bbbaebda6c7cebd4b28ba4d437ea1c3e Mon Sep 17 00:00:00 2001
From: MANZANILLAS Luis <manzanillas@sumo.cluster>
Date: Tue, 27 Jun 2023 17:36:09 +0200
Subject: [PATCH] fix bug in position for rectangular source

---
 src/PrimaryGeneratorAction.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/PrimaryGeneratorAction.cc b/src/PrimaryGeneratorAction.cc
index 60d14ff..7cb684d 100644
--- a/src/PrimaryGeneratorAction.cc
+++ b/src/PrimaryGeneratorAction.cc
@@ -72,8 +72,8 @@ void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
         G4ThreeVector position = G4ThreeVector(x_sourceframe, y_sourceframe, fPositionZ);
         
 	if (fSourceGeometry == 1){
-		x_sourceframe = fsource_size_X * (G4UniformRand() - 0.5);
-		y_sourceframe = fsource_size_Y * (G4UniformRand() - 0.5);
+		x_sourceframe = fPositionX + fsource_size_X * (G4UniformRand() - 0.5);
+		y_sourceframe = fPositionY + fsource_size_Y * (G4UniformRand() - 0.5);
         	position = G4ThreeVector(x_sourceframe, y_sourceframe, fPositionZ);
 	}
 
-- 
GitLab