Geant4  10.02.p03
RunActionMaster Class Reference

#include <RunActionMaster.hh>

Inheritance diagram for RunActionMaster:
Collaboration diagram for RunActionMaster:

Public Member Functions

 RunActionMaster ()
 
 ~RunActionMaster ()
 
virtual G4RunGenerateRun ()
 
virtual void BeginOfRunAction (const G4Run *arun)
 
virtual void EndOfRunAction (const G4Run *arun)
 
- Public Member Functions inherited from G4UserRunAction
 G4UserRunAction ()
 
virtual ~G4UserRunAction ()
 
void SetMaster (G4bool val=true)
 
G4bool IsMaster () const
 

Additional Inherited Members

- Protected Attributes inherited from G4UserRunAction
G4bool isMaster
 

Detailed Description

Definition at line 36 of file RunActionMaster.hh.

Constructor & Destructor Documentation

◆ RunActionMaster()

RunActionMaster::RunActionMaster ( )

Definition at line 43 of file RunActionMaster.cc.

44 {
45 }

◆ ~RunActionMaster()

RunActionMaster::~RunActionMaster ( )

Definition at line 54 of file RunActionMaster.cc.

55 {
56 }

Member Function Documentation

◆ BeginOfRunAction()

void RunActionMaster::BeginOfRunAction ( const G4Run arun)
virtual

Reimplemented from G4UserRunAction.

Definition at line 60 of file RunActionMaster.cc.

61 {
63  myana-> Clear();
64  myana->Book();
65 }
void Clear(Node *)
static Analysis * GetAnalysis()
Here is the call graph for this function:

◆ EndOfRunAction()

void RunActionMaster::EndOfRunAction ( const G4Run arun)
virtual

Reimplemented from G4UserRunAction.

Definition at line 69 of file RunActionMaster.cc.

70 {
71  //This is executed by master thread. Workers have already
72  //merged their histograms into this master threads
73  G4int rank = G4MPImanager::GetManager()-> GetRank();
74 
75  //Save histograms before MPI merging
76  if (rank == 0)
77  {
78  G4String fname("dose-rank000");
80  myana-> Save(fname);
81  }
82 
83  G4cout << "======================================";
84  G4cout << "===========" << G4endl;
85  G4cout << "Start EndOfRunAction for master thread in rank: " << rank<<G4endl;
86  G4cout << "======================================";
87  G4cout << "===========" << G4endl;
88 
89  //Merging of G4Run object:
90  //All ranks > 0 merge to rank #0
91  RunMerger rm(static_cast<const Run*>(arun));
92  G4int ver = 0 ; //Use 4 for lots of info
93  if ( rank == 0 && ver == 0) ver = 1;
94 
95  if ( ver > 1 ) {
96  G4cout<<"Before merge the Run object has test counter value: "
97  <<static_cast<const Run*>(arun)->GetCounter()<<G4endl;
98  }
99  rm.SetVerbosity( ver );
100  rm.Merge();
101  if ( ver > 1 ) {
102  G4cout<<"After merge the Run object has test counter value: "
103  <<static_cast<const Run*>(arun)->GetCounter()
104  <<" (with 1 thread== number of ranks)"<<G4endl;
105  }
106 
107  //Merge of scorers
108  //ver = 0;
110  {
112  sm.SetVerbosity(ver);
113  sm.Merge();
114  }
115 
116  //Merge of g4analysis objects
117  ver=0;
118  G4MPIhistoMerger hm(G4AnalysisManager::Instance());
119  hm.SetVerbosity(ver);
120  hm.Merge();
121 
122  G4cout << "======================================";
123  G4cout << "==========" << G4endl;
124  G4cout << "End EndOfRunAction for master thread in rank: " << rank << G4endl;
125  G4cout << "======================================";
126  G4cout << "==========" << G4endl;
127 
128  //Save g4analysis objects to a file
129  //NB: It is important that the save is done *after* MPI-merging of histograms
130 
131  //One can save all ranks or just rank0: remember in case of all ranks,
132  //the file of rank0 contains the sum of everything
133  if (true /*rank == 0*/)
134  {
135  char str[64];
136  sprintf(str, "dose-rank%03d", rank);
137  G4String fname(str);
138  if (rank == 0)
139  fname = "dose-merged";
140  Analysis* myana = Analysis::GetAnalysis();
141  myana-> Save(fname);
142  }
143  Analysis* myana = Analysis::GetAnalysis();
144  myana-> Close();
145 }
int G4int
Definition: G4Types.hh:78
c1 Close()
G4GLOB_DLL std::ostream G4cout
static G4ScoringManager * GetScoringManagerIfExist()
static Analysis * GetAnalysis()
static G4MPImanager * GetManager()
#define G4endl
Definition: G4ios.hh:61
Here is the call graph for this function:

◆ GenerateRun()

G4Run * RunActionMaster::GenerateRun ( void  )
virtual

Reimplemented from G4UserRunAction.

Definition at line 48 of file RunActionMaster.cc.

49 {
50  return new Run;
51 }

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