Skip to content

Commit

Permalink
Clean up of the code, flexibility for the axis and command for the ma…
Browse files Browse the repository at this point in the history
…cro generator.
  • Loading branch information
Marc Granado committed Sep 18, 2024
1 parent 08c012e commit ce8eb3a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
5 changes: 3 additions & 2 deletions source/digits_hits/include/GateVirtualSegmentationSD.hh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ See LICENSE.md for further details


/*! \class GateVirtualSegmentationSD
\brief GateVirtualSegmentationSD does some dummy things with input digi
to create output digi
\brief GateVirtualSegmentationSD - For each volume the local position of the interactions within the crystal are virtually segmented.
the X,Y,Z vector is translated into the IDs of virtual divisions within the crystal
- GateVirtualSegmentationSD - by marc.granado@universite-paris-saclay.fr
Expand Down
2 changes: 1 addition & 1 deletion source/digits_hits/src/GateSinglesDigitizerMessenger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ See LICENSE.md for further details
/*!
\class GateSinglesDigitizerMessenger
Last modification (Adaptation to GND): May 2023 by Mohamed-Jordan Soumano mjsoumano@yahoo.com
Last modification (Adaptation to GND): July 2024 by Marc Granado-Gonzalez marc.granado@universite-paris-saclay.fr
*/

#include "GateSinglesDigitizer.hh"
Expand Down
29 changes: 23 additions & 6 deletions source/digits_hits/src/GateVirtualSegmentationSD.cc
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,15 @@ void GateVirtualSegmentationSD::Digitize()
std::string command = "python3 "+path_to_script+"macro_converter.py";
command +=" -d "+path_to_macros+"digitizer.mac";
command +=" -g "+path_to_macros+"geometry_pseudo-crystal.mac";

if (pitchX) command +=" -x "+std::to_string(pitchX);
if (pitchY) command +=" -y "+std::to_string(pitchY);
if (pitchZ) command +=" -z "+std::to_string(pitchZ);

if (nBinsX) command +=" --binsX "+std::to_string(nBinsX);
if (nBinsY) command +=" --binsY "+std::to_string(nBinsY);
if (nBinsZ) command +=" --binsZ "+std::to_string(nBinsZ);

int result = system(command.c_str());
if (result ==0) std::cout<<"The macro converter script has been executed corectly"<<std::endl;
else std::cout<<"There was an error in the execution of the macro converter script"<<std::endl;
Expand Down Expand Up @@ -333,7 +342,7 @@ G4double GateVirtualSegmentationSD::calculatePitch(G4double crystal_size, G4doub
break;
}
else if (num_pitches>1000){
std::cout<<"ERROR! No pitch found in 1000 iterations!"<<std::endl;
std::cout<<"ERROR! No pitch found in 1000 iterations! Size = "<<crystal_size<<" and desired pitch = "<<pitch<<std::endl;
break;
}

Expand Down Expand Up @@ -479,16 +488,21 @@ void GateVirtualSegmentationSD::SetParameters()
if(pitchX == 0 && m_nameAxis.find('X') != std::string::npos)
{GateError("***ERROR*** Virtual setmentation in X axis has been selected but no value for FWHM was provided.");
}
else{
pitchX = calculatePitch(xLength,pitchX);
nBinsX = int(xLength/pitchX);
else if (pitchX!=0){

std::cout<<"Calculating pitchX with = "<<pitchX<<std::endl;
pitchX = calculatePitch(xLength,pitchX);
std::cout<<"Resulting pitchX = "<<pitchX<<std::endl;
nBinsX = int(xLength/pitchX);
}

if(pitchY == 0 && m_nameAxis.find('Y') != std::string::npos)
{GateError("***ERROR*** Virtual setmentation in Y axis has been selected but no value for FWHM was provided.");
}
else{
else if (pitchY!=0){
std::cout<<"Calculating pitchY with = "<<pitchY<<std::endl;
pitchY = calculatePitch(yLength,pitchY);
std::cout<<"Resulting pitchY = "<<pitchY<<std::endl;
nBinsY = int(yLength/pitchY);
}

Expand All @@ -497,8 +511,11 @@ void GateVirtualSegmentationSD::SetParameters()
if(pitchZ == 0 && m_nameAxis.find('Z') != std::string::npos)
{GateError("***ERROR*** Virtual setmentation in Z axis has been selected but no value for FWHM was provided.");
}
else{
else if (pitchZ!=0){

std::cout<<"Calculating pitchZ with = "<<pitchZ<<std::endl;
pitchZ = calculatePitch(zLength,pitchZ);
std::cout<<"Resulting pitchZ = "<<pitchZ<<std::endl;
nBinsZ = int(zLength/pitchZ);
}

Expand Down

0 comments on commit ce8eb3a

Please sign in to comment.