Import Geant4 6.2.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 10:56:29 +02:00
parent 1d812b78b1
commit e083ffb441
1415 changed files with 111223 additions and 21207 deletions
+2 -1
View File
@@ -1,4 +1,4 @@
# $Id: GNUmakefile,v 1.6 2003/06/20 13:03:51 gcosmo Exp $
# $Id: GNUmakefile,v 1.7 2004/06/11 14:17:19 gcosmo Exp $
# --------------------------------------------------------------------
# GNUmakefile for geometry/volumes library. Gabriele Cosmo, 16/11/96.
# --------------------------------------------------------------------
@@ -11,6 +11,7 @@ endif
include $(G4INSTALL)/config/architecture.gmk
CPPFLAGS += -DG4GEOM_ALLOC_EXPORT
CPPFLAGS += -I$(G4BASE)/graphics_reps/include \
-I$(G4BASE)/intercoms/include \
-I$(G4BASE)/global/management/include \
+24 -1
View File
@@ -1,4 +1,4 @@
$Id: History,v 1.118 2004/03/04 08:07:12 gcosmo Exp $
$Id: History,v 1.122 2004/06/09 07:26:05 gcosmo Exp $
-------------------------------------------------------------------
=========================================================
@@ -17,6 +17,29 @@ committal in the CVS repository !
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
Jun 9th, 2004 G. Cosmo - geomvol-V06-01-03
- Adopt G4DLLIMPORT/G4DLLEXPORT technique to handle extern simbols for
allowing support of DLLs on Windows.
- Coworks with "global-V06-01-02b".
Jun 7th, 2004 G. Cosmo - geomvol-V06-01-02
- Export extern symbols for allowing support of DLLs on Windows.
Modified files: G4NavigationLevel.icc, G4NavigationLevelRep.icc.
- Coworks with "global-V06-01-02a".
May 19th, 2004 G. Cosmo - geomvol-V06-01-01
- Added CleanSurfaceTable() static methods in G4LogicalBorderSurface and
G4LogicalSkinSurface classes for the clearing of the surface tables in
case of dynamic geometries (by T.MacPhail).
May 13th, 2004 G. Cosmo - geomvol-V06-01-00
- Imported G4ReflectionFactory and unit test 'testG4ReflectedSolid' from
module "solids/Boolean".
- Enhanced G4ReflectionFactory to support reflection of divided volumes
(courtesy of I.Hrivnacova). Added Divide(...) set of methods.
- Coworks with tags: geommng-V06-01-00, geomdiv-V06-01-00 and
geom-bool-V06-01-00.
March 4th, 2004 G. Cosmo - geomvol-V06-00-01
- G4NavigationHistory.icc: fixed bug in NewLevel() causing segmentation
violation for cases of geometry with deep nested levels. Fixes problem
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4LogicalBorderSurface.hh,v 1.12 2003/12/01 14:53:26 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00-patch-01 $
// $Id: G4LogicalBorderSurface.hh,v 1.13 2004/05/19 08:14:38 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
// class G4LogicalBorderSurface
//
@@ -72,6 +72,7 @@ class G4LogicalBorderSurface : public G4LogicalSurface
inline void SetVolume2( G4VPhysicalVolume* vol2 );
// To use with care!
static void CleanSurfaceTable();
static const std::vector<G4LogicalBorderSurface*> * GetSurfaceTable();
static size_t GetNumberOfBorderSurfaces();
static void DumpInfo();
@@ -104,3 +105,4 @@ typedef std::vector<G4LogicalBorderSurface*> G4LogicalBorderSurfaceTable;
#include "G4LogicalBorderSurface.icc"
#endif /* G4LogicalBorderSurface_h */
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4LogicalSkinSurface.hh,v 1.12 2003/12/01 14:53:26 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00-patch-01 $
// $Id: G4LogicalSkinSurface.hh,v 1.13 2004/05/19 08:14:39 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
// class G4LogicalSkinSurface
//
@@ -62,6 +62,7 @@ class G4LogicalSkinSurface : public G4LogicalSurface
inline void SetLogicalVolume(G4LogicalVolume* vol);
// Accessors.
static void CleanSurfaceTable();
static size_t GetNumberOfSkinSurfaces();
static void DumpInfo(); // const
// To handle with the table of surfaces.
@@ -95,3 +96,4 @@ typedef std::vector<G4LogicalSkinSurface*> G4LogicalSkinSurfaceTable;
#include "G4LogicalSkinSurface.icc"
#endif /* G4LogicalSkinSurface_h */
@@ -21,14 +21,18 @@
// ********************************************************************
//
//
// $Id: G4NavigationLevel.icc,v 1.15 2003/12/04 15:58:08 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00-patch-01 $
// $Id: G4NavigationLevel.icc,v 1.18 2004/06/11 14:17:20 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
// 30.09.97 J.Apostolakis Initial version.
//
// ----------------------------------------------------------------------
extern G4Allocator<G4NavigationLevel> aNavigationLevelAllocator;
#if defined G4GEOM_ALLOC_EXPORT
extern G4DLLEXPORT G4Allocator<G4NavigationLevel> aNavigationLevelAllocator;
#else
extern G4DLLIMPORT G4Allocator<G4NavigationLevel> aNavigationLevelAllocator;
#endif
inline
G4NavigationLevel::G4NavigationLevel( G4VPhysicalVolume* pPhysVol,
@@ -21,14 +21,18 @@
// ********************************************************************
//
//
// $Id: G4NavigationLevelRep.icc,v 1.9 2003/12/04 15:58:08 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00-patch-01 $
// $Id: G4NavigationLevelRep.icc,v 1.12 2004/06/11 14:17:21 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
// 1 October 1997 J.Apostolakis Initial version.
//
// ----------------------------------------------------------------------
extern G4Allocator<G4NavigationLevelRep> aNavigLevelRepAllocator;
#if defined G4GEOM_ALLOC_EXPORT
extern G4DLLEXPORT G4Allocator<G4NavigationLevelRep> aNavigLevelRepAllocator;
#else
extern G4DLLIMPORT G4Allocator<G4NavigationLevelRep> aNavigLevelRepAllocator;
#endif
// Constructors
//--------------
@@ -0,0 +1,244 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * 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: G4ReflectionFactory.hh,v 1.1 2004/05/13 14:50:58 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
//
// class G4ReflectionFactory
//
// Class description:
//
// Class providing functions for volumes placements with a general
// transfomation that can contain reflection.
// Reflection is then applied to a solid: a new G4ReflectedSolid
// instance is created and is placed with a transformation containing
// pure rotation and translation only.
// The pair of constituent and reflected logical volumes is
// considered as a generalized logical volume that is addressed
// by user specifying the constituent logical volume.
//
// Decomposition of a general transformation that can include reflection
// in a "reflection-free" transformation:
//
// x(inM') = TG*x(inM) TG - general transformation
// = T*(R*x(inM)) T - "reflection-free" transformation
// = T* x(inReflM)
//
// Daughters transformation:
// When a volume V containing daughter D with transformation TD
// is placed in mother M with a general tranformation TGV,
// the TGV is decomposed. New reflected volume ReflV containing
// a new daughter ReflD with reflected transformation ReflTD is created:
//
// x(inV) = TD * x(inD);
// x(inM) = TGV * x(inV)
// = TV * R * x(inV)
// = TV * R * TD * x(inD)
// = TV * R*TD*R-1 * R*x(inD)
// = TV * ReflTD * x(inReflD)
// Author: Ivana Hrivnacova, 16.10.2001 (Ivana.Hrivnacova@cern.ch)
// --------------------------------------------------------------------
#ifndef G4_REFLECTION_FACTORY_HH
#define G4_REFLECTION_FACTORY_HH
#include "G4Types.hh"
#include "G4Transform3D.hh"
#include "geomdefs.hh"
#include <map>
class G4VPhysicalVolume;
class G4LogicalVolume;
class G4VSolid;
class G4VPVDivisionFactory;
typedef std::pair<G4VPhysicalVolume*,
G4VPhysicalVolume*> G4PhysicalVolumesPair;
typedef std::map<G4LogicalVolume*, G4LogicalVolume*,
std::less<G4LogicalVolume*> > G4ReflectedVolumesMap;
class G4ReflectionFactory
{
typedef G4ReflectedVolumesMap::const_iterator LogicalVolumesMapIterator;
public: // with description
virtual ~G4ReflectionFactory();
// Virtual destructor.
static G4ReflectionFactory* Instance();
// Gets pointer to the instance of the singleton.
G4PhysicalVolumesPair Place(const G4Transform3D& transform3D,
const G4String& name,
G4LogicalVolume* LV,
G4LogicalVolume* motherLV,
G4bool isMany,
G4int copyNo);
// Evaluates the passed transformation; if it contains reflection
// it performs its decomposition, creates new reflected solid and
// logical volume (or retrieves them from a map if the reflected
// objects were already created), transforms the daughters (if present)
// and place it in the given mother.
// The result is a pair of physical volumes;
// the second physical volume is a placement in a reflected mother
// or 0 if mother LV was not reflected.
G4PhysicalVolumesPair Replicate(const G4String& name,
G4LogicalVolume* LV,
G4LogicalVolume* motherLV,
EAxis axis,
G4int nofReplicas,
G4double width,
G4double offset=0);
// Creates replica in the given mother.
// The result is a pair of physical volumes;
// the second physical volume is a replica in a reflected mother
// or 0 if mother LV was not reflected.
G4PhysicalVolumesPair Divide(const G4String& name,
G4LogicalVolume* LV,
G4LogicalVolume* motherLV,
EAxis axis,
G4int nofDivisions,
G4double width,
G4double offset);
G4PhysicalVolumesPair Divide(const G4String& name,
G4LogicalVolume* LV,
G4LogicalVolume* motherLV,
EAxis axis,
G4int nofDivisions,
G4double offset);
G4PhysicalVolumesPair Divide(const G4String& name,
G4LogicalVolume* LV,
G4LogicalVolume* motherLV,
EAxis axis,
G4double width,
G4double offset);
// Creates division in the given mother.
// The result is a pair of physical volumes;
// the second physical volume is a division in a reflected mother
// or 0 if mother LV was not reflected.
void SetVerboseLevel(G4int verboseLevel);
G4int GetVerboseLevel() const;
// Sets/gets verbosity level.
void SetVolumesNameExtension(const G4String& nameExtension);
G4String GetVolumesNameExtension() const;
// Returns the name extension for the reflected solids
// and logical volumes.
void SetScalePrecision(G4double scaleValue);
G4double GetScalePrecision() const;
// Sets/gets precision factor for the scale consistency check
// The default value is set to 10*kCarTolerance.
G4LogicalVolume* GetConstituentLV(G4LogicalVolume* reflLV) const;
// Returns the consituent volume of the given reflected volume,
// 0 if the given reflected volume was not found.
G4LogicalVolume* GetReflectedLV(G4LogicalVolume* lv) const;
// Returns the reflected volume of the given consituent volume,
// 0 if the given volume was not reflected.
G4bool IsConstituent(G4LogicalVolume* lv) const;
// Returns true if the given volume has been already reflected
// (is in the map of constituent volumes).
G4bool IsReflected(G4LogicalVolume* lv) const;
// Returns true if the given volume is a reflected volume
// (is in the map reflected volumes).
const G4ReflectedVolumesMap& GetReflectedVolumesMap() const;
// Returns a handle to the internal map of volumes which have
// been reflected, after that placement or replication is performed.
protected:
G4ReflectionFactory();
// Protected singleton constructor.
G4ReflectionFactory(const G4ReflectionFactory&);
G4ReflectionFactory& operator=(const G4ReflectionFactory&);
// Disabled copy constructor and assignment operator.
private:
G4LogicalVolume* ReflectLV(G4LogicalVolume* LV);
// Gets/creates the reflected solid and logical volume
// and copies + transforms LV daughters.
G4LogicalVolume* CreateReflectedLV(G4LogicalVolume* LV);
// Creates the reflected solid and logical volume
// and add the logical volumes pair in the maps.
void ReflectDaughters(G4LogicalVolume* LV, G4LogicalVolume* refLV);
// Reflects daughters recursively.
void ReflectPVPlacement(G4VPhysicalVolume* PV, G4LogicalVolume* refLV);
// Copies and transforms daughter of PVPlacement type of
// a constituent volume into a reflected volume.
void ReflectPVReplica(G4VPhysicalVolume* PV, G4LogicalVolume* refLV);
// Copies and transforms daughter of PVReplica type of
// a constituent volume into a reflected volume.
void ReflectPVDivision(G4VPhysicalVolume* PV, G4LogicalVolume* refLV);
// Copies and transforms daughter of PVDivision type of
// a constituent volume into a reflected volume.
void ReflectPVParameterised(G4VPhysicalVolume* PV, G4LogicalVolume* refLV);
// Not implemented yet.
// Should copy and transform daughter of PVReplica type of
// a constituent volume into a reflected volume.
G4bool IsReflection(const G4Scale3D& scale) const;
// Returns true if the scale is negative, false otherwise.
void CheckScale(const G4Scale3D& scale) const;
// Checks if scale correspond to fScale, if not gives exception.
G4VPVDivisionFactory* GetPVDivisionFactory() const;
// Checks if the division factory is instanciated,
// if not gives exception.
void PrintConstituentLVMap();
// Temporary - for debugging purpose.
private:
static G4ReflectionFactory* fInstance;
static const G4String fDefaultNameExtension;
static const G4Scale3D fScale;
G4double fScalePrecision;
G4int fVerboseLevel;
G4String fNameExtension;
G4ReflectedVolumesMap fConstituentLVMap;
G4ReflectedVolumesMap fReflectedLVMap;
};
#endif
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4LogicalBorderSurface.cc,v 1.12 2003/12/01 14:53:26 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00-patch-01 $
// $Id: G4LogicalBorderSurface.cc,v 1.13 2004/05/19 08:14:42 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
// --------------------------------------------------------------------
// G4LogicalBorderSurface Implementation
@@ -146,3 +146,14 @@ void G4LogicalBorderSurface::DumpInfo()
}
G4cout << G4endl;
}
void G4LogicalBorderSurface::CleanSurfaceTable()
{
std::vector<G4LogicalBorderSurface*>::iterator pos;
for(pos=theBorderSurfaceTable.begin();
pos!=theBorderSurfaceTable.end(); pos++)
{
if (*pos) delete *pos;
}
theBorderSurfaceTable.clear();
}
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4LogicalSkinSurface.cc,v 1.11 2003/12/01 14:53:26 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00-patch-01 $
// $Id: G4LogicalSkinSurface.cc,v 1.12 2004/05/19 08:14:42 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
// --------------------------------------------------------------------
// G4LogicalSkinSurface Implementation
@@ -137,3 +137,13 @@ void G4LogicalSkinSurface::DumpInfo()
}
G4cout << G4endl;
}
void G4LogicalSkinSurface::CleanSurfaceTable()
{
std::vector<G4LogicalSkinSurface*>::iterator pos;
for(pos=theSurfaceTable.begin(); pos!=theSurfaceTable.end(); pos++)
{
if (*pos) delete *pos;
}
theSurfaceTable.clear();
}
@@ -0,0 +1,851 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * 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: G4ReflectionFactory.cc,v 1.1 2004/05/13 14:51:19 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
//
// Class G4ReflectionFactory Implementation
//
// Decomposition of a general transformation
// that can include reflection in a "reflection-free" transformation:
//
// x(inM') = TG*x(inM) TG - general transformation
// = T*(R*x(inM)) T - "reflection-free" transformation
// = T* x(inReflM)
//
// Daughters transformation:
// When a volume V containing daughter D with transformation TD
// is placed in mother M with a general tranformation TGV,
// the TGV is decomposed,
// new reflected volume ReflV containing a new daughter ReflD
// with reflected transformation ReflTD is created:
//
// x(inV) = TD * x(inD);
// x(inM) = TGV * x(inV)
// = TV * R * x(inV)
// = TV * R * TD * x(inD)
// = TV * R*TD*R-1 * R*x(inD)
// = TV * ReflTD * x(inReflD)
// Author: Ivana Hrivnacova, 16.10.2001 (Ivana.Hrivnacova@cern.ch)
// --------------------------------------------------------------------
#include "G4ReflectionFactory.hh"
#include "G4ReflectedSolid.hh"
#include "G4LogicalVolume.hh"
#include "G4PVPlacement.hh"
#include "G4PVReplica.hh"
#include "G4VPVDivisionFactory.hh"
G4ReflectionFactory* G4ReflectionFactory::fInstance = 0;
const G4String G4ReflectionFactory::fDefaultNameExtension = "_refl";
const G4Scale3D G4ReflectionFactory::fScale = G4ScaleZ3D(-1.0);
//_____________________________________________________________________________
G4ReflectionFactory* G4ReflectionFactory::Instance()
{
// Static singleton access method.
// ---
if (!fInstance) new G4ReflectionFactory();
return fInstance;
}
//_____________________________________________________________________________
G4ReflectionFactory::G4ReflectionFactory()
: fVerboseLevel(0),
fNameExtension(fDefaultNameExtension)
{
// Protected singleton constructor.
// ---
fScalePrecision = 10.*kCarTolerance;
fInstance = this;
}
//_____________________________________________________________________________
G4ReflectionFactory::~G4ReflectionFactory()
{
}
//
// public methods
//
//_____________________________________________________________________________
G4PhysicalVolumesPair
G4ReflectionFactory::Place( const G4Transform3D& transform3D,
const G4String& name,
G4LogicalVolume* LV,
G4LogicalVolume* motherLV,
G4bool isMany,
G4int copyNo)
{
// Evaluates the passed transformation; if it contains reflection
// it performs its decomposition, creates new reflected solid and
// logical volume (or retrieves them from a map if the reflected
// objects were already created), transforms the daughters (if present)
// and place it in the given mother.
// The result is a pair of physical volumes;
// the second physical volume is a placement in a reflected mother
// - or 0 if mother LV was not reflected.
// ---
if (fVerboseLevel>0)
{
G4cout << "Place " << name << " lv " << LV << " "
<< LV->GetName() << G4endl;
}
// decompose transformation
G4Scale3D scale;
G4Rotate3D rotation;
G4Translate3D translation;
transform3D.getDecomposition(scale, rotation, translation);
G4Transform3D pureTransform3D = translation * rotation;
//PrintTransform(transform3D);
//PrintTransform(pureTransform3D);
// check that scale correspond to fScale
//
CheckScale(scale);
//
// reflection IS NOT present in transform3D
//
if (! IsReflection(scale))
{
if (fVerboseLevel>0)
G4cout << "Scale positive" << G4endl;
G4VPhysicalVolume* pv1
= new G4PVPlacement(pureTransform3D, LV, name, motherLV, isMany, copyNo);
G4VPhysicalVolume* pv2 = 0;
if (G4LogicalVolume* reflMotherLV = GetReflectedLV(motherLV))
{
// if mother was reflected
// reflect this LV and place it in reflected mother
pv2 = new G4PVPlacement(fScale * (pureTransform3D * fScale.inverse()),
ReflectLV(LV),name,reflMotherLV,isMany,copyNo);
}
return G4PhysicalVolumesPair(pv1, pv2);
}
//
// reflection IS present in transform3D
//
if (fVerboseLevel>0)
G4cout << "scale negative" << G4endl;
G4VPhysicalVolume* pv1
= new G4PVPlacement(pureTransform3D,
ReflectLV(LV), name, motherLV, isMany, copyNo);
G4VPhysicalVolume* pv2 = 0;
if (G4LogicalVolume* reflMotherLV = GetReflectedLV(motherLV))
{
// if mother was reflected
// place the refLV consituent in reflected mother
pv2 = new G4PVPlacement(fScale * (pureTransform3D * fScale.inverse()),
LV, name, reflMotherLV, isMany, copyNo);
}
return G4PhysicalVolumesPair(pv1, pv2);
}
//_____________________________________________________________________________
G4PhysicalVolumesPair
G4ReflectionFactory::Replicate(const G4String& name,
G4LogicalVolume* LV,
G4LogicalVolume* motherLV,
EAxis axis,
G4int nofReplicas,
G4double width,
G4double offset)
{
// Creates replica in given mother.
// The result is a pair of physical volumes;
// the second physical volume is a replica in a reflected mother
// - or 0 if mother LV was not reflected.
// ---
if (fVerboseLevel>0)
{
G4cout << "Replicate " << name << " lv " << LV << " "
<< LV->GetName() << G4endl;
}
G4VPhysicalVolume* pv1
= new G4PVReplica(name, LV, motherLV, axis, nofReplicas, width, offset);
G4VPhysicalVolume* pv2 = 0;
if (G4LogicalVolume* reflMotherLV = GetReflectedLV(motherLV))
{
// if mother was reflected
// reflect the LV and replicate it in reflected mother
pv2 = new G4PVReplica(name, ReflectLV(LV), reflMotherLV,
axis, nofReplicas, width, offset);
}
return G4PhysicalVolumesPair(pv1, pv2);
}
//_____________________________________________________________________________
G4PhysicalVolumesPair
G4ReflectionFactory::Divide(const G4String& name,
G4LogicalVolume* LV,
G4LogicalVolume* motherLV,
EAxis axis,
G4int nofDivisions,
G4double width,
G4double offset)
{
// Creates division in the given mother.
// The result is a pair of physical volumes;
// the second physical volume is a division in a reflected mother
// or 0 if mother LV was not reflected.
// ---
if (fVerboseLevel>0)
{
G4cout << "Divide " << name << " lv " << LV << " "
<< LV->GetName() << G4endl;
}
G4VPVDivisionFactory* divisionFactory = GetPVDivisionFactory();
G4VPhysicalVolume* pv1 = divisionFactory
->CreatePVDivision(name, LV, motherLV, axis, nofDivisions, width, offset);
G4VPhysicalVolume* pv2 = 0;
if (G4LogicalVolume* reflMotherLV = GetReflectedLV(motherLV))
{
// if mother was reflected
// reflect the LV and replicate it in reflected mother
pv2 = divisionFactory->CreatePVDivision(name, ReflectLV(LV), reflMotherLV,
axis, nofDivisions, width, offset);
}
return G4PhysicalVolumesPair(pv1, pv2);
}
//_____________________________________________________________________________
G4PhysicalVolumesPair
G4ReflectionFactory::Divide(const G4String& name,
G4LogicalVolume* LV,
G4LogicalVolume* motherLV,
EAxis axis,
G4int nofDivisions,
G4double offset)
{
// Creates division in the given mother.
// The result is a pair of physical volumes;
// the second physical volume is a division in a reflected mother
// or 0 if mother LV was not reflected.
// ---
if (fVerboseLevel>0)
{
G4cout << "Divide " << name << " lv " << LV << " "
<< LV->GetName() << G4endl;
}
G4VPVDivisionFactory* divisionFactory = GetPVDivisionFactory();
G4VPhysicalVolume* pv1 = divisionFactory
->CreatePVDivision(name, LV, motherLV, axis, nofDivisions, offset);
G4VPhysicalVolume* pv2 = 0;
if (G4LogicalVolume* reflMotherLV = GetReflectedLV(motherLV))
{
// if mother was reflected
// reflect the LV and replicate it in reflected mother
pv2 = divisionFactory->CreatePVDivision(name, ReflectLV(LV), reflMotherLV,
axis, nofDivisions, offset);
}
return G4PhysicalVolumesPair(pv1, pv2);
}
//_____________________________________________________________________________
G4PhysicalVolumesPair
G4ReflectionFactory::Divide(const G4String& name,
G4LogicalVolume* LV,
G4LogicalVolume* motherLV,
EAxis axis,
G4double width,
G4double offset)
{
// Creates division in the given mother.
// The result is a pair of physical volumes;
// the second physical volume is a division in a reflected mother
// or 0 if mother LV was not reflected.
// ---
if (fVerboseLevel>0)
{
G4cout << "Divide " << name << " lv " << LV << " "
<< LV->GetName() << G4endl;
}
G4VPVDivisionFactory* divisionFactory = GetPVDivisionFactory();
G4VPhysicalVolume* pv1 = divisionFactory
-> CreatePVDivision(name, LV, motherLV, axis, width, offset);
G4VPhysicalVolume* pv2 = 0;
if (G4LogicalVolume* reflMotherLV = GetReflectedLV(motherLV))
{
// if mother was reflected
// reflect the LV and replicate it in reflected mother
pv2 = divisionFactory->CreatePVDivision(name, ReflectLV(LV), reflMotherLV,
axis, width, offset);
}
return G4PhysicalVolumesPair(pv1, pv2);
}
//
// private methods
//
//_____________________________________________________________________________
G4LogicalVolume* G4ReflectionFactory::ReflectLV(G4LogicalVolume* LV)
{
// Gets/creates the reflected solid and logical volume
// and copies + transforms LV daughters.
// ---
G4LogicalVolume* refLV = GetReflectedLV(LV);
if (!refLV)
{
// create new (reflected) objects
//
refLV = CreateReflectedLV(LV);
// process daughters
//
ReflectDaughters(LV, refLV);
}
return refLV;
}
//_____________________________________________________________________________
G4LogicalVolume* G4ReflectionFactory::CreateReflectedLV(G4LogicalVolume* LV)
{
// Creates the reflected solid and logical volume
// and add the logical volumes pair in the maps.
// ---
// consistency check
//
if (fReflectedLVMap.find(LV) != fReflectedLVMap.end())
{
G4cerr << "ERROR - G4ReflectionFactory::CreateReflectedLV(..): "
<< LV->GetName() << G4endl
<< " Cannot be applied to an already reflected volume !"
<< G4endl;
G4Exception("G4ReflectionFactory::CreateReflectedLV(..)",
"NotApplicable", FatalException,
"Cannot be applied to a volume already reflected.");
}
G4VSolid* refSolid
= new G4ReflectedSolid(LV->GetSolid()->GetName() + fNameExtension,
LV->GetSolid(), fScale);
G4LogicalVolume* refLV
= new G4LogicalVolume(refSolid,
LV->GetMaterial(),
LV->GetName() + fNameExtension,
LV->GetFieldManager(),
LV->GetSensitiveDetector(),
LV->GetUserLimits());
fConstituentLVMap[LV] = refLV;
fReflectedLVMap[refLV] = LV;
return refLV;
}
//_____________________________________________________________________________
void G4ReflectionFactory::ReflectDaughters(G4LogicalVolume* LV,
G4LogicalVolume* refLV)
{
// Reflects daughters recursively.
// ---
if (fVerboseLevel>0)
{
G4cout << "G4ReflectionFactory::ReflectDaughters(): "
<< LV->GetNoDaughters() << " of " << LV->GetName() << G4endl;
}
for (G4int i=0; i<LV->GetNoDaughters(); i++)
{
G4VPhysicalVolume* dPV = LV->GetDaughter(i);
if (! dPV->IsReplicated())
{
ReflectPVPlacement(dPV, refLV);
}
else if (! dPV->GetParameterisation())
{
ReflectPVReplica(dPV, refLV);
}
else if (G4VPVDivisionFactory::Instance() &&
G4VPVDivisionFactory::Instance()->IsPVDivision(dPV))
{
ReflectPVDivision(dPV, refLV);
}
else
{
ReflectPVParameterised(dPV, refLV);
}
}
}
//_____________________________________________________________________________
void G4ReflectionFactory::ReflectPVPlacement(G4VPhysicalVolume* dPV,
G4LogicalVolume* refLV)
{
// Copies and transforms daughter of PVPlacement type of
// a constituent volume into a reflected volume.
// ---
G4LogicalVolume* dLV = dPV->GetLogicalVolume();
// update daughter transformation
//
G4Transform3D dt(dPV->GetObjectRotationValue(), dPV->GetObjectTranslation());
dt = fScale * (dt * fScale.inverse());
G4LogicalVolume* refDLV;
if (fVerboseLevel>0)
G4cout << "Daughter: " << dPV << " " << dLV->GetName();
if (!IsReflected(dLV))
{
if (fVerboseLevel>0)
G4cout << " will be reflected." << G4endl;
// get reflected volume if already created //
refDLV = GetReflectedLV(dLV);
if (!refDLV)
{
// create new daughter solid and logical volume
//
refDLV = CreateReflectedLV(dLV);
// recursive call
//
ReflectDaughters(dLV, refDLV);
}
// create new daughter physical volume
// with updated transformation
new G4PVPlacement(dt, refDLV, dPV->GetName(), refLV,
dPV->IsMany(), dPV->GetCopyNo());
}
else
{
if (fVerboseLevel>0)
G4cout << " will be reconstitued." << G4endl;
refDLV = GetConstituentLV(dLV);
new G4PVPlacement(dt, refDLV, dPV->GetName(), refLV,
dPV->IsMany(), dPV->GetCopyNo());
}
}
//_____________________________________________________________________________
void G4ReflectionFactory::ReflectPVReplica(G4VPhysicalVolume* dPV,
G4LogicalVolume* refLV)
{
// Copies and transforms daughter of PVReplica type of
// a constituent volume into a reflected volume.
// ---
G4LogicalVolume* dLV = dPV->GetLogicalVolume();
// get replication data
//
EAxis axis;
G4int nofReplicas;
G4double width;
G4double offset;
G4bool consuming;
dPV->GetReplicationData(axis, nofReplicas, width, offset, consuming);
G4LogicalVolume* refDLV;
if (fVerboseLevel>0)
G4cout << "Daughter: " << dPV << " " << dLV->GetName();
if (!IsReflected(dLV))
{
if (fVerboseLevel>0)
G4cout << " will be reflected." << G4endl;
// get reflected volume if already created
//
refDLV = GetReflectedLV(dLV);
if (!refDLV)
{
// create new daughter solid and logical volume
//
refDLV = CreateReflectedLV(dLV);
// recursive call
//
ReflectDaughters(dLV, refDLV);
}
// create new daughter replica
//
new G4PVReplica(dPV->GetName(), refDLV, refLV,
axis, nofReplicas, width, offset);
}
else
{
if (fVerboseLevel>0)
G4cout << " will be reconstitued." << G4endl;
refDLV = GetConstituentLV(dLV);
new G4PVReplica(dPV->GetName(), refDLV, refLV,
axis, nofReplicas, width, offset);
}
}
//_____________________________________________________________________________
void G4ReflectionFactory::ReflectPVDivision(G4VPhysicalVolume* dPV,
G4LogicalVolume* refLV)
{
// Copies and transforms daughter of PVDivision type of
// a constituent volume into a reflected volume.
// ---
G4VPVDivisionFactory* divisionFactory = GetPVDivisionFactory();
G4LogicalVolume* dLV = dPV->GetLogicalVolume();
// get parameterisation data
//
G4VPVParameterisation* param = dPV->GetParameterisation();
G4LogicalVolume* refDLV;
if (fVerboseLevel>0)
G4cout << "Daughter: " << dPV << " " << dLV->GetName();
if (!IsReflected(dLV))
{
if (fVerboseLevel>0)
G4cout << " will be reflected." << G4endl;
// get reflected volume if already created
//
refDLV = GetReflectedLV(dLV);
if (!refDLV)
{
// create new daughter solid and logical volume
//
refDLV = CreateReflectedLV(dLV);
// recursive call
//
ReflectDaughters(dLV, refDLV);
}
// create new daughter replica
//
divisionFactory->CreatePVDivision(dPV->GetName(), refDLV, refLV, param);
}
else
{
if (fVerboseLevel>0)
G4cout << " will be reconstitued." << G4endl;
refDLV = GetConstituentLV(dLV);
divisionFactory->CreatePVDivision(dPV->GetName(), refDLV, refLV, param);
}
}
//_____________________________________________________________________________
void G4ReflectionFactory::ReflectPVParameterised(G4VPhysicalVolume* dPV,
G4LogicalVolume*)
{
// Not implemented.
// Should copy and transform daughter of PVReplica type of
// a constituent volume into a reflected volume.
// ---
G4cerr << "ERROR - G4ReflectionFactory::ReflectPVParameterised(...): "
<< dPV->GetName() << G4endl
<< " Reflection of parameterised volumes "
<< "is not yet implemented." << G4endl;
G4Exception("G4ReflectionFactory::ReflectPVParameterised(...)",
"NotImplemented", FatalException,
"Sorry, not yet implemented.");
}
//_____________________________________________________________________________
G4LogicalVolume*
G4ReflectionFactory::GetConstituentLV(G4LogicalVolume* reflLV) const
{
// Returns the consituent volume of the given reflected volume,
// 0 if the given reflected volume was not found.
// ---
LogicalVolumesMapIterator it = fReflectedLVMap.find(reflLV);
if (it == fReflectedLVMap.end()) return 0;
return (*it).second;
}
//_____________________________________________________________________________
G4LogicalVolume*
G4ReflectionFactory::GetReflectedLV(G4LogicalVolume* lv) const
{
// Returns the reflected volume of the given consituent volume,
// 0 if the given volume was not reflected.
// ---
LogicalVolumesMapIterator it = fConstituentLVMap.find(lv);
if (it == fConstituentLVMap.end()) return 0;
return (*it).second;
}
//_____________________________________________________________________________
G4bool G4ReflectionFactory::IsConstituent(G4LogicalVolume* lv) const
{
// Returns true if the given volume has been already reflected
// (is in the map of constituent volumes).
// ---
return (fConstituentLVMap.find(lv) != fConstituentLVMap.end());
}
//_____________________________________________________________________________
G4bool G4ReflectionFactory::IsReflected(G4LogicalVolume* lv) const
{
// Returns true if the given volume is a reflected volume
// (is in the map reflected volumes).
// ---
return (fReflectedLVMap.find(lv) != fReflectedLVMap.end());
}
//_____________________________________________________________________________
G4bool G4ReflectionFactory::IsReflection(const G4Scale3D& scale) const
{
// Returns true if the scale is negative, false otherwise.
// ---
if (scale(0,0)*scale(1,1)*scale(2,2) < 0.)
return true;
else
return false;
}
//_____________________________________________________________________________
const G4ReflectedVolumesMap&
G4ReflectionFactory::GetReflectedVolumesMap() const
{
return fReflectedLVMap;
}
//_____________________________________________________________________________
void G4ReflectionFactory::PrintConstituentLVMap()
{
// temporary - for debugging purpose
// ---
LogicalVolumesMapIterator it;
for (it = fConstituentLVMap.begin(); it != fConstituentLVMap.end(); it++)
{
G4cout << "lv: " << (*it).first << " lv_refl: " << (*it).second << G4endl;
}
G4cout << G4endl;
}
//_____________________________________________________________________________
void G4ReflectionFactory::CheckScale(const G4Scale3D& scale) const
{
// Check if scale correspond to fScale,
// if not give exception.
// ---
if (!IsReflection(scale)) return;
G4double diff = 0.;
for (G4int i=0; i<4; i++)
for (G4int j=0; j<4; j++)
diff += abs(scale(i,j) - fScale(i,j));
if (diff > fScalePrecision)
{
G4cerr << "ERROR - G4ReflectionFactory::CheckScale(..)" << G4endl
<< " Unexpected scale. Difference: " << diff << G4endl;
G4Exception("G4ReflectionFactory::CheckScale(..)",
"WrongArgumentValue", FatalException,
"Unexpected scale in input !");
}
}
//_____________________________________________________________________________
G4VPVDivisionFactory* G4ReflectionFactory::GetPVDivisionFactory() const
{
// Returns the G4PVDivisionFactory instance if it exists,
// otherwise gives exception
// ---
G4VPVDivisionFactory* divisionFactory = G4VPVDivisionFactory::Instance();
if (!divisionFactory)
{
G4cerr << "ERROR - G4ReflectionFactory::GetPVDivisionFactory()" << G4endl
<< " It has been requested to reflect divided volumes."
<< G4endl
<< " In this case, it is required to instantiate a concrete"
<< G4endl
<< " factory G4PVDivisionFactory in your program -before-"
<< G4endl
<< " executing the reflection !" << G4endl;
G4Exception("G4ReflectionFactory::GetPVDivisionFactory()",
"WrongSetup", FatalException,
"A concrete G4PVDivisionFactory instantiated is required !");
}
return divisionFactory;
}
//_____________________________________________________________________________
void G4ReflectionFactory::SetScalePrecision(G4double scaleValue)
{
fScalePrecision = scaleValue;
}
//_____________________________________________________________________________
G4double G4ReflectionFactory::GetScalePrecision() const
{
return fScalePrecision;
}
//_____________________________________________________________________________
void G4ReflectionFactory::SetVerboseLevel(G4int verboseLevel)
{
fVerboseLevel = verboseLevel;
}
//_____________________________________________________________________________
G4int G4ReflectionFactory::GetVerboseLevel() const
{
return fVerboseLevel;
}
//_____________________________________________________________________________
void G4ReflectionFactory::SetVolumesNameExtension(const G4String& nameExtension)
{
fNameExtension = nameExtension;
}
//_____________________________________________________________________________
G4String G4ReflectionFactory::GetVolumesNameExtension() const
{
return fNameExtension;
}
/*
// placement with decomposed transformation
G4VPhysicalVolume* pv1
= new G4PVPlacement(new G4RotationMatrix(rotation.getRotation().inverse()),
translation.getTranslation(),
refLV, name, motherLV, isMany, copyNo);
*/
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4TouchableHistory.cc,v 1.8 2003/12/05 17:10:53 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00-patch-01 $
// $Id: G4TouchableHistory.cc,v 1.10 2004/06/11 14:17:22 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
//
// class G4TouchableHistory Implementation