Skip to content

Commit

Permalink
Merge pull request #629 from kochebina/develop
Browse files Browse the repository at this point in the history
Add option forceMinSecDifferenceToZero in CoinSorter for prototype te…
  • Loading branch information
kochebina committed Aug 1, 2023
2 parents d3530b2 + 2e90f2d commit b81dbd1
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 11 deletions.
15 changes: 12 additions & 3 deletions source/digits_hits/include/GateCoincidenceSorter.hh
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,15 @@ public:
//! Set the minimum sector difference for valid coincidences
inline void SetMinSectorDifference(G4int diff)
{ m_minSectorDifference = diff; }

//! Get the depth of the system-level for coincidences

//! Get the force to 0 minimum sector difference for valid coincidences
inline G4bool GetForcedTo0MinSectorDifference() const
{ return m_forceMinSecDifferenceToZero; }
//! Set the force to 0 minimum sector difference for valid coincidences
inline void SetForcedTo0MinSectorDifference(G4bool diff)
{ m_forceMinSecDifferenceToZero = diff; }

//! Get the depth of the system-level for coincidences
inline G4int GetDepth() const
{ return m_depth; }
//! Set the depth of the system-level for coincidences
Expand Down Expand Up @@ -192,10 +199,12 @@ protected:
private:
//! \name Work storage variable
//@{

G4bool m_forceMinSecDifferenceToZero;

std::list<GateDigi*> m_presortBuffer; // incoming digis are presorted and buffered
G4int m_presortBufferSize;
G4bool m_presortWarning; // avoid repeat warnings

bool m_CCSorter; // compton camera sorter
G4bool m_triggerOnlyByAbsorber; //! Is the window only open by digis generated in the absorber ?
G4String m_absorberSD;// absorber "SD' volume name CC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ private:
G4UIcmdWithADoubleAndUnit *windowJitterCmd; //!< the UI command 'setWindowJitter'
G4UIcmdWithADoubleAndUnit *offsetJitterCmd; //!< the UI command 'setOffsetJitter'
G4UIcmdWithAnInteger *minSectorDiffCmd; //!< the UI command 'minSectorDifference'
G4UIcmdWithABool *forceMinSectorDiffCmd;
G4UIcmdWithAnInteger *setDepthCmd; //!< the UI command 'setDepth'
G4UIcmdWithAnInteger *setPresortBufferSizeCmd; //!< the UI command 'setPresortBufferSize'
G4UIcmdWithAString *SetInputNameCmd; //!< The UI command "set input name"
Expand Down
5 changes: 5 additions & 0 deletions source/digits_hits/include/GateDigi.hh
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ public:
inline const GateOutputVolumeID& GetOutputVolumeID() const { return m_outputVolumeID; }
inline G4int GetComponentID(size_t depth) const { return (m_outputVolumeID.size()>depth) ? m_outputVolumeID[depth] : -1; }

inline void SetSystemID(const G4int systemID) { m_systemID = systemID; }
inline G4int GetSystemID() const { return m_systemID; }


#ifdef GATE_USE_OPTICAL
inline void SetOptical(G4bool optical = true) { m_optical = optical;}
Expand Down Expand Up @@ -221,6 +224,8 @@ public:
G4ThreeVector m_scannerPos; //!< Position of the scanner
G4double m_scannerRotAngle; //!< Rotation angle of the scanner
GateOutputVolumeID m_outputVolumeID;
G4int m_systemID; // system ID in for the multi-system approach

#ifdef GATE_USE_OPTICAL
G4bool m_optical; //!< Is the pulse generated by optical photons
#endif
Expand Down
19 changes: 15 additions & 4 deletions source/digits_hits/src/GateCoincidenceSorter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ See LICENSE.md for further details

#include "GateVolumeID.hh"
#include "GateObjectStore.hh"
#include "GateSystemListManager.hh"


#include "GateCoincidenceSorterMessenger.hh"
Expand All @@ -39,6 +40,7 @@ GateCoincidenceSorter::GateCoincidenceSorter(GateDigitizerMgr* itsDigitizerMgr,
m_offset(0.),
m_offsetJitter(0.),
m_minSectorDifference(2),
m_forceMinSecDifferenceToZero(false),
m_multiplesPolicy(kKeepIfAllAreGoods),
m_allDigiOpenCoincGate(false),
m_depth(1),
Expand Down Expand Up @@ -664,7 +666,14 @@ G4int GateCoincidenceSorter::ComputeSectorID(const GateDigi& digi)
// Check whether a coincidence is invalid: ring difference or sector difference too small...
G4bool GateCoincidenceSorter::IsForbiddenCoincidence(const GateDigi* digi1, const GateDigi* digi2)
{
G4int blockID1 = m_system->GetMainComponentIDGND(digi1),

if(!GateSystemListManager::GetInstance()->GetIsAnySystemDefined())
{
// TODO GND define case if there is no system defiend!

}

G4int blockID1 = m_system->GetMainComponentIDGND(digi1),
blockID2 = m_system->GetMainComponentIDGND(digi2);

// Modif by D. Lazaro, February 25th, 2004
Expand Down Expand Up @@ -693,9 +702,10 @@ G4bool GateCoincidenceSorter::IsForbiddenCoincidence(const GateDigi* digi1, cons
if (sectorDiff2<0)
sectorDiff2 += sectorNumber;
G4int sectorDifference = std::min(sectorDiff1,sectorDiff2);

//G4cout<<sectorDifference<<G4endl;

//Compare the sector difference with the minimum differences for valid coincidences
if (sectorDifference<m_minSectorDifference) {
if (sectorDifference<m_minSectorDifference && !m_forceMinSecDifferenceToZero) {
if (nVerboseLevel>1)
G4cout << "[GateCoincidenceSorter::IsForbiddenCoincidence]: coincidence between neighbor blocks --> refused\n";
return true;
Expand All @@ -719,7 +729,8 @@ G4bool GateCoincidenceSorter::IsForbiddenCoincidence(const GateDigi* digi1, cons
G4int sectorDifference = std::min(sectorDiff1,sectorDiff2);

//Compare the sector difference with the minimum differences for valid coincidences
if (sectorDifference<m_minSectorDifference) {
if (sectorDifference<m_minSectorDifference && (digi1->GetSystemID()==digi2->GetSystemID())&& !m_forceMinSecDifferenceToZero ) {
//G4cout<<digi1->GetSystemID()<<" "<<digi2->GetSystemID()<<G4endl;
if (nVerboseLevel>1)
G4cout << "[GateCoincidenceSorter::IsForbiddenCoincidence]: coincidence between neighbour blocks --> refused\n";
return true;
Expand Down
10 changes: 9 additions & 1 deletion source/digits_hits/src/GateCoincidenceSorterMessenger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ GateCoincidenceSorterMessenger::GateCoincidenceSorterMessenger(GateCoincidenceSo
minSectorDiffCmd->SetParameterName("diff",false);
minSectorDiffCmd->SetRange("diff>=1");

cmdName = GetDirectoryName()+"forceMinSecDifferenceToZero";
forceMinSectorDiffCmd = new G4UIcmdWithABool(cmdName,this);
forceMinSectorDiffCmd->SetGuidance("Force the minimum sector difference for valid coincidences to 0: specsific case for prototype testbench simulations.");
forceMinSectorDiffCmd->SetParameterName("ForceDiff0",false);


cmdName = GetDirectoryName()+"setDepth";
setDepthCmd = new G4UIcmdWithAnInteger(cmdName.c_str(),this);
setDepthCmd->SetGuidance("Set the depth of system-level for coincidences.");
Expand Down Expand Up @@ -111,7 +117,7 @@ GateCoincidenceSorterMessenger::~GateCoincidenceSorterMessenger()
delete SetTriggerOnlyByAbsorberCmd;
delete SetAcceptancePolicy4CCCmd;
delete SetEventIDCoincCmd;

delete forceMinSectorDiffCmd;
}


Expand All @@ -125,6 +131,8 @@ void GateCoincidenceSorterMessenger::SetNewValue(G4UIcommand* aCommand, G4String
{ m_CoincidenceSorter->SetOffset(offsetCmd->GetNewDoubleValue(newValue)); }
else if( aCommand == offsetJitterCmd )
{ m_CoincidenceSorter->SetOffsetJitter(offsetJitterCmd->GetNewDoubleValue(newValue)); }
else if( aCommand == forceMinSectorDiffCmd )
{ m_CoincidenceSorter->SetForcedTo0MinSectorDifference(forceMinSectorDiffCmd->GetNewBoolValue(newValue)); }
else if( aCommand == minSectorDiffCmd )
{ m_CoincidenceSorter->SetMinSectorDifference(minSectorDiffCmd->GetNewIntValue(newValue)); }
else if( aCommand == setDepthCmd )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ void GateDigitizerInitializationModule::Digitize()
Digi->SetComptonVolumeName( (*inHC)[i]->GetComptonVolumeName() );
Digi->SetRayleighVolumeName( (*inHC)[i]->GetRayleighVolumeName() );
Digi->SetVolumeID( (*inHC)[i]->GetVolumeID() );
Digi->SetSystemID( (*inHC)[i]->GetSystemID() );
Digi->SetScannerPos( (*inHC)[i]->GetScannerPos() );
Digi->SetScannerRotAngle( (*inHC)[i]->GetScannerRotAngle() );
#ifdef GATE_USE_OPTICAL
Expand Down
6 changes: 3 additions & 3 deletions source/digits_hits/src/GateDigitizerMerger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ void GateDigitizerMerger::Digitize()
{
//GateDigiCollection* IDCerror = 0;
//G4String err = fDM->GetDigiCollection(m_DCID-1)->GetName();
//TODO add more clean error messege
GateError("***ERROR*** Wrong usage of Merger Digitizer Module: the Digi collection that you want to use doesn't exist yet (not digitized yet). The Merger must be inserted as a module of last called sensitive detector\n "
"Please, read the description here: XXXX \n\n");
GateError("***ERROR*** Wrong usage of Merger Digitizer Module: the Digi collection that you want to use doesn't exist yet (not digitized yet?). The Merger must be inserted as a module of last called sensitive detector\n "
"Please, read the description here: https://opengate.readthedocs.io/en/latest/digitizer_and_detector_modeling.html#id28 \n "
"It is also possible that your input collection is empty at the first event. This bug will be addressed soon. \n\n");
return;

}
Expand Down

0 comments on commit b81dbd1

Please sign in to comment.