From c26b199058bfa5f98843b54619ccb153070fa60a Mon Sep 17 00:00:00 2001 From: Marc Granado Date: Wed, 23 Oct 2024 14:16:25 +0200 Subject: [PATCH 1/2] Fixing small bug when target_pitch is best_pitch --- source/digits_hits/src/GateVirtualSegmentationSD.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/digits_hits/src/GateVirtualSegmentationSD.cc b/source/digits_hits/src/GateVirtualSegmentationSD.cc index afe840117..8ee984876 100644 --- a/source/digits_hits/src/GateVirtualSegmentationSD.cc +++ b/source/digits_hits/src/GateVirtualSegmentationSD.cc @@ -295,6 +295,8 @@ G4double GateVirtualSegmentationSD::calculatePitch(G4double crystal_size, G4doub double min_diff = 999; int num_pitches = 1; + if (std::fmod(crystal_size, target_pitch) == 0) return target_pitch; + while (true) { double pitch = crystal_size / num_pitches; From 21c09778091fd3f01f5de721523b970b6c0765ab Mon Sep 17 00:00:00 2001 From: Marc Granado Date: Thu, 28 Nov 2024 17:57:07 +0100 Subject: [PATCH 2/2] Fixing bug at virtual segmentation for hits at the back surface --- source/digits_hits/src/GateVirtualSegmentationSD.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/source/digits_hits/src/GateVirtualSegmentationSD.cc b/source/digits_hits/src/GateVirtualSegmentationSD.cc index 8ee984876..56efaaf4e 100644 --- a/source/digits_hits/src/GateVirtualSegmentationSD.cc +++ b/source/digits_hits/src/GateVirtualSegmentationSD.cc @@ -295,8 +295,6 @@ G4double GateVirtualSegmentationSD::calculatePitch(G4double crystal_size, G4doub double min_diff = 999; int num_pitches = 1; - if (std::fmod(crystal_size, target_pitch) == 0) return target_pitch; - while (true) { double pitch = crystal_size / num_pitches; @@ -334,8 +332,12 @@ void GateVirtualSegmentationSD::SetVirtualID( int nBins, double pitch, G4double bin = std::floor(pos/pitch+nBins/2.); + if (bin == nBins) bin -=1; + if (bin < 0) bin = 0; m_outputDigi->SetOutputVolumeID(bin,depth); + //std::cout<<"Pos at depth"<