45 G4PersistencyCenter::G4PersistencyCenter()
49 f_wrObj[1] =
"MCTruth";
51 f_wrObj[3] =
"Digits";
54 f_rdObj[1] =
"HitsBG";
58 for ( itr = f_wrObj.begin(); itr != f_wrObj.end(); itr++ ) {
59 f_writeFileName[(*itr).second] =
"G4defaultOutput";
62 for ( itr = f_rdObj.begin(); itr != f_rdObj.end(); itr++ ) {
63 f_readFileName[(*itr).second] =
"G4defaultInput";
67 f_writeFileMode[
"MCTruth"] =
kOn;
68 f_writeFileMode[
"Hits"] =
kOn;
69 f_writeFileMode[
"Digits"] =
kOff;
71 f_readFileMode[
"Hits"] =
false;
72 f_readFileMode[
"HitsBG"] =
false;
79 G4PersistencyCenter::~G4PersistencyCenter()
81 delete f_theMessenger;
82 delete f_currentManager;
98 if (f_currentManager!=0)
delete f_currentManager;
102 if (systemName==
"ROOT")
104 G4cout<<
" G4PersistencyCenter: \"ROOT\" Persistency Package is selected."
113 else if (systemName==
"ODBMS")
115 G4cout<<
" G4PersistencyCenter: \"ODBMS\" package is selected."<<
G4endl;
125 G4cout<<
" G4PersistencyCenter: Default is selected."<<
G4endl;
130 f_currentManager = pm->
Create();
132 f_currentSystemName = systemName;
157 if ( (*(f_writeFileName.find(objName))).second !=
"" ) {
158 f_writeFileMode[objName] = mode;
160 G4cerr <<
"!! unknown object type " << objName <<
" for output."
168 if ( (*(f_readFileName.find(objName))).second !=
"" ) {
169 f_readFileMode[objName] = mode;
171 G4cerr <<
"!! unknown object type " << objName <<
" for input."
179 if ( (*(f_writeFileName.find(objName))).second !=
"" ) {
180 return f_writeFileMode[objName];
189 if ( (*(f_readFileName.find(objName))).second !=
"" ) {
190 return f_readFileMode[objName];
199 if ( (*(f_writeFileName.find(objName))).second !=
"" ) {
200 f_writeFileName[objName] = writeFileName;
202 G4cerr <<
"!! unknown object type " << objName <<
" for output."
215 f_readFileName[objName] = readFileName;
219 G4cerr <<
"!! File \"" << objName <<
"\" does not exist."
230 if ( (*(f_writeFileName.find(objName))).second !=
"" ) {
231 return f_writeFileName[objName];
240 if ( (*(f_readFileName.find(objName))).second !=
"" ) {
241 return f_readFileName[objName];
250 FileMap::iterator itr;
251 for ( itr = f_readFileName.begin(); itr != f_readFileName.end(); itr++ ) {
252 if ( file == (*itr).second )
return (*itr).first;
254 for ( itr = f_writeFileName.begin(); itr != f_writeFileName.end(); itr++ ) {
255 if ( file == (*itr).second )
return (*itr).first;
269 G4cerr <<
"Error! -- HCIO assignment failed for detector " << detName
270 <<
", collection " << colName <<
G4endl;
286 std::string colName =
"";
291 G4cerr <<
"Error! -- DCIO assignment failed for detector " << detName
292 <<
", collection " << colName <<
G4endl;
309 ObjMap::iterator itr;
314 G4cout <<
"Output object types and file names:" <<
G4endl;
315 for ( itr = f_wrObj.begin(); itr != f_wrObj.end(); itr++ ) {
316 name = (*itr).second;
318 if ( name !=
"HepMC" && name !=
"MCTruth" ) {
319 G4cout <<
" Object: " << PadString(name, 9);
323 }
else if ( mode ==
kOff ) {
329 if ( file ==
"" ) file =
" <N/A>";
335 G4cout <<
"Input object types and file names:" <<
G4endl;
336 for ( itr = f_rdObj.begin(); itr != f_rdObj.end(); itr++ ) {
337 name = (*itr).second;
339 if ( name !=
"HepMC" && name !=
"MCTruth" ) {
340 G4cout <<
" Object: " << PadString(name, 9);
347 if ( file ==
"" ) file =
" <N/A>";
360 G4cout <<
"Hit IO Manager catalog is not registered." <<
G4endl;
370 G4cout <<
"Digit IO Manager catalog is not registered." <<
G4endl;
379 f_currentSystemName=
name;
385 if (f_theCatalog.find(nam)!=f_theCatalog.end())
386 return f_theCatalog[nam];
393 f_theCatalog[pm->
GetName()]=pm;
399 if (f_currentManager!=0)
delete f_currentManager;
407 if ( f_currentManager != 0 ) f_currentManager->
SetVerboseLevel(m_verbose);
411 std::string G4PersistencyCenter::PadString(std::string
name,
unsigned int width)
413 if ( name.length() >
width ) {
414 return name.substr(0,width-1) +
"#";
416 std::string wname =
name;
417 for (
unsigned int i=0; i < width-name.length(); i++) wname = wname +
" ";
void SetRetrieveMode(std::string objName, G4bool mode)
std::string CurrentObject(std::string file)
void AddDCIOmanager(std::string detName)
std::string CurrentReadFile(std::string objName)
G4VHCIOentry * GetEntry(std::string name)
std::string CurrentHCIOmanager()
void AddHCIOmanager(std::string detName, std::string colName)
virtual void CreateDCIOmanager(std::string, std::string)
void DeletePersistencyManager()
static G4HCIOcatalog * GetHCIOcatalog()
void SelectSystem(std::string systemName)
void SetPersistencyManager(G4PersistencyManager *pm, std::string name)
StoreMode CurrentStoreMode(std::string objName)
void SetHepMCObjyReaderFile(std::string file)
std::string CurrentDCIOmanager()
virtual void CreateHCIOmanager(std::string, std::string)
std::string CurrentHCIOmanager()
G4GLOB_DLL std::ostream G4cout
G4VDCIOentry * GetEntry(std::string name)
G4bool FileExists(const std::string file)
static G4DCIOcatalog * GetDCIOcatalog()
G4bool CurrentRetrieveMode(std::string objName)
G4bool SetWriteFile(std::string objName, std::string writeFileName)
virtual G4PersistencyManager * Create()
void RegisterPersistencyManager(G4PersistencyManager *pm)
void SetStoreMode(std::string objName, StoreMode mode)
G4bool SetReadFile(std::string objName, std::string readFileName)
void SetVerboseLevel(int v)
const std::string CurrentSystem()
G4PersistencyManager * GetPersistencyManager(std::string nam)
std::string CurrentHepMCObjyReaderFile()
std::string CurrentDCIOmanager()
std::string CurrentWriteFile(std::string objName)
static G4PersistencyCenter * GetPersistencyCenter()
G4GLOB_DLL std::ostream G4cerr
void SetVerboseLevel(int v)