From e0c643d13ad8bb26eaf0700093425a1f446c1810 Mon Sep 17 00:00:00 2001 From: kochebina Date: Tue, 18 Jul 2023 11:02:42 +0200 Subject: [PATCH 1/2] Add option forceMinSecDifferenceToZero in CoinSorter for prototype testbench simus --- .../digits_hits/include/GateCoincidenceSorter.hh | 15 ++++++++++++--- .../include/GateCoincidenceSorterMessenger.hh | 1 + source/digits_hits/src/GateCoincidenceSorter.cc | 8 +++++--- .../src/GateCoincidenceSorterMessenger.cc | 10 +++++++++- 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/source/digits_hits/include/GateCoincidenceSorter.hh b/source/digits_hits/include/GateCoincidenceSorter.hh index eddae4237..f6762c95e 100644 --- a/source/digits_hits/include/GateCoincidenceSorter.hh +++ b/source/digits_hits/include/GateCoincidenceSorter.hh @@ -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 @@ -192,10 +199,12 @@ protected: private: //! \name Work storage variable //@{ - + G4bool m_forceMinSecDifferenceToZero; + std::list 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 diff --git a/source/digits_hits/include/GateCoincidenceSorterMessenger.hh b/source/digits_hits/include/GateCoincidenceSorterMessenger.hh index 91f32c5c1..82ead3444 100644 --- a/source/digits_hits/include/GateCoincidenceSorterMessenger.hh +++ b/source/digits_hits/include/GateCoincidenceSorterMessenger.hh @@ -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" diff --git a/source/digits_hits/src/GateCoincidenceSorter.cc b/source/digits_hits/src/GateCoincidenceSorter.cc index 597312011..7d9264c8c 100644 --- a/source/digits_hits/src/GateCoincidenceSorter.cc +++ b/source/digits_hits/src/GateCoincidenceSorter.cc @@ -39,6 +39,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), @@ -693,9 +694,10 @@ G4bool GateCoincidenceSorter::IsForbiddenCoincidence(const GateDigi* digi1, cons if (sectorDiff2<0) sectorDiff2 += sectorNumber; G4int sectorDifference = std::min(sectorDiff1,sectorDiff2); - + //G4cout<1) G4cout << "[GateCoincidenceSorter::IsForbiddenCoincidence]: coincidence between neighbor blocks --> refused\n"; return true; @@ -719,7 +721,7 @@ 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 (sectorDifference1) G4cout << "[GateCoincidenceSorter::IsForbiddenCoincidence]: coincidence between neighbour blocks --> refused\n"; return true; diff --git a/source/digits_hits/src/GateCoincidenceSorterMessenger.cc b/source/digits_hits/src/GateCoincidenceSorterMessenger.cc index 5a19d7de1..0ce249a91 100644 --- a/source/digits_hits/src/GateCoincidenceSorterMessenger.cc +++ b/source/digits_hits/src/GateCoincidenceSorterMessenger.cc @@ -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."); @@ -111,7 +117,7 @@ GateCoincidenceSorterMessenger::~GateCoincidenceSorterMessenger() delete SetTriggerOnlyByAbsorberCmd; delete SetAcceptancePolicy4CCCmd; delete SetEventIDCoincCmd; - + delete forceMinSectorDiffCmd; } @@ -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 ) From 2e90f2dc8eb6750fbeee4e8524cb7e5c7d13e011 Mon Sep 17 00:00:00 2001 From: kochebina Date: Thu, 27 Jul 2023 14:50:37 +0200 Subject: [PATCH 2/2] corrections in CoinSort --- source/digits_hits/include/GateDigi.hh | 5 +++++ source/digits_hits/src/GateCoincidenceSorter.cc | 13 +++++++++++-- .../src/GateDigitizerInitializationModule.cc | 1 + source/digits_hits/src/GateDigitizerMerger.cc | 6 +++--- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/source/digits_hits/include/GateDigi.hh b/source/digits_hits/include/GateDigi.hh index f6d411131..7be01d0ae 100644 --- a/source/digits_hits/include/GateDigi.hh +++ b/source/digits_hits/include/GateDigi.hh @@ -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;} @@ -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 diff --git a/source/digits_hits/src/GateCoincidenceSorter.cc b/source/digits_hits/src/GateCoincidenceSorter.cc index 7d9264c8c..40ca8bbec 100644 --- a/source/digits_hits/src/GateCoincidenceSorter.cc +++ b/source/digits_hits/src/GateCoincidenceSorter.cc @@ -14,6 +14,7 @@ See LICENSE.md for further details #include "GateVolumeID.hh" #include "GateObjectStore.hh" +#include "GateSystemListManager.hh" #include "GateCoincidenceSorterMessenger.hh" @@ -665,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 @@ -721,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 (sectorDifferenceGetSystemID()==digi2->GetSystemID())&& !m_forceMinSecDifferenceToZero ) { + //G4cout<GetSystemID()<<" "<GetSystemID()<1) G4cout << "[GateCoincidenceSorter::IsForbiddenCoincidence]: coincidence between neighbour blocks --> refused\n"; return true; diff --git a/source/digits_hits/src/GateDigitizerInitializationModule.cc b/source/digits_hits/src/GateDigitizerInitializationModule.cc index e9d2e3a1b..26165d81b 100644 --- a/source/digits_hits/src/GateDigitizerInitializationModule.cc +++ b/source/digits_hits/src/GateDigitizerInitializationModule.cc @@ -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 diff --git a/source/digits_hits/src/GateDigitizerMerger.cc b/source/digits_hits/src/GateDigitizerMerger.cc index 11cd93f3c..22aed3159 100755 --- a/source/digits_hits/src/GateDigitizerMerger.cc +++ b/source/digits_hits/src/GateDigitizerMerger.cc @@ -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; }