Geant4  10.02.p03
G4PersistencyCenter Class Reference

#include <G4PersistencyCenter.hh>

Collaboration diagram for G4PersistencyCenter:

Public Member Functions

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

Static Public Member Functions

static G4PersistencyCenterGetPersistencyCenter ()
 

Private Member Functions

 G4PersistencyCenter ()
 
 ~G4PersistencyCenter ()
 
std::string PadString (std::string name, unsigned int width)
 

Private Attributes

G4PersistencyCenterMessengerf_theMessenger
 
G4PersistencyManagerf_currentManager
 
std::string f_currentSystemName
 
PMap f_theCatalog
 
ObjMap f_wrObj
 
ObjMap f_rdObj
 
FileMap f_writeFileName
 
FileMap f_readFileName
 
StoreMap f_writeFileMode
 
BoolMap f_readFileMode
 
G4int m_verbose
 
G4FileUtilities f_ut
 

Static Private Attributes

static G4ThreadLocal G4PersistencyCenterf_thePointer = 0
 

Detailed Description

Definition at line 63 of file G4PersistencyCenter.hh.

Constructor & Destructor Documentation

◆ G4PersistencyCenter()

G4PersistencyCenter::G4PersistencyCenter ( )
private

Definition at line 45 of file G4PersistencyCenter.cc.

46  : m_verbose(0)
47 {
48  f_wrObj[0] = "HepMC";
49  f_wrObj[1] = "MCTruth";
50  f_wrObj[2] = "Hits";
51  f_wrObj[3] = "Digits";
52 
53  f_rdObj[0] = "Hits";
54  f_rdObj[1] = "HitsBG";
55 
56  ObjMap::iterator itr;
57 
58  for ( itr = f_wrObj.begin(); itr != f_wrObj.end(); itr++ ) {
59  f_writeFileName[(*itr).second] = "G4defaultOutput";
60  }
61 
62  for ( itr = f_rdObj.begin(); itr != f_rdObj.end(); itr++ ) {
63  f_readFileName[(*itr).second] = "G4defaultInput";
64  }
65 
66  f_writeFileMode["HepMC"] = kRecycle;
67  f_writeFileMode["MCTruth"] = kOn;
68  f_writeFileMode["Hits"] = kOn;
69  f_writeFileMode["Digits"] = kOff;
70 
71  f_readFileMode["Hits"] = false;
72  f_readFileMode["HitsBG"] = false;
73 
75  f_currentManager = new G4PersistencyManager(this, "Default");
76 }
G4PersistencyManager * f_currentManager
G4PersistencyCenterMessenger * f_theMessenger
Here is the caller graph for this function:

◆ ~G4PersistencyCenter()

G4PersistencyCenter::~G4PersistencyCenter ( )
private

Definition at line 79 of file G4PersistencyCenter.cc.

80 {
81  delete f_theMessenger;
82  delete f_currentManager;
83 }
G4PersistencyManager * f_currentManager
G4PersistencyCenterMessenger * f_theMessenger
Here is the caller graph for this function:

Member Function Documentation

◆ AddDCIOmanager()

void G4PersistencyCenter::AddDCIOmanager ( std::string  detName)

Definition at line 282 of file G4PersistencyCenter.cc.

283 {
285 
286  std::string colName = "";
287  G4VDCIOentry* ioe = ioc->GetEntry(detName);
288  if ( ioe != 0 ) {
289  ioe->CreateDCIOmanager(detName, colName);
290  } else {
291  G4cerr << "Error! -- DCIO assignment failed for detector " << detName
292  << ", collection " << colName << G4endl;
293  }
294 }
virtual void CreateDCIOmanager(std::string, std::string)
Definition: G4VDCIOentry.hh:57
G4VDCIOentry * GetEntry(std::string name)
static G4DCIOcatalog * GetDCIOcatalog()
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr
Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddHCIOmanager()

void G4PersistencyCenter::AddHCIOmanager ( std::string  detName,
std::string  colName 
)

Definition at line 261 of file G4PersistencyCenter.cc.

262 {
264 
265  G4VHCIOentry* ioe = ioc->GetEntry(detName);
266  if ( ioe != 0 ) {
267  ioe->CreateHCIOmanager(detName, colName);
268  } else {
269  G4cerr << "Error! -- HCIO assignment failed for detector " << detName
270  << ", collection " << colName << G4endl;
271  }
272 }
G4VHCIOentry * GetEntry(std::string name)
static G4HCIOcatalog * GetHCIOcatalog()
virtual void CreateHCIOmanager(std::string, std::string)
Definition: G4VHCIOentry.hh:57
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CurrentDCIOmanager()

std::string G4PersistencyCenter::CurrentDCIOmanager ( )

Definition at line 297 of file G4PersistencyCenter.cc.

298 {
300  return ioc->CurrentDCIOmanager();
301 }
static G4DCIOcatalog * GetDCIOcatalog()
std::string CurrentDCIOmanager()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CurrentHCIOmanager()

std::string G4PersistencyCenter::CurrentHCIOmanager ( )

Definition at line 275 of file G4PersistencyCenter.cc.

276 {
278  return ioc->CurrentHCIOmanager();
279 }
std::string CurrentHCIOmanager()
static G4HCIOcatalog * GetHCIOcatalog()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CurrentHepMCObjyReaderFile()

std::string G4PersistencyCenter::CurrentHepMCObjyReaderFile ( )

Definition at line 145 of file G4PersistencyCenter.cc.

146 {
147  if ( CurrentRetrieveMode("HepMC") ) {
148  return CurrentReadFile("HepMC");
149  } else {
150  return "";
151  }
152 }
std::string CurrentReadFile(std::string objName)
G4bool CurrentRetrieveMode(std::string objName)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CurrentObject()

std::string G4PersistencyCenter::CurrentObject ( std::string  file)

Definition at line 248 of file G4PersistencyCenter.cc.

249 {
250  FileMap::iterator itr;
251  for ( itr = f_readFileName.begin(); itr != f_readFileName.end(); itr++ ) {
252  if ( file == (*itr).second ) return (*itr).first;
253  }
254  for ( itr = f_writeFileName.begin(); itr != f_writeFileName.end(); itr++ ) {
255  if ( file == (*itr).second ) return (*itr).first;
256  }
257  return "?????";
258 }
TFile * file
Here is the caller graph for this function:

◆ CurrentPersistencyManager()

G4PersistencyManager* G4PersistencyCenter::CurrentPersistencyManager ( )
inline

Definition at line 124 of file G4PersistencyCenter.hh.

124 { return f_currentManager; };
G4PersistencyManager * f_currentManager
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CurrentReadFile()

std::string G4PersistencyCenter::CurrentReadFile ( std::string  objName)

Definition at line 238 of file G4PersistencyCenter.cc.

239 {
240  if ( (*(f_readFileName.find(objName))).second != "" ) {
241  return f_readFileName[objName];
242  } else {
243  return "?????";
244  }
245 }
Here is the caller graph for this function:

◆ CurrentRetrieveMode()

G4bool G4PersistencyCenter::CurrentRetrieveMode ( std::string  objName)

Definition at line 187 of file G4PersistencyCenter.cc.

188 {
189  if ( (*(f_readFileName.find(objName))).second != "" ) {
190  return f_readFileMode[objName];
191  } else {
192  return false;
193  }
194 }
Here is the caller graph for this function:

◆ CurrentStoreMode()

StoreMode G4PersistencyCenter::CurrentStoreMode ( std::string  objName)

Definition at line 177 of file G4PersistencyCenter.cc.

178 {
179  if ( (*(f_writeFileName.find(objName))).second != "" ) {
180  return f_writeFileMode[objName];
181  } else {
182  return kOff;
183  }
184 }
Here is the caller graph for this function:

◆ CurrentSystem()

const std::string G4PersistencyCenter::CurrentSystem ( )
inline

Definition at line 73 of file G4PersistencyCenter.hh.

73 { return f_currentSystemName; };
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CurrentWriteFile()

std::string G4PersistencyCenter::CurrentWriteFile ( std::string  objName)

Definition at line 228 of file G4PersistencyCenter.cc.

229 {
230  if ( (*(f_writeFileName.find(objName))).second != "" ) {
231  return f_writeFileName[objName];
232  } else {
233  return "?????";
234  }
235 }
Here is the caller graph for this function:

◆ DeletePersistencyManager()

void G4PersistencyCenter::DeletePersistencyManager ( )

Definition at line 397 of file G4PersistencyCenter.cc.

398 {
399  if (f_currentManager!=0) delete f_currentManager;
401 }
G4PersistencyManager * f_currentManager
Here is the caller graph for this function:

◆ GetPersistencyCenter()

G4PersistencyCenter * G4PersistencyCenter::GetPersistencyCenter ( )
static

Definition at line 86 of file G4PersistencyCenter.cc.

87 {
89  return f_thePointer;
90 }
static G4ThreadLocal G4PersistencyCenter * f_thePointer
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetPersistencyManager()

G4PersistencyManager * G4PersistencyCenter::GetPersistencyManager ( std::string  nam)

Definition at line 383 of file G4PersistencyCenter.cc.

384 {
385  if (f_theCatalog.find(nam)!=f_theCatalog.end())
386  return f_theCatalog[nam];
387  return 0;
388 }
Here is the caller graph for this function:

◆ PadString()

std::string G4PersistencyCenter::PadString ( std::string  name,
unsigned int  width 
)
private

Definition at line 411 of file G4PersistencyCenter.cc.

412 {
413  if ( name.length() > width ) {
414  return name.substr(0,width-1) + "#";
415  } else {
416  std::string wname = name;
417  for ( unsigned int i=0; i < width-name.length(); i++) wname = wname + " ";
418  return wname;
419  }
420 }
G4String name
Definition: TRTMaterials.hh:40
#define width
Here is the caller graph for this function:

◆ PrintAll()

void G4PersistencyCenter::PrintAll ( void  )

Definition at line 304 of file G4PersistencyCenter.cc.

305 {
306  G4cout << "Persistency Package: " << CurrentSystem() << G4endl;
307  G4cout << G4endl;
308 
309  ObjMap::iterator itr;
310  std::string name;
311  std::string file;
312  StoreMode mode;
313 
314  G4cout << "Output object types and file names:" << G4endl;
315  for ( itr = f_wrObj.begin(); itr != f_wrObj.end(); itr++ ) {
316  name = (*itr).second;
317  // disabled HepMC and MCTruth for now
318  if ( name != "HepMC" && name != "MCTruth" ) {
319  G4cout << " Object: " << PadString(name, 9);
320  mode = CurrentStoreMode(name);
321  if ( mode == kOn ) {
322  G4cout << " <on> ";
323  } else if ( mode == kOff ) {
324  G4cout << " <off> ";
325  } else if ( mode == kRecycle ) {
326  G4cout << "<recycle>";
327  }
328  file = CurrentWriteFile(name);
329  if ( file == "" ) file = " <N/A>";
330  G4cout << " File: " << file << G4endl;
331  }
332  }
333  G4cout << G4endl;
334 
335  G4cout << "Input object types and file names:" << G4endl;
336  for ( itr = f_rdObj.begin(); itr != f_rdObj.end(); itr++ ) {
337  name = (*itr).second;
338  // disabled HepMC and MCTruth for now
339  if ( name != "HepMC" && name != "MCTruth" ) {
340  G4cout << " Object: " << PadString(name, 9);
341  if ( CurrentRetrieveMode(name) ) {
342  G4cout << " <on> ";
343  } else {
344  G4cout << " <off> ";
345  }
346  file = CurrentReadFile(name);
347  if ( file == "" ) file = " <N/A>";
348  G4cout << " File: " << CurrentReadFile(name) << G4endl;
349  }
350  }
351  G4cout << G4endl;
352 
354  if ( hioc != 0 ) {
355  G4cout << "Hit IO Managers:" << G4endl;
356  hioc->PrintEntries();
357  hioc->PrintHCIOmanager();
358  G4cout << G4endl;
359  } else {
360  G4cout << "Hit IO Manager catalog is not registered." << G4endl;
361  }
362 
364  if ( dioc != 0 ) {
365  G4cout << "Digit IO Managers:" << G4endl;
366  dioc->PrintEntries();
367  dioc->PrintDCIOmanager();
368  G4cout << G4endl;
369  } else {
370  G4cout << "Digit IO Manager catalog is not registered." << G4endl;
371  }
372 }
void PrintDCIOmanager()
std::string CurrentReadFile(std::string objName)
G4String name
Definition: TRTMaterials.hh:40
std::string PadString(std::string name, unsigned int width)
static G4HCIOcatalog * GetHCIOcatalog()
TFile * file
StoreMode CurrentStoreMode(std::string objName)
G4GLOB_DLL std::ostream G4cout
void PrintHCIOmanager()
static G4DCIOcatalog * GetDCIOcatalog()
G4bool CurrentRetrieveMode(std::string objName)
const std::string CurrentSystem()
#define G4endl
Definition: G4ios.hh:61
std::string CurrentWriteFile(std::string objName)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ RegisterPersistencyManager()

void G4PersistencyCenter::RegisterPersistencyManager ( G4PersistencyManager pm)

Definition at line 391 of file G4PersistencyCenter.cc.

392 {
393  f_theCatalog[pm->GetName()]=pm;
394 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SelectSystem()

void G4PersistencyCenter::SelectSystem ( std::string  systemName)

Definition at line 94 of file G4PersistencyCenter.cc.

95 {
96  G4int st = 0;
97 
98  if (f_currentManager!=0) delete f_currentManager;
99 
100  G4PersistencyManager* pm = 0;
101 
102  if (systemName=="ROOT")
103  {
104  G4cout<<" G4PersistencyCenter: \"ROOT\" Persistency Package is selected."
105  <<G4endl;
106  // G4UImanager *man=G4UImanager::GetUIpointer();
107  // std::string libs="Cint:Core:Tree:Rint:Matrix:Physics:fadsROOT";
108  // st = man->ApplyCommand("/load "+libs);
109  if ( st == 0 ) {
110  pm = GetPersistencyManager("ROOT");
111  }
112  }
113  else if (systemName=="ODBMS")
114  {
115  G4cout<<" G4PersistencyCenter: \"ODBMS\" package is selected."<<G4endl;
116  // G4UImanager *man=G4UImanager::GetUIpointer();
117  // std::string libs="fadsODBMS";
118  // st = man->ApplyCommand("/load "+libs);
119  if ( st == 0 ) {
120  pm = GetPersistencyManager("ODBMS");
121  }
122  }
123  else
124  {
125  G4cout<<" G4PersistencyCenter: Default is selected."<< G4endl;
126  pm = new G4PersistencyManager(this, "Default");
127  }
128 
129  if ( st == 0 ) {
130  f_currentManager = pm->Create();
132  f_currentSystemName = systemName;
133  }
134 }
G4PersistencyManager * f_currentManager
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
virtual G4PersistencyManager * Create()
#define G4endl
Definition: G4ios.hh:61
G4PersistencyManager * GetPersistencyManager(std::string nam)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetHepMCObjyReaderFile()

void G4PersistencyCenter::SetHepMCObjyReaderFile ( std::string  file)

Definition at line 137 of file G4PersistencyCenter.cc.

138 {
139  if ( SetReadFile("HepMC", file) ) {
140  SetRetrieveMode("HepMC", true);
141  }
142 }
void SetRetrieveMode(std::string objName, G4bool mode)
TFile * file
G4bool SetReadFile(std::string objName, std::string readFileName)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetPersistencyManager()

void G4PersistencyCenter::SetPersistencyManager ( G4PersistencyManager pm,
std::string  name 
)

Definition at line 375 of file G4PersistencyCenter.cc.

377 {
378  f_currentManager=pm;
380 }
G4PersistencyManager * f_currentManager
G4String name
Definition: TRTMaterials.hh:40
Here is the caller graph for this function:

◆ SetReadFile()

G4bool G4PersistencyCenter::SetReadFile ( std::string  objName,
std::string  readFileName 
)

Definition at line 210 of file G4PersistencyCenter.cc.

211 {
212 #ifndef WIN32
213  if ( f_ut.FileExists(readFileName) )
214  {
215  f_readFileName[objName] = readFileName;
216  }
217  else
218  {
219  G4cerr << "!! File \"" << objName << "\" does not exist."
220  << G4endl;
221  return false;
222  }
223 #endif
224  return true;
225 }
G4bool FileExists(const std::string file)
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetRetrieveMode()

void G4PersistencyCenter::SetRetrieveMode ( std::string  objName,
G4bool  mode 
)

Definition at line 166 of file G4PersistencyCenter.cc.

167 {
168  if ( (*(f_readFileName.find(objName))).second != "" ) {
169  f_readFileMode[objName] = mode;
170  } else {
171  G4cerr << "!! unknown object type " << objName << " for input."
172  << G4endl;
173  }
174 }
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr
Here is the caller graph for this function:

◆ SetStoreMode()

void G4PersistencyCenter::SetStoreMode ( std::string  objName,
StoreMode  mode 
)

Definition at line 155 of file G4PersistencyCenter.cc.

156 {
157  if ( (*(f_writeFileName.find(objName))).second != "" ) {
158  f_writeFileMode[objName] = mode;
159  } else {
160  G4cerr << "!! unknown object type " << objName << " for output."
161  << G4endl;
162  }
163 }
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr
Here is the caller graph for this function:

◆ SetVerboseLevel()

void G4PersistencyCenter::SetVerboseLevel ( int  v)

Definition at line 404 of file G4PersistencyCenter.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetWriteFile()

G4bool G4PersistencyCenter::SetWriteFile ( std::string  objName,
std::string  writeFileName 
)

Definition at line 197 of file G4PersistencyCenter.cc.

198 {
199  if ( (*(f_writeFileName.find(objName))).second != "" ) {
200  f_writeFileName[objName] = writeFileName;
201  } else {
202  G4cerr << "!! unknown object type " << objName << " for output."
203  << G4endl;
204  return false;
205  }
206  return true;
207 }
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr
Here is the caller graph for this function:

◆ VerboseLevel()

int G4PersistencyCenter::VerboseLevel ( )
inline

Definition at line 142 of file G4PersistencyCenter.hh.

142 { return m_verbose; };
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ f_currentManager

G4PersistencyManager* G4PersistencyCenter::f_currentManager
private

Definition at line 159 of file G4PersistencyCenter.hh.

◆ f_currentSystemName

std::string G4PersistencyCenter::f_currentSystemName
private

Definition at line 160 of file G4PersistencyCenter.hh.

◆ f_rdObj

ObjMap G4PersistencyCenter::f_rdObj
private

Definition at line 163 of file G4PersistencyCenter.hh.

◆ f_readFileMode

BoolMap G4PersistencyCenter::f_readFileMode
private

Definition at line 167 of file G4PersistencyCenter.hh.

◆ f_readFileName

FileMap G4PersistencyCenter::f_readFileName
private

Definition at line 165 of file G4PersistencyCenter.hh.

◆ f_theCatalog

PMap G4PersistencyCenter::f_theCatalog
private

Definition at line 161 of file G4PersistencyCenter.hh.

◆ f_theMessenger

G4PersistencyCenterMessenger* G4PersistencyCenter::f_theMessenger
private

Definition at line 157 of file G4PersistencyCenter.hh.

◆ f_thePointer

G4ThreadLocal G4PersistencyCenter * G4PersistencyCenter::f_thePointer = 0
staticprivate

Definition at line 158 of file G4PersistencyCenter.hh.

◆ f_ut

G4FileUtilities G4PersistencyCenter::f_ut
private

Definition at line 170 of file G4PersistencyCenter.hh.

◆ f_writeFileMode

StoreMap G4PersistencyCenter::f_writeFileMode
private

Definition at line 166 of file G4PersistencyCenter.hh.

◆ f_writeFileName

FileMap G4PersistencyCenter::f_writeFileName
private

Definition at line 164 of file G4PersistencyCenter.hh.

◆ f_wrObj

ObjMap G4PersistencyCenter::f_wrObj
private

Definition at line 162 of file G4PersistencyCenter.hh.

◆ m_verbose

G4int G4PersistencyCenter::m_verbose
private

Definition at line 168 of file G4PersistencyCenter.hh.


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