Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4PersistencyManager Class Reference

#include <G4PersistencyManager.hh>

Inheritance diagram for G4PersistencyManager:
Collaboration diagram for G4PersistencyManager:

Public Member Functions

 G4PersistencyManager (G4PersistencyCenter *pc, std::string n)
 
virtual ~G4PersistencyManager ()
 
virtual G4PersistencyManagerCreate ()
 
std::string GetName ()
 
virtual G4VPEventIOEventIO ()
 
virtual G4VPHitIOHitIO ()
 
virtual G4VPDigitIODigitIO ()
 
virtual G4VMCTruthIOMCTruthIO ()
 
virtual G4VTransactionManagerTransactionManager ()
 
virtual void Initialize ()
 
void SetVerboseLevel (int v)
 
G4bool Store (const G4Event *evt)
 
G4bool Retrieve (G4Event *&evt)
 
G4bool Store (const G4Run *)
 
G4bool Retrieve (G4Run *&)
 
G4bool Store (const G4VPhysicalVolume *)
 
G4bool Retrieve (G4VPhysicalVolume *&)
 
- Public Member Functions inherited from G4VPersistencyManager
virtual ~G4VPersistencyManager ()
 

Static Protected Member Functions

static G4PersistencyManagerGetPersistencyManager ()
 

Protected Attributes

G4PersistencyCenterf_pc
 
int m_verbose
 

Friends

class G4PersistencyCenter
 

Additional Inherited Members

- Static Public Member Functions inherited from G4VPersistencyManager
static G4VPersistencyManagerGetPersistencyManager ()
 
- Protected Member Functions inherited from G4VPersistencyManager
 G4VPersistencyManager ()
 

Detailed Description

Definition at line 114 of file G4PersistencyManager.hh.

Constructor & Destructor Documentation

G4PersistencyManager::G4PersistencyManager ( G4PersistencyCenter pc,
std::string  n 
)

Definition at line 38 of file G4PersistencyManager.cc.

39  : f_pc(ptc), nameMgr(n), f_is_initialized(false)
40 {
42 }
G4PersistencyCenter * f_pc

Here is the call graph for this function:

G4PersistencyManager::~G4PersistencyManager ( )
virtual

Definition at line 45 of file G4PersistencyManager.cc.

46 {}

Member Function Documentation

virtual G4PersistencyManager* G4PersistencyManager::Create ( )
inlinevirtual

Reimplemented in G4PersistencyManagerT< T >.

Definition at line 127 of file G4PersistencyManager.hh.

127 {return 0;};

Here is the caller graph for this function:

virtual G4VPDigitIO* G4PersistencyManager::DigitIO ( )
inlinevirtual

Reimplemented in G4PersistencyManagerT< T >.

Definition at line 141 of file G4PersistencyManager.hh.

141 { return 0; };

Here is the caller graph for this function:

virtual G4VPEventIO* G4PersistencyManager::EventIO ( )
inlinevirtual

Reimplemented in G4PersistencyManagerT< T >.

Definition at line 133 of file G4PersistencyManager.hh.

133 { return 0; };

Here is the caller graph for this function:

std::string G4PersistencyManager::GetName ( )
inline

Definition at line 130 of file G4PersistencyManager.hh.

130 {return nameMgr;};

Here is the caller graph for this function:

G4PersistencyManager * G4PersistencyManager::GetPersistencyManager ( )
staticprotected

Definition at line 49 of file G4PersistencyManager.cc.

50 {
52 }
G4PersistencyManager * CurrentPersistencyManager()
static G4PersistencyCenter * GetPersistencyCenter()

Here is the call graph for this function:

virtual G4VPHitIO* G4PersistencyManager::HitIO ( )
inlinevirtual

Reimplemented in G4PersistencyManagerT< T >.

Definition at line 137 of file G4PersistencyManager.hh.

137 { return 0; };

Here is the caller graph for this function:

virtual void G4PersistencyManager::Initialize ( )
inlinevirtual

Reimplemented in G4PersistencyManagerT< T >.

Definition at line 153 of file G4PersistencyManager.hh.

153 {};

Here is the caller graph for this function:

virtual G4VMCTruthIO* G4PersistencyManager::MCTruthIO ( )
inlinevirtual

Reimplemented in G4PersistencyManagerT< T >.

Definition at line 145 of file G4PersistencyManager.hh.

145 { return 0; };

Here is the caller graph for this function:

G4bool G4PersistencyManager::Retrieve ( G4Event *&  evt)
virtual

Implements G4VPersistencyManager.

Definition at line 230 of file G4PersistencyManager.cc.

231 {
232  if ( m_verbose > 2 ) {
233  G4cout << "G4PersistencyManager::Retrieve(G4Event*&) is called."
234  << G4endl;
235  }
236 
237  if ( TransactionManager() == 0 ) return true;
238 
239  if ( f_pc->CurrentRetrieveMode("MCTruth") == false &&
240  f_pc->CurrentRetrieveMode("Hits") == false &&
241  f_pc->CurrentRetrieveMode("Digits") == false ) {
242  return true;
243  }
244 
245  // Call package dependent Initialize()
246  //
247  if ( ! f_is_initialized ) {
248  f_is_initialized = true;
249  if ( m_verbose > 1 ) {
250  G4cout << "G4PersistencyManager:: Initializing Transaction ... "
251  << G4endl;
252  }
253  Initialize();
254  }
255 
256  // Start event IO transaction
257  //
258  if ( TransactionManager()->StartRead() ) {
259  if ( m_verbose > 2 ) {
260  G4cout << "G4PersistencyManager: Read transaction started."
261  << G4endl;
262  }
263  } else {
264  G4cerr << "TransactionManager::Retrieve(G4Event) - StartRead() failed."
265  << G4endl;
266  return false;
267  }
268 
269  G4bool st = false;
270  std::string file;
271 
272  // Retrieve a G4EVENT
273  //
274  std::string obj = "Hits";
275  if ( f_pc->CurrentRetrieveMode(obj) == true ) {
276  file = f_pc->CurrentReadFile(obj);
277  if ( TransactionManager()->SelectReadFile(obj, file) ) {
278  st = EventIO()->Retrieve(evt);
279  if ( st && m_verbose > 1 ) {
280  G4cout << " -- File : " << file << " -- Event# "
281  << evt->GetEventID()
282  << " -- G4Event is Retrieved." << G4endl;
283  }
284  } else {
285  st = false;
286  }
287  }
288 
289  if ( st ) {
291  } else {
292  G4cerr << "G4PersistencyManager::Retrieve() - Transaction aborted."
293  << G4endl;
295  }
296 
297  return st;
298 }
std::string CurrentReadFile(std::string objName)
virtual G4bool Retrieve(G4Pevent *&anEvent)=0
G4int GetEventID() const
Definition: G4Event.hh:151
G4GLOB_DLL std::ostream G4cout
virtual void Commit()=0
bool G4bool
Definition: G4Types.hh:79
virtual void Abort()=0
G4bool CurrentRetrieveMode(std::string objName)
virtual G4VPEventIO * EventIO()
G4PersistencyCenter * f_pc
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr
virtual G4VTransactionManager * TransactionManager()

Here is the call graph for this function:

G4bool G4PersistencyManager::Retrieve ( G4Run *&  )
inlinevirtual

Implements G4VPersistencyManager.

Definition at line 169 of file G4PersistencyManager.hh.

169 {return false;};
G4bool G4PersistencyManager::Retrieve ( G4VPhysicalVolume *&  )
inlinevirtual

Implements G4VPersistencyManager.

Definition at line 175 of file G4PersistencyManager.hh.

175 {return false;};
void G4PersistencyManager::SetVerboseLevel ( int  v)

Definition at line 55 of file G4PersistencyManager.cc.

56 {
57  m_verbose = v;
58  if ( m_verbose > 2 ) {
59  G4cout << "G4PersistencyManager[\"" << nameMgr << "\"," << this
60  << "]: verbose level is set to " << m_verbose << "."
61  << G4endl;
62  }
63  if ( EventIO() != 0 ) EventIO()->SetVerboseLevel(m_verbose);
64  if ( MCTruthIO() != 0 ) MCTruthIO()->SetVerboseLevel(m_verbose);
65  if ( HitIO() != 0 ) HitIO()->SetVerboseLevel(m_verbose);
66  if ( DigitIO() != 0 ) DigitIO()->SetVerboseLevel(m_verbose);
68 
69  size_t i;
70 
72  if ( hcio != 0 ) {
74  for ( i = 0; i < hcio->NumberOfHCIOmanager(); i++ ) {
76  }
77  }
79  if ( dcio != 0 ) {
81  for ( i = 0; i < dcio->NumberOfDCIOmanager(); i++ ) {
83  }
84  }
85 }
G4VPDigitsCollectionIO * GetDCIOmanager(std::string name)
static G4HCIOcatalog * GetHCIOcatalog()
void SetVerboseLevel(int v)
Definition: G4VPEventIO.hh:50
size_t NumberOfHCIOmanager()
virtual G4VPDigitIO * DigitIO()
virtual G4VMCTruthIO * MCTruthIO()
G4GLOB_DLL std::ostream G4cout
void SetVerboseLevel(int v)
Definition: G4VMCTruthIO.hh:59
static G4DCIOcatalog * GetDCIOcatalog()
G4VPHitsCollectionIO * GetHCIOmanager(std::string name)
void SetVerboseLevel(int v)
virtual G4VPEventIO * EventIO()
virtual G4VPHitIO * HitIO()
void SetVerboseLevel(int v)
Definition: G4VPHitIO.cc:43
#define G4endl
Definition: G4ios.hh:61
void SetVerboseLevel(int v)
size_t NumberOfDCIOmanager()
void SetVerboseLevel(int v)
Definition: G4VPDigitIO.cc:43
virtual G4VTransactionManager * TransactionManager()

Here is the call graph for this function:

Here is the caller graph for this function:

G4bool G4PersistencyManager::Store ( const G4Event evt)
virtual

Implements G4VPersistencyManager.

Definition at line 88 of file G4PersistencyManager.cc.

89 {
90  if ( m_verbose > 2 ) {
91  G4cout << "G4PersistencyManager::Store() is called for event# "
92  << evt->GetEventID() << "." << G4endl;
93  }
94 
95  if ( TransactionManager() == 0 ) return true;
96 
97  G4bool is_store = f_pc->CurrentStoreMode("MCTruth") != kOff ||
98  f_pc->CurrentStoreMode("Hits") != kOff ||
99  f_pc->CurrentStoreMode("Digits") != kOff;
100 
101  if ( ! is_store ) return true;
102 
103  // Call package dependent Initialize()
104  //
105  if ( ! f_is_initialized ) {
106  f_is_initialized = true;
107  if ( m_verbose > 1 ) {
108  G4cout << "G4PersistencyManager:: Initializing Transaction ... "
109  << G4endl;
110  }
111  Initialize();
112  }
113 
114  G4bool st1 = true, st2 = true;
115 
116  // Start event IO transaction
117  //
118  if ( TransactionManager()->StartUpdate() ) {
119  if ( m_verbose > 2 ) {
120  G4cout << "G4PersistencyManager: Update transaction started for event#"
121  << evt->GetEventID() << "." << G4endl;
122  }
123  } else {
124  G4cerr << "TransactionManager::Store(G4Event) - StartUpdate() failed."
125  << G4endl;
126  return false;
127  }
128 
129  std::string file;
130  std::string obj;
131 
132  G4bool stmct = true, st3 = true;
133 
134  // Store MCTruth event
135  //
136  obj = "MCTruth";
137  G4MCTEvent* mctevt = 0;
138  if ( f_pc->CurrentStoreMode(obj) == kOn ) {
139 
140  // Note: This part of code will not be activated until a method
141  // to obtain the current pointer of G4MCTEvent* become available.
142 
143  // if ( (mctevt = f_MCTman->GetCurrentEvent()) != 0 ) {
144  if ( mctevt != 0 ) {
145  file = f_pc->CurrentWriteFile(obj);
146  if ( TransactionManager()->SelectWriteFile(obj, file) ) {
147  stmct = MCTruthIO()->Store(mctevt);
148  if ( stmct && m_verbose > 1 ) {
149  G4cout << " -- File : " << file << " -- Event# "
150  << evt->GetEventID() << " -- G4MCTEvent Stored." << G4endl;
151  }
152  } else {
153  stmct = false;
154  }
155  } // end of if ( mctevt != 0 )
156  }
157 
158  // Store hits collection
159  //
160  obj = "Hits";
161  if ( f_pc->CurrentStoreMode(obj) == kOn ) {
162  if ( G4HCofThisEvent* hc = evt->GetHCofThisEvent() ) {
163  file = f_pc->CurrentWriteFile(obj);
164  if ( TransactionManager()->SelectWriteFile(obj, file) ) {
165  st1 = HitIO()->Store(hc);
166  if ( st1 && m_verbose > 1 ) {
167  G4cout << " -- File : " << file << " -- Event# "
168  << evt->GetEventID()
169  << " -- Hit Collections Stored." << G4endl;
170  }
171  } else {
172  st1 = false;
173  }
174  }
175  }
176 
177  // Store digits collection
178  //
179  obj = "Digits";
180  if ( f_pc->CurrentStoreMode(obj) == kOn ) {
181  if ( G4DCofThisEvent* dc = evt->GetDCofThisEvent() ) {
182  file = f_pc->CurrentWriteFile(obj);
183  if ( TransactionManager()->SelectWriteFile(obj, file) ) {
184  st2 = DigitIO()->Store(dc);
185  if ( st2 && m_verbose > 1 ) {
186  G4cout << " -- File : " << file << " -- Event# "
187  << evt->GetEventID()
188  << " -- Digit Collections Stored." << G4endl;
189  }
190  } else {
191  st2 = false;
192  }
193  }
194  }
195 
196  // Store this G4EVENT
197  //
198  if ( mctevt!=0 || evt!=0 ) {
199  obj = "Hits";
200  file = f_pc->CurrentWriteFile(obj);
201  if ( TransactionManager()->SelectWriteFile(obj, file) ) {
202  st3 = EventIO()->Store(evt);
203  if ( st3 && m_verbose > 1 ) {
204  G4cout << " -- File name: " << f_pc->CurrentWriteFile("Hits")
205  << " -- Event# " << evt->GetEventID()
206  << " -- G4Pevent is Stored." << G4endl;
207  }
208  } else {
209  st3 = false;
210  }
211  }
212 
213  G4bool st = stmct && st1 && st2 && st3;
214 
215  if ( st ) {
217  if ( m_verbose > 0 )
218  G4cout << "G4PersistencyManager: event# "
219  << evt->GetEventID() << " is stored." << G4endl;
220  } else {
221  G4cerr << "G4PersistencyManager::Store(G4Event) - Transaction aborted."
222  << G4endl;
224  }
225 
226  return st;
227 }
const G4double hc
[MeV*fm]
virtual G4bool Store(const G4Event *anEvent)=0
virtual G4VPDigitIO * DigitIO()
G4int GetEventID() const
Definition: G4Event.hh:151
StoreMode CurrentStoreMode(std::string objName)
virtual G4VMCTruthIO * MCTruthIO()
G4GLOB_DLL std::ostream G4cout
virtual void Commit()=0
bool G4bool
Definition: G4Types.hh:79
virtual void Abort()=0
virtual G4bool Store(const G4DCofThisEvent *)=0
virtual G4VPEventIO * EventIO()
virtual G4VPHitIO * HitIO()
virtual G4bool Store(const G4HCofThisEvent *)=0
G4PersistencyCenter * f_pc
#define G4endl
Definition: G4ios.hh:61
virtual G4bool Store(G4MCTEvent *)=0
G4HCofThisEvent * GetHCofThisEvent() const
Definition: G4Event.hh:185
G4DCofThisEvent * GetDCofThisEvent() const
Definition: G4Event.hh:187
std::string CurrentWriteFile(std::string objName)
G4GLOB_DLL std::ostream G4cerr
virtual G4VTransactionManager * TransactionManager()

Here is the call graph for this function:

G4bool G4PersistencyManager::Store ( const G4Run )
inlinevirtual

Implements G4VPersistencyManager.

Definition at line 166 of file G4PersistencyManager.hh.

166 {return false;};
G4bool G4PersistencyManager::Store ( const G4VPhysicalVolume )
inlinevirtual

Implements G4VPersistencyManager.

Definition at line 172 of file G4PersistencyManager.hh.

172 {return false;};
virtual G4VTransactionManager* G4PersistencyManager::TransactionManager ( )
inlinevirtual

Reimplemented in G4PersistencyManagerT< T >.

Definition at line 149 of file G4PersistencyManager.hh.

149 { return 0; };

Here is the caller graph for this function:

Friends And Related Function Documentation

friend class G4PersistencyCenter
friend

Definition at line 117 of file G4PersistencyManager.hh.

Member Data Documentation

G4PersistencyCenter* G4PersistencyManager::f_pc
protected

Definition at line 183 of file G4PersistencyManager.hh.

int G4PersistencyManager::m_verbose
protected

Definition at line 184 of file G4PersistencyManager.hh.


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