Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/persistency/mctruth/src/G4PersistencyManager.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /persistency/mctruth/src/G4PersistencyManager.cc (Version 11.3.0) and /persistency/mctruth/src/G4PersistencyManager.cc (Version 9.2.p1)


  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 // G4PersistencyManager implementation         <<  26 // File: G4PersistencyManager.cc
 27 //                                                 27 //
 28 // Author: Youhei Morita, 17.07.2001           <<  28 // History:
 29 // ------------------------------------------- <<  29 //   01.07.17  Youhei Morita  Initial creation (with "fadsclass")
 30                                                    30 
 31 #include "G4PersistencyManager.hh"                 31 #include "G4PersistencyManager.hh"
 32                                                    32 
                                                   >>  33 // Addtional Include:
 33 #include <iomanip>                                 34 #include <iomanip>
 34 #include "G4PersistencyCenter.hh"                  35 #include "G4PersistencyCenter.hh"
 35                                                    36 
 36 // ------------------------------------------- <<  37 // Implementation of Constructor #1
 37 G4PersistencyManager::G4PersistencyManager(G4P <<  38 G4PersistencyManager::G4PersistencyManager(G4PersistencyCenter* pc, std::string n)
 38                                            con <<  39  : f_pc(pc), nameMgr(n), f_is_initialized(false)
 39   : f_pc(ptc)                                  << 
 40   , nameMgr(n)                                 << 
 41 {                                                  40 {
 42   m_verbose = f_pc->VerboseLevel();                41   m_verbose = f_pc->VerboseLevel();
                                                   >>  42 
                                                   >>  43   // G4cout << "G4PersistencyManager is constructed with name \"" << nameMgr
                                                   >>  44   //        << "\", " << this << ", verbose = " << m_verbose << G4endl;
                                                   >>  45 
                                                   >>  46   // f_GenCenter = GeneratorCenter::GetGeneratorCenter();
                                                   >>  47   // f_MCTman    = G4MCTManager::GetPointer();
 43 }                                                  48 }
 44                                                    49 
 45 // ------------------------------------------- <<  50 // Implementation of Destructor #1
 46 G4PersistencyManager::~G4PersistencyManager()      51 G4PersistencyManager::~G4PersistencyManager()
 47 {                                              <<  52 {}
 48 }                                              << 
 49                                                    53 
 50 // ------------------------------------------- <<  54 // Implementation of GetPersistencyManager
 51 G4PersistencyManager* G4PersistencyManager::Ge     55 G4PersistencyManager* G4PersistencyManager::GetPersistencyManager()
 52 {                                                  56 {
 53   return G4PersistencyCenter::GetPersistencyCe <<  57   return G4PersistencyCenter::GetPersistencyCenter()->CurrentPersistencyManager();
 54     ->CurrentPersistencyManager();             << 
 55 }                                                  58 }
 56                                                    59 
 57 // ------------------------------------------- <<  60 // Implementation of SetVerboseLevel
 58 void G4PersistencyManager::SetVerboseLevel(G4i <<  61 void G4PersistencyManager::SetVerboseLevel(int v)
 59 {                                                  62 {
 60   m_verbose = v;                                   63   m_verbose = v;
 61   if(m_verbose > 2)                            <<  64   if ( m_verbose > 2 ) {
 62   {                                            << 
 63     G4cout << "G4PersistencyManager[\"" << nam     65     G4cout << "G4PersistencyManager[\"" << nameMgr << "\"," << this
 64            << "]: verbose level is set to " << <<  66            << "]: verbose level is set to " << m_verbose << "."
                                                   >>  67            << G4endl;
 65   }                                                68   }
 66   if(EventIO() != nullptr)                     <<  69   if (   EventIO() != 0 )   EventIO()->SetVerboseLevel(m_verbose);
 67     EventIO()->SetVerboseLevel(m_verbose);     <<  70 #ifndef WIN32
 68   if(MCTruthIO() != nullptr)                   <<  71 #ifdef G4LIB_USE_HEPMC
 69     MCTruthIO()->SetVerboseLevel(m_verbose);   <<  72   if (   HepMCIO() != 0 )   HepMCIO()->SetVerboseLevel(m_verbose);
 70   if(HitIO() != nullptr)                       <<  73   if ( MCTruthIO() != 0 ) MCTruthIO()->SetVerboseLevel(m_verbose);
 71     HitIO()->SetVerboseLevel(m_verbose);       <<  74 #endif
 72   if(DigitIO() != nullptr)                     <<  75 #endif
 73     DigitIO()->SetVerboseLevel(m_verbose);     <<  76   if (     HitIO() != 0 )     HitIO()->SetVerboseLevel(m_verbose);
 74   if(TransactionManager() != nullptr)          <<  77   if (   DigitIO() != 0 )   DigitIO()->SetVerboseLevel(m_verbose);
 75     TransactionManager()->SetVerboseLevel(m_ve <<  78   if (TransactionManager() != 0) TransactionManager()->SetVerboseLevel(m_verbose);
 76                                                    79 
 77   G4int i;                                     <<  80   size_t i;
 78                                                    81 
 79   G4HCIOcatalog* hcio = G4HCIOcatalog::GetHCIO     82   G4HCIOcatalog* hcio = G4HCIOcatalog::GetHCIOcatalog();
 80   if(hcio != nullptr)                          <<  83   if ( hcio != 0 ) {
 81   {                                            << 
 82     hcio->SetVerboseLevel(m_verbose);              84     hcio->SetVerboseLevel(m_verbose);
 83     for(i = 0; i < (G4int)hcio->NumberOfHCIOma <<  85     for ( i = 0; i < hcio->NumberOfHCIOmanager(); i++ ) {
 84     {                                          << 
 85       hcio->GetHCIOmanager(i)->SetVerboseLevel     86       hcio->GetHCIOmanager(i)->SetVerboseLevel(m_verbose);
 86     }                                              87     }
 87   }                                                88   }
 88   G4DCIOcatalog* dcio = G4DCIOcatalog::GetDCIO     89   G4DCIOcatalog* dcio = G4DCIOcatalog::GetDCIOcatalog();
 89   if(dcio != nullptr)                          <<  90   if ( dcio != 0 ) {
 90   {                                            << 
 91     dcio->SetVerboseLevel(m_verbose);              91     dcio->SetVerboseLevel(m_verbose);
 92     for(i = 0; i < (G4int)dcio->NumberOfDCIOma <<  92     for ( i = 0; i < dcio->NumberOfDCIOmanager(); i++ ) {
 93     {                                          << 
 94       dcio->GetDCIOmanager(i)->SetVerboseLevel     93       dcio->GetDCIOmanager(i)->SetVerboseLevel(m_verbose);
 95     }                                              94     }
 96   }                                                95   }
 97 }                                                  96 }
 98                                                    97 
 99 // ------------------------------------------- <<  98 // Implementation of Store
100 G4bool G4PersistencyManager::Store(const G4Eve     99 G4bool G4PersistencyManager::Store(const G4Event* evt)
101 {                                                 100 {
102   if(m_verbose > 2)                            << 101   if ( m_verbose > 2 ) {
103   {                                            << 
104     G4cout << "G4PersistencyManager::Store() i    102     G4cout << "G4PersistencyManager::Store() is called for event# "
105            << evt->GetEventID() << "." << G4en    103            << evt->GetEventID() << "." << G4endl;
106   }                                               104   }
107                                                   105 
108   if(TransactionManager() == nullptr)          << 106   if ( TransactionManager() == 0 ) return true;
109     return true;                               << 
110                                                   107 
111   G4bool is_store = f_pc->CurrentStoreMode("MC << 108   G4bool is_store = f_pc->CurrentStoreMode("HepMC")   != kOff ||
112                     f_pc->CurrentStoreMode("Hi << 109                     f_pc->CurrentStoreMode("MCTruth") != kOff ||
113                     f_pc->CurrentStoreMode("Di << 110                     f_pc->CurrentStoreMode("Hits")    != kOff ||
                                                   >> 111                     f_pc->CurrentStoreMode("Digits")  != kOff;
114                                                   112 
115   if(!is_store)                                << 113   if ( ! is_store ) return true;
116     return true;                               << 
117                                                   114 
118   // Call package dependent Initialize()          115   // Call package dependent Initialize()
119   //                                              116   //
120   if(!f_is_initialized)                        << 117   if ( ! f_is_initialized ) {
121   {                                            << 
122     f_is_initialized = true;                      118     f_is_initialized = true;
123     if(m_verbose > 1)                          << 119     if ( m_verbose > 1 ) {
124     {                                          << 
125       G4cout << "G4PersistencyManager:: Initia    120       G4cout << "G4PersistencyManager:: Initializing Transaction ... "
126              << G4endl;                           121              << G4endl;
127     }                                             122     }
128     Initialize();                                 123     Initialize();
129   }                                               124   }
130                                                   125 
131   G4bool st1 = true, st2 = true;                  126   G4bool st1 = true, st2 = true;
132                                                   127 
133   // Start event IO transaction                   128   // Start event IO transaction
134   //                                              129   //
135   if(TransactionManager()->StartUpdate())      << 130   if ( TransactionManager()->StartUpdate() ) {
136   {                                            << 131     if ( m_verbose > 2 ) {
137     if(m_verbose > 2)                          << 
138     {                                          << 
139       G4cout << "G4PersistencyManager: Update     132       G4cout << "G4PersistencyManager: Update transaction started for event#"
140              << evt->GetEventID() << "." << G4    133              << evt->GetEventID() << "." << G4endl;
141     }                                             134     }
142   }                                            << 135   } else {
143   else                                         << 
144   {                                            << 
145     G4cerr << "TransactionManager::Store(G4Eve    136     G4cerr << "TransactionManager::Store(G4Event) - StartUpdate() failed."
146            << G4endl;                             137            << G4endl;
147     return false;                                 138     return false;
148   }                                               139   }
149                                                   140 
150   G4String file;                               << 141   std::string file;
151   G4String obj;                                << 142   std::string obj;
                                                   >> 143 
                                                   >> 144 #ifndef WIN32
                                                   >> 145 #ifdef G4LIB_USE_HEPMC
                                                   >> 146 
                                                   >> 147   G4bool sthep = true, stmct = true, st3 = true;
152                                                   148 
153   G4bool stmct = true, st3 = true;             << 149   // Store HepMC event
                                                   >> 150   //
                                                   >> 151   obj = "HepMC";
                                                   >> 152   HepMC::GenEvent* hepevt = 0;
                                                   >> 153   if ( f_pc->CurrentStoreMode(obj) == kOn ) {
                                                   >> 154 
                                                   >> 155     //  Note: This part of code will not be activated until a method
                                                   >> 156     //  to obtain the current pointer of HepMC::GenEvent* become available.
                                                   >> 157 
                                                   >> 158     // if ( (hepevt = f_GenCenter->GetGenEvent()) !=0 ) {
                                                   >> 159     if ( hepevt !=0 ) {
                                                   >> 160 
                                                   >> 161       file = f_pc->CurrentWriteFile(obj);
                                                   >> 162       if ( TransactionManager()->SelectWriteFile(obj, file) ) {
                                                   >> 163         sthep = HepMCIO()->Store(hepevt);
                                                   >> 164         if ( sthep && m_verbose > 1 ) {
                                                   >> 165           G4cout << " -- File : " << file << " -- Event# "
                                                   >> 166                  << evt->GetEventID() << " -- HepMC Stored." << G4endl;
                                                   >> 167         }
                                                   >> 168       } else {
                                                   >> 169         sthep = false;
                                                   >> 170       }
                                                   >> 171     } // end of if ( hepevt != 0 )
                                                   >> 172   } else { // recycle or off
                                                   >> 173     // hepevt= f_GenCenter-> GetGenEvent();
                                                   >> 174   }
154                                                   175 
155   // Store MCTruth event                          176   // Store MCTruth event
156   //                                              177   //
157   obj                = "MCTruth";              << 178   obj = "MCTruth";
158   G4MCTEvent* mctevt = nullptr;                << 179   G4MCTEvent* mctevt = 0;
159   if(f_pc->CurrentStoreMode(obj) == kOn)       << 180   if ( f_pc->CurrentStoreMode(obj) == kOn ) {
160   {                                            << 181 
161     //  Note: This part of code will not be ac    182     //  Note: This part of code will not be activated until a method
162     //  to obtain the current pointer of G4MCT    183     //  to obtain the current pointer of G4MCTEvent* become available.
163                                                   184 
164     // if ( (mctevt = f_MCTman->GetCurrentEven    185     // if ( (mctevt = f_MCTman->GetCurrentEvent()) != 0 ) {
165     if(mctevt != nullptr)                      << 186     if ( mctevt != 0 ) {
166     {                                          << 
167       file = f_pc->CurrentWriteFile(obj);         187       file = f_pc->CurrentWriteFile(obj);
168       if(TransactionManager()->SelectWriteFile << 188       if ( TransactionManager()->SelectWriteFile(obj, file) ) {
169       {                                        << 
170         stmct = MCTruthIO()->Store(mctevt);       189         stmct = MCTruthIO()->Store(mctevt);
171         if(stmct && m_verbose > 1)             << 190         if ( stmct && m_verbose > 1 ) {
172         {                                      << 191           G4cout << " -- File : " << file << " -- Event# "
173           G4cout << " -- File : " << file << " << 192                  << evt->GetEventID() << " -- G4MCTEvent Stored." << G4endl;
174                  << " -- G4MCTEvent Stored." < << 
175         }                                         193         }
176       }                                        << 194       } else {
177       else                                     << 
178       {                                        << 
179         stmct = false;                            195         stmct = false;
180       }                                           196       }
181     }  // end of if ( mctevt != nullptr )      << 197     } // end of if ( mctevt != 0 )
182   }                                               198   }
183                                                   199 
                                                   >> 200 #endif
                                                   >> 201 #endif
                                                   >> 202 
184   // Store hits collection                        203   // Store hits collection
185   //                                              204   //
186   obj = "Hits";                                   205   obj = "Hits";
187   if(f_pc->CurrentStoreMode(obj) == kOn)       << 206   if ( f_pc->CurrentStoreMode(obj) == kOn ) {
188   {                                            << 207     if ( G4HCofThisEvent* hc = evt->GetHCofThisEvent() ) {
189     if(G4HCofThisEvent* hc = evt->GetHCofThisE << 
190     {                                          << 
191       file = f_pc->CurrentWriteFile(obj);         208       file = f_pc->CurrentWriteFile(obj);
192       if(TransactionManager()->SelectWriteFile << 209       if ( TransactionManager()->SelectWriteFile(obj, file) ) {
193       {                                        << 
194         st1 = HitIO()->Store(hc);                 210         st1 = HitIO()->Store(hc);
195         if(st1 && m_verbose > 1)               << 211         if ( st1 && m_verbose > 1 ) {
196         {                                      << 212           G4cout << " -- File : " << file << " -- Event# "
197           G4cout << " -- File : " << file << " << 213                  << evt->GetEventID()
198                  << " -- Hit Collections Store    214                  << " -- Hit Collections Stored." << G4endl;
199         }                                         215         }
200       }                                        << 216       } else {
201       else                                     << 
202       {                                        << 
203         st1 = false;                              217         st1 = false;
204       }                                           218       }
205     }                                             219     }
206   }                                               220   }
207                                                   221 
208   // Store digits collection                      222   // Store digits collection
209   //                                              223   //
210   obj = "Digits";                                 224   obj = "Digits";
211   if(f_pc->CurrentStoreMode(obj) == kOn)       << 225   if ( f_pc->CurrentStoreMode(obj) == kOn ) {
212   {                                            << 226     if ( G4DCofThisEvent* dc = evt->GetDCofThisEvent() ) {
213     if(G4DCofThisEvent* dc = evt->GetDCofThisE << 
214     {                                          << 
215       file = f_pc->CurrentWriteFile(obj);         227       file = f_pc->CurrentWriteFile(obj);
216       if(TransactionManager()->SelectWriteFile << 228       if ( TransactionManager()->SelectWriteFile(obj, file) ) {
217       {                                        << 
218         st2 = DigitIO()->Store(dc);               229         st2 = DigitIO()->Store(dc);
219         if(st2 && m_verbose > 1)               << 230         if ( st2 && m_verbose > 1 ) {
220         {                                      << 231           G4cout << " -- File : " << file << " -- Event# "
221           G4cout << " -- File : " << file << " << 232                  << evt->GetEventID()
222                  << " -- Digit Collections Sto    233                  << " -- Digit Collections Stored." << G4endl;
223         }                                         234         }
224       }                                        << 235       } else {
225       else                                     << 
226       {                                        << 
227         st2 = false;                              236         st2 = false;
228       }                                           237       }
229     }                                             238     }
230   }                                               239   }
231                                                   240 
                                                   >> 241 #ifndef WIN32
                                                   >> 242 #ifdef G4LIB_USE_HEPMC
                                                   >> 243 
232   // Store this G4EVENT                           244   // Store this G4EVENT
233   //                                              245   //
234   if(mctevt != 0 || evt != 0)                  << 246   if ( hepevt!=0 || mctevt!=0 || evt!=0 ) {
235   {                                            << 247     obj = "Hits";
236     obj  = "Hits";                             << 
237     file = f_pc->CurrentWriteFile(obj);           248     file = f_pc->CurrentWriteFile(obj);
238     if(TransactionManager()->SelectWriteFile(o << 249     if ( TransactionManager()->SelectWriteFile(obj, file) ) {
239     {                                          << 250       // st3 = EventIO()->Store(hepevt, mctevt, evt);
240       st3 = EventIO()->Store(evt);             << 251       st3 = EventIO()->Store(hepevt, evt);
241       if(st3 && m_verbose > 1)                 << 252       if ( st3 && m_verbose > 1 ) {
242       {                                        << 
243         G4cout << " -- File name: " << f_pc->C    253         G4cout << " -- File name: " << f_pc->CurrentWriteFile("Hits")
244                << " -- Event# " << evt->GetEve << 254                << " -- Event# "  << evt->GetEventID()
245                << " -- G4Pevent is Stored." <<    255                << " -- G4Pevent is Stored." << G4endl;
246       }                                           256       }
247     }                                          << 257     } else {
248     else                                       << 
249     {                                          << 
250       st3 = false;                                258       st3 = false;
251     }                                             259     }
252   }                                               260   }
                                                   >> 261   
                                                   >> 262   G4bool st = sthep && stmct && st1 && st2 && st3;
                                                   >> 263 
                                                   >> 264 #else
                                                   >> 265 
                                                   >> 266   G4bool st = st1 && st2;
                                                   >> 267 
                                                   >> 268 #endif
                                                   >> 269 
                                                   >> 270 #else
253                                                   271 
254   G4bool st = stmct && st1 && st2 && st3;      << 272   G4bool st = st1 && st2;
255                                                   273 
256   if(st)                                       << 274 #endif
257   {                                            << 275 
                                                   >> 276   if ( st ) {
258     TransactionManager()->Commit();               277     TransactionManager()->Commit();
259     if(m_verbose > 0)                          << 278     if ( m_verbose > 0 )
260       G4cout << "G4PersistencyManager: event#  << 279       G4cout << "G4PersistencyManager: event# "
261              << " is stored." << G4endl;       << 280              << evt->GetEventID() << " is stored." << G4endl;
262   }                                            << 281   } else {
263   else                                         << 
264   {                                            << 
265     G4cerr << "G4PersistencyManager::Store(G4E    282     G4cerr << "G4PersistencyManager::Store(G4Event) - Transaction aborted."
266            << G4endl;                             283            << G4endl;
267     TransactionManager()->Abort();                284     TransactionManager()->Abort();
268   }                                               285   }
269                                                   286 
270   return st;                                      287   return st;
271 }                                                 288 }
272                                                   289 
273 // ------------------------------------------- << 290 // Implementation of Retrieve
274 G4bool G4PersistencyManager::Retrieve(G4Event*    291 G4bool G4PersistencyManager::Retrieve(G4Event*& evt)
275 {                                                 292 {
276   if(m_verbose > 2)                            << 293   if ( m_verbose > 2 ) {
277   {                                            << 294     G4cout << "G4PersistencyManager::Retrieve(G4Event*&) is called."
278     G4cout << "G4PersistencyManager::Retrieve( << 295            << G4endl;
279   }                                               296   }
280                                                   297 
281   if(TransactionManager() == nullptr)          << 298   if ( TransactionManager() == 0 ) return true;
282     return true;                               << 
283                                                   299 
284   if(f_pc->CurrentRetrieveMode("MCTruth") == f << 300   if ( f_pc->CurrentRetrieveMode("HepMC")   == false &&
285      f_pc->CurrentRetrieveMode("Hits") == fals << 301        f_pc->CurrentRetrieveMode("MCTruth") == false &&
286      f_pc->CurrentRetrieveMode("Digits") == fa << 302        f_pc->CurrentRetrieveMode("Hits")    == false &&
287   {                                            << 303        f_pc->CurrentRetrieveMode("Digits")  == false ) {
288     return true;                                  304     return true;
289   }                                               305   }
290                                                   306 
291   // Call package dependent Initialize()          307   // Call package dependent Initialize()
292   //                                              308   //
293   if(!f_is_initialized)                        << 309   if ( ! f_is_initialized ) {
294   {                                            << 
295     f_is_initialized = true;                      310     f_is_initialized = true;
296     if(m_verbose > 1)                          << 311     if ( m_verbose > 1 ) {
297     {                                          << 
298       G4cout << "G4PersistencyManager:: Initia    312       G4cout << "G4PersistencyManager:: Initializing Transaction ... "
299              << G4endl;                           313              << G4endl;
300     }                                             314     }
301     Initialize();                                 315     Initialize();
302   }                                               316   }
303                                                   317 
304   // Start event IO transaction                   318   // Start event IO transaction
305   //                                              319   //
306   if(TransactionManager()->StartRead())        << 320   if ( TransactionManager()->StartRead() ) {
307   {                                            << 321     if ( m_verbose > 2 ) {
308     if(m_verbose > 2)                          << 322       G4cout << "G4PersistencyManager: Read transaction started."
309     {                                          << 323              << G4endl;
310       G4cout << "G4PersistencyManager: Read tr << 
311     }                                             324     }
312   }                                            << 325   } else {
313   else                                         << 
314   {                                            << 
315     G4cerr << "TransactionManager::Retrieve(G4    326     G4cerr << "TransactionManager::Retrieve(G4Event) - StartRead() failed."
316            << G4endl;                             327            << G4endl;
317     return false;                                 328     return false;
318   }                                               329   }
319                                                   330 
320   G4bool st = false;                              331   G4bool st = false;
321   G4String file;                               << 332   std::string file;
322                                                   333 
323   // Retrieve a G4EVENT                           334   // Retrieve a G4EVENT
324   //                                              335   //
325   G4String obj = "Hits";                       << 336   std::string obj = "Hits";
326   if(f_pc->CurrentRetrieveMode(obj) == true)   << 337   if ( f_pc->CurrentRetrieveMode(obj) == true ) {
327   {                                            << 
328     file = f_pc->CurrentReadFile(obj);            338     file = f_pc->CurrentReadFile(obj);
329     if(TransactionManager()->SelectReadFile(ob << 339     if ( TransactionManager()->SelectReadFile(obj, file) ) {
330     {                                          << 
331       st = EventIO()->Retrieve(evt);              340       st = EventIO()->Retrieve(evt);
332       if(st && m_verbose > 1)                  << 341       if ( st && m_verbose > 1 ) {
333       {                                        << 342         G4cout << " -- File : " << file << " -- Event# "
334         G4cout << " -- File : " << file << " - << 343                << evt->GetEventID()
335                << " -- G4Event is Retrieved."     344                << " -- G4Event is Retrieved." << G4endl;
336       }                                           345       }
337     }                                          << 346     } else {
338     else                                       << 
339     {                                          << 
340       st = false;                                 347       st = false;
341     }                                             348     }
342   }                                               349   }
343                                                   350 
344   if(st)                                       << 351   if ( st ) {
345   {                                            << 
346     TransactionManager()->Commit();               352     TransactionManager()->Commit();
347   }                                            << 353   } else {
348   else                                         << 
349   {                                            << 
350     G4cerr << "G4PersistencyManager::Retrieve(    354     G4cerr << "G4PersistencyManager::Retrieve() - Transaction aborted."
351            << G4endl;                             355            << G4endl;
352     TransactionManager()->Abort();                356     TransactionManager()->Abort();
353   }                                               357   }
354                                                   358 
355   return st;                                      359   return st;
356 }                                                 360 }
                                                   >> 361 
                                                   >> 362 #ifndef WIN32
                                                   >> 363 #ifdef G4LIB_USE_HEPMC
                                                   >> 364 
                                                   >> 365 // Implementation of Retrieve
                                                   >> 366 G4bool G4PersistencyManager::Retrieve(HepMC::GenEvent*& evt, int id)
                                                   >> 367 {
                                                   >> 368   if ( m_verbose > 2 ) {
                                                   >> 369     G4cout << "G4PersistencyManager::Retrieve(HepMC::GenEvent*&) is called."
                                                   >> 370            << G4endl;
                                                   >> 371   }
                                                   >> 372 
                                                   >> 373   if ( TransactionManager() == 0 ) return true;
                                                   >> 374 
                                                   >> 375   // Call package dependent Initialize()
                                                   >> 376   //
                                                   >> 377   if ( ! f_is_initialized ) {
                                                   >> 378     f_is_initialized = true;
                                                   >> 379     if ( m_verbose > 1 ) {
                                                   >> 380       G4cout << "G4PersistencyManager:: Initializing Transaction ... "
                                                   >> 381              << G4endl;
                                                   >> 382     }
                                                   >> 383     Initialize();
                                                   >> 384   }
                                                   >> 385 
                                                   >> 386   // Start event IO transaction
                                                   >> 387   //
                                                   >> 388   if ( TransactionManager()->StartRead() ) {
                                                   >> 389     if ( m_verbose > 2 ) {
                                                   >> 390       G4cout << "G4PersistencyManager: Read transaction started."
                                                   >> 391              << G4endl;
                                                   >> 392     }
                                                   >> 393   } else {
                                                   >> 394     G4cerr << "TransactionManager::Retrieve(HepMC) - StartRead() failed."
                                                   >> 395            << G4endl;
                                                   >> 396     return false;
                                                   >> 397   }
                                                   >> 398 
                                                   >> 399   G4bool st = false;
                                                   >> 400   std::string file;
                                                   >> 401 
                                                   >> 402   // Retrieve a HepMC GenEvent
                                                   >> 403   //
                                                   >> 404   std::string obj = "HepMC";
                                                   >> 405   if ( f_pc->CurrentRetrieveMode(obj) == true ) {
                                                   >> 406     file = f_pc->CurrentReadFile(obj);
                                                   >> 407     if ( TransactionManager()->SelectReadFile(obj, file) ) {
                                                   >> 408       st = HepMCIO()->Retrieve(evt, id);
                                                   >> 409       if ( st && m_verbose > 1 ) {
                                                   >> 410         G4cout << " -- File: " << file
                                                   >> 411                << " - Event# " << HepMCIO()->LastEventID()
                                                   >> 412                << " - HepMC event is Retrieved." << G4endl;
                                                   >> 413       }
                                                   >> 414     } else {
                                                   >> 415       st = false;
                                                   >> 416     }
                                                   >> 417   }
                                                   >> 418 
                                                   >> 419   if ( st ) {
                                                   >> 420     TransactionManager()->Commit();
                                                   >> 421   } else {
                                                   >> 422     G4cerr << "G4PersistencyManager::Retrieve(HepMC) - Transaction aborted."
                                                   >> 423            << G4endl;
                                                   >> 424     TransactionManager()->Abort();
                                                   >> 425   }
                                                   >> 426 
                                                   >> 427   return st;
                                                   >> 428 }
                                                   >> 429 #endif
                                                   >> 430 #endif
                                                   >> 431 
                                                   >> 432 // End of G4PersistencyManager.cc
                                                   >> 433 
357                                                   434