Index: /trunk/source/g3tog4/GNUmakefile
===================================================================
--- /trunk/source/g3tog4/GNUmakefile	(revision 817)
+++ /trunk/source/g3tog4/GNUmakefile	(revision 817)
@@ -0,0 +1,190 @@
+###############################################################################
+###  GNUmakefile for the G3 to G4 conversion package.
+###
+###  T. Wenaus 20/11/1995
+###  Uses chunks of John Allison's generic makefiles.
+###
+###  The presence of Fortran and several standalone programs
+###  make this package non-generic enough to require its
+###  own makefile.
+###
+###############################################################################
+
+G4TARGET := rztog4
+
+name := G3toG4
+
+ifndef G4INSTALL
+  G4INSTALL := ../..
+endif
+
+GLOBLIBS  = libG4tracking.lib libG4processes.lib libG4digits_hits.lib
+GLOBLIBS += libG4track.lib libG4particles.lib libG4geometry.lib
+GLOBLIBS += libG4materials.lib libG4graphics_reps.lib
+GLOBLIBS += libG4intercoms.lib libG4global.lib
+
+include $(G4INSTALL)/config/architecture.gmk
+
+CPPFLAGS  += \
+             -I$(G4BASE)/global/management/include \
+             -I$(G4BASE)/global/HEPGeometry/include \
+             -I$(G4BASE)/global/HEPRandom/include \
+             -I$(G4BASE)/geometry/magneticfield/include \
+             -I$(G4BASE)/geometry/volumes/include \
+             -I$(G4BASE)/geometry/management/include \
+             -I$(G4BASE)/geometry/solids/CSG/include \
+             -I$(G4BASE)/geometry/solids/specific/include \
+             -I$(G4BASE)/geometry/solids/Boolean/include \
+             -I$(G4BASE)/geometry/solids/BREPS/include \
+             -I$(G4BASE)/graphics_reps/include \
+             -I$(G4BASE)/materials/include \
+             -I$(G4BASE)/particles/management/include \
+             -I$(G4BASE)/processes/management/include \
+             -I$(G4BASE)/processes/general/include \
+             -I$(G4BASE)/processes/decay/include \
+             -I$(G4BASE)/track/include \
+             -I$(G4BASE)/tracking/include \
+             -I$(G4BASE)/digits_hits/detector/include \
+             -I$(G4BASE)/digits_hits/hits/include
+
+###	kludge for AIX
+
+ifeq ($(FC),xlf)
+	cpp_include_flag=-WF,-I
+### -d writes out F*.f file
+	FCFLAGS += -d $(patsubst -I%,$(cpp_include_flag)%,-Iinclude)
+### xlf prepends .f name with F
+	dotf_prepend=F
+else
+### other compilers do not prepend .f name with F
+	dotf_prepend=
+	FCFLAGS += -Iinclude
+endif
+
+.SUFFIXES: 
+.SUFFIXES:	.a .o .cc .cxx .c .f .F .d
+
+### --------------------- vpaths ----------------------------------------------
+
+vpath %.hh  $(patsubst -I%,%,$(filter -I%,$(CPPFLAGS)))
+vpath %.inc $(patsubst -I%,%,$(filter -I%,$(CPPFLAGS)))
+
+G4LIBDIR := $(G4LIB)/$(G4SYSTEM)
+G4TMPDIR := $(G4TMP)/$(G4SYSTEM)/$(name)
+G4BINDIR := $(G4BIN)/$(G4SYSTEM)
+
+Fbinsources = src/$(G4TARGET).F
+Fbinobjects = $(patsubst src/%.F,$(G4TMPDIR)/%.o,$(Fbinsources))
+Flibsources = $(filter-out $(Fbinsources),$(wildcard src/*.F))
+Flibobjects = $(patsubst src/%.F,$(G4TMPDIR)/%.o,$(Flibsources))
+Fdependencies = $(patsubst %.o,%.d,$(Fbinobjects) $(Flibobjects))
+
+ifdef G3G4DEBUG
+  CPPFLAGS += -DG3G4DEBUG
+endif
+ifdef G3G4_NO_REFLECTION
+  CPPFLAGS += -DG3G4_NO_REFLECTION
+endif
+
+###############################################################################
+### user beware! .rz files made with cernlib v 95a cannot be read with later
+### versions. You can use cernlib -v option to specify the cernlib version 
+###############################################################################
+
+### .PHONY targets are executed regardless of time-stamp of any file of same 
+###  name
+
+.PHONY: global all lib bin libC libF
+
+###--------------------- section to define explicit rules --------------------
+
+first: lib
+
+global: lib bin
+
+all: lib
+
+lib: libc libF
+
+ifneq ($(G4LIB_BUILD_SHARED),)
+libc : $(G4LIBDIR)/lib$(name).$(SHEXT)
+else
+libc : $(G4LIBDIR)/lib$(name).a
+endif
+	@echo $@ stage done
+
+libF : $(G4LIBDIR)/lib$(name)F.a
+	@echo $@ stage done
+
+bin: $(G4BINDIR)/$(G4TARGET)
+	@echo $@ stage done
+
+### Make Fortran library.
+
+$(G4LIBDIR)/lib$(name)F.a: $(Flibobjects)
+	@if [ ! -d $(G4LIBDIR) ] ; then mkdir $(G4LIBDIR) ;fi
+	@echo Creating/replacing object files in lib$(name)F.a
+	@ar r $@ $?
+	@if [ -f /usr/bin/ranlib -o -f /bin/ranlib ] ; then \
+	echo Running ranlib on lib$(name)F.a ; ranlib $@ ; fi
+
+### rztog4: Standalone Fortran program that reads an RZ file and converts
+###       the geometry and other init structures therein to G4. A call
+###       list file and G4 C++ code are generated; either can be used
+###       on the G4 side to build the geometry.
+
+$(G4BINDIR)/$(G4TARGET) : $(Fbinobjects) $(G4LIBDIR)/lib$(name)F.a
+	@if [ ! -d $(G4BINDIR) ] ; then mkdir $(G4BINDIR) ;fi
+	@echo Linking $(G4TARGET)
+	$(RM) $@
+	echo $(G4TARGET) dependencies: $^
+	$(FC) $(Fbinobjects) -o $@ $(G4LIBDIR)/lib$(name)F.a $(shell cernlib -v pro geant321 packlib)
+	@echo Finished linking $(G4TARGET)
+
+###-------------------- locally defined pattern rules ------------------------
+
+### Make the .o files from src/*.F
+$(G4TMPDIR)/%.o : src/%.F
+	$(FC) $(FCFLAGS) -o $(G4TMPDIR)/$(*F).o -c src/$(*F).F
+	@file=$(dotf_prepend)$(*F).f;\
+	if [ -f $$file ]; then echo Moving $$file to $(G4TMPDIR)/$$file; \
+	mv $$file $(G4TMPDIR)/$$file; fi	
+
+### Move the .f files
+$(G4TMPDIR)/%.f : %.f
+	@echo Moving $< to $@
+	@mv $< $@
+
+### --------------------- .d files --------------------------------------------
+
+### Make the .d file(s) and include it(them).
+### g++ -MM is good at this, except it forgets the subdirectory (hence
+###  the echo $(@D)/).
+
+$(G4TMPDIR)/%.d: src/%.F
+	@if [ ! -d $(G4TMP)/$(G4SYSTEM) ] ; then mkdir $(G4TMP)/$(G4SYSTEM) ;fi
+	@if [ ! -d $(G4TMPDIR) ] ; then mkdir $(G4TMPDIR) ;fi
+	@if test -f $@ ; then rm -f $@; fi
+	@echo $(G4LIBDIR)/lib$(name)F.a\($*.o\) $@ " : " $? "\\" > $@
+	@if test -f $< ; then awk '$$1=="#include" { print $$2 " \\" }' $< | tr -d \"\>\< >> $@ ; echo >> $@ ; fi
+
+###@if test -f $< ; then echo Making $@ depend file for $<; awk '$$1=="#include" { print $$2 " \\" }' $< | tr -d \"\>\< >> $@ ; echo >> $@ ; fi
+
+### --------------------- end of pattern rules --------------------------------
+
+-include $(Fdependencies)
+
+clean:: cleanf
+
+cleanf:
+	@$(RM) $(Flibobjects)
+	@$(RM) $(Fbinobjects)
+	@$(RM) $(Fdependencies)
+	@$(RM) $(G4BINDIR)/$(G4TARGET)
+
+include $(G4INSTALL)/config/common.gmk
+
+test1:
+	@echo $(sources)
+	@echo $(objects)
+	@echo $(dependencies)
Index: /trunk/source/g3tog4/History
===================================================================
--- /trunk/source/g3tog4/History	(revision 817)
+++ /trunk/source/g3tog4/History	(revision 817)
@@ -0,0 +1,797 @@
+$Id: History,v 1.61 2005/11/14 18:21:56 gcosmo Exp $
+
+G3toG4 Modification History (reverse chronological order, please !)
+--------------------------------------------------------------------
+
+g3tog4-V07-01-01 14-Nov-2005 G.Cosmo
+- Implemented migration to <sstream> from deprecated <strstream>.
+- GNUmakefile: moved call to 'cernlib' to 'bin' target.
+
+g3tog4-V07-01-00 05-Nov-2005 G.Cosmo
+- G3EleTable.cc: corrected inclusion of <strstrem> in implementation.
+  Temporary solution pending migration to <sstream>.
+  Fixes compilation problem on gcc/AMD64.
+
+g3tog4-V07-00-01 26-May-2005 G.Cosmo
+- Initialise local pointer variable 'mothLV' in method
+  G3toG4BuildTree::G3toG4BuildPVTree().
+
+g3tog4-V07-00-00 06-Apr-2005 J.Allison
+- GNUmakefile: corrected order for graphics_reps and intercoms in the
+  definition of GLOBLIBS.
+
+g3tog4-V06-02-00 07-Dec-2004 G.Cosmo
+- Implemented migration to <cmath>.
+
+g3tog4-V06-01-02 17-Jun-2004 G.Cosmo
+- GNUmakefile: added definition of GLOBLIBS.
+
+g3tog4-V06-01-01 03-May-2004 G.Cosmo
+- G4gsrotm.cc: commented warning about left-handled coordinates for
+  rotation axes (I.Hrivnacova).
+
+g3tog4-V06-01-00 26-Mar-2004 G.Cosmo
+- Removed hardwired gSeparator constant (a character which is used
+  during generation of volume names) to '_'. Now gSeparator is made non
+  constant and so can be changed in case a user wants to use '_' in his
+  code (I.Hrivnacova).
+  Modified files: G3toG4.hh, clparse.cc.
+
+g3tog4-V05-02-00 03-Oct-2003 G.Cosmo
+- GNUmakefile:
+  o replaced "digits+hits" with "digits_hits".
+- Coworks with "geometry-V05-02-00" and "digits_hits-V05-02-00".
+
+g3tog4-V05-01-00 04-Jun-2003 G.Cosmo
+- Fixes for inclusion of <strstream> in G3EleTable.cc, G3PartTable.cc
+  and G4gsmixt.cc in view of the g4std wrappers migration.
+
+g3tog4-V05-00-01 03-Apr-2003 G.Cosmo
+- Cleared trivial strict pedantic warnings.
+
+g3tog4-V05-00-00 27-Jan-2003 G.Cosmo
+- G4gstmed[.hh.cc] (I.Hrivnacova):
+  o added get functions for the medium table entries:
+    G4int GetSize() const
+    G3MedTableEntry* GetMTE(G4int i) const
+
+g3tog4-V04-01-00 23-Oct-2002 G.Cosmo
+- G4gsdvn.cc, G4gsposp.cc (I.Hrivnacova):
+  o fix to enable larger number of clone volumes
+  o fix for division defined in a mother with not yet defined parameters.
+
+g3tog4-V03-02-03 21-Nov-2001 G.Cosmo
+- Added G3G4_NO_REFLECTION flag to exclude G4ReflectionFactory if needed.
+- Changed G3Division::CreatePVReplica() to return a G4PhysicalVolumesPair
+  (I.Hrivnacova).
+
+g3tog4-V03-02-02 08-Nov-2001 G.Cosmo
+- Implemented reflection of CSG solids through G4ReflectionFactory class
+  and G4ReflectedSolid (I.Hrivnacova).
+- Added limited support for MANY volumes through adoption of boolean
+  solids(I.Hrivnacova). New files: G3toG4MANY[.hh.cc], G4gsbool.cc.
+
+g3tog4-V03-02-01 11-Oct-2001 G.Cosmo
+- clparse.cc: removed inclusion of RW wrapper, moved now to G4Tokenizer.hh.
+  This tag co-works with "global-V03-02-03", where STLInterface has been removed.
+
+g3tog4-V03-02-00 16-Jul-2001 G.Cosmo
+- Migration to STL vector, removed references to Rogue-Wave Tools.h++
+  wrappers. Modified files:
+  G3EleTable[.hh.cc], G3MatTable[.hh.cc], G3MedTable[.hh.cc],
+  G3RotTable[.hh.cc], G3VolTableEntry[.hh.cc], G3SensVolVector.hh,
+  G3toG4BuildTree.cc, G4gsatt.cc, clparse.cc.
+- Replaced usage of "NULL" with "0".
+- Replaced usage of "int" with "G4int".
+
+g3tog4-V03-01-01 30-May-2001 G.Cosmo
+- Cleared pedantic warnings detected on Linux-g++ with ISO/ANSI setup.
+
+g3tog4-V03-01-00 15-May-2001 G.Cosmo
+- G3toG4BuildTree[.hh.cc]: fix for a case of the placement a volume
+                           in cloned mothers
+  G3toG4BuildTree() has been split in two methods G3toG4BuildLVTree() and
+  G3toG4BuildPVTree(), the first creating logical volumes only, the second
+  performing placements afterwards. Doing so, all mothers are ready (their
+  logical volumes are created) when a volume is put in more than one mother
+  (courtesy of I.Hrivnacova).
+- GNUmakefile: G4MAKESHLIB replaced with G4LIB_BUILD_SHARED.
+
+g3tog4-V03-00-02 14-Mar-2001 G.Cosmo
+- G3toG4MakeSolid.cc: fixed bug in construction of G4Sphere where theta and
+  phi parameters were reversed according to G4Sphere constructor.
+  Fixes problem report #230.
+- G3Division.cc: correction for "PARA". Slices are placed with G4PVPlacement
+  instead of G4PVReplica for this particular case (I.Hrivnacova).
+
+g3tog4-V03-00-01 14-Feb-2001 G.Cosmo
+- Added support for replicated "PARA" shapes in G3Division::CreateSolid(...)
+  (I.Hrivnacova).
+
+g3tog4-V03-00-00 25-Jan-2001 G.Cosmo
+- Fixes for report #188:
+  o Fixed bug in G3toG4BuildTree(G3VolTableEntry*, G3VolTableEntry*)
+    when positioning volume copies. Index is now decremented.
+  o Added -DG3G4DEBUG to CPPFLAGS in GNUmakefile.
+
+g3tog4-V02-00-05 28-Nov-2000 G.Cosmo
+- Fixed bug in G3toG4BuildTree::ClearG3PosCopy(G4int). Entry in vector was
+  not properly destroyed.
+
+g3tog4-V02-00-04 24-Nov-2000 G.Cosmo
+- Added protection against multiple positiong of the same physical volume
+  and added methods ClearG3PosCopy(G4int) and ClearDivision()in
+  G3VolTableEntry (I.Hrivnacova).
+- Removed useless G3toG4Debug global method and file.
+  Replaced verbosity by G3G4DEBUG flag.
+- Moved global function G3CalcParamsFn(...) from G3CalcParams.cc to
+  G3NegVolPars.cc and removed obsolete class/files G3CalcParams[.hh.cc].
+- Added class description comments for the Software Reference
+  Manual (I.Hrivnacova).
+
+g3tog4-V02-00-03 01-Aug-2000 G.Cosmo
+- Fixed initialisation of pDPhi for CONS in G3toG4MakeSolid.cc (I.Hrivnacova).
+- Updated README file and removed src/README.
+
+g3tog4-V02-00-02 26-Jul-2000 G.Cosmo
+- Fixed definition of G4TMPDIR in GNUmakefile.
+  (The GNUmakefile needs to be completely rewritten to conform to the
+  standard format in G4...)
+
+g3tog4-V02-00-01 24-Jul-2000 G.Cosmo
+- Moved tests clGeometry and cltog4 from source/g3tog4/test to
+  examples/extended/g3tog4. Default build mechanism is now used.
+- Fixed bug to g3tog4/GNUmakefile for allowing building of shared
+  libraries. Removed targets for building tests now moved to different
+  area. Adapted to work with granular libraries mechanism.
+- Fix in destructor for G3RotTable (I.Hrivnacova).
+- Added handling of ELTU solid, affected files: G3toG4MakeSolid.cc
+  and G3CalcParams.cc (I.Hrivnacova).
+
+g3tog4-V02-00-00 21-Jul-2000 G.Cosmo
+- Fixed G3toG4PhysicsList::ConstructMesons() for test/clGeometry,
+  by removing obsolete call to G4RhoZero.
+
+g3tog4-V01-01-00 05-Apr-2000 G.Cosmo
+- Added include path to directory geometry/solids/specific.
+  Modified files: g3tog4/GNUmakefile, g3tog4/test/GNUmakefile.
+
+g3tog4-V01-00-00a 07-Mar-2000 J.Allison
+- Changed char* to const char* where ISO compiler warned.
+
+g3tog4-V01-00-00 02-Mar-2000 G.Cosmo
+- included fixes by Ivana:
+  o G3VolTable:
+  - added tests VTD.size()>0
+  - corrected G3VolTable::GetVTE() 
+  - added back G3VolTable::Clear()
+  o G3Pos:
+  - added G3Pos::GetOnly() 
+  o G3Division:
+  - corrected G3Division::CreateSolid() for
+    the case ( shape == "TUBS") && ( fIAxis == 1 )
+- fixed warnings for extraneous semicolons on DEC (ISO mode).
+- syncronized with HEAD (mainly CVS headers changed from the recent
+  ISO-ANSI C++ migration.
+
+06-Dec-1999 W.Lockman
+- removed G3fillParams.cc
+- G3Eletable.cc: cast double Z to int
+- added G3toG4Debug() global function (yuch)
+- removed G4.cc.omit
+- made sure all header files are protected with #ifndef ... #endif
+- G3toG4BuildTree.cc: avoid placement of the top-level logical volume
+
+g3tog4-V00-01-cand03 05-Dec-1999  G.Cosmo
+- Merged HEAD of main trunk with tag "wsl-991205" which now includes
+  updates by Ivana&Pedro, as well as RW->G4RW migration, STL map
+  migration and integration work by B.Lockman.
+
+g3tog4-br4_0_1fixes-iv2-99nov11    12-Nov-1999  J. Apostolakis
+- Tag of new fixes from consolidation of changes by Ivana & Pedro,
+  as these fixes were on November 11th, at 15:00
+
+g3tog4-br4_0_1fixes-iv1-99nov02    12-Nov-1999  J. Apostolakis
+- Tag of fixes from consolidation of changes by Ivana & Pedro,
+  as these fixes were on November 2nd. 
+
+Summary of changes to be added here (to be obtained from Ivana, Pedro)
+
+g3tog4-4_0_1-fixes-branch  Branch for fixes 
+- Changes introduced and tested by Ivana Hrivnacova and Pedro Arce 
+  based on geant4-00-01
+
+g3tog4-V00-01-02 22-Nov-1999 Lockman
+- g3test.F renamed to g3test.F.save
+- G3RotTable::get now returns a pointer to a G4RotationMatrix thru an upcast
+- G4BuildTree : now get G4RotationMatrix* rather than G3toG4Rotationmatrix*
+
+g3tog4-V00-01-01 20-Oct-99 Allison
+- G3MatTable.cc: introduced G4String matid (a(3,lngth)) to help STL Interface.
+
+g3tog4-V00-01-00 28-Jul-1999 Lockman
+- Commented out "Deleted..." in destructors.
+
+g3tog4-01-01-00 19-Jul-1999 Lockman
+- G3matTable, G3MedTable, G3RotTable: convert from lists G4RWTPtrOrderedVector 
+  to G4RWTPtrHashDictionary to allow for noncontiguous indices
+- G3RotTable::Put,Get->put,get. 
+- G3toG4BuildGeom, G4gsrotm: put,get signature change 
+
+g3tog4-01-00-06 28-May-1999 Lockman
+- ~G3Mat,MedTable: do not destroy G4Material Objects in list. Do a clear()
+  of the list, not clearAndDestroy, then delete the list.
+- ~G3Rot,Vol,Part,EleTable: standardize printout, fix deallocation
+- G3VolTable: changed PutVTE to take a VolTableEntry*; added ListVTE method
+- G3toG4MakeSolid: added G4bool* OKAxis
+- VolTableEntry: added _OKAxis[3] to store which axes may be divided;
+  added AddMother(VolTableEntry*), GetMother(), _Mother.
+- G3toG4MakeSolid: set OKAxis
+- G3toG4EventAction: BeginOfEventAction, EndOfEventAction signature mods
+- G3toG4RunAction: BeginOfRunAction, EndOfRunAction signature mods
+- G3toG4PhysicsList: SetCuts signature mod
+- G3toG4PrimaryGeneratorAction: randomize paricle direction
+
+27-May-1999 Cosmo
+- Fixed circular dependencies in G3Pos - VolTableEntry - G3VolTable.
+- Added default empty constructor to G3Vol.
+- Removed cleantest from "clean" target in GNUmakefile.
+
+g3tog4-01-00-05 Lockman
+- G3G4Interface: G4Strings passed by reference in G4gspos, G4gsposp
+- G3PartTable: now uses G4RWTPtrHashDictionary instead of RWGDList
+- G3RotTable: method name "get" changed to "Get". Space for unit rotation
+  matrix at element 0 in G4RWTPtrOrderedVector. This matrix is instantiated
+  in G4BuildGeom prior to call list read.
+- G3VolTable: many new methods to handle VolTableEntry and G3Pos objects.
+  removed GetPV method.
+- G3toG4.hh: removed G3NegVolPars method
+- G3DetTable: commented out some G4cerr's
+- G3EleTable: some minor internal changes
+- G3PartTable: convert to use G4RWTPtrHashDictionary
+- Added G3Pos class
+- Added G3toG4BuildTree which calls G4LogicalVolume and G4PVPlacement based on
+  G3VolTable
+- G4BuildGeom: invokes G3toG4BuildTree to build VolTableEntry tree
+- G4ggclos: invokes G3Vol.SetFirstVTE() to find top-level VolTableEntry
+- G4makevol: Broke off creation of solids into G3toG4MakeSolid
+- G4gsatt: currently a stub
+- G4gsdvn: currently a stub
+- G4gsdvn2 currently a stub
+- G4gsdvt: currently a stub
+- G4gsdvt2 currently a stub
+- G4gsmixt:added some messages to warn about faulty mixt weights
+- G4gspos: removed G4PVPlacement calls (now done in G3toG4BuildTree)
+- G4gsposp:removed some unneeded headers
+- G4makevol: broke off solids stuff into G3toG4BuildTree
+- G4gsvolu: G4makevol(...) now returns void
+- G4VolTableEntry: now is a node tree
+- clparse: remove some commented out lines
+- cltog4:  minor changes
+- G3toG4.hh make SSVT the mother. Its also not the first volume
+- Added testmodel.dat to test divided/deferred volumes.
+
+17-May-1999 Lockman
+- converted G3PartTable to RWTPtrhaswhDictionary
+- reinstituted VolTableEntry and G3VolTable G4RWTPtrHashDictionary. Creation of
+  logical volume now done in G3VolTable::PutLV
+- G4makevol.cc: added interface to G4Hype
+
+g3tog4-01-00-04 11-May-1999 Lockman
+- G3VolTable: greatly simplified. No longer keep a private logical/physical
+  volume store. Use G4LogicalVolumeStore and G4PhysicalVolumeStore instead.
+  Still keep track of the G3toG4 logical/physical mother.
+- G3toG4RotationMatrix.hh: replace forward declaration of G4RotationMatrix
+  with header file
+
+g3tog4-01-00-03  6-May-1999 Lockman
+- G3MatTable, G3RotTable, G3MedTable: updated to use G4RWTPtrOrderedVector 
+  instead of G4RWTPtrHashDictionary
+
+g3tog4-01-00-02  5-May-1999 Lockman
+- temporarily comment out G4gsdv* code
+- G4gstmed: now just store a link between tracking medium number and assoicated
+  G4Material pointer
+- replaced rw/gdlist with G4RWTPtrHashDictionary
+- replaced iostream.h with G4ios.hh everywhere
+- added G3EleTable to manage elements in G3toG4
+- tog4.F, g3routines.F: generate gsmixt instructions in call list
+- clGeometry.cc: cleaned up and added some default commands
+- added G3toG4EventAction and EventActionMessenger classes to draw tracks
+- GNUmakefile: clean now cleans g3tog4 and all subdirectories      / 24-Apr-1999 Lockman
+- GNUmakefile: cleanf: $(RM) now runs quietly
+- GNUmakefile: re-enabled libF target
+- README: updated instructions on how to configure environment and make
+- G4BuildGeom.cc: replace checkLogVol with checkVol which prints out logical
+  volumes and their physical daughters
+- G4makevol: use G4LogicalVolume(solid, material, name) constructor.
+- test/GNUmakefile: define INCFLAGS
+- test/README: modified and shortened
+- test/src/G3toG4DetectorConstruction.cc: add SimpleConstruct() method 
+  for testing; set visibility of daughters, mother.
+- test/include/G3toG4DetectorMocnstruction.hh: added private _lv, _pv
+- test/src/G3toG4RunAction.cc: set tracking/verbose 1, run/verbose 1
+
+g3tog4-01-00-01 20-Feb-1999 Bill Lockman
+- G4makevol.cc: use G4Polycone, G4Polyhedra classes instead of BREP equivalents
+- clGeometry.cc: protect vis code; removed templates stuff
+- cltog4.cc: removed templates stuff
+
+g3tog4-00-03-04 12-Nov-1998 Bill Lockman
+- G3medtable: dynamically instantiate a G4FieldManager(field*) object and
+  pass it to G4LogicalVolume by pointer.
+- adapt G3toG3PhysicsList.* from N02
+
+g3tog4-00-03-03 02-Nov-1998 Bill Lockman
+- src: Added G3toG4RotationMatrix class, remove G3toG3SetRotation class;
+- test: add parity.dat to test parity inversions
+
+g3tog4-00-03-02 05-Oct-1998 Bill Lockman
+- GNUmakefile, test/GNUmakefile mods by John Allison
+
+g3tog4-00-03-01 21-Sep-1998 BIll Lockman
+- svtwaf.dat: shrank size of svt mother volume just enclose the detectors.
+
+g3tog4-00-02-02 17-Sep-1998 Bill Lockman
+- implemented G4 capitalization convention for class names. g3tog4->G3toG4.
+- clGeometry.cc: introduced G3toG4VisManager class; 
+  added RunManager->Initialize
+- added G3toG4SetRotation class to set rotation matrix elements directly,
+  including improper rotations (parity transforms). Check for orthonormality
+  and left-handedness.
+
+g3tog4-00-02-01 21-Aug-1998 Bill Lockman
+- GNUmakefile: removed 'bin' dependence from 'first' target
+
+g3tog4-00-01-02 16-Jul-1998 Bill Lockman
+- Mods to test/GNUmakefile by B. Lockman to link
+
+g3tog4-00-01-01 07-Jul-1998 Gabriele Cosmo
+- Several updates to test/GNUmakefile by J.Allison
+- Removed obsolete tag g3tog4-00-07-00.
+
+g3tog4-00-07-00 29-Jun-1998 Bill Lockman
+- GNUmakefile:
+- added an 'examples' target to build the examples in test/
+- example/*/cltog4.* moved to test/. Removed all files in example from repo.
+- test/GNUmakefile: added G4EXLIB=true flag
+- test/clGeometry.cc, cltog4.cc: replaced #include "*.cc" with "*.hh" 
+
+g3tog4-00-06-06 26-Jun-1998 Gabriele Cosmo
+- Again changes to GNUmakefiles according to the new structure in
+  processes/electromagnetic. (by J.Allison)
+
+g3tog4-00-06-05 23-Jun-1998 Bill Lockman
+- GNUmakefile:  
+- uncommented cernlibs function (John, did you comment this ???)
+o build only the global processes library, not the processes sublibraries
+o build the global digits+hits library
+- example and test GNUmakefiles: link against global processes library
+- removed test/GNUmakefile.G4VIS_USE, superceded by visualization/G4VIS_USE.gmk
+- modified include paths in example/, test/ to include detector/include,
+  hits/include
+- src/G4gsmate: if G3 vacuum state encountered (dens<G3_input_density), set
+  dens=0; if Z < 1, set Z=1, A=2.
+
+g3tog4-00-06-04 22-Jun-1998 John Allison
+- Changed GNUmakefiles to use G4VIS_USE.gmk.
+- Introduced G4BASE in GNUmakefiles.
+
+g3tog4-00-06-03 14-Jun-1998 Bill Lockman
+- temporarily removed VACUUM from call list. This material causes SetCuts to
+  go into an infinite loop
+- removed proton from macro files
+- if Z<1, set Z=1, A=2.
+- renamed test/clGeometry.g4macro to test/clGeometry.x
+- added example/cltog4.x. 
+- example/cltog4.cc always runs in batch, no graphics.
+
+g3tog4-00-06-02 12-Jun-1998 Bill Lockman
+- simplified xlf include path
+- treat as vacuum (A=2, Z=1, dens=0) if input density < 1.e-15 g/cm3
+- G4makevol: assert Rmin>=0 && Rmax>=Rmin
+
+g3tog4-00-06-00 07-Jun-1998 Bill Lockman
+- added G4VisAttributes.hh header file to clGeometry.cc to define
+  stream operator for G4VisAttributes&
+
+g3tog4-00-05-05 23-Apr-1998 Bill Lockman
+- test/svtwaf.dat: took out PCON mother, replaced with TUBS.
+
+g3tog4-00-05-04 21-Apr-1998 Bill Lockman
+- tog4.F: Increased iia array dimension from 1k to 10k.
+
+09-Apr-1998 Bill Lockman
+- G4BuildGeom.cc: set vis attribute of top level volume to invisible
+- test/src/clGeometry.cc: instantiate MyVisManager
+- rename g4geom.cc to g4geom.cc.main
+- in svtwaf.dat, make volume SSVD a G4Tubs instead of a PCON. Otherwise,
+  can't close the geometry.
+- GNUmakefile: remove EXEC_BUILD = true
+- example/GNUmakefile: add EXEC_BUILD = true
+
+09-Apr-1998 Gabriele Cosmo
+- Porting on DEC-cxx 6.0:
+  > fixed warnings about meaningless usage of the
+    "const" qualifier. Fixed files:
+    G3VolTable.hh, G3VolTable.cc
+  > fixed problem of partial override of G4VPVParameterisation class.
+    Files: G3CalcParams.hh, G3CalcParams.cc
+
+07-Apr-1998 Bill Lockman
+- GNUmakefile: Fbinobjects was misspelled => rztog4.d was not made.
+- src/rztog4.F: check for existence of .rz file before continuing.
+- src/G4makevol.cc: include G4BREPSolidPolyhedra.hh and G4BREPSolidPCone.hh 
+  instead of .h
+
+HEAD April 2, 98 G.Barrand
+- G4VIS_USE_OPENINVENTOR -> G4VIS_USE_OIX in makefiles.
+
+26-Mar-1998 Bill Lockman
+- GNUmakefile: do not include rztog4.o in libG3toG4F.a, but explicitly in
+  link command. See README for what the different phony targets (all, lib, bin,
+  libC libF) do. In general, for both the top-level Makefile and the example
+  makefiles, gmake all will build everything, including the external libraries.
+  gmake all from the top-level makefile will additionally build both example
+  executables as well as rztog4. From the example directory, gmake all will 
+  build the external libraries, the libG3toG4.a and libG3toG4.a libraries,
+  and the example executable executable.
+- G4makevol.cc: added commented-out #include "G4BREPSolidPCone.hh" and 
+#include "G4BREPSolidPolyhedra.hh" (will convert in alpha06 release)
+
+26th March 1998  John Allison
+- Changed G4VisManager to MyVisManager in clGeometry.cc for vis-00-05-01
+  and later.
+
+25-Mar-1998 Gabriele Cosmo
+- Cleaned up warnings on DEC
+
+g3tog4-00-04-02 06-Mar-1998 Bill Lockman
+- Modified example and test GNUmakefiles to synch with latest G4 mods (mainly
+  vis and G4PhysicsList)
+- test/clGeometry.cc use new method for instantiating vis manager
+- broke off g3tog4DetectorConstruction executable code into .cc
+- added g3tog4RunAction from test_skeleton
+- added g3tog4PhysicsList from test_skeleton, dumped Process- and ParticleList
+- updated example/GNUmakefile and cltog4.cc to synch with latest G4 changes
+
+30th January 1998  Gabriele Cosmo (g3tog4-00-03-02)
+- Modified order of link in test/GNUmakefile (G4intercoms)
+
+27th January 1998  John Allison
+- Simplyfied include GNUmakfile.G4VIS_USE in test/GNUmakefile.
+- New way of instantiating G4VisManager in test/src/clGeometry.cc.
+
+20-Jan-1998  Bill Lockman
+- GNUmakefile: in 'ext', do only geometry (BREPS) and visualization (global)
+- example/GNUmakefile: remove include GNUmakefile.common, replace with required
+	rules. Do not use default clean rule - it removes the $G4SYSTEM soft 
+	links
+- test/GNUmakefile: remove include GNUmakefile.common, replace with required
+	rules. Do not use default clean rule - it removes the $G4SYSTEM soft 
+	links
+- test/clGeometry.g4macro: modified
+- test/include/g3tog4DetectorConstruction.hh: modified a comment
+- test/src/clGeometry.cc: added an optional 3rd argument, a terminal type
+- test/src/g3tog4PrimaryGeneratorAction.cc: changed some gun defaults
+
+22-Dec-1997  Bill Lockman
+added example/src, moved cltog4.cc there. Cleaned up g3tog4 makefiles.
+
+20-Dec-1997  John Allison:
+Changed ifdef OPENGL_WIDGET to ifdef G4VIS_USE_OPENGLXM in test/GNUmakefile.
+Also eliminated LOADLIBS += -lGLw.  (GLw is not used, I think.)
+(These flags need tidying in all GNUmakefiles -JA)
+
+g3tog4-00-02-03 12-Dec-1997 Lockman:
+test/GNUmakefile: visualization code and library path cloned from run/example2.
+test/src/clGeometry: added #include "G4VisRegisterGraphicsSystems.icc"; 
+protect all visualization code inside #ifdef VISUALIZE_CLGEOMETRY...#endif
+
+18 Nov 1997 B. Lockman:
+src/G4gsmate.cc: changed | to || 
+src/G3gsdetv.cc: currently disable
+test/src/, include: updated g3tog4*.cc and *.hh from run/example1
+g3tog4.F : commented out call to code generator
+Removed G3G4Init.cc, G3Mother.cc, G3Mother.hh
+GNUmakefile: 	if SLAC env. variable is set, use cernlib -v 95a, otherwise 
+		use pro
+example/GNUmakefile: updated pattern rules to build .d.
+test/GNUmakefile: remove pattern rules, replace with include GNUmakefile.common
+include/G3G4Interface.hh: G4BuildGeom now returns G4LogicalVolume*
+include/G3VolTable.hh: added static G4LogicalVolume* mothLV; getLVx(G4String&)
+		now returns G4LogicalVolume* corresponding to a name, using 
+		G4LogicalVolumeStore class; removed getTopVol method
+src/G3VolTable.cc: removed G3Mother; Mother corresponds to the first volume 
+		placed by G3toG4 (set by method setMother in in putLV.
+src/G4BuildGeom.cc returns G4LogicalVolume* of first volume placed by G3toG4
+src/G4gsatt.cc,G4gsdetv.cc,G4gsdv*.cc: replaced getLV(name) with getLVx(name)
+src/G4gspos*.cc: use G4PVPlacement constructor which places volume inside
+		Logical mother volume.
+src/G4makevol.cc: check that LV is not already placed; if so, do not place it. 
+		Removed references to G3MOther; added G3Bound to chek the
+		radial bounds on PCON and PGON volumes
+src/clparse.cc: removed GlobalMotherVolume and SubsystemMotherVolume logic.
+src/g3tog4.F: remove ctop(G3G4Init)
+test/src/g3tog4DetectorConstruction: G4LogicalVolume* G4BuildGeom; place
+top-level volume.
+
+08-Nov 1997 B. Lockman
+cltog4.cc, clGeometry.cc: update to follow skeleton.cc pattern
+G4makevol.cc: check parameters of PGON, PCON, adjust if necessary
+tog4.F: new rz reader from Vladimir Berejnoi.
+
+21-Jul 1997 G. Cosmo
+G3toG4.hh: commented out extern declaration of min(). Porting on HP-UX10.
+
+16-Jul 1997 B. Lockman
+G3Mother.cc: set the vis attributes of the mother to be invisible
+G4makevol.cc: commented out the forward declaration class G4RWTValVector<double>;
+
+17-Jun-1997  T. Wenaus
+- GNUmakefile mod to exclude g4geom.cc from library
+- G3VolTable mod to add putLV(name, lvol) method for case when nothing
+  other than lvol pointer is known about the volume 
+- src/clparse.cc mods to use g3tog4 in the context of a Geant4
+  application of which g3tog4 is just a component:
+  - G4LogicalVolume* GlobalMotherVolume if non-null points to the
+    global mother to be used by g3tog4
+  - G4LogicalVolume* SubsystemMotherVolume is loaded with the lvol
+    immediately under the g3tog4 global mother (second gsvolu definition
+    during the parsing)
+
+12-Jun-1997  B. Lockman
+G3Mother.cc: set the vis attributes of the mother to be invisible
+
+28-May-1997  B. Lockman
+g3tog4/GNUmakefile : split lib into 'libf' and 'libc'
+test,example/GNUmakefile : make libc target in to level makefile instead of lib
+src/clGeometry.cc : made cltog4.cc a short version of clGeometry.cc
+
+20-May-1997  B. Lockman
+- test/GNUmakefile : added run to include path
+- test/src/clGeometry.cc : add particle and hit generation
+
+05-May-1997  B. Lockman
+- src/clparse.cc: G3G4Init no longer calls G4Setup (G3Setup instantiates a 
+  fixed-shape world volume. This is now handled in G3Mother, based on the 
+  information in the call list file.) G3G4Init now just opens clparse.out.
+
+- src/G4makevol.cc : SingletonMother->Instance(G4LogicalVolume* lvol)
+
+- src/G4BuildGeom returns G3Vol.getPV() (see below)
+
+- G3Mother : Singleton class whose data memebers _instance and _LV are 
+  initialized from a call in G4Makevol
+
+o src/G3Mother::Instance(G4LogicalVolume * LV) stores the pointer to the
+  singleton object (_instance) and the pointer to the logical mother volume
+  (_instance->_LV); places mother volume; store pointer to physcal mother 
+  volume in G3VolTable: G3Vol.setMother(motherWorldPhys)
+
+- src/G3VolTable.cc : 
+
+o G4LogicalVolume* G3VolTable::getLV() returns the pointer to the top-level
+  logical mother volume 
+
+o G4VPhysicalVolume* G3VolTable::getPV() returns the pointer to the top-level 
+  physical mother volume
+
+- test/src/clGeometry.cc:
+
+o geometry is now closed in G4BuildGeom when G3ggclas is called 
+
+03-May-1997  B. Lockman
+- summary : got rid of artifical top level volume, replaced with top level
+  logical volume defined in call list file; place it.
+
+- src/G3Mother.cc, include/G3Mother.hh : singleton class to hold copy of
+  mother volume name. Can be accessed from anywhere
+
+- src/G3VolTable.cc, include/G3VolTable.hh : added getTopVol(), returns a
+  pointer to the top level logical volume
+
+- src/G3makevol.cc: fill singleton class
+
+- src/G4BuildGeom.cc: invoke getTopVol, create top level physical volume
+  from logical volume, no longer done in G4Setup.
+
+02-May-1997  B. Lockman
+- src/jshape.F: translate HYPE, ELTU and CTUBS shape numbers into names
+- src/G4gsdv*.cc: call G4gsvolu with zeronpars
+
+28-Apr-1997  B. Lockman :
+- example,test/GNUmakefile :
+o added 'ext' target which depends on g4ext (phony) and 'all'. The former
+  simply runs the 'ext' target in the top-level GNUmakefile.
+
+25-Apr-1997  B. Lockman :
+- src/G4gsdvn2.cc: fixed array overrun
+- src/G4gspos, G4gsposp, G4gsvolu: fixed some small memory leaks
+- src/rztog4.F : added optional second argument to specify the call list file
+- src/clparse.cc : G4bool _debug (local) controls printing of each read line
+- test/src/clGeometry.cc :  define world volume for tracking : G4TransportationManager::getTransportationManager()->getNavigatorForTracking()->SetWorldVolume( pGeometries );
+
+
+
+24-Apr-1997  B. Lockman :
+-test/src/clGeometry.cc:
+o instantiated a geometry before G4VisManager
+
+23-Apr-1997  B. Lockman :
+- GNUmakefile: 
+o added 'all' to 'ext' dependencies. gmake ext now builds all the
+  needed libraries and makes the rztog4 executable. cltog4 executable is made
+  by example/GNUmakefile; clGeometry executable is made by test/GNUmakefile.
+o added lG4run to library list in all three GNUmakefiles
+ 
+- src/G4gsvolu: 
+o changed 'delete param' to 'delete [] param'
+
+02-Apr-1997  B. Lockman :
+- phase out GNUmakefile-ext. Replace with 'ext' target in GNUmakefile; also 
+  added a 'geom' target which updates geometry/, including STEP and BREPS,
+  and merges all .o files into geometry/$G4SYSTEM/libG4geometry.a. Thus:
+    using         prototype/GNUmakefile      g3tog4/GNUmakefile
+                  ---------------------------------------------
+  either type:         "gmake"     followed by   "gmake ext"           
+      or type:         "gmake vis" followed by   "gmake geom"
+                  ---------------------------------------------
+  where 'ext' updates particle+matter, global, interfaces, visualization and
+  geometry, including BREPS and STEP,
+  and 'geom' updates geometry only, including BREPS and STEP
+  
+- example/: added cltog4.cc, removed from src/.
+07-Apr-1997  B. Lockman
+- GNUmakefiles: particle+matter/GNUmakefile global target now produeces 
+  libraries in particles, processes, management and materials. Modify library
+  path accordingly.
+- src/G4makefile: Updated to construct G4Para.
+
+31-Mar-1997  B. Lockman :
+- src/G4gsrotm.cc:
+o Incorporated proper coordinate-system rotation calculated from Euler angles.
+  The convention in Geant3 is to specify the roation matrix as a rotation of
+  the coordinate system, not a rotation of the body, as was done in Geant3.
+  The c.s. rotation matrix is the transpose of the body rotation matrix.
+
+27-Mar-1997  B. Lockman :
+- moved cltog4.cc from src to example so that it doesnt get put into g3tog4 
+  library. Thus, libG3toG4.a will contain no main routine. This avoids 
+  conflicts with mains in other packages (like visualization/test). Added
+  GNUmakefile to example to build cltog4 target. Commented cltog4 target in
+  g3tog4/GNUmakefile.
+
+20-Mar-1997  B. Lockman :
+- src/G4makevol.cc: 
+o G4BREPSolidPCone, Polyhedra require the number of sections = nz -1
+- GNUmakefile :
+o removed -include ../global/GNUmakefile.common
+o added clean_libs, clean (doesnt remove $G4SYSTEM/), clean-all (removes 
+  $G4SYSTEM)
+o put in libG3toG4.a target, depends on ../$(G4SYSTEM)/libG3toG4.a. Rule is to
+  run ../GNUmakefile which now just makes the libraries
+o typing 'gmake' will make 'all' target
+  typing 'gmake lib' or 'gmake bin' will make the libraries and binaries
+o remove binaries before rebuilding
+- src/GLKludge.cc , include/GLKludge.hh : currently G4BREPSolidPCone and 
+  G4BREPSolidPolyhedra cant handle cases where z[i] = z[i-1], add 10 microns 
+  to z[i] as a temporary kludge if z[i] <= z[i-1]
+
+19-Mar-1997  B. Lockman :
+- GNUmakefile-ext:
+o currently builds geometry global target using geometry/GNUmakefile.test
+
+18-Mar-1997  B. Lockman :
+- GNUmakefile-ext:
+o updating of external packages needed by g3tog4 now done in 
+  GNUmakefile-ext. Invoke 'global' target in packages supporting this.
+  This target removes the libraries in the lower level
+  package directories and consolidates them in the top-level package
+  directories, simplifying the library path somewhat in GNUmakefile and 
+  example/GNUmakefile. This also makes the libraries defined here 
+  compatable with those defined in visualization/test/GNUmakefile.
+o added a clean_libs target to remove all libraries (invoked from the command
+  line; 'all' does not depend on it)
+ 
+Mar 16 '97 TW
+- GNUmakefile:
+o minor typo fix CPPFLAGS -> $(CPPFLAGS)
+o consolidated histories back into this file; please keep this file a
+  single comprehensive history of g3tog4 package modifications.
+
+14-Mar-1997 Lockman: 	
+- GNUmakefile:
+o Added vpath %.a to provide library search path
+o make cltog4 dependent on all the libraries in G4LIBS
+
+11-Mar-1997  B. Lockman :
+- GNUmakefile:
+o added tracking, intercoms to library path ; 
+  now update BREPS, STEP, CSG targets in GNUmakefile-ext
+
+04-Mar-1997  B. Lockman :
+- GNUmakefile:
+o added LDFLAGS variable to allow user to specify link options from
+  from the cmd line
+
+17-Jan-1997  B. Lockman :
+- GNUmakefile:
+o updated include path to include BREPS, STEP and graphics_reps.
+o updated library path to include BREPS, STEP libraries
+o Added phony BREPS and STEP targets to insure these packages are
+  compiled (really should be done in the top-level GNUmakefile)
+  
+15-Jan-1997  B. Lockman :
+- GNUmakefile:
+o rewrote include path after directory restructuring
+o rewrote library path after directory restructuring
+- g3routines.F : run-time formatting of call list file implemented.
+- mztog4.F, rztog4.F : put tog4 into a separate file
+- tog4.F : dimensioned orig, fact to 5000
+
+
+29-Oct-1996  B. Lockman :
+- GNUmakefile:
+o rewrote include path after directory restructuring
+o rewrite library path after directory restructuring  
+
+02-Oct-1996  B. Lockman :
+- GNUmakefile:
+o in making/updating libG3toG4F.a, run ranlib on this library, not 
+  libG3toG4.a
+
+01-Oct-1996  B. Lockman :
+- GNUmakefile:
+o modified FCFLAGS to replace -I with  -WF,-I to define cpp include 
+  path for xlf compiler
+o added -d option for xlf compiler to write intermediate .f file
+o added -g option to produce debug symbols
+o added $(fsources) (*.f filobals.hhles) to 'all' dependencies 
+o moved 'all' rule to below definition of $(cernlibs) so that 
+  $(fsources) is defined
+o defined pattern rule to move .f files to $(G4SYSTEM)
+o moved -include ../global/GNUmakefile.common after explicit rules 
+  and before pattern rules definition. This file defines the
+  variables $(sources) (src/*.cc) and $(dependencies) (corresponding
+  .d files) as well as some pattern rules (which are redefined 
+  locally)
+ 
+Sep 24 '96 TW
+- completion of handling of all cases of Indexing via individual logical
+  volume objects created for each instantiation, with physical volume list
+  of the instantiations kept in the G3Vol data structure and used to
+  place daughters in the logical volume of each instantiation. 
+  (Temporary, pending a proper G4 implementation of Indexed placement.)
+- turn off geometry optimisation (takes forever for big geometries!!)
+
+Sep 15 '96 TW
+- G4Cons incorporated
+- Indexed GSVOLUs via negative length parameters finished (G3CalcParamsFn
+  extended)
+
+Sep 10 '96 TW
+- implementation of gspos (-ve params), gsposp via G4PVPlacement;
+  G3Vol structure keeps track of G4LogicalVolumes created and placed
+  for G3 parametrised volume invocations. (no G4PVIndexed, originally
+  foreseen)
+- G4Trd implemented
+- G4PVReplica, G4PVParameterised implemented
+- placeholder solid eliminated; NPAR=0 cases handled as described
+- cltog4 interface improved
+- clparse inactive geometry calls instated; all now active
+- GSDV* routines fully implemented
+- $$$ pending rot matrix handling question (no access to matrix);
+  GSROTM otherwise updated
+- GNUmakefile fixes & improvements
+
+Sep 3 '96  TW
+- GNUmakefile fix for $G4SYSTEM directory creation
+
+Aug 25 '96  T. Wenaus
+- begin this mod history
+- update G3toG4 code for class structure mods since last update (12/95)
+- update the GNUmakefile to properly compile source in src/, example/
+  and build executables rztocl, cltog4, and (if example code present)
+  g4geom in $G4SYSTEM)/
+- add .d file generation for Fortran code and code in example/
Index: /trunk/source/g3tog4/README
===================================================================
--- /trunk/source/g3tog4/README	(revision 817)
+++ /trunk/source/g3tog4/README	(revision 817)
@@ -0,0 +1,105 @@
+G3toG4
+------
+
+G3toG4 is the Geant4 facility to convert Geant3 geometries into Geant4.
+This is done in two stages. 
+
+First, the user supplies a Geant3 .rz file containing the initialization
+data structures. An executable, rztog4, reads this file and produces an
+ascii ("call list") file containing instructions on how to build the
+geometry. The source code for this is fortran. 
+
+Second, a call list interpreter (G4BuildGeom.cc) reads these instructions
+and builds the geometry in the user's G4 client code.
+
+Two examples of how to use the call list interpreter are supplied in
+examples/extended/g3tog4:
+ - the first example, cltog4, is a simple example which simply invokes the
+   call list interpreter method G4BuildGeom from G3toG4DetectorConstruction
+   class, builds the geometry and exits. 
+ - the second example, clGeometry, is more complete and is patterned after
+   the novice G4 examples. It also invokes the call list interpreter, but
+   in addition, allows the geometry to be visualized and particles to be
+   tracked. Currently, G3toG4 does not provide a method for scoring hits
+   in G4.
+
+To build these examples, especially the one involving visualization, the
+user must have one or more of the following environment variables set:
+
+setenv G4VIS_BUILD_<driver>_DRIVER
+setenv G4VIS_USE_<driver>
+
+where the G4-supported drivers are listed in source/visualization/README.
+
+To use the freeware Mesa API, you must have the environment variable
+OGLHOME defined to point to the directory containing the Mesa lib/ directory
+specific to your platform.
+
+To compile and build the G3toG4 libraries, simply type
+
+gmake
+
+from the top-level G3toG4 directory. 
+
+To build the converter executable "rztog4", simply type
+
+gmake bin
+
+To make everything, simply type:
+
+gmake global
+
+To remove all G3toG4 libraries, executables and .d files, simply type
+
+gmake clean
+
+ the implementation (April 1999)
+----------------------------------------
+- PGON, PCON are built using the CSG classes G4Polycone and G4Polyhedra.
+- G3 MANY feature has not been tested.
+- GsROTM is fully implemented and supports rotations and mirror reflections
+- GSPOSP implemented via individual logical volumes for each instantiation
+  (G4PVIndexed doesn't exist yet)
+- GSDV* routines for dividing volumes implemented, using
+  G4PVReplicas, G4PVParametrised
+- GSROTM is implemented
+- hits are not implemented. Hit code is do-nothing. (It is
+  coded up, but hit class references are commented out.)
+  The digits+hits code has to be updated before G3toG4's
+  hit code can be activated.
+- GSPART has to be updated.
+- Usage of magnetic field class has to be turned on.
+
+ the implementation (February 2001)
+----------------------------------------
+- Supported shapes: all G3 shapes except for
+  "HYPE", "GTRA", "CTUB"
+- G3 MANY feature is not supported.
+- GSDV* routines for dividing volumes implemented, using
+  G4PVReplicas, for shapes:
+      "BOX", "TUBE", "TUBS", "PARA" - all axes;
+      "CONE", "CONS" - axes 2, 3;
+      "TRD1", "TRD2", "TRAP" - axis 3; 
+      "PGON", "PCON" - axis 2;
+      "PARA" -axis 1; axis 2,3 for a special case
+  Unsupported shapes:    
+      "SPHE", "ELTU", "HYPE", "GTRA", "CTUB"
+            
+ the implementation (November 2001)
+----------------------------------------
+- Support for G3 MANY feature:
+
+  MANY positions are resolved in G3toG4MANY function,
+  which has to be processed before G3toG4BuildTree
+  (it is not called by default).
+  In order to resolve MANY user code has to provide
+  additional info using G4gsbool(G4String volName, G4String manyVolName)
+  function) for all overlapping volumes. Daughters of
+  overlapping volumes are then resolved automatically
+  and should not be specified via Gsbool.
+  
+  Limitation: a volume with a MANY position can have only this
+  one position; if more than one position is needed a new volume
+  has to be defined (gsvolu) for each position.
+
+See History file for modification history.
Index: /trunk/source/g3tog4/include/.cvsignore
===================================================================
--- /trunk/source/g3tog4/include/.cvsignore	(revision 817)
+++ /trunk/source/g3tog4/include/.cvsignore	(revision 817)
@@ -0,0 +1,1 @@
+*.rz
Index: /trunk/source/g3tog4/include/G3DetTable.hh
===================================================================
--- /trunk/source/g3tog4/include/G3DetTable.hh	(revision 817)
+++ /trunk/source/g3tog4/include/G3DetTable.hh	(revision 817)
@@ -0,0 +1,54 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G3DetTable.hh,v 1.9 2006/06/29 18:11:17 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+// G3DetTable class
+
+#ifndef G3DETTABLE_HH
+#define G3DETTABLE_HH 1
+
+#include <map>
+#include "globals.hh"
+#include "G3DetTableEntry.hh"
+
+class G3DetTable {
+private:
+  std::map<G4String, G3DetTableEntry*, std::less<G4String> > DTD;
+  G4String MakeHash(G4String& set, G4String& det);
+
+public:
+  G3DetTable();
+  virtual ~G3DetTable();
+  G4int GetID(G4String& set, G4String& det);
+  void Put(G4String& set, G4String& det, G4int id, G4VSensitiveDetector* D);
+  G4VSensitiveDetector* GetSD(G4String& set, G4String& det); 
+  void PrintAll();
+};
+
+extern G3DetTable G3Det;
+#endif
Index: /trunk/source/g3tog4/include/G3DetTableEntry.hh
===================================================================
--- /trunk/source/g3tog4/include/G3DetTableEntry.hh	(revision 817)
+++ /trunk/source/g3tog4/include/G3DetTableEntry.hh	(revision 817)
@@ -0,0 +1,55 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G3DetTableEntry.hh,v 1.6 2006/06/29 18:11:23 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+// G3DetTableEntry class
+
+#ifndef DETTABLEENTRY_HH
+#define DETTABLEENTRY_HH 1
+
+#include <map>
+#include "globals.hh"
+#include "G4VSensitiveDetector.hh"
+
+class G3DetTableEntry {
+private:
+  G4String _set;
+  G4String _det;
+  G4int _id;
+  G4VSensitiveDetector* _detpt;
+
+public:
+  G3DetTableEntry(G4String& set, G4String& det, G4int id, 
+		G4VSensitiveDetector* D);
+  ~G3DetTableEntry();
+  G4VSensitiveDetector* GetSD();
+  G4String GetSet();
+  G4String GetDet();
+  G4int GetID();
+};
+#endif
Index: /trunk/source/g3tog4/include/G3Division.hh
===================================================================
--- /trunk/source/g3tog4/include/G3Division.hh	(revision 817)
+++ /trunk/source/g3tog4/include/G3Division.hh	(revision 817)
@@ -0,0 +1,100 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G3Division.hh,v 1.8 2006/06/29 18:11:49 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+// ----------------------
+// Class description:
+//
+// This class tranforms G3 divided volumes to G4 replicated volumes. 
+// UpdateVTE() method checks parameters of mother volume
+// and in case they are complete the solid that will be replicated 
+// is created. In case of division with offset an additinal envelope 
+// VTE (G3VolTableEntry instance) is created.
+// CreatePVReplica() methods creates the G4PVReplica instance.
+
+// ----------------------
+//
+// by I.Hrivnacova, V.Berejnoi, 27 Sep 99
+
+#ifndef G3DIVISION_HH
+#define G3DIVISION_HH 1
+
+#include "globals.hh"
+#include "geomdefs.hh"
+
+class G3VolTableEntry;
+class G4VPhysicalVolume;
+class G4LogicalVolume;
+
+enum G3DivType { kDvn, kDvn2, kDvt, kDvt2 };
+
+class G3Division 
+{
+  public: // with description
+
+    G3Division(G3DivType type, G3VolTableEntry* vte, G3VolTableEntry* mvte, 
+               G4int nofDivision, G4int iaxis, G4int nmed, G4double c0, 
+	       G4double step);
+    G3Division(G3VolTableEntry* vte, G3VolTableEntry* mvte,
+               const G3Division& division);
+    virtual ~G3Division();
+    
+    // methods
+    void UpdateVTE();
+    void CreatePVReplica();   
+    
+  private:
+
+    // methods
+    void SetRangeAndAxis();
+    void CreateSolid(G4String shape, G4double par[], G4int npar);
+    G3VolTableEntry* CreateEnvelope(G4String shape, G4double hi, G4double lo, 
+                       G4double par[], G4int npar);
+    G3VolTableEntry* Dvn ();
+    G3VolTableEntry* Dvn2();
+    G3VolTableEntry* Dvt ();
+    G3VolTableEntry* Dvt2();
+    void Exception(G4String where, G4String what);
+    
+    // data members 
+    G3DivType         fType;
+    G3VolTableEntry*  fVTE;    
+    G3VolTableEntry*  fMVTE;    
+    G4int             fNofDivisions;  // ndiv/ndvmx    
+    G4int             fIAxis;
+    G4int             fNmed;
+    G4double          fC0;
+    G4double          fStep;
+    G4double          fLowRange;  
+    G4double          fHighRange;
+    G4double          fWidth;
+    G4double          fOffset;
+    EAxis             fAxis;
+};
+
+#endif //G3_DIVISION_H
Index: /trunk/source/g3tog4/include/G3EleTable.hh
===================================================================
--- /trunk/source/g3tog4/include/G3EleTable.hh	(revision 817)
+++ /trunk/source/g3tog4/include/G3EleTable.hh	(revision 817)
@@ -0,0 +1,71 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G3EleTable.hh,v 1.8 2006/06/29 18:11:51 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+// ----------------------
+// Class description:
+//
+// The table of elements.
+// In the constructor an array of strings with element name,
+// symbol and A are created. 
+// The G4Element instances of given Z are created when
+// GetEle(G4double Z) is called using the string array.
+// For each Z the G4Element is created only once.
+
+// ----------------------
+
+#ifndef G4ELETABLE_HH
+#define G4ELETABLE_HH 1
+
+#include "globals.hh"
+#include "G4Element.hh"
+
+class G3EleTable
+{
+
+public:  // with description
+
+  G3EleTable();
+  virtual ~G3EleTable();
+  G4Element* GetEle(G4double Z);
+
+private:
+
+  void LoadUp();
+  G4int parse(G4double& Z, char* name, char* sym, G4double& A); 
+
+private:
+
+  char** _EleNames;
+  G4Element** _Ele;
+  G4int _MaxEle;
+
+};
+
+extern G3EleTable G3Ele;
+#endif
Index: /trunk/source/g3tog4/include/G3G4Interface.hh
===================================================================
--- /trunk/source/g3tog4/include/G3G4Interface.hh	(revision 817)
+++ /trunk/source/g3tog4/include/G3G4Interface.hh	(revision 817)
@@ -0,0 +1,118 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G3G4Interface.hh,v 1.10 2006/06/29 18:11:54 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+//   Interfaces for G3 equivalent routines
+//
+
+#ifndef G3G4INTERFACE_HH
+#define G3G4INTERFACE_HH 1
+
+#include "globals.hh"
+
+class G4LogicalVolume;
+
+void G4gsvolu(G4String name, G4String shape, G4int nmed, G4double* par,
+              G4int npar);
+
+void G4gspos(G4String name, G4int num, G4String moth, 
+	     G4double x, G4double y, G4double z, G4int irot, 
+	     G4String only);
+
+void G4gsposp(G4String name, G4int num, G4String moth, 
+	      G4double x, G4double y, G4double z, G4int irot, 
+	      G4String only, G4double Rpar[], G4int npar);
+
+void G4gsbool(G4String volName, G4String manyVolName);
+
+void G4gsrotm(G4int irot, G4double theta1, G4double phi1,
+              G4double theta2, G4double phi2, G4double theta3, G4double phi3);
+
+void G4gsatt(G4String name, G4String attr, G4int ival);
+
+void G4gsdvn(G4String vname, G4String vmoth, G4int ndiv, G4int iaxis);
+
+void G4gsdvt(G4String name, G4String moth, G4double Step, G4int iaxis,
+             G4int numed, G4int ndvmx);
+
+void G4gsdvx(G4String name, G4String moth, G4int ndiv, G4int iaxis,
+             G4double Step, G4double c0, G4int numed, G4int ndvmx);
+
+void G4gsdvn2(G4String name, G4String moth, G4int ndiv, G4int iaxis,
+              G4double c0, G4int numed);
+
+void G4gsdvt2(G4String name, G4String moth, G4double Step, G4int iaxis,
+              G4double c0, G4int numed, G4int ndvmx);
+
+void G4gsmate(G4int imate, G4String name, G4double a, G4double z,
+              G4double dens, G4double radl, G4int nwbf, G4double* ubuf);
+
+void G4gsmixt(G4int imate, G4String name, G4double a[], G4double* z,
+              G4double dens, G4int nlmat, G4double* wmat);
+
+void G4gstmed(G4int itmed, G4String name, G4int nmat, G4int isvol,
+              G4int ifield, G4double fieldm, G4double tmaxfd,
+              G4double stemax, G4double deemax, G4double epsil,
+              G4double stmin, G4double* par, G4int npar);
+
+void G4gstpar(G4int itmed, G4String chpar, G4double parval);
+
+void G4gspart(G4int ipart, G4String chnpar, G4int itrtyp, G4double amass,
+              G4double charge, G4double tlife, G4double* ubuf,
+              G4int nwb);
+
+void G4gsdk(G4int ipart, G4double* bratio, G4int* mode);
+
+void G4gsdet(G4String chset, G4String chdet, G4int nv, G4String* chnmsv,
+             G4int* nbitsv, G4int idtyp, G4int nwhi, G4int nwdi);
+
+void G4gsdetv(G4String chset, G4String chdet, G4int idtyp, G4int nwhi,
+              G4int nwdi);
+
+void G4gsdeta(G4String chset, G4String chdet, G4String chali,
+              G4int nwhi, G4int nwdi);
+
+void G4gsdeth(G4String chset, G4String chdet, G4int nh, G4String* chnamh,
+              G4int* nbitsh, G4double* orig, G4double* fact);
+
+void G4gsdetd(G4String chset, G4String chdet, G4int nd, G4String* chnmsd,
+              G4int* nbitsd);
+
+void G4gsdetu(G4String chset, G4String chdet, G4int nupar, G4double* upar);
+
+void G4ggclos();
+
+G4LogicalVolume* G4BuildGeom(G4String& inFile);
+#endif
+
+
+
+
+
+
+
Index: /trunk/source/g3tog4/include/G3MatTable.hh
===================================================================
--- /trunk/source/g3tog4/include/G3MatTable.hh	(revision 817)
+++ /trunk/source/g3tog4/include/G3MatTable.hh	(revision 817)
@@ -0,0 +1,72 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G3MatTable.hh,v 1.13 2006/06/29 18:11:56 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+// ----------------------
+// Class description:
+//
+// G3 materials table.
+// Maps G3 material indices to their G4Material object counterparts.
+
+// ----------------------
+//
+// by I.Hrivnacova, 27 Sep 99
+
+#ifndef G3MATTABLE_HH
+#define G3MATTABLE_HH 1
+
+#include "G3MatTableEntry.hh"
+
+#include "globals.hh"
+
+#include <vector>
+
+class G4Material;
+
+typedef std::vector<G3MatTableEntry*>  G3MaterialVector;
+
+class G3MatTable
+{
+  public: // with description
+
+    G3MatTable();
+    virtual ~G3MatTable();
+    
+    // methods
+    G4Material* get(G4int id) const;
+    void put(G4int id, G4Material* material);
+    void Clear();
+
+  private:
+
+    G3MaterialVector*  fMatVector;
+};
+
+extern G3MatTable G3Mat;
+
+#endif
Index: /trunk/source/g3tog4/include/G3MatTableEntry.hh
===================================================================
--- /trunk/source/g3tog4/include/G3MatTableEntry.hh	(revision 817)
+++ /trunk/source/g3tog4/include/G3MatTableEntry.hh	(revision 817)
@@ -0,0 +1,79 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G3MatTableEntry.hh,v 1.6 2006/06/29 18:11:58 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+// ----------------------
+// Class description:
+//
+// The class associates the G3 material index with the
+// corresponding G4Material object.
+
+// ----------------------
+//
+// by I.Hrivnacova, 27 Sep 99
+
+#ifndef G3MATTABLEENTRY_HH
+#define G3MATTABLEENTRY_HH 1
+
+#include "globals.hh"
+
+class G4Material;
+
+class G3MatTableEntry 
+{
+  public: // with description
+  
+    G3MatTableEntry(G4int id, G4Material* material);
+    G3MatTableEntry(const G3MatTableEntry& right);
+    virtual ~G3MatTableEntry();
+    
+    // operators
+    const G3MatTableEntry& operator=(const G3MatTableEntry& right);
+    G4int operator==(const G3MatTableEntry& right) const;
+    G4int operator!=(const G3MatTableEntry& right) const;
+
+    // get methods
+    G4int       GetID() const;
+    G4Material* GetMaterial() const;
+    
+  private:
+  
+    // data members  
+    G4int        fID;
+    G4Material*  fMaterial;
+};
+
+// inline methods
+
+inline G4int G3MatTableEntry::GetID() const
+{ return fID; }
+
+inline G4Material* G3MatTableEntry::GetMaterial() const
+{ return fMaterial; }
+
+#endif
Index: /trunk/source/g3tog4/include/G3MedTable.hh
===================================================================
--- /trunk/source/g3tog4/include/G3MedTable.hh	(revision 817)
+++ /trunk/source/g3tog4/include/G3MedTable.hh	(revision 817)
@@ -0,0 +1,78 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G3MedTable.hh,v 1.13 2006/06/29 18:12:01 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+// ----------------------
+// Class description:
+//
+// G3 tracking medium table.
+// Maps G3 tracking medium indices to their corresponding
+// G4 objects (G4Material, G4MagneticField, G4UserLimits)
+// and the sensitivity flag (isvol).
+
+// ----------------------
+//
+// by I.Hrivnacova, 27 Sep 99
+
+#ifndef G3MEDTABLE_HH
+#define G3MEDTABLE_HH 1
+
+#include "G3MedTableEntry.hh"
+
+#include "globals.hh"
+
+#include <vector>
+
+class G4Material;
+class G4MagneticField;
+class G4UserLimits;
+
+typedef std::vector<G3MedTableEntry*>  G3MediumVector;
+
+class G3MedTable
+{
+  public: // with description
+
+    G3MedTable();
+    virtual ~G3MedTable();
+    
+    // methods
+    G3MedTableEntry* get(G4int id) const;
+    void put(G4int id, G4Material* material, G4MagneticField* field,
+             G4UserLimits* limits, G4int isvol);
+    G4int GetSize() const;
+    G3MedTableEntry*  GetMTE(G4int i) const;
+    void Clear();
+
+  private:
+
+    G3MediumVector*  fMedVector;
+};
+
+extern G3MedTable G3Med;
+#endif
Index: /trunk/source/g3tog4/include/G3MedTableEntry.hh
===================================================================
--- /trunk/source/g3tog4/include/G3MedTableEntry.hh	(revision 817)
+++ /trunk/source/g3tog4/include/G3MedTableEntry.hh	(revision 817)
@@ -0,0 +1,118 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G3MedTableEntry.hh,v 1.6 2006/06/29 18:12:03 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+// ----------------------
+// Class description:
+//
+// The class associates the G3 tracking medium index
+// with the corresponding G4Material, G4MagneticField, G4UserLimits 
+// instances and sensitivity flag (isvol).
+
+// ----------------------
+//
+// by I.Hrivnacova, 27 Sep 99
+
+#ifndef G3MEDTABLEENTRYH_HH
+#define G3MEDTABLEENTRYH_HH 1
+
+#include "globals.hh"
+
+class G4Material;
+class G4MagneticField;
+class G4UserLimits;
+
+class G3MedTableEntry 
+{
+  public:  // with description
+
+    G3MedTableEntry(G4int id, G4Material* material, G4MagneticField* field,
+       G4UserLimits* limits, G4int isvol);
+    G3MedTableEntry(const G3MedTableEntry& right);
+    virtual ~G3MedTableEntry();
+    
+    // operators
+    const G3MedTableEntry& operator=(const G3MedTableEntry& right);
+    G4int operator==(const G3MedTableEntry& right) const;
+    G4int operator!=(const G3MedTableEntry& right) const;
+
+    // set methods
+    void SetMaterial(G4Material* material);
+    void SetField(G4MagneticField* field);
+    void SetLimits(G4UserLimits* limits);
+    void SetISVOL(G4int isvol);
+
+    // get methods
+    G4int GetID() const;
+    G4Material* GetMaterial() const;
+    G4MagneticField* GetField() const;
+    G4UserLimits* GetLimits() const;
+    G4int GetISVOL() const;
+    
+  private:
+
+    // data members  
+    G4int             fID;
+    G4Material*       fMaterial;
+    G4MagneticField*  fField;
+    G4UserLimits*     fLimits;
+    G4int             fISVOL;
+    //G4double deemax;
+    //G4double epsil;
+};
+
+// inline methods
+
+inline void G3MedTableEntry::SetMaterial(G4Material* material)
+{ fMaterial = material; }
+
+inline void G3MedTableEntry::SetField(G4MagneticField* field)
+{ fField = field; }
+
+inline void G3MedTableEntry::SetLimits(G4UserLimits* limits)
+{ fLimits = limits; }
+
+inline void G3MedTableEntry::SetISVOL(G4int isvol)
+{ fISVOL = isvol; }
+
+inline G4int G3MedTableEntry::GetID() const
+{ return fID; }
+
+inline G4Material* G3MedTableEntry::GetMaterial() const
+{ return fMaterial; }
+
+inline G4MagneticField* G3MedTableEntry::GetField() const
+{ return fField; }
+
+inline G4UserLimits* G3MedTableEntry::GetLimits() const
+{ return fLimits; }
+
+inline G4int G3MedTableEntry::GetISVOL() const
+{ return fISVOL; }
+
+#endif
Index: /trunk/source/g3tog4/include/G3PartTable.hh
===================================================================
--- /trunk/source/g3tog4/include/G3PartTable.hh	(revision 817)
+++ /trunk/source/g3tog4/include/G3PartTable.hh	(revision 817)
@@ -0,0 +1,63 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G3PartTable.hh,v 1.10 2006/06/29 18:12:05 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+// ----------------------
+// Class description:
+//
+// G3 particles table.
+// Maps G3 particles indices to their G4 particle object counterparts.
+
+// ----------------------
+
+#ifndef G3PARTTABLE_HH
+#define G3PARTTABLE_HH 1
+#include <map>
+#include "G4ParticleDefinition.hh"
+
+class G3PartTable
+{
+
+public:  // with description
+
+  G3PartTable();
+  virtual ~G3PartTable();
+  G4ParticleDefinition* Get(G4int partid);
+  void Put(G4int partid, G4ParticleDefinition* partpt);
+  void PrintAll();
+
+private:
+
+  std::map<G4String, G4ParticleDefinition*, std::less<G4String> > PTD;
+  void HashID(G4int partid, G4String* _HID);
+  void HashID(G4int partid, G4String& _HID);
+};
+
+extern G3PartTable G3Part;
+
+#endif
Index: /trunk/source/g3tog4/include/G3Pos.hh
===================================================================
--- /trunk/source/g3tog4/include/G3Pos.hh	(revision 817)
+++ /trunk/source/g3tog4/include/G3Pos.hh	(revision 817)
@@ -0,0 +1,76 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G3Pos.hh,v 1.11 2006/06/29 18:12:08 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+// ----------------------
+// Class description:
+//
+// G3 volume position
+
+// ----------------------
+//
+// modified by I.Hrivnacova, 13.10.99
+
+#ifndef G3POS_HH
+#define G3POS_HH 1
+
+#include "G4ThreeVector.hh"
+
+class G3Pos
+{
+
+public:  // with description
+
+  G3Pos(){;}
+
+  G3Pos(G4String M, G4int C, G4ThreeVector* T, G4int R, G4String O);
+
+  G4bool operator == (const G3Pos& g3p) const;
+
+  virtual ~G3Pos();
+
+  G4String& GetMotherName();
+
+  G4int GetIrot();
+
+  G4ThreeVector* GetPos();
+
+  G4int GetCopy();
+
+  G4String& GetOnly();
+
+private:
+
+  G4String _MotherName;   
+  G4int _Copy;
+  G4ThreeVector* _Position;
+  G4int _Irot;
+  G4String _Only;
+};
+
+#endif
Index: /trunk/source/g3tog4/include/G3RotTable.hh
===================================================================
--- /trunk/source/g3tog4/include/G3RotTable.hh	(revision 817)
+++ /trunk/source/g3tog4/include/G3RotTable.hh	(revision 817)
@@ -0,0 +1,73 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G3RotTable.hh,v 1.15 2006/06/29 18:12:10 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+// ----------------------
+// Class description:
+//
+// G3 rotations table.
+// Maps G3 rotations indices to their G4RotationMatrix object counterparts.
+
+// ----------------------
+//
+// by I.Hrivnacova, 27 Sep 99
+
+#ifndef G3ROTTABLEH_HH
+#define G3ROTTABLEH_HH 1
+
+#include "G3RotTableEntry.hh"
+
+#include "globals.hh"
+
+#include <vector>
+
+class G4Material;
+
+typedef std::vector<G3RotTableEntry*>  G3RotMatrixVector;
+
+class G3RotTable
+{
+  public:  // with description
+
+    G3RotTable();
+    virtual ~G3RotTable();
+    
+    // methods
+
+    G4RotationMatrix* Get(G4int id) const;
+    void Put(G4int id, G4RotationMatrix* matrix);
+    void Clear();
+
+  private:
+
+    G3RotMatrixVector*  fRotVector;
+};
+
+extern G3RotTable G3Rot;
+
+#endif
Index: /trunk/source/g3tog4/include/G3RotTableEntry.hh
===================================================================
--- /trunk/source/g3tog4/include/G3RotTableEntry.hh	(revision 817)
+++ /trunk/source/g3tog4/include/G3RotTableEntry.hh	(revision 817)
@@ -0,0 +1,80 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G3RotTableEntry.hh,v 1.6 2006/06/29 18:12:13 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+// ----------------------
+// Class description:
+//
+// The class associates the G3 rotation matrix index to its
+// corresponding G4RotationMatrix object.
+
+// ----------------------
+//
+// by I.Hrivnacova, 27 Sep 99
+
+#ifndef G3ROTTABLEENTRY_HH
+#define G3ROTTABLEENTRY_HH 1
+
+#include "globals.hh"
+#include "G4RotationMatrix.hh"
+
+class G3toG4RotationMatrix;
+
+class G3RotTableEntry 
+{
+  public:  // with description
+
+    G3RotTableEntry(G4int id, G4RotationMatrix* matrix);
+    G3RotTableEntry(const G3RotTableEntry& right);
+    virtual ~G3RotTableEntry();
+    
+    // operators
+    const G3RotTableEntry& operator=(const G3RotTableEntry& right);
+    G4int operator==(const G3RotTableEntry& right) const;
+    G4int operator!=(const G3RotTableEntry& right) const;
+
+    // get methods
+    G4int       GetID() const;
+    G4RotationMatrix* GetMatrix() const;
+    
+  private:
+
+    // data members  
+    G4int              fID;
+    G4RotationMatrix*  fMatrix;
+};
+
+// inline methods
+
+inline G4int G3RotTableEntry::GetID() const
+{ return fID; }
+
+inline G4RotationMatrix* G3RotTableEntry::GetMatrix() const
+{ return fMatrix; }
+
+#endif
Index: /trunk/source/g3tog4/include/G3SensVolVector.hh
===================================================================
--- /trunk/source/g3tog4/include/G3SensVolVector.hh	(revision 817)
+++ /trunk/source/g3tog4/include/G3SensVolVector.hh	(revision 817)
@@ -0,0 +1,44 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G3SensVolVector.hh,v 1.7 2006/06/29 18:12:15 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+// vector of logical volumes that were defined with
+// tracking medium with ISVOL=1
+//
+// by I.Hrivnacova, 27 Sep 99
+
+#ifndef G3SENSVOLVECTOR_HH
+#define G3SENSVOLVECTOR_HH 1
+
+#include <vector>
+#include "G4LogicalVolume.hh"
+
+typedef std::vector<G4LogicalVolume*> G3SensVolVector;
+
+extern G3SensVolVector G3SensVol;
+#endif
Index: /trunk/source/g3tog4/include/G3VolTable.hh
===================================================================
--- /trunk/source/g3tog4/include/G3VolTable.hh	(revision 817)
+++ /trunk/source/g3tog4/include/G3VolTable.hh	(revision 817)
@@ -0,0 +1,87 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G3VolTable.hh,v 1.18 2006/06/29 18:12:18 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+// ----------------------
+// Class description:
+//
+// G3 volumes table.
+// The G3 volumes are represented with the G3VolTableEntry objects
+// that are stored in the map (sorted by names).
+// In the phase of filling the G3 tables (defining G3 geometry, 
+// eg. by parsing the G3 input via clparse.cc)
+// a G3 volume can be defined with incomplete parameters
+// (negative or none) that have to be retrieved from its mother
+// which may be defined later. These parameters are being resolved
+// subsequently in the phase of filling G3 tables.
+// That's why the G4 object counterparts (solids, logical volumes
+// and physical volumes) can be created only after filling the G3 tables
+// is finished and all incomplete parameters are resolved. 
+
+// ----------------------
+//
+// modified by I.Hrivnacova, 13.10.99
+
+#ifndef G3VOLTABLE_HH
+#define G3VOLTABLE_HH 1
+
+#include <map>
+#include "G3VolTableEntry.hh"
+
+class G4LogicalVolume;
+class G4Material;
+class G4VSolid;
+
+class G3VolTable
+{
+
+public:  // with description
+
+  G3VolTableEntry* PutVTE(G3VolTableEntry* aVTE);  
+  G3VolTableEntry* GetVTE(const G4String& Vname);
+  void PrintAll();
+  G3VolTable();
+  virtual ~G3VolTable();
+  G4LogicalVolume* GetG3toG4Mother();
+  G3VolTableEntry* GetFirstVTE();
+  void SetFirstVTE();
+  void VTEStat();
+  void CountG3Pos();
+  void Clear();
+
+private:
+
+  G3VolTableEntry* G3toG4TopVTE;
+  G4String _FirstKey;
+  std::map<G4String, G3VolTableEntry*, std::less<G4String> > VTD;
+  G4int _NG3Pos;
+};
+
+extern G3VolTable G3Vol;
+
+#endif
Index: /trunk/source/g3tog4/include/G3VolTableEntry.hh
===================================================================
--- /trunk/source/g3tog4/include/G3VolTableEntry.hh	(revision 817)
+++ /trunk/source/g3tog4/include/G3VolTableEntry.hh	(revision 817)
@@ -0,0 +1,169 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G3VolTableEntry.hh,v 1.9 2006/06/29 18:12:28 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+// ----------------------
+// Class description:
+//
+// This class is a temporary representation of G3 volume.
+// Its methods enables successive updating of its instances
+// during the phase of filling the G3 tables (defining G3 geometry,
+// eg. by parsing the G3 input via clparse.cc).
+// See G3VolTable class description, too.
+// 
+// Data members:
+//  fVname       volume name; 
+//  fShape       G3 shape name;
+//  fRpar        array of G3 volumes parameters;
+//  fNpar        number of G3 volumes parameters;
+//  fNmed        G3 tracking medium number;
+//  fSolid       the G4VSolid of this volume;
+//  fLV          the G4LogicalVolume;
+//  fHasNegPars  true if G3 volume was defined with incomplete
+//               parameters; 
+//  fDaughters   vector of daughter VTEs (VTEs of volumes placed inside
+//               this volume); 
+//  fMothers     vector of mother VTEs (VTEs of volumes inside which this
+//               volume is placed);
+//  fClones      vector of clone VTEs (see explanation below);
+//  fG3Pos       vector of G3 positions (G3Pos objects)
+//  fDivision    G3Division object created in case the G4 volume
+//               was defined as division; 
+//
+// Clone volumes:
+// In case a G3 volume (e.g. XYZ) has changed its solid parameters
+// with its new position (placement with GSPOSP) a new G3VolTableEntry
+// (associated with this new solid) with a new name (XYZ_N)
+// is created and registered as a clone volume in the fClones vector
+// data member of its master G3VolTableEntry object. 
+
+// ----------------------
+//
+// by I.Hrivnacova, 13.10.99
+
+#ifndef G3VOLTABLEENTRY_HH
+#define G3VOLTABLEENTRY_HH 1
+
+#include "globals.hh"
+#include "G3Pos.hh"
+#include "G3Division.hh"
+#include <vector>
+
+class G4LogicalVolume;
+class G4Material;
+class G4VSolid;
+
+class G3VolTableEntry
+{
+  public:  // with description
+
+    G3VolTableEntry(G4String& vname, G4String& shape, G4double* rpar, 
+                    G4int npar, G4int nmed, G4VSolid* solid, 
+		    G4bool hasNegPars);
+    virtual ~G3VolTableEntry();
+
+    // operators
+    G4bool operator == ( const G3VolTableEntry& vte) const;
+
+    // methods
+    void AddG3Pos(G3Pos* aG3Pos);
+    void AddDaughter(G3VolTableEntry* aDaughter);
+    void AddMother(G3VolTableEntry* aDaughter);
+    void AddClone(G3VolTableEntry* aDaughter);
+    void AddOverlap(G3VolTableEntry* aOverlap);
+    void ReplaceDaughter(G3VolTableEntry* vteOld, G3VolTableEntry* vteNew);
+    void ReplaceMother(G3VolTableEntry* vteOld, G3VolTableEntry* vteNew);
+    G3VolTableEntry* FindDaughter(const G4String& vname);
+    G3VolTableEntry* FindMother(const G4String& vname);
+    G3VolTableEntry* FindClone(const G4String& vname);
+    void PrintSolidInfo();
+
+    // set methods
+    void SetName(G4String name);
+    void SetLV(G4LogicalVolume* lv);
+    void SetSolid(G4VSolid* solid);
+    void SetNmed(G4int nmed);
+    void SetNRpar(G4int npar, G4double* Rpar);
+    void SetDivision(G3Division* division);
+    void SetHasNegPars(G4bool hasNegPars);
+    void SetHasMANY(G4bool hasMANY);
+    void ClearG3PosCopy(G4int copy);
+    void ClearDivision();
+ 
+    // get methods
+    G4String  GetName();
+    G4String  GetShape();
+    G4int GetNmed();
+    G4int GetNpar();
+    G4double* GetRpar();
+    G4int NPCopies();
+    G3Pos* GetG3PosCopy(G4int copy=0);
+    G3Division* GetDivision();
+    G4bool HasNegPars();
+    G4bool HasMANY();
+    G4VSolid* GetSolid();
+    G4LogicalVolume* GetLV();
+    G4int GetNoDaughters();
+    G4int GetNoMothers();
+    G4int GetNoClones();
+    G4int GetNoOverlaps();
+    G3VolTableEntry* GetDaughter(G4int i);
+    G3VolTableEntry* GetMother(G4int i);
+    G3VolTableEntry* GetMother();  
+      // return the first mother - to be removed
+    G3VolTableEntry* GetClone(G4int i);
+    G3VolTableEntry* GetMasterClone();
+    std::vector<G3VolTableEntry*>* GetOverlaps();
+
+  private:
+    G4String fVname;
+    G4String fShape;
+    G4double* fRpar;
+    G4int fNpar;
+    G4int fNmed;
+    G4VSolid* fSolid;
+    G4LogicalVolume* fLV;
+    G4bool fHasNegPars;
+    G4bool fHasMANY;
+    std::vector<G3VolTableEntry*> fDaughters;
+    std::vector<G3VolTableEntry*> fMothers;
+    std::vector<G3VolTableEntry*> fClones;
+    std::vector<G3VolTableEntry*> fOverlaps;
+    std::vector<G3Pos*> fG3Pos;
+    G3Division*  fDivision;
+};
+
+// inline methods
+
+inline void G3VolTableEntry::SetDivision(G3Division* division)
+{ fDivision = division; }
+
+inline G3Division* G3VolTableEntry::GetDivision()
+{ return fDivision; }
+
+#endif
Index: /trunk/source/g3tog4/include/G3toG4.hh
===================================================================
--- /trunk/source/g3tog4/include/G3toG4.hh	(revision 817)
+++ /trunk/source/g3tog4/include/G3toG4.hh	(revision 817)
@@ -0,0 +1,78 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G3toG4.hh,v 1.9 2006/06/29 18:12:33 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+// modified by I.Hrivnacova, 27 Sep 99
+
+#ifndef G3TOG4_HH
+#define G3TOG4_HH 1
+
+#include "globals.hh"
+
+extern char gSeparator; 
+
+extern G4int Ipar[1000];
+extern G4double Rpar[1000];
+extern G4String Spar[1000];
+
+//extern G4double min(G4double, G4double);
+
+void G3fillParams(G4String *tokens, const char *ptypes);
+// G4bool G3NegVolPars(G4double pars[], G4int* np, G4String vol, G4String moth,
+//               char* routine);
+
+#include "G3G4Interface.hh"
+
+// Parameter types for Geant routines
+//   s=string  i=integer r=real   capitalized=array
+//   In case of arrays, the last integer before the array is the 
+//   number of elements.
+#define PTgsvolu "ssiiR"
+#define PTgspos  "sisrrris"
+#define PTgsposp "sisrrrisiR"
+#define PTgsatt  "ssi"
+#define PTgsrotm "irrrrrr"
+#define PTgsdvn  "ssii"
+#define PTgsdvt  "ssriii"
+#define PTgsdvx  "ssiirrii"
+#define PTgsdvn2 "ssiiri"
+#define PTgsdvt2 "ssririi"
+#define PTgsmate "isrrrriR"
+//#define PTgsmixt "isriRRR"
+#define PTgsmixt "isriQ"
+#define PTgstmed "isiiirrrrrriR"
+#define PTgstpar "isr"
+#define PTgspart "isirrriR"
+#define PTgsdk   "iiRI"
+#define PTgsdet  "ssiSIiii"
+#define PTgsdetv "ssiii"
+#define PTgsdeta "sssii"
+#define PTgsdeth "ssiSIRR"
+#define PTgsdetd "ssiSI"
+#define PTgsdetu "ssiR"
+#endif
Index: /trunk/source/g3tog4/include/G3toG4.inc
===================================================================
--- /trunk/source/g3tog4/include/G3toG4.inc	(revision 817)
+++ /trunk/source/g3tog4/include/G3toG4.inc	(revision 817)
@@ -0,0 +1,45 @@
+*    
+*     ********************************************************************
+*     * License and Disclaimer                                           *
+*     *                                                                  *
+*     * The  Geant4 software  is  copyright of the Copyright Holders  of *
+*     * the Geant4 Collaboration.  It is provided  under  the terms  and *
+*     * conditions of the Geant4 Software License,  included in the file *
+*     * LICENSE and available at  http://cern.ch/geant4/license .  These *
+*     * include a list of copyright holders.                             *
+*     *                                                                  *
+*     * 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.  Please see the license in the file  LICENSE  and URL above *
+*     * for the full disclaimer and the limitation of liability.         *
+*     *                                                                  *
+*     * This  code  implementation is the result of  the  scientific and *
+*     * technical work of the GEANT4 collaboration.                      *
+*     * By using,  copying,  modifying or  distributing the software (or *
+*     * any work based  on the software)  you  agree  to acknowledge its *
+*     * use  in  resulting  scientific  publications,  and indicate your *
+*     * acceptance of all terms of the Geant4 Software license.          *
+*     ********************************************************************
+*    
+*    
+*     $Id: G3toG4.inc,v 1.4 2006/06/29 18:12:35 gunter Exp $
+*     GEANT4 tag $Name:  $
+*    
+      integer maxlines
+      parameter (maxlines = 750) ! max no. of cmd lines per C++ source file
+
+      integer irot_index
+      integer imat_index
+      character context*4
+      logical doclist      ! Build call list
+      logical docode       ! Build C++ code
+      logical dogeom       ! Build the Geant geometry as well
+      integer lunlist      ! Output logical unit for call list
+      integer luncode      ! Output logical unit for code
+      integer nfile        ! Current source code file number
+      integer nlines       ! Current source code line count
+      common /g3tog4_c/ irot_index, imat_index,
+     +  doclist, docode, dogeom, lunlist, luncode, context, nfile,
+     +  nlines
Index: /trunk/source/g3tog4/include/G3toG4BuildTree.hh
===================================================================
--- /trunk/source/g3tog4/include/G3toG4BuildTree.hh	(revision 817)
+++ /trunk/source/g3tog4/include/G3toG4BuildTree.hh	(revision 817)
@@ -0,0 +1,59 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G3toG4BuildTree.hh,v 1.8 2006/06/29 18:12:37 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+// ----------------------
+// Class Description:
+//
+// Definition of a global method:
+//
+//         void G3toG4BuildTree(G3VolTableEntry* curVTE,
+//                              G3VolTableEntry* motherVTE)
+//
+// which processes the G3 volumes table (G3VolTable) and creates
+// remaining G4 objects that could not be created during the phase of
+// filling the G3 tables (defining G3 geometry, eg. by parsing the G3
+// input via clparse.cc):
+// G4LogicalVolume, G4PVPlacement and G4PVReplica objects.
+// After processing of this method the G4 geometry is completely
+// created and the G3 tables can be deleted.
+
+// ----------------------
+//
+// modified by I.Hrivnacova, 13.10.99
+
+#ifndef G3TOG4BUILDTREE_HH
+#define G3TOG4BUILDTREE_HH 1
+
+#include "G3VolTableEntry.hh"
+
+void G3toG4BuildTree(G3VolTableEntry* curVTE, G3VolTableEntry* motherVTE);
+void G3toG4BuildLVTree(G3VolTableEntry* curVTE, G3VolTableEntry* motherVTE);
+void G3toG4BuildPVTree(G3VolTableEntry* curVTE);
+
+#endif  
Index: /trunk/source/g3tog4/include/G3toG4MANY.hh
===================================================================
--- /trunk/source/g3tog4/include/G3toG4MANY.hh	(revision 817)
+++ /trunk/source/g3tog4/include/G3toG4MANY.hh	(revision 817)
@@ -0,0 +1,85 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G3toG4MANY.hh,v 1.3 2006/06/29 18:12:39 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+// ----------------------
+// Class Description:
+//
+// Definition of global methods:
+//
+// void G3toG4MANY(G3VolTableEntry* curVTE);
+//
+// void MakeBooleanSolids(G3VolTableEntry* curVTE, 
+//                        G3VolTableEntryVector* overlaps,
+//                        const G4Transform3D& transform);
+//
+// void SubstractSolids(G3VolTableEntry* vte1, 
+//                      G3VolTableEntry* vte2,
+//                      G4int copy, 
+//                      const G4Transform3D& transform);
+//
+// G4Transform3D GetTransform3D(G3Pos*);
+//
+// MANY positions are resolved in G3toG4MANY() function, which has to be
+// processed before G3toG4BuildTree() (it is not called by default).
+// In order to resolve MANY, the user code has to provide additional info
+// using G4gsbool(G4String volName, G4String manyVolName) function, for
+// all overlapping volumes. Daughters of overlapping volumes are then
+// resolved automatically and should not be specified via Gsbool.
+//
+// Limitation: a volume with a MANY position can have only this one
+// ----------  position; if more than one position is needed a new volume
+//             has to be defined (gsvolu) for each position.
+
+// ----------------------
+//
+// By I.Hrivnacova, 22.10.01
+
+#ifndef G3TOG4_MANY_HH
+#define G3TOG4_MANY_HH 1
+
+#include <vector>
+#include "G3VolTableEntry.hh"
+#include "G4Transform3D.hh"
+
+typedef std::vector<G3VolTableEntry*>  G3VolTableEntryVector;
+
+void G3toG4MANY(G3VolTableEntry* curVTE);
+
+void MakeBooleanSolids(G3VolTableEntry* curVTE, 
+                       G3VolTableEntryVector* overlaps,
+		       const G4Transform3D& transform);
+
+void SubstractSolids(G3VolTableEntry* vte1, 
+                     G3VolTableEntry* vte2,
+	             G4int copy, 
+		     const G4Transform3D& transform);
+
+G4Transform3D GetTransform3D(G3Pos*);
+
+#endif  
Index: /trunk/source/g3tog4/include/G3toG4MakeSolid.hh
===================================================================
--- /trunk/source/g3tog4/include/G3toG4MakeSolid.hh	(revision 817)
+++ /trunk/source/g3tog4/include/G3toG4MakeSolid.hh	(revision 817)
@@ -0,0 +1,59 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G3toG4MakeSolid.hh,v 1.7 2006/06/29 18:12:42 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+// ----------------------
+// Class Description:
+//
+// Definition of a global method:
+//
+//   G4VSolid* G3toG4MakeSolid(const G4String& vname,
+//                             const G4String& shape, 
+//                             const G4double* Rpar,
+//                             const G4int npar, 
+//                                   G4bool& NegVolPars,
+//                                   G4bool& Deferred, 
+//                                   G4bool* OKAxis);
+//
+// which checks the volume parameters and creates the G4VSolid
+// subclass object corresponding to the specified shape. 
+// If volume parameters are incomplete (negative or none)
+// it returns 0.
+
+// ----------------------
+
+#ifndef G3TOG4MAKESOLID_HH
+#define G3TOG4MAKESOLID_HH 1
+
+G4VSolid* G3toG4MakeSolid(const G4String& vname, const G4String& shape, 
+			  const G4double* Rpar, const G4int npar, 
+			  G4bool& NegVolPars, G4bool& Deferred, 
+			  G4bool* OKAxis);
+#endif
+
+    
Index: /trunk/source/g3tog4/include/G3toG4RotationMatrix.hh
===================================================================
--- /trunk/source/g3tog4/include/G3toG4RotationMatrix.hh	(revision 817)
+++ /trunk/source/g3tog4/include/G3toG4RotationMatrix.hh	(revision 817)
@@ -0,0 +1,67 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G3toG4RotationMatrix.hh,v 1.6 2006/06/29 18:12:44 gunter Exp $
+// GEANT4 tag $Name:  $
+// ----------------------
+// Class description:
+//
+// An "extended" rotation matrix class.
+// The SetRotationMatrixByCol/Row() methods enables
+// to define the rotation matrix by column/row vectors.
+// The result matrix may be a matrix that does not
+// represent a rotation transformation (!) as
+// G3 "rotation" matrices can be a composition of
+// rotation and reflection.  
+
+// ----------------------
+
+#ifndef G3TOG4ROTATION_HH
+#define G3TOG4ROTATION_HH 1
+
+#include "G4RotationMatrix.hh"
+#include "globals.hh"
+
+class G3toG4RotationMatrix : public G4RotationMatrix 
+{
+
+public:  // with description
+
+  G3toG4RotationMatrix();
+
+  void SetRotationMatrixByCol(const G4ThreeVector& Col1,
+                              const G4ThreeVector& Col2,
+                              const G4ThreeVector& Col3);
+    
+  void SetRotationMatrixByRow(const G4ThreeVector& Row1,
+                              const G4ThreeVector& Row2,
+                              const G4ThreeVector& Row3);
+    
+  ~G3toG4RotationMatrix();
+
+};
+
+#endif    
Index: /trunk/source/g3tog4/include/gcbank.inc
===================================================================
--- /trunk/source/g3tog4/include/gcbank.inc	(revision 817)
+++ /trunk/source/g3tog4/include/gcbank.inc	(revision 817)
@@ -0,0 +1,48 @@
+*    
+*     ********************************************************************
+*     * License and Disclaimer                                           *
+*     *                                                                  *
+*     * The  Geant4 software  is  copyright of the Copyright Holders  of *
+*     * the Geant4 Collaboration.  It is provided  under  the terms  and *
+*     * conditions of the Geant4 Software License,  included in the file *
+*     * LICENSE and available at  http://cern.ch/geant4/license .  These *
+*     * include a list of copyright holders.                             *
+*     *                                                                  *
+*     * 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.  Please see the license in the file  LICENSE  and URL above *
+*     * for the full disclaimer and the limitation of liability.         *
+*     *                                                                  *
+*     * This  code  implementation is the result of  the  scientific and *
+*     * technical work of the GEANT4 collaboration.                      *
+*     * By using,  copying,  modifying or  distributing the software (or *
+*     * any work based  on the software)  you  agree  to acknowledge its *
+*     * use  in  resulting  scientific  publications,  and indicate your *
+*     * acceptance of all terms of the Geant4 Software license.          *
+*     ********************************************************************
+*    
+*    
+*     $Id: gcbank.inc,v 1.4 2006/06/29 18:12:46 gunter Exp $
+*     GEANT4 tag $Name:  $
+*    
+      INTEGER IQ,LQ,NZEBRA,IXSTOR,IXDIV,IXCONS,LMAIN,LR1,JCG
+      INTEGER KWBANK,KWWORK,IWS
+      REAL GVERSN,ZVERSN,FENDQ,WS,Q
+C
+      PARAMETER (KWBANK=69000,KWWORK=5200)
+      COMMON/GCBANK/NZEBRA,GVERSN,ZVERSN,IXSTOR,IXDIV,IXCONS,FENDQ(16)
+     +             ,LMAIN,LR1,WS(KWBANK)
+      DIMENSION IQ(2),Q(2),LQ(8000),IWS(2)
+      EQUIVALENCE (Q(1),IQ(1),LQ(9)),(LQ(1),LMAIN),(IWS(1),WS(1))
+      EQUIVALENCE (JCG,JGSTAT)
+C
+      INTEGER       JDIGI ,JDRAW ,JHEAD ,JHITS ,JKINE ,JMATE ,JPART
+     +      ,JROTM ,JRUNG ,JSET  ,JSTAK ,JGSTAT,JTMED ,JTRACK,JVERTX
+     +      ,JVOLUM,JXYZ  ,JGPAR ,JGPAR2,JSKLT
+C
+      COMMON/GCLINK/JDIGI ,JDRAW ,JHEAD ,JHITS ,JKINE ,JMATE ,JPART
+     +      ,JROTM ,JRUNG ,JSET  ,JSTAK ,JGSTAT,JTMED ,JTRACK,JVERTX
+     +      ,JVOLUM,JXYZ  ,JGPAR ,JGPAR2,JSKLT
+C
Index: /trunk/source/g3tog4/src/.cvsignore
===================================================================
--- /trunk/source/g3tog4/src/.cvsignore	(revision 817)
+++ /trunk/source/g3tog4/src/.cvsignore	(revision 817)
@@ -0,0 +1,1 @@
+*.d
Index: /trunk/source/g3tog4/src/G3DetTable.cc
===================================================================
--- /trunk/source/g3tog4/src/G3DetTable.cc	(revision 817)
+++ /trunk/source/g3tog4/src/G3DetTable.cc	(revision 817)
@@ -0,0 +1,113 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G3DetTable.cc,v 1.12 2006/06/29 18:12:48 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+#include "globals.hh"
+#include "G3DetTable.hh"
+
+typedef std::map<G4String, G3DetTableEntry*, std::less<G4String> >
+::iterator DTDiterator;
+
+G4String 
+G3DetTable::MakeHash(G4String& set, G4String& det){;
+  return set+" "+det;
+}
+
+G3DetTable::G3DetTable(){
+}
+
+G3DetTable::~G3DetTable(){
+  if (DTD.size() > 0) {
+    //    G4cout << "Deleting DTD" << G4endl;
+    for (DTDiterator i=DTD.begin(); i != DTD.end(); i++) {
+      delete (*i).second;
+    }
+    DTD.clear();
+  }
+}
+
+G4VSensitiveDetector* 
+G3DetTable::GetSD(G4String& set, G4String& det){
+
+  // make hash ID
+  const G4String ShashID = MakeHash(set, det);
+
+  // search the map
+  DTDiterator i = DTD.find(ShashID);
+  G3DetTableEntry* DTE = (*i).second;
+  if (DTE != 0) {
+    return DTE->GetSD();
+  } else {
+    return 0;
+  }  
+}
+
+G4int 
+G3DetTable::GetID(G4String& set, G4String& det){
+
+  // make hash ID
+  G4String ShashID = MakeHash(set, det);
+
+  // search the Hash Dictionary
+  DTDiterator i = DTD.find(ShashID);
+  G3DetTableEntry* DTE = (*i).second;
+  if (DTE != 0) {
+    return DTE->GetID();
+  } else {
+    return 0;
+  }
+}
+
+void 
+G3DetTable::Put(G4String& set, G4String& det, G4int id, 
+		G4VSensitiveDetector* D){
+  // make hash ID
+  G4String ShashID = MakeHash(set, det);
+  G3DetTableEntry* DTE = new G3DetTableEntry(set, det, id, D);
+  G4cout << "Inserted DTE with id " << ShashID << G4endl;
+  DTD[ShashID] = DTE;
+}
+
+void
+G3DetTable::PrintAll(){
+  if (DTD.size()>0){
+    G4int count=0;
+    G4cout << "Dump of DTD - " << DTD.size() << " entries:" << G4endl;
+    for (DTDiterator i=DTD.begin(); i != DTD.end(); i++) {
+      count++;
+      G3DetTableEntry* DTE = (*i).second;
+      G4cout << "DTD entry " << std::setw(3) << count << " sensitive detector name: " 
+	     << DTE->GetSD()->GetName() << G4endl;
+    }
+  }
+}
+
+
+
+
+
Index: /trunk/source/g3tog4/src/G3DetTableEntry.cc
===================================================================
--- /trunk/source/g3tog4/src/G3DetTableEntry.cc	(revision 817)
+++ /trunk/source/g3tog4/src/G3DetTableEntry.cc	(revision 817)
@@ -0,0 +1,63 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G3DetTableEntry.cc,v 1.5 2006/06/29 18:12:51 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+#include "globals.hh"
+#include "G3DetTableEntry.hh"
+#include "G4VSensitiveDetector.hh"
+
+G3DetTableEntry::G3DetTableEntry(G4String& set, G4String& det, G4int id, 
+				 G4VSensitiveDetector* D){
+  _set = set;
+  _det = det;
+  _id  = id;
+  _detpt = D;
+}
+
+G3DetTableEntry::~G3DetTableEntry(){;}
+
+G4VSensitiveDetector* 
+G3DetTableEntry::GetSD(){
+  return _detpt;
+}
+
+G4String 
+G3DetTableEntry::GetSet(){
+  return _set;
+}
+
+G4String 
+G3DetTableEntry::GetDet(){
+  return _det;
+}
+
+G4int
+G3DetTableEntry::GetID(){
+  return _id;
+}
+
Index: /trunk/source/g3tog4/src/G3Division.cc
===================================================================
--- /trunk/source/g3tog4/src/G3Division.cc	(revision 817)
+++ /trunk/source/g3tog4/src/G3Division.cc	(revision 817)
@@ -0,0 +1,905 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G3Division.cc,v 1.17 2006/06/29 18:12:53 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+// by I.Hrivnacova, V.Berejnoi 13.10.99
+
+#include "G3Division.hh"
+#include "G3VolTableEntry.hh"
+#include "G3toG4MakeSolid.hh"
+#include "G4Para.hh"
+#include "G3Pos.hh"
+#include "G4LogicalVolume.hh"
+#include "G4VPhysicalVolume.hh"
+#include "G4PVPlacement.hh"
+#include "G4PVReplica.hh"
+#ifndef G3G4_NO_REFLECTION
+#include "G4ReflectionFactory.hh"
+#endif
+
+G3VolTableEntry* G4CreateVTE(G4String vname, G4String shape, G4int nmed,
+                               G4double Rpar[], G4int npar);
+
+G3Division::G3Division(G3DivType type, G3VolTableEntry* vte, 
+                G3VolTableEntry* mvte, G4int nofDivisions, 
+		G4int iaxis, G4int nmed, G4double c0, G4double step)
+  : fType(type),
+    fVTE(vte),
+    fMVTE(mvte),
+    fNofDivisions(nofDivisions),
+    fIAxis(iaxis),
+    fNmed(nmed),
+    fC0(c0),
+    fStep(step),
+    fLowRange(0.),
+    fHighRange(0.),
+    fWidth(0.),
+    fOffset(0.),
+    fAxis(kXAxis)
+{
+  fVTE->SetHasNegPars(true);
+}
+
+G3Division::G3Division(G3VolTableEntry* vte, G3VolTableEntry* mvte,
+                       const G3Division& division)
+  : fVTE(vte),
+    fMVTE(mvte)
+{
+  // only "input" parameters are copied from division
+  fType = division.fType;
+  fNofDivisions = division.fNofDivisions;
+  fIAxis = division.fIAxis;
+  fNmed = division.fNmed;
+  fC0 = division.fC0;
+  fStep = division.fStep;
+
+  // other parameters are set as in standard constructor
+  fLowRange = 0.;
+  fHighRange = 0.;
+  fWidth = 0.;
+  fOffset = 0.;
+  fAxis = kXAxis;
+  fVTE->SetHasNegPars(true);
+}
+
+G3Division::~G3Division()
+{}
+
+// public methods
+
+void G3Division::UpdateVTE()
+{
+  if (fVTE->HasNegPars() && !(fMVTE->HasNegPars())) {
+
+    // set nmed from mother 
+    if (fNmed == 0) fNmed = fMVTE->GetNmed();
+    fVTE->SetNmed(fNmed);
+   
+    SetRangeAndAxis();
+    
+    // create envelope (if necessary)
+    // and solid    
+    G3VolTableEntry* envVTE = 0;
+    if      (fType == kDvn)  envVTE = Dvn(); 
+    else if (fType == kDvn2) envVTE = Dvn2(); 
+    else if (fType == kDvt)  envVTE = Dvt(); 
+    else if (fType == kDvt2) envVTE = Dvt2();
+    
+    if (envVTE) {
+      // reset mother <-> daughter
+      fMVTE->ReplaceDaughter(fVTE, envVTE);
+      fVTE->ReplaceMother(fMVTE, envVTE);
+      envVTE->AddDaughter(fVTE);
+      envVTE->AddMother(fMVTE);
+
+      // replace mother with envelope
+      fMVTE = envVTE;
+    }
+  }  
+}
+
+void G3Division::CreatePVReplica()
+{
+  G4String name = fVTE->GetName();
+  G4LogicalVolume* lv =  fVTE->GetLV();
+  G4LogicalVolume* mlv = fMVTE->GetLV();
+  
+  G4String shape = fMVTE->GetShape();
+  if (shape == "PARA") {
+    // The para volume cannot be replicated using G4PVReplica.
+    // (Replicating a volume along a cartesian axis means "slicing" it
+    // with slices -perpendicular- to that axis.)
+    
+    // position the replicated elements    
+    for (G4int i=0; i<fNofDivisions; i++) {
+       G4ThreeVector position = G4ThreeVector(); 
+       position[fIAxis-1] = fLowRange + fWidth/2. + i*fWidth;
+       if (position.y()!=0.) 
+         position.setX(position.y()*((G4Para*)lv->GetSolid())->GetTanAlpha());
+
+       #ifndef G3G4_NO_REFLECTION
+       G4ReflectionFactory::Instance()
+         ->Place(G4Translate3D(position), name, lv, mlv, 0, i);
+
+       #else  
+       new G4PVPlacement(0, position, lv, name, mlv, 0, i);
+
+       #endif
+    }
+    
+    // G4PVReplica cannot be created
+    return;   
+  }     
+  
+  #ifdef G3G4DEBUG
+    G4cout << "Create G4PVReplica name " << name << " logical volume name " 
+	   << lv->GetName() << " mother logical volme name "
+	   << mlv->GetName() << " axis " << fAxis << " ndivisions " 
+	   << fNofDivisions << " width " << fWidth << " Offset "
+	   << fOffset << G4endl;
+  #endif
+
+  #ifndef G3G4_NO_REFLECTION
+  G4ReflectionFactory::Instance()
+    ->Replicate(name, lv, mlv, fAxis, fNofDivisions, fWidth, fOffset);
+
+  #else    
+  new G4PVReplica(name, lv, mlv, fAxis, fNofDivisions, fWidth, fOffset);
+
+  #endif
+}
+
+// private methods
+
+void G3Division::Exception(G4String where, G4String what) {
+  G4Exception("G3Division::" + where + " for " + what + " is not implemented");
+}  
+
+void G3Division::SetRangeAndAxis()
+// set fHighRange, fLowRange, fAxis
+{
+    G4String shape = fMVTE->GetShape();
+    G4double *Rpar = fMVTE->GetRpar();
+    
+    switch (fIAxis) {
+      case 1: fAxis = kXAxis;
+              break;
+      case 2: fAxis = kYAxis;
+              break;
+      case 3: fAxis = kZAxis;
+              break;
+      default: G4Exception("G3Division: wrong iaxis defenition");
+    }
+
+    if ( shape == "BOX" ) {
+      fHighRange = Rpar[fIAxis-1]*cm;
+      fLowRange = -fHighRange;
+    }
+    else if ( shape == "TRD1" ) {
+      if (fIAxis == 1){
+        fHighRange = std::max(Rpar[0]*cm, Rpar[1]*cm);
+      }
+      else if( fIAxis == 2) {
+       fHighRange = Rpar[2]*cm;
+      }
+      else if( fIAxis == 3) {
+       fHighRange = Rpar[3]*cm;
+      }
+      fLowRange = - fHighRange;
+    }
+    else if ( shape == "TRD2" ) {
+      if (fIAxis == 1){
+        fHighRange = std::max(Rpar[0]*cm, Rpar[1]*cm);
+      }
+      else if( fIAxis == 2) {
+        fHighRange = std::max(Rpar[2]*cm, Rpar[3]*cm);
+      }
+      else if( fIAxis == 3) {
+       fHighRange = Rpar[4]*cm;
+      }
+    }
+    else if ( shape == "TRAP" ) {
+      if ( fIAxis == 3 ) fHighRange = Rpar[0]*cm;
+      else               fHighRange = 0.;
+      fLowRange = -fHighRange;
+    }
+    else if ( shape == "TUBE" ) {
+      if (fIAxis == 1){
+        fHighRange = Rpar[1]*cm;
+        fLowRange = Rpar[0]*cm;
+        fAxis = kRho;
+      }
+      else if( fIAxis == 2) {
+        fHighRange = 360.*deg;
+        fLowRange = 0.;
+        fAxis = kPhi;
+      }
+      else if( fIAxis == 3) {
+       fHighRange = Rpar[2]*cm;
+       fLowRange = -fHighRange;
+      }
+    }
+    else if ( shape == "TUBS" ) {
+      if (fIAxis == 1){
+        fHighRange = Rpar[1]*cm;
+        fLowRange = Rpar[0]*cm;
+        fAxis = kRho;
+      }
+      else if( fIAxis == 2) {
+
+       fLowRange = Rpar[3]*deg;
+       fHighRange = Rpar[4]*deg - fLowRange;
+       if ( Rpar[4]*deg <= fLowRange )fHighRange = fHighRange + 360.*deg;
+       fHighRange = fHighRange + fLowRange;
+       fAxis = kPhi;
+      }
+      else if( fIAxis == 3) {
+       fHighRange = Rpar[2]*cm;
+       fLowRange = -fHighRange;
+      }
+    }
+    else if ( shape == "CONE" ) {
+      if (fIAxis == 1){
+        fHighRange = std::max(Rpar[2]*cm,Rpar[4]*cm);
+        fLowRange = std::max(Rpar[1]*cm,Rpar[3]*cm);
+        fAxis = kRho;
+      }
+      else if( fIAxis == 2) {
+
+       fLowRange = 0.;
+       fHighRange = 360.*deg;
+       fAxis = kPhi;
+      }
+      else if( fIAxis == 3) {
+       fHighRange = Rpar[0]*cm;
+       fLowRange = -fHighRange;
+      }
+    }
+    else if ( shape == "CONS" ) {
+      if (fIAxis == 1){
+        fHighRange = std::max(Rpar[2]*cm,Rpar[4]*cm);
+        fLowRange = std::max(Rpar[1]*cm,Rpar[3]*cm);
+        fAxis = kRho;
+      }
+      else if( fIAxis == 2) {
+
+       fLowRange = Rpar[5]*deg;
+       fHighRange = Rpar[6]*deg - fLowRange;
+       if ( Rpar[6]*deg <= fLowRange )fHighRange = fHighRange + 360.*deg;
+       fHighRange = fHighRange + fLowRange;
+       fAxis = kPhi;
+      }
+      else if( fIAxis == 3) {
+       fHighRange = Rpar[2]*cm;
+       fLowRange = -fHighRange;
+      }
+    }
+    else if ( shape == "SPHE" ) {
+      if (fIAxis == 1){
+        fHighRange = Rpar[1]*cm;
+        fLowRange = Rpar[0]*cm;
+        fAxis = kRho;
+      }
+      else if( fIAxis == 2) {
+       fLowRange = std::min(Rpar[2]*deg,Rpar[3]*deg);
+       fHighRange = std::max(Rpar[2]*deg,Rpar[3]*deg);
+       fAxis = kPhi;
+      }
+      else if( fIAxis == 3) {
+       fLowRange = std::min(Rpar[4]*deg,Rpar[5]*deg);
+       fHighRange = std::max(Rpar[4]*deg,Rpar[5]*deg);
+       fAxis = kPhi; // ?????? 
+      }
+    }
+    else if ( shape == "PARA" ) {
+      fHighRange = Rpar[fIAxis-1]*cm;
+      fLowRange = -fHighRange;
+    }
+    else if ( shape == "PGON" ) {
+        G4int i;
+        G4int nz = G4int(Rpar[3]);
+
+        G4double pPhi1 = Rpar[0]*deg;
+        G4double dPhi  = Rpar[1]*deg;
+    
+        G4double *DzArray = new G4double[nz];
+        G4double *Rmax    = new G4double[nz];
+        G4double *Rmin    = new G4double[nz];
+        G4double rangehi[3], rangelo[3];
+        rangehi[0] = -kInfinity  ;
+        rangelo[0] =  kInfinity ;
+        rangehi[2] = -kInfinity ;
+        rangelo[2] =  kInfinity ;
+
+        for(i=0; i<nz; i++) 
+        {
+            G4int i4=3*i+4;
+            G4int i5=i4+1;
+            G4int i6=i4+2;
+            
+            DzArray[i] = Rpar[i4]*cm;
+            Rmin[i] = Rpar[i5]*cm;
+            Rmax[i] = Rpar[i6]*cm;
+            rangelo[0] = std::min(rangelo[0], Rmin[i]);
+            rangehi[0] = std::max(rangehi[0], Rmax[i]);
+            rangelo[2] = std::min(rangelo[2], DzArray[i]);
+            rangehi[2] = std::max(rangehi[2], DzArray[i]);
+        }
+        for (i=0;i<nz;i++){
+            assert(Rmin[i]>=0 && Rmax[i]>=Rmin[i]);
+        }
+        rangehi[1] = pPhi1 + dPhi;
+        rangelo[1] = pPhi1;
+        fHighRange = rangehi[fIAxis-1];
+        fLowRange = rangelo[fIAxis-1];
+        if      (fIAxis == 1)fAxis = kRho;
+        else if (fIAxis == 2)fAxis = kPhi;
+        else if (fIAxis == 3)fAxis = kZAxis;
+
+        delete [] DzArray;
+        delete [] Rmin;
+        delete [] Rmax;
+
+    }
+    else if ( shape == "PCON" ) {
+
+        G4int i;
+        G4double pPhi1 = Rpar[0]*deg;
+        G4double dPhi  = Rpar[1]*deg;    
+        G4int nz = G4int(Rpar[2]);
+    
+        G4double *DzArray = new G4double[nz];
+        G4double *Rmax    = new G4double[nz];
+        G4double *Rmin    = new G4double[nz];
+        G4double rangehi[3],rangelo[3];
+
+        rangehi[0] = -kInfinity  ;
+        rangelo[0] =  kInfinity ;
+        rangehi[2] = -kInfinity ;
+        rangelo[2] =  kInfinity ;
+        
+        for(i=0; i<nz; i++){
+            G4int i4=3*i+3;
+            G4int i5=i4+1;
+            G4int i6=i4+2;
+            
+            DzArray[i] = Rpar[i4]*cm;
+            Rmin[i] = Rpar[i5]*cm;
+            Rmax[i] = Rpar[i6]*cm;
+            rangelo[0] = std::min(rangelo[0], Rmin[i]);
+            rangehi[0] = std::max(rangehi[0], Rmax[i]);
+            rangelo[2] = std::min(rangelo[2], DzArray[i]);
+            rangehi[2] = std::max(rangehi[2], DzArray[i]);
+        }
+        for (i=0;i<nz;i++){
+            assert(Rmin[i]>=0 && Rmax[i]>=Rmin[i]);
+        }
+        rangehi[1] = pPhi1 + dPhi;
+        rangelo[1] = pPhi1;
+        fHighRange = rangehi[fIAxis-1];
+        fLowRange = rangelo[fIAxis-1];
+        if      (fIAxis == 1)fAxis = kRho;
+        else if (fIAxis == 2)fAxis = kPhi;
+        else if (fIAxis == 3)fAxis = kZAxis;
+
+
+        delete [] DzArray;
+        delete [] Rmin;
+        delete [] Rmax;
+    }
+    else if ( shape == "ELTU" ||  shape == "HYPE" || shape == "GTRA" ||
+         shape == "CTUB") {
+       Exception("SetRangeAndAxis", shape);
+    }
+    else {
+       Exception("SetRangeAndAxis", "Unknown shape" + shape);
+    }  
+
+    // verbose
+    #ifdef G3G4DEBUG
+      G4cout << "Shape " << shape << " SetRangeAndAxis: " 
+	     << fLowRange << " " << fHighRange << " " << fAxis << G4endl;
+    #endif
+}
+
+G3VolTableEntry* G3Division::CreateEnvelope(G4String shape, G4double hi, 
+                               G4double lo, G4double par[], G4int npar)
+// create new VTE with G3Pos corresponding to the
+// envelope of divided volume
+{
+    // verbose
+    // G4cout << "  G3Division::CreateEnvelope " << "fIAaxis= " << fIAxis
+    //        << " hi= " << hi
+    //        << " lo= " << lo
+    //        << G4endl;
+
+    G4double *Rpar = new G4double[npar+2];
+    for (G4int i=0; i<npar; ++i){ Rpar[i] = par[i];}
+    G4double pos[3] = {0.,0.,0.};
+  
+    if ( shape == "BOX" ) {
+      Rpar[fIAxis-1] = (hi - lo)/2./cm;
+      pos [fIAxis-1] = (hi + lo)/2.;
+    }
+    else if ( shape == "TRD1" ) {
+      if ( fIAxis == 1 || fIAxis == 2  ) {
+        Exception("CreateEnvelope","TRD1-x,y");
+      }
+      else if ( fIAxis == 3 ) {
+	// x = x1 + (c-z1)(x2 -x1)/(z2-z1)
+	G4double tn, x1, z1;
+        tn = (Rpar[1] - Rpar[0])/(2.* Rpar[3]); 
+        x1 = Rpar[0]; z1 = -Rpar[3];
+        Rpar[0] = x1 + tn * (lo/cm - z1);
+        Rpar[1] = x1 + tn * (hi/cm - z1);
+        Rpar[3] = (hi - lo)/2./cm;
+        pos[2]  = (hi + lo)/2.;
+      }
+    }
+    else if ( shape == "TRD2" ) {
+      if ( fIAxis == 1 || fIAxis == 2) {
+        Exception("CreateEnvelope","TRD2-x,y");
+      }
+      else if ( fIAxis == 3 ) {
+	// x = x1 + (c-z1)(x2 -x1)/(z2-z1)
+	// y = y1 + (c-z1)(y2 -y1)/(z2-z1)
+	G4double tn1, tn2, x1, y1, z1;
+        tn1 = (Rpar[1] - Rpar[0])/(2.* Rpar[4]); 
+        tn2 = (Rpar[3] - Rpar[2])/(2.* Rpar[4]); 
+        x1 = Rpar[0]; y1 = Rpar[2]; z1 = -Rpar[3];
+        Rpar[0] = x1 + tn1 * (lo/cm - z1);
+        Rpar[1] = x1 + tn1 * (hi/cm - z1);
+        Rpar[2] = y1 + tn2 * (lo/cm - z1);
+        Rpar[3] = y1 + tn2 * (hi/cm - z1);
+        Rpar[4] = (hi - lo)/2./cm;
+        pos[2]  = (hi + lo)/2.;
+      }
+    }
+    else if ( shape == "TRAP" ) {
+      Exception("CreateEnvelope","TRAP-x,y,z");
+    }
+    else if ( shape == "TUBE" ) {
+      if ( fIAxis == 1 ) {
+        Rpar[0] = lo/cm;
+        Rpar[1] = hi/cm;
+      }
+      else if ( fIAxis == 2 ) {
+        Rpar[3] = lo/deg;
+        Rpar[4] = hi/deg;
+        npar = npar + 2;
+        shape = "TUBS";
+      }
+      else if ( fIAxis == 3 ) {
+        Rpar[2] = (hi - lo)/2./cm;
+        pos [2] = (hi + lo)/2.;
+      }
+    }
+    else if ( shape == "TUBS" ) {
+      if ( fIAxis == 1 ) {
+        Rpar[0] = lo/cm;
+        Rpar[1] = hi/cm;
+      }
+      else if ( fIAxis == 2 ) {
+        Rpar[3] = lo/deg;
+        Rpar[4] = hi/deg;
+      }
+      else if ( fIAxis == 3 ) {
+        Rpar[2] = (hi - lo)/2./cm;
+        pos [2] = (hi + lo)/2.;
+      }
+    }
+    else if ( shape == "CONE" ) {
+      if ( fIAxis == 1) {
+        Exception("CreateEnvelope","CONE-x,z");
+      }
+      else if ( fIAxis == 2 ) {
+        Rpar[5] = lo/deg;
+        Rpar[6] = hi/deg;
+        npar = npar + 2;
+        shape = "CONS";
+      }
+      else if ( fIAxis == 3 ) {
+        G4double tn1, tn2, rmin, rmax, z1;
+        tn1 = (Rpar[3] - Rpar[1])/(2.* Rpar[0]); 
+        tn2 = (Rpar[4] - Rpar[2])/(2.* Rpar[0]); 
+        rmin = Rpar[1]; rmax = Rpar[2]; z1 = -Rpar[0];
+        Rpar[1] = rmin + tn1 * (lo/cm - z1);
+        Rpar[3] = rmin + tn1 * (hi/cm - z1);
+        Rpar[2] = rmax + tn2 * (lo/cm - z1);
+        Rpar[4] = rmax + tn2 * (hi/cm - z1);
+        Rpar[0] = (hi - lo)/2./cm;
+        pos[2]  = (hi + lo)/2.;
+      }
+    }
+    else if ( shape == "CONS" ) {
+      if ( fIAxis == 1 ) {
+        Exception("CreateEnvelope","CONS-x");
+      }
+      else if ( fIAxis == 2 ) {
+        Rpar[5] = lo/deg;
+        Rpar[6] = hi/deg;
+      }
+      else if ( fIAxis == 3 ) {
+        G4double tn1, tn2, rmin, rmax, z1;
+        tn1 = (Rpar[3] - Rpar[1])/(2.* Rpar[0]); 
+        tn2 = (Rpar[4] - Rpar[2])/(2.* Rpar[0]); 
+        rmin = Rpar[1]; rmax = Rpar[2]; z1 = -Rpar[0];
+        Rpar[1] = rmin + tn1 * (lo/cm - z1);
+        Rpar[3] = rmin + tn1 * (hi/cm - z1);
+        Rpar[2] = rmax + tn2 * (lo/cm - z1);
+        Rpar[4] = rmax + tn2 * (hi/cm - z1);
+        Rpar[0] = (hi - lo)/2./cm;
+        pos[2]  = (hi + lo)/2.;
+      }
+    }
+    else if ( shape == "SPHE" ) {
+      Exception("CreateEnvelope","SPHE-x,y,z");                
+    }
+    else if ( shape == "PARA" ) {
+      Exception("CreateEnvelope","PARA-x,y,z");
+    }
+    else if ( shape == "PGON" ) {
+      if ( fIAxis == 2) {
+	Rpar[0] = lo/deg;
+	Rpar[1] = hi/deg;
+	// rotm = ???
+      }
+      else {
+        Exception("CreateEnvelope","PGON-x,z");
+      }
+    }
+    else if ( shape == "PCON" ) {
+      if ( fIAxis == 2) {
+	Rpar[0] = lo/deg;
+	Rpar[1] = hi/deg;
+	// rotm = ???
+      }
+      else {
+        Exception("CreateEnvelope","PCON-x,z");
+      }
+    }
+    else {
+       Exception("CreateEnvelope", "Unknown shape" + shape);
+    }  
+
+    // create new VTE corresponding to envelope
+    G4String envName = fVTE->GetName() + "_ENV"; 
+    G3VolTableEntry* envVTE 
+      = G4CreateVTE(envName, shape, fNmed, Rpar, npar);
+
+    // create a G3Pos object and add it to envVTE
+    G4String motherName = fMVTE->GetMasterClone()->GetName();
+    G4ThreeVector* offset = new G4ThreeVector(pos[0],pos[1],pos[2]);    
+    G4String only = "ONLY";
+    G3Pos* aG3Pos = new G3Pos(motherName, 1, offset, 0, only);              
+    envVTE->AddG3Pos(aG3Pos);
+
+    delete [] Rpar; 
+
+    return envVTE;
+}
+
+void G3Division::CreateSolid(G4String shape, G4double par[], G4int npar)
+// create the solid corresponding to divided volume
+// and set the fOffset for replica
+{
+    G4double *Rpar = new G4double[npar+2];
+    for (G4int i=0; i<npar; ++i){ Rpar[i] = par[i];}
+
+    // verbose
+    // G4cout << "G3Division::CreateSolid volume before: " 
+    //        << fVTE->GetName() << " " << shape << G4endl;    
+    // G4cout << " npar,Rpar: " << npar;
+    // for (G4int ii = 0; ii < npar; ++ii) G4cout << " " << Rpar[ii];
+    // G4cout << G4endl;
+  
+    if ( shape == "BOX" ) {
+      if      ( fIAxis == 1 ) Rpar[0] = fWidth/2./cm;
+      else if ( fIAxis == 2 ) Rpar[1] = fWidth/2./cm; 
+      else if ( fIAxis == 3 ) Rpar[2] = fWidth/2./cm; 
+    }
+    else if ( shape == "TRD1" ) {
+      if ( fIAxis == 1 || fIAxis == 2 ) {
+        Exception("CreateSolid", "TRD1-x,y");
+      }
+      else if ( fIAxis == 3 ) {
+         Rpar[3] = fWidth/2./cm; 
+      }
+    }
+    else if ( shape == "TRD2" ) {
+      if ( fIAxis == 1 || fIAxis == 2 ) {
+        Exception("CreateSolid", "TRD2-x,y");
+      }
+      else if ( fIAxis == 3 ) {
+         Rpar[4] =  fWidth/2./cm; 
+      }
+    }
+    else if ( shape == "TRAP" ) {
+      if ( fIAxis == 1 || fIAxis == 2) {
+        Exception("CreateSolid", "TRAP-x,y");
+      }
+      else if ( fIAxis == 3 ) {
+         Rpar[0] =  fWidth/2./cm; 
+      }
+    }
+    else if ( shape == "TUBE" ) {
+      if ( fIAxis == 1 ) {
+         Rpar[1] = Rpar[0] + fWidth/cm;
+         fOffset = Rpar[0]*cm;
+      }
+      else if ( fIAxis == 2 ) {
+         Rpar[3] = 0.; 
+         Rpar[4] = fWidth/deg; 
+         shape = "TUBS";
+         npar = npar + 2;
+      }
+      else if ( fIAxis == 3 ) {
+         Rpar[2] = fWidth/2./cm; 
+      }
+    }
+    else if ( shape == "TUBS" ) {
+      if ( fIAxis == 1 ) {
+        Rpar[1] = Rpar[0] + fWidth/cm;
+        fOffset = Rpar[0]*cm;
+      }
+      else if ( fIAxis == 2 ) {
+         fOffset = Rpar[3]*deg; 
+         Rpar[3] = 0.;
+         Rpar[4] =  fWidth/deg;
+      }
+      else if ( fIAxis == 3 ) {
+         Rpar[2] = fWidth/2./cm; 
+      }
+    }
+    else if ( shape == "CONE" ) {
+      if ( fIAxis == 1 ) {
+        Exception("CreateSolid", "CONE-x"); 
+      }
+      else if ( fIAxis == 2 ) {
+         Rpar[5] = 0.;
+         Rpar[6] = fWidth/deg;
+         shape = "CONS";
+         npar = npar + 2;
+      }
+      else if ( fIAxis == 3 ) {
+         Rpar[0] = fWidth/2./cm; 
+      }
+    }
+    else if ( shape == "CONS" ) {
+      if ( fIAxis == 1 ) {
+        Exception("CreateSolid", "CONS-x"); 
+      }
+      else if ( fIAxis == 2 ) {
+         fOffset = Rpar[5]*deg;
+         Rpar[5] = 0.;
+         Rpar[6] = fWidth/deg;
+      }
+      else if ( fIAxis == 3 ) {
+         Rpar[0] = fWidth/2./cm; 
+      }
+    }
+    else if (shape == "PARA") {
+      if      ( fIAxis == 1 ) {
+         Rpar[0] = fWidth/2./cm;
+      }	 
+      else if ( Rpar[4] == 0. && Rpar[5] == 0. ) {
+         // only special case for axis 2,3 is supported
+        if ( fIAxis == 2 ) {
+          Rpar[1] = fWidth/2./cm;
+	}  
+  	else if ( fIAxis == 3) {
+          Rpar[2] = fWidth/2./cm;
+	}
+      }	  
+      else    
+         Exception("CreateSolid", shape);
+    }	 
+    else if (shape == "SPHE") {
+      Exception("CreateSolid", shape);
+    }
+    else if ( shape == "PGON" ) {
+      if ( fIAxis == 2 ) {
+         fOffset = Rpar[0]*deg;
+         Rpar[0] = 0.;
+         Rpar[1] = fWidth/deg;
+         Rpar[2] = 1.;
+      }
+      else
+       Exception("CreateSolid", shape);
+    }
+    else if ( shape == "PCON" ) {
+      if ( fIAxis == 2 ) {
+         fOffset = Rpar[0]*deg;
+         Rpar[0] = 0.;
+         Rpar[1] = fWidth/deg;
+      }
+      else {
+        Exception("CreateSolid", shape);
+      }	
+    }
+    else {
+       Exception("CreateSolid", "Unknown shape" + shape);
+    }  
+
+    // create solid and set it to fVTE
+    G4bool hasNegPars;
+    G4bool deferred;   
+    G4bool okAxis[3];
+    G4VSolid* solid
+    = G3toG4MakeSolid(fVTE->GetName(), shape, Rpar, npar, hasNegPars, deferred, okAxis);  
+
+    if (hasNegPars) {
+       G4String name = fVTE->GetName();
+       G4Exception("CreateSolid VTE " + name + " has negative parameters.");
+    }   
+    
+    // update vte
+    fVTE->SetSolid(solid);
+    fVTE->SetNRpar(npar, Rpar); 
+    fVTE->SetHasNegPars(hasNegPars);
+
+    // verbose
+    // G4cout << "G3Division::CreateSolid volume after: " 
+    //        << fVTE->GetName() << " " << shape << G4endl;    
+    // G4cout << " npar,Rpar: " << npar;
+    // for (G4int iii = 0; iii < npar; ++iii) G4cout << " " << Rpar[iii];
+    // G4cout << G4endl;
+}
+
+
+G3VolTableEntry* G3Division::Dvn()
+{   
+  // no envelope need to be created 
+
+  // get parameters from mother
+  G4String shape = fMVTE->GetShape(); 
+  G4double* Rpar = fMVTE->GetRpar();
+  G4int     npar = fMVTE->GetNpar();
+
+  // set width for replica and create solid
+  fWidth = (fHighRange - fLowRange)/fNofDivisions;
+  CreateSolid(shape, Rpar, npar);
+
+  return 0;			  
+}
+
+G3VolTableEntry* G3Division::Dvn2()
+{
+  // to be defined as const of this class
+  G4double Rmin = 0.0001*cm;
+
+  G4String shape = fMVTE->GetShape();
+  G4double* Rpar = fMVTE->GetRpar();
+  G4int     npar = fMVTE->GetNpar();
+
+  G4double c0 = fC0;
+  if (fAxis == kPhi)  c0 = c0*deg;
+  else                c0 = c0*cm;
+          
+  // create envelope (if needed)
+  G3VolTableEntry* envVTE = 0;
+  if( std::abs(c0 - fLowRange) > Rmin) {
+    envVTE = CreateEnvelope(shape, fHighRange, c0, Rpar, npar);
+    Rpar = envVTE->GetRpar();
+    npar = envVTE->GetNpar();
+  }  
+
+  // set width for replica and create solid
+  fWidth = (fHighRange - c0)/fNofDivisions;
+  CreateSolid(shape, Rpar, npar);
+
+  return envVTE;
+}
+
+G3VolTableEntry* G3Division::Dvt()
+{
+  // to be defined as const of this class
+  G4double Rmin = 0.0001*cm;
+
+  // get parameters from mother
+  G4String shape = fMVTE->GetShape();
+  G4double* Rpar = fMVTE->GetRpar();
+  G4int     npar = fMVTE->GetNpar();
+
+  // calculate the number of divisions    
+  G4int ndvmx = fNofDivisions;
+  G4double step = fStep;
+  
+  if (fAxis == kPhi)  step = step*deg;
+  else                step = step*cm;
+
+  G4int ndiv = G4int((fHighRange - fLowRange + Rmin)/step);
+  // to be added warning
+  if (ndvmx > 255) ndvmx = 255;
+  if (ndiv > ndvmx && ndvmx > 0 ) ndiv = ndvmx;
+
+  // create envVTE (if needed)
+  G3VolTableEntry* envVTE = 0;
+  G4double delta = std::abs((fHighRange - fLowRange) - ndiv*step);
+  if (delta > Rmin) {
+    envVTE 
+       = CreateEnvelope(shape, fHighRange-delta/2., fLowRange+delta/2., 
+                        Rpar, npar);
+    Rpar = envVTE->GetRpar();
+    npar = envVTE->GetNpar();
+  }
+
+  // set width for replica and create solid
+  fWidth = step;
+  fNofDivisions = ndiv;
+  CreateSolid(shape, Rpar, npar);
+
+  return envVTE;
+}
+
+G3VolTableEntry* G3Division::Dvt2()
+{
+  // to be defined as const of this class
+  G4double Rmin = 0.0001*cm;
+
+  // get parameters from mother
+  G4String shape = fMVTE->GetShape();
+  G4double* Rpar = fMVTE->GetRpar();
+  G4int     npar = fMVTE->GetNpar();
+
+  // calculate the number of divisions   
+  G4int ndvmx = fNofDivisions;
+  G4double step = fStep;
+  G4double c0 = fC0;
+
+  if(fAxis == kPhi){
+    step = step*deg;
+    c0 = c0*deg;
+  } 
+  else {
+    step = step*cm;
+    c0 = c0*cm;
+  }  
+
+  G4int ndiv = G4int((fHighRange - c0 + Rmin)/step);
+  // to be added warning
+  if (ndvmx > 255) ndvmx = 255;
+  if (ndiv > ndvmx && ndvmx > 0 ) ndiv = ndvmx;
+
+  // create envelope (if needed)
+  G3VolTableEntry* envVTE = 0;
+  G4double delta = std::abs((fHighRange - c0) - ndiv*step);
+  if (std::abs(c0 - fLowRange) > Rmin) {
+    envVTE 
+      = CreateEnvelope(shape, fHighRange-delta/2., c0+delta/2., Rpar, npar);
+    Rpar = envVTE->GetRpar();
+    npar = envVTE->GetNpar();
+  }
+
+  // set with for replica and create solid
+  fWidth = step;
+  fNofDivisions = ndiv;
+  CreateSolid(shape, Rpar, npar);
+
+  return envVTE;	 
+}
Index: /trunk/source/g3tog4/src/G3EleTable.cc
===================================================================
--- /trunk/source/g3tog4/src/G3EleTable.cc	(revision 817)
+++ /trunk/source/g3tog4/src/G3EleTable.cc	(revision 817)
@@ -0,0 +1,206 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G3EleTable.cc,v 1.16 2006/06/29 18:12:55 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+
+#include "G4Types.hh"
+#include <sstream>
+#include "G4ios.hh"
+#include "G3EleTable.hh"
+
+G3EleTable::G3EleTable() :_MaxEle(109){
+  _EleNames = new char*[_MaxEle];
+  // create an array of pointers to elements
+  _Ele = new G4Element*[_MaxEle];
+  LoadUp();
+}
+
+G3EleTable::~G3EleTable(){
+  delete [] _EleNames;
+  delete [] _Ele;
+}
+
+G4Element* 
+G3EleTable::GetEle(G4double Z){
+  G4double A;
+  char name[20], sym[3];
+  G4int index = (G4int) Z-1;
+  if (!parse(Z, name, sym, A)) {
+    G4String nm(name);
+    G4String sy(sym);
+    if (_Ele[index] == 0) {
+      // add an element to the element table here
+      _Ele[index] = new G4Element(nm, sy, Z, A*g/mole);
+    }
+  }
+  return _Ele[index];
+}
+
+G4int 
+G3EleTable::parse(G4double& Z, char* name, char* sym, G4double& A){ 
+ G4int rc = 0;
+  if (Z>0 && Z <=_MaxEle){
+    G4int z = (G4int) Z-1;
+    std::istringstream in(_EleNames[z]);
+    in >> name >> sym >> A;
+  } else {
+    rc = -1;
+  }
+  return rc;
+}
+
+void
+G3EleTable::LoadUp(){
+  G4int i=0;
+  _EleNames[i]=(char *)"Hydrogen H 1.00794"; i++;
+  _EleNames[i]=(char *)"Helium He 4.0026"; i++;
+  _EleNames[i]=(char *)"Lithium Li 6.941"; i++;
+  _EleNames[i]=(char *)"Beryllium Be 9.012182"; i++;
+  _EleNames[i]=(char *)"Boron B 10.811"; i++;
+  _EleNames[i]=(char *)"Carbon C 12.011"; i++;
+  _EleNames[i]=(char *)"Nitrogen N 14.00674"; i++;
+  _EleNames[i]=(char *)"Oxygen O 15.9994"; i++;
+  _EleNames[i]=(char *)"Fluorine F 18.9984032"; i++;
+  _EleNames[i]=(char *)"Neon Ne 20.1797"; i++;
+
+  _EleNames[i]=(char *)"Sodium Na 22.989768"; i++;
+  _EleNames[i]=(char *)"Magnesium Mg 24.3050"; i++;
+  _EleNames[i]=(char *)"Aluminum Al 26.981539"; i++;
+  _EleNames[i]=(char *)"Silicon Si 28.0855"; i++;
+  _EleNames[i]=(char *)"Phosphorus P 30.973762"; i++;
+  _EleNames[i]=(char *)"Sulfur S 32.066"; i++;
+  _EleNames[i]=(char *)"Chlorine Cl 35.4527"; i++;
+  _EleNames[i]=(char *)"Argon Ar 39.948"; i++;
+  _EleNames[i]=(char *)"Potassium K 39.0983"; i++;
+  _EleNames[i]=(char *)"Calcium Ca 40.078"; i++;
+
+  _EleNames[i]=(char *)"Scandium Sc 44.955910"; i++;
+  _EleNames[i]=(char *)"Titanium Ti 47.867"; i++;
+  _EleNames[i]=(char *)"Vanadium V 50.9415"; i++;
+  _EleNames[i]=(char *)"Chromium Cr 51.9961"; i++;
+  _EleNames[i]=(char *)"Manganese Mn 54.93805"; i++;
+  _EleNames[i]=(char *)"Iron Fe 55.845"; i++;
+  _EleNames[i]=(char *)"Cobalt Co 58.93320"; i++;
+  _EleNames[i]=(char *)"Nickel Ni 58.6934"; i++;
+  _EleNames[i]=(char *)"Copper Cu 63.546"; i++;
+  _EleNames[i]=(char *)"Zinc Zn 65.39"; i++;
+
+  _EleNames[i]=(char *)"Gallium Ga 69.723"; i++;
+  _EleNames[i]=(char *)"Germanium Ge 72.61"; i++;
+  _EleNames[i]=(char *)"Arsenic As 74.92159"; i++;
+  _EleNames[i]=(char *)"Selenium Se 78.96"; i++;
+  _EleNames[i]=(char *)"Bromine Br 79.904"; i++;
+  _EleNames[i]=(char *)"Krypton Kr 83.80"; i++;
+  _EleNames[i]=(char *)"Rubidium Rb 85.4678"; i++;
+  _EleNames[i]=(char *)"Strontium Sr 87.62"; i++;
+  _EleNames[i]=(char *)"Yttrium Y 88.90585"; i++;
+  _EleNames[i]=(char *)"Zirconium Zr 91.224"; i++;
+
+  _EleNames[i]=(char *)"Niobium Nb 92.90638"; i++;
+  _EleNames[i]=(char *)"Molybdenum Mo 95.94"; i++;
+  _EleNames[i]=(char *)"Technetium Tc 97.907215"; i++;
+  _EleNames[i]=(char *)"Ruthenium Ru 101.07"; i++;
+  _EleNames[i]=(char *)"Rhodium Rh 102.90550"; i++;
+  _EleNames[i]=(char *)"Palladium Pd 106.42"; i++;
+  _EleNames[i]=(char *)"Silver Ag 107.8682"; i++;
+  _EleNames[i]=(char *)"Cadmium Cd 112.41"; i++;
+  _EleNames[i]=(char *)"Indium In 114.818"; i++;
+  _EleNames[i]=(char *)"Tin Sn 118.710"; i++;
+
+  _EleNames[i]=(char *)"Antimony Sb 121.760"; i++;
+  _EleNames[i]=(char *)"Tellurium Te 127.60"; i++;
+  _EleNames[i]=(char *)"Iodine I 126.90447"; i++;
+  _EleNames[i]=(char *)"Xenon Xe 131.29"; i++;
+  _EleNames[i]=(char *)"Cesium Cs 132.90543"; i++;
+  _EleNames[i]=(char *)"Barium Ba 137.27"; i++;
+  _EleNames[i]=(char *)"Lanthanum La 138.9055"; i++;
+  _EleNames[i]=(char *)"Cerium Ce 140.115"; i++;
+  _EleNames[i]=(char *)"Praeseodymium Pr 140.90765"; i++;
+  _EleNames[i]=(char *)"NeoDymium Nd 144.24"; i++;
+  
+  _EleNames[i]=(char *)"Promethium Pm 144.912745"; i++;
+  _EleNames[i]=(char *)"Samarium Sm 150.36"; i++;
+  _EleNames[i]=(char *)"Europium Eu 151.965"; i++;
+  _EleNames[i]=(char *)"Gadolinium Gd 157.25"; i++;
+  _EleNames[i]=(char *)"Terbium Tb 158.92534"; i++;
+  _EleNames[i]=(char *)"Dysprosium Dy 162.50"; i++;
+  _EleNames[i]=(char *)"Holmium Ho 164.93032"; i++;
+  _EleNames[i]=(char *)"Erbium Er 167.26"; i++;
+  _EleNames[i]=(char *)"Thulium Tm 168.93421"; i++;
+  _EleNames[i]=(char *)"Ytterbium Yb 173.04"; i++;
+
+  _EleNames[i]=(char *)"Lutetium Lu 174.967"; i++;
+  _EleNames[i]=(char *)"Hafnium Hf 178.49"; i++;
+  _EleNames[i]=(char *)"Tantalum Ta 180.9479"; i++;
+  _EleNames[i]=(char *)"Tungsten W 183.84"; i++;
+  _EleNames[i]=(char *)"Rhenium Re 186.207"; i++;
+  _EleNames[i]=(char *)"Osmium Os 190.23"; i++;
+  _EleNames[i]=(char *)"Iridium Ir 192.217"; i++;
+  _EleNames[i]=(char *)"Platinum Pt 195.08"; i++;
+  _EleNames[i]=(char *)"Gold Au 196.96654"; i++;
+  _EleNames[i]=(char *)"Mercury Hg 200.59"; i++;
+
+  _EleNames[i]=(char *)"Thallium Tl 204.3833"; i++;
+  _EleNames[i]=(char *)"Lead Pb 207.2"; i++;
+  _EleNames[i]=(char *)"Bismuth Bi 208.98037"; i++;
+  _EleNames[i]=(char *)"Polonium Po 208.982415"; i++;
+  _EleNames[i]=(char *)"Astatine At 209.987131"; i++;
+  _EleNames[i]=(char *)"Radon Rn 222.017570"; i++;
+  _EleNames[i]=(char *)"Francium Fr 223.019731"; i++;
+  _EleNames[i]=(char *)"Radium Ra 226.025402"; i++;
+  _EleNames[i]=(char *)"Actinium Ac 227.027747"; i++;
+  _EleNames[i]=(char *)"Thorium Th 232.0381"; i++;
+
+  _EleNames[i]=(char *)"Protactinium Pa 231.03588"; i++;
+  _EleNames[i]=(char *)"Uranium U 238.0289"; i++;
+  _EleNames[i]=(char *)"Neptunium Np 237.048166"; i++;
+  _EleNames[i]=(char *)"Plutonium Pu 244.064197"; i++;
+  _EleNames[i]=(char *)"Americium Am 243.061372"; i++;
+  _EleNames[i]=(char *)"Curium Cm 247.070346"; i++;
+  _EleNames[i]=(char *)"Berkelium Bk 247.070298"; i++;
+  _EleNames[i]=(char *)"Californium Cf 251.079579"; i++;
+  _EleNames[i]=(char *)"Einsteinium Es 252.08297"; i++;
+  _EleNames[i]=(char *)"Fermium Fm 257.095096"; i++;
+
+  _EleNames[i]=(char *)"Mendelevium Md 258.098427"; i++;
+  _EleNames[i]=(char *)"Nobelium No 259.1011"; i++;
+  _EleNames[i]=(char *)"Lawrencium Lr 262.1098"; i++;
+  _EleNames[i]=(char *)"Rutherfordium Rf 261.1089";  i++;
+  _EleNames[i]=(char *)"Hahnium Ha 262.1144";  i++;
+  _EleNames[i]=(char *)"Seaborgium Sg 263.1186";  i++;
+  _EleNames[i]=(char *)"Nielsborium Ns 262.1231";  i++;
+  _EleNames[i]=(char *)"Hassium Hs 265.1306";  i++;
+  _EleNames[i]=(char *)"Meitnerium Mt 266.1378";  i++;
+
+  // initialize element pointers to 0
+  for (G4int j=0; j<i; j++) {
+    _Ele[j]=0;
+  }
+}
+
+
Index: /trunk/source/g3tog4/src/G3MatTable.cc
===================================================================
--- /trunk/source/g3tog4/src/G3MatTable.cc	(revision 817)
+++ /trunk/source/g3tog4/src/G3MatTable.cc	(revision 817)
@@ -0,0 +1,75 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G3MatTable.cc,v 1.16 2006/06/29 18:12:57 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+// by I.Hrivnacova, 27 Sep 99
+
+#include "G3MatTable.hh"
+
+G3MatTable::G3MatTable()
+{
+  fMatVector = new G3MaterialVector();
+}
+
+G3MatTable::~G3MatTable()
+{
+  Clear();
+  delete fMatVector;
+}
+
+G4Material* G3MatTable::get(G4int id) const
+{
+  for (size_t i=0; i< fMatVector->size(); i++) {
+    G3MatTableEntry* mte = (*fMatVector)[i];
+    if (id == mte->GetID()) return mte->GetMaterial();
+  }
+  return 0;
+}    
+
+void G3MatTable::put(G4int id, G4Material* material)
+{
+  G3MatTableEntry* mte = new G3MatTableEntry(id, material);
+  fMatVector->push_back(mte);
+}
+
+void G3MatTable::Clear()
+{
+  G3MatTableEntry* a;
+  while (fMatVector->size()>0) {
+    a = fMatVector->back();
+    fMatVector->pop_back();
+    for (G3MaterialVector::iterator i=fMatVector->begin();
+                                    i!=fMatVector->end(); i++){
+      if (*i==a) {
+	fMatVector->erase(i);
+	i--;
+      }
+    } 
+    if ( a )  delete a;    
+  } 
+}
Index: /trunk/source/g3tog4/src/G3MatTableEntry.cc
===================================================================
--- /trunk/source/g3tog4/src/G3MatTableEntry.cc	(revision 817)
+++ /trunk/source/g3tog4/src/G3MatTableEntry.cc	(revision 817)
@@ -0,0 +1,72 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G3MatTableEntry.cc,v 1.4 2006/06/29 18:13:00 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+// by I.Hrivnacova, 27 Sep 99
+
+#include "G3MatTableEntry.hh"
+
+#include "G4Material.hh"
+
+G3MatTableEntry::G3MatTableEntry(G4int id, G4Material* material)
+  : fID(id),
+    fMaterial(material)
+{}
+
+G3MatTableEntry::G3MatTableEntry(const G3MatTableEntry& right)
+  : fID(right.GetID()),
+    fMaterial(right.GetMaterial())
+{}    
+
+G3MatTableEntry::~G3MatTableEntry()
+{}
+
+const G3MatTableEntry& 
+G3MatTableEntry::operator=(const G3MatTableEntry& right)
+{ 
+  fID = right.GetID();
+  fMaterial = right.GetMaterial();     
+  return *this;
+}
+
+G4int G3MatTableEntry::operator==(const G3MatTableEntry& right) const
+{ 
+  if (fID == right.GetID()) 
+    return 1;
+  else
+    return 0;
+}
+
+G4int G3MatTableEntry::operator!=(const G3MatTableEntry& right) const
+{ 
+  if (*this == right) 
+    return 0;
+  else
+    return 1;
+}
+
Index: /trunk/source/g3tog4/src/G3MedTable.cc
===================================================================
--- /trunk/source/g3tog4/src/G3MedTable.cc	(revision 817)
+++ /trunk/source/g3tog4/src/G3MedTable.cc	(revision 817)
@@ -0,0 +1,90 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G3MedTable.cc,v 1.15 2006/06/29 18:13:03 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+// by I.Hrivnacova, 27 Sep 99
+
+#include "G3MedTable.hh"
+
+G3MedTable::G3MedTable()
+{
+  fMedVector = new G3MediumVector();
+}
+
+G3MedTable::~G3MedTable()
+{
+  Clear();
+  delete fMedVector;
+}
+
+G3MedTableEntry* G3MedTable::get(G4int id) const
+{
+  for (size_t i=0; i< fMedVector->size(); i++) {
+    G3MedTableEntry* mte = (*fMedVector)[i];
+    if (id == mte->GetID()) return mte;
+  }
+  return 0;
+}    
+
+void G3MedTable::put(G4int id, G4Material* material, G4MagneticField* field,
+       G4UserLimits* limits, G4int isvol)
+{
+  G3MedTableEntry* mte 
+    = new G3MedTableEntry(id, material, field, limits, isvol);
+  fMedVector->push_back(mte);
+}
+
+G3MedTableEntry* G3MedTable::GetMTE(G4int i) const
+{
+  if (i<0 || i>= G4int(fMedVector->size())) 
+    return 0;
+  
+  return (*fMedVector)[i];
+}    
+    
+G4int G3MedTable::GetSize() const
+{
+  return fMedVector->size();
+}    
+
+void G3MedTable::Clear()
+{
+  G3MedTableEntry* a;
+  while (fMedVector->size()>0) {
+    a = fMedVector->back();
+    fMedVector->pop_back();
+    for (G3MediumVector::iterator i=fMedVector->begin();
+                                  i!=fMedVector->end(); i++){
+      if (*i==a) {
+	fMedVector->erase(i);
+	i--;
+      }
+    } 
+    if ( a )  delete a;    
+  } 
+}
Index: /trunk/source/g3tog4/src/G3MedTableEntry.cc
===================================================================
--- /trunk/source/g3tog4/src/G3MedTableEntry.cc	(revision 817)
+++ /trunk/source/g3tog4/src/G3MedTableEntry.cc	(revision 817)
@@ -0,0 +1,84 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G3MedTableEntry.cc,v 1.4 2006/06/29 18:13:06 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+// by I.Hrivnacova, 27 Sep 99
+
+#include "G3MedTableEntry.hh"
+
+#include "G4Material.hh"
+#include "G4MagneticField.hh"
+#include "G4UserLimits.hh"
+
+G3MedTableEntry::G3MedTableEntry(G4int id, G4Material* material, 
+       G4MagneticField* field, G4UserLimits* limits, G4int isvol)
+  : fID(id),
+    fMaterial(material),
+    fField(field),
+    fLimits(limits),
+    fISVOL(isvol)
+{}
+
+G3MedTableEntry::G3MedTableEntry(const G3MedTableEntry& right)
+  : fID(right.GetID()),
+    fMaterial(right.GetMaterial()),
+    fField(right.GetField()),
+    fLimits(right.GetLimits()),
+    fISVOL(right.GetISVOL())    
+{}    
+
+G3MedTableEntry::~G3MedTableEntry()
+{}
+
+const G3MedTableEntry& 
+G3MedTableEntry::operator=(const G3MedTableEntry& right)
+{ 
+  fID = right.GetID();
+  fMaterial = right.GetMaterial();     
+  fField = right.GetField();
+  fLimits = right.GetLimits();
+  fISVOL = right.GetISVOL();  
+  return *this;
+}
+
+G4int G3MedTableEntry::operator==(const G3MedTableEntry& right) const
+{ 
+  if (fID == right.GetID()) 
+    return 1;
+  else
+    return 0;
+}
+
+G4int G3MedTableEntry::operator!=(const G3MedTableEntry& right) const
+{ 
+  if (*this == right) 
+    return 0;
+  else
+    return 1;
+}
+
Index: /trunk/source/g3tog4/src/G3NegVolPars.cc
===================================================================
--- /trunk/source/g3tog4/src/G3NegVolPars.cc	(revision 817)
+++ /trunk/source/g3tog4/src/G3NegVolPars.cc	(revision 817)
@@ -0,0 +1,223 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G3NegVolPars.cc,v 1.13 2006/06/29 18:13:08 gunter Exp $ 
+// GEANT4 tag $Name:  $
+//
+// modified by I. Hrivnacova, 13.10.99 
+
+#include "globals.hh"
+#include "G3VolTable.hh"
+#include "G4VSolid.hh"
+#include "G3toG4.hh"
+#include <cmath>
+
+G4bool G3CalcParamsFn(G4double *Rpar, G4int npar, G4double *Rparm,
+                      G4String shape, G4String shapem)
+  // Returns true only in case the parameters *after* processing
+  // this method remain negative.
+{
+  G4bool NegPresent = FALSE;
+  // for normal single volume positioning, just substitute for the
+  // negative parameters
+  // treat only the legal cases
+  if (shapem == shape) {
+    if (shape == "BOX" || shape == "TRD1" || shape == "TRD2" || 
+        shape == "ELTU") {
+      for (G4int i=0;i<npar;i++) {
+        if (Rpar[i] < 0) {
+          if (Rparm != 0) Rpar[i] = Rparm[i];
+	  if (Rpar[i] < 0) NegPresent = TRUE;
+        }
+      }
+    }
+    if (shape == "TRAP") {
+      for (G4int i=0;i<11;i++) {
+        if (i != 1 && i != 2 && i != 6 && i != 10) {
+          if (Rpar[i]<0) {
+            if (Rparm != 0) Rpar[i] = Rparm[i];
+	    if (Rpar[i] < 0) NegPresent = TRUE;
+	  }  
+        }
+      }
+    }
+    if (shape == "TUBE" || shape == "TUBS" || shape == "PARA") {
+      for (G4int i=0;i<3;i++) {
+        if (Rpar[i] < 0) {
+          if (Rparm != 0) Rpar[i] = Rparm[i];
+	  if (Rpar[i] < 0) NegPresent = TRUE;
+        }
+      }
+    }
+    if (shape == "CONE" || shape == "CONS") {
+      for (G4int i=0;i<5;i++) {
+        if (Rpar[i] < 0) {
+          if (Rparm != 0) Rpar[i] = Rparm[i];
+	  if (Rpar[i] < 0) NegPresent = TRUE;
+        }
+      }
+    }
+    if (shape == "SPHE") {
+      for (G4int i=0;i<2;i++) {
+        if (Rpar[i] < 0) {
+          if (Rparm != 0) Rpar[i] = Rparm[i];
+	  if (Rpar[i] < 0) NegPresent = TRUE;
+        }
+      }
+    }
+    if (shape == "PGON") {
+      G4int nz = int(Rpar[3]);
+      G4int ipl;
+      for (G4int i=0;i<nz;i++) {
+        ipl = 5 + i*3;
+        if (Rpar[ipl] < 0) {
+          if (Rparm != 0) Rpar[ipl] = Rparm[ipl];
+	  if (Rpar[ipl] < 0) NegPresent = TRUE;
+        }
+        if (Rpar[ipl+1] < 0) {
+          if (Rparm != 0)  Rpar[ipl] = Rparm[ipl];
+	  if (Rpar[ipl] < 0) NegPresent = TRUE;
+        }
+      }
+    }
+    if (shape == "PCON") {
+      G4int nz = int(Rpar[2]);
+      G4int ipl;
+      for (G4int i=0;i<nz;i++) {
+        ipl = 4 + i*3;
+        if (Rpar[ipl] < 0) {
+          if (Rparm != 0) Rpar[ipl] = Rparm[ipl];
+	  if (Rpar[ipl] < 0) NegPresent = TRUE;
+        }
+        if (Rpar[ipl+1] < 0) {
+          // TO DO
+	  // check - folowing argument might be ipl+1
+          if (Rparm != 0) Rpar[ipl] = Rparm[ipl];
+	  if (Rpar[ipl] < 0) NegPresent = TRUE;
+        }
+      }
+    }
+  }
+
+  if (shape == "BOX") {
+    if (shapem == "TRD1") {
+      if (Rpar[1] < 0) {
+        if (Rparm != 0) Rpar[1] = Rparm[2];
+	if (Rpar[1] < 0) NegPresent = TRUE;
+      }
+      if (Rpar[2] < 0) {
+        if (Rparm != 0) Rpar[2] = Rparm[3];
+	if (Rpar[2] < 0) NegPresent = TRUE;
+      }
+      if (Rpar[0] < 0) {
+        if (Rparm != 0) Rpar[0] = std::min(Rparm[0],Rparm[1]) +
+                                  std::abs(Rparm[0]-Rparm[1])*.5*Rpar[2]/Rparm[3];
+	if (Rpar[0] < 0) NegPresent = TRUE;
+      }
+    }
+    if (shapem == "TRD2") {
+      if (Rpar[2] < 0) {
+        if (Rparm != 0) Rpar[2] = Rparm[4];
+        if (Rpar[2]<0) NegPresent = TRUE;
+      }
+      if (Rpar[0] < 0) {
+        if (Rparm != 0) Rpar[0] = std::min(Rparm[0],Rparm[1]) +
+                                  std::abs(Rparm[0]-Rparm[1])*.5*Rpar[2]/Rparm[4];
+        if (Rpar[0]<0) NegPresent = TRUE;
+      }
+      if (Rpar[1] < 0) {
+        if (Rparm != 0) Rpar[1] = std::min(Rparm[2],Rparm[3]) +
+                                  std::abs(Rparm[2]-Rparm[3])*.5*Rpar[2]/Rparm[4];
+        if (Rpar[1]<0) NegPresent = TRUE;
+      }
+    }
+    if (shapem == "TRAP") {
+      if (Rpar[2] < 0) {
+        if (Rparm != 0) Rpar[2] = Rparm[0];
+        if (Rpar[2] < 0) NegPresent = TRUE;
+      }
+      if (Rpar[0] < 0) {
+        if (Rparm != 0) {
+          G4double xlo = std::min(Rparm[4],Rparm[8]) +
+            std::abs(Rparm[4]-Rparm[8])*.5*Rpar[2]/Rparm[0];
+          G4double xhi = std::min(Rparm[5],Rparm[9]) +
+            std::abs(Rparm[5]-Rparm[9])*.5*Rpar[2]/Rparm[0];
+          Rpar[0] = std::min(xlo,xhi);
+        }
+        if (Rpar[0] < 0) NegPresent = TRUE;
+      }
+      if (Rpar[1] < 0) {
+        if (Rparm != 0) Rpar[1] = std::min(Rparm[3],Rparm[7]) +
+                        std::abs(Rparm[3]-Rparm[7])*.5*Rpar[2]/Rparm[0];
+        if (Rpar[1] < 0) NegPresent = TRUE;
+      }
+    }
+  }
+  return NegPresent;
+}
+
+G4bool G3NegVolPars(G4double pars[], G4int *nparpt,
+                    G3VolTableEntry* vte,
+                    G3VolTableEntry* mvte, const char routine[])
+{
+  G4bool NegPresent = FALSE;
+
+  // retrieve parameters 
+
+  // the volume
+  G4String shape = vte->GetShape();
+  G4double* Rpar = vte->GetRpar();
+  G4int npar = vte->GetNpar();  
+  if (npar ==0) {
+    // no solid parameters are defined in vte
+    npar = *nparpt;
+    Rpar = pars;
+  }
+  else {  
+    // solid parameters are already defined in vte
+    // pars[], nparpt are ignored
+    // TO DO: check if g3 ignores them too or resets
+    // vte parameters according to this new ones !!
+  }  
+      
+  // mother
+  G4String shapem = mvte->GetShape();
+  G4double* Rparm = mvte->GetRpar();
+
+  if (strcmp(routine,"GSPOS") == 0 || strcmp(routine,"GSVOLU") == 0) {
+    NegPresent = G3CalcParamsFn(Rpar,npar,Rparm,shape,shapem);
+  }
+  if (strcmp(routine,"GSDVN") == 0) {
+    // just set the flag. The parametrization function figures out
+    // what to do.
+    for (G4int i=0;i<npar;i++) {
+      if (Rpar[i] < 0) {
+        NegPresent = TRUE;
+      }
+    }
+  }
+  return NegPresent;
+}
Index: /trunk/source/g3tog4/src/G3PartTable.cc
===================================================================
--- /trunk/source/g3tog4/src/G3PartTable.cc	(revision 817)
+++ /trunk/source/g3tog4/src/G3PartTable.cc	(revision 817)
@@ -0,0 +1,96 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G3PartTable.cc,v 1.14 2006/06/29 18:13:10 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+
+#include "G4Types.hh"
+#include <sstream>
+#include <iomanip>
+#include "G3PartTable.hh"
+
+typedef std::map<G4String, G4ParticleDefinition*, std::less<G4String> >
+::iterator PTDiterator;
+
+G3PartTable::G3PartTable(){
+}
+
+G3PartTable::~G3PartTable(){
+  if (PTD.size()>0){
+    //    G4cout << "Deleting PTD" << G4endl;
+    for (PTDiterator i=PTD.begin(); i != PTD.end(); i++) {
+      delete (*i).second;
+    }
+    PTD.clear();
+  }
+}
+
+G4ParticleDefinition*
+G3PartTable::Get(G4int partid){
+  G4String ShashID; // static
+  HashID(partid, ShashID);
+  PTDiterator i = PTD.find(ShashID);
+  return (*i).second;
+}
+
+void 
+G3PartTable::Put(G4int partid, G4ParticleDefinition *partpt){
+  G4String ShashID; // static
+  HashID(partid, ShashID);
+  PTD[ShashID]=partpt;
+}
+
+void
+G3PartTable::HashID(G4int partid, G4String& theHashID){
+  std::ostringstream ostr;
+  ostr << "Part" << partid << std::ends;
+  theHashID = ostr.str();
+}
+
+void 
+G3PartTable::HashID(G4int partid, G4String* theHashID){
+  HashID(partid, *theHashID);
+}
+
+void
+G3PartTable::PrintAll(){
+  if (PTD.size()>0){
+    G4int count=0;
+    G4cout << "Dump of PTD - " << PTD.size() << " entries: " << G4endl;
+    for (PTDiterator i=PTD.begin(); i != PTD.end(); i++) {
+      count++;
+      G4ParticleDefinition* aPTD = (*i).second;
+      G4cout << "PTD entry " << std::setw(3) << count << " particle name: " 
+	     << aPTD->GetParticleName() << G4endl;
+    }
+  }
+}
+
+
+
+
+
Index: /trunk/source/g3tog4/src/G3Pos.cc
===================================================================
--- /trunk/source/g3tog4/src/G3Pos.cc	(revision 817)
+++ /trunk/source/g3tog4/src/G3Pos.cc	(revision 817)
@@ -0,0 +1,81 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G3Pos.cc,v 1.9 2006/06/29 18:13:12 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+// modified by I.Hrivnacova, 13.10.99
+
+#include "globals.hh"
+#include "G3Pos.hh"
+
+G3Pos::G3Pos(G4String motherName, G4int C, G4ThreeVector* Position, G4int irot, 
+	     G4String Only) 
+  : _MotherName(motherName),
+    _Copy(C), 
+    _Position(Position), 
+    _Irot(irot), 
+    _Only(Only)
+{
+  if (_Only == "MANY") {
+    // warning when MANY position is created
+    G4String text = "G3Pos warning: Not supported MANY option has been encountered.\n";
+    text = text +   "               It may cause overlapping volumes.";
+    G4cerr << text << G4endl;
+  }
+}
+
+G3Pos::~G3Pos(){;}
+
+G4bool 
+G3Pos::operator == ( const G3Pos& lv) const {
+  return (this==&lv) ? true : false;
+}
+
+G4String&
+G3Pos::GetMotherName() {
+  return _MotherName;
+}
+
+G4int
+G3Pos::GetIrot() {
+  return _Irot;
+}
+
+G4int
+G3Pos::GetCopy() {
+  return _Copy;
+}
+
+G4ThreeVector* 
+G3Pos::GetPos() {
+  return _Position;
+}
+
+G4String&
+G3Pos::GetOnly() {
+  return _Only;
+}
Index: /trunk/source/g3tog4/src/G3RotTable.cc
===================================================================
--- /trunk/source/g3tog4/src/G3RotTable.cc	(revision 817)
+++ /trunk/source/g3tog4/src/G3RotTable.cc	(revision 817)
@@ -0,0 +1,75 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G3RotTable.cc,v 1.16 2006/06/29 18:13:15 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+// by I.Hrivnacova, 27 Sep 99
+
+#include "G3RotTable.hh"
+
+G3RotTable::G3RotTable()
+{
+  fRotVector = new G3RotMatrixVector();
+}
+
+G3RotTable::~G3RotTable()
+{
+  fRotVector->clear();
+  delete fRotVector;
+}
+
+G4RotationMatrix* G3RotTable::Get(G4int id) const
+{
+  for (size_t i=0; i<fRotVector->size(); i++) {
+    G3RotTableEntry* rte = (*fRotVector)[i];
+    if (id == rte->GetID()) return rte->GetMatrix();
+  }
+  return 0;
+}    
+
+void G3RotTable::Put(G4int id, G4RotationMatrix* matrix)
+{
+  G3RotTableEntry* rte = new G3RotTableEntry(id, matrix);
+  fRotVector->push_back(rte);
+}
+
+void G3RotTable::Clear()
+{
+  G3RotTableEntry* a;
+  while (fRotVector->size()>0) {
+    a = fRotVector->back();
+    fRotVector->pop_back();
+    for (G3RotMatrixVector::iterator i=fRotVector->begin();
+                                     i!=fRotVector->end(); i++){
+      if (*i==a) {
+	fRotVector->erase(i);
+	i--;
+      }
+    } 
+    if ( a )  delete a;    
+  } 
+}
Index: /trunk/source/g3tog4/src/G3RotTableEntry.cc
===================================================================
--- /trunk/source/g3tog4/src/G3RotTableEntry.cc	(revision 817)
+++ /trunk/source/g3tog4/src/G3RotTableEntry.cc	(revision 817)
@@ -0,0 +1,72 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G3RotTableEntry.cc,v 1.4 2006/06/29 18:13:17 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+// by I.Hrivnacova, 27 Sep 99
+
+#include "G3RotTableEntry.hh"
+
+#include "G3toG4RotationMatrix.hh"
+
+G3RotTableEntry::G3RotTableEntry(G4int id, G4RotationMatrix* matrix)
+  : fID(id),
+    fMatrix(matrix)
+{}
+
+G3RotTableEntry::G3RotTableEntry(const G3RotTableEntry& right)
+  : fID(right.GetID()),
+    fMatrix(right.GetMatrix())
+{}    
+
+G3RotTableEntry::~G3RotTableEntry()
+{}
+
+const G3RotTableEntry& 
+G3RotTableEntry::operator=(const G3RotTableEntry& right)
+{ 
+  fID = right.GetID();
+  fMatrix = right.GetMatrix();     
+  return *this;
+}
+
+G4int G3RotTableEntry::operator==(const G3RotTableEntry& right) const
+{ 
+  if (fID == right.GetID()) 
+    return 1;
+  else
+    return 0;
+}
+
+G4int G3RotTableEntry::operator!=(const G3RotTableEntry& right) const
+{ 
+  if (*this == right) 
+    return 0;
+  else
+    return 1;
+}
+
Index: /trunk/source/g3tog4/src/G3VolTable.cc
===================================================================
--- /trunk/source/g3tog4/src/G3VolTable.cc	(revision 817)
+++ /trunk/source/g3tog4/src/G3VolTable.cc	(revision 817)
@@ -0,0 +1,130 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G3VolTable.cc,v 1.22 2006/06/29 18:13:20 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+// modified by I.Hrivnacova, 13.10.99
+
+#include <iomanip>
+#include "globals.hh"
+#include "G3VolTable.hh"
+#include "G3Pos.hh"
+
+typedef std::map<G4String, G3VolTableEntry*, std::less<G4String> >
+::iterator VTDiterator;
+
+G3VolTable::G3VolTable() 
+  : G3toG4TopVTE(0), _FirstKey("UnDefined"), _NG3Pos(0){
+}
+
+G3VolTable::~G3VolTable(){
+  if (VTD.size()>0){
+    //    G4cout << "Deleting VTD" << G4endl;
+    for (VTDiterator i=VTD.begin(); i != VTD.end(); i++) {
+      delete (*i).second;
+    }
+    VTD.clear();
+  }
+}
+
+G3VolTableEntry*
+G3VolTable::GetVTE(const G4String& Vname) {
+  VTDiterator i = VTD.find(Vname);
+  if (i == VTD.end()) return 0;
+  else                return (*i).second;
+}
+
+void 
+G3VolTable::PrintAll(){
+  if (VTD.size()){
+    G4int i=0;
+    G4cout << "Dump of VTD - " << VTD.size() << " entries:" << G4endl;
+    VTEStat();
+    for (VTDiterator v=VTD.begin(); v != VTD.end(); v++){
+      G3VolTableEntry* VTE = (*v).second;
+      G4cout << "G3VolTable element " << std::setw(3) << i++ << " name "
+	     << VTE->GetName() << " has " << VTE->GetNoDaughters() 
+	     << " daughters" << G4endl;
+    }
+  }
+}
+
+G3VolTableEntry*
+G3VolTable::PutVTE(G3VolTableEntry* aG3VolTableEntry){
+  
+  if (GetVTE(aG3VolTableEntry->GetName()) == 0 ){
+    
+    // create a hash key
+    G4String HashID = aG3VolTableEntry->GetName();
+    
+    if (_FirstKey == "UnDefined") _FirstKey = HashID;
+    
+    // insert into dictionary
+    VTD[HashID] = aG3VolTableEntry;
+  }
+  return GetVTE(aG3VolTableEntry->GetName());
+}
+
+void 
+G3VolTable::CountG3Pos(){
+  _NG3Pos++;
+}
+
+void
+G3VolTable::SetFirstVTE(){
+  G3toG4TopVTE = VTD[_FirstKey];
+  
+  if (G3toG4TopVTE->NPCopies() > 0) {
+    _FirstKey = G3toG4TopVTE->GetMother()->GetName();
+    SetFirstVTE();
+  }
+}
+
+G3VolTableEntry*
+G3VolTable::GetFirstVTE() {
+  return G3toG4TopVTE;
+}
+
+void
+G3VolTable::VTEStat() {
+  G4cout << "Instantiated " << VTD.size() << 
+    " volume table entries \n" 
+ 	 << "                      " << _NG3Pos << " positions." << G4endl;
+}
+
+void 
+G3VolTable::Clear() {
+  if (VTD.size()>0){
+    for (VTDiterator i=VTD.begin(); i != VTD.end(); i++) {
+      delete (*i).second;
+    }
+    VTD.clear();
+  }
+  G3toG4TopVTE = 0;
+  _FirstKey = "UnDefined";
+  _NG3Pos = 0;
+}  
Index: /trunk/source/g3tog4/src/G3VolTableEntry.cc
===================================================================
--- /trunk/source/g3tog4/src/G3VolTableEntry.cc	(revision 817)
+++ /trunk/source/g3tog4/src/G3VolTableEntry.cc	(revision 817)
@@ -0,0 +1,355 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G3VolTableEntry.cc,v 1.12 2006/06/29 18:13:22 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+// modified by I.Hrivnacova, 13.10.99
+
+#include "globals.hh"
+#include "G3VolTableEntry.hh"
+#include "G3VolTable.hh"
+#include "G3RotTable.hh"
+#include "G4LogicalVolume.hh"
+#include "G4SubtractionSolid.hh"
+#include "G3Pos.hh"
+#include "G3toG4.hh"
+
+G3VolTableEntry::G3VolTableEntry(G4String& vname, G4String& shape, 
+			         G4double* rpar, G4int npar, G4int nmed, 
+			         G4VSolid* solid, G4bool hasNegPars)
+  : fVname(vname), fShape(shape), fRpar(0), fNpar(npar), fNmed(nmed), 
+    fSolid(solid), fLV(0), fHasNegPars(hasNegPars), fHasMANY(false),
+    fDivision(0)		  		     
+{
+  if (npar>0 && rpar!=0) {
+    fRpar = new G4double[npar];
+    for (G4int i=0; i<npar; i++) fRpar[i] = rpar[i];
+  }
+  fClones.push_back(this);
+}
+
+G3VolTableEntry::~G3VolTableEntry(){
+  if (fRpar!=0) delete [] fRpar;
+  delete fDivision;
+}
+
+inline G4bool 
+G3VolTableEntry::operator == ( const G3VolTableEntry& lv) const {
+  return (this==&lv) ? true : false;
+}
+
+void 
+G3VolTableEntry::AddG3Pos(G3Pos* aG3Pos){
+
+  // insert this position to the vector
+  G3Vol.CountG3Pos();
+  fG3Pos.push_back(aG3Pos);
+
+  // pass MANY info 
+  G4String vonly = aG3Pos->GetOnly();
+  if (vonly == "MANY") SetHasMANY(true);
+}
+
+void 
+G3VolTableEntry::AddDaughter(G3VolTableEntry* aDaughter){
+  if (FindDaughter(aDaughter->GetName()) == 0) {
+    fDaughters.push_back(aDaughter);
+  }
+}
+
+void 
+G3VolTableEntry::AddMother(G3VolTableEntry* itsMother){
+  if (FindMother(itsMother->GetName()) == 0) {
+    fMothers.push_back(itsMother);
+  }  
+}
+
+void 
+G3VolTableEntry::AddClone(G3VolTableEntry* itsClone){
+  if (FindClone(itsClone->GetName()) == 0) {
+    fClones.push_back(itsClone);
+  }  
+}
+
+void 
+G3VolTableEntry::AddOverlap(G3VolTableEntry* overlap){
+    fOverlaps.push_back(overlap);
+}
+
+void 
+G3VolTableEntry::ReplaceDaughter(G3VolTableEntry* vteOld, 
+                                 G3VolTableEntry* vteNew)
+{
+  G4int index = -1;
+  for (G4int i=0; i<GetNoDaughters(); i++){
+    if (fDaughters[i]->GetName() == vteOld->GetName()) index = i;
+  }
+  if (index<0) {
+    G4Exception(
+      "G3VolTableEntry::ReplaceDaughter: old daughter " +
+       vteOld->GetName() + " does not exist.");
+  }      
+  fDaughters[index] = vteNew;
+}
+
+void 
+G3VolTableEntry::ReplaceMother(G3VolTableEntry* vteOld, 
+                               G3VolTableEntry* vteNew)
+{
+  G4int index = -1;
+  for (G4int i=0; i<GetNoMothers(); i++){
+    if (fMothers[i]->GetName() == vteOld->GetName()) index = i;
+  }
+  if (index<0) {
+    G4Exception(
+      "G3VolTableEntry::ReplaceMother: old mother " +
+       vteOld->GetName() + " does not exist.");
+  }      
+  fMothers[index] = vteNew;
+}
+
+G3VolTableEntry*
+G3VolTableEntry::FindDaughter(const G4String& Dname){
+  for (G4int idau=0; idau<GetNoDaughters(); idau++){
+    if (GetDaughter(idau)->GetName() == Dname) return GetDaughter(idau);
+  }
+  return 0;
+}
+
+G3VolTableEntry*
+G3VolTableEntry::FindMother(const G4String& Mname){
+  for (G4int i=0; i<GetNoMothers(); i++){
+    G3VolTableEntry* mvte = GetMother(i);
+    if (mvte->GetName() == Mname) return mvte;
+  }
+  return 0;
+}
+
+G3VolTableEntry*
+G3VolTableEntry::FindClone(const G4String& Cname){
+  for (G4int i=0; i<GetNoClones(); i++){
+    G3VolTableEntry* cvte = GetClone(i);
+    if (cvte->GetName() == Cname) return cvte;
+  }
+  return 0;
+}
+
+void G3VolTableEntry::PrintSolidInfo() {
+// only parameters related to solid definition
+// are printed
+  G4cout << "VTE: " << fVname << " " << this << G4endl;
+  G4cout << "Solid: " << fSolid << G4endl;
+  G4cout << "Parameters (npar = " << fNpar << ") fRpar: ";
+  for (G4int i=0; i<fNpar; i++) G4cout << fRpar[i] << " ";
+  G4cout << G4endl;
+  G4cout << "HasNegPars: " << fHasNegPars << G4endl;
+  G4cout << "HasMANY: " << fHasMANY << G4endl;
+  G4cout << "================================= " << G4endl;
+}
+
+void
+G3VolTableEntry::SetName(G4String name){
+  fVname = name;
+}
+
+void
+G3VolTableEntry::SetLV(G4LogicalVolume* lv){
+  fLV = lv;
+}
+
+void 
+G3VolTableEntry::SetSolid(G4VSolid* solid){
+  fSolid = solid;
+}
+
+void G3VolTableEntry::SetNmed(G4int nmed) {
+  fNmed = nmed;
+}
+
+void G3VolTableEntry::SetNRpar(G4int npar, G4double* Rpar) {
+  if (npar != fNpar) {
+    fNpar = npar;
+    delete [] fRpar;
+    fRpar = new G4double[fNpar];
+  }      
+  for (G4int i=0; i<fNpar; i++) fRpar[i] = Rpar[i];
+}  
+
+void G3VolTableEntry::SetHasNegPars(G4bool hasNegPars) {
+  fHasNegPars = hasNegPars;
+}
+
+void G3VolTableEntry::SetHasMANY(G4bool hasMANY) {
+  fHasMANY = hasMANY;
+}
+
+void G3VolTableEntry::ClearG3PosCopy(G4int copy) {
+  if (fG3Pos.size()>0 && copy>=0 && copy<G4int(fG3Pos.size())) {
+    G3Pos* tmp=0;
+     std::vector<G3Pos*>::iterator it=fG3Pos.begin();
+     for(G4int j=0;j<copy;j++) it++;
+     if(it!=fG3Pos.end()) {
+         tmp = fG3Pos[copy];
+         fG3Pos.erase(it);
+     }
+  }
+}
+
+void G3VolTableEntry::ClearDivision() {
+  delete fDivision;
+  fDivision = 0;
+}
+
+G4String
+G3VolTableEntry::GetName() {
+  return fVname;
+}
+
+G4String
+G3VolTableEntry::GetShape() {
+  return fShape;
+}
+
+G4int
+G3VolTableEntry::GetNmed() {
+  return fNmed;
+}
+
+G4int 
+G3VolTableEntry::GetNpar() {
+  return fNpar;
+}
+
+G4double* 
+G3VolTableEntry::GetRpar() {
+  return fRpar;
+}
+
+G4int 
+G3VolTableEntry::NPCopies() {
+  return fG3Pos.size();
+}
+
+G3Pos* 
+G3VolTableEntry::GetG3PosCopy(G4int copy) {
+  if (fG3Pos.size()>0 && copy>=0)
+    return fG3Pos[copy];
+  else
+    return 0;
+}
+
+G4bool 
+G3VolTableEntry::HasNegPars(){
+  return fHasNegPars;
+}
+
+G4bool 
+G3VolTableEntry::HasMANY(){
+  return fHasMANY;
+}
+
+G4VSolid*
+G3VolTableEntry::GetSolid() {
+  return fSolid;
+}
+
+G4LogicalVolume* 
+G3VolTableEntry::GetLV() {
+  return fLV;
+}
+
+G4int
+G3VolTableEntry::GetNoDaughters() {
+  return fDaughters.size();
+}
+
+G4int
+G3VolTableEntry::GetNoMothers() {
+  return fMothers.size();
+}
+
+G4int
+G3VolTableEntry::GetNoClones() {
+  return fClones.size();
+}
+
+G4int
+G3VolTableEntry::GetNoOverlaps() {
+  return fOverlaps.size();
+}
+
+G3VolTableEntry* 
+G3VolTableEntry::GetDaughter(G4int i) {
+  if (i<G4int(fDaughters.size()) && i>=0)
+    return fDaughters[i];
+  else 
+    return 0;
+}
+
+G3VolTableEntry*
+G3VolTableEntry::GetMother(G4int i){
+  if (i<G4int(fMothers.size()) && i>=0)
+    return fMothers[i];
+  else
+    return 0;
+}
+
+// to be removed
+G3VolTableEntry*
+G3VolTableEntry::GetMother(){
+  if (fMothers.size()>0)
+    return fMothers[0];
+  else
+    return 0;  
+}
+
+G3VolTableEntry*
+G3VolTableEntry::GetClone(G4int i){
+  if (i<G4int(fClones.size()) && i>=0)
+    return fClones[i];
+  else
+    return 0;
+}
+
+G3VolTableEntry*
+G3VolTableEntry::GetMasterClone(){
+  G3VolTableEntry* master;
+  G4String name = fVname;
+  if (name.contains(gSeparator)) {
+    name = name(0, name.first(gSeparator));
+    master = G3Vol.GetVTE(name); 
+  }
+  else 
+    master = this;
+
+  return master;
+}
+
+std::vector<G3VolTableEntry*>*
+G3VolTableEntry::GetOverlaps(){
+  return &fOverlaps;
+}
Index: /trunk/source/g3tog4/src/G3fillParams.cc.archive
===================================================================
--- /trunk/source/g3tog4/src/G3fillParams.cc.archive	(revision 817)
+++ /trunk/source/g3tog4/src/G3fillParams.cc.archive	(revision 817)
@@ -0,0 +1,76 @@
+// 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: G3fillParams.cc.archive,v 1.2 2003/06/16 16:50:54 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+// extracted from clparse.cc by I. Hrivnacova, 30.7.99
+
+#include "globals.hh"
+#include <fstream>
+
+ofstream ofile;
+
+G4int narray;
+G4int Ipar[1000];
+G4double Rpar[1000];
+G4String Spar[1000];
+
+void G3fillParams(G4String *tokens, char *ptypes)
+//
+// G3fillParams
+//
+// Interpret tokens to fill call parameters, based on parameter
+//   types ptypes
+//
+{
+    // loop over ptypes
+    G4int i =0, ipt = 0, k = 0;
+    G4int ni =0, nr = 0, ns = 0;
+    while (ptypes[i] != '\0')
+        {
+            switch (ptypes[i]) {
+            case 'i':
+                Ipar[ni] = atoi(tokens[ipt].data());
+                narray = Ipar[ni];
+                ni++; ipt++;
+                break;
+            case 'r':
+                Rpar[nr] = atof(tokens[ipt].data());
+                nr++; ipt++;
+                break;
+            case 's':
+                Spar[ns] = tokens[ipt];
+                ns++; ipt++;
+                break;
+            case 'I':
+                for (k=0; k < narray; k++)
+                    {
+                        Ipar[ni] = atoi(tokens[ipt].data());
+                        ni++; ipt++;
+                    }
+                break;
+            case 'R':
+                for (k=0; k < narray; k++) 
+                    { 
+                        Rpar[nr] = atof(tokens[ipt].data()); 
+                        nr++; ipt++;
+                    }
+                break;
+            case 'S':
+                for (k=0; k < narray; k++)
+                    {
+                        Spar[ns] = tokens[ipt];
+                        ns++; ipt++;
+                    }
+                break;
+            default:
+                ofile << "unidentified ptype '" << ptypes[i] << endl;
+            };
+            i++;
+        }
+}
Index: /trunk/source/g3tog4/src/G3toG4BuildTree.cc
===================================================================
--- /trunk/source/g3tog4/src/G3toG4BuildTree.cc	(revision 817)
+++ /trunk/source/g3tog4/src/G3toG4BuildTree.cc	(revision 817)
@@ -0,0 +1,201 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G3toG4BuildTree.cc,v 1.20 2006/06/29 18:13:24 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+// modified by I. Hrivnacova, 2.8.99 
+
+#include "globals.hh"
+#include "G3toG4BuildTree.hh"
+#include "G3RotTable.hh"
+#include "G3MedTable.hh"
+#include "G3VolTable.hh"
+#include "G3SensVolVector.hh"
+#include "G3Pos.hh"
+#include "G4LogicalVolume.hh"
+#include "G4PVPlacement.hh"
+#include "G4ReflectionFactory.hh"
+#include "G4Transform3D.hh"
+
+void G3toG4BuildTree(G3VolTableEntry* curVTE, G3VolTableEntry* motherVTE)
+{
+  G3toG4BuildLVTree(curVTE, motherVTE);
+  G3toG4BuildPVTree(curVTE);
+}  
+
+void G3toG4BuildLVTree(G3VolTableEntry* curVTE, G3VolTableEntry* motherVTE)
+{
+  // check existence of the solid
+  if (curVTE->GetSolid()) {
+    G4LogicalVolume* curLog = curVTE->GetLV();
+    if (!curLog) {
+      // skip creating logical volume
+      // in case it already exists
+    
+      // material
+      G4Material* material = 0;
+      G3MedTableEntry* mte = G3Med.get(curVTE->GetNmed());
+      if (mte) material = mte->GetMaterial();
+      if (!material) {
+        G4Exception("VTE " + curVTE->GetName() + " has not defined material!!");
+      } 
+
+      // logical volume
+      curLog = 
+        new G4LogicalVolume(curVTE->GetSolid(), material, curVTE->GetName());
+      curVTE->SetLV(curLog);
+      
+      // insert logical volume to G3SensVol vector
+      // in case it is sensitive
+      if (mte->GetISVOL()) G3SensVol.push_back(curLog);
+    }  
+  }
+  else {
+    if ( !(curVTE->GetDivision() && motherVTE->GetMasterClone() == motherVTE &&
+           motherVTE->GetNoClones()>1)) {
+      // ignore dummy vte's 
+      // (this should be the only case when the vte is dummy but
+      // is present in mother <-> daughters tree
+      G4Exception("VTE " + curVTE->GetName() + " has not defined solid!!");
+    }
+  }  
+  
+  // process daughters
+  G4int Ndau = curVTE->GetNoDaughters();
+  for (int Idau=0; Idau<Ndau; Idau++){
+    G3toG4BuildLVTree(curVTE->GetDaughter(Idau), curVTE);
+  }
+}
+
+void G3toG4BuildPVTree(G3VolTableEntry* curVTE)
+{
+  // check existence of the solid
+  if (curVTE->GetSolid()) {
+    G4LogicalVolume* curLog = curVTE->GetLV();
+  
+    // positions in motherVTE
+    for (G4int i=0; i<curVTE->NPCopies(); i++){
+
+      G3Pos* theG3Pos = curVTE->GetG3PosCopy(i);
+      if (theG3Pos) {
+
+        // loop over all mothers 
+        for (G4int im=0; im<curVTE->GetNoMothers(); im++) {
+
+          G3VolTableEntry* motherVTE = curVTE->GetMother(im);
+          if (theG3Pos->GetMotherName() == motherVTE->GetMasterClone()->GetName()) {
+     
+            // get mother logical volume
+            G4LogicalVolume* mothLV=0;
+            if (motherVTE) {
+              G4String motherName = motherVTE->GetName();    
+              if (!curVTE->FindMother(motherName)) continue;
+              if (curVTE->FindMother(motherName)->GetName() != motherName) {
+                // check consistency - tbr
+                G4Exception("G3toG4BuildTree: Inconsistent mother <-> daughter !!");
+              }
+              mothLV = motherVTE->GetLV();
+            }  
+            else {  	    
+              mothLV = 0;
+            }  
+    
+            // copy number
+            // (in G3 numbering starts from 1 but in G4 from 0)
+            G4int copyNo = theG3Pos->GetCopy() - 1;
+      
+            // position it if not top-level volume
+
+	    if (mothLV != 0) {
+
+              // transformation
+              G4int irot = theG3Pos->GetIrot();
+              G4RotationMatrix* theMatrix = 0;
+              if (irot>0) theMatrix = G3Rot.Get(irot);
+              G4Rotate3D rotation;
+              if (theMatrix) {            
+  	        rotation = G4Rotate3D(*theMatrix);
+	      }
+
+              #ifndef G3G4_NO_REFLECTION
+              G4Translate3D translation(*(theG3Pos->GetPos()));
+	      G4Transform3D transform3D = translation * (rotation.inverse());
+
+              G4ReflectionFactory::Instance()
+	        ->Place(transform3D,       // transformation
+	                curVTE->GetName(), // PV name
+			curLog,            // its logical volume 
+			mothLV,            // mother logical volume
+			false,             // only
+			copyNo);           // copy
+              #else
+              new G4PVPlacement(theMatrix,            // rotation matrix
+                              *(theG3Pos->GetPos()),  // its position
+                              curLog,                 // its LogicalVolume 
+                              curVTE->GetName(),      // PV name
+                              mothLV,                 // Mother LV
+                              0,                      // only
+                              copyNo);                // copy
+              #endif
+
+              // verbose
+  	      #ifdef G3G4DEBUG
+	        G4cout << "PV: " << i << "th copy of " << curVTE->GetName()
+	  	       << "  in " << motherVTE->GetName() << "  copyNo: " 
+		       << copyNo << "  irot: " << irot << "  pos: " 
+		       << *(theG3Pos->GetPos()) << G4endl;
+	      #endif
+            }	    
+	  }
+        }
+        // clear this position
+        curVTE->ClearG3PosCopy(i);
+        i--;
+      }
+    }
+
+    // divisions     
+    if (curVTE->GetDivision()) {
+      curVTE->GetDivision()->CreatePVReplica();
+      // verbose
+      #ifdef G3G4DEBUG
+	G4cout << "CreatePVReplica: " << curVTE->GetName() 
+	       << " in "  <<  curVTE->GetMother()->GetName() << G4endl;
+      #endif
+
+      // clear this divison
+      curVTE->ClearDivision(); 
+    }
+  }
+  
+  // process daughters
+  G4int Ndau = curVTE->GetNoDaughters();
+  for (int Idau=0; Idau<Ndau; Idau++){
+    G3toG4BuildPVTree(curVTE->GetDaughter(Idau));
+  }
+}
+
Index: /trunk/source/g3tog4/src/G3toG4MANY.cc
===================================================================
--- /trunk/source/g3tog4/src/G3toG4MANY.cc	(revision 817)
+++ /trunk/source/g3tog4/src/G3toG4MANY.cc	(revision 817)
@@ -0,0 +1,158 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G3toG4MANY.cc,v 1.2 2006/06/29 18:13:26 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+// By I. Hrivnacova, 22.10.01 
+
+//#define G3G4DEBUG 1
+
+#include "globals.hh"
+#include "G3toG4MANY.hh"
+#include "G3Pos.hh"
+#include "G3RotTable.hh"
+#include "G4SubtractionSolid.hh"
+
+void G3toG4MANY(G3VolTableEntry* curVTE)
+{
+  if (curVTE->GetNoOverlaps() > 0) {
+  
+    // check consistency 
+    if (!curVTE->HasMANY()) { 
+      G4String text = "G3toG4MANY: volume ";
+      text = text + curVTE->GetName() + " has specified overlaps \n";
+      text = text + " but is not defined as MANY.";
+      G4Exception(text);
+    }  
+
+    // only MANY volumes with one position are supported
+    if (curVTE->NPCopies() != 1) {
+      G4String text = "G3toG4MANY: volume ";
+      text = text + curVTE->GetName() + " which has MANY has not just one position.";
+      G4Exception(text);
+    }  
+
+    #ifdef G3G4DEBUG
+    G4cout << "G3toG4MANY  " << curVTE->GetName() << " boolean" << G4endl;
+    #endif
+
+    G4Transform3D transform = GetTransform3D(curVTE->GetG3PosCopy(0)); 
+    
+    MakeBooleanSolids(curVTE, curVTE->GetOverlaps(), transform.inverse());
+  }
+
+  // process daughters
+  for (G4int i=0; i<curVTE->GetNoDaughters(); i++)
+    G3toG4MANY(curVTE->GetDaughter(i));
+}
+
+void MakeBooleanSolids(G3VolTableEntry* curVTE, G3VolTableEntryVector* overlaps,
+		       const G4Transform3D& transform)
+{			     
+  // loop over overlap VTEs
+  for (size_t i=0; i<overlaps->size(); i++){
+   
+    G3VolTableEntry* overlapVTE = (*overlaps)[i]; 
+
+     // loop over clone VTEs
+    for (G4int ij=0; ij<overlapVTE->GetMasterClone()->GetNoClones(); ij++){
+    
+      G3VolTableEntry* cloneVTE = overlapVTE->GetMasterClone()->GetClone(ij);   
+   
+      // loop over clone positions
+      for (G4int j=0; j<cloneVTE->NPCopies(); j++){
+
+        #ifdef G3G4DEBUG
+        G4cout << "From '" << curVTE->GetName() << "' "
+	       << "cut '" << cloneVTE->GetName() << "' :"
+	       << i  << "th overlap (from " << overlaps->size() << ") "
+	       << ij << "th clone (from " << overlapVTE->GetMasterClone()->GetNoClones() << ") "
+	       << j  << "th copy (from " << cloneVTE->NPCopies() << ")  "
+	       << G4endl;
+        #endif
+
+        SubstractSolids(curVTE, cloneVTE, j, transform); 
+      }
+    }    
+  }				  
+}			
+
+void SubstractSolids(G3VolTableEntry* vte1, G3VolTableEntry* vte2,
+	             G4int copy, const G4Transform3D& transform)
+{			     
+  // vte2 transformation
+  G4Transform3D transform2 = GetTransform3D(vte2->GetG3PosCopy(copy));
+   
+  // compose new name 
+  G4String newName = vte1->GetSolid()->GetName();
+  newName = newName + "-" + vte2->GetSolid()->GetName();   
+
+  #ifdef G3G4DEBUG
+  G4cout << "   " << newName << G4endl; 
+  #endif
+
+  G4VSolid* newSolid 
+    = new G4SubtractionSolid(newName, vte1->GetSolid(), vte2->GetSolid(),
+                             transform*transform2);
+				 
+  // update vte1
+  vte1->SetSolid(newSolid);
+
+  // process daughters
+  for (G4int k=0; k<vte1->GetNoDaughters(); k++){
+         	
+    G3VolTableEntry* dVTE = vte1->GetDaughter(k);				
+	 
+    if (dVTE->NPCopies() != 1) {
+      G4String text = "G3toG4MANY: volume ";
+      text = text + dVTE->GetName() + " which has MANY has not just one position.";
+      G4Exception(text);
+    }
+	  
+    G4Transform3D dt = GetTransform3D(dVTE->GetG3PosCopy(0)); 
+    SubstractSolids(dVTE, vte2, copy, dt.inverse()*transform);
+  }	
+}			
+
+G4Transform3D GetTransform3D(G3Pos* g3pos)
+{
+  G4int irot = g3pos->GetIrot();
+  G4RotationMatrix* theMatrix = 0;
+  if (irot>0) theMatrix = G3Rot.Get(irot);
+  
+  G4Rotate3D rotation;
+  if (theMatrix) {            
+     rotation = G4Rotate3D(*theMatrix);
+  }
+
+  G4Translate3D translation(*(g3pos->GetPos()));
+  G4Transform3D transform3D = translation * (rotation.inverse());
+  
+  return transform3D;
+}
+
+
Index: /trunk/source/g3tog4/src/G3toG4MakeSolid.cc
===================================================================
--- /trunk/source/g3tog4/src/G3toG4MakeSolid.cc	(revision 817)
+++ /trunk/source/g3tog4/src/G3toG4MakeSolid.cc	(revision 817)
@@ -0,0 +1,341 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G3toG4MakeSolid.cc,v 1.10 2006/06/29 18:13:29 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+// modified by I.Hrivnacova, V.Berejnoi 27 Sep 99 
+
+#include "globals.hh"
+#include "G4Box.hh"
+#include "G4Tubs.hh"
+#include "G4Trd.hh"
+#include "G4Trap.hh"
+#include "G4Cons.hh"
+#include "G4Sphere.hh"
+#include "G3toG4.hh"
+#include "G4Polycone.hh"
+#include "G4Polyhedra.hh"
+#include "G4Para.hh"
+#include "G4Hype.hh"
+#include "G4EllipticalTube.hh"
+#include "G3toG4MakeSolid.hh"
+        
+G4VSolid* G3toG4MakeSolid(const G4String& vname, const G4String& shape, 
+			  const G4double* Rpar, const G4int npar, 
+			  G4bool& NegVolPars, G4bool& Deferred,
+			  G4bool* OKAxis){
+    
+  // Create the solid if no negative length parameters
+  G4VSolid *solid = 0;
+
+  NegVolPars = false;
+
+  // if npar = 0 assume LV deferral
+  Deferred = (npar == 0);
+  // modified
+  if (Deferred) return solid;
+
+  for (G4int i=0;i<3;i++){
+    OKAxis[i]=false;
+  };
+
+  if ( shape == "BOX" ) {
+    G4double pX = Rpar[0]*cm;
+    G4double pY = Rpar[1]*cm;
+    G4double pZ = Rpar[2]*cm;
+
+    OKAxis[0]=OKAxis[1]=OKAxis[2]=true;
+    
+    NegVolPars = pX<0 || pY<0 || pZ<0;
+    
+    if (!(NegVolPars || Deferred)) { 
+      solid = new G4Box(vname, pX, pY, pZ);
+    }
+
+  } else if ( shape == "TRD1" ) {
+    G4double pdx1 = Rpar[0]*cm;
+    G4double pdx2 = Rpar[1]*cm;
+    G4double pdy1 = Rpar[2]*cm;
+    G4double pdy2 = pdy1;
+    G4double pdz  = Rpar[3]*cm;
+
+    OKAxis[1]=OKAxis[2]=true;
+
+    NegVolPars = pdx1<0 || pdx2<0 || pdy1<0 || pdz<0;
+
+    if (!(NegVolPars || Deferred)) {
+      solid = new G4Trd(vname, pdx1, pdx2, pdy1, pdy2, pdz);
+    }
+
+  } else if ( shape == "TRD2" ) {
+    G4double pdx1 = Rpar[0]*cm;
+    G4double pdx2 = Rpar[1]*cm;
+    G4double pdy1 = Rpar[2]*cm;
+    G4double pdy2 = Rpar[3]*cm;
+    G4double pdz  = Rpar[4]*cm;
+
+    OKAxis[2]=true;
+
+    NegVolPars = pdx1<0 || pdx2<0 || pdy1<0 || pdy2<0 || pdz<0;
+ 
+    if (!(NegVolPars || Deferred)) {
+      solid = new G4Trd(vname, pdx1, pdx2, pdy1, pdy2, pdz);
+    }
+
+  } else if ( shape == "TRAP" ) {
+    G4double pDz    = Rpar[0]*cm;
+    G4double pTheta = Rpar[1]*deg;
+    G4double pPhi   = Rpar[2]*deg;
+    G4double pDy1   = Rpar[3]*cm;
+    G4double pDx1   = Rpar[4]*cm;
+    G4double pDx2   = Rpar[5]*cm;
+    G4double pAlp1  = Rpar[6]*deg;
+    G4double pDy2   = Rpar[7]*cm;
+    G4double pDx3   = Rpar[8]*cm;
+    G4double pDx4   = Rpar[9]*cm;
+    G4double pAlp2  = Rpar[10]*deg;
+
+    OKAxis[2]=true;
+
+    NegVolPars= pDz<0 || pDy1<0 || pDx1<0 || pDx2<0 || pDy2<0 || pDx3<0 || pDx4<0;
+
+    if (!(NegVolPars || Deferred)) {
+      // added for test only 
+      if (!(pDz>0))  pDz  += 0.001*cm;
+      if (!(pDy1>0)) pDy1 += 0.001*cm;
+      if (!(pDx1>0)) pDx1 += 0.001*cm;
+      if (!(pDx2>0)) pDx2 += 0.001*cm;
+      if (!(pDy2>0)) pDy2 += 0.001*cm;
+      if (!(pDx3>0)) pDx3 += 0.001*cm;
+      if (!(pDx4>0)) pDx4 += 0.001*cm;
+    
+      solid = new 
+	G4Trap(vname, pDz, pTheta, pPhi, pDy1, pDx1, pDx2, pAlp1, pDy2, pDx3, 
+	       pDx4, pAlp2);
+    }
+
+  } else if ( shape == "TUBE" ) {
+    G4double pRMin = Rpar[0]*cm;
+    G4double pRMax = Rpar[1]*cm;
+    G4double pDz   = Rpar[2]*cm;
+    G4double pSPhi = 0.*deg;
+    G4double pDPhi = 360.*deg;
+    
+    OKAxis[0]=OKAxis[1]=OKAxis[2]=true;
+
+    NegVolPars = pRMin<0 || pRMax<0 || pDz<0;
+    
+    if (!(NegVolPars || Deferred)) {
+      solid = new G4Tubs(vname, pRMin, pRMax, pDz, pSPhi, pDPhi);
+    }
+
+  } else if ( shape == "TUBS" ) {
+    G4double pRMin = Rpar[0]*cm;
+    G4double pRMax = Rpar[1]*cm;
+    G4double pDz   = Rpar[2]*cm;
+    G4double pSPhi = Rpar[3]*deg;
+    G4double pDPhi = Rpar[4]*deg - pSPhi;
+    if ( Rpar[4]*deg <= pSPhi ) pDPhi = pDPhi + 360.*deg;
+
+    OKAxis[0]=OKAxis[1]=OKAxis[2]=true;
+
+    NegVolPars = pRMin<0 || pRMax<0 || pDz<0;
+
+    if (!(NegVolPars || Deferred)){
+      solid = new G4Tubs(vname, pRMin, pRMax, pDz, pSPhi, pDPhi);
+    }
+
+  } else if ( shape == "CONE" ) {
+    G4double pDz    = Rpar[0]*cm;
+    G4double pRmin1 = Rpar[1]*cm;
+    G4double pRmax1 = Rpar[2]*cm;
+    G4double pRmin2 = Rpar[3]*cm;
+    G4double pRmax2 = Rpar[4]*cm;
+    G4double pSPhi = 0.*deg;
+    G4double pDPhi = 360.*deg;
+
+    OKAxis[0]=OKAxis[1]=OKAxis[2]=true;
+
+    NegVolPars = pDz<0 || pRmin1<0 || pRmax1<0 || pRmin2<0 || pRmax2<0;
+
+    if (!(NegVolPars || Deferred)){
+      solid = new 
+	G4Cons(vname, pRmin1, pRmax1, pRmin2, pRmax2, pDz, pSPhi, pDPhi);
+    }
+
+  } else if ( shape == "CONS" ) {
+    G4double pDz    = Rpar[0]*cm;
+    G4double pRmin1 = Rpar[1]*cm;
+    G4double pRmax1 = Rpar[2]*cm;
+    G4double pRmin2 = Rpar[3]*cm;
+    G4double pRmax2 = Rpar[4]*cm;
+    G4double pSPhi  = Rpar[5]*deg;
+    G4double pDPhi  = Rpar[6]*deg - pSPhi;
+    if ( Rpar[6]*deg <= pSPhi ) pDPhi = pDPhi + 360.*deg;
+
+    OKAxis[0]=OKAxis[1]=OKAxis[2]=true;
+
+    NegVolPars = pDz<0 || pRmin1<0 || pRmax1<0 || pRmin2<0 || pRmax2<0;
+
+    if (!(NegVolPars || Deferred)){
+      solid = new 
+	G4Cons(vname, pRmin1, pRmax1, pRmin2, pRmax2, pDz, pSPhi, pDPhi);
+    }
+
+  } else if ( shape == "SPHE" ) {
+    G4double pRmin  = Rpar[0]*cm;
+    G4double pRmax  = Rpar[1]*cm;
+    G4double pThe1  = Rpar[2]*deg;
+    G4double pThe2  = Rpar[3]*deg;
+    G4double pDThe  = pThe2 - pThe1;
+    G4double pPhi1  = Rpar[4]*deg;
+    G4double pPhi2  = Rpar[5]*deg;
+    G4double pDPhi  = pPhi2 - pPhi1;
+
+    NegVolPars = pRmin<0 || pRmax<0;
+
+    if (!(NegVolPars || Deferred)) {
+      solid = new G4Sphere(vname, pRmin, pRmax, pPhi1, pDPhi, pThe1, pDThe);
+    }
+
+  } else if ( shape == "PARA" ) {
+    G4double pDx = Rpar[0]*cm;
+    G4double pDy = Rpar[1]*cm;
+    G4double pDz = Rpar[2]*cm;
+    G4double pAlph = Rpar[3]*deg;
+    G4double pThet = Rpar[4]*deg;
+    G4double pPhi  = Rpar[5]*deg;
+
+    OKAxis[0]=OKAxis[1]=OKAxis[2]=true;
+
+    NegVolPars = pDx<0 || pDy<0 || pDz<0;
+
+    if (!(NegVolPars || Deferred)){
+      solid = new G4Para(vname, pDx, pDy, pDz, pAlph, pThet, pPhi);
+    }
+
+  } else if ( shape == "PGON" ) {
+    G4int i;
+    G4int npdv = G4int(Rpar[2]);
+    G4int nz = G4int(Rpar[3]);
+    G4double pPhi1 = Rpar[0]*deg;
+    G4double dPhi  = Rpar[1]*deg;
+    G4double *DzArray = new G4double[nz];
+    G4double *Rmax    = new G4double[nz];
+    G4double *Rmin    = new G4double[nz];
+
+    OKAxis[0]=OKAxis[1]=OKAxis[2]=true;
+
+    NegVolPars = 0;
+
+    for(i=0; i<nz; i++) {
+      G4int i4=3*i+4;
+      G4int i5=i4+1;
+      G4int i6=i4+2;
+      DzArray[i] = Rpar[i4]*cm;
+      Rmin[i] = Rpar[i5]*cm;
+      Rmax[i] = Rpar[i6]*cm;
+    }
+    solid = new G4Polyhedra(vname, pPhi1, dPhi, npdv, nz, DzArray, Rmin, Rmax);
+    delete [] DzArray;
+    delete [] Rmin;
+    delete [] Rmax;
+
+  } else if ( shape == "PCON" ) {
+    G4int i;
+    G4double pPhi1 =  Rpar[0]*deg;
+    G4double dPhi  = Rpar[1]*deg;    
+    G4int nz = G4int(Rpar[2]);
+    G4double *DzArray = new G4double[nz];
+    G4double *Rmax    = new G4double[nz];
+    G4double *Rmin    = new G4double[nz];
+
+    OKAxis[0]=OKAxis[1]=OKAxis[2]=true;
+
+    NegVolPars = 0;
+
+    for(i=0; i<nz; i++){
+      G4int i4=3*i+3;
+      G4int i5=i4+1;
+      G4int i6=i4+2;
+      DzArray[i] = Rpar[i4]*cm;
+      Rmin[i] = Rpar[i5]*cm;
+      Rmax[i] = Rpar[i6]*cm;
+    }
+    solid = new G4Polycone(vname, pPhi1, dPhi, nz, DzArray, Rmin, Rmax);
+    delete [] DzArray;
+    delete [] Rmin;
+    delete [] Rmax;
+
+  } else if ( shape == "ELTU" ) {
+    G4double dX = Rpar[0]*cm;
+    G4double dY = Rpar[1]*cm;
+    G4double dZ = Rpar[2]*cm;
+
+    OKAxis[0]=OKAxis[1]=OKAxis[2]=true;
+    
+    NegVolPars = dX<0 || dY<0 || dZ<0;
+    
+    if (!(NegVolPars || Deferred)) { 
+      solid = new G4EllipticalTube(vname, dX, dY, dZ);
+    }
+
+  } else if ( shape == "HYPE" ) {
+    G4double pRmin = Rpar[0]*cm;
+    G4double pRmax = Rpar[1]*cm;
+    G4double pDz   = Rpar[2]*cm;
+    G4double pThet = Rpar[3]*deg;
+
+    NegVolPars = pRmin<0 || pRmax<0 || pDz<0;
+
+    if (!(NegVolPars || Deferred)){
+      solid = new G4Hype(vname, pRmin, pRmax, pThet, pThet, pDz);
+    } else {
+      G4cerr << "Negative length parameters not supported for shape " 
+	     << shape << G4endl;
+    }
+
+  } else if ( shape == "GTRA" ) {
+    // $$$ not implemented.
+    G4cerr << "GTRA not supported" << G4endl;
+
+  } else if ( shape == "CTUB" ) {
+    // $$$ not implemented.
+    G4cerr << "CTUB not supported" << G4endl;
+  }
+  return solid;
+}
+
+
+
+
+
+
+
+
+
+
Index: /trunk/source/g3tog4/src/G3toG4RotationMatrix.cc
===================================================================
--- /trunk/source/g3tog4/src/G3toG4RotationMatrix.cc	(revision 817)
+++ /trunk/source/g3tog4/src/G3toG4RotationMatrix.cc	(revision 817)
@@ -0,0 +1,89 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G3toG4RotationMatrix.cc,v 1.4 2006/06/29 18:13:31 gunter Exp $
+// GEANT4 tag $Name:  $
+
+#include "G3toG4RotationMatrix.hh"
+
+G3toG4RotationMatrix::G3toG4RotationMatrix()
+{
+  rxx = 1;
+  ryx = 0;
+  rzx = 0;
+  rxy = 0;
+  ryy = 1;
+  rzy = 0;
+  rxz = 0;
+  ryz = 0;
+  rzz = 1;
+}
+
+G3toG4RotationMatrix::~G3toG4RotationMatrix()
+{
+    ;
+}
+
+void 
+G3toG4RotationMatrix::SetRotationMatrixByCol(const G4ThreeVector& col1,
+                                             const G4ThreeVector& col2,
+                                             const G4ThreeVector& col3)
+{
+  rxx = col1.x();
+  ryx = col1.y();
+  rzx = col1.z();
+  
+  rxy = col2.x();
+  ryy = col2.y();
+  rzy = col2.z();
+  
+  rxz = col3.x();
+  ryz = col3.y();
+  rzz = col3.z();
+  
+}
+
+void 
+G3toG4RotationMatrix::SetRotationMatrixByRow(const G4ThreeVector& row1,
+                                             const G4ThreeVector& row2,
+                                             const G4ThreeVector& row3)
+{
+  rxx = row1.x();
+  rxy = row1.y();
+  rxz = row1.z();
+  
+  ryx = row2.x();
+  ryy = row2.y();
+  ryz = row2.z();
+  
+  rzx = row3.x();
+  rzy = row3.y();
+  rzz = row3.z();
+  
+}
+
+
+
Index: /trunk/source/g3tog4/src/G4BuildGeom.cc
===================================================================
--- /trunk/source/g3tog4/src/G4BuildGeom.cc	(revision 817)
+++ /trunk/source/g3tog4/src/G4BuildGeom.cc	(revision 817)
@@ -0,0 +1,149 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G4BuildGeom.cc,v 1.17 2006/06/29 18:13:34 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+// modified by I. Hrivnacova, 13.10.99 
+
+#include <iomanip>
+#include <fstream>
+#include "globals.hh"
+#include "G3toG4.hh"
+#include "G3MatTable.hh"
+#include "G3MedTable.hh"
+#include "G3RotTable.hh"
+#include "G3VolTable.hh"
+#include "G3PartTable.hh"
+#include "G3DetTable.hh"
+#include "G3toG4BuildTree.hh"
+#include "G4GeometryManager.hh"
+#include "G4LogicalVolume.hh"
+#include "G4LogicalVolumeStore.hh"
+#include "G4PVPlacement.hh"
+#include "G4VisAttributes.hh"
+
+extern std::ofstream ofile;
+
+void G3CLRead(G4String &, char *);
+void checkVol(G4LogicalVolume*, G4int);
+void checkVol();
+
+
+G4LogicalVolume* G4BuildGeom(G4String& inFile){
+
+  G4int irot=0;
+  G4gsrotm(0, 90, 0, 90, 90, 0, 0);
+
+  G4cout << "Instantiated unit rotation matrix irot=" << irot << G4endl;
+ 
+  // Read the call List and interpret to Generate Geant4 geometry
+
+  G4cout << "Reading the call List file " << inFile << "..." << G4endl;
+
+  G3CLRead(inFile, 0);
+
+  G3Part.PrintAll();
+
+  G3Det.PrintAll();
+
+  G3Vol.PrintAll();
+
+  G4cout << "Call List file read completed. Build geometry" << G4endl;
+
+  // Build the geometry
+
+  G3VolTableEntry* topVTE = G3Vol.GetFirstVTE();
+  G4cout << "G3toG4 top level volume is " << topVTE->GetName() << G4endl;
+
+  // modified
+  G3toG4BuildTree(topVTE, 0);
+
+  // Retrieve the top-level G3toG4 logical mother volume pointer
+
+  G4LogicalVolume* topLV = topVTE->GetLV();
+
+  // position the top logical volume
+  // (in Geant3 the top volume is not positioned)
+  // 
+  new G4PVPlacement(0, G4ThreeVector(), topLV->GetName(), topLV, 0, false, 0);
+
+  // mark as invisible
+
+  topLV->SetVisAttributes(G4VisAttributes::Invisible);
+    
+  G4cout << "Top-level G3toG4 logical volume " << topLV->GetName() << " "
+         << *(topLV->GetVisAttributes()) << G4endl;
+        
+        // check the geometry here
+
+  #ifdef G3G4DEBUG
+    G4cout << "scan through G4LogicalVolumeStore:" << G4endl;
+    checkVol();
+  #endif
+
+  return topLV;
+}
+
+void checkVol()
+{
+  G4LogicalVolumeStore* theStore = G4LogicalVolumeStore::GetInstance();
+  G4LogicalVolume* ll = (*theStore)[0];
+  G4int level=0;
+  checkVol(ll, level);
+}
+
+void checkVol(G4LogicalVolume* _lvol, G4int level)
+{
+  G4LogicalVolume* _ldvol;
+  G4VPhysicalVolume* _pdvol;
+  level++;
+  
+  G4int ndau = _lvol -> GetNoDaughters();
+  
+  G4cout << "G44LogicalVolume " << _lvol->GetName() << " at level " << level
+	 << " contains " << ndau << " daughters." << G4endl;
+  for (G4int idau=0; idau<ndau; idau++){
+    _pdvol = _lvol-> GetDaughter(idau);
+    _ldvol = _pdvol -> GetLogicalVolume();
+    G4cout << "G4VPhysical volume " << std::setw(5) << _pdvol -> GetName() 
+	 << " (G4LogicalVolume " << std::setw(5) << _ldvol->GetName() << ")" 
+	 << G4endl;
+    checkVol(_ldvol, level);
+  }
+  return;
+}
+
+
+
+
+
+
+
+
+
+
+
Index: /trunk/source/g3tog4/src/G4ggclos.cc
===================================================================
--- /trunk/source/g3tog4/src/G4ggclos.cc	(revision 817)
+++ /trunk/source/g3tog4/src/G4ggclos.cc	(revision 817)
@@ -0,0 +1,40 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G4ggclos.cc,v 1.8 2006/06/29 18:13:37 gunter Exp $
+// GEANT4 tag $Name:  $
+
+#include "G3toG4.hh"
+#include "G3VolTable.hh"
+
+void PG4ggclos(){
+  G4ggclos();
+}
+
+void G4ggclos(){
+  G4cout << "G4ggclos: setting top-level VolTableEntry" << G4endl;
+  G3Vol.SetFirstVTE();
+}
Index: /trunk/source/g3tog4/src/G4gsatt.cc
===================================================================
--- /trunk/source/g3tog4/src/G4gsatt.cc	(revision 817)
+++ /trunk/source/g3tog4/src/G4gsatt.cc	(revision 817)
@@ -0,0 +1,52 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G4gsatt.cc,v 1.13 2006/06/29 18:13:39 gunter Exp $
+// GEANT4 tag $Name:  $
+
+#include "globals.hh"
+#include "G3toG4.hh"
+#include "G3VolTable.hh"
+
+void PG4gsatt(G4String tokens[])
+{
+    // fill the parameter containers
+    G3fillParams(tokens,PTgsatt);
+
+    // interpret the parameters
+    G4String name = Spar[0];
+    G4String attr = Spar[1];
+    G4int ival = Ipar[0];
+
+    G4gsatt(name, attr, ival);
+}
+
+void G4gsatt(G4String, G4String, G4int)
+{
+    // get logical volume pointer
+    // G4LogicalVolume *lvol = G3Vol.GetVTE(name)->GetLV();
+    G4cerr << "G4gsatt not implemented" << G4endl;
+}
Index: /trunk/source/g3tog4/src/G4gsbool.cc
===================================================================
--- /trunk/source/g3tog4/src/G4gsbool.cc	(revision 817)
+++ /trunk/source/g3tog4/src/G4gsbool.cc	(revision 817)
@@ -0,0 +1,56 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G4gsbool.cc,v 1.2 2006/06/29 18:13:41 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+// by I.Hrivnacova, 13.10.01
+
+#include "G3G4Interface.hh"
+#include "G3VolTable.hh"
+#include "globals.hh"
+
+void G4gsbool(G4String volName, G4String manyVolName)
+{
+  // find VTEs
+  G3VolTableEntry* vte = G3Vol.GetVTE(volName);
+  G3VolTableEntry* manyVTE = G3Vol.GetVTE(manyVolName);
+
+  if (vte == 0) {
+    G4Exception("G4gsbool: '" + volName + "' has no VolTableEntry");
+  } 
+  else if (manyVTE == 0) {
+    // warning
+    G4cerr << "G4gsbool: '" << manyVolName << "' has no VolTableEntry." 
+           << G4endl
+           << "          Specified overlap will be ignored."
+	   << G4endl;
+    return;	   
+  } 
+  else { 
+    manyVTE->AddOverlap(vte);
+  }   
+}
Index: /trunk/source/g3tog4/src/G4gsdet.cc
===================================================================
--- /trunk/source/g3tog4/src/G4gsdet.cc	(revision 817)
+++ /trunk/source/g3tog4/src/G4gsdet.cc	(revision 817)
@@ -0,0 +1,56 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G4gsdet.cc,v 1.5 2006/06/29 18:13:43 gunter Exp $
+// GEANT4 tag $Name:  $
+
+#include "globals.hh"
+#include "G3toG4.hh"
+
+void PG4gsdet(G4String tokens[])
+{
+    // fill the parameter containers
+    G3fillParams(tokens,PTgsdet);
+
+    // interpret the parameters
+    G4String chset = Spar[0];
+    G4String chdet = Spar[1];
+    G4int nv = Ipar[0];
+    G4String chnmsv[100];
+    for (G4int i=0; i<=nv; i++ ) chnmsv[i] = Spar[2+i].data();
+    G4int *nbits = &Ipar[1];
+    G4int idtyp = Ipar[1+nv];
+    G4int nwhi = Ipar[2+nv];
+    G4int nwdi = Ipar[3+nv];
+
+    G4gsdet(chset,chdet,nv,chnmsv,nbits,idtyp,nwhi,nwdi);
+}
+
+void G4gsdet(G4String chset, G4String chdet, G4int, G4String*,
+             G4int*, G4int idtyp, G4int nwhi, G4int nwdi)
+{ 
+    G4gsdetv(chset, chdet, idtyp, nwhi, nwdi);
+}
Index: /trunk/source/g3tog4/src/G4gsdeta.cc
===================================================================
--- /trunk/source/g3tog4/src/G4gsdeta.cc	(revision 817)
+++ /trunk/source/g3tog4/src/G4gsdeta.cc	(revision 817)
@@ -0,0 +1,61 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G4gsdeta.cc,v 1.6 2006/06/29 18:13:45 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+//
+// modified by I.Hrivnacova, 6 Oct 99
+
+#include "G3toG4.hh"
+#include "G3DetTable.hh"
+
+void G4gsdeta(G4String chset, G4String chdet, G4String,
+              G4int nwhi, G4int nwdi);
+
+void PG4gsdeta(G4String tokens[])
+{
+    // fill the parameter containers
+    G3fillParams(tokens,PTgsdeta);
+
+    // interpret the parameters
+    G4String chset = Spar[0];
+    G4String chdet = Spar[1];
+    G4String chali = Spar[2];
+    G4int nwhi = Ipar[0];
+    G4int nwdi = Ipar[1];
+
+    G4gsdeta(chset,chdet,chali,nwhi,nwdi);
+}
+
+void G4gsdeta(G4String chset, G4String chdet, G4String,
+              G4int nwhi, G4int nwdi)
+{
+    G4int idtyp = G3Det.GetID(chset, chdet);
+    // just associate another sensitive detector structure with
+    // the volume chdet
+    G4gsdetv(chset, chdet, idtyp, nwhi, nwdi);
+}
Index: /trunk/source/g3tog4/src/G4gsdetd.cc
===================================================================
--- /trunk/source/g3tog4/src/G4gsdetd.cc	(revision 817)
+++ /trunk/source/g3tog4/src/G4gsdetd.cc	(revision 817)
@@ -0,0 +1,59 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G4gsdetd.cc,v 1.8 2006/06/29 18:13:47 gunter Exp $
+// GEANT4 tag $Name:  $
+
+#include "G3toG4.hh"
+#include "G3DetTable.hh"
+
+class G4VSensitiveDetector;
+
+void PG4gsdetd(G4String tokens[])
+{
+    // fill the parameter containers
+    G3fillParams(tokens,PTgsdetd);
+
+    // interpret the parameters
+    G4String chset = Spar[0];
+    G4String chdet = Spar[1];
+    G4int nd = Ipar[0];
+    G4String chnmsd[100];
+    for (G4int i=0; i<=nd; i++ ) chnmsd[i] = Spar[2+i].data();
+    G4int *nbitsd = &Ipar[1];
+
+    G4gsdetd(chset,chdet,nd,chnmsd,nbitsd);
+}
+
+void G4gsdetd(G4String, G4String, G4int, G4String*, G4int*)
+{
+    // Get pointer to detector chset
+    // G4VSensitiveDetector* sdet = G3Det.GetSD(chset, chdet);
+    // Add hits to sensitive detector
+    // for (G4int i=0; i<nd; i++) {
+      // $$$        sdet->AddDigi(chnmsd[i],nbitsd[i]);
+    // }
+}
Index: /trunk/source/g3tog4/src/G4gsdeth.cc
===================================================================
--- /trunk/source/g3tog4/src/G4gsdeth.cc	(revision 817)
+++ /trunk/source/g3tog4/src/G4gsdeth.cc	(revision 817)
@@ -0,0 +1,62 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G4gsdeth.cc,v 1.8 2006/06/29 18:13:49 gunter Exp $
+// GEANT4 tag $Name:  $
+
+#include "G3toG4.hh"
+#include "G3DetTable.hh"
+
+class G4VSensitiveDetector;
+
+void PG4gsdeth(G4String tokens[])
+{
+    // fill the parameter containers
+    G3fillParams(tokens,PTgsdeth);
+
+    // interpret the parameters
+    G4String chset = Spar[0];
+    G4String chdet = Spar[1];
+    G4int nh = Ipar[0];
+    G4String chnamh[100];
+    for (G4int i=0; i<=nh; i++ ) chnamh[i] = Spar[2+i].data();
+    G4int *nbitsh = &Ipar[1];
+    G4double *orig = Rpar;
+    G4double *fact = &Rpar[nh];
+
+    G4gsdeth(chset,chdet,nh,chnamh,nbitsh,orig,fact);
+}
+
+void G4gsdeth(G4String, G4String, G4int, G4String*,
+              G4int*, G4double*, G4double*)
+{
+    // Get pointer to sensitive detector chset
+    // G4VSensitiveDetector* sdet = G3Det.GetSD(chset, chdet);
+    // Add hits to sensitive detector
+    // for (G4int i=0; i<nh; i++) {
+      // $$$        sdet->AddHit(chnamh[i],nbitsh[i],orig[i],fact[i]);
+    // }
+}
Index: /trunk/source/g3tog4/src/G4gsdetu.cc
===================================================================
--- /trunk/source/g3tog4/src/G4gsdetu.cc	(revision 817)
+++ /trunk/source/g3tog4/src/G4gsdetu.cc	(revision 817)
@@ -0,0 +1,49 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G4gsdetu.cc,v 1.6 2006/06/29 18:13:51 gunter Exp $
+// GEANT4 tag $Name:  $
+
+#include "G3toG4.hh"
+
+void PG4gsdetu(G4String tokens[])
+{
+    // fill the parameter containers
+    G3fillParams(tokens,PTgsdetu);
+
+    // interpret the parameters
+    G4String chset = Spar[0].data();
+    G4String chdet = Spar[1].data();
+    G4int nupar = Ipar[0];
+    G4double *upar = Rpar;
+
+    G4gsdetu(chset,chdet,nupar,upar);
+}
+
+void G4gsdetu(G4String, G4String, G4int, G4double*)
+{
+    // $$$ nothing right now
+}
Index: /trunk/source/g3tog4/src/G4gsdetv.cc
===================================================================
--- /trunk/source/g3tog4/src/G4gsdetv.cc	(revision 817)
+++ /trunk/source/g3tog4/src/G4gsdetv.cc	(revision 817)
@@ -0,0 +1,72 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G4gsdetv.cc,v 1.10 2006/06/29 18:13:53 gunter Exp $
+// GEANT4 tag $Name:  $
+
+#include "G4ios.hh"
+#include "G3toG4.hh"
+#include "G3DetTable.hh"
+#include "G3VolTable.hh"
+
+class G4VSensitiveDetector;
+
+void PG4gsdetv(G4String tokens[])
+{
+    // fill the parameter containers
+    G3fillParams(tokens,PTgsdetv);
+
+    // interpret the parameters
+    G4String chset = Spar[0];
+    G4String chdet = Spar[1];
+    G4int idtyp = Ipar[0];
+    G4int nwhi = Ipar[1];
+    G4int nwdi = Ipar[2];
+
+    G4gsdetv(chset,chdet,idtyp,nwhi,nwdi);
+}
+
+void G4gsdetv(G4String, G4String, G4int, G4int,G4int)
+{  
+  G4cout << "G4gsdetv not currently implemented." << G4endl;
+  /*
+    // get lvol for detector chdet
+    G4LogicalVolume *lvol = G3Vol.GetLV(chdet);
+    if (lvol == 0) {
+    G4cout << "G4gsdetv: Logical volume " << chdet << " not available. Skip." << G4endl;
+    return;
+    }
+    // Generate a sensitive detector structure
+    // G4VSensitiveDetector *sdet;
+    // $$$    G4VSensitiveDetector *sdet = new G4VSensitiveDetector(chset);
+    // inform the logical volume of its sensitive detector
+    // lvol->SetSensitiveDetector(sdet);
+    // $$$ sdet->SetID(idtyp);
+    // Add the sensitive detector to the table
+    // G3Det.put(chset,idtyp,sdet);
+    */
+}
+
Index: /trunk/source/g3tog4/src/G4gsdk.cc
===================================================================
--- /trunk/source/g3tog4/src/G4gsdk.cc	(revision 817)
+++ /trunk/source/g3tog4/src/G4gsdk.cc	(revision 817)
@@ -0,0 +1,62 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G4gsdk.cc,v 1.7 2006/06/29 18:13:55 gunter Exp $
+// GEANT4 tag $Name:  $
+
+#include "G4Decay.hh"
+#include "G3toG4.hh"
+#include "G3PartTable.hh"
+
+void PG4gsdk(G4String tokens[])
+{
+    // fill the parameter containers
+    G3fillParams(tokens,PTgsdk);
+
+    // interpret the parameters
+    G4int ipart = Ipar[0];
+    G4int *mode = &Ipar[3];
+    G4double *bratio = Rpar;
+
+    G4gsdk(ipart,bratio,mode);
+}
+
+void G4gsdk(G4int, G4double*, G4int*)
+{
+/*
+    // create decay object for the particle
+    G4Decay *decay = new G4Decay();
+    // add decay modes
+    for (G4int i=0; i<6; i++) {
+        if (mode[i] != 0) {
+// $$$            decay->AddMode(mode[i],bratio[i]);
+        }
+    }
+    // associate decay object with particle ipart
+    G4ParticleDefinition *part = G3Part.Get(ipart);
+// $$$    part->SetDecay(decay);
+*/
+}
Index: /trunk/source/g3tog4/src/G4gsdvn.cc
===================================================================
--- /trunk/source/g3tog4/src/G4gsdvn.cc	(revision 817)
+++ /trunk/source/g3tog4/src/G4gsdvn.cc	(revision 817)
@@ -0,0 +1,118 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G4gsdvn.cc,v 1.10 2006/06/29 18:13:57 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+// by I.Hrivnacova, V.Berejnoi, 29 Oct 99
+
+#include "G3G4Interface.hh"
+#include "G3Division.hh"
+#include "G3VolTableEntry.hh"
+#include "G3VolTable.hh"
+#include "globals.hh"
+#include "G3toG4.hh"
+
+void PG4gsdvn(G4String tokens[])
+{
+  // fill the parameter containers
+  G3fillParams(tokens,PTgsdvn);
+  
+  // interpret the parameters
+  G4String vname = Spar[0];
+  G4String vmoth = Spar[1];
+  G4int ndiv = Ipar[0];
+  G4int iaxis = Ipar[1];
+  
+  G4gsdvn(vname, vmoth, ndiv, iaxis);
+}
+
+void G4CreateCloneVTEWithDivision(G4String vname, G3VolTableEntry* mvte,
+        G3DivType divType, G4int nofDivisions, G4int iaxis, G4int, 
+	G4double c0, G4double step)
+{	
+  G3VolTableEntry* vte=0;
+
+  // loop over all mothers
+  for (G4int i=0; i<mvte->GetNoClones(); i++) {
+    G3VolTableEntry* mvteClone =  mvte->GetClone(i);
+    G4String shape = mvteClone->GetShape();
+    G4int    nmed  = mvteClone->GetNmed();
+    G4String mvteName = mvteClone->GetName();
+    
+    G4String newName = vname;
+    if (i>0) {
+      char index[5]; sprintf(index, "%d", i);
+      newName.append(gSeparator); newName = newName + index;
+    }	
+
+    // create new VTE with 0 solid
+    // and let vol table know about it
+    G3VolTableEntry* vteClone
+      = new G3VolTableEntry(newName, shape, 0, 0, nmed, 0, true);
+    G3Vol.PutVTE(vteClone);
+
+    // set mother <-> daughter
+    // (mother/daughter are reset in case an envelope
+    //  needs to be created in G3Division::UpdateVTE)
+    mvteClone->AddDaughter(vteClone);
+    vteClone->AddMother(mvteClone);
+
+    // create new G3Division 
+    G3Division* division
+      = new G3Division(divType, vteClone, mvteClone,
+                       nofDivisions, iaxis, nmed, c0, step);
+
+    // set division to vte and update it
+    vteClone->SetDivision(division);
+    division->UpdateVTE();
+      
+    if (i == 0) {
+      // keep the first clone copy
+      vte = vteClone;
+    }
+    else {		
+      // let vte know about this clone copy
+      vte->AddClone(vteClone);     
+    }
+  }
+}    
+
+void G4gsdvn(G4String vname, G4String vmoth, G4int ndiv, G4int iaxis)
+{
+  // find mother VTE
+  G3VolTableEntry* mvte = G3Vol.GetVTE(vmoth);
+ 
+  if (mvte == 0) {
+    G4Exception("G4gsdvn:'" + vmoth + "' has no VolTableEntry");
+  }  
+  else {
+    // a new vte clone copy with division is created
+    // for each mother (clone copy)
+    
+    G4CreateCloneVTEWithDivision(vname, mvte, kDvn, ndiv, iaxis, 0, 0., 0.); 
+  }  
+}
Index: /trunk/source/g3tog4/src/G4gsdvn2.cc
===================================================================
--- /trunk/source/g3tog4/src/G4gsdvn2.cc	(revision 817)
+++ /trunk/source/g3tog4/src/G4gsdvn2.cc	(revision 817)
@@ -0,0 +1,72 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G4gsdvn2.cc,v 1.8 2006/06/29 18:14:00 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+// by I.Hrivnacova, V.Berejnoi, 29 Oct 99
+
+#include "G3Division.hh"
+#include "G3VolTableEntry.hh"
+#include "G3VolTable.hh"
+#include "globals.hh"
+#include "G3toG4.hh"
+
+void G4CreateCloneVTEWithDivision(G4String vname, G3VolTableEntry* mvte,
+               G3DivType divType, G4int nofDivisions, G4int iaxis, G4int nmed, 
+     	       G4double c0, G4double step);
+
+void PG4gsdvn2(G4String tokens[]) {
+  // fill the parameter containers
+  G3fillParams(tokens, PTgsdvn2);
+  
+  // interpret the parameters
+  G4String vname = Spar[0];
+  G4String vmoth = Spar[1];
+  G4int ndiv = Ipar[0];
+  G4int iaxis = Ipar[1];
+  G4int numed = Ipar[2];
+  G4double c0 = Rpar[0];
+  
+  G4gsdvn2(vname, vmoth, ndiv, iaxis, c0, numed);
+}
+
+void G4gsdvn2(G4String vname, G4String vmoth, G4int ndiv, G4int iaxis,
+               G4double c0, G4int numed)
+{
+  // find mother VTE
+  G3VolTableEntry* mvte = G3Vol.GetVTE(vmoth);
+  if (mvte == 0) {
+    G4Exception("G4gsdvn2:'" + vmoth + "' has no VolTableEntry");
+  }    
+  else {
+    // a new vte clone copy with division is created
+    // for each mother (clone copy)
+    
+    G4CreateCloneVTEWithDivision(vname, mvte, 
+                                  kDvn2, ndiv, iaxis, numed, c0, 0.); 
+  }  
+}
Index: /trunk/source/g3tog4/src/G4gsdvt.cc
===================================================================
--- /trunk/source/g3tog4/src/G4gsdvt.cc	(revision 817)
+++ /trunk/source/g3tog4/src/G4gsdvt.cc	(revision 817)
@@ -0,0 +1,73 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G4gsdvt.cc,v 1.7 2006/06/29 18:14:03 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+// by I.Hrivnacova, V.Berejnoi, 29 Oct 99
+
+#include "G3Division.hh"
+#include "G3VolTableEntry.hh"
+#include "G3VolTable.hh"
+#include "globals.hh"
+#include "G3toG4.hh"
+
+void G4CreateCloneVTEWithDivision(G4String vname, G3VolTableEntry* mvte,
+               G3DivType divType, G4int nofDivisions, G4int iaxis, G4int nmed, 
+     	       G4double c0, G4double step);
+
+void PG4gsdvt(G4String tokens[])
+{
+  // fill the parameter containers
+  G3fillParams(tokens,PTgsdvt);
+  
+  // interpret the parameters
+  G4String vname = Spar[0];
+  G4String vmoth = Spar[1];
+  G4int iaxis = Ipar[0];
+  G4int numed = Ipar[1];
+  G4int ndvmx = Ipar[2];
+  G4double Step = Rpar[0];
+  
+  G4gsdvt(vname,vmoth,Step,iaxis,numed,ndvmx);
+}
+
+void G4gsdvt(G4String vname, G4String vmoth, G4double step, G4int iaxis,
+             G4int numed, G4int ndvmx)
+{
+  // find mother VTE
+  G3VolTableEntry* mvte = G3Vol.GetVTE(vmoth);
+  if (mvte == 0) {
+    G4Exception("G4gsdvt:'" + vmoth + "' has no VolTableEntry");
+  }    
+  else {
+    // a new vte clone copy with division is created
+    // for each mother (clone copy)
+    
+    G4CreateCloneVTEWithDivision(vname, mvte, 
+                                  kDvt, ndvmx, iaxis, numed, 0., step); 
+  }  
+}
Index: /trunk/source/g3tog4/src/G4gsdvt2.cc
===================================================================
--- /trunk/source/g3tog4/src/G4gsdvt2.cc	(revision 817)
+++ /trunk/source/g3tog4/src/G4gsdvt2.cc	(revision 817)
@@ -0,0 +1,74 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G4gsdvt2.cc,v 1.7 2006/06/29 18:14:05 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+// by I.Hrivnacova, V.Berejnoi, 29 Oct 99
+
+#include "G3Division.hh"
+#include "G3VolTableEntry.hh"
+#include "G3VolTable.hh"
+#include "globals.hh"
+#include "G3toG4.hh"
+
+void G4CreateCloneVTEWithDivision(G4String vname, G3VolTableEntry* mvte,
+               G3DivType divType, G4int nofDivisions, G4int iaxis, G4int nmed, 
+     	       G4double c0, G4double step);
+
+void PG4gsdvt2(G4String tokens[])
+{
+  // fill the parameter containers
+  G3fillParams(tokens,PTgsdvt2);
+  
+  // interpret the parameters
+  G4String vname = Spar[0];
+  G4String vmoth = Spar[1];
+  G4int iaxis = Ipar[0];
+  G4int numed = Ipar[1];
+  G4int ndvmx = Ipar[2];
+  G4double Step = Rpar[0];
+  G4double c0 = Rpar[1];
+  
+  G4gsdvt2(vname,vmoth,Step,iaxis,c0,numed,ndvmx);
+}
+
+void G4gsdvt2(G4String vname, G4String vmoth, G4double step, G4int iaxis,
+               G4double c0, G4int numed, G4int ndvmx)
+{
+  // find mother VTE
+  G3VolTableEntry* mvte = G3Vol.GetVTE(vmoth);
+  if (mvte == 0) {
+    G4Exception("G4gsdtn2:'" + vmoth + "' has no VolTableEntry");
+  }    
+  else {
+    // a new vte clone copy with division is created
+    // for each mother (clone copy)
+    
+    G4CreateCloneVTEWithDivision(vname, mvte, 
+                                  kDvt2, ndvmx, iaxis, numed, c0, step); 
+  }  
+}
Index: /trunk/source/g3tog4/src/G4gsdvx.cc
===================================================================
--- /trunk/source/g3tog4/src/G4gsdvx.cc	(revision 817)
+++ /trunk/source/g3tog4/src/G4gsdvx.cc	(revision 817)
@@ -0,0 +1,68 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G4gsdvx.cc,v 1.5 2006/06/29 18:14:08 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+// by I.Hrivnacova, V.Berejnoi, 27 Sep 99
+
+#include "globals.hh"
+#include "G3toG4.hh"
+
+void G4gsdvn2(G4String name, G4String moth, G4int ndiv, G4int iaxis,
+              G4double c0, G4int numed);
+
+void G4gsdvt2(G4String name, G4String moth, G4double Step, G4int iaxis,
+              G4double c0, G4int numed, G4int ndvmx);
+
+void PG4gsdvx(G4String tokens[])
+{
+    // fill the parameter containers
+    G3fillParams(tokens,PTgsdvx);
+
+    // interpret the parameters
+    G4String name = Spar[0];
+    G4String moth = Spar[1];
+    G4int ndiv = Ipar[0];
+    G4int iaxis = Ipar[1];
+    G4int numed = Ipar[2];
+    G4int ndvmx = Ipar[3];
+    G4double Step = Rpar[0];
+    G4double c0 = Rpar[1];
+
+    G4gsdvx(name,moth,ndiv,iaxis,Step,c0,numed,ndvmx);
+}
+
+void G4gsdvx(G4String name, G4String moth, G4int ndiv, G4int iaxis,
+             G4double Step, G4double c0, G4int numed, G4int ndvmx)
+{
+    // pass to gsdvn2 or gsdvt2
+    if (Step > 0.) {
+        G4gsdvt2(name,moth,Step,iaxis,c0,numed,ndvmx);
+    } else if (ndiv > 0) {
+        G4gsdvn2(name,moth,ndiv,iaxis,c0,numed);
+    }
+}
Index: /trunk/source/g3tog4/src/G4gsmate.cc
===================================================================
--- /trunk/source/g3tog4/src/G4gsmate.cc	(revision 817)
+++ /trunk/source/g3tog4/src/G4gsmate.cc	(revision 817)
@@ -0,0 +1,155 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G4gsmate.cc,v 1.12 2006/06/29 18:14:10 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+// by I.Hrivnacova, 27 Sep 99
+
+#include <cmath>
+
+#include "G3toG4.hh"
+#include "G3MatTable.hh"
+#include "G3EleTable.hh"
+#include "G4Material.hh"
+#include "G4Isotope.hh"
+#include "G4UnitsTable.hh"
+
+void PG4gsmate(G4String tokens[])
+{
+  // fill the parameter containers
+  G3fillParams(tokens,PTgsmate);
+  G4String name = Spar[0];
+  G4int imate = Ipar[0];
+  G4int nwbf = Ipar[1];
+  G4double a = Rpar[0];
+  G4double z = Rpar[1];
+  G4double dens = Rpar[2];
+  G4double radl = Rpar[3];
+  // G4double absl = Rpar[4];
+  G4double *ubuf = &Rpar[5];
+
+  G4gsmate(imate, name, a, z, dens, radl, nwbf, ubuf);
+}
+
+/*
+// replaced with G3EleTable 
+// only used G4Elements are created;
+// !! no checking of given A of the element;
+//
+
+G4Element* CreateElement(G4double zeff, G4double aeff, G4String matName)
+{
+  // tolerance in Z, A for element definition
+  const G4double tolerance = 0.001;
+
+  // define the symbol Z%A% of element
+  // !! symbol is not unambiguous element identifier
+  char symbol[20];
+  sprintf(symbol,"Z%dA%d",int(zeff),int(aeff/(g/mole)));
+  G4String elSymbol = symbol;
+ 
+  // search element table for the element with given (Z,A)
+  // 
+  G4int index = 0;
+  const G4ElementTable* table = G4Element::GetElementTable();
+  for (G4int i=0; i<table->entries(); i++) {
+     G4Element* entry = (*table)[i];
+     if (elSymbol == entry->GetSymbol()) index++; 
+     if ( std::abs(zeff - entry->GetZ()) < tolerance &&
+         (std::abs(aeff - entry->GetA())/(g/mole)) < tolerance ){
+       return entry;
+     }
+  }  
+
+  // define a unique name En-Z%A% 
+  // (n - index of elements with the same int(Z), int(A))
+  char chIndex[4];
+  sprintf(chIndex,"%d",index);
+  G4String elName = "E";  
+  elName = elName + chIndex + "-";
+  elName = elName + elSymbol;  
+
+  // create new element if it was not found in element table
+  G4Element* element = new G4Element(elName, elSymbol, zeff, aeff);	
+  G4cout << "New element: " << element->GetName()
+         << " for " << matName << " material has been created." << G4endl;
+  return element;	
+}
+*/
+
+void G4gsmate(G4int imate, G4String name, G4double ain, G4double zin,
+              G4double densin, G4double, G4int, G4double*)
+{
+  G4double G3_minimum_density = 1.e-10*g/cm3;
+
+  // add units
+  G4double z = zin;    
+  G4double a = ain*g/mole;
+  G4double dens = densin*g/cm3;
+
+  G4Material* material=0;
+  
+  G4String sname = name.strip(G4String::both);
+  if (sname == "AIR") {
+    // handle the built in AIR mixture
+    G4double a[2], z[2], wmat[2];
+    a[0] = 14.01*g/mole;
+    a[1] = 16.00*g/mole;
+    z[0] = 7;
+    z[1] = 8;
+    wmat[0] = 0.7;
+    wmat[1] = 0.3;
+    // G4double theDensity = 1.2931*mg/cm3;
+    G4double theDensity = 0.0012931;
+    int n=2;
+    G4gsmixt(imate, sname, a, z, theDensity, n, wmat);
+  } 
+  else if ( z<1 || dens < G3_minimum_density ) {
+    // define vacuum according to definition from N03 example
+    G4double density     = universe_mean_density;    //from PhysicalConstants.h
+    G4double pressure    = 3.e-18*pascal;
+    G4double temperature = 2.73*kelvin;
+    material = new G4Material(name, z=1., a=1.01*g/mole, density,
+                    kStateGas,temperature,pressure);
+  }
+  else {
+    //G4Element* element = CreateElement(z, a, name);
+    G4Element* element = G3Ele.GetEle(z);
+    material = new G4Material(name, dens, 1);
+    material->AddElement(element, 1.);    
+  }  
+
+  // add the material to the List
+  G3Mat.put(imate, material);
+}
+
+
+
+
+
+
+
Index: /trunk/source/g3tog4/src/G4gsmixt.cc
===================================================================
--- /trunk/source/g3tog4/src/G4gsmixt.cc	(revision 817)
+++ /trunk/source/g3tog4/src/G4gsmixt.cc	(revision 817)
@@ -0,0 +1,162 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G4gsmixt.cc,v 1.13 2006/06/29 18:14:37 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+// by I.Hrivnacova, 27 Sep 99
+
+#include "globals.hh"
+#include <iomanip>
+#include <iomanip>
+
+#include "G3toG4.hh"
+#include "G3EleTable.hh"
+#include "G3MatTable.hh"
+#include "G4Material.hh"
+#include "G4Isotope.hh"
+
+void PG4gsmixt(G4String tokens[])
+{
+    // fill the parameter containers
+    G3fillParams(tokens,PTgsmixt);
+
+    // interpret the parameters
+    G4String name = Spar[0].data();
+    G4int imate = Ipar[0];
+    G4int nlmat = Ipar[1];
+    //G4double dens = Rpar[0]*g/cm3;
+    G4double dens = Rpar[0];
+    G4double *a = Rpar + 1;
+    G4double *z = Rpar + 1+std::abs(nlmat);
+    G4double *wmat = Rpar + 1 + 2*std::abs(nlmat);
+
+    for (int i=0; i<std::abs(nlmat); i++){
+      //Rpar[i]=Rpar[i]*g/mole;
+      Rpar[i]=Rpar[i];
+    };
+    G4gsmixt(imate,name,a,z,dens,nlmat,wmat);
+}
+
+// replaced with G3EleTable 
+// only used G4Elements are created;
+// !! no checking of given A of the element;
+//
+// extern G4Element* CreateElement(G4double zeff, G4double aeff, G4String matName);
+
+
+void G4gsmixt(G4int imate, G4String name, G4double* a, G4double* z,
+              G4double dens, G4int nlmat, G4double* wmat)
+{
+  // in Geant3:
+  // After a call with ratios by number (negative number of elements), 
+  // the ratio array is changed to the ratio by weight, so all successive 
+  // calls with the same array must specify the number of elements as 
+  // positive 
+  G4int i=0;
+  if (nlmat<0) {
+    // in case of proportions given in atom counts (nlmat<0),
+    // the wmat[i] are converted to weight fractions
+    G4double aMol = 0.;
+    for (i=0; i<std::abs(nlmat); i++) { 
+      // total molecular weight 
+      aMol += wmat[i]*a[i]; 
+    }  
+    if (aMol == 0.)
+      G4Exception("\nG4mixt: Total molecular weight in " +
+        name + " = 0.");       
+    for (i=0; i<std::abs(nlmat); i++) {
+      // weight fractions
+      wmat[i] = wmat[i]*a[i]/aMol;
+    }
+  }
+
+  // create material with given number of components
+  // (elements)
+
+  G4Material* material 
+    = new G4Material(name, dens*g/cm3, std::abs(nlmat));
+  for (i=0; i<std::abs(nlmat); i++) {
+    // add units
+    // G4Element* element = G4Element(z[i], a[i]*g/mole, name);
+    G4Element* element = G3Ele.GetEle(z[i]);
+    material->AddElement(element, wmat[i]);    
+  }
+
+  // add the material to the List
+  G3Mat.put(imate, material);
+}
+
+/*
+void G4gsmixt(G4int imate, G4String name, G4double a[], G4double z[],
+              G4double dens, G4int nlmat, G4double wmat[]){
+  G4int nmate = std::abs(nlmat);
+  G4String sname = name.strip(G4String::both);
+  G4double theDensity = dens*g/cm3;
+
+  G4Material* theMixture = new G4Material(name, dens, nmate); 
+  G4bool ok=true;
+  for (int i=0; i< nmate; i++){
+    G4Element* theElement = G3Ele.GetEle(z[i]);
+    if (nlmat>0) {
+      G4double fractionmass = wmat[i];
+      ok = ok && std::abs(fractionmass)<=1.;
+      theMixture->AddElement(theElement, fractionmass);
+    } else if (nlmat<0) {
+      G4int natoms = wmat[i];
+      ok = ok && wmat[i] == natoms;
+      theMixture->AddElement(theElement, natoms);
+    } else {
+      ok=false;
+    }
+  }
+  if (ok) {
+    G3Mat.put(imate, theMixture);
+  } else {
+    if (nlmat>0) {
+      G4cerr << "G4gsmixt: for mixture '" << name 
+	     << "' some |weights|>1 : " << G4endl;
+      for (G4int i=0;i<nlmat; i++) {
+	G4cerr << "Component " << std::setw(3) << i+1 << " fraction: "
+	       << std::setw(10) << wmat[i] << G4endl;
+      }
+    } else if (nlmat<0) {
+      G4cerr << "G4gsmixt: for mixture '" << name 
+	     << "' some #natoms are non-integer: " << G4endl;
+      for (G4int i=0;i<nlmat; i++) {
+	G4cerr << "Component " << std::setw(3) << i+1 << " #atoms "
+	       << std::setw(10) << wmat[i] << G4endl;
+      }
+    } else {
+      G4cerr << "G4gsmixt: Number of components for mixture '" 
+	     << name << "' (" << nlmat << ") not allowed." << G4endl;
+    }
+  }
+}
+*/
+
+
+
Index: /trunk/source/g3tog4/src/G4gspart.cc
===================================================================
--- /trunk/source/g3tog4/src/G4gspart.cc	(revision 817)
+++ /trunk/source/g3tog4/src/G4gspart.cc	(revision 817)
@@ -0,0 +1,111 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G4gspart.cc,v 1.7 2006/06/29 18:14:40 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+#include "G4ProcessManager.hh"
+#include "G3toG4.hh"
+#include "G3PartTable.hh"
+
+void PG4gspart(G4String tokens[])
+{
+    // fill the parameter containers
+    G3fillParams(tokens,PTgspart);
+
+    // interpret the parameters
+    G4String chnpar = Spar[0];
+    G4int ipart = Ipar[0];
+    G4int itrtyp = Ipar[1];
+    G4int nwb = Ipar[2];
+    G4double amass = Rpar[0];
+    G4double charge = Rpar[1];
+    G4double tlife = Rpar[2];
+    G4double *ubuf = &Rpar[3];
+
+    G4gspart(ipart,chnpar,itrtyp,amass,charge,tlife,ubuf,nwb);
+}
+
+void G4gspart(G4int, G4String, G4int, G4double,
+              G4double, G4double, G4double*, G4int)
+{
+}
+
+#ifdef OMIT_CODE
+void G4gspart(G4int ipart, G4String chnpar, G4int itrtyp, G4double amass,
+              G4double charge, G4double tlife, G4double*, G4int)
+{
+    // Handle conversion of itrtyp into an appropriate ProcessManager
+    G4ProcessManager *mgr = 0;
+    switch (itrtyp) {
+    case 1:
+        // gamma
+// $$$        mgr = gammaProcessManager;
+        break;
+    case 2:
+        // electron
+// $$$        mgr = electronProcessManager;
+        break;
+    case 3:
+        // neutron
+// $$$        mgr = neutronProcessManager;
+        break;
+    case 4:
+        // hadron
+// $$$        mgr = hadronProcessManager;
+        break;
+    case 5:
+        // muon
+// $$$        mgr = muonProcessManager;
+        break;
+    case 6:
+        // geantino
+// $$$        mgr = geantinoProcessManager;
+        break;
+    case 7:
+        // heavy ion
+// $$$        mgr = heavyIonProcessManager;
+        break;
+    case 8:
+        // light ion
+// $$$        mgr = lightIonProcessManager;
+        break;
+    default:
+// $$$        mgr = theProcessManager;
+        break;
+    }
+
+    // Create the particle; provide parameters and a process mgr.
+    G4ParticleDefinition *part = new G4ParticleDefinition(chnpar);
+    part->SetProcessManager(mgr);
+    part->SetPDGMass(amass);
+    part->SetPDGCharge(charge);
+    part->SetPDGLifeTime(tlife);
+
+    // add to particle table
+    G3Part.put(&ipart, part);
+}
+#endif
Index: /trunk/source/g3tog4/src/G4gspos.cc
===================================================================
--- /trunk/source/g3tog4/src/G4gspos.cc	(revision 817)
+++ /trunk/source/g3tog4/src/G4gspos.cc	(revision 817)
@@ -0,0 +1,105 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G4gspos.cc,v 1.13 2006/06/29 18:14:42 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+// by I.Hrivnacova, 13.10.99
+
+#include "G3G4Interface.hh"
+#include "G3VolTable.hh"
+#include "G3toG4.hh"
+#include "G3Pos.hh"
+#include "globals.hh"
+
+void G4CreateCloneVTE(G3VolTableEntry* vte, G3VolTableEntry* mvte,
+              G4double pars[], G4int npar, G4int num,
+              G4double x, G4double y, G4double z, G4int irot, G4String vonly);
+
+void PG4gspos(G4String tokens[])
+{
+        // fill the parameter containers
+    G3fillParams(tokens,PTgspos);
+  
+        // interpret the parameters
+    G4String name = Spar[0];
+    G4String moth = Spar[1];
+    G4String only = Spar[2];
+    G4int num = Ipar[0];
+    G4int irot = Ipar[1];
+        // all parameters are passed to G4gsxxx methods
+        // in G3 default units         
+    //G4double x = Rpar[0]*cm;
+    //G4double y = Rpar[1]*cm;
+    //G4double z = Rpar[2]*cm;
+    G4double x = Rpar[0];
+    G4double y = Rpar[1];
+    G4double z = Rpar[2];
+  
+    G4gspos(name, num, moth, x, y, z, irot, only);
+}
+
+void G4gspos(G4String vname, G4int num, G4String vmoth, G4double x,
+             G4double y, G4double z, G4int irot, G4String vonly)
+{
+  // find VTEs
+  G3VolTableEntry* vte = G3Vol.GetVTE(vname);
+  G3VolTableEntry* mvte = G3Vol.GetVTE(vmoth);
+
+  if (vte == 0) {
+    G4Exception("G4gspos: '" + vname + "' has no VolTableEntry");
+  } 
+  else if (mvte == 0) {
+    G4Exception("G4gspos: '" + vmoth + "' has no VolTableEntry");
+  } 
+  else { 
+    if (!vte->HasNegPars()) {
+      // position vector
+      G4ThreeVector* offset = new G4ThreeVector(x*cm, y*cm, z*cm);
+
+      // create a G3Pos object and add it to the vte
+      G3Pos* aG3Pos = new G3Pos(vmoth, num, offset, irot, vonly);              
+      vte->AddG3Pos(aG3Pos);
+
+      // loop over all mothers
+      for (G4int i=0; i<mvte->GetNoClones(); i++) {
+                       // (mvte is retrieved from its "master" name
+                       //  -> there is no need to call GetMasterClone()
+        G3VolTableEntry* mvteClone = mvte->GetClone(i);
+        vte->AddMother(mvteClone);
+        mvteClone->AddDaughter(vte);
+      }     
+    } 
+    else {
+      // if vte has neg parameters 
+      // a new vte clone copy is created for each mother (clone copy)  
+      // and its parameters are derived from it if possible
+
+      G4CreateCloneVTE(vte, mvte, vte->GetRpar(), vte->GetNpar(), num,
+                     x, y, z, irot, vonly);
+    }    
+  }      
+}
Index: /trunk/source/g3tog4/src/G4gsposp.cc
===================================================================
--- /trunk/source/g3tog4/src/G4gsposp.cc	(revision 817)
+++ /trunk/source/g3tog4/src/G4gsposp.cc	(revision 817)
@@ -0,0 +1,316 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G4gsposp.cc,v 1.16 2006/06/29 18:14:44 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+// by I.Hrivnacova, 13.10.99
+
+#include "G3G4Interface.hh"
+#include "G3toG4.hh"
+#include "G3VolTable.hh"
+#include "G3toG4MakeSolid.hh"
+#include "G3Division.hh"
+#include "G4VSolid.hh"
+
+G4bool G3NegVolPars(G4double pars[], G4int *nparpt, 
+          G3VolTableEntry* vte, G3VolTableEntry* mvte, const char routine[]);		       
+
+void PG4gsposp(G4String tokens[]){
+  // fill the parameter containers
+  G3fillParams(tokens,PTgsposp);
+  
+  // interpret the parameters
+  G4String name = Spar[0];
+  G4String moth = Spar[1];
+  G4String only = Spar[2];
+  G4int num = Ipar[0];
+  G4int irot = Ipar[1];
+  G4int npar = Ipar[2];
+  // all parameters are passed to G4gsxxx methods
+  // in G3 default units         
+  //G4double x = Rpar[0]*cm;
+  //G4double y = Rpar[1]*cm;
+  //G4double z = Rpar[2]*cm;
+  G4double x = Rpar[0];
+  G4double y = Rpar[1];
+  G4double z = Rpar[2];
+  G4double *pars = &Rpar[3];
+  
+  G4gsposp(name, num, moth, x, y, z, irot, only, pars, npar);
+}
+
+void G4ProcessDaughters(G3VolTableEntry* vte)
+// restore negative volume parameters and create solid for all
+// vte daughters
+{
+  if (vte->HasNegPars()) {
+    G4cerr << " Warning:" << G4endl;
+    G4cerr << " G4ProcessDaughters: Ignored (vte has negative parameters)." 
+           << G4endl;
+  }  
+  else {  
+    for (G4int i=0; i<vte->GetNoDaughters(); i++) {
+   
+      G3VolTableEntry* dvte = vte->GetDaughter(i);
+
+      if (dvte->HasNegPars()) {
+        if (dvte->GetDivision()) {
+           // call division method for creating solid and updating
+           // dvte parameters
+           dvte->GetDivision()->UpdateVTE();
+        }
+        else {
+          // update negative parameters
+          G4double* pars = dvte->GetRpar();
+          G4int     npar = dvte->GetNpar();
+          G4bool negpars 
+	    = G3NegVolPars(pars,&npar, dvte, vte, "GSPOS");
+
+          if (negpars) {
+            G4String text = "    G4ProcessDaughter:\n"; 
+  	    text = text + "    G3NegVolPars still returns negative parameters!";
+            G4Exception(text);
+  	  }  
+
+          // create solid
+          G4bool hasNegPars;
+          G4bool deferred;   
+          G4bool okAxis[3];
+          G4VSolid* solid
+            = G3toG4MakeSolid(dvte->GetName(), dvte->GetShape(), pars, npar, 
+	                      hasNegPars, deferred, okAxis);  
+          if (hasNegPars) {
+            G4String text = "    G4ProcessDaughter:\n"; 
+  	    text = text + "    G3toG4MakeSolid still returns negative parameters!";
+            G4Exception(text);
+	  }  
+
+          // update dvte			  
+          dvte->SetNRpar(npar, pars);
+          dvte->SetSolid(solid);
+          dvte->SetHasNegPars(hasNegPars);
+        }
+
+        // process daughters
+	G4ProcessDaughters(dvte);  
+      }		
+    }
+  }     
+}
+    
+void G4CloneDaughters(G3VolTableEntry* vte, G3VolTableEntry* vteClone)
+// copy vte daughters to vteClone
+// (in case of daughters with negative parameters
+// or with divisions new clone copies have to be created)
+{
+  G4int nofDaughters = vte->GetNoDaughters();
+  if (nofDaughters>0)
+    for (G4int id=0; id<nofDaughters; id++) {	  
+      G3VolTableEntry* dvte = vte->GetDaughter(id);
+
+      if (dvte->HasNegPars() || dvte->GetDivision()){
+        // create new dvteClone with Position/Division
+	// and set it to vteClone       
+
+        // get master of dvte
+        G3VolTableEntry* dvteMaster = dvte->GetMasterClone();
+
+        // generate vteClone name
+        G4int cloneNo = dvteMaster->GetNoClones();
+        char index[5]; sprintf(index,"%d",cloneNo);
+        G4String newName = dvteMaster->GetName();
+        newName.append(gSeparator); newName = newName + index;
+        
+        // create dvteClone
+        G4String  dvteShape = dvte->GetShape();
+	G4double* dvteRpar  = dvte->GetRpar();
+	G4int     dvteNpar  = dvte->GetNpar();
+	G4int     dvteNmed  = dvte->GetNmed();
+	G4bool   hasNegPars = dvte->HasNegPars();
+        G3VolTableEntry* dvteClone
+          = new G3VolTableEntry(newName, dvteShape, dvteRpar, dvteNpar,
+	                         dvteNmed, 0, hasNegPars);
+				 
+        // let dvte master and vol table know about it
+        G3Vol.PutVTE(dvteClone);
+        dvteMaster->AddClone(dvteClone);
+
+        // set mother daughter
+        vteClone->AddDaughter(dvteClone);
+        dvteClone->AddMother(vteClone);
+	
+        // copy positions
+        G4int nofPositions = dvte->NPCopies();
+	for (G4int ip=0; ip<nofPositions; ip++)
+	  dvteClone->AddG3Pos(dvte->GetG3PosCopy(ip));
+	  
+        // copy division
+	G3Division* dvteDivision = dvte->GetDivision();
+	if (dvteDivision) {          
+	  G3Division* dvteCloneDivision
+	    = new G3Division(dvteClone, vteClone, *dvteDivision);
+          dvteClone->SetDivision(dvteCloneDivision);
+          dvteCloneDivision->UpdateVTE();
+	}  
+                                
+	// clone daughters recursively
+	G4CloneDaughters(dvte, dvteClone);
+      }	
+      else {     
+        // set dvte to vteClone
+        vteClone->AddDaughter(dvte);
+        dvte->AddMother(vteClone);
+      }	
+    }
+}
+
+void G4CreateCloneVTE(G3VolTableEntry* vte, G3VolTableEntry* mvte,
+              G4double pars[], G4int npar, G4int num,
+              G4double x, G4double y, G4double z, G4int irot, G4String vonly)
+//
+// create a new vte clone copy for each mother
+// and derive its parameters from the mother if possible
+{
+   // create a G3Pos
+   G4ThreeVector* offset = new G4ThreeVector(x*cm, y*cm, z*cm);
+   G3Pos* aG3Pos = new G3Pos(mvte->GetName(), num, offset, irot, vonly);
+            
+   // loop over all mothers
+   for (G4int i=0; i<mvte->GetNoClones(); i++) {
+                    // mvte was retrieved from its "master" name
+                    // -> there is no need to call GetMasterClone()
+      G3VolTableEntry* mvteClone = mvte->GetClone(i);
+        
+      G4String tmpName = "TRY";
+      G4String vteShape = vte->GetShape();
+      G3VolTableEntry* vteClone
+        = new G3VolTableEntry(tmpName, vteShape, pars, npar, vte->GetNmed(),
+                               0, true);
+          
+      // negative parameters will be updated only 
+      // for vteClone, pars are unchanged
+      G4double* clonePars = vteClone->GetRpar();
+      G4int     cloneNpar = vteClone->GetNpar();
+      G4bool negpars
+        = G3NegVolPars(clonePars, &cloneNpar, vteClone, mvteClone, "GSPOS");
+      vteClone->SetHasNegPars(negpars);
+
+      G3VolTableEntry* vteSameClone = 0;
+      G4VSolid* solid = 0;
+      if (!negpars) {
+        // check if vteClone with the same parameters exist
+        for (G4int ic=0; ic<vte->GetNoClones(); ic++) {
+          G3VolTableEntry* checkClone = vte->GetClone(ic);
+	  G4int checkNpar = checkClone->GetNpar();
+	  G4double* checkPars = checkClone->GetRpar();
+	  
+          G4bool isSame;
+          if (checkNpar != cloneNpar) 
+	    isSame = false;
+	  else {  
+  	    isSame = true;
+	    for (G4int ip=0; ip<cloneNpar; ip++) 
+	      if (checkPars[ip] != clonePars[ip]) {
+	        isSame = false;
+		break;  
+	      }
+	  } 
+	  if (isSame) vteSameClone = checkClone;	  
+	  break;
+        }
+       
+        if (vteSameClone) {
+          delete vteClone;
+	  
+          // add aG3Pos to the vteClone  
+          vteSameClone->AddG3Pos(aG3Pos);
+          mvteClone->AddDaughter(vteSameClone);  
+          vteSameClone->AddMother(mvteClone);
+        }
+	else {
+          // create the solid
+          G4bool hasNegPars;
+          G4bool deferred;
+          G4bool okAxis[3];
+          G4String vteName = vte->GetName();
+          G4String cloneShape = vteClone->GetShape();
+          solid = G3toG4MakeSolid(vteName, cloneShape, clonePars, cloneNpar,
+                                  hasNegPars, deferred, okAxis);
+        }				  
+      }
+   
+      if ( negpars || !(vteSameClone)) {
+        // generate vteClone name	  
+        G4int cloneNo = vte->GetNoClones();
+        char index[5]; sprintf(index,"%d",cloneNo);
+        G4String newName = vte->GetName();
+        newName.append(gSeparator); newName = newName + index;
+        
+        // update vteClone
+        vteClone->SetName(newName);
+        vteClone->SetSolid(solid);
+        vteClone->SetHasNegPars(negpars);
+                                
+        // let vte and vol table know about it
+        G3Vol.PutVTE(vteClone);
+        vte->AddClone(vteClone);
+          
+        // add aG3Pos to the vteClone  
+        vteClone->AddG3Pos(aG3Pos);
+        mvteClone->AddDaughter(vteClone);
+        vteClone->AddMother(mvteClone);
+           
+        // copy all daughters
+        G4CloneDaughters(vte, vteClone);
+
+        // retrieve daughters parameters
+        if (!negpars) G4ProcessDaughters(vteClone);
+      }
+  }
+}
+
+void G4gsposp(G4String vname, G4int num, G4String vmoth, G4double x,
+              G4double y, G4double z, G4int irot, G4String vonly,
+              G4double pars[], G4int npar)
+{
+  // find VTEs
+  G3VolTableEntry* vte = G3Vol.GetVTE(vname);
+  G3VolTableEntry* mvte = G3Vol.GetVTE(vmoth);
+
+  if (vte == 0) {
+    G4Exception("G4gsposp: '" + vname + "' has no VolTableEntry");
+  } 
+  if (mvte == 0) {
+    G4Exception("G4gsposp: '" + vmoth + "' has no VolTableEntry");
+  } 
+  else { 
+    // a new vte clone copy is created for each mother (clone copy)  
+    // and its parameters are derived from it if possible
+    
+    G4CreateCloneVTE(vte, mvte, pars, npar, num, x, y, z, irot, vonly);
+  }
+}
Index: /trunk/source/g3tog4/src/G4gsrotm.cc
===================================================================
--- /trunk/source/g3tog4/src/G4gsrotm.cc	(revision 817)
+++ /trunk/source/g3tog4/src/G4gsrotm.cc	(revision 817)
@@ -0,0 +1,103 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G4gsrotm.cc,v 1.12 2006/06/29 18:14:55 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+#include "G3toG4.hh"
+#include "G3RotTable.hh"
+#include "G4ThreeVector.hh"
+#include "G3toG4RotationMatrix.hh"
+
+void PG4gsrotm(G4String tokens[])
+{
+    // fill the parameter containers
+    G3fillParams(tokens,PTgsrotm);
+
+    // interpret the parameters
+    G4int irot = Ipar[0];
+    
+    // the angles in Geant are in degrees
+    G4double theta1 = Rpar[0];
+    G4double phi1   = Rpar[1];
+    G4double theta2 = Rpar[2];
+    G4double phi2   = Rpar[3];
+    G4double theta3 = Rpar[4];
+    G4double phi3   = Rpar[5];
+
+    G4gsrotm(irot, theta1,phi1, theta2,phi2, theta3,phi3);
+}
+
+void G4gsrotm(G4int irot, G4double theta1, G4double phi1,
+              G4double theta2, G4double phi2, G4double theta3, G4double phi3)
+{
+    G4double degrad = pi/180;
+    
+    G4double th1r = theta1*degrad;
+    G4double th2r = theta2*degrad;
+    G4double th3r = theta3*degrad;
+    
+    G4double phi1r = phi1*degrad;
+    G4double phi2r = phi2*degrad;
+    G4double phi3r = phi3*degrad;
+    
+        // Construct unit vectors 
+    
+    G4ThreeVector x(std::sin(th1r)*std::cos(phi1r), std::sin(th1r)*std::sin(phi1r), std::cos(th1r));
+    G4ThreeVector y(std::sin(th2r)*std::cos(phi2r), std::sin(th2r)*std::sin(phi2r), std::cos(th2r));
+    G4ThreeVector z(std::sin(th3r)*std::cos(phi3r), std::sin(th3r)*std::sin(phi3r), std::cos(th3r));
+
+        // check for orthonormality and left-handedness
+
+    G4double check = (x.cross(y))*z;
+    G4double tol = 1.0e-3;
+        
+    if (1-std::abs(check)>tol) {
+        G4cerr << "Coordinate axes forming rotation matrix "
+               << irot << " are not orthonormal.(" << 1-std::abs(check) << ")" 
+         << G4endl;
+        G4cerr << " theta1=" << theta1;
+        G4cerr << " phi1=" << phi1;
+        G4cerr << " theta2=" << theta2;
+        G4cerr << " phi2=" << phi2;
+        G4cerr << " theta3=" << theta3;
+        G4cerr << " phi3=" << phi3;
+        G4cerr << G4endl;
+        G4Exception("G4gsrotm error");
+    }
+    //else if (1+check<=tol) {
+    //    G4cerr << "G4gsrotm warning: coordinate axes forming rotation "
+    //           << "matrix " << irot << " are left-handed" << G4endl;
+    //}
+    
+    G3toG4RotationMatrix* rotp = new G3toG4RotationMatrix;
+
+    rotp->SetRotationMatrixByRow(x, y, z);
+    
+        // add it to the List
+
+    G3Rot.Put(irot, rotp);
+}
Index: /trunk/source/g3tog4/src/G4gstmed.cc
===================================================================
--- /trunk/source/g3tog4/src/G4gstmed.cc	(revision 817)
+++ /trunk/source/g3tog4/src/G4gstmed.cc	(revision 817)
@@ -0,0 +1,95 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G4gstmed.cc,v 1.7 2006/06/29 18:15:02 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+// The last G4int argument of G4gstmed(..) is used for sending
+// info whether the Geant3 tracking medium parameters should
+// be set (the max step, later: G3 default cut values).
+//
+// by I.Hrivnacova, 27 Sep 99
+
+#include "G4LogicalVolume.hh"
+#include "G3toG4.hh"
+#include "G3MatTable.hh"
+#include "G3MedTable.hh"
+#include "G4UserLimits.hh"
+#include "G4MagneticField.hh"
+#include "G4Material.hh"
+
+void PG4gstmed(G4String tokens[])
+{
+    // fill the parameter containers
+    G3fillParams(tokens,PTgstmed);
+
+    // interpret the parameters
+    G4String name = Spar[0];
+    G4int itmed = Ipar[0];
+    G4int nmat = Ipar[1];
+    G4int isvol = Ipar[2];
+    G4int ifield = Ipar[3];
+    G4int nwbuf = Ipar[4];
+    G4double fieldm = Rpar[0];
+    G4double tmaxfd = Rpar[1];
+    G4double stemax = Rpar[2];
+    G4double deemax = Rpar[3];
+    G4double epsil = Rpar[4];
+    G4double stmin = Rpar[5];
+    G4double *ubuf = &Rpar[6];
+
+    G4gstmed(itmed,name,nmat,isvol,ifield,fieldm,tmaxfd,stemax,
+             deemax,epsil,stmin,ubuf,nwbuf);
+}
+
+void G4gstmed(G4int itmed, G4String, G4int nmat, G4int isvol,
+              G4int, G4double, G4double,
+              G4double stemax, G4double, G4double,
+              G4double, G4double*, G4int useG3TMLimits)
+{
+    // get the pointer to material nmat
+    G4Material* material = G3Mat.get(nmat);
+
+    // NB. there is the possibility for redundancy in the mag field
+    //     and user limits objects. Who cares.
+    // Generate the mag field object
+    // $$$ G4MagneticField* field = new G4MagneticField(ifield, fieldm, tmaxfd);
+    G4MagneticField* field = 0;
+
+    // Generate the user limits object
+    // !!! only "stemax" has its equivalent in G4
+
+    G4UserLimits* limits = 0;
+    if (useG3TMLimits) {
+      limits = new G4UserLimits();
+      limits->SetMaxAllowedStep(stemax*cm);
+      // limits->SetG3DefaultCuts();
+         // this is arranged globally by physics manager
+    }
+
+    // Store this medium in the G3Med structure
+    G3Med.put(itmed, material, field, limits, isvol);
+}
Index: /trunk/source/g3tog4/src/G4gstpar.cc
===================================================================
--- /trunk/source/g3tog4/src/G4gstpar.cc	(revision 817)
+++ /trunk/source/g3tog4/src/G4gstpar.cc	(revision 817)
@@ -0,0 +1,51 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G4gstpar.cc,v 1.8 2006/06/29 18:15:04 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+#include "G3toG4.hh"
+#include "G3VolTable.hh"
+
+void PG4gstpar(G4String tokens[])
+{
+    // fill the parameter containers
+    G3fillParams(tokens,PTgstpar);
+
+    // interpret the parameters
+    G4String chpar = Spar[0];
+    G4int itmed = Ipar[0];
+    G4double parval = Rpar[0];
+
+    G4gstpar(itmed,chpar,parval);
+}
+
+void G4gstpar(G4int, G4String, G4double)
+{
+    // set special tracking medium parameter. Apply to all logical
+    // volumes making use of the specified tracking medium.
+  G4cerr << "G4gstpar: not implemented." << G4endl;
+}
Index: /trunk/source/g3tog4/src/G4gsvolu.cc
===================================================================
--- /trunk/source/g3tog4/src/G4gsvolu.cc	(revision 817)
+++ /trunk/source/g3tog4/src/G4gsvolu.cc	(revision 817)
@@ -0,0 +1,90 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G4gsvolu.cc,v 1.10 2006/06/29 18:15:06 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+// by I.Hrivnacova, 13.10.99
+
+#include <iomanip>
+#include "G3VolTable.hh"
+#include "globals.hh"
+#include "G3toG4.hh"
+#include "G3toG4MakeSolid.hh"
+
+void PG4gsvolu(G4String tokens[]) {
+    // fill the parameter containers
+    G3fillParams(tokens,PTgsvolu);
+
+    // interpret the parameters
+    G4String vname = Spar[0];
+    G4String shape = Spar[1];
+    G4int nmed = Ipar[0];
+    G4int npar = Ipar[1];
+    G4double *pars = Rpar;
+
+    G4gsvolu(vname, shape, nmed, pars, npar);
+}
+
+G3VolTableEntry* G4CreateVTE(G4String vname, G4String shape, G4int nmed,
+                             G4double Rpar[], G4int npar)
+{    
+  // create the solid
+  G4bool hasNegPars;
+  G4bool deferred;   
+  G4bool okAxis[3];
+  G4VSolid* solid
+    = G3toG4MakeSolid(vname, shape, Rpar, npar, hasNegPars, deferred, okAxis);  
+
+  // if solid has been deferred 
+  // VTE is created with hasNegPars = true  
+  if (deferred) hasNegPars = true;   
+
+  // create VTE
+  G3VolTableEntry* vte 
+     = new G3VolTableEntry(vname, shape, Rpar, npar, nmed, solid, hasNegPars);
+  G3Vol.PutVTE(vte);
+  
+  return vte;
+}
+
+void G4gsvolu(G4String vname, G4String shape, G4int nmed, G4double* Rpar,
+              G4int npar)
+{
+  /*
+  G4cout << "Creating logical volume " << vname << " shape " << shape
+  	 << " nmed " << nmed << " #pars "<< npar << " parameters (cm): ";
+  for (int ipar=0; ipar< npar; ipar++) G4cout << std::setw(8) << Rpar[ipar];
+  G4cout << G4endl;
+  */
+  if (G3Vol.GetVTE(vname)) {
+    // abort if VTE with given name exists
+    G4Exception("G4gsvolu: Attempt to create volume " + vname + " twice.");
+  }
+  else {  
+    G4CreateVTE(vname, shape, nmed, Rpar, npar);
+  }  
+}
Index: /trunk/source/g3tog4/src/clparse.cc
===================================================================
--- /trunk/source/g3tog4/src/clparse.cc	(revision 817)
+++ /trunk/source/g3tog4/src/clparse.cc	(revision 817)
@@ -0,0 +1,284 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * 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.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: clparse.cc,v 1.18 2006/06/29 18:15:08 gunter Exp $
+// GEANT4 tag $Name:  $
+//
+// modified by I.Hrivnacova
+// added G3SensVol
+
+#include "globals.hh"
+#include <fstream>
+#include "G4Tokenizer.hh"
+#include "G3toG4.hh"
+#include "G3EleTable.hh"
+#include "G3VolTable.hh"
+#include "G3MatTable.hh"
+#include "G3MedTable.hh"
+#include "G3RotTable.hh"
+#include "G3PartTable.hh"
+#include "G3DetTable.hh"
+#include "G3SensVolVector.hh"
+
+std::ofstream ofile;
+
+extern "C" {
+#include <stdlib.h>
+}
+
+extern std::ofstream ofile;
+
+G3VolTable G3Vol;
+G3MatTable G3Mat; // material G3 ID <-> G4 pointer table
+G3MedTable G3Med; // trk media G3 ID <-> G4 pointer table
+G3RotTable G3Rot; // rotation ID <-> G4 transform object table
+G3PartTable G3Part; // particle ID <-> ParticleDefinition pointer
+G3DetTable G3Det; // sensitive detector name <-> pointer
+G3EleTable G3Ele; // element names table
+G3SensVolVector G3SensVol; // vector of sensitive logical volumes
+char gSeparator('_');
+
+G4int narray;
+
+G4int Ipar[1000];
+G4double Rpar[1000];
+G4String Spar[1000];
+
+G4int G3CLTokens(G4String *line, G4String *tokens);
+void G3CLEval(G4String *tokens, char *select);
+
+// front-end decoders for G3 routines
+void PG4gsvolu(G4String *tokens);
+void PG4gspos (G4String *tokens);
+void PG4gsposp(G4String *tokens);
+void PG4gsatt (G4String *tokens);
+void PG4gsrotm(G4String *tokens);
+void PG4gsdvn (G4String *tokens);
+void PG4gsdvt (G4String *tokens);
+void PG4gsdvx (G4String *tokens);
+void PG4gsdvn2(G4String *tokens);
+void PG4gsdvt2(G4String *tokens);
+void PG4gsmate(G4String *tokens);
+void PG4gsmixt(G4String *tokens);
+void PG4gstmed(G4String *tokens);
+void PG4gstpar(G4String *tokens);
+void PG4gspart(G4String *tokens);
+void PG4gsdk  (G4String *tokens);
+void PG4gsdet (G4String *tokens);
+void PG4gsdetv(G4String *tokens);
+void PG4gsdeta(G4String *tokens);
+void PG4gsdeth(G4String *tokens);
+void PG4gsdetd(G4String *tokens);
+void PG4gsdetu(G4String *tokens);
+void PG4ggclos();
+
+void G3CLRead(G4String & fname, char *select = 0){
+//
+//  G3CLRead
+//  Read the call List file, parse the tokens, and pass the token
+//  List to the Geant4 interpreter
+//
+//  fname: call List filename
+//
+  
+  G4String line;
+  G4String tokens[1000];
+
+  const char* ofname = "clparse.out";
+  ofile.open(ofname);
+  ofile << "Output file open\n";
+
+  G4int count = 0;
+  G4int ntokens = 0;
+  std::ifstream istr(fname);
+    
+  while (line.readLine(istr) && ! istr.eof()){
+      count++;
+      ntokens = G3CLTokens(&line,tokens);  // tokenize the line
+      for (G4int i=0; i < ntokens; i++) ofile << tokens[i] << G4endl;
+      
+          // interpret the line as a Geant call
+      G3CLEval(tokens, select);
+  }
+}
+
+
+G4int G3CLTokens(G4String *line, G4String tokens[])
+//
+// G3CLTokens
+//
+// Tokenize line, returning tokens in tokens[]. Items in ".."
+// are extracted as single tokens, despite embedded spaces.
+//
+{
+    G4Tokenizer next(*line);
+    // first tokenize using " to identify strings
+    G4int itok = 0;
+    G4int ntokens = 0;
+    G4String token1, token2;
+    while (!(token1=next("\"")).isNull())
+        {
+            itok++;
+            if (itok%2 == 0 ) // even: inside a string
+                {
+                    tokens[ntokens++] = token1;
+                } else        // not in a quoted string: finish tokenization
+                {
+                    G4Tokenizer lev2(token1);
+                    while (!(token2=lev2()).isNull())
+                        {
+                            tokens[ntokens] = token2;
+                            ntokens++;
+                        }
+                }
+        }
+    return ntokens;
+}
+
+void G3CLEval(G4String tokens[], char *select)
+//
+// G3CLEval
+//
+// Evaluate the token List as a Geant3 call, and execute it as
+// a Geant4 call.
+//
+{
+    const char* context = tokens[0];
+    const char* routine = tokens[1];
+
+    // If context is selected, return unless context matches.
+    if (select != 0 && select != "*") if ( strcmp(select,context) ) return;
+
+    // Branch on Geant3 routine name
+    ofile << "Do routine " << routine << " in context " << context << G4endl;
+    
+    if ( !strcmp(routine,"GSVOLU") ) { 
+//      volcount++;
+//      if (volcount == 1) {
+//        // Special handling of the first one, assumed to be global mother
+//        if ( GlobalMotherVolume == 0 ) {
+//        PG4gsvolu(&tokens[2]); 
+//        } else {
+//          G4String gblmoth="Global mother";
+//          G3Vol.PutLV(&gblmoth,GlobalMotherVolume);
+//        }
+//      } else {
+//        PG4gsvolu(&tokens[2]); 
+//      }
+//      if (volcount == 2) {
+//        G4String vname = tokens[2];
+//        SubsystemMotherVolume = G3Vol.GetLV(&vname);
+//      }
+        { PG4gsvolu(&tokens[2]); return;}
+    }
+    if ( !strcmp(routine,"GSPOS") )  { PG4gspos (&tokens[2]); return;}
+    if ( !strcmp(routine,"GSPOSP") ) { PG4gsposp(&tokens[2]); return;}
+    if ( !strcmp(routine,"GSATT") )  { PG4gsatt (&tokens[2]); return;}
+    if ( !strcmp(routine,"GSROTM") ) { PG4gsrotm(&tokens[2]); return;}
+    if ( !strcmp(routine,"GSDVN") )  { PG4gsdvn (&tokens[2]); return;}
+    if ( !strcmp(routine,"GSDVT") )  { PG4gsdvt (&tokens[2]); return;}
+    if ( !strcmp(routine,"GSDVX") )  { PG4gsdvx (&tokens[2]); return;}
+    if ( !strcmp(routine,"GSDVN2") ) { PG4gsdvn2(&tokens[2]); return;}
+    if ( !strcmp(routine,"GSDVT2") ) { PG4gsdvt2(&tokens[2]); return;}
+    if ( !strcmp(routine,"GSMATE") ) { PG4gsmate(&tokens[2]); return;}
+    if ( !strcmp(routine,"GSMIXT") ) { PG4gsmixt(&tokens[2]); return;}
+    if ( !strcmp(routine,"GSTMED") ) { PG4gstmed(&tokens[2]); return;}
+    if ( !strcmp(routine,"GSTPAR") ) { PG4gstpar(&tokens[2]); return;}
+    if ( !strcmp(routine,"GSPART") ) { PG4gspart(&tokens[2]); return;}
+    if ( !strcmp(routine,"GSDK") )   { PG4gsdk  (&tokens[2]); return;}
+    if ( !strcmp(routine,"GSDET") )  { PG4gsdet (&tokens[2]); return;}
+    if ( !strcmp(routine,"GSDETV") ) { PG4gsdetv(&tokens[2]); return;}
+    if ( !strcmp(routine,"GSDETA") ) { PG4gsdeta(&tokens[2]); return;}
+    if ( !strcmp(routine,"GSDETH") ) { PG4gsdeth(&tokens[2]); return;}
+    if ( !strcmp(routine,"GSDETD") ) { PG4gsdetd(&tokens[2]); return;}
+    if ( !strcmp(routine,"GSDETU") ) { PG4gsdetu(&tokens[2]); return;}
+    if ( !strcmp(routine,"GGCLOS") ) { PG4ggclos(); return;}
+}
+
+void G3fillParams(G4String *tokens, const char *ptypes)
+//
+// G3fillParams
+//
+// Interpret tokens to fill call parameters, based on parameter
+//   types ptypes
+//
+{
+    // loop over ptypes
+    G4int i =0, ipt = 0, k = 0;
+    G4int ni =0, nr = 0, ns = 0;
+    while (ptypes[i] != '\0')
+        {
+            switch (ptypes[i]) {
+            case 'i':
+                Ipar[ni] = atoi(tokens[ipt].data());
+                narray = Ipar[ni];
+                ni++; ipt++;
+                break;
+            case 'r':
+                Rpar[nr] = atof(tokens[ipt].data());
+                nr++; ipt++;
+                break;
+            case 's':
+                Spar[ns] = tokens[ipt];
+                ns++; ipt++;
+                break;
+            case 'I':
+                for (k=0; k < narray; k++)
+                    {
+                        Ipar[ni] = atoi(tokens[ipt].data());
+                        ni++; ipt++;
+                    }
+                break;
+            case 'R':
+                for (k=0; k < narray; k++) 
+                    { 
+                        Rpar[nr] = atof(tokens[ipt].data()); 
+                        nr++; ipt++;
+                    }
+                break;
+            case 'Q':
+                // special case of reading three successive R arrays 
+                // into one (used in gsmixt)
+                narray = 3 * std::abs(narray);
+                for (k=0; k < narray; k++) 
+                    { 
+                        Rpar[nr] = atof(tokens[ipt].data()); 
+                        nr++; ipt++;
+                    }
+                break;
+            case 'S':
+                for (k=0; k < narray; k++)
+                    {
+                        Spar[ns] = tokens[ipt];
+                        ns++; ipt++;
+                    }
+                break;
+            default:
+                ofile << "unidentified ptype '" << ptypes[i] << G4endl;
+            };
+            i++;
+        }
+}
Index: /trunk/source/g3tog4/src/g3routines.F
===================================================================
--- /trunk/source/g3tog4/src/g3routines.F	(revision 817)
+++ /trunk/source/g3tog4/src/g3routines.F	(revision 817)
@@ -0,0 +1,1023 @@
+*    
+*     ********************************************************************
+*     * License and Disclaimer                                           *
+*     *                                                                  *
+*     * The  Geant4 software  is  copyright of the Copyright Holders  of *
+*     * the Geant4 Collaboration.  It is provided  under  the terms  and *
+*     * conditions of the Geant4 Software License,  included in the file *
+*     * LICENSE and available at  http://cern.ch/geant4/license .  These *
+*     * include a list of copyright holders.                             *
+*     *                                                                  *
+*     * 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.  Please see the license in the file  LICENSE  and URL above *
+*     * for the full disclaimer and the limitation of liability.         *
+*     *                                                                  *
+*     * This  code  implementation is the result of  the  scientific and *
+*     * technical work of the GEANT4 collaboration.                      *
+*     * By using,  copying,  modifying or  distributing the software (or *
+*     * any work based  on the software)  you  agree  to acknowledge its *
+*     * use  in  resulting  scientific  publications,  and indicate your *
+*     * acceptance of all terms of the Geant4 Software license.          *
+*     ********************************************************************
+*    
+*    
+*     $Id: g3routines.F,v 1.5 2006/06/29 18:15:10 gunter Exp $
+*     GEANT4 tag $Name:  $
+*    
+#define CALL_GEANT
+
+#ifndef CALL_GEANT
+      subroutine gsvolu(name, shape, nmed, par, npar, ivol)
+#else 
+      subroutine Ksvolu(name, shape, nmed, par, npar, ivol)
+#endif
+************************************************************************
+************************************************************************
+      implicit none
+      character name*4, shape*4, fmt*150
+      integer nmed, npar, ivol, k
+      real par(npar)
+      character rname*6
+#include "G3toG4.inc"
+      data rname /'GSVOLU'/
+*     
+      call check_lines
+#ifdef CALL_GEANT
+      if (dogeom) call gsvolu(name, shape, nmed, par, npar, ivol)
+#endif
+      if (npar.ne.0) call checkshape(name, shape, par, npar)
+*     
+      if (lunlist.ne.0) then
+*        write(lunlist,
+*     +    '(a4,1x,a6,1x,a4,1x,a4,2i5,<npar>e15.8)')
+*     +    context, rname, name, shape, nmed, npar,
+*     +    (par(k),k=1,npar)
+         write(fmt,'(A,I2,A)')'(a4,1x,a6,1x,a4,1x,a4,2i5,',max(npar,1),
+     >        '(1x,e16.8))'
+         write(lunlist,fmt) context, rname, name, shape, nmed, npar,
+     +        (par(k),k=1,npar)
+      endif
+      if (luncode.ne.0) then
+         write(luncode,'(''{'')')
+         call g3ldpar(par,npar)
+         write(luncode,1000) name, shape, nmed, npar
+ 1000    format('G4gsvolu(name="',a,'",shape="',a,'",nmed=',i5,
+     +        ',par,npar=',i4,');')
+         write(luncode,'(''}'')')
+      endif
+*     
+      end
+*     
+#ifndef CALL_GEANT
+      subroutine gspos(name, num, moth, x, y, z, irot, only)
+#else 
+      subroutine Kspos(name, num, moth, x, y, z, irot, only)
+#endif
+************************************************************************
+************************************************************************
+      implicit none
+      character name*4, moth*4, only*4
+      integer num, irot
+      real x, y, z
+      character rname*6
+#include "G3toG4.inc"
+      data rname /'GSPOS '/
+*     
+      call check_lines
+#ifdef CALL_GEANT
+      if (dogeom) call gspos(name, num, moth, x, y, z, irot, only)
+#endif
+      if (lunlist.ne.0) then
+         write(lunlist,
+     +        '(a4,1x,a6,1x,a4,i5,1x,a4,3(1x,e16.8),i5,1x,a4)')
+     +        context, rname, name, num, moth, x, y, z, irot, only
+      endif
+      if (luncode.ne.0) then
+         write(luncode,'(''{'')')
+         call rtocp('x',x)
+         call rtocp('y',y)
+         call rtocp('z',z)
+         write(luncode,1000) name,num,moth,irot,only
+ 1000    format('G4gspos(name="',a,'",num=',i5,',moth="',a,
+     +        '",x,y,z,irot=',i5,',only="',a,'");')
+         write(luncode,'(''}'')')
+      endif
+*     
+      end
+*     
+#ifndef CALL_GEANT
+      subroutine gsposp(name, num, moth, x, y, z, irot, only, par, npar)
+#else 
+      subroutine Ksposp(name, num, moth, x, y, z, irot, only, par, npar)
+#endif
+************************************************************************
+************************************************************************
+      implicit none
+      character name*4, moth*4, only*4
+      integer num, irot, npar, k
+      real x, y, z, par(npar)
+      character rname*6, fmt*150
+#include "G3toG4.inc"
+      data rname /'GSPOSP'/
+*     
+      call check_lines
+#ifdef CALL_GEANT
+      if (dogeom) call gsposp(name, num, moth, x, y, z, irot, only,
+     +     par, npar)
+#endif
+      if (lunlist.ne.0) then
+         do k=1,npar
+            if (abs(par(k)).gt.1.e10) then
+               print *,'Warning: huge junk value in PAR for GSPOS'
+               print *,'  zeroed out. Volume ',name
+               par(k) = 0.
+            endif
+         enddo
+*        write(lunlist,
+*     +    '(a4,1x,a6,1x,a4,i5,1x,a4,3e15.8,i5,1x,a4,
+*     +    i5,<npar>e15.8)')
+*     +    context, rname, name, num, moth, x, y, z, irot, only,
+*     +    npar,
+*     +    (par(k),k=1,npar)
+         write(fmt,'(A,A,I2,A)')
+     >        '(a4,1x,a6,1x,a4,i5,1x,a4,3(1x,e16.8),',       
+     +        'i5,1x,a4,i5,',max(npar,1),'(1x,e16.8))'
+         write(lunlist,fmt)
+     +        context, rname, name, num, moth, x, y, z, irot, only,
+     +        npar,
+     +        (par(k),k=1,npar)
+      endif
+      if (luncode.ne.0) then
+         write(luncode,'(''{'')')
+         call rtocp('x',x)
+         call rtocp('y',y)
+         call rtocp('z',z)
+         call g3ldpar(par,npar)
+         write(luncode,1000) name,num,moth,irot,only,npar
+ 1000    format('G4gsposp(name="',a,'",num=',i5,',moth="',a,
+     +        '",x,y,z,irot=',i5,',only="',a,'",par,npar=',i4,');')
+         write(luncode,'(''}'')')
+      endif
+*     
+      end
+*     
+#ifndef CALL_GEANT
+      subroutine gsatt(name, attr, ival)
+#else 
+      subroutine Ksatt(name, attr, ival)
+#endif
+************************************************************************
+************************************************************************
+      implicit none
+      character name*4, attr*4
+      integer ival
+      character rname*6
+#include "G3toG4.inc"
+      data rname /'GSATT '/
+*     
+      call check_lines
+#ifdef CALL_GEANT
+      if (dogeom) call gsatt(name, attr, ival)
+#endif
+      if (lunlist.ne.0) then
+         write(lunlist,
+     +        '(a4,1x,a6,1x,a4,1x,a4,i12)')
+     +        context, rname, name, attr, ival
+      endif
+      if (luncode.ne.0) then
+         write(luncode,'(''{'')')
+         write(luncode,1000) name,attr,ival
+ 1000    format('G4gsatt(name="',a,'",attr="',a,'",ival=',i10,');')
+         write(luncode,'(''}'')')
+      endif
+*     
+      end
+*     
+#ifndef CALL_GEANT
+      subroutine gsrotm(irot, theta1, phi1, theta2, phi2,
+     +     theta3, phi3)
+#else 
+      subroutine Ksrotm(irot, theta1, phi1, theta2, phi2,
+     +     theta3, phi3)
+#endif
+************************************************************************
+************************************************************************
+      implicit none
+      integer irot
+      real theta1, phi1, theta2, phi2, theta3, phi3
+      character rname*6
+#include "G3toG4.inc"
+      data rname /'GSROTM'/
+*     
+      call check_lines
+#ifdef CALL_GEANT
+      if (dogeom) call gsrotm(irot, theta1, phi1, theta2, phi2,
+     +     theta3, phi3)
+#endif
+      if (lunlist.ne.0) then
+         write(lunlist,
+     +        '(a4,1x,a6,i5,6f11.5)')
+     +        context, rname, irot, theta1, phi1, theta2, phi2,
+     +        theta3, phi3
+      endif
+      if (luncode.ne.0) then
+         write(luncode,'(''{'')')
+         call rtocp('theta1',theta1)
+         call rtocp('phi1',phi1)
+         call rtocp('theta2',theta2)
+         call rtocp('phi2',phi2)
+         call rtocp('theta3',theta3)
+         call rtocp('phi3',phi3)
+         write(luncode,1000) irot
+ 1000    format('G4gsrotm(irot=',i5,
+     +        ',theta1,phi1,theta2,phi2,theta3,phi3);')
+         write(luncode,'(''}'')')
+      endif
+*     
+      end
+*     
+#ifndef CALL_GEANT
+      subroutine gsdvn(name, moth, ndiv, iaxis)
+#else 
+      subroutine Ksdvn(name, moth, ndiv, iaxis)
+#endif
+************************************************************************
+************************************************************************
+      implicit none
+      character name*4, moth*4
+      integer ndiv, iaxis
+      character rname*6
+#include "G3toG4.inc"
+      data rname /'GSDVN '/
+*     
+      call check_lines
+#ifdef CALL_GEANT
+      if (dogeom) call gsdvn(name, moth, ndiv, iaxis)
+#endif
+      if (lunlist.ne.0) then
+         write(lunlist,
+     +        '(a4,1x,a6,1x,a4,1x,a4,i5,i3)')
+     +        context, rname, name, moth, ndiv, iaxis
+      endif
+      if (luncode.ne.0) then
+         write(luncode,'(''{'')')
+         write(luncode,1000) name, moth, ndiv, iaxis
+ 1000    format('G4gsdvn(name="',a,'",moth="',a,'",ndiv=',i3,
+     +        ',iaxis=',i1,');')
+         write(luncode,'(''}'')')
+      endif
+*     
+      end
+*     
+#ifndef CALL_GEANT
+      subroutine gsdvt(name, moth, step, iaxis, numed, ndvmx)
+#else 
+      subroutine Ksdvt(name, moth, step, iaxis, numed, ndvmx)
+#endif
+************************************************************************
+************************************************************************
+      implicit none
+      character name*4, moth*4
+      real step
+      integer iaxis, numed, ndvmx
+      character rname*6
+#include "G3toG4.inc"
+      data rname /'GSDVT '/
+*     
+      call check_lines
+#ifdef CALL_GEANT
+      if (dogeom) call gsdvt(name, moth, step, iaxis, numed, ndvmx)
+#endif
+      if (lunlist.ne.0) then
+         write(lunlist,
+     +        '(a4,1x,a6,1x,a4,1x,a4,(1x,e16.8),3i5)')
+     +        context, rname, name, moth, step, iaxis, numed, ndvmx
+      endif
+      if (luncode.ne.0) then
+         write(luncode,'(''{'')')
+         call rtocp('step',step)
+         write(luncode,1000) name,moth,iaxis,numed,ndvmx
+ 1000    format('G4gsdvt(name="',a,'",moth="',a,'",step,iaxis=',
+     +        i1,',numed=',i4,',ndvmx=',i4,');')
+         write(luncode,'(''}'')')
+      endif
+*     
+      end
+*     
+#ifndef CALL_GEANT
+      subroutine gsdvx(name, moth, ndiv, iaxis, step, c0, numed, ndvmx)
+#else 
+      subroutine Ksdvx(name, moth, ndiv, iaxis, step, c0, numed, ndvmx)
+#endif
+************************************************************************
+************************************************************************
+      implicit none
+      character name*4, moth*4
+      integer ndiv, iaxis, numed, ndvmx
+      real step, c0
+      character rname*6
+#include "G3toG4.inc"
+      data rname /'GSDVX '/
+*     
+      call check_lines
+#ifdef CALL_GEANT
+      if (dogeom) call gsdvx(name, moth, ndiv, iaxis, step, c0, numed,
+     +     ndvmx)
+#endif
+      if (lunlist.ne.0) then
+         write(lunlist,
+     +        '(a4,1x,a6,1x,a4,1x,a4,i5,i3,2(1x,e16.8),2i5)')
+     +        context, rname, name, moth, ndiv, iaxis,step, c0,
+     +        numed, ndvmx
+      endif
+      if (luncode.ne.0) then
+         write(luncode,'(''{'')')
+         call rtocp('step',step)
+         call rtocp('c0',c0)
+         write(luncode,1000) name,moth,ndiv,iaxis,numed,ndvmx
+ 1000    format('G4gsdvx(name="',a,'",moth="',a,'",ndiv=',i3,',iaxis=',
+     +        i1,',step,c0,numed=',i4,',ndvmx=',i4,');')
+         write(luncode,'(''}'')')
+      endif
+*     
+      end
+*     
+#ifndef CALL_GEANT
+      subroutine gsdvn2(name, moth, ndiv, iaxis, c0, numed)
+#else 
+      subroutine Ksdvn2(name, moth, ndiv, iaxis, c0, numed)
+#endif
+************************************************************************
+************************************************************************
+      implicit none
+      character name*4, moth*4
+      integer ndiv, iaxis, numed
+      real c0
+      character rname*6
+#include "G3toG4.inc"
+      data rname /'GSDVN2'/
+*     
+      call check_lines
+#ifdef CALL_GEANT
+      if (dogeom) call gsdvn2(name, moth, ndiv, iaxis, c0, numed)
+#endif
+      if (lunlist.ne.0) then
+         write(lunlist,
+     +        '(a4,1x,a6,1x,a4,1x,a4,i5,i3,(1x,e16.8),i5)')
+     +        context, rname, name, moth, ndiv, iaxis, c0, numed
+      endif
+      if (luncode.ne.0) then
+         write(luncode,'(''{'')')
+         call rtocp('c0',c0)
+         write(luncode, 1000) name,moth,ndiv,iaxis,numed
+ 1000    format('G4gsdvn2(name="',a,'",moth="',a,'",ndiv=',i3,',iaxis=',
+     +        i1,',c0,numed=',i4,');')
+         write(luncode,'(''}'')')
+      endif
+*     
+      end
+*     
+#ifndef CALL_GEANT
+      subroutine gsdvt2(name, moth, step, iaxis, c0, numed, ndvmx)
+#else 
+      subroutine Ksdvt2(name, moth, step, iaxis, c0, numed, ndvmx)
+#endif
+************************************************************************
+************************************************************************
+      implicit none
+      character name*4, moth*4
+      integer iaxis, numed, ndvmx
+      real step, c0
+      character rname*6
+#include "G3toG4.inc"
+      data rname /'GSDVT2'/
+*     
+      call check_lines
+#ifdef CALL_GEANT
+      if (dogeom) call gsdvt2(name, moth, step, iaxis, c0, numed, ndvmx)
+#endif
+      if (lunlist.ne.0) then
+         write(lunlist,
+     +        '(a4,1x,a6,1x,a4,1x,a4,(1x,e16.8),i3,(1x,e16.8),2i5)')
+     +        context, rname, name, moth, step, iaxis, c0, numed, ndvmx
+      endif
+      if (luncode.ne.0) then
+         write(luncode,'(''{'')')
+         call rtocp('step',step)
+         call rtocp('c0',c0)
+         write(luncode,1000) name,moth,iaxis,numed,ndvmx
+ 1000    format('G4gsdvt2(name="',a,'",moth="',a,'",step,iaxis=',
+     +        i1,',c0,numed=',i4,',ndvmx=',i4,');')
+         write(luncode,'(''}'')')
+      endif
+*     
+      end
+*     
+#ifndef CALL_GEANT
+      subroutine gsmate(imate, name, a, z, dens, radl, absl, ubf, nwbf)
+#else 
+      subroutine Ksmate(imate, name, a, z, dens, radl, absl, ubf, nwbf)
+#endif
+************************************************************************
+************************************************************************
+      implicit none
+      character name*(*)
+      integer imate, nwbf, k
+      real a, z, dens, radl, absl, ubf(nwbf)
+      character rname*6, fmt*150
+#include "G3toG4.inc"
+      data rname /'GSMATE'/
+*     
+      call check_lines
+#ifdef CALL_GEANT
+      if (dogeom) call gsmate
+     +     (imate, name, a, z, dens, radl, absl, ubf, nwbf)
+#endif
+      if (lunlist.ne.0) then
+         write(fmt,'(A,I3,A)')
+     >        '(a4,1x,a6,i5,1x,''"'',a,''"'',4(1x,e16.8),i3,',
+     >        max(nwbf,1),'(1x,e16.8))'
+         write(lunlist,fmt)
+     +        context, rname, imate, name, a, z, dens, radl,
+     +        nwbf, (ubf(k), k=1,nwbf)
+      endif
+      if (luncode.ne.0) then
+         write(luncode,'(''{'')')
+         call rtocp('a',a)
+         call rtocp('z',z)
+         call rtocp('dens',dens)
+         call rtocp('radl',radl)
+         call g3ldpar(ubf,nwbf)
+         write(luncode,1000) imate, name, nwbf
+ 1000    format('G4gsmate(imate=',i4,',name="',a,
+     +        '",a,z,dens,radl,npar=',i4,',par);')
+         write(luncode,'(''}'')')
+      endif
+*     
+      end
+*     
+#ifndef CALL_GEANT
+      subroutine gsmixt(imate, name, a, z, dens, nlmat, wmat)
+#else 
+      subroutine Ksmixt(imate, name, a, z, dens, nlmat, wmat)
+#endif
+************************************************************************
+************************************************************************
+      implicit none
+      character name*(*)
+      integer imate, nlmat, k, nlmata
+      real a(*), z(*), dens, wmat(*)
+      character rname*6, fmt*150
+#include "G3toG4.inc"
+      data rname /'GSMIXT'/
+*     
+      call check_lines
+#ifdef CALL_GEANT
+      if (dogeom) call gsmixt
+     +     (imate, name, a, z, dens, nlmat, wmat)
+#endif
+      if (lunlist.ne.0) then
+         nlmata = abs(nlmat)
+         write(fmt,'(A,I3,A,I3,A,I3,A)')
+     +        '(a4,1x,a6,i5,1x,''"'',a,''"'',1x,e16.8,1x,i3,',
+     >        max(nlmata,1),
+     >        '(1x,e16.8),',max(nlmata,1),'(1x,e16.8),',
+     >        max(nlmata,1),'(1x,e16.8))'
+         write(lunlist,fmt)
+     +        context, rname, imate, name, dens,
+     +        nlmat, 
+     +        (a(k), k=1,abs(nlmat)),
+     +        (z(k), k=1,abs(nlmat)),
+     +        (wmat(k), k=1,abs(nlmat))
+      endif
+      if (luncode.ne.0) then
+         write(luncode,'(''{'')')
+         call rtocp('dens',dens)
+         call artocp('aa',a,abs(nlmat))
+         call artocp('zz',z,abs(nlmat))
+         call artocp('wmat',wmat,abs(nlmat))
+         write(luncode,1000) imate,name,nlmat
+ 1000    format('G4gsmixt(imate=',i5,',name="',a,
+     +        '",aa,zz,dens,nlmat=',i3,',wmat);')
+         write(luncode,'(''}'')')
+      endif
+*     
+      end
+*     
+#ifndef CALL_GEANT
+      subroutine gstmed(
+     +     itmed, name, nmat, isvol, ifield, fieldm,
+     +     tmaxfd, stemax, deemax, epsil, stmin, ubuf, nwbuf)
+#else 
+      subroutine Kstmed(
+     +     itmed, name, nmat, isvol, ifield, fieldm,
+     +     tmaxfd, stemax, deemax, epsil, stmin, ubuf, nwbuf)
+#endif
+************************************************************************
+************************************************************************
+      implicit none
+      character name*(*)
+      integer itmed, nmat, isvol, ifield, nwbuf, k
+      real fieldm, tmaxfd, stemax, deemax, epsil, stmin, ubuf(nwbuf)
+      character rname*6, fmt*150
+#include "G3toG4.inc"
+      data rname /'GSTMED'/
+*     
+      call check_lines
+#ifdef CALL_GEANT
+      if (dogeom) call gstmed(
+     +     itmed, name, nmat, isvol, ifield, fieldm,
+     +     tmaxfd, stemax, deemax, epsil, stmin, ubuf, nwbuf)
+#endif
+      if (lunlist.ne.0) then
+*         write(lunlist,
+*     +        '(a4,1x,a6,i5,1x,''"'',a,''"'',3i3,6e15.8,i3,<nwbuf>e15.8)')
+*     +        context, rname, itmed, name, nmat, isvol, ifield, fieldm,
+*     +        tmaxfd, stemax, deemax, epsil, stmin,
+*     +        nwbuf, (ubuf(k),k=1,nwbuf)
+         write(fmt,'(A,I3,A)') 
+     >        '(a4,1x,a6,i5,1x,''"'',a,''"'',3i3,6(1x,e16.8),i3,',
+     >        max(nwbuf,1),'(1x,e16.8))'
+         write(lunlist,fmt)
+     +        context, rname, itmed, name, nmat, isvol, ifield, fieldm,
+     +        tmaxfd, stemax, deemax, epsil, stmin,
+     +        nwbuf, (ubuf(k),k=1,nwbuf)
+      endif
+      if (luncode.ne.0) then
+         write(luncode,'(''{'')')
+         call rtocp('fieldm',fieldm)
+         call rtocp('tmaxfd',tmaxfd)
+         call rtocp('stemax',stemax)
+         call rtocp('deemax',deemax)
+         call rtocp('epsil',epsil)
+         call rtocp('stmin',stmin)
+         call g3ldpar(ubuf,nwbuf)
+         write(luncode,1000) itmed,name,nmat,isvol,ifield,nwbuf
+ 1000    format('G4gstmed(itmed=',i4,',name="',a,'",nmat=',i4,
+     +        ',isvol=',i2,',ifield=',i2,',',/
+     +        '    fieldm,tmaxfd,stemax,deemax,epsil,stmin,par,npar=',
+     +        i4,');')
+         write(luncode,'(''}'')')
+      endif
+*     
+      end
+*     
+#ifndef CALL_GEANT
+      subroutine gstpar(itmed, chpar, parval)
+#else 
+      subroutine Kstpar(itmed, chpar, parval)
+#endif
+************************************************************************
+************************************************************************
+      implicit none
+      character chpar*(*)
+      integer itmed
+      real parval
+      character rname*6
+#include "G3toG4.inc"
+      data rname /'GSTPAR'/
+*     
+      call check_lines
+#ifdef CALL_GEANT
+      if (dogeom) call gstpar (itmed, chpar, parval)
+#endif
+      if (lunlist.ne.0) then
+         write(lunlist,
+     +        '(a4,1x,a6,i5,1x,a4,(1x,e16.8))')
+     +        context, rname, itmed, chpar, parval
+      endif
+      if (luncode.ne.0) then
+         write(luncode,'(''{'')')
+         write(luncode,1000) itmed, chpar, parval
+ 1000    format('G4gstpar(itmed=',i4,',chpar="',a,'",parval=',
+     +        (1x,e16.8),');')
+         write(luncode,'(''}'')')
+      endif
+*     
+      end
+*     
+#ifndef CALL_GEANT
+      subroutine gspart(
+     +     ipart, chpar, itrtyp, amass, charge, tlife, ub, nwb)
+#else 
+      subroutine Kspart(
+     +     ipart, chpar, itrtyp, amass, charge, tlife, ub, nwb)
+#endif
+************************************************************************
+************************************************************************
+      implicit none
+      character chpar*(*)
+      integer ipart, itrtyp, nwb, k
+      real amass, charge, tlife, ub(nwb)
+      character rname*6, fmt*150
+#include "G3toG4.inc"
+      data rname /'GSPART'/
+*     
+      call check_lines
+#ifdef CALL_GEANT
+      if (dogeom) call gspart(
+     +     ipart, chpar, itrtyp, amass, charge, tlife, ub, nwb)
+#endif
+      if (lunlist.ne.0) then
+*         write(lunlist,
+*     +        '(a4,1x,a6,i5,1x,''"'',a,''"'',i3,3e15.8,i3,<nwb>e15.8)')
+*     +        context, rname, ipart, chpar, itrtyp, amass, charge, tlife,
+*     +        nwb, (ub(k), k=1,nwb)
+         write(fmt,'(A,I3,A)') 
+     >        '(a4,1x,a6,i5,1x,''"'',a,''"'',i3,3(1x,e16.8),i3,',        
+     >        max(nwb,1),'(1x,e16.8))'
+         write(lunlist,fmt)
+     +        context, rname, ipart, chpar, itrtyp, amass, charge, 
+     >        tlife,
+     +        nwb, (ub(k), k=1,nwb)
+      endif
+      if (luncode.ne.0) then
+         write(luncode,'(''{'')')
+         call rtocp('amass',amass)
+         call rtocp('charge',charge)
+         call rtocp('tlife',tlife)
+         call g3ldpar(ub,nwb)
+         write(luncode,1000) ipart,chpar,itrtyp,nwb
+ 1000    format('G4gspart(ipart=',i8,',chpar="',a,'",itrtyp=',i8,
+     +        ',amass,charge,'/'         tlife,par,npar=',i4,');')
+         write(luncode,'(''}'')')
+      endif
+*     
+      end
+*     
+#ifndef CALL_GEANT
+      subroutine gsdk(ipart, bratio, mode)
+#else 
+      subroutine Ksdk(ipart, bratio, mode)
+#endif
+************************************************************************
+************************************************************************
+      implicit none
+      integer ipart, mode(6)
+      real bratio(6)
+      character rname*6
+#include "G3toG4.inc"
+      data rname /'GSDK  '/
+*     
+      call check_lines
+#ifdef CALL_GEANT
+      if (dogeom) call gsdk(ipart, bratio, mode)
+#endif
+      if (lunlist.ne.0) then
+***   6 is prefixed to the arrays for consistency with other
+***   array treatments (count precedes the array)
+         write(lunlist,
+     +        '(a4,1x,a6,i5,i3,6(1x,e16.8),6i8)')
+     +        context, rname, ipart, 6, bratio, mode
+      endif
+      if (luncode.ne.0) then
+         write(luncode,'(''{'')')
+         call artocp('bratio',bratio,6)
+         call aitocp('mode',mode,6)
+         write(luncode,1000) ipart
+ 1000    format('G4gsdk(ipart=',i8,',bratio,mode);')
+         write(luncode,'(''}'')')
+      endif
+*     
+      end
+*     
+#ifndef CALL_GEANT
+      subroutine gsdet(chset, chdet, nv, chnam, nbits, idtyp, nwhi,
+     +     nwdi, iset, idet)
+#else 
+      subroutine Ksdet(chset, chdet, nv, chnam, nbits, idtyp, nwhi,
+     +     nwdi, iset, idet)
+#endif
+************************************************************************
+************************************************************************
+      implicit none
+      integer nv, nbits(nv), idtyp, nwhi, nwdi, iset, idet, k
+      character rname*6, chset*4, chdet*4, chnam(nv)*4, fmt*150
+#include "G3toG4.inc"
+      data rname /'GSDET '/
+*     
+      call check_lines
+#ifdef CALL_GEANT
+      if (dogeom) call gsdet(chset, chdet, nv, chnam, nbits, idtyp,
+     +     nwhi, nwdi, iset, idet)
+#endif
+      if (lunlist.ne.0) then
+*         write(lunlist,
+*     +        '(a4,1x,a6,1x,a4,1x,a4,i5,<nv>(1x,a4),<nv>i10,i10,2i5)')
+*     +        context, rname, chset, chdet, nv, (chnam(k), k=1,nv),
+*     +        (nbits(k), k=1,nv), idtyp, nwhi, nwdi
+         write(fmt,'(A,I3,A,I3,A)')'(a4,1x,a6,1x,a4,1x,a4,i5,',
+     >        max(nv,1),'(1x,a4),',max(nv,1),'i10,i10,2i5)'
+         write(lunlist,fmt)
+     +        context, rname, chset, chdet, nv, (chnam(k), k=1,nv),
+     +        (nbits(k), k=1,nv), idtyp, nwhi, nwdi
+      endif
+      if (luncode.ne.0) then
+         write(luncode,'(''{'')')
+         call astocp('chnam',chnam,nv)
+         call aitocp('nbits',nbits,nv)
+         write(luncode,1000) chset, chdet, nv, idtyp, nwhi, nwdi
+ 1000    format('G4gsdet(chset="',a,'",chdet="',a,'",nv=',i3,
+     +        ',chnam,nbits,idtyp=',i8,','/
+     +        '        nwhi=',i8,',nwdi=',i8,');')
+         write(luncode,'(''}'')')
+      endif
+*     
+      end
+*     
+#ifndef CALL_GEANT
+      subroutine gsdetv(chset, chdet, idtyp, nwhi, nwdi, iset, idet)
+#else 
+      subroutine Ksdetv(chset, chdet, idtyp, nwhi, nwdi, iset, idet)
+#endif
+************************************************************************
+************************************************************************
+      implicit none
+      integer idtyp, nwhi, nwdi, iset, idet
+      character rname*6, chset*4, chdet*4
+#include "G3toG4.inc"
+      data rname /'GSDETV'/
+*     
+      call check_lines
+#ifdef CALL_GEANT
+      if (dogeom) call gsdetv(chset, chdet, idtyp,
+     +     nwhi, nwdi, iset, idet)
+#endif
+      if (lunlist.ne.0) then
+         write(lunlist,
+     +        '(a4,1x,a6,1x,a4,1x,a4,i10,2i5)')
+     +        context, rname, chset, chdet, idtyp, nwhi, nwdi
+      endif
+      if (luncode.ne.0) then
+         write(luncode,'(''{'')')
+         write(luncode,1000) chset, chdet, idtyp, nwhi, nwdi
+ 1000    format('G4gsdetv(chset="',a,'",chdet="',a,'",idtyp=',i8,
+     +        ',nwhi=',i8,',nwdi=',i8,');')
+         write(luncode,'(''}'')')
+      endif
+*     
+      end
+*     
+#ifndef CALL_GEANT
+      subroutine gsdeta(chset, chdet, chali, nwhi, nwdi, iali)
+#else 
+      subroutine Ksdeta(chset, chdet, chali, nwhi, nwdi, iali)
+#endif
+************************************************************************
+************************************************************************
+      implicit none
+      integer nwhi, nwdi, iali
+      character rname*6, chset*4, chdet*4, chali*4
+#include "G3toG4.inc"
+      data rname /'GSDETA'/
+*     
+      call check_lines
+#ifdef CALL_GEANT
+      if (dogeom) call gsdeta(chset, chdet, chali, nwhi, nwdi, iali)
+#endif
+      if (lunlist.ne.0) then
+         write(lunlist,
+     +        '(a4,1x,a6,1x,a4,1x,a4,1x,a4,2i5)')
+     +        context, rname, chset, chdet, chali, nwhi, nwdi
+      endif
+      if (luncode.ne.0) then
+         write(luncode,'(''{'')')
+         write(luncode,1000) chset, chdet, chali, nwhi, nwdi
+ 1000    format('G4gsdeta(chset="',a,'",chdet="',a,'",chali="',a,
+     +        '",nwhi=',i8,',nwdi=',i8,');')
+         write(luncode,'(''}'')')
+      endif
+*     
+      end
+*     
+#ifndef CALL_GEANT
+      subroutine gsdeth(chset, chdet, nh, chnam, nbits, orig, fact)
+#else 
+      subroutine Ksdeth(chset, chdet, nh, chnam, nbits, orig, fact)
+#endif
+************************************************************************
+************************************************************************
+      implicit none
+      integer nh, nbits(nh), k
+      real orig(nh), fact(nh)
+      character rname*6, chset*4, chdet*4, chnam(nh)*4, fmt*150
+#include "G3toG4.inc"
+      data rname /'GSDETH'/
+*     
+      call check_lines
+#ifdef CALL_GEANT
+      if (dogeom) call gsdeth(chset, chdet, nh, chnam, nbits,
+     +     orig, fact)
+#endif
+      if (lunlist.ne.0) then
+*         write(lunlist,
+*     +        '(a4,1x,a6,1x,a4,1x,a4,i5,<nh>(1x,a4),<nh>i5,<nh>e15.8,
+*     +        <nh>e15.8)')
+*     +        context, rname, chset, chdet, nh, (chnam(k), k=1,nh),
+*     +        (nbits(k), k=1,nh), (orig(k), k=1,nh), (fact(k), k=1,nh)
+         write(fmt,'(A,I3,A,I3,A,I3,A,I3,A)')
+     >        '(a4,1x,a6,1x,a4,1x,a4,i5,',max(nh,1),'(1x,a4),',
+     >        max(nh,1),'i5,',max(nh,1),'(1x,e16.8),',max(nh,1),
+     >        '(1x,e16.8))'
+         write(lunlist, fmt)
+     +        context, rname, chset, chdet, nh, (chnam(k), k=1,nh),
+     +        (nbits(k), k=1,nh), (orig(k), k=1,nh), (fact(k), k=1,nh)
+      endif
+      if (luncode.ne.0) then
+         write(luncode,'(''{'')')
+         call astocp('chnam',chnam,nh)
+         call aitocp('nbits',nbits,nh)
+         call artocp('orig',orig,nh)
+         call artocp('fact',fact,nh)
+         write(luncode,1000) chset,chdet,nh
+ 1000    format('G4gsdeth(chset="',a,'",chdet="',a,'",nh=',i4,
+     +        ',chnam,nbits,orig,fact);')
+         write(luncode,'(''}'')')
+      endif
+*     
+      end
+*     
+#ifndef CALL_GEANT
+      subroutine gsdetd(chset, chdet, nd, chnam, nbits)
+#else 
+      subroutine Ksdetd(chset, chdet, nd, chnam, nbits)
+#endif
+************************************************************************
+************************************************************************
+      implicit none
+      integer nd, nbits(nd), k
+      character rname*6, chset*4, chdet*4, chnam(nd)*4, fmt*150
+#include "G3toG4.inc"
+      data rname /'GSDETD'/
+*     
+      call check_lines
+#ifdef CALL_GEANT
+      if (dogeom) call gsdetd(chset, chdet, nd, chnam, nbits)
+#endif
+      if (lunlist.ne.0) then
+*         write(lunlist,
+*     +        '(a4,1x,a6,1x,a4,1x,a4,i5,<nd>(1x,a4),<nd>i5)')
+*     +        context, rname, chset, chdet, nd, (chnam(k), k=1,nd),
+*     +        (nbits(k), k=1,nd)
+         write(fmt,'(A,I3,A,I3,A)')
+     +        '(a4,1x,a6,1x,a4,1x,a4,i5,',max(nd,1),'(1x,a4),',
+     >        max(nd,1),'i5)'
+         write(lunlist,fmt)
+     +        context, rname, chset, chdet, nd, (chnam(k), k=1,nd),
+     +        (nbits(k), k=1,nd)
+      endif
+      if (luncode.ne.0) then
+         write(luncode,'(''{'')')
+         call astocp('chnam',chnam,nd)
+         call aitocp('nbits',nbits,nd)
+         write(luncode,1000) chset, chdet, nd
+ 1000    format('G4gsdetd(chset="',a,'",chdet="',a,'",nd=',i4,
+     +        ',chnam,nbits);')
+         write(luncode,'(''}'')')
+      endif
+*     
+      end
+*     
+#ifndef CALL_GEANT
+      subroutine gsdetu(chset, chdet, nupar, upar)
+#else 
+      subroutine Ksdetu(chset, chdet, nupar, upar)
+#endif
+************************************************************************
+************************************************************************
+      implicit none
+      integer nupar, k
+      real upar(nupar)
+      character rname*6, chset*4, chdet*4, fmt*150
+#include "G3toG4.inc"
+      data rname /'GSDETU'/
+*     
+      call check_lines
+#ifdef CALL_GEANT
+      if (dogeom) call gsdetu(chset, chdet, nupar, upar)
+#endif
+      if (lunlist.ne.0) then
+*         write(lunlist,
+*     +        '(a4,1x,a6,1x,a4,1x,a4,i5,<nupar>e15.8)')
+*     +        context, rname, chset, chdet, nupar, (upar(k), k=1,nupar)
+         write(fmt,'(A,I3,A)')
+     +        '(a4,1x,a6,1x,a4,1x,a4,i5,',max(nupar,1),'(1x,e16.8))'
+         write(lunlist,fmt)
+     +        context, rname, chset, chdet, nupar, (upar(k), k=1,nupar)
+      endif
+      if (luncode.ne.0) then
+         write(luncode,'(''{'')')
+         call g3ldpar(upar,nupar)
+         write(luncode,1000) chset, chdet, nupar
+ 1000    format('G4gsdetu(chset="',a,'",chdet="',a,'",npar=',
+     +        i4,',par);')
+         write(luncode,'(''}'')')
+      endif
+*     
+      end
+*     
+#ifndef CALL_GEANT
+      subroutine ggclos
+#else 
+      subroutine kgclos
+#endif
+************************************************************************
+************************************************************************
+      implicit none
+      character rname*6
+#include "G3toG4.inc"
+      data rname /'GGCLOS'/
+*     
+      call check_lines
+#ifdef CALL_GEANT
+      if (dogeom) call ggclos
+#endif
+      if (lunlist.ne.0) then
+         write(lunlist,'(a4,1x,a6)') context, rname
+         close(lunlist)
+      endif
+      if (luncode.ne.0) then
+         write(luncode,'(''//GeoMgr->CloseGeometry();'')')
+         write(luncode,'(''}'')')
+         call g3main
+         close(luncode)
+      endif
+*     
+      end
+
+      subroutine checkshape(name, shape, par, npar)
+      implicit none
+************************************************************************
+* convert TRAP, PARA and GTRA to external form
+************************************************************************
+      character name*4, shape*4
+      real ph, par(*), tt, raddeg
+      integer npar
+      
+      raddeg = 180./3.1415926
+
+      if (shape(1:3).eq.'BOX'.and.npar.ne.3) then
+         print *,'!! error, BOX with ',npar,' parameters, vol ',name
+      endif
+      if (shape.eq.'TRD1'.and.npar.ne.4) then
+         print *,'!! error, TRD1 with ',npar,' parameters, vol ',name
+      endif
+      if (shape.eq.'TRD2'.and.npar.ne.5) then
+         print *,'!! error, TRD2 with ',npar,' parameters, vol ',name
+      endif
+      if (shape.eq.'TRAP'.and.npar.ne.35.and.npar.ne.11) then
+***   G3 sets 11 to 35. Why?
+         print *,'!! error, TRAP with ',npar,' parameters, vol ',name
+      endif
+      if (shape.eq.'TUBE'.and.npar.ne.3) then
+         print *,'!! error, TUBE with ',npar,' parameters, vol ',name
+      endif
+      if (shape.eq.'TUBS'.and.npar.ne.5) then
+         print *,'!! error, TUBS with ',npar,' parameters, vol ',name
+      endif
+      if (shape.eq.'CONE'.and.npar.ne.5) then
+         print *,'!! error, CONE with ',npar,' parameters, vol ',name
+      endif
+      if (shape.eq.'CONS'.and.npar.ne.7) then
+         print *,'!! error, CONS with ',npar,' parameters, vol ',name
+      endif
+      if (shape.eq.'SPHE'.and.npar.ne.6) then
+         print *,'!! error, SPHE with ',npar,' parameters, vol ',name
+      endif
+      if (shape.eq.'PARA'.and.npar.ne.6) then
+         print *,'!! error, PARA with ',npar,' parameters, vol ',name
+      endif
+      if (shape.eq.'PARA') then
+*
+*  **    PARA
+*
+         ph = 0.
+         if (par(5).ne.0.) ph = atan2(par(6),par(5))*raddeg
+         tt = sqrt(par(5)**2+par(6)**2)
+         par(4) = atan(par(4))*raddeg
+         if (par(4).gt.90.0) par(4) = par(4)-180.0
+         par(5) = atan(tt)*raddeg
+         if (ph.lt.0.0) ph = ph + 360.0
+         par(6) = PH
+      end if
+      if (shape.eq.'TRAP') then
+*
+*  **    TRAP
+*
+         npar=11
+         ph = 0.
+         if (par(2).ne.0.) ph = atan2(par(3),par(2))*raddeg
+         tt = sqrt(par(2)**2+par(3)**2)
+         par(2) = atan(tt)*raddeg
+         if (ph.lt.0.0) ph = ph+360.0
+         par(3) = ph
+         par(7) = atan(par(7))*raddeg
+         if (par(7).gt.90.0) par(7) = par(7)-180.0
+         par(11)= atan(par(11))*raddeg
+         if (par(11).gt.90.0) par(11) = par(11)-180.0
+
+      end if
+      end
Index: /trunk/source/g3tog4/src/g3test.F.main
===================================================================
--- /trunk/source/g3tog4/src/g3test.F.main	(revision 817)
+++ /trunk/source/g3tog4/src/g3test.F.main	(revision 817)
@@ -0,0 +1,77 @@
+*     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: g3test.F.main,v 1.2 1999/12/05 17:50:16 gcosmo Exp $
+*     GEANT4 tag $Name:  $
+*    
+*
+*       g3test
+*
+*       Test G3toG4 Geant3 -> Geant4 geometry code convertor
+*
+      implicit none
+      real par(20), bratio(6)
+      integer npar, i, ivol, mode(6), idum
+      character*4 charray(10)
+      integer iarray(10)
+      npar = 3
+      do i=1,3
+        par(i) = i**2
+      enddo
+      call G3toG4(10,11,' ')
+      call g3context('TRAK')
+      call gsmate(1,'material 1',16.,8.,1.001,.0002,.3,par,3)
+      call gstmed(1,'muon med',1,1,2,1.5,5.,.3,.001,.00001,
+     +  .0000001, par, 3)
+      call gsmixt(2,'mixture 2',16.,8.,.77,-3,par)
+      call gsvolu('NAM1','BOX ', 1, par, npar, ivol)
+      call gsmate(3,'material 3',16.,8.,1.001,.0002,.3,par,3)
+      call gstmed(2,'trak med',3,1,2,1.5,5.,.3,.001,.00001,
+     +  .0000001, par, 3)
+      call gsmixt(4,'mixture 4',16.,8.,.77,3,par)
+      call gsvolu('NAM2','TUBS', 2, par, npar, ivol)
+      call gsvolu('NAM3','TUBS', 2, par, npar, ivol)
+      call gsvolu('NAM4','TUBS', 2, par, npar, ivol)
+      call gsvolu('NAM5','TUBS', 2, par, npar, ivol)
+      call gsvolu('NAM6','TUBS', 2, par, npar, ivol)
+      call gspos('NAM2', 3, 'NAM1', 10., 20., 30., 0, 'ONLY')
+c      call gsposp('NAMP', 3, 'MOTH', 10., 20., 30., 99, 'ONLY',
+c     +  par, npar)
+      call gsatt('NAM1', 'COLO', 66)
+      call gsrotm(44, 90., 91., 180., 181., -270., -271.)
+      call gsdvn('NDVN','NAM2',22,3)
+      call gsdvt('NDV2','NAM3',2.,1,-1,20)
+      call gsdvx('NDV3','NAM4',6,3,2.,0.,2,20)
+      call gsdvn2('NDV4','NAM5',6,3,0.,2)
+      call gsdvt2('NDV5','NAM5',1.5,1,0.,2,20)
+      call gstpar(33,'PHOT',2.)
+      call gspart(22,'particle',8,91.14,0.,1.e-24,0.,0)
+      bratio(1)=1.1
+      bratio(2)=2.2
+      bratio(3)=3.3
+      bratio(4)=4.4
+      bratio(5)=5.5
+      bratio(6)=6.6
+      mode(1)=101
+      mode(2)=202
+      mode(3)=303
+      mode(4)=404
+      mode(5)=505
+      mode(6)=606
+      call gsdk(22,bratio,mode)
+      charray(1) = 'Hit1'
+      charray(2) = 'Hit2'
+      iarray(1) = 1
+      iarray(2) = 2
+      call gsdet('DETT','SETT',2,charray,iarray,1001,4,4,idum,idum)
+      call gsdetv('DETT','SETT',1001,4,4,idum,idum)
+      call gsdeta('DETT','SETT', 'ALIA', 4,4,idum)
+      call gsdeth('DETT','SETT',1,'Hit1',16,0.,.01)
+      call gsdetd('DETT','SETT',1,'Digi',16)
+      call gsdetu('DETT','SETT',3,par)
+      call ggclos
+      end
Index: /trunk/source/g3tog4/src/g3tog4.F
===================================================================
--- /trunk/source/g3tog4/src/g3tog4.F	(revision 817)
+++ /trunk/source/g3tog4/src/g3tog4.F	(revision 817)
@@ -0,0 +1,320 @@
+*    
+*     ********************************************************************
+*     * License and Disclaimer                                           *
+*     *                                                                  *
+*     * The  Geant4 software  is  copyright of the Copyright Holders  of *
+*     * the Geant4 Collaboration.  It is provided  under  the terms  and *
+*     * conditions of the Geant4 Software License,  included in the file *
+*     * LICENSE and available at  http://cern.ch/geant4/license .  These *
+*     * include a list of copyright holders.                             *
+*     *                                                                  *
+*     * 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.  Please see the license in the file  LICENSE  and URL above *
+*     * for the full disclaimer and the limitation of liability.         *
+*     *                                                                  *
+*     * This  code  implementation is the result of  the  scientific and *
+*     * technical work of the GEANT4 collaboration.                      *
+*     * By using,  copying,  modifying or  distributing the software (or *
+*     * any work based  on the software)  you  agree  to acknowledge its *
+*     * use  in  resulting  scientific  publications,  and indicate your *
+*     * acceptance of all terms of the Geant4 Software license.          *
+*     ********************************************************************
+*    
+*    
+*     $Id: g3tog4.F,v 1.5 2006/06/29 18:15:12 gunter Exp $
+*     GEANT4 tag $Name:  $
+*    
+*
+*       G3toG4
+*
+*       Package to convert Geant3 Fortran geometry code to a call list
+*       file to be interpreted by the Geant4 geometry call list
+*       interpreter, or alternatively, directly to Geant4 code.
+*
+*       This set of routines is to be linked in front of, so overriding,
+*       the standard Geant library.
+*
+*       It is possible to execute the Geant calls while at the same
+*       time building the call list/Geant4 code. In order to do this,
+*       these routines must occupy a different name space to that of
+*       the real Geant routines. This is provided by the CALL_GEANT
+*       cpp flag. If these routines are compiled with this flag,
+*       the routine names begin with K rather than G. eg. GSVOLU
+*       becomes KSVOLU. Routine names in your source code must be so
+*       converted; a perl script is provided to do this. 
+*         $$$ provide the script
+*       Under normal circumstances it should *not* be necessary to go
+*       through this; it is only necessary if during the geometry
+*       generation process your code extracts information from Geant
+*       about material already generated.
+*
+*       Torre Wenaus, LLNL  6/95
+*
+*  To Do
+*  - option to divide generated Geant4 code into separate files/routines
+*    based on context
+*
+************************************************************************
+*
+      subroutine G3toG4(luni,lunc,chopt)
+************************************************************************
+*
+*       G3toG4
+*
+*       Initialization/setup routine
+*
+*       luni (call list), lunc (C++ code) logical unit numbers:
+*         lun>0: Open output file on unit lun. Filenames used:
+*             g3calls.dat      Call list file
+*             g4geom.cc        Geant4 C++ geometry code
+*         lun<0: File open has been done by the user. Just write to |lun|
+*         lun=0: Don't generate this output.
+*            ie.  luni=0:  Don't generate the call list
+*                 lunc=0:  Don't generate the Geant4 code
+*
+*       chopt options:
+*       'G'  execute the actual Geant calls as well as building the
+*            code/call list. In case users use info obtained from Geant
+*            during the geometry building process. THIS IS THE DEFAULT
+*            at present:
+#define CALL_GEANT
+*
+************************************************************************
+      implicit none
+      integer luni, lunc
+      character chopt*(*)
+#include "G3toG4.inc"
+*
+      print *,'Initializing Geant3 to Geant4 conversion'
+#ifdef CALL_GEANT
+c      dogeom = index(chopt,'G') + index(chopt,'g') .ne. 0
+      dogeom = .true.
+#else
+      dogeom = .false.
+#endif
+      context = '----'
+      if (luni.eq.0.and.lunc.eq.0) then
+        print *,'G3TOG4: No output requested by user. No output'//
+     +  ' will be generated.'
+      endif
+      lunlist = abs(luni)
+      luncode = abs(lunc)
+      if (lunlist.ne.0) then
+        doclist = .true.
+      else
+        doclist = .false.
+      endif
+      if (luncode.ne.0) then
+        docode = .true.
+      else
+        docode = .false.
+      endif
+***     If lun>0, open the file
+      if (lunlist.gt.0) then
+        open(unit=lunlist,file='g3calls.dat',status='unknown')
+      endif
+      if (luncode.gt.0) then
+        nfile = 1
+        call g3source
+      endif
+*
+      end
+*
+      subroutine g4init
+************************************************************************
+************************************************************************
+      implicit none
+#include "G3toG4.inc"
+*
+      if (luncode.ne.0) then
+        write(luncode,
+     + '(''//G4GeometryManager* GeoMgr = new G4GeometryManager();'')')
+*     call ctocp('void G3G4init();')
+      endif
+*
+      end
+*
+      subroutine g3header
+************************************************************************
+*
+************************************************************************
+      implicit none
+      call g4init
+      end
+
+      subroutine g3source
+************************************************************************
+*
+************************************************************************
+      implicit none
+#include "G3toG4.inc"
+      character fname*30
+      if (luncode.le.0) return
+      if (nfile.gt.1) write(luncode,'(''}'')')
+      close(luncode)
+      write (fname,'(''G3toG4code_'',i2.2,''.cc'')') nfile
+      open(unit=luncode,file=fname,status='unknown')
+      write(luncode,'(''#include "G3toG4.hh"'')')
+      if (nfile.eq.1) call g3header
+      write(luncode,'(/''void G3toG4code_'',i2.2,''()'')') nfile
+      write(luncode,'(''{'')')
+      call ctocp('// init to 0 avoids "unused" warnings')
+      call ctocp('G4int nd=0,nh=0,nv=0,imate=0,itmed=0,nmat=0,')
+      call ctocp(' isvol=0,ifield=0,nwhi=0,nwdi=0,idtyp=0,ipart=0,')
+      call ctocp(' itrtyp=0,nlmat=0,npar=0,ndvmx=0,numed=0,iaxis=0,')
+      call ctocp(
+     +     ' ndiv=0,irot=0,ival=0,num=0,nmed=0,nbits[100],mode[6];')
+      call ctocp('G4String chnam[100];')
+      call ctocp('G4String name="",moth="",attr="",only="",shape="";')
+      call ctocp('G4String chset="",chdet="",chali="",chpar="";')
+      call ctocp('G4double amass=0.,charge=0.,tlife=0.,parval=0.;')
+      call ctocp('G4double c0=0.,step=0.,a=0.,dens=0.,radl=0.,x=0.;')
+      call ctocp('G4double y=0.,z=0.,theta1=0.,phi1=0.,theta2=0.;')
+      call ctocp('G4double phi2=0.,theta3=0.,phi3=0.,fieldm=0.;')
+      call ctocp('G4double tmaxfd=0.,stemax=0.,deemax=0.,epsil=0.;')
+      call ctocp('G4double stmin=0.,par[100],fact[100],orig[100];')
+      call ctocp('G4double bratio[6],aa[100],zz[100],wmat[100];')
+      call ctocp('nbits[0]=mode[0]=0;chnam[0]="";par[0]=0.;')
+      call ctocp('fact[0]=orig[0]=bratio[0]=aa[0]=zz[0]=wmat[0]=0.;')      
+      call ctocp(' ')
+      if (nfile.eq.1) then
+*     call ctocp('G3G4init();')
+         call ctocp(' ')
+      endif
+      end
+
+      subroutine g3main
+************************************************************************
+************************************************************************
+      implicit none
+#include "G3toG4.inc"
+      integer i
+*
+      close(luncode)
+      open(unit=luncode,file='G3toG4code.cc',status='unknown')
+      do i=1,nfile
+        write(luncode,'('' void G3toG4code_'',i2.2,''();'')') i
+      enddo
+      call ctocp('void G3toG4code()')
+      call ctocp('{')
+      do i=1,nfile
+        write(luncode,'(''   G3toG4code_'',i2.2,''();'')') i
+      enddo
+      call ctocp('}')
+      close(luncode)
+      end
+
+      subroutine g3context(cntxt)
+************************************************************************
+*
+*       g3context
+*
+*       Set the current geometry code context. eg. context can be used
+*       to distinguish code for different subdetectors. The Geant4
+*       call list interpreter can then execute the code selectively for
+*       a particular context only, if desired. Spaces not allowed.
+*
+************************************************************************
+      implicit none
+      character*(*) cntxt
+#include "G3toG4.inc"
+      context = cntxt
+      end
+*
+      subroutine ctocp(string)
+************************************************************************
+************************************************************************
+      implicit none
+      character*(*) string
+#include "G3toG4.inc"
+      write (luncode,*) string
+      end
+*
+      subroutine rtocp(string,x)
+************************************************************************
+************************************************************************
+      implicit none
+      character*(*) string
+      real x
+#include "G3toG4.inc"
+      write(luncode,'(4x,a,'' = '',e14.8,'';'')')
+     +  string, x
+      end
+*
+      subroutine artocp(string,ax,n)
+************************************************************************
+************************************************************************
+      implicit none
+      character*(*) string
+      real ax(*)
+      integer n,i
+#include "G3toG4.inc"
+      do i=1,n
+        write(luncode,'(''    '',a,''['',i3,''] = '',e14.8,'';'')')
+     +    string, i-1, ax(i)
+      enddo
+      end
+*
+      subroutine aitocp(string,ai,n)
+************************************************************************
+************************************************************************
+      implicit none
+      character*(*) string
+      integer ai(*)
+      integer n,i
+#include "G3toG4.inc"
+      do i=1,n
+        write(luncode,'(''    '',a,''['',i3,''] = '',i10,'';'')')
+     +    string, i-1, ai(i)
+      enddo
+      end
+*
+      subroutine astocp(string,ac,n)
+************************************************************************
+************************************************************************
+      implicit none
+      character*(*) string, ac(*)
+      integer n,i
+#include "G3toG4.inc"
+c      write(luncode,'(''    G4String '',a,''['',i3,''];'')') string, n
+      do i=1,n
+        write(luncode,'(''    '',a,''['',i3,''] = "'',a,''";'')')
+     +    string, i-1, ac(i)
+      enddo
+      end
+*
+      subroutine g3ldpar(par,npar)
+************************************************************************
+*
+*       g3ldpar
+*
+************************************************************************
+      implicit none
+*
+      integer npar, i
+      real par(*)
+#include "G3toG4.inc"
+*
+      if (npar.gt.0) then
+        write(luncode,'(''    par['',i4,''] = '',e14.8,'';'')')
+     +    (i-1,par(i),i=1,npar)
+      endif
+      end
+*
+      subroutine check_lines
+************************************************************************
+************************************************************************
+      implicit none
+#include "G3toG4.inc"
+      if (luncode.ne.0) then
+        nlines = nlines +1
+        if (nlines.gt.maxlines) then
+          nfile = nfile +1
+          call g3source
+          nlines = 0
+        endif
+      endif
+      end
Index: /trunk/source/g3tog4/src/g4geom.cc.main
===================================================================
--- /trunk/source/g3tog4/src/g4geom.cc.main	(revision 817)
+++ /trunk/source/g3tog4/src/g4geom.cc.main	(revision 817)
@@ -0,0 +1,27 @@
+// 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: g4geom.cc.main,v 1.2 1999/12/05 17:50:17 gcosmo Exp $ 
+// GEANT4 tag $Name:  $ 
+//
+//   g4geom
+//
+//   Use the geometry code built by G3->G4 conversion to create the
+//   Geant4 geometry
+//
+//   T. Wenaus  LLNL  6/95
+//
+#include "G3toG4.hh"
+#include "G4GeometryManager.hh"
+void G3toG4code();
+void G3G4init();
+int main(int argc, char* argv[])
+{
+    G3toG4code();
+    G4GeometryManager::GetInstance()->CloseGeometry();
+    return 0;
+}
Index: /trunk/source/g3tog4/src/jshape.F
===================================================================
--- /trunk/source/g3tog4/src/jshape.F	(revision 817)
+++ /trunk/source/g3tog4/src/jshape.F	(revision 817)
@@ -0,0 +1,76 @@
+*    
+*     ********************************************************************
+*     * License and Disclaimer                                           *
+*     *                                                                  *
+*     * The  Geant4 software  is  copyright of the Copyright Holders  of *
+*     * the Geant4 Collaboration.  It is provided  under  the terms  and *
+*     * conditions of the Geant4 Software License,  included in the file *
+*     * LICENSE and available at  http://cern.ch/geant4/license .  These *
+*     * include a list of copyright holders.                             *
+*     *                                                                  *
+*     * 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.  Please see the license in the file  LICENSE  and URL above *
+*     * for the full disclaimer and the limitation of liability.         *
+*     *                                                                  *
+*     * This  code  implementation is the result of  the  scientific and *
+*     * technical work of the GEANT4 collaboration.                      *
+*     * By using,  copying,  modifying or  distributing the software (or *
+*     * any work based  on the software)  you  agree  to acknowledge its *
+*     * use  in  resulting  scientific  publications,  and indicate your *
+*     * acceptance of all terms of the Geant4 Software license.          *
+*     ********************************************************************
+*    
+*    
+*     $Id: jshape.F,v 1.4 2006/06/29 18:15:14 gunter Exp $
+*     GEANT4 tag $Name:  $
+*    
+*     
+*--   Author : Jouko Vuoskoski, CERN, Jouko.Vuoskoski@cern.ch
+*     
+      SUBROUTINE JSHAPE(RSHAPE,SHAPE)
+      implicit none
+      real rshape
+      integer ishape
+      CHARACTER*4      SHAPE
+
+      ishape = rshape
+      IF     (ISHAPE.EQ.1) THEN
+         SHAPE='BOX '
+      ELSEIF (ISHAPE.EQ.2) THEN
+         SHAPE='TRD1'
+      ELSEIF (ISHAPE.EQ.3) THEN
+         SHAPE='TRD2'
+      ELSEIF (ISHAPE.EQ.4) THEN
+         SHAPE='TRAP'
+      ELSEIF (ISHAPE.EQ.5) THEN
+         SHAPE='TUBE'
+      ELSEIF (ISHAPE.EQ.6) THEN
+         SHAPE='TUBS'
+      ELSEIF (ISHAPE.EQ.7) THEN
+         SHAPE='CONE'
+      ELSEIF (ISHAPE.EQ.8) THEN
+         SHAPE='CONS'
+      ELSEIF (ISHAPE.EQ.9) THEN
+         SHAPE='SPHE'
+      ELSEIF (ISHAPE.EQ.10) THEN
+         SHAPE='PARA'
+      ELSEIF (ISHAPE.EQ.11) THEN
+         SHAPE='PGON'
+      ELSEIF (ISHAPE.EQ.12) THEN
+         SHAPE='PCON'
+      ELSEIF (ISHAPE.EQ.13) THEN
+         SHAPE='ELTU'
+      ELSEIF (ISHAPE.EQ.14) THEN
+         SHAPE='HYPE'
+      ELSEIF (ISHAPE.EQ.28) THEN
+         SHAPE='GTRA'
+      ELSEIF (ISHAPE.EQ.29) THEN
+         SHAPE='CTUB'
+      ELSE
+         write(6,*)'(E) jshape: shape number ',ishape,' is unknown'
+         SHAPE=' '
+      ENDIF
+      END
Index: /trunk/source/g3tog4/src/mztog4.F
===================================================================
--- /trunk/source/g3tog4/src/mztog4.F	(revision 817)
+++ /trunk/source/g3tog4/src/mztog4.F	(revision 817)
@@ -0,0 +1,57 @@
+*    
+*     ********************************************************************
+*     * License and Disclaimer                                           *
+*     *                                                                  *
+*     * The  Geant4 software  is  copyright of the Copyright Holders  of *
+*     * the Geant4 Collaboration.  It is provided  under  the terms  and *
+*     * conditions of the Geant4 Software License,  included in the file *
+*     * LICENSE and available at  http://cern.ch/geant4/license .  These *
+*     * include a list of copyright holders.                             *
+*     *                                                                  *
+*     * 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.  Please see the license in the file  LICENSE  and URL above *
+*     * for the full disclaimer and the limitation of liability.         *
+*     *                                                                  *
+*     * This  code  implementation is the result of  the  scientific and *
+*     * technical work of the GEANT4 collaboration.                      *
+*     * By using,  copying,  modifying or  distributing the software (or *
+*     * any work based  on the software)  you  agree  to acknowledge its *
+*     * use  in  resulting  scientific  publications,  and indicate your *
+*     * acceptance of all terms of the Geant4 Software license.          *
+*     ********************************************************************
+*    
+*    
+*     $Id: mztog4.F,v 1.4 2006/06/29 18:15:16 gunter Exp $
+*     GEANT4 tag $Name:  $
+*    
+      subroutine mztog4
+************************************************************************
+*
+*       mztog4
+*
+*       Within a Geant3 program, call this routine to perform conversion
+*       to Geant4 on G3 data structures in memory.
+*
+*...  History:
+*     15-Jan-1997 Lockman : Put tog4 in a separate file
+************************************************************************
+      implicit none
+#include "G3toG4.inc"
+*
+***     conversion initialization
+      dogeom = .false.
+      context = '----'
+      lunlist = 98
+      open(unit=lunlist,file='g3calls.dat',status='unknown')
+      luncode = 99
+      nfile = 1
+      call g3source
+*
+***     do conversion
+      call tog4
+*
+      end
+*
Index: /trunk/source/g3tog4/src/rztog4.F
===================================================================
--- /trunk/source/g3tog4/src/rztog4.F	(revision 817)
+++ /trunk/source/g3tog4/src/rztog4.F	(revision 817)
@@ -0,0 +1,113 @@
+*    
+*     ********************************************************************
+*     * License and Disclaimer                                           *
+*     *                                                                  *
+*     * The  Geant4 software  is  copyright of the Copyright Holders  of *
+*     * the Geant4 Collaboration.  It is provided  under  the terms  and *
+*     * conditions of the Geant4 Software License,  included in the file *
+*     * LICENSE and available at  http://cern.ch/geant4/license .  These *
+*     * include a list of copyright holders.                             *
+*     *                                                                  *
+*     * 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.  Please see the license in the file  LICENSE  and URL above *
+*     * for the full disclaimer and the limitation of liability.         *
+*     *                                                                  *
+*     * This  code  implementation is the result of  the  scientific and *
+*     * technical work of the GEANT4 collaboration.                      *
+*     * By using,  copying,  modifying or  distributing the software (or *
+*     * any work based  on the software)  you  agree  to acknowledge its *
+*     * use  in  resulting  scientific  publications,  and indicate your *
+*     * acceptance of all terms of the Geant4 Software license.          *
+*     ********************************************************************
+*    
+*    
+*     $Id: rztog4.F,v 1.4 2006/06/29 18:15:18 gunter Exp $
+*     GEANT4 tag $Name:  $
+*    
+      program rztog4
+************************************************************************
+*
+*       rztog4
+*
+*       A standalone program to convert a Geant RZ initialization file
+*       (containing geometry, materials, etc.) to a Geant4 C++
+*       geometry.
+*
+*       Torre Wenaus, LLNL  6/95
+*
+*       todo:
+*       - attributes
+*
+*       JSHAPE routine of Jouko Vuoskoski, CERN employed. 
+*
+*...  History:
+*     15-Jan-1997 Lockman : put tog4 in a separate file
+************************************************************************
+      implicit none
+#include "G3toG4.inc"
+      integer iargc, lenocc, ln, lnout
+      character*256  file, ofile
+*
+      real h, q
+      integer nh, nz
+      parameter (nh=1000000, nz=2000000)
+      common/pawc/h(nh)
+      common/gcbank/q(nz)
+C
+      COMMON/GCUNIT/LIN,LOUT,NUNITS,LUNITS(5)
+      INTEGER LIN,LOUT,NUNITS,LUNITS
+      COMMON/GCMAIL/CHMAIL
+      CHARACTER*132 CHMAIL
+      logical lexist
+*
+      lout = 6
+*
+      if( iargc() .gt. 0 ) then
+        call getarg(1,file)
+        ln = lenocc(file)
+      else
+        print *,'rztog4 <rzfile> [ <call-list> ]'
+        print *,'<rzfile> : name of the ZEBRA rz file'
+        print *,'<call-list> : name of output call list file'
+        print *,'(def: g3calls.dat)'
+        print *,'You need to specify an rz file'
+        goto 999
+      endif
+
+      if (iargc() .gt. 1 ) then
+         call getarg(2,ofile)
+      else
+         ofile='g3calls.dat'
+      end if
+      inquire(file=file(:ln),exist=lexist)
+      if (.not.lexist) then
+         write(6,*) 'rz-file "',file(:ln),'" doesn''t exist.'
+         stop 1
+      end if
+*
+***     Geant/Zebra initialization
+      call gzebra(nz)
+      call gzinit
+      call grfile(90,file(:ln),'i')
+*
+***     conversion initialization
+      dogeom = .false.
+      context = '----'
+      lunlist = 98
+      lnout = lenocc(ofile)
+      open(unit=lunlist,file=ofile(:lnout),status='unknown')
+      print *,'Opened call list file ',ofile(:lnout)
+*
+      luncode = 99
+      luncode = 0
+      nfile = 1
+      call g3source
+*
+***     do conversion
+      call tog4
+*
+ 999  end
+
Index: /trunk/source/g3tog4/src/tog4.F
===================================================================
--- /trunk/source/g3tog4/src/tog4.F	(revision 817)
+++ /trunk/source/g3tog4/src/tog4.F	(revision 817)
@@ -0,0 +1,284 @@
+*    
+*     ********************************************************************
+*     * License and Disclaimer                                           *
+*     *                                                                  *
+*     * The  Geant4 software  is  copyright of the Copyright Holders  of *
+*     * the Geant4 Collaboration.  It is provided  under  the terms  and *
+*     * conditions of the Geant4 Software License,  included in the file *
+*     * LICENSE and available at  http://cern.ch/geant4/license .  These *
+*     * include a list of copyright holders.                             *
+*     *                                                                  *
+*     * 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.  Please see the license in the file  LICENSE  and URL above *
+*     * for the full disclaimer and the limitation of liability.         *
+*     *                                                                  *
+*     * This  code  implementation is the result of  the  scientific and *
+*     * technical work of the GEANT4 collaboration.                      *
+*     * By using,  copying,  modifying or  distributing the software (or *
+*     * any work based  on the software)  you  agree  to acknowledge its *
+*     * use  in  resulting  scientific  publications,  and indicate your *
+*     * acceptance of all terms of the Geant4 Software license.          *
+*     ********************************************************************
+*    
+*    
+*     $Id: tog4.F,v 1.5 2006/06/29 18:15:21 gunter Exp $
+*     GEANT4 tag $Name:  $
+*    
+      subroutine tog4
+************************************************************************
+*     
+*     tog4
+*     
+*     Perform the translation to G4
+*     
+************************************************************************
+      implicit none
+#include "gcbank.inc"
+      integer maxdivols
+      parameter (maxdivols=20000)
+      integer nvol, nrotm, nmate, ntmed, nset, i, jma, nmixt, k, nin,
+     >     jdiv, jd, iaxis, ivo, ndiv, numed, npar, natt, ivol, jin,
+     >     nparv, npard, nr, irot, konly, nwbuf, isvol, nmat, ifield,
+     >     nbits(5000), idtyp, nwhi, nwdi, iset, idet, j, in, jmx,
+     >     jdh, jdd, jdu, ndet, nn, nupar, npos, ndvol, ndivols, ii, 
+     >     npositioned, iia(10000), imate, smixt
+
+      real c0, step, x, y, z, a, dens, radl, absl, fact(5000), 
+     >     fieldm, tmaxfd, stemax, deemax, epsil, stmin, orig(5000), 
+     >     upar(5000)
+
+      character shape*4, name*4, dname*4, chonly*4, chmat*20, chtmed*20,
+     >     chset*4, chdet*4, chnms(5000)*4, divols(maxdivols)*4
+*     
+      npositioned = 0
+*     
+***   count materials and convert
+      call bankcnt(jmate,iia, nmate)
+      print *,'Materials: ',nmate
+      do imate=1,nmate
+         ii=iia(imate)
+         jma = lq(jmate-ii)
+         call uhtoc(iq(jma+1),4,chmat,20)
+         a = q(jma+6)
+         z = q(jma+7)
+         dens = q(jma+8)
+         radl = q(jma+9)
+         absl = q(jma+10)
+         nwbuf = iq(jma-1)-11
+         if (jma.gt.0) then
+            smixt=q(jma+11)
+            nmixt=abs(smixt)
+            if (nmixt.le.1) then
+               write(6,101) imate, chmat, a, z, dens, radl, absl
+               call ksmate(ii, chmat, a, z, dens, radl, absl,
+     >              q(jma+12), nwbuf)
+            else
+               jmx = lq(jma-5)
+               write(6,102) imate, chmat, a, z, dens, radl, absl,
+     >              (j,q(jmx+j),q(jmx+nmixt+j),q(jmx+2*nmixt+j), 
+     >              j=1,nmixt)
+               call ksmixt(ii, chmat, q(jmx+1), q(jmx+nmixt+1),
+     >              dens, smixt, q(jmx+2*nmixt+1))
+            end if
+         end if
+      enddo
+ 101  format(1x,i5,1x,A12,f6.2,f5.1,f8.2,2f9.2)
+ 102  format(1x,i5,1x,A12,f6.2,f5.1,f8.2,2f9.2,1x,i2, f6.2, f5.1, 
+     >     f6.2/(57x, i2, f6.2, f5.1, f6.2))
+*     
+***   count tracking media and convert
+      call bankcnt(jtmed,iia, ntmed)
+      print *,'Media: ',ntmed
+      do i=1,ntmed
+         ii=iia(i)
+         j = lq(jtmed-ii)
+         call uhtoc(iq(j+1),4,chtmed,20)
+         nmat = q(j+6)
+         isvol = q(j+7)
+         ifield = q(j+8)
+         fieldm = q(j+9)
+         tmaxfd = q(j+10)
+         stemax = q(j+11)
+         deemax = q(j+12)
+         epsil = q(j+13)
+         stmin = q(j+14)
+         nwbuf = iq(j-1) -14
+         call kstmed(ii,chtmed,nmat,isvol,ifield,fieldm,tmaxfd,stemax,
+     +        deemax,epsil,stmin,q(j+15),nwbuf)
+      enddo
+*     
+***   count rotation matrices and convert
+      call bankcnt(jrotm,iia, nrotm)
+      print *,'Rotms: ',nrotm
+      do i=1,nrotm
+         ii=iia(i) 
+         j = lq(jrotm-ii)
+         call ksrotm(ii,q(j+11),q(j+12),q(j+13),q(j+14),q(j+15),q(j+16))
+      enddo
+*     
+***   count volumes
+      npos = 0
+      call bankcnt(jvolum,iia, nvol)
+      print *,'Volumes: ',nvol
+***   pull out the names of the volumes which are subvolumes of
+***   divided volumes (gsvolu should not be called on these)
+      ndivols = 0
+      do i=1, nvol
+         ii=iia(i)
+         j = lq(jvolum-ii)
+         nin = q(j+3)
+         if (nin.lt.0) then
+            jdiv = lq(j-1)
+            ivo = q(jdiv+2)
+            call uhtoc(iq(jvolum+ivo),4,dname,4)
+            ndivols = ndivols +1
+            if (ndivols.gt.maxdivols) then
+               ndivols = maxdivols
+               print *,
+     +              '!!!ERROR!!! ndivols array exhausted. ',
+     +              'Too many divisions.'
+            endif
+            divols(ndivols) = dname
+         endif
+      enddo
+***   create the logical volumes (gsvolu)
+      ndvol = 0
+      do i=1, nvol
+         ii=iia(i)
+         j = lq(jvolum-ii)
+         call uhtoc(iq(jvolum+ii),4,name,4)
+         call jshape(q(j+2),shape)
+         nin = q(j+3)
+         numed = q(j+4)
+         npar = q(j+5)
+         natt = q(j+6)
+         do k=1, ndivols
+            if (divols(k).eq.name) then
+               ndvol = ndvol +1
+c     print *,'Division volume ',name,'; no gsvolu call.'
+               goto 11
+            endif
+         enddo
+         call ksvolu(name, shape, numed, q(j+7), npar, ivol)
+ 11      continue
+      enddo
+      print *,'Divided volumes: ',ndvol
+
+***   properties of the mother volume
+      call uhtoc(iq(jvolum+1),4,name,4)
+      j=lq(jvolum-1)
+      call jshape(q(j+2),shape)
+      print *,'mother volume: ',name,' shape: ',shape
+***   convert physical volumes
+      do i=1, nvol
+         ii=iia(i)
+         j = lq(jvolum-ii)
+         call uhtoc(iq(jvolum+ii),4,name,4)
+         nin = q(j+3)
+         numed = q(j+4)
+         npar = q(j+5)
+         if (nin.lt.0) then
+*     ! divided volume
+            jdiv = lq(j-1)
+            iaxis = q(jdiv+1)
+            ivo = q(jdiv+2)
+            call uhtoc(iq(jvolum+ivo),4,dname,4)
+            jd = lq(jvolum-ivo)
+            numed = q(jd+4)
+            ndiv = q(jdiv+3)
+            c0 = q(jdiv+4)
+            step = q(jdiv+5)
+            call ksdvn2(dname, name, ndiv, iaxis, c0, numed)
+         else if (nin.gt.0) then
+*     ! volume not divided. Handle positioning of daughter vols
+            do in=1, nin
+               jin = lq(j-in)
+               ivo = q(jin+2)
+               call uhtoc(iq(jvolum+ivo),4,dname,4)
+               jd = lq(jvolum-ivo)
+               nparv = q(jd+5)  ! NPAR declared in the GSVOLU call
+               nr = q(jin+3)
+               irot = q(jin+4)
+               x = q(jin+5)
+               y = q(jin+6)
+               z = q(jin+7)
+               konly = q(jin+8)
+               if (konly.ne.0) then
+                  chonly = 'ONLY'
+               else
+                  chonly = 'MANY'
+               endif
+               npard = iq(jin-1) -9
+               npositioned = npositioned +1
+               if (nparv.eq.0) then
+*     ! use GSPOSP
+                  call ksposp(dname, nr, name, x, y, z, irot, chonly,
+     +                 q(jin+10), npard)
+               else
+*     ! GSPOS
+                  call kspos(dname, nr, name, x, y, z, irot, chonly)
+               endif
+            enddo
+         endif
+      enddo
+*     
+***   count sensitive detectors
+      call bankcnt(jset,iia, nset)
+      print *,'Sets: ',nset
+      do i=1,nset
+         ii=iia(i)
+         j = lq(jset-ii)
+         call uhtoc(iq(jset+i),4,chset,4)
+         ndet = iq(j-1)
+         do k=1,ndet
+            jd = lq(j-k)
+            call uhtoc(iq(j+k),4,chdet,4)
+            call gfdet(chset, chdet, nn, chnms, nbits, idtyp,
+     +           nwhi, nwdi, iset, idet)
+            call ksdet(chset, chdet, nn, chnms, nbits, idtyp,
+     +           nwhi, nwdi, iset, idet)
+            jdh = lq(jd-1)
+            if (jdh.ne.0) then
+               call gfdeth(chset,chdet,nn,chnms,nbits,orig,fact)
+               call ksdeth(chset,chdet,nn,chnms,nbits,orig,fact)
+            endif
+            jdd = lq(jd-2)
+            if (jdd.ne.0) then
+               call gfdetd(chset,chdet,nn,chnms,nbits)
+               call ksdetd(chset,chdet,nn,chnms,nbits)
+            endif
+            jdu = lq(jd-3)
+            if (jdu.ne.0) then
+               call gfdetu(chset,chdet,100,nupar,upar)
+               call ksdetu(chset,chdet,nupar,upar)
+            endif
+         enddo
+      enddo
+      print *,'Positioned volumes (gspos, gsposp):',npositioned
+*     
+      call kgclos
+*     
+      end
+
+      subroutine bankcnt(link,iia,nbanks)
+************************************************************************
+************************************************************************
+      implicit none
+#include "gcbank.inc"
+      integer i, link, nbanks, iia(*)
+*     
+      nbanks=0
+      if (link.eq.0) return
+C*      do i=1,9999999
+      do i=1,iq(link-2)
+C*         if(lq(link-nbanks-1).eq.0.or.iq(link-2).eq.nbanks) goto 10
+         if(lq(link-i).ne.0)then
+           nbanks = nbanks +1
+           iia(nbanks)=i
+         endif
+      enddo
+ 10   continue
+      end
