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

#include <G4PersistencyCenter.hh>

Public Member Functions

void SelectSystem (const G4String &systemName)
 
const G4StringCurrentSystem ()
 
void SetHepMCObjyReaderFile (const G4String &file)
 
G4String CurrentHepMCObjyReaderFile ()
 
void SetStoreMode (const G4String &objName, StoreMode mode)
 
void SetRetrieveMode (const G4String &objName, G4bool mode)
 
StoreMode CurrentStoreMode (const G4String &objName)
 
G4bool CurrentRetrieveMode (const G4String &objName)
 
G4bool SetWriteFile (const G4String &objName, const G4String &writeFileName)
 
G4bool SetReadFile (const G4String &objName, const G4String &readFileName)
 
G4String CurrentWriteFile (const G4String &objName)
 
G4String CurrentReadFile (const G4String &objName)
 
G4String CurrentObject (const G4String &file)
 
void AddHCIOmanager (const G4String &detName, const G4String &colName)
 
G4String CurrentHCIOmanager ()
 
void AddDCIOmanager (const G4String &detName)
 
G4String CurrentDCIOmanager ()
 
void PrintAll ()
 
G4PersistencyManagerCurrentPersistencyManager ()
 
void SetPersistencyManager (G4PersistencyManager *pm, const G4String &name)
 
G4PersistencyManagerGetPersistencyManager (const G4String &nam)
 
void RegisterPersistencyManager (G4PersistencyManager *pm)
 
void DeletePersistencyManager ()
 
void SetVerboseLevel (G4int v)
 
G4int VerboseLevel ()
 

Static Public Member Functions

static G4PersistencyCenterGetPersistencyCenter ()
 

Detailed Description

Definition at line 66 of file G4PersistencyCenter.hh.

Member Function Documentation

◆ AddDCIOmanager()

void G4PersistencyCenter::AddDCIOmanager ( const G4String & detName)

Definition at line 313 of file G4PersistencyCenter.cc.

314{
316
317 G4String colName = "";
318 G4VDCIOentry* ioe = ioc->GetEntry(detName);
319 if(ioe != nullptr)
320 {
321 ioe->CreateDCIOmanager(detName, colName);
322 }
323 else
324 {
325 G4cerr << "Error! -- DCIO assignment failed for detector " << detName
326 << ", collection " << colName << G4endl;
327 }
328}
G4GLOB_DLL std::ostream G4cerr
#define G4endl
Definition G4ios.hh:67
G4VDCIOentry * GetEntry(const G4String &name)
static G4DCIOcatalog * GetDCIOcatalog()
virtual void CreateDCIOmanager(const G4String &, const G4String &)

◆ AddHCIOmanager()

void G4PersistencyCenter::AddHCIOmanager ( const G4String & detName,
const G4String & colName )

Definition at line 288 of file G4PersistencyCenter.cc.

290{
292
293 G4VHCIOentry* ioe = ioc->GetEntry(detName);
294 if(ioe != nullptr)
295 {
296 ioe->CreateHCIOmanager(detName, colName);
297 }
298 else
299 {
300 G4cerr << "Error! -- HCIO assignment failed for detector " << detName
301 << ", collection " << colName << G4endl;
302 }
303}
G4VHCIOentry * GetEntry(const G4String &name)
static G4HCIOcatalog * GetHCIOcatalog()
virtual void CreateHCIOmanager(const G4String &, const G4String &)

◆ CurrentDCIOmanager()

G4String G4PersistencyCenter::CurrentDCIOmanager ( )

Definition at line 331 of file G4PersistencyCenter.cc.

332{
334 return ioc->CurrentDCIOmanager();
335}
G4String CurrentDCIOmanager()

◆ CurrentHCIOmanager()

G4String G4PersistencyCenter::CurrentHCIOmanager ( )

Definition at line 306 of file G4PersistencyCenter.cc.

307{
309 return ioc->CurrentHCIOmanager();
310}
G4String CurrentHCIOmanager()

◆ CurrentHepMCObjyReaderFile()

G4String G4PersistencyCenter::CurrentHepMCObjyReaderFile ( )

Definition at line 147 of file G4PersistencyCenter.cc.

148{
149 if(CurrentRetrieveMode("HepMC"))
150 {
151 return CurrentReadFile("HepMC");
152 }
153 else
154 {
155 return "";
156 }
157}
G4bool CurrentRetrieveMode(const G4String &objName)
G4String CurrentReadFile(const G4String &objName)

◆ CurrentObject()

G4String G4PersistencyCenter::CurrentObject ( const G4String & file)

Definition at line 272 of file G4PersistencyCenter.cc.

273{
274 for(auto itr = f_readFileName.cbegin(); itr != f_readFileName.cend(); ++itr)
275 {
276 if(file == (*itr).second)
277 return (*itr).first;
278 }
279 for(auto itr = f_writeFileName.cbegin(); itr != f_writeFileName.cend(); ++itr)
280 {
281 if(file == (*itr).second)
282 return (*itr).first;
283 }
284 return "?????";
285}

◆ CurrentPersistencyManager()

G4PersistencyManager * G4PersistencyCenter::CurrentPersistencyManager ( )
inline

Definition at line 127 of file G4PersistencyCenter.hh.

128 {
129 return f_currentManager;
130 }

Referenced by G4PersistencyManager::GetPersistencyManager().

◆ CurrentReadFile()

G4String G4PersistencyCenter::CurrentReadFile ( const G4String & objName)

Definition at line 259 of file G4PersistencyCenter.cc.

260{
261 if((*(f_readFileName.find(objName))).second != "")
262 {
263 return f_readFileName[objName];
264 }
265 else
266 {
267 return "?????";
268 }
269}

Referenced by CurrentHepMCObjyReaderFile(), PrintAll(), and G4PersistencyManager::Retrieve().

◆ CurrentRetrieveMode()

G4bool G4PersistencyCenter::CurrentRetrieveMode ( const G4String & objName)

Definition at line 199 of file G4PersistencyCenter.cc.

200{
201 if((*(f_readFileName.find(objName))).second != "")
202 {
203 return f_readFileMode[objName];
204 }
205 else
206 {
207 return false;
208 }
209}

Referenced by CurrentHepMCObjyReaderFile(), PrintAll(), and G4PersistencyManager::Retrieve().

◆ CurrentStoreMode()

StoreMode G4PersistencyCenter::CurrentStoreMode ( const G4String & objName)

Definition at line 186 of file G4PersistencyCenter.cc.

187{
188 if((*(f_writeFileName.find(objName))).second != "")
189 {
190 return f_writeFileMode[objName];
191 }
192 else
193 {
194 return kOff;
195 }
196}

Referenced by PrintAll(), and G4PersistencyManager::Store().

◆ CurrentSystem()

const G4String & G4PersistencyCenter::CurrentSystem ( )
inline

Definition at line 76 of file G4PersistencyCenter.hh.

76{ return f_currentSystemName; }

Referenced by PrintAll().

◆ CurrentWriteFile()

G4String G4PersistencyCenter::CurrentWriteFile ( const G4String & objName)

Definition at line 246 of file G4PersistencyCenter.cc.

247{
248 if((*(f_writeFileName.find(objName))).second != "")
249 {
250 return f_writeFileName[objName];
251 }
252 else
253 {
254 return "?????";
255 }
256}

Referenced by PrintAll(), and G4PersistencyManager::Store().

◆ DeletePersistencyManager()

void G4PersistencyCenter::DeletePersistencyManager ( )

Definition at line 450 of file G4PersistencyCenter.cc.

451{
452 if(f_currentManager != nullptr)
453 delete f_currentManager;
454 f_currentManager = nullptr;
455}

◆ GetPersistencyCenter()

G4PersistencyCenter * G4PersistencyCenter::GetPersistencyCenter ( )
static

◆ GetPersistencyManager()

G4PersistencyManager * G4PersistencyCenter::GetPersistencyManager ( const G4String & nam)

Definition at line 436 of file G4PersistencyCenter.cc.

437{
438 if(f_theCatalog.find(nam) != f_theCatalog.cend())
439 return f_theCatalog[nam];
440 return nullptr;
441}

Referenced by SelectSystem().

◆ PrintAll()

void G4PersistencyCenter::PrintAll ( )

Definition at line 338 of file G4PersistencyCenter.cc.

339{
340 G4cout << "Persistency Package: " << CurrentSystem() << G4endl;
341 G4cout << G4endl;
342
343 G4String name, file;
344 StoreMode mode;
345
346 G4cout << "Output object types and file names:" << G4endl;
347 for(auto itr = f_wrObj.cbegin(); itr != f_wrObj.cend(); ++itr)
348 {
349 name = (*itr).second;
350 // disabled HepMC and MCTruth for now
351 if(name != "HepMC" && name != "MCTruth")
352 {
353 G4cout << " Object: " << PadString(name, 9);
354 mode = CurrentStoreMode(name);
355 if(mode == kOn)
356 {
357 G4cout << " <on> ";
358 }
359 else if(mode == kOff)
360 {
361 G4cout << " <off> ";
362 }
363 else if(mode == kRecycle)
364 {
365 G4cout << "<recycle>";
366 }
367 file = CurrentWriteFile(name);
368 if(file == "")
369 file = " <N/A>";
370 G4cout << " File: " << file << G4endl;
371 }
372 }
373 G4cout << G4endl;
374
375 G4cout << "Input object types and file names:" << G4endl;
376 for(auto itr = f_rdObj.cbegin(); itr != f_rdObj.cend(); ++itr)
377 {
378 name = (*itr).second;
379 // disabled HepMC and MCTruth for now
380 if(name != "HepMC" && name != "MCTruth")
381 {
382 G4cout << " Object: " << PadString(name, 9);
383 if(CurrentRetrieveMode(name))
384 {
385 G4cout << " <on> ";
386 }
387 else
388 {
389 G4cout << " <off> ";
390 }
391 file = CurrentReadFile(name);
392 if(file == "")
393 file = " <N/A>";
394 G4cout << " File: " << CurrentReadFile(name) << G4endl;
395 }
396 }
397 G4cout << G4endl;
398
400 if(hioc != nullptr)
401 {
402 G4cout << "Hit IO Managers:" << G4endl;
403 hioc->PrintEntries();
404 hioc->PrintHCIOmanager();
405 G4cout << G4endl;
406 }
407 else
408 {
409 G4cout << "Hit IO Manager catalog is not registered." << G4endl;
410 }
411
413 if(dioc != nullptr)
414 {
415 G4cout << "Digit IO Managers:" << G4endl;
416 dioc->PrintEntries();
417 dioc->PrintDCIOmanager();
418 G4cout << G4endl;
419 }
420 else
421 {
422 G4cout << "Digit IO Manager catalog is not registered." << G4endl;
423 }
424}
G4GLOB_DLL std::ostream G4cout
void PrintDCIOmanager()
void PrintHCIOmanager()
StoreMode CurrentStoreMode(const G4String &objName)
const G4String & CurrentSystem()
G4String CurrentWriteFile(const G4String &objName)
const char * name(G4int ptype)

◆ RegisterPersistencyManager()

void G4PersistencyCenter::RegisterPersistencyManager ( G4PersistencyManager * pm)

Definition at line 444 of file G4PersistencyCenter.cc.

445{
446 f_theCatalog[pm->GetName()] = pm;
447}

Referenced by G4PersistencyManagerT< T >::G4PersistencyManagerT().

◆ SelectSystem()

void G4PersistencyCenter::SelectSystem ( const G4String & systemName)

Definition at line 90 of file G4PersistencyCenter.cc.

91{
92 G4int st = 0;
93
94 if(f_currentManager != nullptr)
95 delete f_currentManager;
96
97 G4PersistencyManager* pm = nullptr;
98
99 if(systemName == "ROOT")
100 {
101 G4cout << " G4PersistencyCenter: \"ROOT\" Persistency Package is selected."
102 << G4endl;
103 // G4UImanager *man=G4UImanager::GetUIpointer();
104 // std::string libs="Cint:Core:Tree:Rint:Matrix:Physics:fadsROOT";
105 // st = man->ApplyCommand("/load "+libs);
106 if(st == 0)
107 {
108 pm = GetPersistencyManager("ROOT");
109 }
110 }
111 else if(systemName == "ODBMS")
112 {
113 G4cout << " G4PersistencyCenter: \"ODBMS\" package is selected." << G4endl;
114 // G4UImanager *man=G4UImanager::GetUIpointer();
115 // std::string libs="fadsODBMS";
116 // st = man->ApplyCommand("/load "+libs);
117 if(st == 0)
118 {
119 pm = GetPersistencyManager("ODBMS");
120 }
121 }
122 else
123 {
124 G4cout << " G4PersistencyCenter: Default is selected." << G4endl;
125 pm = new G4PersistencyManager(this, "Default");
126 }
127
128 if(st == 0)
129 {
130 f_currentManager = pm->Create();
131 if(f_currentManager != nullptr)
132 f_currentManager->SetVerboseLevel(m_verbose);
133 f_currentSystemName = systemName;
134 }
135}
int G4int
Definition G4Types.hh:85
G4PersistencyManager * GetPersistencyManager(const G4String &nam)
virtual G4PersistencyManager * Create()

◆ SetHepMCObjyReaderFile()

void G4PersistencyCenter::SetHepMCObjyReaderFile ( const G4String & file)

Definition at line 138 of file G4PersistencyCenter.cc.

139{
140 if(SetReadFile("HepMC", file))
141 {
142 SetRetrieveMode("HepMC", true);
143 }
144}
void SetRetrieveMode(const G4String &objName, G4bool mode)
G4bool SetReadFile(const G4String &objName, const G4String &readFileName)

◆ SetPersistencyManager()

void G4PersistencyCenter::SetPersistencyManager ( G4PersistencyManager * pm,
const G4String & name )

Definition at line 427 of file G4PersistencyCenter.cc.

429{
430 f_currentManager = pm;
431 f_currentSystemName = name;
432}

◆ SetReadFile()

G4bool G4PersistencyCenter::SetReadFile ( const G4String & objName,
const G4String & readFileName )

Definition at line 228 of file G4PersistencyCenter.cc.

230{
231#ifndef WIN32
232 if(f_ut.FileExists(readFileName))
233 {
234 f_readFileName[objName] = readFileName;
235 }
236 else
237 {
238 G4cerr << "!! File \"" << objName << "\" does not exist." << G4endl;
239 return false;
240 }
241#endif
242 return true;
243}
G4bool FileExists(const G4String &file)

Referenced by SetHepMCObjyReaderFile().

◆ SetRetrieveMode()

void G4PersistencyCenter::SetRetrieveMode ( const G4String & objName,
G4bool mode )

Definition at line 173 of file G4PersistencyCenter.cc.

174{
175 if((*(f_readFileName.find(objName))).second != "")
176 {
177 f_readFileMode[objName] = mode;
178 }
179 else
180 {
181 G4cerr << "!! unknown object type " << objName << " for input." << G4endl;
182 }
183}

Referenced by SetHepMCObjyReaderFile().

◆ SetStoreMode()

void G4PersistencyCenter::SetStoreMode ( const G4String & objName,
StoreMode mode )

Definition at line 160 of file G4PersistencyCenter.cc.

161{
162 if((*(f_writeFileName.find(objName))).second != "")
163 {
164 f_writeFileMode[objName] = mode;
165 }
166 else
167 {
168 G4cerr << "!! unknown object type " << objName << " for output." << G4endl;
169 }
170}

◆ SetVerboseLevel()

void G4PersistencyCenter::SetVerboseLevel ( G4int v)

Definition at line 458 of file G4PersistencyCenter.cc.

459{
460 m_verbose = v;
461 if(f_currentManager != nullptr)
462 f_currentManager->SetVerboseLevel(m_verbose);
463}

◆ SetWriteFile()

G4bool G4PersistencyCenter::SetWriteFile ( const G4String & objName,
const G4String & writeFileName )

Definition at line 212 of file G4PersistencyCenter.cc.

214{
215 if((*(f_writeFileName.find(objName))).second != "")
216 {
217 f_writeFileName[objName] = writeFileName;
218 }
219 else
220 {
221 G4cerr << "!! unknown object type " << objName << " for output." << G4endl;
222 return false;
223 }
224 return true;
225}

◆ VerboseLevel()

G4int G4PersistencyCenter::VerboseLevel ( )
inline

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