Skip to content

Commit

Permalink
Merge pull request OpenGATE#611 from tontyoutoure/tontyoutoure_spatia…
Browse files Browse the repository at this point in the history
…l_resolution_fix

Fix spatial resolution digitizer reqiuring all levels of geometry being defined
  • Loading branch information
kochebina authored Jun 7, 2023
2 parents e73015d + 953cc1b commit b3b7408
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
7 changes: 4 additions & 3 deletions source/digits_hits/src/GateSpatialResolution.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,11 @@ void GateSpatialResolution::Digitize()
if (m_system==NULL) G4Exception( "GateSpatialResolution::Digitize", "Digitize", FatalException,
"Failed to get the system corresponding to that digitizer. Abort.\n");

if (!m_system->CheckIfAllLevelsAreDefined())
if (!m_system->CheckIfEnoughLevelsAreDefined())
{
GateError( " *** ERROR*** GateSpatialResolution::Digitize. Not all required geometry levels and sublevels for this system are defined. "
"(Ex.: for cylindricalPET, the required levels are: rsector, module, submodule, crystal). Please, add them to your geometry macro in /gate/systems/cylindricalPET/XXX/attach YYY. Abort.\n");
GateError( " *** ERROR*** GateSpatialResolution::Digitize. Not all defined geometry levels has their mother levels defined."
"(Ex.: for cylindricalPET, the levels are: rsector, module, submodule, crystal). If you have defined submodule, you have to have resector and module defined as well."
"Please, add them to your geometry macro in /gate/systems/cylindricalPET/XXX/attach YYY. Abort.\n");
}

m_systemDepth = m_system->GetTreeDepth();
Expand Down
4 changes: 4 additions & 0 deletions source/geometry/include/GateVSystem.hh
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@ class GateVSystem : public GateClockDependent
//! Checks if all levels are defined in the system (need by readout and spatial resolution)
G4bool CheckIfAllLevelsAreDefined();

// Checks if all the ancestors of the lowest defined level are also defined.
// For spatial reslution to work with some undefined low levels.
G4bool CheckIfEnoughLevelsAreDefined();

//! Generate the output-volumeID based on the information stored in the volumeID
virtual GateOutputVolumeID ComputeOutputVolumeID(const GateVolumeID& aVolumeID);

Expand Down
23 changes: 23 additions & 0 deletions source/geometry/src/GateVSystem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,29 @@ G4bool GateVSystem::CheckIfAllLevelsAreDefined()
}
//-----------------------------------------------------------------------------

G4bool GateVSystem::CheckIfEnoughLevelsAreDefined()
{
G4int systemDepth=this->GetTreeDepth();
G4bool has_undefined_high_level = false;
for (G4int i=1;i<systemDepth-1;i++)
{
auto compList = this->MakeComponentListAtLevel(i);
GateSystemComponent* comp0= compList[0][0];
if (!comp0->GetCreator())
{
if (!has_undefined_high_level)
has_undefined_high_level = true;
}
else if (has_undefined_high_level)
{
delete compList;
return false;
}
delete compList;
}

return true;
}

//-----------------------------------------------------------------------------
GateVSystem::compList_t* GateVSystem::MakeComponentListAtLevel(G4int level) const
Expand Down

0 comments on commit b3b7408

Please sign in to comment.