Skip to content

Commit

Permalink
Merge pull request #698 from Oudihat-Radia/coincidenceTimeDiffSelector
Browse files Browse the repository at this point in the history
Coincidence time diff selector
  • Loading branch information
kochebina authored Sep 3, 2024
2 parents 313b007 + a47dcdd commit 0546479
Show file tree
Hide file tree
Showing 8 changed files with 141 additions and 48 deletions.
4 changes: 3 additions & 1 deletion source/digits_hits/include/GateCoincidenceDigi.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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<GateDigi*>
class GateCoincidenceDigi : public G4VDigi, public std::vector<GateDigi*>
{
public:

Expand Down Expand Up @@ -51,6 +51,7 @@ public:

public:

G4double ComputeFinishTime();

inline G4double GetStartTime() const
{ return m_startTime; }
Expand Down Expand Up @@ -84,6 +85,7 @@ public:
static std::vector<G4bool> GetCoincidenceASCIIMask();
static G4bool GetCoincidenceASCIIMask(G4int index);


protected:
static std::vector<G4bool> m_coincidenceASCIIMask;
static G4bool m_coincidenceASCIIMaskDefault;
Expand Down
33 changes: 24 additions & 9 deletions source/digits_hits/include/GateCoincidenceTimeDiffSelector.hh
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,37 @@ See LICENSE.md for further details
#include <vector>
#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
Expand All @@ -53,14 +63,19 @@ 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);



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;
};


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
};
Expand Down
15 changes: 15 additions & 0 deletions source/digits_hits/src/GateCoincidenceDigi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,21 @@ GateCoincidenceDigi::GateCoincidenceDigi(GateDigi *firstDigi,


}
G4double GateCoincidenceDigi::ComputeFinishTime()
{
//std::vector< GateDigi* >* IDCVector = IDC->GetVector ();
std::vector<GateDigi*>::iterator iter;

G4double finishTime = 0;
for (iter =begin(); iter < end() ; ++iter) {
if ( (*iter)->GetTime() > finishTime ){
finishTime = (*iter)->GetTime();
}
}


return finishTime;
}



Expand Down
10 changes: 9 additions & 1 deletion source/digits_hits/src/GateCoincidenceDigitizerMessenger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
79 changes: 57 additions & 22 deletions source/digits_hits/src/GateCoincidenceTimeDiffSelector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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);
}

Expand All @@ -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<GateCoincidenceDigi*>::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) && (timeDiff<m_minTime) )
||
((m_maxTime>0) && (timeDiff>m_maxTime) ) )
return 0;
else
return new GateCoincidencePulse(*inputPulse);
}


void GateCoincidenceTimeDiffSelector::DescribeMyself(size_t indent)
{
G4cout << GateTools::Indent(indent) << "TimeDiffSelector: "
Expand Down
17 changes: 12 additions & 5 deletions source/digits_hits/src/GateCoincidenceTimeDiffSelectorMessenger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 0546479

Please sign in to comment.