diff --git a/source/digits_hits/include/GateCoincidenceGeometrySelector.hh b/source/digits_hits/include/GateCoincidenceGeometrySelector.hh deleted file mode 100644 index 7b61b2cce..000000000 --- a/source/digits_hits/include/GateCoincidenceGeometrySelector.hh +++ /dev/null @@ -1,67 +0,0 @@ -/*---------------------- - Copyright (C): OpenGATE Collaboration - -This software is distributed under the terms -of the GNU Lesser General Public Licence (LGPL) -See LICENSE.md for further details -----------------------*/ - - -#ifndef GateCoincidenceGeometrySelector_h -#define GateCoincidenceGeometrySelector_h 1 - -#include "globals.hh" -#include -#include -#include "G4ThreeVector.hh" - -#include "GateVPulseProcessor.hh" -#include "GateObjectStore.hh" -#include "GateVCoincidencePulseProcessor.hh" - -class GateCoincidenceGeometrySelectorMessenger; - - -class GateCoincidenceGeometrySelector : public GateVCoincidencePulseProcessor -{ -public: - - - - //! Destructor - virtual ~GateCoincidenceGeometrySelector() ; - - - //! Constructs a new dead time attached to a GateDigitizer - GateCoincidenceGeometrySelector(GateCoincidencePulseProcessorChain* itsChain, - const G4String& itsName); - -public: - - //! Returns the GeometrySelector - G4double GetMaxS() const {return m_maxS;} - G4double GetMaxDeltaZ() const {return m_maxDeltaZ;} - - //! Set the GeometrySelector - void SetMaxS(G4double val) { m_maxS = val;} - void SetMaxDeltaZ(G4double val) { m_maxDeltaZ = val;} - - //! Implementation of the pure virtual method declared by the base class GateClockDependent - //! print-out the attributes specific of the GeometrySelector - virtual void DescribeMyself(size_t indent); - -protected: - - /*! Implementation of the pure virtual method declared by the base class GateVCoincidencePulseProcessor*/ - GateCoincidencePulse* ProcessPulse(GateCoincidencePulse* inputPulse,G4int iPulse); - - - -private: - G4double m_maxS; //!< contains the rebirth time. - G4double m_maxDeltaZ; //!< contains the rebirth time. - GateCoincidenceGeometrySelectorMessenger *m_messenger; //!< Messenger -}; - - -#endif diff --git a/source/digits_hits/include/GateCoincidenceGeometrySelectorMessenger.hh b/source/digits_hits/include/GateCoincidenceGeometrySelectorMessenger.hh deleted file mode 100644 index 1804af823..000000000 --- a/source/digits_hits/include/GateCoincidenceGeometrySelectorMessenger.hh +++ /dev/null @@ -1,35 +0,0 @@ -/*---------------------- - Copyright (C): OpenGATE Collaboration - -This software is distributed under the terms -of the GNU Lesser General Public Licence (LGPL) -See LICENSE.md for further details -----------------------*/ - - -#ifndef GateCoincidenceGeometrySelectorMessenger_h -#define GateCoincidenceGeometrySelectorMessenger_h 1 - -#include "GatePulseProcessorMessenger.hh" - -class G4UIdirectory; -class G4UIcmdWithADoubleAndUnit; - -class GateCoincidenceGeometrySelector; - -class GateCoincidenceGeometrySelectorMessenger: public GateClockDependentMessenger -{ -public: - GateCoincidenceGeometrySelectorMessenger(GateCoincidenceGeometrySelector* itsGeometrySelector); - virtual ~GateCoincidenceGeometrySelectorMessenger(); - - inline void SetNewValue(G4UIcommand* aCommand, G4String aString); - - inline GateCoincidenceGeometrySelector* GetGeometrySelector(){ return (GateCoincidenceGeometrySelector*) GetClockDependent(); } - -private: - G4UIcmdWithADoubleAndUnit *maxSCmd; //!< set the max time window - G4UIcmdWithADoubleAndUnit *maxDeltaZCmd; //!< set the max time window -}; - -#endif diff --git a/source/digits_hits/include/GateCoincidenceSorter.hh b/source/digits_hits/include/GateCoincidenceSorter.hh index f6762c95e..be6a893c0 100644 --- a/source/digits_hits/include/GateCoincidenceSorter.hh +++ b/source/digits_hits/include/GateCoincidenceSorter.hh @@ -170,6 +170,12 @@ public: void SetAcceptancePolicy4CC(const G4String& policy); + G4double GetMinS() const {return m_minS;} + G4double GetMaxDeltaZ() const {return m_maxDeltaZ;} + + //! Set the GeometrySelector + void SetMinS(G4double val) { m_minS = val;} + void SetMaxDeltaZ(G4double val) { m_maxDeltaZ = val;} @@ -190,7 +196,8 @@ protected: acceptance_policy_4CC_t m_acceptance_policy_4CC; //! AddNewModule(newDM); } - /*else if (childTypeName=="readout") { newDM = new GateReadout(m_digitizer, DMname); diff --git a/source/digits_hits/src/GateCoincidenceGeometrySelector.cc b/source/digits_hits/src/GateCoincidenceGeometrySelector.cc deleted file mode 100644 index 7fdf6beef..000000000 --- a/source/digits_hits/src/GateCoincidenceGeometrySelector.cc +++ /dev/null @@ -1,98 +0,0 @@ -/*---------------------- - Copyright (C): OpenGATE Collaboration - -This software is distributed under the terms -of the GNU Lesser General Public Licence (LGPL) -See LICENSE.md for further details -----------------------*/ - - -#include "GateCoincidenceGeometrySelector.hh" -#include "G4UnitsTable.hh" -#include "GateCoincidenceGeometrySelectorMessenger.hh" -#include "GateTools.hh" -#include "GateVolumeID.hh" -#include "GateOutputVolumeID.hh" -#include "GateVVolume.hh" -#include "GateDetectorConstruction.hh" -#include "GateCrystalSD.hh" -#include "GateVSystem.hh" -#include "GateObjectChildList.hh" -#include "GateMaps.hh" - - - - -GateCoincidenceGeometrySelector::GateCoincidenceGeometrySelector(GateCoincidencePulseProcessorChain* itsChain, - const G4String& itsName) - : GateVCoincidencePulseProcessor(itsChain,itsName) -{ - m_maxS = -1; - m_maxDeltaZ = -1; - - m_messenger = new GateCoincidenceGeometrySelectorMessenger(this); -} - - - - -GateCoincidenceGeometrySelector::~GateCoincidenceGeometrySelector() -{ - delete m_messenger; -} - - - - -GateCoincidencePulse* GateCoincidenceGeometrySelector::ProcessPulse(GateCoincidencePulse* inputPulse,G4int ) -{ - if (!inputPulse) { - if (nVerboseLevel>1) - G4cout << "[GateCoincidenceGeometrySelector::ProcessOnePulse]: input pulse was null -> nothing to do\n\n"; - return 0; - } - - G4double s; - if (inputPulse->size() != 2) { - if (nVerboseLevel>1) - G4cout << "[GateCoincidenceGeometrySelector::ProcessOnePulse]: input pulse has not 2 pulses -> nothing to do\n\n"; - return 0; - } - - G4ThreeVector globalPos1 = (*inputPulse)[0]->GetGlobalPos(); - G4ThreeVector globalPos2 = (*inputPulse)[1]->GetGlobalPos(); - - if ((m_maxDeltaZ>0) && (fabs(globalPos2.z()-globalPos1.z())>m_maxDeltaZ) ) - return 0; - - G4double denom = (globalPos1.y()-globalPos2.y()) * (globalPos1.y()-globalPos2.y()) + - (globalPos2.x()-globalPos1.x()) * (globalPos2.x()-globalPos1.x()); - - if (denom!=0.) { - denom = sqrt(denom); - - s = ( globalPos1.x() * (globalPos1.y()-globalPos2.y()) + - globalPos1.y() * (globalPos2.x()-globalPos1.x()) ) - / denom; - } else { - s = 0.; - } - - G4double theta; - theta = atan2(globalPos1.x()-globalPos2.x(), globalPos1.y()-globalPos2.y()); - if ( theta < 0.) { - theta = theta + pi; - s = -s; - } - if ((m_maxS>0) && (fabs(s)>m_maxS) ) return 0; - - return new GateCoincidencePulse(*inputPulse); -} - - -void GateCoincidenceGeometrySelector::DescribeMyself(size_t indent) -{ - G4cout << GateTools::Indent(indent) << "GeometrySelector: " - << "SMax : "<SetGuidance("Set max S value accepted (<0 --> all is accepted)"); - maxSCmd->SetUnitCategory("Length"); - - cmdName = GetDirectoryName() + "setDeltaZMax"; - maxDeltaZCmd= new G4UIcmdWithADoubleAndUnit(cmdName,this); - maxDeltaZCmd->SetGuidance("Set max delta Z value accepted (<0 --> all is accepted)"); - maxDeltaZCmd->SetUnitCategory("Length"); -} - - -GateCoincidenceGeometrySelectorMessenger::~GateCoincidenceGeometrySelectorMessenger() -{ - delete maxSCmd; - delete maxDeltaZCmd; -} - - -void GateCoincidenceGeometrySelectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue) -{ - if (command==maxSCmd) - GetGeometrySelector()->SetMaxS(maxSCmd->GetNewDoubleValue(newValue)); - else if (command==maxDeltaZCmd) - GetGeometrySelector()->SetMaxDeltaZ(maxDeltaZCmd->GetNewDoubleValue(newValue)); - else - GateClockDependentMessenger::SetNewValue(command,newValue); -} diff --git a/source/digits_hits/src/GateCoincidenceSorter.cc b/source/digits_hits/src/GateCoincidenceSorter.cc index 2be1c2d42..f77f905fd 100644 --- a/source/digits_hits/src/GateCoincidenceSorter.cc +++ b/source/digits_hits/src/GateCoincidenceSorter.cc @@ -40,6 +40,8 @@ GateCoincidenceSorter::GateCoincidenceSorter(GateDigitizerMgr* itsDigitizerMgr, m_offset(0.), m_offsetJitter(0.), m_minSectorDifference(2), + m_minS (-1), + m_maxDeltaZ ( -1), m_forceMinSecDifferenceToZero(false), m_multiplesPolicy(kKeepIfAllAreGoods), m_allDigiOpenCoincGate(false), @@ -737,10 +739,37 @@ G4bool GateCoincidenceSorter::IsForbiddenCoincidence(const GateDigi* digi1, cons G4cout << "[GateCoincidenceSorter::IsForbiddenCoincidence]: coincidence between neighbour blocks --> refused\n"; return true; } + G4ThreeVector globalPos1 = digi1->GetGlobalPos(); + G4ThreeVector globalPos2 = digi2->GetGlobalPos(); - return false; - } + // Check the difference in Z between the two positions + if ((m_maxDeltaZ > 0) && (fabs(globalPos2.z() - globalPos1.z()) > m_maxDeltaZ)) { + if (nVerboseLevel > 1) + G4cout << "[GateCoincidenceSorter::IsForbiddenCoincidence]: difference in Z too large --> refused\n"; + return true; + } + + // Calculate the denominator for distance 's' in the XY plane + G4double denom = (globalPos1.y() - globalPos2.y()) * (globalPos1.y() - globalPos2.y()) + + (globalPos2.x() - globalPos1.x()) * (globalPos2.x() - globalPos1.x()); + + G4double s = 0.0; + if (denom != 0.0) { + denom = sqrt(denom); + s = (globalPos1.x() * (globalPos1.y() - globalPos2.y()) + + globalPos1.y() * (globalPos2.x() - globalPos1.x())) / denom; + } + + // Check the distance 's' against the maximum threshold + if ((m_minS < 0) && (fabs(s) < m_minS)) { + if (nVerboseLevel > 1) + G4cout << "[GateCoincidenceSorter::IsForbiddenCoincidence]: distance s too large --> refused\n"; + return true; + } + + return false; + } } //------------------------------------------------------------------------------------------------------ diff --git a/source/digits_hits/src/GateCoincidenceSorterMessenger.cc b/source/digits_hits/src/GateCoincidenceSorterMessenger.cc index e12cfc6f7..0c7842d46 100644 --- a/source/digits_hits/src/GateCoincidenceSorterMessenger.cc +++ b/source/digits_hits/src/GateCoincidenceSorterMessenger.cc @@ -53,6 +53,16 @@ GateCoincidenceSorterMessenger::GateCoincidenceSorterMessenger(GateCoincidenceSo minSectorDiffCmd->SetParameterName("diff",false); minSectorDiffCmd->SetRange("diff>=1"); + cmdName = GetDirectoryName() + "setSMin"; + minSCmd= new G4UIcmdWithADoubleAndUnit(cmdName,this); + minSCmd->SetGuidance("Set min S value accepted (<0 --> all is accepted)"); + minSCmd->SetUnitCategory("Length"); + + cmdName = GetDirectoryName() + "setDeltaZMax"; + maxDeltaZCmd= new G4UIcmdWithADoubleAndUnit(cmdName,this); + maxDeltaZCmd->SetGuidance("Set max delta Z value accepted (<0 --> all is accepted)"); + maxDeltaZCmd->SetUnitCategory("Length"); + 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."); @@ -118,6 +128,8 @@ GateCoincidenceSorterMessenger::~GateCoincidenceSorterMessenger() delete SetAcceptancePolicy4CCCmd; delete SetEventIDCoincCmd; delete forceMinSectorDiffCmd; + delete minSCmd; + delete maxDeltaZCmd; } @@ -135,6 +147,10 @@ void GateCoincidenceSorterMessenger::SetNewValue(G4UIcommand* aCommand, G4String { m_CoincidenceSorter->SetForcedTo0MinSectorDifference(forceMinSectorDiffCmd->GetNewBoolValue(newValue)); } else if( aCommand == minSectorDiffCmd ) { m_CoincidenceSorter->SetMinSectorDifference(minSectorDiffCmd->GetNewIntValue(newValue)); } + else if (aCommand==minSCmd) + m_CoincidenceSorter->SetMinS(minSCmd->GetNewDoubleValue(newValue)); + else if (aCommand==maxDeltaZCmd) + m_CoincidenceSorter->SetMaxDeltaZ(maxDeltaZCmd->GetNewDoubleValue(newValue)); else if( aCommand == setDepthCmd ) { m_CoincidenceSorter->SetDepth(setDepthCmd->GetNewIntValue(newValue)); } else if( aCommand == setPresortBufferSizeCmd ) diff --git a/source/physics/src/GateCoincidencePulseProcessorChainMessenger.cc b/source/physics/src/GateCoincidencePulseProcessorChainMessenger.cc index aad9787f5..9519c1e50 100644 --- a/source/physics/src/GateCoincidencePulseProcessorChainMessenger.cc +++ b/source/physics/src/GateCoincidencePulseProcessorChainMessenger.cc @@ -20,7 +20,7 @@ See LICENSE.md for further details #include "GateCoincidencePulseProcessorChain.hh" //#include "GateCoincidenceDeadTime.hh" -#include "GateCoincidenceGeometrySelector.hh" +//#include "GateCoincidenceGeometrySelector.hh" #include "GateTriCoincidenceSorter.hh" //mhadi_add #include "GateCCCoincidenceSequenceRecon.hh"//AE @@ -94,8 +94,8 @@ void GateCoincidencePulseProcessorChainMessenger::DoInsertion(const G4String& ch newProcessor = new GateCCCoincidenceSequenceRecon(GetProcessorChain(),newInsertionName); //else if (childTypeName=="timeDiffSelector") //newProcessor = new GateCoincidenceTimeDiffSelector(GetProcessorChain(),newInsertionName); - else if (childTypeName=="geometrySelector") - newProcessor = new GateCoincidenceGeometrySelector(GetProcessorChain(),newInsertionName); + //else if (childTypeName=="geometrySelector") + //newProcessor = new GateCoincidenceGeometrySelector(GetProcessorChain(),newInsertionName); // else if (childTypeName=="buffer") // newProcessor = new GateCoincidenceBuffer(GetProcessorChain(),newInsertionName); //else if (childTypeName=="multiplesKiller")