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

#include <G4PersistencyCenter.hh>

Public Member Functions

 G4PersistencyCenter ()
 
 ~G4PersistencyCenter ()
 
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 ()
 

Detailed Description

Definition at line 63 of file G4PersistencyCenter.hh.

Constructor & Destructor Documentation

◆ G4PersistencyCenter()

G4PersistencyCenter::G4PersistencyCenter ( )

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
74 f_theMessenger = new G4PersistencyCenterMessenger(this);
75 f_currentManager = new G4PersistencyManager(this, "Default");
76}
@ kRecycle

Referenced by GetPersistencyCenter().

◆ ~G4PersistencyCenter()

G4PersistencyCenter::~G4PersistencyCenter ( )

Definition at line 79 of file G4PersistencyCenter.cc.

80{
81 delete f_theMessenger;
82 delete f_currentManager;
83}

Member Function Documentation

◆ AddDCIOmanager()

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

Definition at line 284 of file G4PersistencyCenter.cc.

285{
287
288 std::string colName = "";
289 G4VDCIOentry* ioe = ioc->GetEntry(detName);
290 if ( ioe != 0 ) {
291 ioe->CreateDCIOmanager(detName, colName);
292 } else {
293 G4cerr << "Error! -- DCIO assignment failed for detector " << detName
294 << ", collection " << colName << G4endl;
295 }
296}
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cerr
G4VDCIOentry * GetEntry(std::string name)
static G4DCIOcatalog * GetDCIOcatalog()
virtual void CreateDCIOmanager(std::string, std::string)
Definition: G4VDCIOentry.hh:57

◆ AddHCIOmanager()

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

Definition at line 263 of file G4PersistencyCenter.cc.

264{
266
267 G4VHCIOentry* ioe = ioc->GetEntry(detName);
268 if ( ioe != 0 ) {
269 ioe->CreateHCIOmanager(detName, colName);
270 } else {
271 G4cerr << "Error! -- HCIO assignment failed for detector " << detName
272 << ", collection " << colName << G4endl;
273 }
274}
G4VHCIOentry * GetEntry(std::string name)
static G4HCIOcatalog * GetHCIOcatalog()
virtual void CreateHCIOmanager(std::string, std::string)
Definition: G4VHCIOentry.hh:57

Referenced by G4PersistencyCenterMessenger::SetNewValue().

◆ CurrentDCIOmanager()

std::string G4PersistencyCenter::CurrentDCIOmanager ( )

Definition at line 299 of file G4PersistencyCenter.cc.

300{
302 return ioc->CurrentDCIOmanager();
303}
std::string CurrentDCIOmanager()

◆ CurrentHCIOmanager()

std::string G4PersistencyCenter::CurrentHCIOmanager ( )

Definition at line 277 of file G4PersistencyCenter.cc.

278{
280 return ioc->CurrentHCIOmanager();
281}
std::string CurrentHCIOmanager()

Referenced by G4PersistencyCenterMessenger::GetCurrentValue().

◆ 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}
G4bool CurrentRetrieveMode(std::string objName)
std::string CurrentReadFile(std::string objName)

◆ CurrentObject()

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

Definition at line 250 of file G4PersistencyCenter.cc.

251{
252 FileMap::iterator itr;
253 for ( itr = f_readFileName.begin(); itr != f_readFileName.end(); itr++ ) {
254 if ( file == (*itr).second ) return (*itr).first;
255 }
256 for ( itr = f_writeFileName.begin(); itr != f_writeFileName.end(); itr++ ) {
257 if ( file == (*itr).second ) return (*itr).first;
258 }
259 return "?????";
260}

◆ CurrentPersistencyManager()

G4PersistencyManager * G4PersistencyCenter::CurrentPersistencyManager ( )
inline

Definition at line 130 of file G4PersistencyCenter.hh.

130{ return f_currentManager; };

Referenced by G4PersistencyManager::GetPersistencyManager().

◆ CurrentReadFile()

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

Definition at line 240 of file G4PersistencyCenter.cc.

241{
242 if ( (*(f_readFileName.find(objName))).second != "" ) {
243 return f_readFileName[objName];
244 } else {
245 return "?????";
246 }
247}

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

◆ CurrentRetrieveMode()

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

Definition at line 189 of file G4PersistencyCenter.cc.

190{
191 if ( (*(f_readFileName.find(objName))).second != "" ) {
192 return f_readFileMode[objName];
193 } else {
194 return false;
195 }
196}

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

◆ CurrentStoreMode()

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

Definition at line 177 of file G4PersistencyCenter.cc.

178{
179
180
181 if ( (*(f_writeFileName.find(objName))).second != "" ) {
182 return f_writeFileMode[objName];
183 } else {
184 return kOff;
185 }
186}

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

◆ CurrentSystem()

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

Definition at line 79 of file G4PersistencyCenter.hh.

79{ return f_currentSystemName; };

Referenced by G4PersistencyCenterMessenger::GetCurrentValue(), and PrintAll().

◆ CurrentWriteFile()

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

Definition at line 230 of file G4PersistencyCenter.cc.

231{
232 if ( (*(f_writeFileName.find(objName))).second != "" ) {
233 return f_writeFileName[objName];
234 } else {
235 return "?????";
236 }
237}

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

◆ DeletePersistencyManager()

void G4PersistencyCenter::DeletePersistencyManager ( )

Definition at line 399 of file G4PersistencyCenter.cc.

400{
401 if (f_currentManager!=0) delete f_currentManager;
402 f_currentManager=0;
403}

◆ GetPersistencyCenter()

G4PersistencyCenter * G4PersistencyCenter::GetPersistencyCenter ( )
static

◆ GetPersistencyManager()

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

Definition at line 385 of file G4PersistencyCenter.cc.

386{
387 if (f_theCatalog.find(nam)!=f_theCatalog.end())
388 return f_theCatalog[nam];
389 return 0;
390}

Referenced by SelectSystem().

◆ PrintAll()

void G4PersistencyCenter::PrintAll ( )

Definition at line 306 of file G4PersistencyCenter.cc.

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

Referenced by G4PersistencyCenterMessenger::SetNewValue().

◆ RegisterPersistencyManager()

void G4PersistencyCenter::RegisterPersistencyManager ( G4PersistencyManager pm)

Definition at line 393 of file G4PersistencyCenter.cc.

394{
395 f_theCatalog[pm->GetName()]=pm;
396}

◆ 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();
131 if (f_currentManager!=0) f_currentManager->SetVerboseLevel(m_verbose);
132 f_currentSystemName = systemName;
133 }
134}
int G4int
Definition: G4Types.hh:66
G4PersistencyManager * GetPersistencyManager(std::string nam)
virtual G4PersistencyManager * Create()

Referenced by G4PersistencyCenterMessenger::SetNewValue().

◆ 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}
G4bool SetReadFile(std::string objName, std::string readFileName)
void SetRetrieveMode(std::string objName, G4bool mode)

◆ SetPersistencyManager()

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

Definition at line 377 of file G4PersistencyCenter.cc.

379{
380 f_currentManager=pm;
381 f_currentSystemName=name;
382}

◆ SetReadFile()

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

Definition at line 212 of file G4PersistencyCenter.cc.

213{
214#ifndef WIN32
215 if ( f_ut.FileExists(readFileName) )
216 {
217 f_readFileName[objName] = readFileName;
218 }
219 else
220 {
221 G4cerr << "!! File \"" << objName << "\" does not exist."
222 << G4endl;
223 return false;
224 }
225#endif
226 return true;
227}
G4bool FileExists(const std::string file)

Referenced by SetHepMCObjyReaderFile().

◆ 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}

Referenced by SetHepMCObjyReaderFile().

◆ 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}

Referenced by G4PersistencyCenterMessenger::SetNewValue().

◆ SetVerboseLevel()

void G4PersistencyCenter::SetVerboseLevel ( int  v)

Definition at line 406 of file G4PersistencyCenter.cc.

407{
408 m_verbose = v;
409 if ( f_currentManager != 0 ) f_currentManager->SetVerboseLevel(m_verbose);
410}

Referenced by G4PersistencyCenterMessenger::SetNewValue().

◆ SetWriteFile()

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

Definition at line 199 of file G4PersistencyCenter.cc.

200{
201 if ( (*(f_writeFileName.find(objName))).second != "" ) {
202 f_writeFileName[objName] = writeFileName;
203 } else {
204 G4cerr << "!! unknown object type " << objName << " for output."
205 << G4endl;
206 return false;
207 }
208 return true;
209}

Referenced by G4PersistencyCenterMessenger::SetNewValue().

◆ VerboseLevel()

int G4PersistencyCenter::VerboseLevel ( )
inline

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