Skip to content
Closed
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
41 changes: 35 additions & 6 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,7 +36,7 @@
#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
Expand Down Expand Up @@ -69,7 +69,12 @@ 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 use the DigiMode" << G4endl );
GateMessage( "Core", 0,
" --d FILE use Offline Digi mode with input ROOT file"
<< G4endl );


GateMessage( "Core", 0, " --qt use the Qt visualization mode" << G4endl );
exit( EXIT_FAILURE );
}
Expand Down Expand Up @@ -200,6 +205,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 +220,7 @@ 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", required_argument, 0, 'd' }, //{ "d", no_argument, &isDigiMode, 1 },
{ "qt", no_argument, &isQt, 1 },
{ "param", required_argument, 0, 'a' }
};
Expand Down Expand Up @@ -262,6 +268,10 @@ int main( int argc, char* argv[] )
case 'a':
listOfParameters = optarg;
break;
case 'd':
isDigiMode = 1;
digiInputFile = optarg;
break;
default:
printHelpAndQuit( "Out of switch options" );
break;
Expand All @@ -272,6 +282,20 @@ int main( int argc, char* argv[] )
if( isDigiMode )
aDigiMode = kofflineMode;

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

GateHitFileReader::GetInstance()->SetFileName(digiInputFile);
GateDigitizerMgr::GetInstance()->SetOfflineMode(true);
}


// Analyzing parameterized macro
std::queue< G4String > commandQueue = decodeParameters( listOfParameters );

Expand Down Expand Up @@ -317,12 +341,17 @@ int main( int argc, char* argv[] )
#endif

if( aDigiMode == kofflineMode )
#ifdef G4ANALYSIS_USE_ROOT
{
#ifndef G4ANALYSIS_USE_ROOT
abortIfRootNotFound();
#endif
}
/*#ifdef G4ANALYSIS_USE_ROOT
GateHitFileReader::GetInstance();
#else
abortIfRootNotFound();
#endif

*/
GateSourceMgr* sourceMgr = GateSourceMgr::GetInstance();
GateApplicationMgr* appMgr = GateApplicationMgr::GetInstance();
GateClock::GetInstance()->SetTime( 0 );
Expand Down
16 changes: 11 additions & 5 deletions source/digits_hits/include/GateDigitizerMgr.hh
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,6 @@ public:
GateSinglesDigitizer* FindSinglesDigitizer(G4String mName);
/// End of methods for Singles




/// Methods for Coincidences

//Sorters
Expand All @@ -105,12 +102,20 @@ public:
GateCoincidenceDigitizer* FindCoincidenceDigitizer(G4String mName);
/// End of methods for Coincidences

private:

public:
void SetOfflineMode(bool b) { mOfflineMode = b; }
bool IsOfflineMode() const { return mOfflineMode; }

GateDigitizerMgrMessenger *fMessenger;
GateHitsCollection* GetOfflineHitsCollection();

void SetOfflineHitsCollection(GateHitsCollection* hc);
void ClearOfflineHitsCollection();
private:
GateDigitizerMgrMessenger *fMessenger;
static GateDigitizerMgr* theDigitizerMgr;
GateHitsCollection* mOfflineHitsCollection = nullptr;
bool mOfflineMode = false;

protected:
G4String m_elementTypeName; //!< Type-name for DigitizerMgr --> used only for cout and help messengers
Expand All @@ -135,5 +140,6 @@ public:
G4bool m_alreadyRun;



};
#endif
37 changes: 28 additions & 9 deletions source/digits_hits/include/GateHitFileReader.hh
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,9 @@ See LICENSE.md for further details
#ifdef G4ANALYSIS_USE_ROOT

#include "globals.hh"
#include <queue>

#include "G4Event.hh"

#include "GateHit.hh"
class G4Event;
class GateHit;



#include "TROOT.h"
Expand Down Expand Up @@ -53,6 +50,7 @@ public:
*/
static GateHitFileReader* GetInstance();


~GateHitFileReader(); //!< Public destructor

private:
Expand All @@ -72,7 +70,7 @@ public:

//! 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();
//void PrepareEndOfEvent();


//! This method must be called (normally by the application manager) after completion of a DigiGate acquisition
Expand All @@ -84,13 +82,28 @@ public:
//! Set the hit file name
void SetFileName(const G4String aName) { m_fileName = aName; };


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

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

bool IsFinished() const
{
return m_finished;
}

/*! \brief Overload of the base-class virtual method to print-out a description of the reader

\param indent: the print-out indentation (cosmetic parameter)
*/
virtual void Describe(size_t indent=0);


void ReleaseHits();
protected:

//! Reads a set of hit data from the hit-tree, and stores them into the root-hit buffer
Expand All @@ -111,15 +124,21 @@ protected:
//!< 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
//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()


std::vector<GateHit*> m_hitVector;


GateHitFileReaderMessenger *m_messenger; //!< Messenger;

private:
static GateHitFileReader* instance; //!< Instance of the GateHitFielReader singleton
bool m_finished;

};

#endif
Expand Down
2 changes: 2 additions & 0 deletions source/digits_hits/include/GateHitFileReaderMessenger.hh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class GateHitFileReaderMessenger: public GateClockDependentMessenger

void SetNewValue(G4UIcommand*, G4String);



//! Get the clock-dependent object
inline GateHitFileReader* GetHitFileReader()
{ return (GateHitFileReader*) GetClockDependent(); }
Expand Down
2 changes: 1 addition & 1 deletion source/digits_hits/include/GateOutputMgr.hh
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public:

//! Static getter and setter to know the current mode of the digitizer
inline static DigiMode GetDigiMode() { return m_digiMode;}
inline static void SetDigiMode(DigiMode mode) { m_digiMode = mode; }
inline static void SetDigiMode(DigiMode mode) { m_digiMode = mode;}
GateVOutputModule* GetModule(G4String);

//! Call in startDAQ, this function search for all output module inserted
Expand Down
3 changes: 3 additions & 0 deletions source/digits_hits/include/GateToRoot.hh
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ public:
void RecordOpticalData(const G4Event *event);
// v. cuplov - optical photons


void SetOfflineOutputFileName();

void RecordVoxels(const G4Step *);

void BookBeginOfAquisition();
Expand Down
34 changes: 30 additions & 4 deletions source/digits_hits/src/GateCoincidenceSorter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -278,13 +278,27 @@ void GateCoincidenceSorter::Digitize()


//------ put input digis in sorted input buffer----------
if (nVerboseLevel > 1) {
G4cout<<"GateCoincidenceSorter::Digitize. Putting input digis in sorted input buffer"<<G4endl;

}
for(gpl_iter = IDCvector->begin();gpl_iter != IDCvector->end();gpl_iter++)
{
// make a copy of the digi
digi = new GateDigi(**gpl_iter);
if (nVerboseLevel > 1) {
G4cout<<"[GateCoincidenceSorter::Digitize] EventID "<< digi->GetEventID()<<G4endl;

}

if (nVerboseLevel > 2) {
G4cout << "[GateCoincidenceSorter::Digitize] Input digi \n"
<< *digi << Gateendl << Gateendl ;

}

if(m_presortBuffer.empty())
m_presortBuffer.push_back(digi);
m_presortBuffer.push_back(digi);
else if(digi->GetTime() < m_presortBuffer.back()->GetTime()) // check that even isn't earlier than the earliest event in the buffer
{
if(!m_presortWarning)
Expand All @@ -298,13 +312,18 @@ void GateCoincidenceSorter::Digitize()
while(digi->GetTime() < (*buf_iter)->GetTime())
buf_iter++;
m_presortBuffer.insert(buf_iter, digi);
// G4cout<<"presortBuffer filled in position "<<std::distance(m_presortBuffer.begin(),buf_iter)<<G4endl;
// G4cout<<"digiTime "<<digi->GetTime()<<G4endl;
// G4cout<<"digiTime "<<digi->GetTime()/ns<<G4endl;
if (nVerboseLevel > 3)
{
G4cout<<"presortBuffer filled in position "<<std::distance(m_presortBuffer.begin(),buf_iter)<<G4endl;
G4cout<<"digiTime "<<digi->GetTime()<<G4endl;
G4cout<<"digiTime "<<digi->GetTime()/ns<<G4endl;
}
}

}

if (nVerboseLevel > 1)
G4cout<<"[GateCoincidenceSorter::Digitize] Analyzing the presort buffer..."<<G4endl;

// once buffer reaches the specified size look for coincidences
for(G4int i = m_presortBuffer.size();i > m_presortBufferSize;i--)
Expand Down Expand Up @@ -375,6 +394,13 @@ void GateCoincidenceSorter::Digitize()
delete digi;
}

if (nVerboseLevel>1) {
G4cout << "[GateCoincidenceSorter::Digitizer]: returning output coincidence digi collection with " << m_OutputCoincidenceDigiCollection->GetSize () << " entries\n";
//for (iter=m_OutputCoincidenceDigiCollection->begin(); iter!= m_OutputCoincidenceDigiCollection->end() ; ++iter)
//G4cout << **iter << Gateendl;
//G4cout << Gateendl;
}

StoreDigiCollection(m_OutputCoincidenceDigiCollection);
}

Expand Down
Loading