G4PersistencyManager Class Reference

#include <G4PersistencyManager.hh>

Inheritance diagram for G4PersistencyManager:

G4VPersistencyManager G4PersistencyManagerT< T >

Public Member Functions

 G4PersistencyManager (G4PersistencyCenter *pc, std::string n)
virtual ~G4PersistencyManager ()
virtual G4PersistencyManagerCreate ()
std::string GetName ()
virtual G4VPEventIOEventIO ()
virtual G4VPHitIOHitIO ()
virtual G4VPDigitIODigitIO ()
virtual G4VMCTruthIOMCTruthIO ()
virtual G4VTransactionManagerTransactionManager ()
virtual void Initialize ()
void SetVerboseLevel (int v)
G4bool Store (const G4Event *evt)
G4bool Retrieve (G4Event *&evt)
G4bool Store (const G4Run *)
G4bool Retrieve (G4Run *&)
G4bool Store (const G4VPhysicalVolume *)
G4bool Retrieve (G4VPhysicalVolume *&)

Static Protected Member Functions

static G4PersistencyManagerGetPersistencyManager ()

Protected Attributes

G4PersistencyCenterf_pc
int m_verbose

Friends

class G4PersistencyCenter

Detailed Description

Definition at line 114 of file G4PersistencyManager.hh.


Constructor & Destructor Documentation

G4PersistencyManager::G4PersistencyManager ( G4PersistencyCenter pc,
std::string  n 
)

Definition at line 38 of file G4PersistencyManager.cc.

References f_pc, m_verbose, and G4PersistencyCenter::VerboseLevel().

00039  : f_pc(ptc), nameMgr(n), f_is_initialized(false)
00040 {
00041   m_verbose = f_pc->VerboseLevel();
00042 }

G4PersistencyManager::~G4PersistencyManager (  )  [virtual]

Definition at line 45 of file G4PersistencyManager.cc.

00046 {}


Member Function Documentation

virtual G4PersistencyManager* G4PersistencyManager::Create (  )  [inline, virtual]

Reimplemented in G4PersistencyManagerT< T >.

Definition at line 127 of file G4PersistencyManager.hh.

Referenced by G4PersistencyCenter::SelectSystem().

00127 {return 0;};

virtual G4VPDigitIO* G4PersistencyManager::DigitIO (  )  [inline, virtual]

Reimplemented in G4PersistencyManagerT< T >.

Definition at line 141 of file G4PersistencyManager.hh.

Referenced by G4PersistencyManagerT< T >::DigitIO(), SetVerboseLevel(), and Store().

00141 { return 0; };

virtual G4VPEventIO* G4PersistencyManager::EventIO (  )  [inline, virtual]

Reimplemented in G4PersistencyManagerT< T >.

Definition at line 133 of file G4PersistencyManager.hh.

Referenced by G4PersistencyManagerT< T >::EventIO(), Retrieve(), SetVerboseLevel(), and Store().

00133 { return 0; };

std::string G4PersistencyManager::GetName (  )  [inline]

Definition at line 130 of file G4PersistencyManager.hh.

Referenced by G4PersistencyManagerT< T >::Create(), and G4PersistencyCenter::RegisterPersistencyManager().

00130 {return nameMgr;};

G4PersistencyManager * G4PersistencyManager::GetPersistencyManager (  )  [static, protected]

Reimplemented from G4VPersistencyManager.

Definition at line 49 of file G4PersistencyManager.cc.

References G4PersistencyCenter::CurrentPersistencyManager(), and G4PersistencyCenter::GetPersistencyCenter().

virtual G4VPHitIO* G4PersistencyManager::HitIO (  )  [inline, virtual]

Reimplemented in G4PersistencyManagerT< T >.

Definition at line 137 of file G4PersistencyManager.hh.

Referenced by G4PersistencyManagerT< T >::HitIO(), SetVerboseLevel(), and Store().

00137 { return 0; };

virtual void G4PersistencyManager::Initialize (  )  [inline, virtual]

Reimplemented in G4PersistencyManagerT< T >.

Definition at line 153 of file G4PersistencyManager.hh.

Referenced by Retrieve(), and Store().

00153 {};

virtual G4VMCTruthIO* G4PersistencyManager::MCTruthIO (  )  [inline, virtual]

Reimplemented in G4PersistencyManagerT< T >.

Definition at line 145 of file G4PersistencyManager.hh.

Referenced by G4PersistencyManagerT< T >::MCTruthIO(), SetVerboseLevel(), and Store().

00145 { return 0; };

G4bool G4PersistencyManager::Retrieve ( G4VPhysicalVolume *&   )  [inline, virtual]

Implements G4VPersistencyManager.

Definition at line 175 of file G4PersistencyManager.hh.

00175 {return false;};

G4bool G4PersistencyManager::Retrieve ( G4Run *&   )  [inline, virtual]

Implements G4VPersistencyManager.

Definition at line 169 of file G4PersistencyManager.hh.

00169 {return false;};

G4bool G4PersistencyManager::Retrieve ( G4Event *&  evt  )  [virtual]

Implements G4VPersistencyManager.

Definition at line 230 of file G4PersistencyManager.cc.

References G4VTransactionManager::Abort(), G4VTransactionManager::Commit(), G4PersistencyCenter::CurrentReadFile(), G4PersistencyCenter::CurrentRetrieveMode(), EventIO(), f_pc, G4cerr, G4cout, G4endl, G4Event::GetEventID(), Initialize(), m_verbose, G4VPEventIO::Retrieve(), and TransactionManager().

00231 {
00232   if ( m_verbose > 2 ) {
00233     G4cout << "G4PersistencyManager::Retrieve(G4Event*&) is called."
00234            << G4endl;
00235   }
00236 
00237   if ( TransactionManager() == 0 ) return true;
00238 
00239   if ( f_pc->CurrentRetrieveMode("MCTruth") == false &&
00240        f_pc->CurrentRetrieveMode("Hits")    == false &&
00241        f_pc->CurrentRetrieveMode("Digits")  == false ) {
00242     return true;
00243   }
00244 
00245   // Call package dependent Initialize()
00246   //
00247   if ( ! f_is_initialized ) {
00248     f_is_initialized = true;
00249     if ( m_verbose > 1 ) {
00250       G4cout << "G4PersistencyManager:: Initializing Transaction ... "
00251              << G4endl;
00252     }
00253     Initialize();
00254   }
00255 
00256   // Start event IO transaction
00257   //
00258   if ( TransactionManager()->StartRead() ) {
00259     if ( m_verbose > 2 ) {
00260       G4cout << "G4PersistencyManager: Read transaction started."
00261              << G4endl;
00262     }
00263   } else {
00264     G4cerr << "TransactionManager::Retrieve(G4Event) - StartRead() failed."
00265            << G4endl;
00266     return false;
00267   }
00268 
00269   G4bool st = false;
00270   std::string file;
00271 
00272   // Retrieve a G4EVENT
00273   //
00274   std::string obj = "Hits";
00275   if ( f_pc->CurrentRetrieveMode(obj) == true ) {
00276     file = f_pc->CurrentReadFile(obj);
00277     if ( TransactionManager()->SelectReadFile(obj, file) ) {
00278       st = EventIO()->Retrieve(evt);
00279       if ( st && m_verbose > 1 ) {
00280         G4cout << " -- File : " << file << " -- Event# "
00281                << evt->GetEventID()
00282                << " -- G4Event is Retrieved." << G4endl;
00283       }
00284     } else {
00285       st = false;
00286     }
00287   }
00288 
00289   if ( st ) {
00290     TransactionManager()->Commit();
00291   } else {
00292     G4cerr << "G4PersistencyManager::Retrieve() - Transaction aborted."
00293            << G4endl;
00294     TransactionManager()->Abort();
00295   }
00296 
00297   return st;
00298 }

void G4PersistencyManager::SetVerboseLevel ( int  v  ) 

Reimplemented in G4PersistencyManagerT< T >.

Definition at line 55 of file G4PersistencyManager.cc.

References DigitIO(), EventIO(), G4cout, G4endl, G4DCIOcatalog::GetDCIOcatalog(), G4DCIOcatalog::GetDCIOmanager(), G4HCIOcatalog::GetHCIOcatalog(), G4HCIOcatalog::GetHCIOmanager(), HitIO(), m_verbose, MCTruthIO(), G4DCIOcatalog::NumberOfDCIOmanager(), G4HCIOcatalog::NumberOfHCIOmanager(), G4VPDigitsCollectionIO::SetVerboseLevel(), G4DCIOcatalog::SetVerboseLevel(), G4VPHitsCollectionIO::SetVerboseLevel(), G4HCIOcatalog::SetVerboseLevel(), G4VTransactionManager::SetVerboseLevel(), G4VPDigitIO::SetVerboseLevel(), G4VPHitIO::SetVerboseLevel(), G4VMCTruthIO::SetVerboseLevel(), G4VPEventIO::SetVerboseLevel(), and TransactionManager().

Referenced by G4PersistencyCenter::SelectSystem(), G4PersistencyManagerT< T >::SetVerboseLevel(), and G4PersistencyCenter::SetVerboseLevel().

00056 {
00057   m_verbose = v;
00058   if ( m_verbose > 2 ) {
00059     G4cout << "G4PersistencyManager[\"" << nameMgr << "\"," << this
00060            << "]: verbose level is set to " << m_verbose << "."
00061            << G4endl;
00062   }
00063   if (   EventIO() != 0 )   EventIO()->SetVerboseLevel(m_verbose);
00064   if ( MCTruthIO() != 0 ) MCTruthIO()->SetVerboseLevel(m_verbose);
00065   if (     HitIO() != 0 )     HitIO()->SetVerboseLevel(m_verbose);
00066   if (   DigitIO() != 0 )   DigitIO()->SetVerboseLevel(m_verbose);
00067   if (TransactionManager() != 0) TransactionManager()->SetVerboseLevel(m_verbose);
00068 
00069   size_t i;
00070 
00071   G4HCIOcatalog* hcio = G4HCIOcatalog::GetHCIOcatalog();
00072   if ( hcio != 0 ) {
00073     hcio->SetVerboseLevel(m_verbose);
00074     for ( i = 0; i < hcio->NumberOfHCIOmanager(); i++ ) {
00075       hcio->GetHCIOmanager(i)->SetVerboseLevel(m_verbose);
00076     }
00077   }
00078   G4DCIOcatalog* dcio = G4DCIOcatalog::GetDCIOcatalog();
00079   if ( dcio != 0 ) {
00080     dcio->SetVerboseLevel(m_verbose);
00081     for ( i = 0; i < dcio->NumberOfDCIOmanager(); i++ ) {
00082       dcio->GetDCIOmanager(i)->SetVerboseLevel(m_verbose);
00083     }
00084   }
00085 }

G4bool G4PersistencyManager::Store ( const G4VPhysicalVolume  )  [inline, virtual]

Implements G4VPersistencyManager.

Definition at line 172 of file G4PersistencyManager.hh.

00172 {return false;};

G4bool G4PersistencyManager::Store ( const G4Run  )  [inline, virtual]

Implements G4VPersistencyManager.

Definition at line 166 of file G4PersistencyManager.hh.

00166 {return false;};

G4bool G4PersistencyManager::Store ( const G4Event evt  )  [virtual]

Implements G4VPersistencyManager.

Definition at line 88 of file G4PersistencyManager.cc.

References G4VTransactionManager::Abort(), G4VTransactionManager::Commit(), G4PersistencyCenter::CurrentStoreMode(), G4PersistencyCenter::CurrentWriteFile(), DigitIO(), EventIO(), f_pc, G4cerr, G4cout, G4endl, G4Event::GetDCofThisEvent(), G4Event::GetEventID(), G4Event::GetHCofThisEvent(), G4INCL::PhysicalConstants::hc, HitIO(), Initialize(), kOff, kOn, m_verbose, MCTruthIO(), G4VPEventIO::Store(), G4VPDigitIO::Store(), G4VPHitIO::Store(), G4VMCTruthIO::Store(), and TransactionManager().

00089 {
00090   if ( m_verbose > 2 ) {
00091     G4cout << "G4PersistencyManager::Store() is called for event# "
00092            << evt->GetEventID() << "." << G4endl;
00093   }
00094 
00095   if ( TransactionManager() == 0 ) return true;
00096 
00097   G4bool is_store = f_pc->CurrentStoreMode("MCTruth") != kOff ||
00098                     f_pc->CurrentStoreMode("Hits")    != kOff ||
00099                     f_pc->CurrentStoreMode("Digits")  != kOff;
00100 
00101   if ( ! is_store ) return true;
00102 
00103   // Call package dependent Initialize()
00104   //
00105   if ( ! f_is_initialized ) {
00106     f_is_initialized = true;
00107     if ( m_verbose > 1 ) {
00108       G4cout << "G4PersistencyManager:: Initializing Transaction ... "
00109              << G4endl;
00110     }
00111     Initialize();
00112   }
00113 
00114   G4bool st1 = true, st2 = true;
00115 
00116   // Start event IO transaction
00117   //
00118   if ( TransactionManager()->StartUpdate() ) {
00119     if ( m_verbose > 2 ) {
00120       G4cout << "G4PersistencyManager: Update transaction started for event#"
00121              << evt->GetEventID() << "." << G4endl;
00122     }
00123   } else {
00124     G4cerr << "TransactionManager::Store(G4Event) - StartUpdate() failed."
00125            << G4endl;
00126     return false;
00127   }
00128 
00129   std::string file;
00130   std::string obj;
00131 
00132   G4bool stmct = true, st3 = true;
00133 
00134   // Store MCTruth event
00135   //
00136   obj = "MCTruth";
00137   G4MCTEvent* mctevt = 0;
00138   if ( f_pc->CurrentStoreMode(obj) == kOn ) {
00139 
00140     //  Note: This part of code will not be activated until a method
00141     //  to obtain the current pointer of G4MCTEvent* become available.
00142 
00143     // if ( (mctevt = f_MCTman->GetCurrentEvent()) != 0 ) {
00144     if ( mctevt != 0 ) {
00145       file = f_pc->CurrentWriteFile(obj);
00146       if ( TransactionManager()->SelectWriteFile(obj, file) ) {
00147         stmct = MCTruthIO()->Store(mctevt);
00148         if ( stmct && m_verbose > 1 ) {
00149           G4cout << " -- File : " << file << " -- Event# "
00150                  << evt->GetEventID() << " -- G4MCTEvent Stored." << G4endl;
00151         }
00152       } else {
00153         stmct = false;
00154       }
00155     } // end of if ( mctevt != 0 )
00156   }
00157 
00158   // Store hits collection
00159   //
00160   obj = "Hits";
00161   if ( f_pc->CurrentStoreMode(obj) == kOn ) {
00162     if ( G4HCofThisEvent* hc = evt->GetHCofThisEvent() ) {
00163       file = f_pc->CurrentWriteFile(obj);
00164       if ( TransactionManager()->SelectWriteFile(obj, file) ) {
00165         st1 = HitIO()->Store(hc);
00166         if ( st1 && m_verbose > 1 ) {
00167           G4cout << " -- File : " << file << " -- Event# "
00168                  << evt->GetEventID()
00169                  << " -- Hit Collections Stored." << G4endl;
00170         }
00171       } else {
00172         st1 = false;
00173       }
00174     }
00175   }
00176 
00177   // Store digits collection
00178   //
00179   obj = "Digits";
00180   if ( f_pc->CurrentStoreMode(obj) == kOn ) {
00181     if ( G4DCofThisEvent* dc = evt->GetDCofThisEvent() ) {
00182       file = f_pc->CurrentWriteFile(obj);
00183       if ( TransactionManager()->SelectWriteFile(obj, file) ) {
00184         st2 = DigitIO()->Store(dc);
00185         if ( st2 && m_verbose > 1 ) {
00186           G4cout << " -- File : " << file << " -- Event# "
00187                  << evt->GetEventID()
00188                  << " -- Digit Collections Stored." << G4endl;
00189         }
00190       } else {
00191         st2 = false;
00192       }
00193     }
00194   }
00195 
00196   // Store this G4EVENT
00197   //
00198   if ( mctevt!=0 || evt!=0 ) {
00199     obj = "Hits";
00200     file = f_pc->CurrentWriteFile(obj);
00201     if ( TransactionManager()->SelectWriteFile(obj, file) ) {
00202       st3 = EventIO()->Store(evt);
00203       if ( st3 && m_verbose > 1 ) {
00204         G4cout << " -- File name: " << f_pc->CurrentWriteFile("Hits")
00205                << " -- Event# "  << evt->GetEventID()
00206                << " -- G4Pevent is Stored." << G4endl;
00207       }
00208     } else {
00209       st3 = false;
00210     }
00211   }
00212   
00213   G4bool st = stmct && st1 && st2 && st3;
00214 
00215   if ( st ) {
00216     TransactionManager()->Commit();
00217     if ( m_verbose > 0 )
00218       G4cout << "G4PersistencyManager: event# "
00219              << evt->GetEventID() << " is stored." << G4endl;
00220   } else {
00221     G4cerr << "G4PersistencyManager::Store(G4Event) - Transaction aborted."
00222            << G4endl;
00223     TransactionManager()->Abort();
00224   }
00225 
00226   return st;
00227 }

virtual G4VTransactionManager* G4PersistencyManager::TransactionManager (  )  [inline, virtual]

Reimplemented in G4PersistencyManagerT< T >.

Definition at line 149 of file G4PersistencyManager.hh.

Referenced by Retrieve(), SetVerboseLevel(), Store(), and G4PersistencyManagerT< T >::TransactionManager().

00149 { return 0; };


Friends And Related Function Documentation

friend class G4PersistencyCenter [friend]

Definition at line 117 of file G4PersistencyManager.hh.


Field Documentation

G4PersistencyCenter* G4PersistencyManager::f_pc [protected]

Definition at line 183 of file G4PersistencyManager.hh.

Referenced by G4PersistencyManagerT< T >::Create(), G4PersistencyManager(), Retrieve(), and Store().

int G4PersistencyManager::m_verbose [protected]

Definition at line 184 of file G4PersistencyManager.hh.

Referenced by G4PersistencyManager(), G4PersistencyManagerT< T >::G4PersistencyManagerT(), Retrieve(), SetVerboseLevel(), and Store().


The documentation for this class was generated from the following files:
Generated on Mon May 27 17:52:53 2013 for Geant4 by  doxygen 1.4.7