Geant4  10.02.p03
GammaRayTelRunAction Class Reference

#include <GammaRayTelRunAction.hh>

Inheritance diagram for GammaRayTelRunAction:
Collaboration diagram for GammaRayTelRunAction:

Public Member Functions

 GammaRayTelRunAction ()
 
 ~GammaRayTelRunAction ()
 
void BeginOfRunAction (const G4Run *)
 
void EndOfRunAction (const G4Run *)
 
std::ofstream * GetOutputFile ()
 
- Public Member Functions inherited from G4UserRunAction
 G4UserRunAction ()
 
virtual ~G4UserRunAction ()
 
virtual G4RunGenerateRun ()
 
void SetMaster (G4bool val=true)
 
G4bool IsMaster () const
 

Private Member Functions

void OpenFile ()
 

Private Attributes

std::ofstream * outFile
 
G4String fileName
 
G4int fRunID
 

Additional Inherited Members

- Protected Attributes inherited from G4UserRunAction
G4bool isMaster
 

Detailed Description

Definition at line 51 of file GammaRayTelRunAction.hh.

Constructor & Destructor Documentation

◆ GammaRayTelRunAction()

GammaRayTelRunAction::GammaRayTelRunAction ( )

Definition at line 55 of file GammaRayTelRunAction.cc.

55  :
56  outFile(0),fileName("NULL"),fRunID(-1)
57 {;}

◆ ~GammaRayTelRunAction()

GammaRayTelRunAction::~GammaRayTelRunAction ( )

Definition at line 62 of file GammaRayTelRunAction.cc.

63 {;}

Member Function Documentation

◆ BeginOfRunAction()

void GammaRayTelRunAction::BeginOfRunAction ( const G4Run aRun)
virtual

Reimplemented from G4UserRunAction.

Definition at line 67 of file GammaRayTelRunAction.cc.

68 {
69  fRunID = aRun->GetRunID();
70 
71  //Master mode or sequential
72  if (IsMaster())
73  G4cout << "### Run " << aRun->GetRunID() << " starts (master)." << G4endl;
74  else
75  G4cout << "### Run " << aRun->GetRunID() << " starts (worker)." << G4endl;
76 
77  // Prepare the visualization
79  {
81  UI->ApplyCommand("/vis/scene/notifyHandlers");
82  }
83 
84  // If analysis is used reset the histograms
86  // analysis->BeginOfRun(aRun->GetRunID());
87  analysis->BeginOfRun();
88 }
static G4VVisManager * GetConcreteInstance()
static GammaRayTelAnalysis * getInstance()
G4bool IsMaster() const
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
G4GLOB_DLL std::ostream G4cout
G4int GetRunID() const
Definition: G4Run.hh:76
#define G4endl
Definition: G4ios.hh:61
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:446
Here is the call graph for this function:

◆ EndOfRunAction()

void GammaRayTelRunAction::EndOfRunAction ( const G4Run aRun)
virtual

Reimplemented from G4UserRunAction.

Definition at line 92 of file GammaRayTelRunAction.cc.

93 {
94  G4cout << "End of Run " << aRun->GetRunID() << G4endl;
95 
96  // Close the file with the hits information
97 #ifdef G4STORE_DATA
98  if (outFile)
99  {
100  G4cout << "File " << fileName << G4endl;
101  outFile->close();
102  delete outFile;
103  outFile = 0;
104  }
105 #endif
106 
107  // If analysis is used, print out the histograms
109  analysis->EndOfRun();
110 }
static GammaRayTelAnalysis * getInstance()
G4GLOB_DLL std::ostream G4cout
G4int GetRunID() const
Definition: G4Run.hh:76
#define G4endl
Definition: G4ios.hh:61
Here is the call graph for this function:

◆ GetOutputFile()

std::ofstream * GammaRayTelRunAction::GetOutputFile ( )

Definition at line 115 of file GammaRayTelRunAction.cc.

116 {
117  if (!outFile)
118  OpenFile();
119  return outFile;
120 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ OpenFile()

void GammaRayTelRunAction::OpenFile ( )
private

Definition at line 123 of file GammaRayTelRunAction.cc.

124 {
125  // Open the file for the tracks of this run
126 #ifdef G4STORE_DATA
127  //check that we are in a worker: returns -1 in a master and -2 in sequential
128  //one file per thread is produced
129  //Tracks_runR.N.dat, where R=run number, N=thread ID
130  char name[25];
131  if (G4Threading::G4GetThreadId() >= 0)
132  sprintf(name,"Tracks_run%d.%d.dat",fRunID,
134  else
135  sprintf(name,"Tracks_run%d.dat",fRunID);
136  if (!outFile)
137  {
138  outFile = new std::ofstream;
139  outFile->open(name);
140  fileName = G4String(name);
141  }
142  G4cout << "Open file: " << fileName << G4endl;
143 #endif
144 }
G4String name
Definition: TRTMaterials.hh:40
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
G4int G4GetThreadId()
Definition: G4Threading.cc:134
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ fileName

G4String GammaRayTelRunAction::fileName
private

Definition at line 65 of file GammaRayTelRunAction.hh.

◆ fRunID

G4int GammaRayTelRunAction::fRunID
private

Definition at line 68 of file GammaRayTelRunAction.hh.

◆ outFile

std::ofstream* GammaRayTelRunAction::outFile
private

Definition at line 64 of file GammaRayTelRunAction.hh.


The documentation for this class was generated from the following files: