| [818] | 1 | //
|
|---|
| 2 | // ********************************************************************
|
|---|
| 3 | // * License and Disclaimer *
|
|---|
| 4 | // * *
|
|---|
| 5 | // * The Geant4 software is copyright of the Copyright Holders of *
|
|---|
| 6 | // * the Geant4 Collaboration. It is provided under the terms and *
|
|---|
| 7 | // * conditions of the Geant4 Software License, included in the file *
|
|---|
| 8 | // * LICENSE and available at http://cern.ch/geant4/license . These *
|
|---|
| 9 | // * include a list of copyright holders. *
|
|---|
| 10 | // * *
|
|---|
| 11 | // * Neither the authors of this software system, nor their employing *
|
|---|
| 12 | // * institutes,nor the agencies providing financial support for this *
|
|---|
| 13 | // * work make any representation or warranty, express or implied, *
|
|---|
| 14 | // * regarding this software system or assume any liability for its *
|
|---|
| 15 | // * use. Please see the license in the file LICENSE and URL above *
|
|---|
| 16 | // * for the full disclaimer and the limitation of liability. *
|
|---|
| 17 | // * *
|
|---|
| 18 | // * This code implementation is the result of the scientific and *
|
|---|
| 19 | // * technical work of the GEANT4 collaboration. *
|
|---|
| 20 | // * By using, copying, modifying or distributing the software (or *
|
|---|
| 21 | // * any work based on the software) you agree to acknowledge its *
|
|---|
| 22 | // * use in resulting scientific publications, and indicate your *
|
|---|
| 23 | // * acceptance of all terms of the Geant4 Software license. *
|
|---|
| 24 | // ********************************************************************
|
|---|
| 25 | //
|
|---|
| 26 | // File: G4PersistencyManager.hh
|
|---|
| 27 | //
|
|---|
| 28 | // History:
|
|---|
| 29 | // 01.07.17 Youhei Morita Initial creation (with "fadsclass")
|
|---|
| 30 |
|
|---|
| 31 | #ifndef PERSISTENCY_MANAGER_HH
|
|---|
| 32 | #define PERSISTENCY_MANAGER_HH 1
|
|---|
| 33 |
|
|---|
| 34 | #include "G4Event.hh"
|
|---|
| 35 |
|
|---|
| 36 | #ifndef WIN32
|
|---|
| 37 | #ifdef G4LIB_USE_HEPMC
|
|---|
| 38 | #include "CLHEP/HepMC/GenEvent.h"
|
|---|
| 39 | #include "G4VHepMCIO.hh"
|
|---|
| 40 | #include "G4VMCTruthIO.hh"
|
|---|
| 41 | #endif
|
|---|
| 42 | #endif
|
|---|
| 43 |
|
|---|
| 44 | #include "G4HCIOcatalog.hh"
|
|---|
| 45 | #include "G4DCIOcatalog.hh"
|
|---|
| 46 | #include "G4VPEventIO.hh"
|
|---|
| 47 | #include "G4VPHitIO.hh"
|
|---|
| 48 | #include "G4VPDigitIO.hh"
|
|---|
| 49 | #include "G4VTransactionManager.hh"
|
|---|
| 50 | #include <string>
|
|---|
| 51 |
|
|---|
| 52 | class G4PersistencyCenter;
|
|---|
| 53 |
|
|---|
| 54 | // Class inherited:
|
|---|
| 55 | #include "G4VPersistencyManager.hh"
|
|---|
| 56 |
|
|---|
| 57 | // Class Description:
|
|---|
| 58 | // Manager base class to handle event store and retrieve operation.
|
|---|
| 59 | // Actual persistency implementation should be handled with
|
|---|
| 60 | // derived classes.
|
|---|
| 61 | //
|
|---|
| 62 | // Each persistency package should implement derived classes of
|
|---|
| 63 | // G4VHepMCIO, G4VMCTruthIO, G4VPHitIO, G4VPDigitIO, G4VPEventIO.
|
|---|
| 64 | // Concreate G4PersistencyManager should implement the methods
|
|---|
| 65 | // HepMCIO(), MCTruthIO(), HitIO(), DigitIO() and EventIO() to
|
|---|
| 66 | // return the pointers of the above classes.
|
|---|
| 67 | // G4PersistencyManager handles the sequence of the storing and
|
|---|
| 68 | // retrieving of the persistent object of each type, along with
|
|---|
| 69 | // the transaction handling.
|
|---|
| 70 | //
|
|---|
| 71 | // Retrieving a HepMC event:
|
|---|
| 72 | //
|
|---|
| 73 | // G4PersistencyManager::Retrieve( HepMC::GenEvent*& )
|
|---|
| 74 | // |
|
|---|
| 75 | // | ... StartRead() ...
|
|---|
| 76 | // |
|
|---|
| 77 | // | ... HepMCIO()->Retrieve() ...
|
|---|
| 78 | // |
|
|---|
| 79 | // | ... Commit() ...
|
|---|
| 80 | // V
|
|---|
| 81 | //
|
|---|
| 82 | // Storing a Geant4 event:
|
|---|
| 83 | //
|
|---|
| 84 | // G4PersistencyManager::Store( G4Pevent* )
|
|---|
| 85 | // |
|
|---|
| 86 | // | ... StartUpdate() ...
|
|---|
| 87 | // |
|
|---|
| 88 | // | ... HepMCIO()->Store( HepMC event ) ...
|
|---|
| 89 | // |
|
|---|
| 90 | // | ... MCTruthIO()->Store( MCTruth event ) ...
|
|---|
| 91 | // |
|
|---|
| 92 | // | ... HitIO()->Store( hit_collection_of_event ) ...
|
|---|
| 93 | // |
|
|---|
| 94 | // | ... DigitIO()->Store( digit_collection_of_event ) ...
|
|---|
| 95 | // |
|
|---|
| 96 | // | ... EventIO()->Store( event with hits and digits ) ...
|
|---|
| 97 | // |
|
|---|
| 98 | // | ... Commit() ...
|
|---|
| 99 | // V
|
|---|
| 100 | //
|
|---|
| 101 | // Retrieving a Geant event:
|
|---|
| 102 | //
|
|---|
| 103 | // G4PersistencyManager::Retrieve( event )
|
|---|
| 104 | // |
|
|---|
| 105 | // | ... StartRead() ...
|
|---|
| 106 | // |
|
|---|
| 107 | // | ... EventIO()->Retrieve( event ) ...
|
|---|
| 108 | // |
|
|---|
| 109 | // | ... Commit() ...
|
|---|
| 110 | // V
|
|---|
| 111 | //
|
|---|
| 112 | // Hit collection and digit collection of each detector component
|
|---|
| 113 | // should be handled by detector specific I/O manager, which
|
|---|
| 114 | // should be registered to the G4PersistencyCenter with
|
|---|
| 115 | // AddHCIOmanager() and AddDCIOmanager(). Usually this is done
|
|---|
| 116 | // through a command
|
|---|
| 117 | //
|
|---|
| 118 | // /Persistency/Store/Using/HitIO <detector_io_manager_name>
|
|---|
| 119 | //
|
|---|
| 120 | // which is handled by G4PersistencyCenterMessenger.
|
|---|
| 121 | //
|
|---|
| 122 | // A static template declaration of G4HCIOentryT<class> must be
|
|---|
| 123 | // implementated for each I/O manager.
|
|---|
| 124 |
|
|---|
| 125 | class G4PersistencyManager
|
|---|
| 126 | : public G4VPersistencyManager
|
|---|
| 127 | {
|
|---|
| 128 | friend class G4PersistencyCenter;
|
|---|
| 129 |
|
|---|
| 130 | public: // With description
|
|---|
| 131 | G4PersistencyManager(G4PersistencyCenter* pc, std::string n);
|
|---|
| 132 | // Constructor
|
|---|
| 133 |
|
|---|
| 134 | virtual ~G4PersistencyManager();
|
|---|
| 135 | // Destructor
|
|---|
| 136 |
|
|---|
| 137 | public: // With description
|
|---|
| 138 | virtual G4PersistencyManager* Create() {return 0;};
|
|---|
| 139 | // Create a new persistency manager. To be used by G4PersistencyManagerT<>.
|
|---|
| 140 |
|
|---|
| 141 | std::string GetName() {return nameMgr;};
|
|---|
| 142 | // Get the name of persistency manager
|
|---|
| 143 |
|
|---|
| 144 | virtual G4VPEventIO* EventIO() { return 0; };
|
|---|
| 145 | // Returns the current event I/O handling manager
|
|---|
| 146 | // Each derived class should return the pointer of actual manager.
|
|---|
| 147 |
|
|---|
| 148 | virtual G4VPHitIO* HitIO() { return 0; };
|
|---|
| 149 | // Returns the current hit I/O handling manager
|
|---|
| 150 | // Each derived class should return the pointer of actual manager.
|
|---|
| 151 |
|
|---|
| 152 | virtual G4VPDigitIO* DigitIO() { return 0; };
|
|---|
| 153 | // Returns the current digit I/O handling manager
|
|---|
| 154 | // Each derived class should return the pointer of actual manager.
|
|---|
| 155 | #ifndef WIN32
|
|---|
| 156 | #ifdef G4LIB_USE_HEPMC
|
|---|
| 157 | virtual G4VHepMCIO* HepMCIO() { return 0; };
|
|---|
| 158 | // Returns the current HepMC I/O handling manager
|
|---|
| 159 | // Each derived class should return the pointer of actual manager.
|
|---|
| 160 |
|
|---|
| 161 | virtual G4VMCTruthIO* MCTruthIO() { return 0; };
|
|---|
| 162 | // Returns the current MCTruth I/O handling manager
|
|---|
| 163 | // Each derived class should return the pointer of actual manager.
|
|---|
| 164 | #endif
|
|---|
| 165 | #endif
|
|---|
| 166 | virtual G4VTransactionManager* TransactionManager() { return 0; };
|
|---|
| 167 | // Returns the current transaction manager
|
|---|
| 168 | // Each derived class should return the pointer of actual manager.
|
|---|
| 169 |
|
|---|
| 170 | virtual void Initialize() {};
|
|---|
| 171 | // Initialize the persistency package.
|
|---|
| 172 | // Each derived class should implement the acutal initialization sequence.
|
|---|
| 173 |
|
|---|
| 174 | void SetVerboseLevel(int v);
|
|---|
| 175 | // Set verbose level.
|
|---|
| 176 |
|
|---|
| 177 | G4bool Store(const G4Event* evt);
|
|---|
| 178 | // Store the G4Event and its associated objects
|
|---|
| 179 |
|
|---|
| 180 | G4bool Retrieve(G4Event*& evt);
|
|---|
| 181 | // Retrieve the G4Event and its associated objects
|
|---|
| 182 | #ifndef WIN32
|
|---|
| 183 | #ifdef G4LIB_USE_HEPMC
|
|---|
| 184 | G4bool Retrieve(HepMC::GenEvent*& evt, int id=-1);
|
|---|
| 185 | // retrieves HepMC GenEvent and its associated object.
|
|---|
| 186 | // To be used by generator/HepMCObjyReader.
|
|---|
| 187 | #endif
|
|---|
| 188 | #endif
|
|---|
| 189 | G4bool Store(const G4Run*) {return false;};
|
|---|
| 190 | // not used
|
|---|
| 191 |
|
|---|
| 192 | G4bool Retrieve(G4Run*&) {return false;};
|
|---|
| 193 | // not used
|
|---|
| 194 |
|
|---|
| 195 | G4bool Store(const G4VPhysicalVolume*) {return false;};
|
|---|
| 196 | // not used
|
|---|
| 197 |
|
|---|
| 198 | G4bool Retrieve(G4VPhysicalVolume*&) {return false;};
|
|---|
| 199 | // not used
|
|---|
| 200 |
|
|---|
| 201 | protected:
|
|---|
| 202 | static G4PersistencyManager* GetPersistencyManager();
|
|---|
| 203 | // Get the instance of persistency manager
|
|---|
| 204 |
|
|---|
| 205 | protected:
|
|---|
| 206 | G4PersistencyCenter* f_pc;
|
|---|
| 207 | int m_verbose;
|
|---|
| 208 |
|
|---|
| 209 | private:
|
|---|
| 210 | std::string nameMgr;
|
|---|
| 211 | // GeneratorCenter* f_GenCenter;
|
|---|
| 212 | // G4MCTManager* f_MCTman;
|
|---|
| 213 | G4bool f_is_initialized;
|
|---|
| 214 |
|
|---|
| 215 | }; // End of class G4PersistencyManager
|
|---|
| 216 |
|
|---|
| 217 | #endif
|
|---|
| 218 |
|
|---|