Import Geant4 1.0.0 source tree
This commit is contained in:
@@ -1,279 +0,0 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4PGeometryObjectMap.cc,v 1.2 1999/04/29 09:08:32 morita Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
//
|
||||
// class G4PGeometryObjectMap
|
||||
//
|
||||
// Implementation of a class responsible for keeping track of
|
||||
// the geometry object map.
|
||||
//
|
||||
// History:
|
||||
// 98.06.20 Y.Morita Initial version
|
||||
|
||||
#include "G4PGeometryObjectMap.hh"
|
||||
|
||||
// tell C++ compiler to generate code of parametrized class for each class
|
||||
// (Required by Objectivity/DB)
|
||||
implement(HepRefVArray,G4PLogicalVolume)
|
||||
implement(HepRefVArray,G4PVSolid)
|
||||
|
||||
G4PGeometryObjectMap::G4PGeometryObjectMap()
|
||||
{
|
||||
}
|
||||
|
||||
G4PGeometryObjectMap::G4PGeometryObjectMap( const G4String theGeometryName )
|
||||
{
|
||||
noPhysVol = 0;
|
||||
noLogVol = 0;
|
||||
noSolids = 0;
|
||||
}
|
||||
|
||||
G4PGeometryObjectMap::~G4PGeometryObjectMap()
|
||||
{
|
||||
}
|
||||
|
||||
// -------- LookUp() and Add() functions for each class -------- //
|
||||
|
||||
HepRef(G4PVPhysicalVolume) G4PGeometryObjectMap::LookUp(
|
||||
G4VPhysicalVolume* inGeomObj )
|
||||
{
|
||||
assert(inGeomObj != NULL);
|
||||
for(G4int i=0;i<noPhysVol;i++)
|
||||
if( transPhysVolPtrs[i] == inGeomObj )
|
||||
return persPhysVolPtrs[i];
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void G4PGeometryObjectMap::Add( G4VPhysicalVolume* inGeomObj,
|
||||
HepRef(G4PVPhysicalVolume) outGeomObj )
|
||||
{
|
||||
assert(inGeomObj != NULL);
|
||||
HepRef(G4PVPhysicalVolume) aGeomObj = LookUp( inGeomObj );
|
||||
if( aGeomObj == NULL )
|
||||
{
|
||||
// assert( inGeomObj == aGeomObj );
|
||||
noPhysVol++;
|
||||
transPhysVolPtrs.resize(noPhysVol);
|
||||
transPhysVolPtrs[noPhysVol-1] = inGeomObj;
|
||||
persPhysVolPtrs.append(outGeomObj);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------- //
|
||||
|
||||
G4VPhysicalVolume* G4PGeometryObjectMap::LookUp(
|
||||
HepRef(G4PVPhysicalVolume) inGeomObj )
|
||||
{
|
||||
assert(inGeomObj != NULL);
|
||||
for(G4int i=0;i<noPhysVol;i++)
|
||||
if( persPhysVolPtrs[i] == inGeomObj )
|
||||
return transPhysVolPtrs[i];
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void G4PGeometryObjectMap::Add( HepRef(G4PVPhysicalVolume) inGeomObj,
|
||||
G4VPhysicalVolume* outGeomObj )
|
||||
{
|
||||
assert(inGeomObj != NULL);
|
||||
for(G4int i=0;i<noPhysVol;i++)
|
||||
{
|
||||
if( persPhysVolPtrs[i] == inGeomObj )
|
||||
{
|
||||
transPhysVolPtrs[i] = outGeomObj;
|
||||
break;
|
||||
}
|
||||
cerr << "G4PGeometryObjectMap::Add -- transient solid not assigned" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------- //
|
||||
|
||||
HepRef(G4PLogicalVolume) G4PGeometryObjectMap::LookUp(
|
||||
G4LogicalVolume* inGeomObj )
|
||||
{
|
||||
assert(inGeomObj != NULL);
|
||||
for(G4int i=0;i<noLogVol;i++)
|
||||
if( transLogVolPtrs[i] == inGeomObj )
|
||||
return persLogVolPtrs[i];
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void G4PGeometryObjectMap::Add( G4LogicalVolume* inGeomObj,
|
||||
HepRef(G4PLogicalVolume) outGeomObj )
|
||||
{
|
||||
assert(inGeomObj != NULL);
|
||||
HepRef(G4PLogicalVolume) aGeomObj = LookUp( inGeomObj );
|
||||
if( aGeomObj == NULL )
|
||||
{
|
||||
// assert( inGeomObj == aGeomObj );
|
||||
noLogVol++;
|
||||
transLogVolPtrs.resize(noLogVol);
|
||||
transLogVolPtrs[noLogVol-1] = inGeomObj;
|
||||
persLogVolPtrs.append(outGeomObj);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------- //
|
||||
|
||||
G4LogicalVolume* G4PGeometryObjectMap::LookUp(
|
||||
HepRef(G4PLogicalVolume) inGeomObj )
|
||||
{
|
||||
assert(inGeomObj != NULL);
|
||||
for(G4int i=0;i<noLogVol;i++)
|
||||
if( persLogVolPtrs[i] == inGeomObj )
|
||||
return transLogVolPtrs[i];
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void G4PGeometryObjectMap::Add( HepRef(G4PLogicalVolume) inGeomObj,
|
||||
G4LogicalVolume* outGeomObj )
|
||||
{
|
||||
assert(inGeomObj != NULL);
|
||||
for(G4int i=0;i<noLogVol;i++)
|
||||
{
|
||||
if( persLogVolPtrs[i] == inGeomObj )
|
||||
{
|
||||
transLogVolPtrs[i] = outGeomObj;
|
||||
break;
|
||||
}
|
||||
cerr << "G4PGeometryObjectMap::Add -- transient solid not assigned" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------- //
|
||||
HepRef(G4PVSolid) G4PGeometryObjectMap::LookUp( G4VSolid* inGeomObj )
|
||||
{
|
||||
|
||||
#ifdef G4PERSISTENCY_DEBUG
|
||||
cout << "G4PGeometryObjectMap::LookUp(G4VSolid) -- noSolids is "
|
||||
<< noSolids << endl;
|
||||
cout << " G4VSolid info: " << inGeomObj << endl;
|
||||
#endif
|
||||
|
||||
assert(inGeomObj != NULL);
|
||||
for(G4int i=0;i<noSolids;i++)
|
||||
{
|
||||
#ifdef G4PERSISTENCY_DEBUG
|
||||
G4VSolid* tmpSolid = transSolidPtrs[i];
|
||||
cout << "[" << i << "] transSolidPtrs[i]=" << tmpSolid <<endl;
|
||||
cout << " persSolidPtrs[i]=";
|
||||
HepRef(G4PVSolid) tmpPSolid = persSolidPtrs[i];
|
||||
tmpPSolid.print();
|
||||
#endif
|
||||
|
||||
if( transSolidPtrs[i] == inGeomObj )
|
||||
return persSolidPtrs[i];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void G4PGeometryObjectMap::Add( G4VSolid* inGeomObj,
|
||||
HepRef(G4PVSolid) outGeomObj )
|
||||
{
|
||||
assert(inGeomObj != NULL);
|
||||
HepRef(G4PVSolid) aGeomObj = LookUp( inGeomObj );
|
||||
if( aGeomObj == NULL )
|
||||
{
|
||||
// assert( inGeomObj == aGeomObj );
|
||||
noSolids++;
|
||||
transSolidPtrs.resize(noSolids);
|
||||
transSolidPtrs[noSolids-1] = inGeomObj;
|
||||
persSolidPtrs.append(outGeomObj);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------- //
|
||||
|
||||
G4VSolid* G4PGeometryObjectMap::LookUp(
|
||||
HepRef(G4PVSolid) inGeomObj )
|
||||
{
|
||||
|
||||
#ifdef G4PERSISTENCY_DEBUG
|
||||
cout << "G4PGeometryObjectMap::LookUp(G4PVSolid) -- noSolids is "
|
||||
<< noSolids << endl;
|
||||
cout << " G4PVSolid info:";
|
||||
inGeomObj.print(stdout);
|
||||
#endif
|
||||
|
||||
assert(inGeomObj != NULL);
|
||||
for(G4int i=0;i<noSolids;i++)
|
||||
{
|
||||
#ifdef G4PERSISTENCY_DEBUG
|
||||
cout << "[" << i << "] persSolidPtrs[i]=";
|
||||
HepRef(G4PVSolid) tmpPSolid = persSolidPtrs[i];
|
||||
tmpPSolid.print();
|
||||
G4VSolid* tmpSolid = transSolidPtrs[i];
|
||||
cout << " transSolidPtrs[i]=" << tmpSolid <<endl;
|
||||
#endif
|
||||
if( persSolidPtrs[i] == inGeomObj )
|
||||
return transSolidPtrs[i];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void G4PGeometryObjectMap::Add( HepRef(G4PVSolid) inGeomObj,
|
||||
G4VSolid* outGeomObj )
|
||||
{
|
||||
assert(inGeomObj != NULL);
|
||||
for(G4int i=0;i<noSolids;i++)
|
||||
{
|
||||
if( persSolidPtrs[i] == inGeomObj )
|
||||
{
|
||||
transSolidPtrs[i] = outGeomObj;
|
||||
break;
|
||||
}
|
||||
cerr << "G4PGeometryObjectMap::Add -- transient solid not assigned" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------- //
|
||||
|
||||
G4VSolid* G4PGeometryObjectMap::GetSolid(G4int i)
|
||||
{
|
||||
if( i >= 0 && i < noSolids)
|
||||
return transSolidPtrs[i];
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
HepRef(G4PVSolid) G4PGeometryObjectMap::GetPSolid(G4int i)
|
||||
{
|
||||
if( i >= 0 && i < noSolids)
|
||||
return persSolidPtrs[i];
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void G4PGeometryObjectMap::InitTransientMap()
|
||||
{
|
||||
transPhysVolPtrs.resize(noPhysVol);
|
||||
transLogVolPtrs.resize(noLogVol);
|
||||
transSolidPtrs.resize(noSolids);
|
||||
|
||||
#ifdef G4PERSISTENCY_DEBUG
|
||||
cout << "G4PGeometryObjectMap::InitTransientMap()" << endl;
|
||||
cout << " -- noPhysVol: " << noPhysVol << endl;
|
||||
cout << " -- transPhysVolPtrs.length: " << transPhysVolPtrs.length() << endl;
|
||||
cout << " -- transLogVolPtrs.length: " << transLogVolPtrs.length() << endl;
|
||||
cout << " -- transSolidPtrs.length: " << transSolidPtrs.length() << endl;
|
||||
#endif
|
||||
|
||||
for(G4int i=0;i<noPhysVol;i++)
|
||||
transPhysVolPtrs[i] = NULL;
|
||||
for(i=0;i<noLogVol;i++)
|
||||
transLogVolPtrs[i] = NULL;
|
||||
for(i=0;i<noSolids;i++)
|
||||
transSolidPtrs[i] = NULL;
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
// the GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4PersistencyManager.cc,v 1.1 1999/01/07 16:10:57 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
// $Id: G4PersistencyManager.cc,v 1.15.2.1 1999/12/07 20:50:14 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
// class G4PersistencyManager
|
||||
//
|
||||
@@ -20,6 +20,16 @@
|
||||
|
||||
#include "G4ios.hh"
|
||||
|
||||
// forward declarations
|
||||
#include "G4PersistentHitMan.hh"
|
||||
#include "G4PersistentDigitMan.hh"
|
||||
#include "G4PersistentEventMan.hh"
|
||||
#include "G4PersistentRunMan.hh"
|
||||
#include "G4PersistentGeomMan.hh"
|
||||
#include "G4PersistencyMessenger.hh"
|
||||
#include "G4TransactionManager.hh"
|
||||
#include "HepODBMS/clustering/HepDbApplication.h"
|
||||
|
||||
G4PersistencyManager* G4PersistencyManager::f_PersistencyManager = NULL;
|
||||
|
||||
G4PersistencyManager* G4PersistencyManager::GetPersistencyManager()
|
||||
@@ -35,87 +45,246 @@ G4PersistencyManager* G4PersistencyManager::get_PersistencyManagerIfExist()
|
||||
{ return f_PersistencyManager; }
|
||||
|
||||
G4PersistencyManager::G4PersistencyManager()
|
||||
: f_verboseLevel(0)
|
||||
{
|
||||
f_pHitMan = G4PersistentHitMan::GetPersistentHitMan();
|
||||
f_pDigitMan = G4PersistentDigitMan::GetPersistentDigitMan();
|
||||
f_pEventMan = new G4PersistentEventMan(f_pHitMan, f_pDigitMan);
|
||||
f_pRunMan = new G4PersistentRunMan;
|
||||
f_pGeomMan = new G4PersistentGeomMan;
|
||||
|
||||
dbApp = new HepDbApplication("g4example");
|
||||
|
||||
if (!dbApp)
|
||||
{
|
||||
G4cerr << "could not allocate HepDbApplication in G4PersistencyManager!" << endl;
|
||||
}
|
||||
|
||||
// Open and Initialize a database
|
||||
|
||||
// Note: The name of the federated database file "G4EXAMPLE" is
|
||||
// hard-coded here for now.
|
||||
// In near future G4PersistencyManager should take an argument
|
||||
// of the file name so that user can specify it on the fly.
|
||||
|
||||
const G4String bootFileName = "G4EXAMPLE";
|
||||
G4cout << "Opening Federated Database " << bootFileName << "." << endl;
|
||||
dbApp->fdBootName(bootFileName);
|
||||
dbApp->Init();
|
||||
|
||||
// Locate or create run databases and containers
|
||||
const G4String runDBName = "Runs";
|
||||
if( ! f_pRunMan.LocateDB( dbApp, runDBName) )
|
||||
{
|
||||
G4cerr << "could not locate run database in G4PersistencyManager!" << endl;
|
||||
}
|
||||
|
||||
// Locate or create event databases and containers
|
||||
const G4String eventDBName = "Events";
|
||||
if( ! f_pEventMan.LocateDB( dbApp, eventDBName) )
|
||||
{
|
||||
G4cerr << "could not locate event database in G4PersistencyManager!" << endl;
|
||||
}
|
||||
|
||||
f_persMessenger = new G4PersistencyMessenger(this);
|
||||
f_transactionMan = new G4TransactionManager
|
||||
(f_pRunMan, f_pEventMan, f_pHitMan, f_pDigitMan,
|
||||
f_pGeomMan);
|
||||
}
|
||||
|
||||
G4PersistencyManager::~G4PersistencyManager()
|
||||
{
|
||||
// Any persistent objects which are created during save() should
|
||||
// not be deleted in ~G4PersistencyManager() implicitly, because
|
||||
// delete utility classes
|
||||
|
||||
delete f_pHitMan;
|
||||
delete f_pDigitMan;
|
||||
delete f_pEventMan;
|
||||
delete f_pRunMan;
|
||||
delete f_pGeomMan;
|
||||
delete f_persMessenger;
|
||||
delete f_transactionMan;
|
||||
|
||||
// Any persistent objects which are created during Store()
|
||||
// should not be deleted in ~G4PersistencyManager(), because
|
||||
// they are "persistent"!
|
||||
|
||||
// On the contrary, any transient objects which are created during
|
||||
// Retrieve() should be deleted explicitly when they are no longer
|
||||
// in use. It is the responsibility of the caller of Retrieve()
|
||||
// to destroy the retrieved transient objects if Retrieve() is to be
|
||||
// called repeatedlly.
|
||||
|
||||
G4cout << "PersistencyManager is deleting." << endl;
|
||||
if(f_verboseLevel>0)
|
||||
G4cout << "PersistencyManager is deleting." << endl;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
G4bool G4PersistencyManager::Store(const G4Event* anEvent)
|
||||
{
|
||||
return f_pEventMan.Store(dbApp, anEvent);
|
||||
f_transactionMan->StartTransaction(kEventDB, kUpdate, false);
|
||||
|
||||
if( f_pEventMan->Store(f_transactionMan->DbApp(), anEvent) )
|
||||
{
|
||||
if( f_verboseLevel>1 )
|
||||
{
|
||||
G4cout << " -- G4PEvent " << f_pEventMan->CurrentEventID() << " stored in "
|
||||
<< DBContainerName(kEventDB);
|
||||
if( f_transactionMan->SustainedMode() )
|
||||
G4cout << " (sustained)" << endl;
|
||||
else
|
||||
G4cout << endl;
|
||||
}
|
||||
f_transactionMan->Commit(kEventDB, false);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
f_transactionMan->Abort(kEventDB, false);
|
||||
G4cerr << "G4PersistencyManager: Failed to store G4PEvent in "
|
||||
<< DBContainerName(kEventDB) << endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
G4bool G4PersistencyManager::Store(const G4Run* aRun)
|
||||
{
|
||||
return f_pRunMan.Store(dbApp, aRun);
|
||||
f_transactionMan->StartTransaction(kRunDB, kUpdate, false);
|
||||
|
||||
if( f_pRunMan->Store(f_transactionMan->DbApp(), aRun) )
|
||||
{
|
||||
if( f_verboseLevel>0 )
|
||||
G4cout << " -- G4PRun " << f_pRunMan->CurrentRunID() << " stored in "
|
||||
<< DBContainerName(kRunDB) << endl;
|
||||
f_transactionMan->Commit(kRunDB, false);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
f_transactionMan->Abort(kRunDB, false);
|
||||
G4cerr << "G4PersistencyManager: Failed to store G4PRun in "
|
||||
<< DBContainerName(kRunDB) << endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
G4bool G4PersistencyManager::Store(const G4VPhysicalVolume* aWorld)
|
||||
{
|
||||
return f_pGeomMan.Store(dbApp, aWorld);
|
||||
f_transactionMan->StartTransaction(kGeomDB, kUpdate, false);
|
||||
|
||||
if( f_pGeomMan->Store(f_transactionMan->DbApp(), aWorld) )
|
||||
{
|
||||
if( f_verboseLevel>0 )
|
||||
G4cout << " -- Geometry stored in "
|
||||
<< DBContainerName(kGeomDB) << endl;
|
||||
f_transactionMan->Commit(kGeomDB, false);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
f_transactionMan->Abort(kGeomDB, false);
|
||||
G4cerr << "G4PersistencyManager: Failed to store Geometry in "
|
||||
<< DBContainerName(kGeomDB) << endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
G4bool G4PersistencyManager::Retrieve(G4Event*& anEvent)
|
||||
{
|
||||
return f_pEventMan.Retrieve(dbApp, anEvent);
|
||||
f_transactionMan->StartTransaction(kEventDB, kRead, false);
|
||||
|
||||
if( f_pEventMan->Retrieve(f_transactionMan->DbApp(), anEvent) )
|
||||
{
|
||||
if( f_verboseLevel>1 )
|
||||
{
|
||||
if( anEvent )
|
||||
G4cout << " -- G4Event " << f_pEventMan->CurrentEventID()
|
||||
<< " retrieved from "
|
||||
<< DBContainerName(kEventDB) << endl;
|
||||
else
|
||||
G4cout << " -- scan of G4Event from "
|
||||
<< DBContainerName(kEventDB)
|
||||
<< " is completed." << endl;
|
||||
}
|
||||
f_transactionMan->Commit(kEventDB, false);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
f_transactionMan->Abort(kEventDB, false);
|
||||
G4cerr << "G4PersistencyManager: Failed to retrieve G4Event from "
|
||||
<< DBContainerName(kEventDB) << endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
G4bool G4PersistencyManager::Retrieve(G4Run*& aRun)
|
||||
{
|
||||
return f_pRunMan.Retrieve(dbApp, aRun);
|
||||
f_transactionMan->StartTransaction(kRunDB, kRead, false);
|
||||
|
||||
if( f_pRunMan->Retrieve(f_transactionMan->DbApp(), aRun) )
|
||||
{
|
||||
if( f_verboseLevel>0 )
|
||||
{
|
||||
if( aRun )
|
||||
G4cout << " -- G4Run " << f_pRunMan->CurrentRunID()
|
||||
<< " retrieved from "
|
||||
<< DBContainerName(kRunDB) << "." << endl;
|
||||
else
|
||||
G4cout << " -- scan of G4Run from "
|
||||
<< DBContainerName(kRunDB)
|
||||
<< " is completed." << endl;
|
||||
}
|
||||
f_transactionMan->Commit(kRunDB, false);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
f_transactionMan->Abort(kRunDB, false);
|
||||
G4cerr << "G4PersistencyManager: Failed to retrieve G4Run from "
|
||||
<< DBContainerName(kRunDB) << endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
G4bool G4PersistencyManager::Retrieve(G4VPhysicalVolume*& theWorld)
|
||||
{
|
||||
return f_pGeomMan.Retrieve(dbApp, theWorld);
|
||||
f_transactionMan->StartTransaction(kGeomDB, kRead, false);
|
||||
|
||||
if( f_pGeomMan->Retrieve(f_transactionMan->DbApp(), theWorld) )
|
||||
{
|
||||
if( f_verboseLevel>0 )
|
||||
{
|
||||
if( theWorld )
|
||||
G4cout << " -- Geometry retrieved from "
|
||||
<< DBContainerName(kGeomDB) << endl;
|
||||
}
|
||||
f_transactionMan->Commit(kGeomDB, false);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
f_transactionMan->Abort(kGeomDB, false);
|
||||
G4cerr << "G4PersistencyManager: Failed to retrieve Geometry from "
|
||||
<< DBContainerName(kGeomDB) << endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
HepDbApplication* G4PersistencyManager::DbApp()
|
||||
{ return f_transactionMan->DbApp(); }
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
G4bool G4PersistencyManager::SelectDB(ETypeOfDB dbtype,
|
||||
G4String dbname, G4bool updateMode)
|
||||
{ return f_transactionMan->SelectDB(dbtype, dbname, updateMode); }
|
||||
|
||||
G4String G4PersistencyManager::DBName(ETypeOfDB dbtype)
|
||||
{ return f_transactionMan->DBName(dbtype); }
|
||||
|
||||
G4String G4PersistencyManager::ContainerName(ETypeOfDB dbtype)
|
||||
{ return f_transactionMan->ContainerName(dbtype); }
|
||||
|
||||
HepDatabaseRef G4PersistencyManager::DBref(ETypeOfDB dbtype)
|
||||
{ return f_transactionMan->DBref(dbtype); }
|
||||
|
||||
HepContainerRef G4PersistencyManager::ContainerRef(ETypeOfDB dbtype)
|
||||
{ return f_transactionMan->ContainerRef(dbtype); }
|
||||
|
||||
G4String G4PersistencyManager::DBContainerName(ETypeOfDB dbtype)
|
||||
{ return f_transactionMan->DBContainerName(dbtype); }
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
G4bool G4PersistencyManager::StartTransaction( ETypeOfDB dbtype,
|
||||
ETransactionMode dbmode,
|
||||
G4bool isSustained)
|
||||
{
|
||||
return f_transactionMan->StartTransaction(
|
||||
dbtype, dbmode, isSustained );
|
||||
}
|
||||
|
||||
G4bool G4PersistencyManager::Commit(ETypeOfDB dbtype, G4bool isSustained)
|
||||
{ return f_transactionMan->Commit(dbtype, isSustained); }
|
||||
|
||||
G4bool G4PersistencyManager::Abort(ETypeOfDB dbtype, G4bool isSustained)
|
||||
{ return f_transactionMan->Abort(dbtype, isSustained); }
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
void G4PersistencyManager::SetVerboseLevel(G4int vl)
|
||||
{
|
||||
f_verboseLevel = vl;
|
||||
f_pHitMan->SetVerboseLevel(vl);
|
||||
f_pDigitMan->SetVerboseLevel(vl);
|
||||
f_pRunMan->SetVerboseLevel(vl);
|
||||
f_pEventMan->SetVerboseLevel(vl);
|
||||
f_pGeomMan->SetVerboseLevel(vl);
|
||||
f_transactionMan->SetVerboseLevel(vl);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4PersistencyMessenger.cc,v 1.7 1999/11/26 16:50:21 morita Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
|
||||
#include "G4PersistencyMessenger.hh"
|
||||
#include "G4PersistencyManager.hh"
|
||||
#include "G4UIdirectory.hh"
|
||||
#include "G4UIcmdWithoutParameter.hh"
|
||||
#include "G4UIcmdWithAString.hh"
|
||||
#include "G4UIcmdWithAnInteger.hh"
|
||||
#include "G4UIcmdWithABool.hh"
|
||||
#include "G4UIcommand.hh"
|
||||
#include "G4UIparameter.hh"
|
||||
#include "G4ios.hh"
|
||||
|
||||
G4PersistencyMessenger::G4PersistencyMessenger(G4PersistencyManager* persistencyMgr)
|
||||
: persistencyManager(persistencyMgr)
|
||||
{
|
||||
persistencyDirectory = new G4UIdirectory("/db/");
|
||||
persistencyDirectory->SetGuidance("Database control commands.");
|
||||
|
||||
verboseCmd = new G4UIcmdWithAnInteger("/db/verbose",this);
|
||||
verboseCmd->SetGuidance("Set the verbose level of G4PersistencyManager.");
|
||||
verboseCmd->SetGuidance(" 0 : Silent (default)");
|
||||
verboseCmd->SetGuidance(" 1 : Display main topics");
|
||||
verboseCmd->SetGuidance(" 2 : Display event-level topics");
|
||||
verboseCmd->SetGuidance(" 3 : Display debug information");
|
||||
verboseCmd->SetParameterName("level",true);
|
||||
verboseCmd->SetDefaultValue(0);
|
||||
verboseCmd->SetRange("level >=0 && level <=3");
|
||||
|
||||
runDbCmd = new G4UIcmdWithAString("/db/run",this);
|
||||
runDbCmd->SetGuidance("Set the name of Run Database.");
|
||||
runDbCmd->SetParameterName("fileName",true);
|
||||
runDbCmd->SetDefaultValue("Runs");
|
||||
runDbCmd->AvailableForStates(PreInit,Idle);
|
||||
|
||||
eventDbCmd = new G4UIcmdWithAString("/db/event",this);
|
||||
eventDbCmd->SetGuidance("Set the name of Event Database.");
|
||||
eventDbCmd->SetParameterName("fileName",true);
|
||||
eventDbCmd->SetDefaultValue("Events");
|
||||
eventDbCmd->AvailableForStates(PreInit,Idle);
|
||||
|
||||
geomDbCmd = new G4UIcmdWithAString("/db/geometry",this);
|
||||
geomDbCmd->SetGuidance("Set the name of Geometry Database.");
|
||||
geomDbCmd->SetParameterName("fileName",true);
|
||||
geomDbCmd->SetDefaultValue("Geometry");
|
||||
geomDbCmd->AvailableForStates(PreInit,Idle);
|
||||
}
|
||||
|
||||
G4PersistencyMessenger::~G4PersistencyMessenger()
|
||||
{
|
||||
delete verboseCmd;
|
||||
delete runDbCmd;
|
||||
delete eventDbCmd;
|
||||
delete geomDbCmd;
|
||||
delete persistencyDirectory;
|
||||
}
|
||||
|
||||
void G4PersistencyMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
|
||||
{
|
||||
if( command==verboseCmd )
|
||||
{ persistencyManager->SetVerboseLevel(verboseCmd->GetNewIntValue(newValue)); }
|
||||
else if( command==runDbCmd )
|
||||
{ persistencyManager->SelectDB(kRunDB, newValue, true); }
|
||||
else if( command==eventDbCmd )
|
||||
{ persistencyManager->SelectDB(kEventDB, newValue, true); }
|
||||
else if( command==geomDbCmd )
|
||||
{ persistencyManager->SelectDB(kGeomDB, newValue, true); }
|
||||
}
|
||||
|
||||
G4String G4PersistencyMessenger::GetCurrentValue(G4UIcommand * command)
|
||||
{
|
||||
G4String cv;
|
||||
|
||||
if( command==verboseCmd )
|
||||
{ cv = verboseCmd->ConvertToString(persistencyManager->GetVerboseLevel()); }
|
||||
else if( command==runDbCmd )
|
||||
{ cv = persistencyManager->DBName(kRunDB); }
|
||||
else if( command==eventDbCmd )
|
||||
{ cv = persistencyManager->DBName(kEventDB); }
|
||||
else if( command==geomDbCmd )
|
||||
{ cv = persistencyManager->DBName(kGeomDB); }
|
||||
|
||||
return cv;
|
||||
}
|
||||
|
||||
@@ -1,117 +0,0 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4PersistentEventMan.cc,v 1.1 1999/01/07 16:10:57 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
//
|
||||
// class G4PersistentEventMan
|
||||
//
|
||||
// Implementation for concrete G4PersistentEventMan.
|
||||
//
|
||||
// History:
|
||||
// 98.01.08 Y.Morita Initial version
|
||||
// 98.06.20 Y.Morita Implement geometry Store and Retrieve
|
||||
|
||||
#include "G4PersistentEventMan.hh"
|
||||
|
||||
#include "G4Event.hh"
|
||||
#include "G4PEvent.hh"
|
||||
|
||||
#include "G4ios.hh"
|
||||
|
||||
G4PersistentEventMan::G4PersistentEventMan()
|
||||
{;}
|
||||
|
||||
G4PersistentEventMan::~G4PersistentEventMan()
|
||||
{;}
|
||||
|
||||
HepDatabaseRef G4PersistentEventMan::GetDB()
|
||||
{
|
||||
return f_EventDB;
|
||||
}
|
||||
|
||||
HepContainerRef G4PersistentEventMan::GetContainer()
|
||||
{
|
||||
return f_EventContainer;
|
||||
}
|
||||
|
||||
G4bool G4PersistentEventMan::LocateDB(HepDbApplication* dbApp,
|
||||
const G4String eventDBName)
|
||||
{
|
||||
G4bool theStatus = true;
|
||||
|
||||
// start a transaction to create databases and containers
|
||||
dbApp->startUpdate();
|
||||
|
||||
// create a root named object tree namespace
|
||||
// namedRoot = new NamedNode;
|
||||
// NamedObjectTree namedTree( namedRoot );
|
||||
|
||||
// use database Events
|
||||
f_EventDB = dbApp->db(eventDBName);
|
||||
|
||||
if (f_EventDB == NULL)
|
||||
{
|
||||
G4cerr << "Could not create or find " << eventDBName << " database." << endl;
|
||||
theStatus = false;
|
||||
}
|
||||
|
||||
// create a new container for event collection in this database
|
||||
f_EventContainer = dbApp->container("EventContainer");
|
||||
|
||||
if ( f_EventContainer == NULL )
|
||||
{
|
||||
G4cerr << "could not find or create eventContainer in the database" << endl;
|
||||
theStatus = false;
|
||||
}
|
||||
|
||||
// create a "Events" named object tree in the namespace
|
||||
// namedTree.mkdir(eventDBName);
|
||||
// namedTree.cd(eventDBName);
|
||||
|
||||
// Commit the update
|
||||
dbApp->commit();
|
||||
|
||||
return theStatus;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
G4bool G4PersistentEventMan::Store( HepDbApplication* dbApp,
|
||||
const G4Event* anEvent )
|
||||
{
|
||||
// Start Update G4PEvent in the database
|
||||
dbApp->startUpdate();
|
||||
|
||||
// Create persistent event object
|
||||
new(f_EventContainer) G4PEvent(anEvent);
|
||||
|
||||
// Put it into event iterator
|
||||
|
||||
// Commit the update
|
||||
dbApp->commit();
|
||||
|
||||
#ifndef G4PERSISTENCY_DEBUG
|
||||
G4cout << "G4PEvent " << anEvent->GetEventID() << " Committed." << endl;
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
G4bool G4PersistentEventMan::Retrieve( HepDbApplication* dbApp,
|
||||
G4Event*& anEvent )
|
||||
{
|
||||
// not implemented yet
|
||||
|
||||
G4bool fStatus = false;
|
||||
|
||||
// loop thru the event iterator
|
||||
|
||||
fStatus = true;
|
||||
return fStatus;
|
||||
}
|
||||
|
||||
@@ -1,491 +0,0 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4PersistentGeomMan.cc,v 1.2 1999/03/29 16:05:27 morita Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
//
|
||||
// class G4PersistentGeomMan
|
||||
//
|
||||
// Implementation for concrete G4PersistentGeomMan.
|
||||
//
|
||||
// History:
|
||||
// 98.10.30 Y.Morita Splited from G4PersistencyManager
|
||||
|
||||
#include "G4PersistentGeomMan.hh"
|
||||
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4VSolid.hh"
|
||||
#include "G4PVSolid.hh"
|
||||
#include "G4PBox.hh"
|
||||
#include "G4PCons.hh"
|
||||
#include "G4PHype.hh"
|
||||
#include "G4PPara.hh"
|
||||
#include "G4PSphere.hh"
|
||||
#include "G4PTorus.hh"
|
||||
#include "G4PTrap.hh"
|
||||
#include "G4PTrd.hh"
|
||||
#include "G4PTubs.hh"
|
||||
|
||||
#include "G4PLogicalVolume.hh"
|
||||
#include "G4PPVPlacement.hh"
|
||||
#include "G4PPVReplica.hh"
|
||||
#include "G4PPVParameterised.hh"
|
||||
|
||||
#include "G4ios.hh"
|
||||
|
||||
G4PersistentGeomMan::G4PersistentGeomMan()
|
||||
{
|
||||
f_GeomMapScopeName = "Geant4 Geometry Object Map";
|
||||
}
|
||||
|
||||
G4PersistentGeomMan::~G4PersistentGeomMan()
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
G4bool G4PersistentGeomMan::Store( HepDbApplication* dbApp,
|
||||
const G4VPhysicalVolume* theWorld)
|
||||
{
|
||||
void* aWorld = (void*) theWorld;
|
||||
G4bool fStatus = false;
|
||||
const G4String theGeometryName = "G4EXAMPLE test geometry";
|
||||
|
||||
// clear the recursive call counter
|
||||
f_nRecursive = 0;
|
||||
f_tRecursive = 0;
|
||||
|
||||
// Start Updating the geometry database
|
||||
dbApp->startUpdate();
|
||||
|
||||
// Open or create Geometry DB
|
||||
const HepDatabaseRef f_GeomDB = dbApp->db("Geometry");
|
||||
|
||||
if ( f_GeomDB == NULL )
|
||||
{
|
||||
G4cerr << "G4PersistentGeomMan::Store" <<
|
||||
" -- error in opening or creating the geometry database." << endl;
|
||||
}
|
||||
|
||||
// create a new container for geometry collection in this database
|
||||
f_GeomContainer = dbApp->container("GeometryContainer");
|
||||
|
||||
if ( f_GeomContainer == NULL )
|
||||
{
|
||||
G4cerr << "could not find or create f_GeomContainer in the database" << endl;
|
||||
}
|
||||
|
||||
// ----------------------- Objectivity Feature ----------------------- //
|
||||
// Look for the geometry object map in the database and create it
|
||||
// if it does not exist
|
||||
if ( ! f_GeomMap.lookupObj( f_GeomDB, f_GeomMapScopeName, oocUpdate ) )
|
||||
{
|
||||
|
||||
// Prepare lookup table for the geometry object tree
|
||||
f_GeomMap =
|
||||
new(f_GeomContainer) G4PGeometryObjectMap( theGeometryName );
|
||||
|
||||
// Add ScopeName to f_GeomMap for future reference (*Objy feature)
|
||||
if ( ! f_GeomMap.nameObj( f_GeomDB, f_GeomMapScopeName ) )
|
||||
{
|
||||
G4cerr << "G4PersistentGeomMan::Store" <<
|
||||
" -- error in naming the geometry object map: " <<
|
||||
f_GeomMapScopeName << endl;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
G4cerr << "G4PersistentGeomMan::Store" <<
|
||||
" -- the object map already defined in the geometry database." << endl;
|
||||
G4cerr << " Geometry not stored." << endl;
|
||||
dbApp->abort();
|
||||
return false;
|
||||
}
|
||||
// ----------------------- Objectivity Feature ----------------------- //
|
||||
|
||||
// make the persistent world volume object from "theWorld"
|
||||
HepRef(G4PVPhysicalVolume) persWorld =
|
||||
MakePersistentObject( (G4VPhysicalVolume*)aWorld );
|
||||
|
||||
if ( persWorld != NULL )
|
||||
{
|
||||
// set the persistent World Volume to f_GeomMap
|
||||
f_GeomMap->SetWorldVolume( persWorld );
|
||||
|
||||
// commit the changes to the geometry database
|
||||
dbApp->commit();
|
||||
fStatus = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
dbApp->abort();
|
||||
fStatus = false;
|
||||
}
|
||||
|
||||
return fStatus;
|
||||
}
|
||||
|
||||
G4bool G4PersistentGeomMan::Retrieve( HepDbApplication* dbApp,
|
||||
G4VPhysicalVolume*& theWorld)
|
||||
{
|
||||
const G4PString theGeometryName = "G4EXAMPLE test geometry";
|
||||
G4bool fStatus = false;
|
||||
|
||||
theWorld = NULL;
|
||||
|
||||
// Start "Read" transactions to the database
|
||||
dbApp->startRead();
|
||||
|
||||
// Open existing Geometry database
|
||||
f_GeomDB = dbApp->db("Geometry");
|
||||
|
||||
if ( f_GeomDB == NULL )
|
||||
{
|
||||
G4cerr << "G4PersistentGeomMan::Retrieve" <<
|
||||
" -- error in searching the geometry database" << endl;
|
||||
}
|
||||
|
||||
// ----------------------- Objectivity Feature ----------------------- //
|
||||
// Load the geometry object map from the database with read-only mode
|
||||
if ( ! f_GeomMap.lookupObj( f_GeomDB, f_GeomMapScopeName, oocRead ) )
|
||||
{
|
||||
G4cerr << "G4PersistentGeomMan::Retrieve" <<
|
||||
" -- error in looking up the geometry object map: " <<
|
||||
f_GeomMapScopeName << endl;
|
||||
}
|
||||
// ----------------------- Objectivity Feature ----------------------- //
|
||||
|
||||
if ( f_GeomMap == NULL )
|
||||
{
|
||||
G4cerr << "G4PersistentGeomMan::Retrieve" <<
|
||||
" -- error in searching the geometry object map: " <<
|
||||
f_GeomMapScopeName << endl;
|
||||
}
|
||||
|
||||
#ifdef G4PERSISTENCY_DEBUG
|
||||
G4cout << "G4PersistentGeomMan::Retrieve(G4VPhysicalVolume*)"
|
||||
<< " -- f_GeomMap is loaded." << endl;
|
||||
#endif
|
||||
|
||||
// initialize the transient part of the geometry object map
|
||||
f_GeomMap->InitTransientMap();
|
||||
|
||||
#ifdef G4PERSISTENCY_DEBUG
|
||||
G4cout << "G4PersistentGeomMan::Retrieve(G4VPhysicalVolume*)"
|
||||
<< " -- f_GeomMap is initialized." << endl;
|
||||
#endif
|
||||
|
||||
// loop through the number of solids in the database
|
||||
G4int nSolids = f_GeomMap->GetNoSolids();
|
||||
for(G4int i=0;i<nSolids;i++)
|
||||
{
|
||||
// load persistent solid object from DB
|
||||
HepRef(G4PVSolid) persSolid = f_GeomMap->GetPSolid(i);
|
||||
|
||||
// make transient version of G4VSolid from the persistent solid
|
||||
G4VSolid* theSolid = MakeTransientObject(persSolid);
|
||||
}
|
||||
|
||||
#ifdef G4PERSISTENCY_DEBUG
|
||||
G4cout << "G4PersistentGeomMan::Retrieve(G4VPhysicalVolume*)"
|
||||
<< " -- Transient Solid is created for nSolids:"
|
||||
<< nSolids << endl;
|
||||
#endif
|
||||
|
||||
// Locate the persistent world physics volume
|
||||
HepRef(G4PVPhysicalVolume) persWorld = f_GeomMap->GetWorldVolume();
|
||||
|
||||
if ( persWorld == NULL )
|
||||
{
|
||||
G4cerr << "G4PersistentGeomMan::Retrieve" <<
|
||||
" -- geometry object map does not have world volume." << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
// start the recursive data member copy
|
||||
// to create the transient geometry object tree
|
||||
HepRef(G4PVPhysicalVolume) persMother = NULL;
|
||||
G4VPhysicalVolume* theWorld =
|
||||
MakeTransientObject( persWorld, persMother );
|
||||
|
||||
if ( theWorld != NULL )
|
||||
fStatus = true;
|
||||
}
|
||||
// Close the transaction on geometry retrive
|
||||
dbApp->commit();
|
||||
|
||||
return fStatus;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
HepRef(G4PVPhysicalVolume) G4PersistentGeomMan::MakePersistentObject (
|
||||
G4VPhysicalVolume* thePhysVol )
|
||||
{
|
||||
// check the depth of the recursive call to this method
|
||||
if ( ++f_nRecursive > G4_PHYS_VOLUME_DEPTH_MAX )
|
||||
{
|
||||
G4cerr << "G4PersistentGeomMan::MakePersistentObject" <<
|
||||
" -- Physical Volume recursive depth reached to G4_PHYS_VOLUME_DEPTH_MAX."
|
||||
<< endl;
|
||||
return NULL;
|
||||
}
|
||||
#ifdef G4PERSISTENCY_DEBUG
|
||||
if ( f_nRecursive % 1000 == 0 )
|
||||
{
|
||||
G4cout << "G4PersistentGeomMan::MakePersistentObject" <<
|
||||
" -- Physical Volume recursive depth is " << f_nRecursive << endl;
|
||||
}
|
||||
#endif // G4PERSISTENCY_DEBUG
|
||||
|
||||
// check if the persistent version of thePhysVol exists
|
||||
HepRef(G4PVPhysicalVolume) persPhysVol = f_GeomMap->LookUp(thePhysVol);
|
||||
if ( persPhysVol == NULL )
|
||||
{
|
||||
// Get the Logical Volume in thePhysVol
|
||||
G4LogicalVolume* theLogVol = thePhysVol->GetLogicalVolume();
|
||||
|
||||
// make the persistent logical volume object from "theLogVol"
|
||||
HepRef(G4PLogicalVolume) persLogVol =
|
||||
MakePersistentObject( theLogVol );
|
||||
assert( persLogVol != NULL );
|
||||
|
||||
// Construct the persistent version of thePhysVol for each type of volume
|
||||
switch (VolumeType(thePhysVol))
|
||||
{
|
||||
case kNormal:
|
||||
persPhysVol = new(f_GeomContainer)
|
||||
G4PPVPlacement( thePhysVol, persLogVol);
|
||||
break;
|
||||
case kReplica:
|
||||
persPhysVol = new(f_GeomContainer)
|
||||
G4PPVReplica( thePhysVol, persLogVol);
|
||||
break;
|
||||
case kParameterised:
|
||||
persPhysVol = new(f_GeomContainer)
|
||||
G4PPVReplica( thePhysVol, persLogVol);
|
||||
// G4PPVParameterized( thePhysVol, persLogVol);
|
||||
break;
|
||||
}
|
||||
assert( persPhysVol != NULL );
|
||||
|
||||
// register persPhysVol to the geometry object lookup table
|
||||
f_GeomMap->Add( thePhysVol, persPhysVol );
|
||||
|
||||
} // end of if f_GeomMap->LookUp(thePhysVol)
|
||||
|
||||
return persPhysVol;
|
||||
}
|
||||
|
||||
HepRef(G4PLogicalVolume) G4PersistentGeomMan::MakePersistentObject (
|
||||
G4LogicalVolume* theLogVol )
|
||||
|
||||
{
|
||||
// check if the persistent version of theLogVol exists
|
||||
HepRef(G4PLogicalVolume) persLogVol = f_GeomMap->LookUp(theLogVol);
|
||||
if ( persLogVol == NULL )
|
||||
{
|
||||
// get the solid of the transient logical volume
|
||||
G4VSolid* theSolid = theLogVol->GetSolid();
|
||||
|
||||
// make the persistent solid object from "theSolid"
|
||||
HepRef(G4PVSolid) persSolid = MakePersistentObject(theSolid);
|
||||
|
||||
// Construct the persistent version of theLogVol
|
||||
persLogVol = new(f_GeomContainer) G4PLogicalVolume(theLogVol, persSolid);
|
||||
assert( persLogVol != NULL );
|
||||
|
||||
// register persLogVol to the geometry object lookup table
|
||||
f_GeomMap->Add( theLogVol, persLogVol );
|
||||
|
||||
// loop through the daughter physical volumes in theLogVol
|
||||
G4int nDaughters = theLogVol->GetNoDaughters();
|
||||
for(G4int i=0;i<nDaughters;i++)
|
||||
{
|
||||
// Get the i-th daughter physics volume
|
||||
G4VPhysicalVolume* dPhysVol = theLogVol->GetDaughter(i);
|
||||
|
||||
// make the persistent physics volume object from "dPhysVol"
|
||||
HepRef(G4PVPhysicalVolume) persDaughterPhysVol =
|
||||
MakePersistentObject( dPhysVol );
|
||||
|
||||
// add persistent daughter volume to the persistent logical volume
|
||||
if ( persDaughterPhysVol != NULL )
|
||||
persLogVol->AddDaughter( persDaughterPhysVol );
|
||||
|
||||
} // end of for(G4int i=0;i<nDaughters;i++)
|
||||
|
||||
} // end of if f_GeomMap->LookUp(theLogVol)
|
||||
|
||||
return persLogVol;
|
||||
}
|
||||
|
||||
HepRef(G4PVSolid) G4PersistentGeomMan::MakePersistentObject (
|
||||
G4VSolid* theSolid )
|
||||
{
|
||||
// check if the persistent version of theSolid exists
|
||||
HepRef(G4PVSolid) persSolid = f_GeomMap->LookUp(theSolid);
|
||||
if ( persSolid == NULL )
|
||||
{
|
||||
G4GeometryType theSolidType = theSolid->GetEntityType();
|
||||
|
||||
#ifdef G4PERSISTENCY_DEBUG
|
||||
G4cout << "G4PersistentGeomMan::MakePersistentObject (G4VSolid) "
|
||||
<< "-- theSolidType is " << theSolidType << endl;
|
||||
#endif
|
||||
|
||||
// Construct persistent and concrete solid object
|
||||
// according to the entity type of theSolid
|
||||
if ( theSolidType == "G4Box")
|
||||
persSolid = new(f_GeomContainer) G4PBox( (G4Box*)theSolid );
|
||||
else if ( theSolidType == "G4Cons")
|
||||
persSolid = new(f_GeomContainer) G4PCons( (G4Cons*)theSolid );
|
||||
else if ( theSolidType == "G4Hype")
|
||||
persSolid = new(f_GeomContainer) G4PHype( (G4Hype*)theSolid );
|
||||
else if ( theSolidType == "G4Para")
|
||||
persSolid = new(f_GeomContainer) G4PPara( (G4Para*)theSolid );
|
||||
else if ( theSolidType == "G4Sphere")
|
||||
persSolid = new(f_GeomContainer) G4PSphere( (G4Sphere*)theSolid );
|
||||
else if ( theSolidType == "G4Torus")
|
||||
persSolid = new(f_GeomContainer) G4PTorus( (G4Torus*)theSolid );
|
||||
else if ( theSolidType == "G4Trap")
|
||||
persSolid = new(f_GeomContainer) G4PTrap( (G4Trap*)theSolid );
|
||||
else if ( theSolidType == "G4Trd")
|
||||
persSolid = new(f_GeomContainer) G4PTrd( (G4Trd*)theSolid );
|
||||
else if ( theSolidType == "G4Tubs")
|
||||
persSolid = new(f_GeomContainer) G4PTubs( (G4Tubs*)theSolid );
|
||||
|
||||
// register persSolid to the geometry object lookup table
|
||||
if ( persSolid != NULL )
|
||||
f_GeomMap->Add( theSolid, persSolid );
|
||||
|
||||
} // end of if f_GeomMap->LookUp(theSolid)
|
||||
|
||||
return persSolid;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
G4VPhysicalVolume* G4PersistentGeomMan::MakeTransientObject (
|
||||
HepRef(G4PVPhysicalVolume) persPhysVol,
|
||||
HepRef(G4PVPhysicalVolume) persMotherVol )
|
||||
{
|
||||
// check the depth of the recursive call to this method
|
||||
if ( ++f_tRecursive > G4_PHYS_VOLUME_DEPTH_MAX )
|
||||
{
|
||||
G4cerr << "G4PersistentGeomMan::MakeTransientObject" <<
|
||||
" -- Physical Volume recursive depth reached to G4_PHYS_VOLUME_DEPTH_MAX."
|
||||
<< endl;
|
||||
return NULL;
|
||||
}
|
||||
#ifdef G4PERSISTENCY_DEBUG
|
||||
if ( f_tRecursive % 1000 == 0 )
|
||||
{
|
||||
G4cout << "G4PersistentGeomMan::MakeTransientObject" <<
|
||||
" -- Physical Volume recursive depth is " << f_tRecursive << endl;
|
||||
}
|
||||
#endif // G4PERSISTENCY_DEBUG
|
||||
|
||||
// check if the transient version of persPhysVol exists
|
||||
G4VPhysicalVolume* thePhysVol = f_GeomMap->LookUp(persPhysVol);
|
||||
if ( thePhysVol == NULL )
|
||||
{
|
||||
// Get the Logical Volume in persPhysVol
|
||||
HepRef(G4PLogicalVolume) persLogVol = persPhysVol->GetLogicalVolume();
|
||||
|
||||
// make the transient logical volume object from "persPhysVol"
|
||||
G4LogicalVolume* theLogVol =
|
||||
MakeTransientObject( persLogVol, persPhysVol );
|
||||
assert( theLogVol != NULL );
|
||||
|
||||
// Construct the transient version of persPhysVol
|
||||
G4VPhysicalVolume*
|
||||
thePhysVol = persPhysVol->MakeTransientObject(
|
||||
theLogVol, f_GeomMap->LookUp(persMotherVol) );
|
||||
assert( thePhysVol != NULL );
|
||||
|
||||
// register thePhysVol to the geometry object lookup table
|
||||
f_GeomMap->Add( persPhysVol, thePhysVol );
|
||||
|
||||
} // end of if f_GeomMap->LookUp(persPhysVol)
|
||||
|
||||
return thePhysVol;
|
||||
}
|
||||
|
||||
G4LogicalVolume* G4PersistentGeomMan::MakeTransientObject (
|
||||
HepRef(G4PLogicalVolume) persLogVol,
|
||||
HepRef(G4PVPhysicalVolume) persMotherVol )
|
||||
{
|
||||
// check if the transient version of persLogVol exists
|
||||
G4LogicalVolume* theLogVol = f_GeomMap->LookUp(persLogVol);
|
||||
if ( theLogVol == NULL )
|
||||
{
|
||||
// get the solid of the persistent logical volume
|
||||
HepRef(G4PVSolid) persSolid = persLogVol->GetSolid();
|
||||
assert( persSolid != NULL );
|
||||
|
||||
// check if the transient version of persSolid exists
|
||||
G4VSolid* theSolid = f_GeomMap->LookUp(persSolid);
|
||||
|
||||
if ( theSolid == NULL )
|
||||
{
|
||||
G4cerr << "G4PersistentGeomMan::MakeTransientObject" <<
|
||||
" -- transient Solid not found for the persistent Solid" << endl;
|
||||
}
|
||||
|
||||
// Construct the persistent version of theLogVol with theSolid
|
||||
theLogVol = persLogVol->MakeTransientObject(theSolid);
|
||||
assert( theLogVol != NULL );
|
||||
|
||||
// register theLogVol to the geometry object lookup table
|
||||
f_GeomMap->Add( persLogVol, theLogVol );
|
||||
|
||||
// loop through the daughter physical volumes in persLogVol
|
||||
G4int nDaughters = persLogVol->GetNoDaughters();
|
||||
for(G4int i=0;i<nDaughters;i++)
|
||||
{
|
||||
// Get the i-th daughter physics volume
|
||||
HepRef(G4PVPhysicalVolume) persDaughterPhysVol
|
||||
= persLogVol->GetDaughter(i);
|
||||
|
||||
// make the transient physics volume object from "persDaughterPhysVol"
|
||||
G4VPhysicalVolume* theDaughterPhysVol =
|
||||
MakeTransientObject( persDaughterPhysVol, persMotherVol );
|
||||
|
||||
// add transient daughter volume to the transient logical volume
|
||||
if ( theDaughterPhysVol != NULL )
|
||||
theLogVol->AddDaughter( theDaughterPhysVol );
|
||||
|
||||
} // end of for(G4int i=0;i<nDaughters;i++)
|
||||
|
||||
} // end of if f_GeomMap->LookUp(persLogVol)
|
||||
|
||||
return theLogVol;
|
||||
}
|
||||
|
||||
G4VSolid* G4PersistentGeomMan::MakeTransientObject (
|
||||
HepRef(G4PVSolid) persSolid )
|
||||
{
|
||||
// check if the persistent version of theSolid exists
|
||||
G4VSolid* transSolid = f_GeomMap->LookUp(persSolid);
|
||||
if ( transSolid == NULL )
|
||||
{
|
||||
#ifdef G4PERSISTENCY_DEBUG
|
||||
G4GeometryType theSolidType = persSolid->GetEntityType();
|
||||
G4cout << "G4PersistentGeomMan::MakePersistentObject (G4PVSolid) "
|
||||
<< "-- theSolidType is " << theSolidType << endl;
|
||||
#endif
|
||||
transSolid = persSolid->MakeTransientObject();
|
||||
assert( transSolid != NULL );
|
||||
f_GeomMap->Add( persSolid, transSolid );
|
||||
}
|
||||
|
||||
return transSolid;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -1,113 +0,0 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4PersistentRunMan.cc,v 1.1 1999/01/07 16:10:58 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
//
|
||||
// class G4PersistentRunMan
|
||||
//
|
||||
// Implementation for concrete G4PersistentRunMan.
|
||||
//
|
||||
// History:
|
||||
// 98.01.08 Y.Morita Initial version
|
||||
// 98.06.20 Y.Morita Implement geometry Store and Retrieve
|
||||
|
||||
#include "G4PersistentRunMan.hh"
|
||||
|
||||
#include "G4Run.hh"
|
||||
#include "G4PRun.hh"
|
||||
|
||||
#include "G4ios.hh"
|
||||
|
||||
G4PersistentRunMan::G4PersistentRunMan()
|
||||
{;}
|
||||
|
||||
G4PersistentRunMan::~G4PersistentRunMan()
|
||||
{;}
|
||||
|
||||
HepDatabaseRef G4PersistentRunMan::GetDB()
|
||||
{
|
||||
return f_RunDB;
|
||||
}
|
||||
|
||||
HepContainerRef G4PersistentRunMan::GetContainer()
|
||||
{
|
||||
return f_RunContainer;
|
||||
}
|
||||
|
||||
G4PersistentRunMan::LocateDB(HepDbApplication* dbApp,
|
||||
const G4String runDBName)
|
||||
{
|
||||
G4bool theStatus = true;
|
||||
|
||||
// start a transaction to create databases and containers
|
||||
dbApp->startUpdate();
|
||||
|
||||
// create a root named object tree namespace
|
||||
// namedRoot = new NamedNode;
|
||||
// NamedObjectTree namedTree( namedRoot );
|
||||
|
||||
// use database RunDB
|
||||
f_RunDB = dbApp->db("RunDB");
|
||||
|
||||
if (f_RunDB == NULL)
|
||||
{
|
||||
G4cerr << "Could not create or find RunDB database." << endl;
|
||||
theStatus = false;
|
||||
}
|
||||
|
||||
// create a new container for Run collection in this database
|
||||
f_RunContainer = dbApp->container("RunContainer");
|
||||
|
||||
if ( f_RunContainer == NULL )
|
||||
{
|
||||
G4cerr << "could not find or create RunContainer in the database" << endl;
|
||||
theStatus = false;
|
||||
}
|
||||
|
||||
// create a "RunDB" named object tree in the namespace
|
||||
// namedTree.mkdir("RunDB");
|
||||
// namedTree.cd("RunDB");
|
||||
|
||||
// Commit the update
|
||||
dbApp->commit();
|
||||
|
||||
return theStatus;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
G4bool G4PersistentRunMan::Store( HepDbApplication* dbApp,
|
||||
const G4Run* aRun)
|
||||
{
|
||||
// Start Update G4PRun in the database
|
||||
dbApp->startUpdate();
|
||||
|
||||
// Create persistent Run object
|
||||
new(f_RunContainer) G4PRun(aRun);
|
||||
|
||||
// Commit the update
|
||||
dbApp->commit();
|
||||
|
||||
#ifndef G4PERSISTENCY_DEBUG
|
||||
G4cout << "G4PRun " << aRun->GetRunID() << " Committed." << endl;
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
G4bool G4PersistentRunMan::Retrieve( HepDbApplication* dbApp,
|
||||
G4Run*& aRun)
|
||||
{
|
||||
// not implemented yet
|
||||
|
||||
G4bool fStatus = false;
|
||||
|
||||
fStatus = true;
|
||||
return fStatus;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,438 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4TransactionManager.cc,v 1.5.2.1 1999/12/07 20:50:14 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
// class G4TransactionManager
|
||||
//
|
||||
// Implementation for concrete G4TransactionManager.
|
||||
//
|
||||
// History:
|
||||
// 99.11.25 Y.Morita Initial version
|
||||
|
||||
#include "G4TransactionManager.hh"
|
||||
|
||||
#include "G4ios.hh"
|
||||
|
||||
// forward declarations
|
||||
#include "G4PersistentRunMan.hh"
|
||||
#include "G4PersistentEventMan.hh"
|
||||
#include "G4PersistentHitMan.hh"
|
||||
#include "G4PersistentDigitMan.hh"
|
||||
#include "G4PersistentGeomMan.hh"
|
||||
|
||||
G4TransactionManager::G4TransactionManager(
|
||||
G4PersistentRunMan* runMan,
|
||||
G4PersistentEventMan* eventMan,
|
||||
G4PersistentHitMan* hitMan,
|
||||
G4PersistentDigitMan* digitMan,
|
||||
G4PersistentGeomMan* geomMan)
|
||||
: f_RunDBName("Runs"), f_EventDBName("Events"), f_HitDBName("Events"),
|
||||
f_DigitDBName("Events"), f_GeomDBName("Geometry"),
|
||||
f_RunContainerName("RunContainer"), f_EventContainerName("EventContainer"),
|
||||
f_HitContainerName("EventContainer"), f_DigitContainerName("EventContainer"),
|
||||
f_GeomContainerName("GeomContainer"),
|
||||
f_pRunMan(runMan), f_pEventMan(eventMan), f_pHitMan(hitMan),
|
||||
f_pDigitMan(digitMan), f_pGeomMan(geomMan)
|
||||
{
|
||||
const G4String applicationName = "g4example";
|
||||
f_dbApp = new HepDbApplication(applicationName);
|
||||
|
||||
// Open and Initialize a database
|
||||
G4cout << "Opening federated database OO_FD_BOOT." << endl;
|
||||
f_dbApp->init();
|
||||
|
||||
// Locate or create run,event,geometry databases and containers
|
||||
SelectDB( kRunDB, f_RunDBName, kUpdate);
|
||||
SelectDB( kEventDB, f_EventDBName, kUpdate);
|
||||
SelectDB( kGeomDB, f_GeomDBName, kUpdate);
|
||||
}
|
||||
|
||||
G4TransactionManager::~G4TransactionManager()
|
||||
{
|
||||
delete f_dbApp;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
G4bool G4TransactionManager::StartTransaction(
|
||||
ETypeOfDB dbtype,
|
||||
ETransactionMode dbmode,
|
||||
G4bool isSustained)
|
||||
{
|
||||
ESustainedState f_sustainedState = CheckState(dbtype, isSustained);
|
||||
|
||||
switch(f_sustainedState)
|
||||
{
|
||||
case kAlreadySelected:
|
||||
if(f_verboseLevel>2)
|
||||
G4cout << "G4TransactionManager: Sustained transaction for /"
|
||||
<< DBName(f_whichDB) << "/ already in progress." << endl;
|
||||
break;
|
||||
case kCannotOverride:
|
||||
G4cerr << "G4TransactionManager: Cannot override the existing "
|
||||
<< "transaction for /" << DBName(f_whichDB) << "/" << endl;
|
||||
return false;
|
||||
break;
|
||||
case kStartNewSustained:
|
||||
f_isSustained = isSustained;
|
||||
f_whichDB = dbtype;
|
||||
f_transactionMode = dbmode;
|
||||
DoStart(dbtype, dbmode, true);
|
||||
break;
|
||||
case kCommitAndStartNonSustained:
|
||||
f_dbApp->commit();
|
||||
if(f_verboseLevel>1)
|
||||
G4cout << "Sustained transaction for /" << DBName(f_whichDB)
|
||||
<< "/ is paused." << endl;
|
||||
DoStart(dbtype, dbmode, false);
|
||||
break;
|
||||
case kStartNonSustained:
|
||||
DoStart(dbtype, dbmode, false);
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
ESustainedState G4TransactionManager::CheckState(
|
||||
ETypeOfDB dbtype, G4bool isSustained)
|
||||
{
|
||||
if( isSustained )
|
||||
if( f_isSustained )
|
||||
if( f_whichDB == dbtype )
|
||||
return kAlreadySelected;
|
||||
else
|
||||
return kCannotOverride;
|
||||
else
|
||||
return kStartNewSustained;
|
||||
else
|
||||
if( f_isSustained )
|
||||
if( f_whichDB == dbtype )
|
||||
return kAlreadySelected;
|
||||
else
|
||||
return kCommitAndStartNonSustained;
|
||||
else
|
||||
return kStartNonSustained;
|
||||
}
|
||||
|
||||
G4bool G4TransactionManager::DoStart(ETypeOfDB dbtype,
|
||||
ETransactionMode dbmode,
|
||||
G4bool isSustained)
|
||||
{
|
||||
switch(dbmode)
|
||||
{
|
||||
case kUpdate:
|
||||
f_dbApp->startUpdate();
|
||||
break;
|
||||
case kRead:
|
||||
f_dbApp->startRead();
|
||||
break;
|
||||
}
|
||||
|
||||
HepDatabaseRef aDBref = f_dbApp->db( DBName(dbtype) );
|
||||
if( aDBref == NULL )
|
||||
{
|
||||
G4cerr << "G4TransactionManager: Could not create or find /"
|
||||
<< DBName(dbtype) << "/ database." << endl;
|
||||
return false;
|
||||
}
|
||||
SetDB( dbtype, aDBref );
|
||||
|
||||
HepContainerRef aContRef = f_dbApp->container(ContainerName(dbtype));
|
||||
if( aContRef == NULL )
|
||||
{
|
||||
G4cerr << "G4TransactionManager: Could not create or find /"
|
||||
<< ContainerName(dbtype) << "/ container." << endl;
|
||||
return false;
|
||||
}
|
||||
SetContainer( dbtype, aContRef );
|
||||
|
||||
f_currentDB = dbtype;
|
||||
|
||||
if(f_verboseLevel>1)
|
||||
{
|
||||
G4cout << "Transaction started for /" << DBName(dbtype) << "/"
|
||||
<< ContainerName(dbtype) << "/ with ";
|
||||
if(isSustained)
|
||||
G4cout << "sustained mode." << endl;
|
||||
else
|
||||
G4cout << "non-sustained mode." << endl;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
G4bool G4TransactionManager::Commit(ETypeOfDB dbtype, G4bool isSustained)
|
||||
{
|
||||
if( dbtype == f_currentDB )
|
||||
{
|
||||
if( ! f_isSustained || isSustained )
|
||||
{
|
||||
f_dbApp->commit();
|
||||
|
||||
if(f_verboseLevel>1)
|
||||
G4cout << "Transaction is committed on /" << DBName(dbtype)
|
||||
<< "/" << ContainerName(dbtype) << "/" << endl;
|
||||
|
||||
if( f_isSustained && dbtype != f_whichDB )
|
||||
{
|
||||
StartTransaction( f_whichDB, f_transactionMode, true );
|
||||
if(f_verboseLevel>1)
|
||||
G4cout << "Resumeing transaction on /" << DBName(f_whichDB)
|
||||
<< "/" << ContainerName(f_whichDB) << "/" << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
f_isSustained = false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
G4cerr << "Error: Commit() received on /" << DBName(dbtype)
|
||||
<< "/" << ContainerName(dbtype) << "/" << endl
|
||||
<< " Current transaction is on /" << DBName(f_currentDB)
|
||||
<< "/" << ContainerName(f_currentDB) << "/" << endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
G4bool G4TransactionManager::Abort(ETypeOfDB dbtype, G4bool isSustained)
|
||||
{
|
||||
if( dbtype == f_currentDB )
|
||||
{
|
||||
if( ! f_isSustained || isSustained )
|
||||
{
|
||||
f_dbApp->abort();
|
||||
|
||||
if(f_verboseLevel>1)
|
||||
G4cout << "Transaction is aborted on /" << DBName(dbtype)
|
||||
<< "/" << ContainerName(dbtype) << "/" << endl;
|
||||
|
||||
if( f_isSustained && dbtype != f_whichDB )
|
||||
{
|
||||
StartTransaction( f_whichDB, f_transactionMode, true );
|
||||
if(f_verboseLevel>1)
|
||||
G4cout << "Resumeing transaction on /" << DBName(f_whichDB)
|
||||
<< "/" << ContainerName(f_whichDB) << "/" << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
f_isSustained = false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
G4cerr << "Error: Abort() received on /" << DBName(dbtype)
|
||||
<< "/" << ContainerName(dbtype) << "/" << endl
|
||||
<< " Current transaction is on /" << DBName(f_currentDB)
|
||||
<< "/" << ContainerName(f_currentDB) << "/" << endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
G4bool G4TransactionManager::SelectDB( ETypeOfDB dbtype,
|
||||
G4String dbname,
|
||||
G4bool updateMode)
|
||||
{
|
||||
G4bool theStatus = false;
|
||||
|
||||
G4String oldDBname = DBName(dbtype);
|
||||
SetDBName(dbtype, dbname);
|
||||
|
||||
// start a non-sustained transaction for this database type
|
||||
if( StartTransaction( dbtype, kUpdate, false ) )
|
||||
{
|
||||
Commit( dbtype, false );
|
||||
// update database ref and container ref in SubDbManagers
|
||||
SendDB(dbtype);
|
||||
SendContainer(dbtype);
|
||||
theStatus = true;
|
||||
|
||||
if(f_verboseLevel>0)
|
||||
G4cout << "Set database to /"
|
||||
<< DBName(dbtype) << "/." << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Abort( dbtype, false );
|
||||
SetDBName(dbtype, oldDBname);
|
||||
G4cerr << "G4TransactionManager: Failed to set database /"
|
||||
<< DBName(dbtype) << "/." << endl;
|
||||
theStatus = false;
|
||||
}
|
||||
|
||||
return theStatus;
|
||||
}
|
||||
|
||||
G4String G4TransactionManager::DBName(ETypeOfDB dbtype)
|
||||
{
|
||||
switch(dbtype)
|
||||
{
|
||||
case kRunDB:
|
||||
return f_RunDBName;
|
||||
break;
|
||||
case kEventDB:
|
||||
return f_EventDBName;
|
||||
break;
|
||||
case kGeomDB:
|
||||
return f_GeomDBName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
G4String G4TransactionManager::ContainerName(ETypeOfDB dbtype)
|
||||
{
|
||||
switch(dbtype)
|
||||
{
|
||||
case kRunDB:
|
||||
return f_RunContainerName;
|
||||
break;
|
||||
case kEventDB:
|
||||
return f_EventContainerName;
|
||||
break;
|
||||
case kGeomDB:
|
||||
return f_GeomContainerName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
HepDatabaseRef G4TransactionManager::DBref(ETypeOfDB dbtype)
|
||||
{
|
||||
switch(dbtype)
|
||||
{
|
||||
case kRunDB:
|
||||
return f_RunDB;
|
||||
break;
|
||||
case kEventDB:
|
||||
return f_EventDB;
|
||||
break;
|
||||
case kGeomDB:
|
||||
return f_GeomDB;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
HepContainerRef G4TransactionManager::ContainerRef(ETypeOfDB dbtype)
|
||||
{
|
||||
switch(dbtype)
|
||||
{
|
||||
case kRunDB:
|
||||
return f_RunContainer;
|
||||
break;
|
||||
case kEventDB:
|
||||
return f_EventContainer;
|
||||
break;
|
||||
case kGeomDB:
|
||||
return f_GeomContainer;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void G4TransactionManager::SetDBName(ETypeOfDB dbtype, G4String dbname)
|
||||
{
|
||||
switch(dbtype)
|
||||
{
|
||||
case kRunDB:
|
||||
f_RunDBName = dbname;
|
||||
break;
|
||||
case kEventDB:
|
||||
f_EventDBName = dbname;
|
||||
f_HitDBName = dbname;
|
||||
f_DigitDBName = dbname;
|
||||
break;
|
||||
case kGeomDB:
|
||||
f_GeomDBName = dbname;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void G4TransactionManager::SetDB(ETypeOfDB dbtype, HepDatabaseRef aDB)
|
||||
{
|
||||
switch(dbtype)
|
||||
{
|
||||
case kRunDB:
|
||||
f_RunDB = aDB;
|
||||
break;
|
||||
case kEventDB:
|
||||
f_EventDB = aDB;
|
||||
f_HitDB = aDB;
|
||||
f_DigitDB = aDB;
|
||||
break;
|
||||
case kGeomDB:
|
||||
f_GeomDB = aDB;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void G4TransactionManager::SetContainer(ETypeOfDB dbtype, HepContainerRef aCont)
|
||||
{
|
||||
switch(dbtype)
|
||||
{
|
||||
case kRunDB:
|
||||
f_RunContainer = aCont;
|
||||
break;
|
||||
case kEventDB:
|
||||
f_EventContainer = aCont;
|
||||
f_HitContainer = aCont;
|
||||
f_DigitContainer = aCont;
|
||||
break;
|
||||
case kGeomDB:
|
||||
f_GeomContainer = aCont;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void G4TransactionManager::SendDB(ETypeOfDB dbtype)
|
||||
{
|
||||
switch(dbtype)
|
||||
{
|
||||
case kRunDB:
|
||||
f_pRunMan->SetDB(f_RunDB);
|
||||
break;
|
||||
case kEventDB:
|
||||
f_pEventMan->SetDB(f_EventDB);
|
||||
f_pHitMan ->SetDB(f_EventDB);
|
||||
f_pDigitMan->SetDB(f_EventDB);
|
||||
break;
|
||||
case kGeomDB:
|
||||
f_pGeomMan->SetDB(f_GeomDB);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void G4TransactionManager::SendContainer(ETypeOfDB dbtype)
|
||||
{
|
||||
switch(dbtype)
|
||||
{
|
||||
case kRunDB:
|
||||
f_pRunMan->SetContainer(f_RunContainer);
|
||||
break;
|
||||
case kEventDB:
|
||||
f_pEventMan->SetContainer(f_EventContainer);
|
||||
f_pHitMan ->SetContainer(f_EventContainer);
|
||||
f_pDigitMan->SetContainer(f_EventContainer);
|
||||
break;
|
||||
case kGeomDB:
|
||||
f_pGeomMan->SetContainer(f_GeomContainer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
G4String G4TransactionManager::DBContainerName(ETypeOfDB dbtype)
|
||||
{
|
||||
G4String aString = "/" + DBName(dbtype) + "/" + ContainerName(dbtype) + "/";
|
||||
return aString;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user