ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4MPIstatus.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4MPIstatus.cc
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
27 
28 #include "G4ApplicationState.hh"
29 #include "G4MPIstatus.hh"
30 
31 // --------------------------------------------------------------------------
33  : rank_(0), run_id_(0), nevent_to_be_processed_(0), event_id_(0),
34  cputime_(0.), g4state_(G4State_Quit)
35 {
36  timer_ = new G4Timer;
37 }
38 
39 // --------------------------------------------------------------------------
41 {
42  delete timer_;
43 }
44 
45 // --------------------------------------------------------------------------
47 {
48  timer_-> Start();
49 }
50 
51 // --------------------------------------------------------------------------
53 {
54  timer_-> Stop();
55 }
56 
57 // --------------------------------------------------------------------------
58 void G4MPIstatus::SetStatus(G4int arank, G4int runid, G4int noe, G4int evtid,
59  G4ApplicationState state)
60 {
61  rank_ = arank;
62  run_id_ = runid;
64  event_id_ = evtid;
65  g4state_ = state;
66  if ( timer_-> IsValid() ) cputime_= timer_-> GetRealElapsed();
67  else cputime_ = 0.;
68 }
69 
70 // --------------------------------------------------------------------------
72 {
73  data[0] = rank_;
74  data[1] = run_id_;
75  data[2] = nevent_to_be_processed_;
76  data[3] = event_id_;
77  data[4] = g4state_;
78 
79  G4double* ddata = (G4double*)(data+5);
80  ddata[0] = cputime_;
81 }
82 
83 // --------------------------------------------------------------------------
85 {
86  rank_ = data[0];
87  run_id_ = data[1];
88  nevent_to_be_processed_ = data[2];
89  event_id_ = data[3];
90  g4state_ = (G4ApplicationState)data[4];
91 
92  G4double* ddata = (G4double*)(data+5);
93  cputime_ = ddata[0];
94 }
95 
96 // --------------------------------------------------------------------------
97 void G4MPIstatus::Print() const
98 {
99  // * rank= 001 run= 10002 event= 00001 / 100000 state= Idle"
100  G4cout << "* rank= " << rank_
101  << " run= " << run_id_
102  << " event= " << event_id_ << " / " << nevent_to_be_processed_
103  << " state= " << GetStateString(g4state_)
104  << " time= " << cputime_ << "s"
105  << G4endl;
106 }
107 
108 // --------------------------------------------------------------------------
110 {
111  G4String sname;
112 
113  switch(astate) {
114  case G4State_PreInit:
115  sname = "PreInit";
116  break;
117  case G4State_Init:
118  sname = "Init";
119  break;
120  case G4State_Idle:
121  sname = "Idle";
122  break;
123  case G4State_GeomClosed:
124  sname = "GeomClosed";
125  break;
126  case G4State_EventProc:
127  sname = "EventProc";
128  break;
129  case G4State_Quit:
130  sname = "Quit";
131  break;
132  case G4State_Abort:
133  sname = "Abort";
134  break;
135  default:
136  sname = "Unknown";
137  break;
138  }
139 
140  return sname;
141 }