00001 // 00002 // ******************************************************************** 00003 // * License and Disclaimer * 00004 // * * 00005 // * The Geant4 software is copyright of the Copyright Holders of * 00006 // * the Geant4 Collaboration. It is provided under the terms and * 00007 // * conditions of the Geant4 Software License, included in the file * 00008 // * LICENSE and available at http://cern.ch/geant4/license . These * 00009 // * include a list of copyright holders. * 00010 // * * 00011 // * Neither the authors of this software system, nor their employing * 00012 // * institutes,nor the agencies providing financial support for this * 00013 // * work make any representation or warranty, express or implied, * 00014 // * regarding this software system or assume any liability for its * 00015 // * use. Please see the license in the file LICENSE and URL above * 00016 // * for the full disclaimer and the limitation of liability. * 00017 // * * 00018 // * This code implementation is the result of the scientific and * 00019 // * technical work of the GEANT4 collaboration. * 00020 // * By using, copying, modifying or distributing the software (or * 00021 // * any work based on the software) you agree to acknowledge its * 00022 // * use in resulting scientific publications, and indicate your * 00023 // * acceptance of all terms of the Geant4 Software license. * 00024 // ******************************************************************** 00025 // 00026 // File: G4PersistencyManager.hh 00027 // 00028 // History: 00029 // 01.07.17 Youhei Morita Initial creation (with "fadsclass") 00030 00031 #ifndef PERSISTENCY_MANAGER_HH 00032 #define PERSISTENCY_MANAGER_HH 1 00033 00034 #include "G4Event.hh" 00035 00036 #include "G4VMCTruthIO.hh" 00037 #include "G4HCIOcatalog.hh" 00038 #include "G4DCIOcatalog.hh" 00039 #include "G4VPEventIO.hh" 00040 #include "G4VPHitIO.hh" 00041 #include "G4VPDigitIO.hh" 00042 #include "G4VTransactionManager.hh" 00043 #include <string> 00044 00045 class G4PersistencyCenter; 00046 00047 // Class inherited: 00048 #include "G4VPersistencyManager.hh" 00049 00050 // Class Description: 00051 // Manager base class to handle event store and retrieve operation. 00052 // Actual persistency implementation should be handled with 00053 // derived classes. 00054 // 00055 // Each persistency package should implement derived classes of 00056 // G4VHepMCIO, G4VMCTruthIO, G4VPHitIO, G4VPDigitIO, G4VPEventIO. 00057 // Concreate G4PersistencyManager should implement the methods 00058 // HepMCIO(), MCTruthIO(), HitIO(), DigitIO() and EventIO() to 00059 // return the pointers of the above classes. 00060 // G4PersistencyManager handles the sequence of the storing and 00061 // retrieving of the persistent object of each type, along with 00062 // the transaction handling. 00063 // 00064 // Retrieving a HepMC event: 00065 // 00066 // G4PersistencyManager::Retrieve( HepMC::GenEvent*& ) 00067 // | 00068 // | ... StartRead() ... 00069 // | 00070 // | ... Commit() ... 00071 // V 00072 // 00073 // Storing a Geant4 event: 00074 // 00075 // G4PersistencyManager::Store( G4Pevent* ) 00076 // | 00077 // | ... StartUpdate() ... 00078 // | 00079 // | ... MCTruthIO()->Store( MCTruth event ) ... 00080 // | 00081 // | ... HitIO()->Store( hit_collection_of_event ) ... 00082 // | 00083 // | ... DigitIO()->Store( digit_collection_of_event ) ... 00084 // | 00085 // | ... EventIO()->Store( event with hits and digits ) ... 00086 // | 00087 // | ... Commit() ... 00088 // V 00089 // 00090 // Retrieving a Geant event: 00091 // 00092 // G4PersistencyManager::Retrieve( event ) 00093 // | 00094 // | ... StartRead() ... 00095 // | 00096 // | ... EventIO()->Retrieve( event ) ... 00097 // | 00098 // | ... Commit() ... 00099 // V 00100 // 00101 // Hit collection and digit collection of each detector component 00102 // should be handled by detector specific I/O manager, which 00103 // should be registered to the G4PersistencyCenter with 00104 // AddHCIOmanager() and AddDCIOmanager(). Usually this is done 00105 // through a command 00106 // 00107 // /Persistency/Store/Using/HitIO <detector_io_manager_name> 00108 // 00109 // which is handled by G4PersistencyCenterMessenger. 00110 // 00111 // A static template declaration of G4HCIOentryT<class> must be 00112 // implementated for each I/O manager. 00113 00114 class G4PersistencyManager 00115 : public G4VPersistencyManager 00116 { 00117 friend class G4PersistencyCenter; 00118 00119 public: // With description 00120 G4PersistencyManager(G4PersistencyCenter* pc, std::string n); 00121 // Constructor 00122 00123 virtual ~G4PersistencyManager(); 00124 // Destructor 00125 00126 public: // With description 00127 virtual G4PersistencyManager* Create() {return 0;}; 00128 // Create a new persistency manager. To be used by G4PersistencyManagerT<>. 00129 00130 std::string GetName() {return nameMgr;}; 00131 // Get the name of persistency manager 00132 00133 virtual G4VPEventIO* EventIO() { return 0; }; 00134 // Returns the current event I/O handling manager 00135 // Each derived class should return the pointer of actual manager. 00136 00137 virtual G4VPHitIO* HitIO() { return 0; }; 00138 // Returns the current hit I/O handling manager 00139 // Each derived class should return the pointer of actual manager. 00140 00141 virtual G4VPDigitIO* DigitIO() { return 0; }; 00142 // Returns the current digit I/O handling manager 00143 // Each derived class should return the pointer of actual manager. 00144 00145 virtual G4VMCTruthIO* MCTruthIO() { return 0; }; 00146 // Returns the current MCTruth I/O handling manager 00147 // Each derived class should return the pointer of actual manager. 00148 00149 virtual G4VTransactionManager* TransactionManager() { return 0; }; 00150 // Returns the current transaction manager 00151 // Each derived class should return the pointer of actual manager. 00152 00153 virtual void Initialize() {}; 00154 // Initialize the persistency package. 00155 // Each derived class should implement the acutal initialization sequence. 00156 00157 void SetVerboseLevel(int v); 00158 // Set verbose level. 00159 00160 G4bool Store(const G4Event* evt); 00161 // Store the G4Event and its associated objects 00162 00163 G4bool Retrieve(G4Event*& evt); 00164 // Retrieve the G4Event and its associated objects 00165 00166 G4bool Store(const G4Run*) {return false;}; 00167 // not used 00168 00169 G4bool Retrieve(G4Run*&) {return false;}; 00170 // not used 00171 00172 G4bool Store(const G4VPhysicalVolume*) {return false;}; 00173 // not used 00174 00175 G4bool Retrieve(G4VPhysicalVolume*&) {return false;}; 00176 // not used 00177 00178 protected: 00179 static G4PersistencyManager* GetPersistencyManager(); 00180 // Get the instance of persistency manager 00181 00182 protected: 00183 G4PersistencyCenter* f_pc; 00184 int m_verbose; 00185 00186 private: 00187 std::string nameMgr; 00188 G4bool f_is_initialized; 00189 00190 }; // End of class G4PersistencyManager 00191 00192 #endif 00193