Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Protected Member Functions | Protected Attributes | Friends
G4PersistencyManager Class Reference

#include <G4PersistencyManager.hh>

Inheritance diagram for G4PersistencyManager:
G4VPersistencyManager G4PersistencyManagerT< T >

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.

References f_pc, m_verbose, and G4PersistencyCenter::VerboseLevel().

39  : f_pc(ptc), nameMgr(n), f_is_initialized(false)
40 {
42 }
const G4int n
G4PersistencyCenter * f_pc
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.

Referenced by G4PersistencyCenter::SelectSystem().

127 {return 0;};
virtual G4VPDigitIO* G4PersistencyManager::DigitIO ( )
inlinevirtual

Reimplemented in G4PersistencyManagerT< T >.

Definition at line 141 of file G4PersistencyManager.hh.

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

141 { return 0; };
virtual G4VPEventIO* G4PersistencyManager::EventIO ( )
inlinevirtual

Reimplemented in G4PersistencyManagerT< T >.

Definition at line 133 of file G4PersistencyManager.hh.

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

133 { return 0; };
std::string G4PersistencyManager::GetName ( void  )
inline

Definition at line 130 of file G4PersistencyManager.hh.

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

130 {return nameMgr;};
G4PersistencyManager * G4PersistencyManager::GetPersistencyManager ( )
staticprotected
virtual G4VPHitIO* G4PersistencyManager::HitIO ( )
inlinevirtual

Reimplemented in G4PersistencyManagerT< T >.

Definition at line 137 of file G4PersistencyManager.hh.

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

137 { return 0; };
virtual void G4PersistencyManager::Initialize ( )
inlinevirtual

Reimplemented in G4PersistencyManagerT< T >.

Definition at line 153 of file G4PersistencyManager.hh.

Referenced by Retrieve(), and Store().

153 {};
virtual G4VMCTruthIO* G4PersistencyManager::MCTruthIO ( )
inlinevirtual

Reimplemented in G4PersistencyManagerT< T >.

Definition at line 145 of file G4PersistencyManager.hh.

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

145 { return 0; };
G4bool G4PersistencyManager::Retrieve ( G4Event *&  evt)
virtual

Implements G4VPersistencyManager.

Definition at line 230 of file G4PersistencyManager.cc.

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

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:140
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()
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.

References DigitIO(), EventIO(), G4cout, G4endl, G4DCIOcatalog::GetDCIOcatalog(), G4DCIOcatalog::GetDCIOmanager(), G4HCIOcatalog::GetHCIOcatalog(), G4HCIOcatalog::GetHCIOmanager(), HitIO(), m_verbose, MCTruthIO(), G4DCIOcatalog::NumberOfDCIOmanager(), G4HCIOcatalog::NumberOfHCIOmanager(), G4VPEventIO::SetVerboseLevel(), G4VTransactionManager::SetVerboseLevel(), G4VMCTruthIO::SetVerboseLevel(), G4HCIOcatalog::SetVerboseLevel(), G4DCIOcatalog::SetVerboseLevel(), G4VPHitIO::SetVerboseLevel(), G4VPDigitIO::SetVerboseLevel(), G4VPHitsCollectionIO::SetVerboseLevel(), G4VPDigitsCollectionIO::SetVerboseLevel(), TransactionManager(), and test::v.

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

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()
G4bool G4PersistencyManager::Store ( const G4Event evt)
virtual

Implements G4VPersistencyManager.

Definition at line 88 of file G4PersistencyManager.cc.

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

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:140
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:174
G4DCofThisEvent * GetDCofThisEvent() const
Definition: G4Event.hh:176
std::string CurrentWriteFile(std::string objName)
G4GLOB_DLL std::ostream G4cerr
virtual G4VTransactionManager * TransactionManager()
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.

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

149 { return 0; };

Friends And Related Function Documentation

friend class G4PersistencyCenter
friend

Definition at line 117 of file G4PersistencyManager.hh.

Field Documentation

G4PersistencyCenter* G4PersistencyManager::f_pc
protected
int G4PersistencyManager::m_verbose
protected

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