Geant4  10.01.p01
G4PersistencyManager.hh
Go to the documentation of this file.
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 #include "G4VMCTruthIO.hh"
37 #include "G4HCIOcatalog.hh"
38 #include "G4DCIOcatalog.hh"
39 #include "G4VPEventIO.hh"
40 #include "G4VPHitIO.hh"
41 #include "G4VPDigitIO.hh"
42 #include "G4VTransactionManager.hh"
43 #include <string>
44 
46 
47 // Class inherited:
48 #include "G4VPersistencyManager.hh"
49 
50 // Class Description:
51 // Manager base class to handle event store and retrieve operation.
52 // Actual persistency implementation should be handled with
53 // derived classes.
54 //
55 // Each persistency package should implement derived classes of
56 // G4VHepMCIO, G4VMCTruthIO, G4VPHitIO, G4VPDigitIO, G4VPEventIO.
57 // Concreate G4PersistencyManager should implement the methods
58 // HepMCIO(), MCTruthIO(), HitIO(), DigitIO() and EventIO() to
59 // return the pointers of the above classes.
60 // G4PersistencyManager handles the sequence of the storing and
61 // retrieving of the persistent object of each type, along with
62 // the transaction handling.
63 //
64 // Retrieving a HepMC event:
65 //
66 // G4PersistencyManager::Retrieve( HepMC::GenEvent*& )
67 // |
68 // | ... StartRead() ...
69 // |
70 // | ... Commit() ...
71 // V
72 //
73 // Storing a Geant4 event:
74 //
75 // G4PersistencyManager::Store( G4Pevent* )
76 // |
77 // | ... StartUpdate() ...
78 // |
79 // | ... MCTruthIO()->Store( MCTruth event ) ...
80 // |
81 // | ... HitIO()->Store( hit_collection_of_event ) ...
82 // |
83 // | ... DigitIO()->Store( digit_collection_of_event ) ...
84 // |
85 // | ... EventIO()->Store( event with hits and digits ) ...
86 // |
87 // | ... Commit() ...
88 // V
89 //
90 // Retrieving a Geant event:
91 //
92 // G4PersistencyManager::Retrieve( event )
93 // |
94 // | ... StartRead() ...
95 // |
96 // | ... EventIO()->Retrieve( event ) ...
97 // |
98 // | ... Commit() ...
99 // V
100 //
101 // Hit collection and digit collection of each detector component
102 // should be handled by detector specific I/O manager, which
103 // should be registered to the G4PersistencyCenter with
104 // AddHCIOmanager() and AddDCIOmanager(). Usually this is done
105 // through a command
106 //
107 // /Persistency/Store/Using/HitIO <detector_io_manager_name>
108 //
109 // which is handled by G4PersistencyCenterMessenger.
110 //
111 // A static template declaration of G4HCIOentryT<class> must be
112 // implementated for each I/O manager.
113 
115  : public G4VPersistencyManager
116 {
117  friend class G4PersistencyCenter;
118 
119  public: // With description
121  // Constructor
122 
123  virtual ~G4PersistencyManager();
124  // Destructor
125 
126  public: // With description
127  virtual G4PersistencyManager* Create() {return 0;};
128  // Create a new persistency manager. To be used by G4PersistencyManagerT<>.
129 
130  std::string GetName() {return nameMgr;};
131  // Get the name of persistency manager
132 
133  virtual G4VPEventIO* EventIO() { return 0; };
134  // Returns the current event I/O handling manager
135  // Each derived class should return the pointer of actual manager.
136 
137  virtual G4VPHitIO* HitIO() { return 0; };
138  // Returns the current hit I/O handling manager
139  // Each derived class should return the pointer of actual manager.
140 
141  virtual G4VPDigitIO* DigitIO() { return 0; };
142  // Returns the current digit I/O handling manager
143  // Each derived class should return the pointer of actual manager.
144 
145  virtual G4VMCTruthIO* MCTruthIO() { return 0; };
146  // Returns the current MCTruth I/O handling manager
147  // Each derived class should return the pointer of actual manager.
148 
149  virtual G4VTransactionManager* TransactionManager() { return 0; };
150  // Returns the current transaction manager
151  // Each derived class should return the pointer of actual manager.
152 
153  virtual void Initialize() {};
154  // Initialize the persistency package.
155  // Each derived class should implement the acutal initialization sequence.
156 
157  void SetVerboseLevel(int v);
158  // Set verbose level.
159 
160  G4bool Store(const G4Event* evt);
161  // Store the G4Event and its associated objects
162 
163  G4bool Retrieve(G4Event*& evt);
164  // Retrieve the G4Event and its associated objects
165 
166  G4bool Store(const G4Run*) {return false;};
167  // not used
168 
169  G4bool Retrieve(G4Run*&) {return false;};
170  // not used
171 
172  G4bool Store(const G4VPhysicalVolume*) {return false;};
173  // not used
174 
175  G4bool Retrieve(G4VPhysicalVolume*&) {return false;};
176  // not used
177 
178  protected:
180  // Get the instance of persistency manager
181 
182  protected:
185 
186  private:
187  std::string nameMgr;
189 
190 }; // End of class G4PersistencyManager
191 
192 #endif
193 
static G4PersistencyManager * GetPersistencyManager()
G4bool Store(const G4Run *)
G4bool Store(const G4Event *evt)
virtual G4VPDigitIO * DigitIO()
G4bool Retrieve(G4VPhysicalVolume *&)
virtual G4VMCTruthIO * MCTruthIO()
G4bool Store(const G4VPhysicalVolume *)
bool G4bool
Definition: G4Types.hh:79
Definition: G4Run.hh:46
const G4int n
static const double pc
Definition: G4SIunits.hh:118
virtual G4PersistencyManager * Create()
virtual G4VPEventIO * EventIO()
virtual G4VPHitIO * HitIO()
G4PersistencyCenter * f_pc
G4PersistencyManager(G4PersistencyCenter *pc, std::string n)
G4bool Retrieve(G4Event *&evt)
virtual G4VTransactionManager * TransactionManager()