Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4PersistencyManager Class Reference

#include <G4PersistencyManager.hh>

+ Inheritance diagram for G4PersistencyManager:

Public Member Functions

 G4PersistencyManager (G4PersistencyCenter *pc, const G4String &n)
 
virtual ~G4PersistencyManager ()
 
virtual G4PersistencyManagerCreate ()
 
const G4StringGetName ()
 
virtual G4VPEventIOEventIO ()
 
virtual G4VPHitIOHitIO ()
 
virtual G4VPDigitIODigitIO ()
 
virtual G4VMCTruthIOMCTruthIO ()
 
virtual G4VTransactionManagerTransactionManager ()
 
virtual void Initialize ()
 
void SetVerboseLevel (G4int 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 = nullptr
 
G4int m_verbose = 0
 

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 110 of file G4PersistencyManager.hh.

Constructor & Destructor Documentation

◆ G4PersistencyManager()

G4PersistencyManager::G4PersistencyManager ( G4PersistencyCenter * pc,
const G4String & n )

Definition at line 37 of file G4PersistencyManager.cc.

39 : f_pc(ptc)
40 , nameMgr(n)
41{
43}
G4PersistencyCenter * f_pc

◆ ~G4PersistencyManager()

G4PersistencyManager::~G4PersistencyManager ( )
virtual

Definition at line 46 of file G4PersistencyManager.cc.

47{
48}

Member Function Documentation

◆ Create()

virtual G4PersistencyManager * G4PersistencyManager::Create ( )
inlinevirtual

Reimplemented in G4PersistencyManagerT< T >.

Definition at line 122 of file G4PersistencyManager.hh.

122{ return nullptr; }

Referenced by G4PersistencyCenter::SelectSystem().

◆ DigitIO()

virtual G4VPDigitIO * G4PersistencyManager::DigitIO ( )
inlinevirtual

Reimplemented in G4PersistencyManagerT< T >.

Definition at line 137 of file G4PersistencyManager.hh.

137{ return nullptr; }

Referenced by G4PersistencyManagerT< T >::DigitIO(), SetVerboseLevel(), and Store().

◆ EventIO()

virtual G4VPEventIO * G4PersistencyManager::EventIO ( )
inlinevirtual

Reimplemented in G4PersistencyManagerT< T >.

Definition at line 129 of file G4PersistencyManager.hh.

129{ return nullptr; }

Referenced by G4PersistencyManagerT< T >::EventIO(), Retrieve(), SetVerboseLevel(), and Store().

◆ GetName()

const G4String & G4PersistencyManager::GetName ( )
inline

Definition at line 126 of file G4PersistencyManager.hh.

126{ return nameMgr; }

Referenced by G4PersistencyManagerT< T >::Create(), and G4PersistencyCenter::RegisterPersistencyManager().

◆ GetPersistencyManager()

G4PersistencyManager * G4PersistencyManager::GetPersistencyManager ( )
staticprotected

Definition at line 51 of file G4PersistencyManager.cc.

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

◆ HitIO()

virtual G4VPHitIO * G4PersistencyManager::HitIO ( )
inlinevirtual

Reimplemented in G4PersistencyManagerT< T >.

Definition at line 133 of file G4PersistencyManager.hh.

133{ return nullptr; }

Referenced by G4PersistencyManagerT< T >::HitIO(), SetVerboseLevel(), and Store().

◆ Initialize()

virtual void G4PersistencyManager::Initialize ( )
inlinevirtual

Reimplemented in G4PersistencyManagerT< T >.

Definition at line 149 of file G4PersistencyManager.hh.

149{}

Referenced by Retrieve(), and Store().

◆ MCTruthIO()

virtual G4VMCTruthIO * G4PersistencyManager::MCTruthIO ( )
inlinevirtual

Reimplemented in G4PersistencyManagerT< T >.

Definition at line 141 of file G4PersistencyManager.hh.

141{ return nullptr; }

Referenced by G4PersistencyManagerT< T >::MCTruthIO(), SetVerboseLevel(), and Store().

◆ Retrieve() [1/3]

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

Implements G4VPersistencyManager.

Definition at line 274 of file G4PersistencyManager.cc.

275{
276 if(m_verbose > 2)
277 {
278 G4cout << "G4PersistencyManager::Retrieve(G4Event*&) is called." << G4endl;
279 }
280
281 if(TransactionManager() == nullptr)
282 return true;
283
284 if(f_pc->CurrentRetrieveMode("MCTruth") == false &&
285 f_pc->CurrentRetrieveMode("Hits") == false &&
286 f_pc->CurrentRetrieveMode("Digits") == false)
287 {
288 return true;
289 }
290
291 // Call package dependent Initialize()
292 //
293 if(!f_is_initialized)
294 {
295 f_is_initialized = true;
296 if(m_verbose > 1)
297 {
298 G4cout << "G4PersistencyManager:: Initializing Transaction ... "
299 << G4endl;
300 }
301 Initialize();
302 }
303
304 // Start event IO transaction
305 //
306 if(TransactionManager()->StartRead())
307 {
308 if(m_verbose > 2)
309 {
310 G4cout << "G4PersistencyManager: Read transaction started." << G4endl;
311 }
312 }
313 else
314 {
315 G4cerr << "TransactionManager::Retrieve(G4Event) - StartRead() failed."
316 << G4endl;
317 return false;
318 }
319
320 G4bool st = false;
321 G4String file;
322
323 // Retrieve a G4EVENT
324 //
325 G4String obj = "Hits";
326 if(f_pc->CurrentRetrieveMode(obj) == true)
327 {
328 file = f_pc->CurrentReadFile(obj);
329 if(TransactionManager()->SelectReadFile(obj, file))
330 {
331 st = EventIO()->Retrieve(evt);
332 if(st && m_verbose > 1)
333 {
334 G4cout << " -- File : " << file << " -- Event# " << evt->GetEventID()
335 << " -- G4Event is Retrieved." << G4endl;
336 }
337 }
338 else
339 {
340 st = false;
341 }
342 }
343
344 if(st)
345 {
347 }
348 else
349 {
350 G4cerr << "G4PersistencyManager::Retrieve() - Transaction aborted."
351 << G4endl;
353 }
354
355 return st;
356}
bool G4bool
Definition G4Types.hh:86
G4GLOB_DLL std::ostream G4cerr
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
G4int GetEventID() const
Definition G4Event.hh:123
G4bool CurrentRetrieveMode(const G4String &objName)
G4String CurrentReadFile(const G4String &objName)
virtual G4VPEventIO * EventIO()
virtual G4VTransactionManager * TransactionManager()
virtual G4bool Retrieve(G4Pevent *&anEvent)=0
virtual void Abort()=0
virtual void Commit()=0

◆ Retrieve() [2/3]

G4bool G4PersistencyManager::Retrieve ( G4Run *& )
inlinevirtual

Implements G4VPersistencyManager.

Definition at line 165 of file G4PersistencyManager.hh.

165{ return false; }

◆ Retrieve() [3/3]

G4bool G4PersistencyManager::Retrieve ( G4VPhysicalVolume *& )
inlinevirtual

Implements G4VPersistencyManager.

Definition at line 171 of file G4PersistencyManager.hh.

171{ return false; }

◆ SetVerboseLevel()

void G4PersistencyManager::SetVerboseLevel ( G4int v)

Definition at line 58 of file G4PersistencyManager.cc.

59{
60 m_verbose = v;
61 if(m_verbose > 2)
62 {
63 G4cout << "G4PersistencyManager[\"" << nameMgr << "\"," << this
64 << "]: verbose level is set to " << m_verbose << "." << G4endl;
65 }
66 if(EventIO() != nullptr)
68 if(MCTruthIO() != nullptr)
70 if(HitIO() != nullptr)
72 if(DigitIO() != nullptr)
74 if(TransactionManager() != nullptr)
76
77 G4int i;
78
80 if(hcio != nullptr)
81 {
83 for(i = 0; i < (G4int)hcio->NumberOfHCIOmanager(); ++i)
84 {
86 }
87 }
89 if(dcio != nullptr)
90 {
92 for(i = 0; i < (G4int)dcio->NumberOfDCIOmanager(); ++i)
93 {
95 }
96 }
97}
int G4int
Definition G4Types.hh:85
void SetVerboseLevel(int v)
static G4DCIOcatalog * GetDCIOcatalog()
G4VPDigitsCollectionIO * GetDCIOmanager(const G4String &name)
std::size_t NumberOfDCIOmanager()
G4VPHitsCollectionIO * GetHCIOmanager(const G4String &name)
void SetVerboseLevel(G4int v)
static G4HCIOcatalog * GetHCIOcatalog()
std::size_t NumberOfHCIOmanager()
virtual G4VMCTruthIO * MCTruthIO()
virtual G4VPHitIO * HitIO()
virtual G4VPDigitIO * DigitIO()
void SetVerboseLevel(G4int v)
void SetVerboseLevel(G4int v)
void SetVerboseLevel(G4int v)
void SetVerboseLevel(G4int v)
Definition G4VPHitIO.cc:42

Referenced by G4PersistencyCenter::SelectSystem(), G4PersistencyCenter::SetVerboseLevel(), and G4PersistencyManagerT< T >::SetVerboseLevel().

◆ Store() [1/3]

G4bool G4PersistencyManager::Store ( const G4Event * evt)
virtual

Implements G4VPersistencyManager.

Definition at line 100 of file G4PersistencyManager.cc.

101{
102 if(m_verbose > 2)
103 {
104 G4cout << "G4PersistencyManager::Store() is called for event# "
105 << evt->GetEventID() << "." << G4endl;
106 }
107
108 if(TransactionManager() == nullptr)
109 return true;
110
111 G4bool is_store = f_pc->CurrentStoreMode("MCTruth") != kOff ||
112 f_pc->CurrentStoreMode("Hits") != kOff ||
113 f_pc->CurrentStoreMode("Digits") != kOff;
114
115 if(!is_store)
116 return true;
117
118 // Call package dependent Initialize()
119 //
120 if(!f_is_initialized)
121 {
122 f_is_initialized = true;
123 if(m_verbose > 1)
124 {
125 G4cout << "G4PersistencyManager:: Initializing Transaction ... "
126 << G4endl;
127 }
128 Initialize();
129 }
130
131 G4bool st1 = true, st2 = true;
132
133 // Start event IO transaction
134 //
135 if(TransactionManager()->StartUpdate())
136 {
137 if(m_verbose > 2)
138 {
139 G4cout << "G4PersistencyManager: Update transaction started for event#"
140 << evt->GetEventID() << "." << G4endl;
141 }
142 }
143 else
144 {
145 G4cerr << "TransactionManager::Store(G4Event) - StartUpdate() failed."
146 << G4endl;
147 return false;
148 }
149
150 G4String file;
151 G4String obj;
152
153 G4bool stmct = true, st3 = true;
154
155 // Store MCTruth event
156 //
157 obj = "MCTruth";
158 G4MCTEvent* mctevt = nullptr;
159 if(f_pc->CurrentStoreMode(obj) == kOn)
160 {
161 // Note: This part of code will not be activated until a method
162 // to obtain the current pointer of G4MCTEvent* become available.
163
164 // if ( (mctevt = f_MCTman->GetCurrentEvent()) != 0 ) {
165 if(mctevt != nullptr)
166 {
167 file = f_pc->CurrentWriteFile(obj);
168 if(TransactionManager()->SelectWriteFile(obj, file))
169 {
170 stmct = MCTruthIO()->Store(mctevt);
171 if(stmct && m_verbose > 1)
172 {
173 G4cout << " -- File : " << file << " -- Event# " << evt->GetEventID()
174 << " -- G4MCTEvent Stored." << G4endl;
175 }
176 }
177 else
178 {
179 stmct = false;
180 }
181 } // end of if ( mctevt != nullptr )
182 }
183
184 // Store hits collection
185 //
186 obj = "Hits";
187 if(f_pc->CurrentStoreMode(obj) == kOn)
188 {
189 if(G4HCofThisEvent* hc = evt->GetHCofThisEvent())
190 {
191 file = f_pc->CurrentWriteFile(obj);
192 if(TransactionManager()->SelectWriteFile(obj, file))
193 {
194 st1 = HitIO()->Store(hc);
195 if(st1 && m_verbose > 1)
196 {
197 G4cout << " -- File : " << file << " -- Event# " << evt->GetEventID()
198 << " -- Hit Collections Stored." << G4endl;
199 }
200 }
201 else
202 {
203 st1 = false;
204 }
205 }
206 }
207
208 // Store digits collection
209 //
210 obj = "Digits";
211 if(f_pc->CurrentStoreMode(obj) == kOn)
212 {
213 if(G4DCofThisEvent* dc = evt->GetDCofThisEvent())
214 {
215 file = f_pc->CurrentWriteFile(obj);
216 if(TransactionManager()->SelectWriteFile(obj, file))
217 {
218 st2 = DigitIO()->Store(dc);
219 if(st2 && m_verbose > 1)
220 {
221 G4cout << " -- File : " << file << " -- Event# " << evt->GetEventID()
222 << " -- Digit Collections Stored." << G4endl;
223 }
224 }
225 else
226 {
227 st2 = false;
228 }
229 }
230 }
231
232 // Store this G4EVENT
233 //
234 if(mctevt != 0 || evt != 0)
235 {
236 obj = "Hits";
237 file = f_pc->CurrentWriteFile(obj);
238 if(TransactionManager()->SelectWriteFile(obj, file))
239 {
240 st3 = EventIO()->Store(evt);
241 if(st3 && m_verbose > 1)
242 {
243 G4cout << " -- File name: " << f_pc->CurrentWriteFile("Hits")
244 << " -- Event# " << evt->GetEventID()
245 << " -- G4Pevent is Stored." << G4endl;
246 }
247 }
248 else
249 {
250 st3 = false;
251 }
252 }
253
254 G4bool st = stmct && st1 && st2 && st3;
255
256 if(st)
257 {
259 if(m_verbose > 0)
260 G4cout << "G4PersistencyManager: event# " << evt->GetEventID()
261 << " is stored." << G4endl;
262 }
263 else
264 {
265 G4cerr << "G4PersistencyManager::Store(G4Event) - Transaction aborted."
266 << G4endl;
268 }
269
270 return st;
271}
G4HCofThisEvent * GetHCofThisEvent() const
Definition G4Event.hh:161
G4DCofThisEvent * GetDCofThisEvent() const
Definition G4Event.hh:163
StoreMode CurrentStoreMode(const G4String &objName)
G4String CurrentWriteFile(const G4String &objName)
virtual G4bool Store(G4MCTEvent *)=0
virtual G4bool Store(const G4DCofThisEvent *)=0
virtual G4bool Store(const G4Event *anEvent)=0
virtual G4bool Store(const G4HCofThisEvent *)=0

◆ Store() [2/3]

G4bool G4PersistencyManager::Store ( const G4Run * )
inlinevirtual

Implements G4VPersistencyManager.

Definition at line 162 of file G4PersistencyManager.hh.

162{ return false; }

◆ Store() [3/3]

G4bool G4PersistencyManager::Store ( const G4VPhysicalVolume * )
inlinevirtual

Implements G4VPersistencyManager.

Definition at line 168 of file G4PersistencyManager.hh.

168{ return false; }

◆ TransactionManager()

virtual G4VTransactionManager * G4PersistencyManager::TransactionManager ( )
inlinevirtual

Reimplemented in G4PersistencyManagerT< T >.

Definition at line 145 of file G4PersistencyManager.hh.

145{ return nullptr; }

Referenced by Retrieve(), SetVerboseLevel(), Store(), and G4PersistencyManagerT< T >::TransactionManager().

Friends And Related Symbol Documentation

◆ G4PersistencyCenter

friend class G4PersistencyCenter
friend

Definition at line 112 of file G4PersistencyManager.hh.

Member Data Documentation

◆ f_pc

G4PersistencyCenter* G4PersistencyManager::f_pc = nullptr
protected

◆ m_verbose

G4int G4PersistencyManager::m_verbose = 0
protected

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