Geant4-11
Public Member Functions | Static Protected Member Functions | Protected Attributes | Private Attributes | Static Private Attributes
G4PersistencyManagerT< T > Class Template Reference

#include <G4PersistencyManagerT.hh>

Inheritance diagram for G4PersistencyManagerT< T >:
G4PersistencyManager G4VPersistencyManager

Public Member Functions

G4PersistencyManagerCreate ()
 
void Delete ()
 
G4VPDigitIODigitIO ()
 
G4VPEventIOEventIO ()
 
 G4PersistencyManagerT (G4PersistencyCenter *pc, const G4String &n)
 
const G4StringGetName ()
 
G4VHepMCIO * HepMCIO ()
 
G4VPHitIOHitIO ()
 
void Initialize ()
 
G4VMCTruthIOMCTruthIO ()
 
G4bool Retrieve (G4Event *&evt)
 
G4bool Retrieve (G4Run *&)
 
G4bool Retrieve (G4VPhysicalVolume *&)
 
void SetVerboseLevel (G4int v)
 
G4bool Store (const G4Event *evt)
 
G4bool Store (const G4Run *)
 
G4bool Store (const G4VPhysicalVolume *)
 
G4VTransactionManagerTransactionManager ()
 
 ~G4PersistencyManagerT ()
 

Static Protected Member Functions

static G4PersistencyManagerGetPersistencyManager ()
 

Protected Attributes

G4PersistencyCenterf_pc = nullptr
 
G4int m_verbose = 0
 

Private Attributes

G4bool f_is_initialized = false
 
G4String nameMgr
 
G4PersistencyManagerpm = nullptr
 

Static Private Attributes

static G4ThreadLocal G4VPersistencyManagerfPersistencyManager = nullptr
 

Detailed Description

template<class T>
class G4PersistencyManagerT< T >

Definition at line 41 of file G4PersistencyManagerT.hh.

Constructor & Destructor Documentation

◆ G4PersistencyManagerT()

template<class T >
G4PersistencyManagerT< T >::G4PersistencyManagerT ( G4PersistencyCenter pc,
const G4String n 
)
inline

Definition at line 45 of file G4PersistencyManagerT.hh.

47 {
48 if(m_verbose > 2)
49 {
50 G4cout << "G4PersistencyManagerT: Registering G4PersistencyManager \""
51 << n << "\"" << G4endl;
52 }
55 }
static constexpr double pc
Definition: G4SIunits.hh:117
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
static G4PersistencyCenter * GetPersistencyCenter()
void RegisterPersistencyManager(G4PersistencyManager *pm)
G4PersistencyManager(G4PersistencyCenter *pc, const G4String &n)

References G4cout, G4endl, G4PersistencyCenter::GetPersistencyCenter(), G4PersistencyManager::m_verbose, CLHEP::detail::n, and G4PersistencyCenter::RegisterPersistencyManager().

◆ ~G4PersistencyManagerT()

template<class T >
G4PersistencyManagerT< T >::~G4PersistencyManagerT ( )
inline

Definition at line 58 of file G4PersistencyManagerT.hh.

58{}

Member Function Documentation

◆ Create()

template<class T >
G4PersistencyManager * G4PersistencyManagerT< T >::Create ( )
inlinevirtual

Reimplemented from G4PersistencyManager.

Definition at line 61 of file G4PersistencyManagerT.hh.

62 {
63 pm = new T(f_pc, GetName());
64 return pm;
65 }
G4PersistencyManager * pm
G4PersistencyCenter * f_pc
const G4String & GetName()

References G4PersistencyManager::f_pc, G4PersistencyManager::GetName(), and G4PersistencyManagerT< T >::pm.

◆ Delete()

template<class T >
void G4PersistencyManagerT< T >::Delete ( )
inline

Definition at line 68 of file G4PersistencyManagerT.hh.

69 {
70 if(pm != nullptr) delete pm;
71 }

References G4PersistencyManagerT< T >::pm.

◆ DigitIO()

template<class T >
G4VPDigitIO * G4PersistencyManagerT< T >::DigitIO ( )
inlinevirtual

Reimplemented from G4PersistencyManager.

Definition at line 92 of file G4PersistencyManagerT.hh.

93 {
94 if(pm != nullptr)
95 return pm->DigitIO();
96 else
97 return nullptr;
98 }
virtual G4VPDigitIO * DigitIO()

References G4PersistencyManager::DigitIO(), and G4PersistencyManagerT< T >::pm.

◆ EventIO()

template<class T >
G4VPEventIO * G4PersistencyManagerT< T >::EventIO ( )
inlinevirtual

Reimplemented from G4PersistencyManager.

Definition at line 74 of file G4PersistencyManagerT.hh.

75 {
76 if(pm != nullptr)
77 return pm->EventIO();
78 else
79 return nullptr;
80 }
virtual G4VPEventIO * EventIO()

References G4PersistencyManager::EventIO(), and G4PersistencyManagerT< T >::pm.

◆ GetName()

const G4String & G4PersistencyManager::GetName ( )
inlineinherited

◆ GetPersistencyManager()

G4PersistencyManager * G4PersistencyManager::GetPersistencyManager ( )
staticprotectedinherited

◆ HepMCIO()

template<class T >
G4VHepMCIO * G4PersistencyManagerT< T >::HepMCIO ( )
inline

Definition at line 101 of file G4PersistencyManagerT.hh.

102 {
103 if(pm != nullptr)
104 return pm->HepMCIO();
105 else
106 return nullptr;
107 }

References G4PersistencyManagerT< T >::pm.

◆ HitIO()

template<class T >
G4VPHitIO * G4PersistencyManagerT< T >::HitIO ( )
inlinevirtual

Reimplemented from G4PersistencyManager.

Definition at line 83 of file G4PersistencyManagerT.hh.

84 {
85 if(pm != nullptr)
86 return pm->HitIO();
87 else
88 return nullptr;
89 }
virtual G4VPHitIO * HitIO()

References G4PersistencyManager::HitIO(), and G4PersistencyManagerT< T >::pm.

◆ Initialize()

template<class T >
void G4PersistencyManagerT< T >::Initialize ( )
inlinevirtual

Reimplemented from G4PersistencyManager.

Definition at line 128 of file G4PersistencyManagerT.hh.

128{}

◆ MCTruthIO()

template<class T >
G4VMCTruthIO * G4PersistencyManagerT< T >::MCTruthIO ( )
inlinevirtual

Reimplemented from G4PersistencyManager.

Definition at line 110 of file G4PersistencyManagerT.hh.

111 {
112 if(pm != nullptr)
113 return pm->MCTruthIO();
114 else
115 return nullptr;
116 }
virtual G4VMCTruthIO * MCTruthIO()

References G4PersistencyManager::MCTruthIO(), and G4PersistencyManagerT< T >::pm.

◆ Retrieve() [1/3]

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

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 //
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;
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
G4int GetEventID() const
Definition: G4Event.hh:118
G4bool CurrentRetrieveMode(const G4String &objName)
G4String CurrentReadFile(const G4String &objName)
virtual G4VTransactionManager * TransactionManager()
virtual G4bool Retrieve(G4Pevent *&anEvent)=0
virtual void Abort()=0
virtual void Commit()=0

References G4VTransactionManager::Abort(), G4VTransactionManager::Commit(), G4PersistencyCenter::CurrentReadFile(), G4PersistencyCenter::CurrentRetrieveMode(), G4PersistencyManager::EventIO(), G4PersistencyManager::f_is_initialized, G4PersistencyManager::f_pc, geant4_check_module_cycles::file, G4cerr, G4cout, G4endl, G4Event::GetEventID(), G4PersistencyManager::Initialize(), G4PersistencyManager::m_verbose, G4VPEventIO::Retrieve(), and G4PersistencyManager::TransactionManager().

◆ Retrieve() [2/3]

G4bool G4PersistencyManager::Retrieve ( G4Run *&  )
inlinevirtualinherited

Implements G4VPersistencyManager.

Definition at line 165 of file G4PersistencyManager.hh.

165{ return false; }

◆ Retrieve() [3/3]

G4bool G4PersistencyManager::Retrieve ( G4VPhysicalVolume *&  )
inlinevirtualinherited

Implements G4VPersistencyManager.

Definition at line 171 of file G4PersistencyManager.hh.

171{ return false; }

◆ SetVerboseLevel()

template<class T >
void G4PersistencyManagerT< T >::SetVerboseLevel ( G4int  v)
inline

Definition at line 131 of file G4PersistencyManagerT.hh.

132 {
133 if(pm != nullptr)
134 return pm->SetVerboseLevel();
135 else
136 return nullptr;
137 }

References G4PersistencyManagerT< T >::pm, and G4PersistencyManager::SetVerboseLevel().

◆ Store() [1/3]

G4bool G4PersistencyManager::Store ( const G4Event evt)
virtualinherited

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 //
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
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 {
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:156
G4DCofThisEvent * GetDCofThisEvent() const
Definition: G4Event.hh:158
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
const G4double hc
[MeV*fm]

References G4VTransactionManager::Abort(), G4VTransactionManager::Commit(), G4PersistencyCenter::CurrentStoreMode(), G4PersistencyCenter::CurrentWriteFile(), G4PersistencyManager::DigitIO(), G4PersistencyManager::EventIO(), G4PersistencyManager::f_is_initialized, G4PersistencyManager::f_pc, geant4_check_module_cycles::file, G4cerr, G4cout, G4endl, G4Event::GetDCofThisEvent(), G4Event::GetEventID(), G4Event::GetHCofThisEvent(), G4INCL::PhysicalConstants::hc, G4PersistencyManager::HitIO(), G4PersistencyManager::Initialize(), kOff, kOn, G4PersistencyManager::m_verbose, G4PersistencyManager::MCTruthIO(), G4VPDigitIO::Store(), G4VPEventIO::Store(), G4VPHitIO::Store(), G4VMCTruthIO::Store(), and G4PersistencyManager::TransactionManager().

◆ Store() [2/3]

G4bool G4PersistencyManager::Store ( const G4Run )
inlinevirtualinherited

Implements G4VPersistencyManager.

Definition at line 162 of file G4PersistencyManager.hh.

162{ return false; }

◆ Store() [3/3]

G4bool G4PersistencyManager::Store ( const G4VPhysicalVolume )
inlinevirtualinherited

Implements G4VPersistencyManager.

Definition at line 168 of file G4PersistencyManager.hh.

168{ return false; }

◆ TransactionManager()

template<class T >
G4VTransactionManager * G4PersistencyManagerT< T >::TransactionManager ( )
inlinevirtual

Reimplemented from G4PersistencyManager.

Definition at line 119 of file G4PersistencyManagerT.hh.

120 {
121 if(pm != nullptr)
122 return pm->TransactionManager();
123 else
124 return nullptr;
125 }

References G4PersistencyManagerT< T >::pm, and G4PersistencyManager::TransactionManager().

Field Documentation

◆ f_is_initialized

G4bool G4PersistencyManager::f_is_initialized = false
privateinherited

◆ f_pc

G4PersistencyCenter* G4PersistencyManager::f_pc = nullptr
protectedinherited

◆ fPersistencyManager

G4ThreadLocal G4VPersistencyManager * G4VPersistencyManager::fPersistencyManager = nullptr
staticprivateinherited

◆ m_verbose

G4int G4PersistencyManager::m_verbose = 0
protectedinherited

◆ nameMgr

G4String G4PersistencyManager::nameMgr
privateinherited

◆ pm

template<class T >
G4PersistencyManager* G4PersistencyManagerT< T >::pm = nullptr
private

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