Import Geant4 0.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-01 15:25:35 +02:00
parent 54d6b71f95
commit b97f8d0df7
3237 changed files with 807095 additions and 0 deletions
+59
View File
@@ -0,0 +1,59 @@
# $Id: GNUmakefile,v 2.5 1998/11/09 17:07:16 morita Exp $
name := G4pmanagement
G4ODBMS := true
ifndef G4INSTALL
G4INSTALL = ../../..
endif
include $(G4INSTALL)/config/architecture.gmk
# $(G4TMPDIR) will be overrided in common.gmk later.
G4TMPDIR := $(G4TMP)/$(G4SYSTEM)/$(name)
CPPFLAGS += \
-Iinclude \
-I$(G4TMPDIR) \
-I../geometry/management/include \
-I$(G4TMP)/$(G4SYSTEM)/G4pgeomn \
-I../geometry/volumes/include \
-I$(G4TMP)/$(G4SYSTEM)/G4pvol \
-I../geometry/solids/CSG/include \
-I$(G4TMP)/$(G4SYSTEM)/G4pcsg \
-I../events/include \
-I$(G4TMP)/$(G4SYSTEM)/G4pevents \
-I$(G4TMP)/$(G4SYSTEM)/G4prun \
-I$(G4INSTALL)/source/run/include \
-I$(G4INSTALL)/source/event/include \
-I$(G4INSTALL)/source/global/management/include \
-I$(G4INSTALL)/source/global/HEPRandom/include \
-I$(G4INSTALL)/source/global/HEPGeometry/include \
-I$(G4INSTALL)/source/geometry/management/include \
-I$(G4INSTALL)/source/geometry/volumes/include \
-I$(G4INSTALL)/source/geometry/solids/CSG/include \
-I$(G4INSTALL)/source/events+tracks/include \
-I$(G4INSTALL)/source/processes/management/include \
-I$(G4INSTALL)/source/materials/include \
-I$(G4INSTALL)/source/particles/management/include \
-I$(G4INSTALL)/source/graphics_reps/include \
-I$(G4INSTALL)/source/tracking/include \
-I$(G4INSTALL)/source/track/include \
-I$(G4INSTALL)/source/digits+hits/detector/include \
-I$(G4INSTALL)/source/digits+hits/hits/include \
-I$(G4INSTALL)/source/digits+hits/digits/include
#--------------------------------------------------------------------
include $(G4INSTALL)/config/G4ODBMS_BUILD.gmk
include $(G4INSTALL)/config/common.gmk
#--------------------------------------------------------------------
# Explicit DDL dependencies:
# G4PEvent.ddl includes G4PPrimaryVertex.hh, so G4PPrimaryVertex.hh
# should be created before G4PEvent.hh.
$(G4TMPDIR)/G4PEvent.hh: $(G4TMPDIR)/G4PPrimaryVertex.hh
#--------------------------------------------------------------------
@@ -0,0 +1,147 @@
// 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.ddl,v 2.5 1998/07/14 14:12:35 morita Exp $
// GEANT4 tag $Name: geant4-00 $
//
// class G4PGeometryObjectMap
//
// A Class responsible for keeping track of the geometry object map.
//
// This class is persistent-capable.
//
// Member functions:
// =================
// G4PGeometryObjectMap( G4PString theGeometryName );
// ~G4PGeometryObjectMap();
//
// protected:
// G4PVPhysicalVolume* LookUp( G4VPhysicalVolume* aPhysVol );
// void Add( const G4VPhysicalVolume* aPhysVol,
// const G4PVPhysicalVolume* persPhysVol );
// G4PLogicalVolume* LookUp(G4LogicalVolume* aLogVol);
// void Add( const G4LogicalVolume* aLogVol,
// const G4PLogicalVolume* persLogVol );
// G4PVSolid* LookUp(G4VSolid* aSolid);
// void Add( const G4VSolid* aSolid,
// const G4PVSolid* persSolid );
// G4int GetNoSolids();
// G4VSolid* GetSolid(G4int n);
// G4PVSolid* GetPSolid(G4int n);
//
// Note:
// =====
// This class contains RWTPtrVector of the transient classes.
// As a result, ooddlx compiler will issue warnings as follows, but it's okay.
// The value of RWTPtrVector is used only in transient case
// in this class, and you can safely ignore these warnings.
// ----
// "include/G4PGeometryObjectMap.ddl", line xxx: warning: persistent-capable
// class member type is a problem
// The type of base class RWPtrVector is a problem
// The type of member RWPtrVector::array_ is pointer
// The type of base class RWTPtrVector<G4VPhysicalVolume > is a
// problem
// The type of base class RWPtrVector is a problem
// G4PhysVolRefVArray transPhysVolPtrs;
// ^
// ----
//
//
// History:
// 98.06.20 Y.Morita Initial version
#ifndef G4PGeometryObjectMap_h
#define G4PGeometryObjectMap_h 1
#include <rw/tpordvec.h>
#include "globals.hh"
#include "G4VPhysicalVolume.hh"
#include "G4LogicalVolume.hh"
#include "G4VSolid.hh"
#include "G4PersistentTypes.hh"
#include "HepODBMS/odbms/HepODBMS.h"
#include "G4PVPhysicalVolume.hh"
#include "G4PVPhysVolRefVArray.hh"
#include "G4PLogicalVolume.hh"
#include "G4PLogVolRefVArray.hh"
#include "G4PVSolid.hh"
#include "G4PVSolidRefVArray.hh"
typedef RWTPtrVector<G4VPhysicalVolume> G4VPhysVolRefVArray;
typedef RWTPtrVector<G4LogicalVolume> G4LogVolRefVArray;
typedef RWTPtrVector<G4VSolid> G4VSolidRefVArray;
class G4PGeometryObjectMap
: public HepPersObj
{
public:
G4PGeometryObjectMap();
G4PGeometryObjectMap( const G4String theGeometryName );
~G4PGeometryObjectMap();
// template cannot be used in class scope!!
// template<class T_IN, class T_OUT> T_OUT LookUp( const T_IN aGeomObj );
HepRef(G4PVPhysicalVolume) LookUp( G4VPhysicalVolume* aPhysVol );
G4VPhysicalVolume* LookUp( HepRef(G4PVPhysicalVolume) aPhysVol );
HepRef(G4PLogicalVolume) LookUp( G4LogicalVolume* aLogVol);
G4LogicalVolume* LookUp( HepRef(G4PLogicalVolume) aLogVol);
HepRef(G4PVSolid) LookUp( G4VSolid* aSolid);
G4VSolid* LookUp( HepRef(G4PVSolid) persSolid);
void Add( G4VPhysicalVolume* aPhysVol,
HepRef(G4PVPhysicalVolume) persPhysVol );
void Add( HepRef(G4PVPhysicalVolume) persPhysVol,
G4VPhysicalVolume* aPhysVol );
void Add( G4LogicalVolume* aLogVol,
HepRef(G4PLogicalVolume) persLogVol );
void Add( HepRef(G4PLogicalVolume) persLogVol,
G4LogicalVolume* aLogVol );
void Add( G4VSolid* aSolid,
HepRef(G4PVSolid) persSolid );
void Add( HepRef(G4PVSolid) persSolid,
G4VSolid* aSolid );
inline void SetWorldVolume( const HepRef(G4PVPhysicalVolume) aWorld )
{ thePersistentWorldVolume = aWorld; }
inline HepRef(G4PVPhysicalVolume) GetWorldVolume()
{ return thePersistentWorldVolume; }
inline G4int GetNoPhysVol() const { return noPhysVol; }
inline G4int GetNoLogVol() const { return noLogVol; }
inline G4int GetNoSolids() const { return noSolids; }
G4VSolid* GetSolid(G4int n);
HepRef(G4PVSolid) GetPSolid(G4int n);
void InitTransientMap();
private:
// World Volume of this Geometry object tree
ooRef(G4PVPhysicalVolume) thePersistentWorldVolume;
// Physics Volume Pointer Array
G4Pint noPhysVol;
G4VPhysVolRefVArray transPhysVolPtrs;
G4PVPhysVolRefVArray persPhysVolPtrs;
// Logical Volume Pointer Array
G4Pint noLogVol;
G4LogVolRefVArray transLogVolPtrs;
G4PLogVolRefVArray persLogVolPtrs;
// Solid Pointer Array
G4Pint noSolids;
G4VSolidRefVArray transSolidPtrs;
G4PVSolidRefVArray persSolidPtrs;
};
#endif
@@ -0,0 +1,20 @@
//
// G4PLogVolRefVArray.hh
//
// HepRefVArray typedefs for Geant4/Persistency category
//
// It is the user's responsibility to include header files
// of classes G4PLogicalVolume.hh _before_ including this file.
//
// History:
// 09.07.98 Y.Morita - Created
#ifndef G4PLOGVOLREFVARRAY_HH
#define G4PLOGVOLREFVARRAY_HH 1
#include "HepODBMS/odbms/HepRefVArray.h"
declare(HepRefVArray,G4PLogicalVolume)
typedef HepRefVArray(G4PLogicalVolume) G4PLogVolRefVArray;
#endif /* G4PLOGVOLREFVARRAY_HH */
@@ -0,0 +1,20 @@
//
// G4PVPhysVolRefVArray.hh
//
// HepRefVArray typedefs for Geant4/Persistency category
//
// It is the user's responsibility to include header files
// of classes G4PVPhysicalVolume.hh _before_ including this file.
//
// History:
// 09.07.98 Y.Morita - Created
#ifndef G4PVPHYSVOLREFVARRAY_HH
#define G4PVPHYSVOLREFVARRAY_HH 1
#include "HepODBMS/odbms/HepRefVArray.h"
declare(HepRefVArray,G4PVPhysicalVolume)
typedef HepRefVArray(G4PVPhysicalVolume) G4PVPhysVolRefVArray;
#endif /* G4PVPHYSVOLREFVARRAY_HH */
@@ -0,0 +1,20 @@
//
// G4PVSolidRefVArray.hh
//
// HepRefVArray typedefs for Geant4/Persistency category
//
// It is the user's responsibility to include header files
// of classes G4PVSolid.hh _before_ including this file.
//
// History:
// 09.07.98 Y.Morita - Created
#ifndef G4PVSOLIDREFVARRAY_HH
#define G4PVSOLIDREFVARRAY_HH 1
#include "HepODBMS/odbms/HepRefVArray.h"
declare(HepRefVArray,G4PVSolid)
typedef HepRefVArray(G4PVSolid) G4PVSolidRefVArray;
#endif /* G4PVSOLIDREFVARRAY_HH */
@@ -0,0 +1,103 @@
// 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: G4PersistencyManager.hh,v 2.5 1998/11/09 17:21:42 morita Exp $
// GEANT4 tag $Name: geant4-00 $
//
// class G4PersistencyManager
//
// A Class responsible for storing and retrieving the run, event,
// Hit and geometry objects into ODBMS using HepODBMS interface.
//
// The class is `singleton', with access via
// G4PersistencyManager::GetPersistencyManager.
//
// This class itself is not persistent-capable.
//
// Member functions:
// =================
// static G4PersistencyManager* GetPersistencyManager();
// static G4PersistencyManager* get_PersistencyManagerIfExist();
// Return ptr to singleton instance of the class.
//
// G4bool Store(const G4Event* anEvent);
// Store anEvent and associated objects into a database.
// G4bool Store(const G4Run* aRun);
// Store aRun and associated objects into a database.
// G4bool Store(const G4VPhysicalVolume* aWorld);
// Store aWorld and entire geometry object tree into a database.
//
// G4bool Retrieve(G4Event*& anEvent);
// Retrieve anEvent and associated objects from a database.
// G4bool Retrieve(G4Run*& aRun);
// Retrieve aRun and associated objects from a database.
// G4bool Retrieve(G4VPhysicalVolume*& aWorld);
// Retrieve aWorld and entire geometry object tree from a database.
//
// Member data:
// ============
// static G4PersistencyManager* fPersistencyManager
// Ptr to the unique instance of class
//
// History:
// 98.01.08 Y.Morita Initial version
// 98.06.20 Y.Morita Implement geometry Store and Retrieve
// 98.10.30 Y.Morita Splitted into event/run/geometry utility classes
#ifndef G4PERSISTENCYMANAGER_HH
#define G4PERSISTENCYMANAGER_HH 1
#include "globals.hh"
#include "G4VPersistencyManager.hh"
#include "G4PersistentEventMan.hh"
#include "G4PersistentRunMan.hh"
#include "G4PersistentGeomMan.hh"
////#include "HepODBMS/clustering/HepContainerHint.h"
#include "HepODBMS/clustering/HepDbApplication.h"
class G4PersistencyManager
: public G4VPersistencyManager
{
public:
static G4PersistencyManager* GetPersistencyManager();
static G4PersistencyManager* get_PersistencyManagerIfExist();
G4PersistencyManager();
public:
~G4PersistencyManager();
private:
HepDbApplication* dbApp;
// static HepRef(NamedNode) namedRoot;
// static NamedObjectTree*
private:
static G4PersistencyManager * f_PersistencyManager;
public:
G4bool Store(const G4Event* anEvent);
G4bool Store(const G4Run* aRun);
G4bool Store(const G4VPhysicalVolume* aWorld);
G4bool Retrieve(G4Event*& anEvent);
G4bool Retrieve(G4Run*& aRun);
G4bool Retrieve(G4VPhysicalVolume*& aWorld);
// Utility Classes
private:
G4PersistentEventMan f_pEventMan;
G4PersistentRunMan f_pRunMan;
G4PersistentGeomMan f_pGeomMan;
};
#endif
@@ -0,0 +1,70 @@
// 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.hh,v 2.1 1998/11/09 17:19:04 morita Exp $
// GEANT4 tag $Name: geant4-00 $
//
// class G4PersistentEventMan
//
// A Utility class for storing and retrieving the event objects.
//
// This class is not persistent-capable.
//
// Member functions:
// =================
// G4bool Store(const G4Event* anEvent);
// Store anEvent and associated objects into database.
// G4bool Retrieve(G4Event*& anEvent);
// Retrieve anEvent and associated objects into database.
// G4Bool LocateDB( HepDBApplication* dbApp,
// const G4String eventDBName );
// Create and locate event database and container.
//
// Member data:
// ============
// HepDatabaseRef f_EventDB;
// Reference to the event database.
// HepContainerRef f_EventContainer;
// Reference to the event container in the database.
//
// History:
// 98.10.30 Y.Morita Splited from G4PersistencyManager
#ifndef G4PERSISTENTEVENTMAN_H
#define G4PERSISTENTEVENTMAN_H 1
#include "globals.hh"
#include "HepODBMS/clustering/HepDbApplication.h"
class G4Event;
class G4PersistentEventMan
{
public:
G4PersistentEventMan();
~G4PersistentEventMan();
HepDatabaseRef GetDB();
HepContainerRef GetContainer();
G4bool LocateDB( HepDbApplication* dbApp,
const G4String eventDBName );
private:
HepDatabaseRef f_EventDB;
HepContainerRef f_EventContainer;
public:
G4bool Store( HepDbApplication* dbApp,
const G4Event* anEvent );
G4bool Retrieve( HepDbApplication* dbApp,
G4Event*& anEvent );
};
#endif
@@ -0,0 +1,111 @@
// 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.hh,v 2.2 1998/11/10 18:23:41 morita Exp $
// GEANT4 tag $Name: geant4-00 $
//
// class G4PersistentGeomMan
//
// A Utility class for storing and retrieving the geometry objects.
//
// This class is not persistent-capable.
//
// Member functions:
// =================
//
//
// Member data:
// ============
// static G4PersistentGeomMan* fPersistencyManager
// Ptr to the unique instance of class
//
// History:
// 98.10.30 Y.Morita Splited from G4PersistencyManager
#ifndef G4PERSISTENTGEOMMAN_H
#define G4PERSISTENTGEOMMAN_H 1
#include "globals.hh"
#include "geomdefs.hh"
#include "HepODBMS/clustering/HepDbApplication.h"
#define G4_PHYS_VOLUME_DEPTH_MAX 1000000
class G4VSolid;
class G4PEvent;
class G4VPhysicalVolume;
class G4LogicalVolume;
class G4PVPhysicalVolume;
class G4PLogicalVolume;
class G4PVSolid;
#include "G4PGeometryObjectMap.hh"
class G4PersistentGeomMan
{
public:
G4PersistentGeomMan();
~G4PersistentGeomMan();
private:
HepDatabaseRef f_GeomDB;
HepContainerRef f_GeomContainer;
HepRef(G4PGeometryObjectMap) f_GeomMap;
public:
G4bool Store( HepDbApplication* dbApp,
const G4VPhysicalVolume* aWorld );
G4bool Retrieve( HepDbApplication* dbApp,
G4VPhysicalVolume*& aWorld );
private:
// Characterise `type' of volume - normal/replicated/parameterised
EVolume VolumeType(const G4VPhysicalVolume *pVol) const;
HepRef(G4PVPhysicalVolume) MakePersistentObject (
G4VPhysicalVolume* aPhysVol );
HepRef(G4PLogicalVolume) MakePersistentObject (
G4LogicalVolume* aLogVol );
HepRef(G4PVSolid) MakePersistentObject ( G4VSolid* aSolid );
G4VPhysicalVolume* MakeTransientObject (
HepRef(G4PVPhysicalVolume) aPhysVol,
HepRef(G4PVPhysicalVolume) theMotherVol );
G4LogicalVolume* MakeTransientObject (
HepRef(G4PLogicalVolume) aLogVol,
HepRef(G4PVPhysicalVolume) theMotherVol );
G4VSolid* MakeTransientObject ( HepRef(G4PVSolid) aSolid );
private:
G4int f_nRecursive;
G4int f_tRecursive;
G4PString f_GeomMapScopeName;
};
inline EVolume G4PersistentGeomMan::VolumeType(const G4VPhysicalVolume *pVol) const
{
EVolume type;
EAxis axis;
G4int nReplicas;
G4double width,offset;
G4bool consuming;
if (pVol->IsReplicated())
{
pVol->GetReplicationData(axis,nReplicas,width,offset,consuming);
type=(consuming) ? kReplica : kParameterised;
}
else
{
type=kNormal;
}
return type;
}
#endif
@@ -0,0 +1,68 @@
// 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.hh,v 2.1 1998/11/09 17:19:06 morita Exp $
// GEANT4 tag $Name: geant4-00 $
//
// class G4PersistentRunMan
//
// A Utility class for storing and retrieving the run objects.
//
// This class is not persistent-capable.
//
// Member functions:
// =================
// G4bool Store(const G4Run* aRun);
// Store aRun and associated objects into database.
// G4bool Retrieve(G4Run*& aRun);
// Retrieve aRun and associated objects into database.
// G4Bool LocateDB( HepDbApplication* dbApp,
// const G4String runDBName );
// Create and locate run database and container.
//
// Member data:
// ============
// HepDatabaseRef f_RunDB;
// Reference to the run database.
// HepContainerRef f_RunContainer;
// Reference to the run container in the database.
//
// History:
// 98.10.30 Y.Morita Splited from G4PersistencyManager
#ifndef G4PERSISTENTRUNMAN_H
#define G4PERSISTENTRUNMAN_H 1
#include "globals.hh"
#include "HepODBMS/clustering/HepDbApplication.h"
class G4Run;
class G4PersistentRunMan
{
public:
G4PersistentRunMan();
~G4PersistentRunMan();
HepDatabaseRef GetDB();
HepContainerRef GetContainer();
G4bool LocateDB( HepDbApplication* dbApp,
const G4String runDBName );
private:
HepDatabaseRef f_RunDB;
HepContainerRef f_RunContainer;
public:
G4bool Store( HepDbApplication* dbApp, const G4Run* aRun);
G4bool Retrieve( HepDbApplication* dbApp, G4Run*& aRun );
};
#endif
@@ -0,0 +1,29 @@
// 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: G4PersistentTypes.hh,v 2.0 1998/07/02 16:13:43 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Persistent-capable typedefs for Geant4/Persistency category
//
// History:
// 15.06.98 Y.Morita - Created
#ifndef G4_PERSISTENT_TYPES_HH
#define G4_PERSISTENT_TYPES_HH
// Typedefs to decouple from library classes
#include <HepODBMS/odbms/HepODBMS.h>
typedef d_String G4PString;
typedef d_Double G4Pdouble;
typedef d_Float G4Pfloat;
typedef d_Long G4Pint;
typedef d_Long G4Plong;
#endif /* G4_PERSISTENT_TYPES_HH */
@@ -0,0 +1,280 @@
// 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 2.2 1998/07/14 14:15:04 morita Exp $
// GEANT4 tag $Name: geant4-00 $
//
// 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 eacy class
// (Required by Objectivity/DB)
implement(HepRefVArray,G4PVPhysicalVolume)
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;
}
@@ -0,0 +1,121 @@
// 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: G4PersistencyManager.cc,v 2.7 1998/11/09 17:22:07 morita Exp $
// GEANT4 tag $Name: geant4-00 $
//
// class G4PersistencyManager
//
// Implementation for concrete G4PersistencyManager.
//
// History:
// 98.01.08 Y.Morita Initial version
// 98.06.20 Y.Morita Implement geometry Store and Retrieve
#include "G4PersistencyManager.hh"
#include "G4ios.hh"
G4PersistencyManager* G4PersistencyManager::f_PersistencyManager = NULL;
G4PersistencyManager* G4PersistencyManager::GetPersistencyManager()
{
if(!f_PersistencyManager)
{
f_PersistencyManager = new G4PersistencyManager;
}
return f_PersistencyManager;
}
G4PersistencyManager* G4PersistencyManager::get_PersistencyManagerIfExist()
{ return f_PersistencyManager; }
G4PersistencyManager::G4PersistencyManager()
{
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;
}
}
G4PersistencyManager::~G4PersistencyManager()
{
// Any persistent objects which are created during save() should
// not be deleted in ~G4PersistencyManager() implicitly, 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;
}
//----------------------------------------------------------------------------
G4bool G4PersistencyManager::Store(const G4Event* anEvent)
{
return f_pEventMan.Store(dbApp, anEvent);
}
G4bool G4PersistencyManager::Store(const G4Run* aRun)
{
return f_pRunMan.Store(dbApp, aRun);
}
G4bool G4PersistencyManager::Store(const G4VPhysicalVolume* aWorld)
{
return f_pGeomMan.Store(dbApp, aWorld);
}
G4bool G4PersistencyManager::Retrieve(G4Event*& anEvent)
{
return f_pEventMan.Retrieve(dbApp, anEvent);
}
G4bool G4PersistencyManager::Retrieve(G4Run*& aRun)
{
return f_pRunMan.Retrieve(dbApp, aRun);
}
G4bool G4PersistencyManager::Retrieve(G4VPhysicalVolume*& theWorld)
{
return f_pGeomMan.Retrieve(dbApp, theWorld);
}
@@ -0,0 +1,117 @@
// 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 2.1 1998/11/09 17:19:46 morita Exp $
// GEANT4 tag $Name: geant4-00 $
//
// 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;
}
@@ -0,0 +1,491 @@
// 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 2.2 1998/11/10 18:27:43 morita Exp $
// GEANT4 tag $Name: geant4-00 $
//
// 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;
}
//----------------------------------------------------------------------------
@@ -0,0 +1,113 @@
// 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 2.2 1998/11/10 04:05:52 morita Exp $
// GEANT4 tag $Name: geant4-00 $
//
// 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;
}