From 7e520d88b94758107569f065291b1f7d79d37561 Mon Sep 17 00:00:00 2001 From: Jan Kieseler Date: Mon, 9 Sep 2024 14:56:30 +0200 Subject: [PATCH] fixes --- bind/G4Calo.py | 3 +++ src/DetectorConstruction.cc | 3 +++ src/PrimaryGeneratorAction.cc | 23 ++++++++++++++--------- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/bind/G4Calo.py b/bind/G4Calo.py index 7f5a7a0..9925618 100644 --- a/bind/G4Calo.py +++ b/bind/G4Calo.py @@ -213,6 +213,9 @@ def run_batch( assert (n_ex_non_zero==n_unique), f"only {n_unique} unique non-zero entries in total_dep_energy out of {n_ex_non_zero}" + if len(filename): + df.to_pickle(filename) + return alldf def _fill_event(gd : GeometryDescriptor, diff --git a/src/DetectorConstruction.cc b/src/DetectorConstruction.cc index 71f1c17..e2d6d7f 100644 --- a/src/DetectorConstruction.cc +++ b/src/DetectorConstruction.cc @@ -294,7 +294,10 @@ G4VPhysicalVolume* DetectorConstruction::DefineVolumes() position += layer.thickness / 2 *cm; //assign the physical volume to the layer + G4cout << "layer " << layer.name << " built with " << layer.sensors.size() << " sensors and depth of " << layer.thickness << G4endl; + } + //exit(0);// DEBUG // // Visualization attributes // diff --git a/src/PrimaryGeneratorAction.cc b/src/PrimaryGeneratorAction.cc index 9d6d12a..463d115 100644 --- a/src/PrimaryGeneratorAction.cc +++ b/src/PrimaryGeneratorAction.cc @@ -121,16 +121,21 @@ void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent) G4Exception("PrimaryGeneratorAction::GeneratePrimaries()", "MyCode0002", JustWarning, msg); } - //draw particle position from a unit distribution in x-y with +-7.5 cm around the center - G4double x = -1000; - G4double y = -1000; - G4double x_width = 15; - G4double y_width = 15; - while(x < -x_width/2. || x > x_width/2. || y < -y_width/2. || y > y_width/2.){ - x = G4INCL::Random::shoot()*x_width - x_width/2; - y = G4INCL::Random::shoot()*y_width - y_width/2; + if(false){ + //draw particle position from a unit distribution in x-y with +-3 cm around the center + G4double x = -1000; + G4double y = -1000; + G4double x_width = 6; + G4double y_width = 6; + while(x < -x_width/2. || x > x_width/2. || y < -y_width/2. || y > y_width/2.){ + x = G4INCL::Random::shoot()*x_width - x_width/2; + y = G4INCL::Random::shoot()*y_width - y_width/2; + } + fParticleGun->SetParticlePosition(G4ThreeVector(x*cm, y*cm, -worldZHalfLength)); + } + else{ + fParticleGun->SetParticlePosition(G4ThreeVector(0.*cm, 0.*cm, -worldZHalfLength)); } - fParticleGun->SetParticlePosition(G4ThreeVector(x*cm, y*cm, -worldZHalfLength)); //printout for checking //G4cout << "shooting at " << x << " " << y << " " << -worldZHalfLength << G4endl;