Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // G4PersistencyCenter implementation << 26 // File: G4PersistencyCenter.cc 27 // 27 // 28 // Author: Youhei Morita, 10.08.2001 << 28 // History: 29 // ------------------------------------------- << 29 // '01.08.10 Youhei Morita Initial creation (with "fadsclass3") 30 30 31 #include "G4PersistencyCenter.hh" 31 #include "G4PersistencyCenter.hh" >> 32 >> 33 // Forward Declarations: 32 #include "G4PersistencyCenterMessenger.hh" 34 #include "G4PersistencyCenterMessenger.hh" 33 35 >> 36 // Addtional Include: 34 #include "G4UImanager.hh" 37 #include "G4UImanager.hh" 35 #include "G4PersistencyManager.hh" 38 #include "G4PersistencyManager.hh" 36 #include "G4VHCIOentry.hh" << 37 #include "G4VDCIOentry.hh" << 38 39 39 G4ThreadLocal G4PersistencyCenter* G4Persisten << 40 G4PersistencyCenter* G4PersistencyCenter::f_thePointer=G4PersistencyCenter::GetPersistencyCenter(); 40 41 41 // ------------------------------------------- << 42 // Implementation of Constructor #1 42 G4PersistencyCenter::G4PersistencyCenter() 43 G4PersistencyCenter::G4PersistencyCenter() >> 44 : m_verbose(0) 43 { 45 { 44 f_wrObj[0] = "HepMC"; 46 f_wrObj[0] = "HepMC"; 45 f_wrObj[1] = "MCTruth"; 47 f_wrObj[1] = "MCTruth"; 46 f_wrObj[2] = "Hits"; 48 f_wrObj[2] = "Hits"; 47 f_wrObj[3] = "Digits"; 49 f_wrObj[3] = "Digits"; 48 50 49 f_rdObj[0] = "Hits"; 51 f_rdObj[0] = "Hits"; 50 f_rdObj[1] = "HitsBG"; 52 f_rdObj[1] = "HitsBG"; 51 53 52 for(auto itr = f_wrObj.cbegin(); itr != f_wr << 54 ObjMap::iterator itr; 53 { << 55 >> 56 for ( itr = f_wrObj.begin(); itr != f_wrObj.end(); itr++ ) { 54 f_writeFileName[(*itr).second] = "G4defaul 57 f_writeFileName[(*itr).second] = "G4defaultOutput"; 55 } 58 } 56 59 57 for(auto itr = f_rdObj.cbegin(); itr != f_rd << 60 for ( itr = f_rdObj.begin(); itr != f_rdObj.end(); itr++ ) { 58 { << 59 f_readFileName[(*itr).second] = "G4default 61 f_readFileName[(*itr).second] = "G4defaultInput"; 60 } 62 } 61 63 62 f_writeFileMode["HepMC"] = kRecycle; 64 f_writeFileMode["HepMC"] = kRecycle; 63 f_writeFileMode["MCTruth"] = kOn; 65 f_writeFileMode["MCTruth"] = kOn; 64 f_writeFileMode["Hits"] = kOn; 66 f_writeFileMode["Hits"] = kOn; 65 f_writeFileMode["Digits"] = kOff; 67 f_writeFileMode["Digits"] = kOff; 66 68 67 f_readFileMode["Hits"] = false; 69 f_readFileMode["Hits"] = false; 68 f_readFileMode["HitsBG"] = false; 70 f_readFileMode["HitsBG"] = false; 69 71 70 f_theMessenger = new G4PersistencyCenterMe << 72 f_theMessenger = new G4PersistencyCenterMessenger(this); 71 f_currentManager = new G4PersistencyManager( 73 f_currentManager = new G4PersistencyManager(this, "Default"); 72 } 74 } 73 75 74 // ------------------------------------------- << 76 // Implementation of Constructor #2 >> 77 G4PersistencyCenter::G4PersistencyCenter(const G4PersistencyCenter&) >> 78 {} >> 79 >> 80 // Implementation of Destructor #1 75 G4PersistencyCenter::~G4PersistencyCenter() 81 G4PersistencyCenter::~G4PersistencyCenter() 76 { 82 { 77 delete f_theMessenger; 83 delete f_theMessenger; 78 delete f_currentManager; 84 delete f_currentManager; 79 } 85 } 80 86 81 // ------------------------------------------- << 87 // Implementation of GetPersistencyCenter 82 G4PersistencyCenter* G4PersistencyCenter::GetP 88 G4PersistencyCenter* G4PersistencyCenter::GetPersistencyCenter() 83 { 89 { 84 if(f_thePointer == nullptr) << 90 if ( f_thePointer == 0 ) f_thePointer = new G4PersistencyCenter; 85 f_thePointer = new G4PersistencyCenter; << 86 return f_thePointer; 91 return f_thePointer; 87 } 92 } 88 93 89 // ------------------------------------------- << 94 90 void G4PersistencyCenter::SelectSystem(const G << 95 // Implementation of SelectSystem >> 96 void G4PersistencyCenter::SelectSystem(std::string systemName) 91 { 97 { 92 G4int st = 0; << 98 int st = 0; 93 99 94 if(f_currentManager != nullptr) << 100 if (f_currentManager!=0) delete f_currentManager; 95 delete f_currentManager; << 96 101 97 G4PersistencyManager* pm = nullptr; << 102 G4PersistencyManager* pm = 0; 98 103 99 if(systemName == "ROOT") << 104 if (systemName=="None") 100 { 105 { 101 G4cout << " G4PersistencyCenter: \"ROOT\" << 106 G4cout<<" G4PersistencyCenter: Default is selected."<< G4endl; 102 << G4endl; << 107 pm = new G4PersistencyManager(this, "Default"); >> 108 } >> 109 else if (systemName=="ROOT") >> 110 { >> 111 G4cout<<" G4PersistencyCenter: \"ROOT\" Persistency Package is selected." >> 112 <<G4endl; 103 // G4UImanager *man=G4UImanager::GetUIpoin 113 // G4UImanager *man=G4UImanager::GetUIpointer(); 104 // std::string libs="Cint:Core:Tree:Rint:M 114 // std::string libs="Cint:Core:Tree:Rint:Matrix:Physics:fadsROOT"; 105 // st = man->ApplyCommand("/load "+libs); 115 // st = man->ApplyCommand("/load "+libs); 106 if(st == 0) << 116 if ( st == 0 ) { 107 { << 108 pm = GetPersistencyManager("ROOT"); 117 pm = GetPersistencyManager("ROOT"); 109 } 118 } 110 } 119 } 111 else if(systemName == "ODBMS") << 120 else if (systemName=="ODBMS") 112 { 121 { 113 G4cout << " G4PersistencyCenter: \"ODBMS\" << 122 G4cout<<" G4PersistencyCenter: \"ODBMS\" package is selected."<<G4endl; 114 // G4UImanager *man=G4UImanager::GetUIpoin 123 // G4UImanager *man=G4UImanager::GetUIpointer(); 115 // std::string libs="fadsODBMS"; 124 // std::string libs="fadsODBMS"; 116 // st = man->ApplyCommand("/load "+libs); 125 // st = man->ApplyCommand("/load "+libs); 117 if(st == 0) << 126 if ( st == 0 ) { 118 { << 119 pm = GetPersistencyManager("ODBMS"); 127 pm = GetPersistencyManager("ODBMS"); 120 } 128 } 121 } 129 } 122 else << 130 if ( st == 0 ) { 123 { << 124 G4cout << " G4PersistencyCenter: Default i << 125 pm = new G4PersistencyManager(this, "Defau << 126 } << 127 << 128 if(st == 0) << 129 { << 130 f_currentManager = pm->Create(); 131 f_currentManager = pm->Create(); 131 if(f_currentManager != nullptr) << 132 if (f_currentManager!=0) f_currentManager->SetVerboseLevel(m_verbose); 132 f_currentManager->SetVerboseLevel(m_verb << 133 f_currentSystemName = systemName; 133 f_currentSystemName = systemName; 134 } 134 } 135 } 135 } 136 136 137 // ------------------------------------------- << 137 // Implementation of SetHepMCObjyReaderFile 138 void G4PersistencyCenter::SetHepMCObjyReaderFi << 138 void G4PersistencyCenter::SetHepMCObjyReaderFile(std::string file) 139 { 139 { 140 if(SetReadFile("HepMC", file)) << 140 if ( SetReadFile("HepMC", file) ) { 141 { << 142 SetRetrieveMode("HepMC", true); 141 SetRetrieveMode("HepMC", true); 143 } 142 } 144 } 143 } 145 144 146 // ------------------------------------------- << 145 // Implementation of CurrentHepMCObjyReaderFile 147 G4String G4PersistencyCenter::CurrentHepMCObjy << 146 std::string G4PersistencyCenter::CurrentHepMCObjyReaderFile() 148 { 147 { 149 if(CurrentRetrieveMode("HepMC")) << 148 if ( CurrentRetrieveMode("HepMC") ) { 150 { << 151 return CurrentReadFile("HepMC"); 149 return CurrentReadFile("HepMC"); 152 } << 150 } else { 153 else << 154 { << 155 return ""; 151 return ""; 156 } 152 } 157 } 153 } 158 154 159 // ------------------------------------------- << 155 // Implementation of SetStoreMode 160 void G4PersistencyCenter::SetStoreMode(const G << 156 void G4PersistencyCenter::SetStoreMode(std::string objName, StoreMode mode) 161 { 157 { 162 if((*(f_writeFileName.find(objName))).second << 158 if ( (*(f_writeFileName.find(objName))).second != "" ) { 163 { << 164 f_writeFileMode[objName] = mode; 159 f_writeFileMode[objName] = mode; 165 } << 160 } else { 166 else << 161 G4cerr << "!! unknown object type " << objName << " for output." 167 { << 162 << G4endl; 168 G4cerr << "!! unknown object type " << obj << 169 } 163 } 170 } 164 } 171 165 172 // ------------------------------------------- << 166 // Implementation of SetRetrieveMode 173 void G4PersistencyCenter::SetRetrieveMode(cons << 167 void G4PersistencyCenter::SetRetrieveMode(std::string objName, G4bool mode) 174 { 168 { 175 if((*(f_readFileName.find(objName))).second << 169 if ( (*(f_readFileName.find(objName))).second != "" ) { 176 { << 177 f_readFileMode[objName] = mode; 170 f_readFileMode[objName] = mode; 178 } << 171 } else { 179 else << 172 G4cerr << "!! unknown object type " << objName << " for input." 180 { << 173 << G4endl; 181 G4cerr << "!! unknown object type " << obj << 182 } 174 } 183 } 175 } 184 176 185 // ------------------------------------------- << 177 // Implementation of CurrentStoreMode 186 StoreMode G4PersistencyCenter::CurrentStoreMod << 178 StoreMode G4PersistencyCenter::CurrentStoreMode(std::string objName) 187 { 179 { 188 if((*(f_writeFileName.find(objName))).second << 180 189 { << 181 >> 182 if ( (*(f_writeFileName.find(objName))).second != "" ) { 190 return f_writeFileMode[objName]; 183 return f_writeFileMode[objName]; 191 } << 184 } else { 192 else << 193 { << 194 return kOff; 185 return kOff; 195 } 186 } 196 } 187 } 197 188 198 // ------------------------------------------- << 189 // Implementation of CurrentRetrieveMode 199 G4bool G4PersistencyCenter::CurrentRetrieveMod << 190 G4bool G4PersistencyCenter::CurrentRetrieveMode(std::string objName) 200 { 191 { 201 if((*(f_readFileName.find(objName))).second << 192 if ( (*(f_readFileName.find(objName))).second != "" ) { 202 { << 203 return f_readFileMode[objName]; 193 return f_readFileMode[objName]; 204 } << 194 } else { 205 else << 206 { << 207 return false; 195 return false; 208 } 196 } 209 } 197 } 210 198 211 // ------------------------------------------- << 199 // Implementation of SetWriteFile 212 G4bool G4PersistencyCenter::SetWriteFile(const << 200 G4bool G4PersistencyCenter::SetWriteFile(std::string objName, std::string writeFileName) 213 const << 214 { 201 { 215 if((*(f_writeFileName.find(objName))).second << 202 if ( (*(f_writeFileName.find(objName))).second != "" ) { 216 { << 217 f_writeFileName[objName] = writeFileName; 203 f_writeFileName[objName] = writeFileName; 218 } << 204 } else { 219 else << 205 G4cerr << "!! unknown object type " << objName << " for output." 220 { << 206 << G4endl; 221 G4cerr << "!! unknown object type " << obj << 222 return false; 207 return false; 223 } 208 } 224 return true; 209 return true; 225 } 210 } 226 211 227 // ------------------------------------------- << 212 // Implementation of SetReadFile 228 G4bool G4PersistencyCenter::SetReadFile(const << 213 G4bool G4PersistencyCenter::SetReadFile(std::string objName, std::string readFileName) 229 const << 230 { 214 { 231 #ifndef WIN32 215 #ifndef WIN32 232 if(f_ut.FileExists(readFileName)) << 216 if ( f_ut.FileExists(readFileName) ) 233 { 217 { 234 f_readFileName[objName] = readFileName; 218 f_readFileName[objName] = readFileName; 235 } 219 } 236 else 220 else 237 { 221 { 238 G4cerr << "!! File \"" << objName << "\" d << 222 G4cerr << "!! File \"" << objName << "\" does not exist." >> 223 << G4endl; 239 return false; 224 return false; 240 } 225 } 241 #endif 226 #endif 242 return true; 227 return true; 243 } 228 } 244 229 245 // ------------------------------------------- << 230 // Implementation of CurrentWriteFile 246 G4String G4PersistencyCenter::CurrentWriteFile << 231 std::string G4PersistencyCenter::CurrentWriteFile(std::string objName) 247 { 232 { 248 if((*(f_writeFileName.find(objName))).second << 233 if ( (*(f_writeFileName.find(objName))).second != "" ) { 249 { << 250 return f_writeFileName[objName]; 234 return f_writeFileName[objName]; 251 } << 235 } else { 252 else << 253 { << 254 return "?????"; 236 return "?????"; 255 } 237 } 256 } 238 } 257 239 258 // ------------------------------------------- << 240 // Implementation of CurrentReadFile 259 G4String G4PersistencyCenter::CurrentReadFile( << 241 std::string G4PersistencyCenter::CurrentReadFile(std::string objName) 260 { 242 { 261 if((*(f_readFileName.find(objName))).second << 243 if ( (*(f_readFileName.find(objName))).second != "" ) { 262 { << 263 return f_readFileName[objName]; 244 return f_readFileName[objName]; 264 } << 245 } else { 265 else << 266 { << 267 return "?????"; 246 return "?????"; 268 } 247 } 269 } 248 } 270 249 271 // ------------------------------------------- << 250 // Implementation of CurrentObject 272 G4String G4PersistencyCenter::CurrentObject(co << 251 std::string G4PersistencyCenter::CurrentObject(std::string file) 273 { 252 { 274 for(auto itr = f_readFileName.cbegin(); itr << 253 FileMap::iterator itr; 275 { << 254 for ( itr = f_readFileName.begin(); itr != f_readFileName.end(); itr++ ) { 276 if(file == (*itr).second) << 255 if ( file == (*itr).second ) return (*itr).first; 277 return (*itr).first; << 278 } 256 } 279 for(auto itr = f_writeFileName.cbegin(); itr << 257 for ( itr = f_writeFileName.begin(); itr != f_writeFileName.end(); itr++ ) { 280 { << 258 if ( file == (*itr).second ) return (*itr).first; 281 if(file == (*itr).second) << 282 return (*itr).first; << 283 } 259 } 284 return "?????"; 260 return "?????"; 285 } 261 } 286 262 287 // ------------------------------------------- << 263 // Implementation of AddHCIOmanager 288 void G4PersistencyCenter::AddHCIOmanager(const << 264 void G4PersistencyCenter::AddHCIOmanager(std::string detName, std::string colName) 289 const << 290 { 265 { 291 G4HCIOcatalog* ioc = G4HCIOcatalog::GetHCIOc 266 G4HCIOcatalog* ioc = G4HCIOcatalog::GetHCIOcatalog(); 292 267 293 G4VHCIOentry* ioe = ioc->GetEntry(detName); 268 G4VHCIOentry* ioe = ioc->GetEntry(detName); 294 if(ioe != nullptr) << 269 if ( ioe != 0 ) { 295 { << 296 ioe->CreateHCIOmanager(detName, colName); 270 ioe->CreateHCIOmanager(detName, colName); 297 } << 271 } else { 298 else << 299 { << 300 G4cerr << "Error! -- HCIO assignment faile 272 G4cerr << "Error! -- HCIO assignment failed for detector " << detName 301 << ", collection " << colName << G4 << 273 << ", collection " << colName << G4endl; 302 } 274 } 303 } 275 } 304 276 305 // ------------------------------------------- << 277 // Implementation of CurrentHCIOmanager 306 G4String G4PersistencyCenter::CurrentHCIOmanag << 278 std::string G4PersistencyCenter::CurrentHCIOmanager() 307 { 279 { 308 G4HCIOcatalog* ioc = G4HCIOcatalog::GetHCIOc 280 G4HCIOcatalog* ioc = G4HCIOcatalog::GetHCIOcatalog(); 309 return ioc->CurrentHCIOmanager(); 281 return ioc->CurrentHCIOmanager(); 310 } 282 } 311 283 312 // ------------------------------------------- << 284 // Implementation of AddDCIOmanager 313 void G4PersistencyCenter::AddDCIOmanager(const << 285 void G4PersistencyCenter::AddDCIOmanager(std::string detName) 314 { 286 { 315 G4DCIOcatalog* ioc = G4DCIOcatalog::GetDCIOc 287 G4DCIOcatalog* ioc = G4DCIOcatalog::GetDCIOcatalog(); 316 288 317 G4String colName = ""; << 289 std::string colName = ""; 318 G4VDCIOentry* ioe = ioc->GetEntry(detName); 290 G4VDCIOentry* ioe = ioc->GetEntry(detName); 319 if(ioe != nullptr) << 291 if ( ioe != 0 ) { 320 { << 321 ioe->CreateDCIOmanager(detName, colName); 292 ioe->CreateDCIOmanager(detName, colName); 322 } << 293 } else { 323 else << 324 { << 325 G4cerr << "Error! -- DCIO assignment faile 294 G4cerr << "Error! -- DCIO assignment failed for detector " << detName 326 << ", collection " << colName << G4 << 295 << ", collection " << colName << G4endl; 327 } 296 } 328 } 297 } 329 298 330 // ------------------------------------------- << 299 // Implementation of CurrentDCIOmanager 331 G4String G4PersistencyCenter::CurrentDCIOmanag << 300 std::string G4PersistencyCenter::CurrentDCIOmanager() 332 { 301 { 333 G4DCIOcatalog* ioc = G4DCIOcatalog::GetDCIOc 302 G4DCIOcatalog* ioc = G4DCIOcatalog::GetDCIOcatalog(); 334 return ioc->CurrentDCIOmanager(); 303 return ioc->CurrentDCIOmanager(); 335 } 304 } 336 305 337 // ------------------------------------------- << 306 // Implementation of PrintAll 338 void G4PersistencyCenter::PrintAll() 307 void G4PersistencyCenter::PrintAll() 339 { 308 { 340 G4cout << "Persistency Package: " << Current 309 G4cout << "Persistency Package: " << CurrentSystem() << G4endl; 341 G4cout << G4endl; 310 G4cout << G4endl; 342 311 343 G4String name, file; << 312 ObjMap::iterator itr; 344 StoreMode mode; << 313 std::string name; >> 314 std::string file; >> 315 StoreMode mode; 345 316 346 G4cout << "Output object types and file name 317 G4cout << "Output object types and file names:" << G4endl; 347 for(auto itr = f_wrObj.cbegin(); itr != f_wr << 318 for ( itr = f_wrObj.begin(); itr != f_wrObj.end(); itr++ ) { 348 { << 349 name = (*itr).second; 319 name = (*itr).second; 350 // disabled HepMC and MCTruth for now 320 // disabled HepMC and MCTruth for now 351 if(name != "HepMC" && name != "MCTruth") << 321 if ( name != "HepMC" && name != "MCTruth" ) { 352 { << 353 G4cout << " Object: " << PadString(name 322 G4cout << " Object: " << PadString(name, 9); 354 mode = CurrentStoreMode(name); 323 mode = CurrentStoreMode(name); 355 if(mode == kOn) << 324 if ( mode == kOn ) { 356 { << 357 G4cout << " <on> "; 325 G4cout << " <on> "; 358 } << 326 } else if ( mode == kOff ) { 359 else if(mode == kOff) << 360 { << 361 G4cout << " <off> "; 327 G4cout << " <off> "; 362 } << 328 } else if ( mode == kRecycle ) { 363 else if(mode == kRecycle) << 364 { << 365 G4cout << "<recycle>"; 329 G4cout << "<recycle>"; 366 } 330 } 367 file = CurrentWriteFile(name); 331 file = CurrentWriteFile(name); 368 if(file == "") << 332 if ( file == "" ) file = " <N/A>"; 369 file = " <N/A>"; << 370 G4cout << " File: " << file << G4endl; 333 G4cout << " File: " << file << G4endl; 371 } 334 } 372 } 335 } 373 G4cout << G4endl; 336 G4cout << G4endl; 374 337 375 G4cout << "Input object types and file names 338 G4cout << "Input object types and file names:" << G4endl; 376 for(auto itr = f_rdObj.cbegin(); itr != f_rd << 339 for ( itr = f_rdObj.begin(); itr != f_rdObj.end(); itr++ ) { 377 { << 378 name = (*itr).second; 340 name = (*itr).second; 379 // disabled HepMC and MCTruth for now 341 // disabled HepMC and MCTruth for now 380 if(name != "HepMC" && name != "MCTruth") << 342 if ( name != "HepMC" && name != "MCTruth" ) { 381 { << 382 G4cout << " Object: " << PadString(name 343 G4cout << " Object: " << PadString(name, 9); 383 if(CurrentRetrieveMode(name)) << 344 if ( CurrentRetrieveMode(name) ) { 384 { << 385 G4cout << " <on> "; 345 G4cout << " <on> "; 386 } << 346 } else { 387 else << 388 { << 389 G4cout << " <off> "; 347 G4cout << " <off> "; 390 } 348 } 391 file = CurrentReadFile(name); 349 file = CurrentReadFile(name); 392 if(file == "") << 350 if ( file == "" ) file = " <N/A>"; 393 file = " <N/A>"; << 394 G4cout << " File: " << CurrentReadFile(n 351 G4cout << " File: " << CurrentReadFile(name) << G4endl; 395 } 352 } 396 } 353 } 397 G4cout << G4endl; 354 G4cout << G4endl; 398 355 399 G4HCIOcatalog* hioc = G4HCIOcatalog::GetHCIO 356 G4HCIOcatalog* hioc = G4HCIOcatalog::GetHCIOcatalog(); 400 if(hioc != nullptr) << 357 if ( hioc != 0 ) { 401 { << 402 G4cout << "Hit IO Managers:" << G4endl; 358 G4cout << "Hit IO Managers:" << G4endl; 403 hioc->PrintEntries(); 359 hioc->PrintEntries(); 404 hioc->PrintHCIOmanager(); 360 hioc->PrintHCIOmanager(); 405 G4cout << G4endl; 361 G4cout << G4endl; 406 } << 362 } else { 407 else << 408 { << 409 G4cout << "Hit IO Manager catalog is not r 363 G4cout << "Hit IO Manager catalog is not registered." << G4endl; 410 } 364 } 411 365 412 G4DCIOcatalog* dioc = G4DCIOcatalog::GetDCIO 366 G4DCIOcatalog* dioc = G4DCIOcatalog::GetDCIOcatalog(); 413 if(dioc != nullptr) << 367 if ( dioc != 0 ) { 414 { << 415 G4cout << "Digit IO Managers:" << G4endl; 368 G4cout << "Digit IO Managers:" << G4endl; 416 dioc->PrintEntries(); 369 dioc->PrintEntries(); 417 dioc->PrintDCIOmanager(); 370 dioc->PrintDCIOmanager(); 418 G4cout << G4endl; 371 G4cout << G4endl; 419 } << 372 } else { 420 else << 421 { << 422 G4cout << "Digit IO Manager catalog is not 373 G4cout << "Digit IO Manager catalog is not registered." << G4endl; 423 } 374 } 424 } 375 } 425 376 426 // ------------------------------------------- << 377 // Implementation of SetPersistencyManager 427 void G4PersistencyCenter::SetPersistencyManage 378 void G4PersistencyCenter::SetPersistencyManager(G4PersistencyManager* pm, 428 << 379 std::string name) 429 { 380 { 430 f_currentManager = pm; << 381 f_currentManager=pm; 431 f_currentSystemName = name; << 382 f_currentSystemName=name; 432 } 383 } 433 384 434 // ------------------------------------------- << 385 // Implementation of GetPersistencyManager 435 G4PersistencyManager* << 386 G4PersistencyManager* G4PersistencyCenter::GetPersistencyManager(std::string nam) 436 G4PersistencyCenter::GetPersistencyManager(con << 437 { 387 { 438 if(f_theCatalog.find(nam) != f_theCatalog.ce << 388 if (f_theCatalog.find(nam)!=f_theCatalog.end()) 439 return f_theCatalog[nam]; 389 return f_theCatalog[nam]; 440 return nullptr; << 390 return 0; 441 } 391 } 442 392 443 // ------------------------------------------- << 393 // Implementation of RegisterPersistencyManager 444 void G4PersistencyCenter::RegisterPersistencyM 394 void G4PersistencyCenter::RegisterPersistencyManager(G4PersistencyManager* pm) 445 { 395 { 446 f_theCatalog[pm->GetName()] = pm; << 396 f_theCatalog[pm->GetName()]=pm; 447 } 397 } 448 398 449 // ------------------------------------------- << 399 // Implementation of DeletePersistencyManager 450 void G4PersistencyCenter::DeletePersistencyMan 400 void G4PersistencyCenter::DeletePersistencyManager() 451 { 401 { 452 if(f_currentManager != nullptr) << 402 if (f_currentManager!=0) delete f_currentManager; 453 delete f_currentManager; << 403 f_currentManager=0; 454 f_currentManager = nullptr; << 455 } 404 } 456 405 457 // ------------------------------------------- << 406 // Implementation of SetVerboseLevel 458 void G4PersistencyCenter::SetVerboseLevel(G4in << 407 void G4PersistencyCenter::SetVerboseLevel(int v) 459 { 408 { 460 m_verbose = v; 409 m_verbose = v; 461 if(f_currentManager != nullptr) << 410 if ( f_currentManager != 0 ) f_currentManager->SetVerboseLevel(m_verbose); 462 f_currentManager->SetVerboseLevel(m_verbos << 463 } 411 } 464 412 465 // ------------------------------------------- << 413 // Implementation of PadString 466 G4String G4PersistencyCenter::PadString(const << 414 std::string G4PersistencyCenter::PadString(std::string name, unsigned int width) 467 unsign << 468 { 415 { 469 if(name.length() > width) << 416 if ( name.length() > width ) { 470 { << 417 return name.substr(0,width-1) + "#"; 471 return name.substr(0, width - 1) + "#"; << 418 } else { 472 } << 419 std::string wname = name; 473 else << 420 for ( unsigned int i=0; i < width-name.length(); i++) wname = wname + " "; 474 { << 475 G4String wname = name; << 476 for(unsigned int i = 0; i < width - name.l << 477 wname = wname + " "; << 478 return wname; 421 return wname; 479 } 422 } 480 } 423 } >> 424 >> 425 // End of G4PersistencyCenter.cc >> 426 481 427