42G4PersistencyCenter::G4PersistencyCenter()
45 f_wrObj[1] =
"MCTruth";
47 f_wrObj[3] =
"Digits";
50 f_rdObj[1] =
"HitsBG";
52 for(
auto itr = f_wrObj.cbegin(); itr != f_wrObj.cend(); ++itr)
54 f_writeFileName[(*itr).second] =
"G4defaultOutput";
57 for(
auto itr = f_rdObj.cbegin(); itr != f_rdObj.cend(); ++itr)
59 f_readFileName[(*itr).second] =
"G4defaultInput";
63 f_writeFileMode[
"MCTruth"] =
kOn;
64 f_writeFileMode[
"Hits"] =
kOn;
65 f_writeFileMode[
"Digits"] =
kOff;
67 f_readFileMode[
"Hits"] =
false;
68 f_readFileMode[
"HitsBG"] =
false;
75G4PersistencyCenter::~G4PersistencyCenter()
77 delete f_theMessenger;
78 delete f_currentManager;
84 if(f_thePointer ==
nullptr)
94 if(f_currentManager !=
nullptr)
95 delete f_currentManager;
99 if(systemName ==
"ROOT")
101 G4cout <<
" G4PersistencyCenter: \"ROOT\" Persistency Package is selected."
111 else if(systemName ==
"ODBMS")
113 G4cout <<
" G4PersistencyCenter: \"ODBMS\" package is selected." <<
G4endl;
124 G4cout <<
" G4PersistencyCenter: Default is selected." <<
G4endl;
130 f_currentManager = pm->
Create();
131 if(f_currentManager !=
nullptr)
133 f_currentSystemName = systemName;
162 if((*(f_writeFileName.find(objName))).second !=
"")
164 f_writeFileMode[objName] = mode;
168 G4cerr <<
"!! unknown object type " << objName <<
" for output." <<
G4endl;
175 if((*(f_readFileName.find(objName))).second !=
"")
177 f_readFileMode[objName] = mode;
181 G4cerr <<
"!! unknown object type " << objName <<
" for input." <<
G4endl;
188 if((*(f_writeFileName.find(objName))).second !=
"")
190 return f_writeFileMode[objName];
201 if((*(f_readFileName.find(objName))).second !=
"")
203 return f_readFileMode[objName];
215 if((*(f_writeFileName.find(objName))).second !=
"")
217 f_writeFileName[objName] = writeFileName;
221 G4cerr <<
"!! unknown object type " << objName <<
" for output." <<
G4endl;
234 f_readFileName[objName] = readFileName;
238 G4cerr <<
"!! File \"" << objName <<
"\" does not exist." <<
G4endl;
248 if((*(f_writeFileName.find(objName))).second !=
"")
250 return f_writeFileName[objName];
261 if((*(f_readFileName.find(objName))).second !=
"")
263 return f_readFileName[objName];
274 for(
auto itr = f_readFileName.cbegin(); itr != f_readFileName.cend(); ++itr)
276 if(file == (*itr).second)
279 for(
auto itr = f_writeFileName.cbegin(); itr != f_writeFileName.cend(); ++itr)
281 if(file == (*itr).second)
300 G4cerr <<
"Error! -- HCIO assignment failed for detector " << detName
301 <<
", collection " << colName <<
G4endl;
325 G4cerr <<
"Error! -- DCIO assignment failed for detector " << detName
326 <<
", collection " << colName <<
G4endl;
346 G4cout <<
"Output object types and file names:" <<
G4endl;
347 for(
auto itr = f_wrObj.cbegin(); itr != f_wrObj.cend(); ++itr)
349 name = (*itr).second;
351 if(name !=
"HepMC" && name !=
"MCTruth")
353 G4cout <<
" Object: " << PadString(name, 9);
359 else if(mode ==
kOff)
375 G4cout <<
"Input object types and file names:" <<
G4endl;
376 for(
auto itr = f_rdObj.cbegin(); itr != f_rdObj.cend(); ++itr)
378 name = (*itr).second;
380 if(name !=
"HepMC" && name !=
"MCTruth")
382 G4cout <<
" Object: " << PadString(name, 9);
409 G4cout <<
"Hit IO Manager catalog is not registered." <<
G4endl;
422 G4cout <<
"Digit IO Manager catalog is not registered." <<
G4endl;
430 f_currentManager = pm;
431 f_currentSystemName = name;
438 if(f_theCatalog.find(nam) != f_theCatalog.cend())
439 return f_theCatalog[nam];
446 f_theCatalog[pm->
GetName()] = pm;
452 if(f_currentManager !=
nullptr)
453 delete f_currentManager;
454 f_currentManager =
nullptr;
461 if(f_currentManager !=
nullptr)
469 if(name.length() > width)
471 return name.substr(0, width - 1) +
"#";
476 for(
unsigned int i = 0; i < width -
name.length(); ++i)
G4GLOB_DLL std::ostream G4cerr
G4GLOB_DLL std::ostream G4cout
G4VDCIOentry * GetEntry(const G4String &name)
G4String CurrentDCIOmanager()
static G4DCIOcatalog * GetDCIOcatalog()
G4bool FileExists(const G4String &file)
G4VHCIOentry * GetEntry(const G4String &name)
static G4HCIOcatalog * GetHCIOcatalog()
G4String CurrentHCIOmanager()
G4String CurrentObject(const G4String &file)
void DeletePersistencyManager()
G4String CurrentDCIOmanager()
G4bool SetWriteFile(const G4String &objName, const G4String &writeFileName)
G4bool CurrentRetrieveMode(const G4String &objName)
void SetRetrieveMode(const G4String &objName, G4bool mode)
void AddDCIOmanager(const G4String &detName)
static G4PersistencyCenter * GetPersistencyCenter()
G4bool SetReadFile(const G4String &objName, const G4String &readFileName)
void SetStoreMode(const G4String &objName, StoreMode mode)
void SetPersistencyManager(G4PersistencyManager *pm, const G4String &name)
G4String CurrentReadFile(const G4String &objName)
G4String CurrentHCIOmanager()
G4PersistencyManager * GetPersistencyManager(const G4String &nam)
void AddHCIOmanager(const G4String &detName, const G4String &colName)
void SetVerboseLevel(G4int v)
StoreMode CurrentStoreMode(const G4String &objName)
G4String CurrentHepMCObjyReaderFile()
void RegisterPersistencyManager(G4PersistencyManager *pm)
void SetHepMCObjyReaderFile(const G4String &file)
const G4String & CurrentSystem()
G4String CurrentWriteFile(const G4String &objName)
void SelectSystem(const G4String &systemName)
virtual G4PersistencyManager * Create()
const G4String & GetName()
void SetVerboseLevel(G4int v)
std::size_t first(char) const
virtual void CreateDCIOmanager(const G4String &, const G4String &)
virtual void CreateHCIOmanager(const G4String &, const G4String &)
const char * name(G4int ptype)