diff --git a/source/digits_hits/include/GateCoincidenceDigi.hh b/source/digits_hits/include/GateCoincidenceDigi.hh index f9e400f2a..ac76ad8a7 100644 --- a/source/digits_hits/include/GateCoincidenceDigi.hh +++ b/source/digits_hits/include/GateCoincidenceDigi.hh @@ -23,7 +23,7 @@ See LICENSE.md for further details // define the minimum offset for a delayed coincidence window in sec #define MIN_COINC_OFFSET -1. -class GateCoincidenceDigi : public G4VDigi, public std::vector +class GateCoincidenceDigi : public G4VDigi, public std::vector { public: @@ -51,6 +51,7 @@ public: public: + G4double ComputeFinishTime(); inline G4double GetStartTime() const { return m_startTime; } @@ -84,6 +85,7 @@ public: static std::vector GetCoincidenceASCIIMask(); static G4bool GetCoincidenceASCIIMask(G4int index); + protected: static std::vector m_coincidenceASCIIMask; static G4bool m_coincidenceASCIIMaskDefault; diff --git a/source/digits_hits/include/GateCoincidenceTimeDiffSelector.hh b/source/digits_hits/include/GateCoincidenceTimeDiffSelector.hh index 7e18f7d09..eca546407 100644 --- a/source/digits_hits/include/GateCoincidenceTimeDiffSelector.hh +++ b/source/digits_hits/include/GateCoincidenceTimeDiffSelector.hh @@ -15,27 +15,37 @@ See LICENSE.md for further details #include #include "G4ThreeVector.hh" -#include "GateVPulseProcessor.hh" +//#include "GateVPulseProcessor.hh" #include "GateObjectStore.hh" -#include "GateVCoincidencePulseProcessor.hh" +#include "GateVDigitizerModule.hh" +#include "GateCoincidenceDigi.hh" +#include "GateClockDependent.hh" +#include "GateCrystalSD.hh" + + +#include "GateDigi.hh" + +#include "GateCoincidenceTimeDiffSelectorMessenger.hh" +#include "GateCoincidenceDigitizer.hh" class GateCoincidenceTimeDiffSelectorMessenger; -class GateCoincidenceTimeDiffSelector : public GateVCoincidencePulseProcessor +class GateCoincidenceTimeDiffSelector : public GateVDigitizerModule { public: - + GateCoincidenceTimeDiffSelector(GateCoincidenceDigitizer *digitizer, G4String name); + ~GateCoincidenceTimeDiffSelector(); //! Destructor - virtual ~GateCoincidenceTimeDiffSelector() ; + //virtual ~GateCoincidenceTimeDiffSelector() ; //! Constructs a new dead time attached to a GateDigitizer - GateCoincidenceTimeDiffSelector(GateCoincidencePulseProcessorChain* itsChain, - const G4String& itsName); - + //GateCoincidenceTimeDiffSelector(GateCoincidencePulseProcessorChain* itsChain, + //const G4String& itsName); +void Digitize() override; public: //! Returns the TimeDiffSelector @@ -53,7 +63,7 @@ public: protected: /*! Implementation of the pure virtual method declared by the base class GateVCoincidencePulseProcessor*/ - GateCoincidencePulse* ProcessPulse(GateCoincidencePulse* inputPulse,G4int iPulse); + //GateCoincidencePulse* ProcessPulse(GateCoincidencePulse* inputPulse,G4int iPulse); @@ -61,6 +71,11 @@ private: G4double m_minTime; //!< TimeDiffSelector value G4double m_maxTime; //!< contains the rebirth time. GateCoincidenceTimeDiffSelectorMessenger *m_messenger; //!< Messenger + GateCoincidenceDigi* m_outputDigi; + + GateCoincidenceDigiCollection* m_OutputDigiCollection; + + GateCoincidenceDigitizer *m_digitizer; }; diff --git a/source/digits_hits/include/GateCoincidenceTimeDiffSelectorMessenger.hh b/source/digits_hits/include/GateCoincidenceTimeDiffSelectorMessenger.hh index 9a3bfbf2c..02064af52 100644 --- a/source/digits_hits/include/GateCoincidenceTimeDiffSelectorMessenger.hh +++ b/source/digits_hits/include/GateCoincidenceTimeDiffSelectorMessenger.hh @@ -10,7 +10,10 @@ See LICENSE.md for further details #ifndef GateCoincidenceTimeDiffSelectorMessenger_h #define GateCoincidenceTimeDiffSelectorMessenger_h 1 -#include "GatePulseProcessorMessenger.hh" +//#include "GatePulseProcessorMessenger.hh" +#include "GateClockDependentMessenger.hh" +#include "G4UImessenger.hh" +#include "globals.hh" class G4UIdirectory; class G4UIcmdWithoutParameter; @@ -21,20 +24,28 @@ class G4UIcmdWithADouble; class G4UIcmdWithADoubleAndUnit; class G4UIcmdWith3Vector; class G4UIcmdWith3VectorAndUnit; +class G4UIdirectory; class GateCoincidenceTimeDiffSelector; class GateCoincidenceTimeDiffSelectorMessenger: public GateClockDependentMessenger { public: - GateCoincidenceTimeDiffSelectorMessenger(GateCoincidenceTimeDiffSelector* itsTimeDiffSelector); - virtual ~GateCoincidenceTimeDiffSelectorMessenger(); + //GateCoincidenceTimeDiffSelectorMessenger(GateCoincidenceTimeDiffSelector* itsTimeDiffSelector); + //virtual ~GateCoincidenceTimeDiffSelectorMessenger(); + GateCoincidenceTimeDiffSelectorMessenger(GateCoincidenceTimeDiffSelector*); + ~GateCoincidenceTimeDiffSelectorMessenger(); + inline void SetNewValue(G4UIcommand* , G4String ); + + - inline void SetNewValue(G4UIcommand* aCommand, G4String aString); - inline GateCoincidenceTimeDiffSelector* GetTimeDiffSelector(){ return (GateCoincidenceTimeDiffSelector*) GetClockDependent(); } + + // inline GateCoincidenceTimeDiffSelector* GetTimeDiffSelector(){ return (GateCoincidenceTimeDiffSelector*) GetClockDependent(); } private: + GateCoincidenceTimeDiffSelector* m_CoincidenceTimeDiffSelector; + G4UIcmdWithADoubleAndUnit *minTimeCmd; //!< set the min time window G4UIcmdWithADoubleAndUnit *maxTimeCmd; //!< set the max time window }; diff --git a/source/digits_hits/src/GateCoincidenceDigi.cc b/source/digits_hits/src/GateCoincidenceDigi.cc index a9c9099b8..914ca17f6 100644 --- a/source/digits_hits/src/GateCoincidenceDigi.cc +++ b/source/digits_hits/src/GateCoincidenceDigi.cc @@ -41,6 +41,21 @@ GateCoincidenceDigi::GateCoincidenceDigi(GateDigi *firstDigi, } +G4double GateCoincidenceDigi::ComputeFinishTime() +{ + //std::vector< GateDigi* >* IDCVector = IDC->GetVector (); + std::vector::iterator iter; + + G4double finishTime = 0; + for (iter =begin(); iter < end() ; ++iter) { + if ( (*iter)->GetTime() > finishTime ){ + finishTime = (*iter)->GetTime(); + } + } + + + return finishTime; +} diff --git a/source/digits_hits/src/GateCoincidenceDigitizerMessenger.cc b/source/digits_hits/src/GateCoincidenceDigitizerMessenger.cc index cc090560a..d81018eed 100644 --- a/source/digits_hits/src/GateCoincidenceDigitizerMessenger.cc +++ b/source/digits_hits/src/GateCoincidenceDigitizerMessenger.cc @@ -28,6 +28,7 @@ See LICENSE.md for further details #include "GateCoincidenceDeadTime.hh" #include "GateCoincidenceMultiplesKiller.hh" #include "GateCoincidenceBuffer.hh" +#include "GateCoincidenceTimeDiffSelector.hh" /*#include "GateAdder.hh" #include "GateReadout.hh" #include "GateEnergyFraming.hh" @@ -124,7 +125,7 @@ void GateCoincidenceDigitizerMessenger::SetNewValue(G4UIcommand* command,G4Strin const G4String& GateCoincidenceDigitizerMessenger::DumpMap() { - static G4String theList = "deadtime multiplesKiller buffer";//readout adder energyFraming timeResolution energyResolution spatialResolution efficiency deadtime pileup adderCompton opticaladder noise merger"; + static G4String theList = "deadtime multiplesKiller buffer timeDiffSelector" ;//readout adder energyFraming timeResolution energyResolution spatialResolution efficiency deadtime pileup adderCompton opticaladder noise merger"; return theList; @@ -164,6 +165,13 @@ void GateCoincidenceDigitizerMessenger::DoInsertion(const G4String& childTypeNam m_CoinDigitizer->AddNewModule(newDM); } + else if (childTypeName=="timeDiffSelector") + { + newDM = new GateCoincidenceTimeDiffSelector(m_CoinDigitizer, DMname); + m_CoinDigitizer->AddNewModule(newDM); + } + + /*else if (childTypeName=="readout") { newDM = new GateReadout(m_digitizer, DMname); diff --git a/source/digits_hits/src/GateCoincidenceTimeDiffSelector.cc b/source/digits_hits/src/GateCoincidenceTimeDiffSelector.cc index 552afc450..0595cb985 100644 --- a/source/digits_hits/src/GateCoincidenceTimeDiffSelector.cc +++ b/source/digits_hits/src/GateCoincidenceTimeDiffSelector.cc @@ -7,7 +7,7 @@ See LICENSE.md for further details ----------------------*/ -#include "GateCoincidenceTimeDiffSelector.hh" +#include "../include/GateCoincidenceTimeDiffSelector.hh" #include "G4UnitsTable.hh" #include "GateCoincidenceTimeDiffSelectorMessenger.hh" #include "GateTools.hh" @@ -19,15 +19,27 @@ See LICENSE.md for further details #include "GateObjectChildList.hh" #include "GateVVolume.hh" #include "GateMaps.hh" +#include "GateCoincidenceDigi.hh" +#include "GateDigitizerMgr.hh" -GateCoincidenceTimeDiffSelector::GateCoincidenceTimeDiffSelector(GateCoincidencePulseProcessorChain* itsChain, - const G4String& itsName) - : GateVCoincidencePulseProcessor(itsChain,itsName) -{ - m_minTime = -1; - m_maxTime = -1; - +#include "G4SystemOfUnits.hh" +#include "G4EventManager.hh" +#include "G4Event.hh" +#include "G4SDManager.hh" +#include "G4DigiManager.hh" +#include "G4ios.hh" +#include "G4UnitsTable.hh" +GateCoincidenceTimeDiffSelector::GateCoincidenceTimeDiffSelector(GateCoincidenceDigitizer *digitizer, G4String name) + :GateVDigitizerModule(name,"digitizerMgr/CoincidenceDigitizer/"+digitizer->m_digitizerName+"/"+name, digitizer), + m_outputDigi(0), + m_OutputDigiCollection(0), + m_digitizer(digitizer) + + { m_minTime = -1; + m_maxTime = -1; + G4String colName = digitizer->GetOutputName() ; + collectionName.push_back(colName); m_messenger = new GateCoincidenceTimeDiffSelectorMessenger(this); } @@ -40,26 +52,49 @@ GateCoincidenceTimeDiffSelector::~GateCoincidenceTimeDiffSelector() } +void GateCoincidenceTimeDiffSelector::Digitize() +{ + G4String digitizerName = m_digitizer->m_digitizerName; + G4String outputCollName = m_digitizer-> GetOutputName(); + m_OutputDigiCollection = new GateCoincidenceDigiCollection(GetName(),outputCollName); // to create the Digi Collection -GateCoincidencePulse* GateCoincidenceTimeDiffSelector::ProcessPulse(GateCoincidencePulse* inputPulse,G4int ) -{ - if (!inputPulse) { - if (nVerboseLevel>1) - G4cout << "[GateCoincidenceTimeDiffSelector::ProcessOnePulse]: input pulse was null -> nothing to do\n\n"; - return 0; + G4DigiManager* DigiMan = G4DigiManager::GetDMpointer(); + + + + + GateCoincidenceDigiCollection* IDC = 0; + IDC = (GateCoincidenceDigiCollection*) (DigiMan->GetDigiCollection(m_DCID)); + + GateCoincidenceDigi* inputDigi = new GateCoincidenceDigi(); + + std::vector< GateCoincidenceDigi* >* OutputDigiCollectionVector = m_OutputDigiCollection->GetVector (); + std::vector::iterator iter; + + if (IDC) { + G4int n_digi = IDC->entries(); + // Loop over input digits + for (G4int i = 0; i < n_digi; i++) { + GateCoincidenceDigi* inputDigi = (*IDC)[i]; // Retrieve input digi + G4double timeDiff = inputDigi->ComputeFinishTime() - inputDigi->GetStartTime(); + if (((m_minTime > 0) && (timeDiff < m_minTime)) || ((m_maxTime > 0) && (timeDiff > m_maxTime))) { + continue; // Skip this digi + } else { + m_outputDigi = new GateCoincidenceDigi(*inputDigi); + m_OutputDigiCollection->insert(m_outputDigi); + }//loop over input digits + }}//IDC +else + { + if (nVerboseLevel>1) + G4cout << "[GateCoincidenceDeadTime::Digitize]: input digi collection is null -> nothing to do\n\n"; + return; } +StoreDigiCollection(m_OutputDigiCollection); - G4double timeDiff = inputPulse->ComputeFinishTime()-inputPulse->GetStartTime(); - if ( ((m_minTime>0) && (timeDiff0) && (timeDiff>m_maxTime) ) ) - return 0; - else - return new GateCoincidencePulse(*inputPulse); } - void GateCoincidenceTimeDiffSelector::DescribeMyself(size_t indent) { G4cout << GateTools::Indent(indent) << "TimeDiffSelector: " diff --git a/source/digits_hits/src/GateCoincidenceTimeDiffSelectorMessenger.cc b/source/digits_hits/src/GateCoincidenceTimeDiffSelectorMessenger.cc index a69bb0a33..c2824fd65 100644 --- a/source/digits_hits/src/GateCoincidenceTimeDiffSelectorMessenger.cc +++ b/source/digits_hits/src/GateCoincidenceTimeDiffSelectorMessenger.cc @@ -10,12 +10,19 @@ See LICENSE.md for further details #include "GateCoincidenceTimeDiffSelectorMessenger.hh" #include "GateCoincidenceTimeDiffSelector.hh" - #include "G4UIcmdWithADoubleAndUnit.hh" #include "G4UIcmdWithAString.hh" +#include "GateDigitizerMgr.hh" +#include "G4UImessenger.hh" +#include "globals.hh" +#include "GateClockDependentMessenger.hh" +#include "G4SystemOfUnits.hh" +#include "G4UIdirectory.hh" + +GateCoincidenceTimeDiffSelectorMessenger::GateCoincidenceTimeDiffSelectorMessenger (GateCoincidenceTimeDiffSelector* CoincidenceTimeDiffSelector) +:GateClockDependentMessenger(CoincidenceTimeDiffSelector), + m_CoincidenceTimeDiffSelector(CoincidenceTimeDiffSelector) -GateCoincidenceTimeDiffSelectorMessenger::GateCoincidenceTimeDiffSelectorMessenger(GateCoincidenceTimeDiffSelector* itsTimeDiffSelector) - : GateClockDependentMessenger(itsTimeDiffSelector) { G4String guidance; G4String cmdName; @@ -44,9 +51,9 @@ GateCoincidenceTimeDiffSelectorMessenger::~GateCoincidenceTimeDiffSelectorMessen void GateCoincidenceTimeDiffSelectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue) { if (command==minTimeCmd) - GetTimeDiffSelector()->SetMinTime(minTimeCmd->GetNewDoubleValue(newValue)); + m_CoincidenceTimeDiffSelector->SetMinTime(minTimeCmd->GetNewDoubleValue(newValue)); else if (command == maxTimeCmd) - GetTimeDiffSelector()->SetMaxTime(maxTimeCmd->GetNewDoubleValue(newValue)); + m_CoincidenceTimeDiffSelector->SetMaxTime(maxTimeCmd->GetNewDoubleValue(newValue)); else GateClockDependentMessenger::SetNewValue(command,newValue); } diff --git a/source/physics/src/GateCoincidencePulseProcessorChainMessenger.cc b/source/physics/src/GateCoincidencePulseProcessorChainMessenger.cc index 0f4be1d83..aad9787f5 100644 --- a/source/physics/src/GateCoincidencePulseProcessorChainMessenger.cc +++ b/source/physics/src/GateCoincidencePulseProcessorChainMessenger.cc @@ -9,9 +9,9 @@ See LICENSE.md for further details #include "GateCoincidencePulseProcessorChainMessenger.hh" -//#include "../../digits_hits/include/GateCoincidenceBuffer.hh" -//#include "../../digits_hits/include/GateCoincidenceMultiplesKiller.hh" -#include "../../digits_hits/include/GateCoincidenceTimeDiffSelector.hh" +//#include "../../digits_hits/include/GateCoincidenceBufferOld.hh" +//#include "../../digits_hits/include/GateCoincidenceMultiplesKillerOld.hh" +//#include "../../digits_hits/include/GateCoincidenceTimeDiffSelectorOld.hh" #include "G4UIdirectory.hh" #include "G4UIcmdWithAString.hh" #include "G4UIcmdWithABool.hh" @@ -92,8 +92,8 @@ void GateCoincidencePulseProcessorChainMessenger::DoInsertion(const G4String& ch */ if (childTypeName=="sequenceRecon") newProcessor = new GateCCCoincidenceSequenceRecon(GetProcessorChain(),newInsertionName); - else if (childTypeName=="timeDiffSelector") - newProcessor = new GateCoincidenceTimeDiffSelector(GetProcessorChain(),newInsertionName); + //else if (childTypeName=="timeDiffSelector") + //newProcessor = new GateCoincidenceTimeDiffSelector(GetProcessorChain(),newInsertionName); else if (childTypeName=="geometrySelector") newProcessor = new GateCoincidenceGeometrySelector(GetProcessorChain(),newInsertionName); // else if (childTypeName=="buffer")