Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 35 additions & 10 deletions Gate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* \brief To launch GATE:
* - 'Gate' or 'Gate --qt' using the Qt visualization
* - 'Gate your_macro.mac' or 'Gate --qt your_macro.mac' using the Qt visualization
* - 'Gate -d your_macro.mac' using the DigiGate
* - 'Gate your_macro.mac --d hits.root' for Offline Digitizer
* - 'Gate -a [activity,10]' using the parameterized macro creating an alias in your macro
*/

Expand Down Expand Up @@ -36,12 +36,12 @@
#include "GateOutputMgr.hh"
#include "GatePrimaryGeneratorAction.hh"
#include "GateUserActions.hh"
#include "GateDigitizer.hh"
#include "GateDigitizerMgr.hh"
#include "GateClock.hh"
#include "GateUIcontrolMessenger.hh"
#ifdef G4ANALYSIS_USE_ROOT
#include "TPluginManager.h"
#include "GateHitFileReader.hh"
#include "GateOfflineFileReader.hh"
#endif
#ifdef G4VIS_USE
#include "G4VisExecutive.hh"
Expand Down Expand Up @@ -69,7 +69,8 @@ void printHelpAndQuit( G4String msg )
GateMessage( "Core", 0, " -h, --help print the help" << G4endl );
GateMessage( "Core", 0, " -v, --version print the version" << G4endl );
GateMessage( "Core", 0, " -a, --param set alias. format is '[alias1,value1] [alias2,value2] ...'" << G4endl );
GateMessage( "Core", 0, " --d use the DigiMode" << G4endl );
GateMessage( "Core", 0, " --d FILE use Offline Digi mode with input ROOT hit file" << G4endl );
GateMessage( "Core", 0, " --d-from-singles FILE use Offline Digi mode with input ROOT singles file" << G4endl );
GateMessage( "Core", 0, " --qt use the Qt visualization mode" << G4endl );
exit( EXIT_FAILURE );
}
Expand Down Expand Up @@ -200,6 +201,7 @@ int main( int argc, char* argv[] )

// analyzing arguments
static G4int isDigiMode = 0; // DigiMode false by default
G4String digiInputFile = "";
static G4int isQt = 0; // Enable Qt or not
G4String listOfParameters = ""; // List of parameters for parameterized macro
DigiMode aDigiMode = kruntimeMode;
Expand All @@ -214,7 +216,8 @@ int main( int argc, char* argv[] )
static struct option longOptions[] = {
{ "help", no_argument, 0, 'h' },
{ "version", no_argument, 0, 'v' },
{ "d", no_argument, &isDigiMode, 1 },
{ "d-fromHits", required_argument, 0, 'd' },
{ "d-fromSingles", required_argument, 0, 's' },
{ "qt", no_argument, &isQt, 1 },
{ "param", required_argument, 0, 'a' }
};
Expand Down Expand Up @@ -262,16 +265,38 @@ int main( int argc, char* argv[] )
case 'a':
listOfParameters = optarg;
break;
default:
case 'd':
isDigiMode = 1;
digiInputFile = optarg;
break;
case 's':
isDigiMode = 2;
digiInputFile = optarg;
break;
default:
printHelpAndQuit( "Out of switch options" );
break;
}
}

// Checking if the DigiMode is activated
if( isDigiMode )
aDigiMode = kofflineMode;

if (isDigiMode == 1)
aDigiMode = kofflineMode;
else if (isDigiMode == 2)
aDigiMode = kofflineSinglesMode;

if (isDigiMode)
{
if (digiInputFile.empty())
{
G4cerr << "Error: Offline Digi mode requires an input ROOT file.\n"
<< "Usage: Gate main.mac --d input.root\n";
return EXIT_FAILURE;
}

GateOfflineFileReader::GetInstance()->SetFileName(digiInputFile);
GateDigitizerMgr::GetInstance()->SetOfflineMode(aDigiMode);
}
// Analyzing parameterized macro
std::queue< G4String > commandQueue = decodeParameters( listOfParameters );

Expand Down Expand Up @@ -318,7 +343,7 @@ int main( int argc, char* argv[] )

if( aDigiMode == kofflineMode )
#ifdef G4ANALYSIS_USE_ROOT
GateHitFileReader::GetInstance();
GateOfflineFileReader::GetInstance();
#else
abortIfRootNotFound();
#endif
Expand Down
22 changes: 20 additions & 2 deletions source/digits_hits/include/GateDigitizerMgr.hh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

#include "GateCoinDigitizerInitializationModule.hh"
#include "GateCoincidenceDigitizer.hh"

#include "GateVOutputModule.hh"

class GateDigitizerMgrMessenger;
class GateVSystem;
Expand Down Expand Up @@ -105,11 +105,29 @@ public:
GateCoincidenceDigitizer* FindCoincidenceDigitizer(G4String mName);
/// End of methods for Coincidences


//Methods for OfflineDigi

void SetOfflineMode(DigiMode mode) { mOfflineMode = mode; }
DigiMode GetDigiMode() const { return mOfflineMode;}


GateHitsCollection* GetOfflineHitsCollection();
void SetOfflineHitsCollection(GateHitsCollection* hc);
void ClearOfflineHitsCollection();

GateDigiCollection* GetOfflineDigiCollection();
void SetOfflineDigiCollection(GateDigiCollection* hc);
void ClearOfflineDigiCollection();


private:


GateDigitizerMgrMessenger *fMessenger;

GateHitsCollection* mOfflineHitsCollection = nullptr;
GateDigiCollection* mOfflineDigiCollection = nullptr;
DigiMode mOfflineMode = kruntimeMode; // = false;
static GateDigitizerMgr* theDigitizerMgr;

protected:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ See LICENSE.md for further details
----------------------*/


#ifndef GateHitFileReader_h
#define GateHitFileReader_h 1
#ifndef GateOfflineFileReader_h
#define GateOfflineFileReader_h 1

#include "GateConfiguration.h"

Expand All @@ -30,33 +30,33 @@ class GateHit;
#include "GateRootDefs.hh"
#include "GateClockDependent.hh"

class GateHitFileReaderMessenger;
class GateOfflineFileReaderMessenger;

/*! \class GateHitFileReader
/*! \class GateOfflineFileReader
\brief Reads hits data from a ROOT simulation-output file and recreates hit-collections for digitisation

- GateHitFileReader - by Daniel.Strul@iphe.unil.ch (Oct. 2002)
- GateOfflineFileReader - by Daniel.Strul@iphe.unil.ch (Oct. 2002)

- The GateHitFileReader is a singleton. It is designed to be used in the DigiGate mode.
In this mode, the GateHitFileReader will read hits data from a ROOT simulation-output file.
- The GateOfflineFileReader is a singleton. It is designed to be used in the DigiGate mode.
In this mode, the GateOfflineFileReader will read hits data from a ROOT simulation-output file.
Based on these data, it will recreate hit-collections that can be fed to the digitizer to
reprocess the hits.
*/
class GateHitFileReader : public GateClockDependent
class GateOfflineFileReader : public GateClockDependent
{
public:
/*! This function allows to retrieve the current instance of the GateHitFileReader singleton
/*! This function allows to retrieve the current instance of the GateOfflineFileReader singleton

If the GateHitFileReader already exists, GetInstance only returns a pointer to this singleton.
If the GateOfflineFileReader already exists, GetInstance only returns a pointer to this singleton.
If this singleton does not exist yet, GetInstance creates it by calling the private
GateHitFileReader constructor
GateOfflineFileReader constructor
*/
static GateHitFileReader* GetInstance();
static GateOfflineFileReader* GetInstance();

~GateHitFileReader(); //!< Public destructor
~GateOfflineFileReader(); //!< Public destructor

private:
GateHitFileReader(); //!< Private constructor: this function should only be called from GetInstance()
GateOfflineFileReader(); //!< Private constructor: this function should only be called from GetInstance()

public:
//! This method must be called (normally by the application manager) before starting a new DigiGate acquisition
Expand All @@ -68,12 +68,8 @@ public:

\returns 1 -> series of hits OK for the current run, 0 -> either no hits or series of hits for the NEXT run
*/
G4int PrepareNextEvent(G4Event* event);

//! This method is meant to be called by output manager before calling the methods RecordEndOfEvent() of the output modules.
//! It creates a new hit-collection, based on the queue of hits previously filled by PrepareNextEvent()
void PrepareEndOfEvent();

G4int PrepareNextEventFromHits(G4Event* event);
G4int PrepareNextEventFromSingles(G4Event* event);

//! This method must be called (normally by the application manager) after completion of a DigiGate acquisition
//! It closes the ROOT input file
Expand All @@ -91,35 +87,48 @@ public:
virtual void Describe(size_t indent=0);


const std::vector<GateHit*>& GetHitVector() const { return m_hitVector;}
std::vector<GateHit*>& GetHitVector() { return m_hitVector; }

const std::vector<GateDigi*>& GetDigiVector() const { return m_digiVector;}
std::vector<GateDigi*>& GetDigiVector() { return m_digiVector; }

bool IsFinished() const { return m_finished; }

protected:

//! Reads a set of hit data from the hit-tree, and stores them into the root-hit buffer
void LoadHitData();

void LoadSinglesData();
protected:

bool m_finished;
G4String m_fileName; //!< Name of the input hit-file
TFile* m_hitFile; //!< the input hit file
TFile* m_inptuFile; //!< the input hit file

TTree* m_hitTree; //!< the input hit tree
TTree* m_inputTree; //!< the input hit tree
Stat_t m_entries; //!< Number of entries in the tree
G4int m_currentEntry; //!< Current entry in the tree



GateRootHitBuffer m_hitBuffer; //!< Buffer to store the data read from the hit-tree
//!< Each field of this structure is a buffer for one of the branches of the tree
//!< The hit-data are loaded into this buffer by LoadHitData()
//!< They are then transformed into a crystal-hit by PrepareNextEvent()

std::queue<GateHit*> m_hitQueue; //!< Queue of waiting hits for the current event
//!< For each event, the queue is filled (from data read out of the hit-file) at
//!< the beginning of each event by PrepareNextEvent(). It is emptied into
//!< a crystal-hit collection at the end of each event by PrepareEndOfEvent()
GateRootSingleBuffer m_singleBuffer; //!< Buffer to store the data read from the hit-tree
//!< Each field of this structure is a buffer for one of the branches of the tree
//!< The hit-data are loaded into this buffer by LoadHitData()
//!< They are then transformed into a crystal-hit by PrepareNextEvent()

std::vector<GateHit*> m_hitVector;
std::vector<GateDigi*> m_digiVector;


GateHitFileReaderMessenger *m_messenger; //!< Messenger;
GateOfflineFileReaderMessenger *m_messenger; //!< Messenger;

private:
static GateHitFileReader* instance; //!< Instance of the GateHitFielReader singleton
static GateOfflineFileReader* instance; //!< Instance of the GateHitFielReader singleton
};

#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,42 @@ See LICENSE.md for further details
----------------------*/


#ifndef GateHitFileReaderMessenger_h
#define GateHitFileReaderMessenger_h 1
#ifndef GateOfflineFileReaderMessenger_h
#define GateOfflineFileReaderMessenger_h 1

#include "GateConfiguration.h"

//e #ifdef G4ANALYSIS_USE_ROOT

#include "GateClockDependentMessenger.hh"

class GateHitFileReader;
class GateOfflineFileReader;


/*! \class GateHitFileReaderMessenger
\brief Messenger used to command a GateHitFileReader
/*! \class GateOfflineFileReaderMessenger
\brief Messenger used to command a GateOfflineFileReader

- GateHitFileReaderMessenger - by Daniel.Strul@iphe.unil.ch
- GateOfflineFileReaderMessenger - by Daniel.Strul@iphe.unil.ch

- The GateHitFileReaderMessenger inherits from the abilities/responsabilities
- The GateOfflineFileReaderMessenger inherits from the abilities/responsabilities
of the GateClockDependentMessenger base-class, i.e. the creation and management
of a Gate UI directory for a Gate object, plus the UI command 'describe'

- In addition, it proposes and manages commands specific to the hit-file reader:
definition of the name of the hit file

*/
class GateHitFileReaderMessenger: public GateClockDependentMessenger
class GateOfflineFileReaderMessenger: public GateClockDependentMessenger
{
public:
GateHitFileReaderMessenger(GateHitFileReader* itsHitFileReader);
~GateHitFileReaderMessenger();
GateOfflineFileReaderMessenger(GateOfflineFileReader* itsOfflineFileReader);
~GateOfflineFileReaderMessenger();

void SetNewValue(G4UIcommand*, G4String);

//! Get the clock-dependent object
inline GateHitFileReader* GetHitFileReader()
{ return (GateHitFileReader*) GetClockDependent(); }
inline GateOfflineFileReader* GetOfflineFileReader()
{ return (GateOfflineFileReader*) GetClockDependent(); }

protected:
G4UIcmdWithAString* SetFileNameCmd;
Expand Down
2 changes: 2 additions & 0 deletions source/digits_hits/include/GateToRoot.hh
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ public:
void RecordOpticalData(const G4Event *event);
// v. cuplov - optical photons

void SetOfflineOutputFileName();

void RecordVoxels(const G4Step *);

void BookBeginOfAquisition();
Expand Down
4 changes: 3 additions & 1 deletion source/digits_hits/include/GateVOutputModule.hh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ class GateVVolume;

enum DigiMode {
kruntimeMode,
kofflineMode
kofflineMode, // Hits -> Singles -> Coincidences
kofflineSinglesMode // Singles -> Coincidences,

};

class GateVOutputModule
Expand Down
5 changes: 1 addition & 4 deletions source/digits_hits/src/GateActions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,7 @@ inline void GateEventAction::EndOfEventAction(const G4Event* anEvent)
{
GateMessage("Core", 2, "End Of Event " << anEvent->GetEventID() << "\n");

//OK GND 2022 TODO
//I would like to RunDigitizers here but some aHit attributes are filled in OutputMng/GateAnalysis->RecordEndOfEvent
//GateDigitizerMgr* digitizerMgr = GateDigitizerMgr::GetInstance();
// digitizerMgr->RunDigitizers();


#ifdef G4ANALYSIS_USE_GENERAL
// Here we fill the histograms of the OutputMgr manager
Expand Down
1 change: 0 additions & 1 deletion source/digits_hits/src/GateAnalysis.cc
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,6 @@ void GateAnalysis::RecordEndOfEvent(const G4Event* event)

if(!digitizerMgr->m_alreadyRun)
{

if (digitizerMgr->m_recordSingles|| digitizerMgr->m_recordCoincidences)
{

Expand Down
Loading
Loading