--- /dev/null
+# $ Id: GNUmakefile,v 1.26 2001/02/12 08:17:31 gcosmo Exp $
+# -----------------------------------------------------------------
+# "gmake" makes default libraries for each subdomain.
+# "gmake global" makes global libraries for each subdomain.
+# Composite libraries are built.
+# "gmake includes" places header files .h/.hh in $G4INCLUDE
+# "gmake libmap" forces rebuilding of map-file for granular libraries.
+# "gmake clean_libs" removes just archive (.a) and shared (.so) libraries
+# of current platform installation.
+# "gmake clean" removes installation of current platform.
+# "gmake clean_all" removes all platforms installations.
+#
+# (The .o files(s) are made by implicit rules.)
+
+MAKEFLAGS= --no-print-directory
+
+SUBDIR1 = dummyG4 Wrappers
+
+ifndef FLUGGINSTALL
+ FLUGGINSTALL = ..
+endif
+
+include $(FLUGGINSTALL)/config/architecture.gmk
+G4BINDIR := $(G4BIN)/$(G4SYSTEM)
+G4LIBDIR := $(G4LIB)/$(G4SYSTEM)
+G4TMPDIR := $(G4TMP)/$(G4SYSTEM)
+unique := $(shell echo $$$$)
+
+.PHONY: all glob global libmap includes clean_libs clean clean_all
+
+all:
+ifdef G4USE_HEPODBMS
+ @$(ECHO) Making granular libraries with HepODBMS option ...
+ @for dir in $(SUBDIR4); do (cd $$dir && $(MAKE) cleandb); done;:
+ @if [ ! -f $(G4TMPDIR)/schema/G4SCHEMA ] ; then \
+ $(ECHO) "Temporary boot file does not exist. Stop." ; exit 1 ; \
+ fi
+endif
+ @for dir in $(SUBDIR1); do (cd $$dir && $(MAKE)); done;:
+ @for dir in $(SUBDIR2); do (cd $$dir && $(MAKE)); done;:
+ @for dir in $(SUBDIR3); do (cd $$dir && $(MAKE)); done;:
+ifdef G4USE_HEPODBMS
+ @for dir in $(SUBDIR4); do (cd $$dir && $(MAKE)); done;:
+endif
+ #$(MAKE) libmap
+
+glob global:
+ifdef G4USE_HEPODBMS
+ @$(ECHO) Making global libraries with HepODBMS option ...
+ @for dir in $(SUBDIR4); do (cd $$dir && $(MAKE) cleandb); done;:
+ @if [ ! -f $(G4TMPDIR)/schema/G4SCHEMA ] ; then \
+ $(ECHO) "Temporary boot file does not exist. Stop." ; exit 1 ; \
+ fi
+endif
+ @for dir in $(SUBDIR1); do (cd $$dir && $(MAKE) global); done;:
+ @for dir in $(SUBDIR2); do (cd $$dir && $(MAKE)); done;:
+ @for dir in $(SUBDIR3); do (cd $$dir && $(MAKE)); done;:
+ifdef G4USE_HEPODBMS
+ @for dir in $(SUBDIR4); do (cd $$dir && $(MAKE) global); done;:
+endif
+
+
+libmap: $(G4LIBDIR)/liblist
+ @echo "WARNING: Making a library map of granular libraries."
+ @echo " This is a list of libraries in order of use, and for"
+ @echo " each library a list of other libraries used."
+ @echo " To do this it needs a complete set of dependency"
+ @echo " files, e.g., after gmake in the source/ directory."
+ @echo "Searching $(FLUGGINSTALL)/source"
+ @echo ' for GNUmakefiles containing "name" and sorting...'
+ @find $(FLUGGINSTALL)/source \
+ -name GNUmakefile -exec $(GREP) -l '^ *name *:=' {} \; \
+ | sort \
+ > /tmp/G4_all_lib_makefiles.$(unique);
+ @echo "Weeding out /test[s]/, global level GNUmakefiles, etc..."
+ @for i in `cat /tmp/G4_all_lib_makefiles.$(unique)`; \
+ do \
+ echo $$i | $(GREP) -q '/tests\?/' || \
+ $(GREP) -q SUBDIR $$i || \
+ $(GREP) -q G4hepgeometry $$i || \
+ echo $$i >> /tmp/G4_granlib_makefiles.$(unique); \
+ done
+ @echo "Making libname.map starter file..."
+ @touch /tmp/G4libname.map.starter.$(unique);
+ @for i in `cat /tmp/G4_granlib_makefiles.$(unique)`; \
+ do \
+ $(GREP) '^ *name *:=' $$i | cut -d \ -f 3 \
+ >> /tmp/G4libname.map.starter.$(unique); \
+ echo $$i >> /tmp/G4libname.map.starter.$(unique); \
+ done
+ @echo "Making libname.map..."
+ @rm -f $(G4LIBDIR)/libname.map;
+ @G4TMP=$(G4TMP); export G4TMP; \
+ $(G4LIBDIR)/liblist -l -d $(G4TMPDIR) \
+ < /tmp/G4libname.map.starter.$(unique) \
+ > $(G4LIBDIR)/libname.map
+ @rm -f /tmp/G4_all_lib_makefiles.$(unique);
+ @rm -f /tmp/G4_granlib_makefiles.$(unique);
+ @rm -f /tmp/G4libname.map.starter.$(unique);
+
+$(G4LIBDIR)/liblist: $(FLUGGINSTALL)/config/liblist.c
+ @echo "Compiling liblist.c..."
+ @if [ ! -d $(G4LIBDIR) ] ; then mkdir $(G4LIBDIR) ;fi
+ $(CC) $(CCFLAGS) -o $(G4LIBDIR)/liblist $(FLUGGINSTALL)/config/liblist.c
+
+includes:
+ @echo Installing includes files in $(G4INCLUDE) ...
+ @for dir in $(SUBDIR1); do (cd $$dir && $(MAKE) $@); done
+ @for dir in $(SUBDIR2); do (cd $$dir && $(MAKE) $@); done
+ @for dir in $(SUBDIR3); do (cd $$dir && $(MAKE) $@); done
+
+clean_libs:
+ @echo Removing all libraries ...
+ @for dir in $(SUBDIR1); do (cd $$dir && $(MAKE) clean_libs); done
+ @for dir in $(SUBDIR2); do (cd $$dir && $(MAKE) clean_libs); done
+ @for dir in $(SUBDIR3); do (cd $$dir && $(MAKE) clean_libs); done
+ @rm -rf $(G4LIBDIR)/libname.map
+
+clean:
+ @echo Removing current $(G4SYSTEM) installation ...
+ @rm -rf $(G4TMPDIR)
+ @rm -rf $(G4LIBDIR)
+ @rm -rf $(G4BINDIR)
+ifdef CFRONT
+ @rm -rf $(G4TREP)
+endif
+
+# Pay _extremely_ attention before executing the following target !!
+#
+clean_all:
+ @echo Removing all installations ...
+ @echo Removing $(G4TMP) ...
+ @rm -rf $(G4TMP)
+ @echo Removing $(G4LIB) ...
+ @rm -rf $(G4LIB)
+ @echo Removing $(G4BIN) ...
+ @rm -rf $(G4BIN)
+ @echo Removing $(G4INCLUDE) ...
+ @rm -rf $(G4INCLUDE)
--- /dev/null
+# $Id$
+# --------------------------------------------------------------
+# GNUmakefile for materials library. Gabriele Cosmo, 18/9/96.
+# --------------------------------------------------------------
+
+name := FggWrappers
+
+ifndef FLUGGINSTALL
+ FLUGGINSTALL = ../..
+endif
+
+include $(FLUGGINSTALL)/config/architecture.gmk
+
+CPPFLAGS += -I$(G4BASE_G4)/global/management/include \
+ -I$(G4BASE_G4)/global/STLInterface \
+ -I$(G4BASE_G4)/global/HEPRandom/include \
+ -I$(G4BASE_G4)/global/HEPGeometry/include \
+ -I$(G4BASE_G4)/geometry/management/include \
+ -I$(G4BASE_G4)/geometry/volumes/include \
+ -I$(G4BASE_G4)/geometry/magneticfield/include \
+ -I$(G4BASE_G4)/materials/include \
+ -I$(G4BASE)/dummyG4/include \
+ -I$(G4BASE)/Wrappers/include
+
+include $(FLUGGINSTALL)/config/common.gmk
+
+.PHONY: global
+
+global: lib
+
--- /dev/null
+// $Id$
+// Flugg tag $Name$
+
+// modified 10/IX/99 for including preStepPoint
+// modified 28/IX/99 for delating allocated memory
+// modified 4/X/99 function FreeMemory
+// modified 2/III/00 base class G4TransportationManager included
+// modified 20/III/00 PrintHistories() included
+
+
+#ifndef FGeometryInit_h
+#define FGeometryInit_h 1
+
+#include "g4std/fstream"
+#include "g4std/iomanip"
+#include "globals.hh"
+
+#include "G4LogicalVolume.hh"
+#include "G4PhysicalVolumeStore.hh"
+#include "G4VPhysicalVolume.hh"
+#include "G4Material.hh"
+#include "G4MaterialTable.hh"
+#include "G4Isotope.hh"
+#include "G4Navigator.hh"
+#include "G4VUserDetectorConstruction.hh"
+#include "G4TouchableHistory.hh"
+#include "G4GeometryManager.hh"
+#include "G4FieldManager.hh"
+#include "G4UniformMagField.hh"
+#include "G4TransportationManager.hh"
+
+
+class FGeometryInit : public G4TransportationManager
+{
+ public:
+ ~FGeometryInit(); //destructor
+ static FGeometryInit *GetInstance();
+ G4Navigator *getNavigatorForTracking();
+ G4FieldManager * getFieldManager();
+ void setDetConstruction(G4VUserDetectorConstruction* detector);
+ void setDetector();
+ void setMotherVolume();
+ void createFlukaMatFile();
+ void closeGeometry();
+
+ void PrintHistories();
+ void InitHistories();
+ void DeleteHistories();
+ void UpdateHistories(const G4NavigationHistory *, const G4int &);
+ G4TouchableHistory * GetTouchableHistory();
+ G4TouchableHistory * GetOldNavHist();
+ G4TouchableHistory * GetTempNavHist();
+
+ void InitHistArray();
+ void DelHistArray();
+ G4int * GetHistArray();
+
+ void InitJrLtGeantArray();
+ G4int * GetJrLtGeantArray();
+ G4int GetLttcFlagGeant();
+ void SetLttcFlagGeant(G4int);
+ void PrintJrLtGeant();
+
+ private:
+ FGeometryInit(); //costructor
+ G4VUserDetectorConstruction * fDetector;
+ G4FieldManager * fFieldManager;
+ G4TransportationManager * fTransportationManager;
+ G4Navigator *fNavigatorForTracking;
+ static FGeometryInit *flagInstance;
+ G4VPhysicalVolume * myTopNode;
+ G4GeometryManager * ptrGeoMan;
+ G4int * ptrArray;
+ G4TouchableHistory * ptrTouchHist;
+ G4TouchableHistory * ptrOldNavHist;
+ G4TouchableHistory * ptrTempNavHist;
+ G4int * ptrJrLtGeant;
+ G4int flagLttcGeant;
+};
+
+#endif
--- /dev/null
+// $Id$
+// Flugg tag $Name$
+
+//
+// NavHistWithCount.hh - Sara Vanini
+// last modified 2/II/'99
+// This class stores a G4NavigationHistory and it adds to it a
+// counter for secondary particles.
+//
+//
+
+
+#ifndef NAVHISTWITHCOUNT_HH
+#define NAVHISTWITHCOUNT_HH
+
+#include "G4NavigationHistory.hh"
+
+
+class NavHistWithCount
+{
+public:
+ NavHistWithCount(const G4NavigationHistory &history);
+ ~NavHistWithCount();
+ void UpdateCount(G4int incrCount);
+ G4NavigationHistory* GetNavHistPtr();
+ G4int GetCount();
+ G4int GetDelateFlag();
+ G4int GetCheckInd();
+ void SaveCheckInd(G4int);
+
+private:
+ G4int count;
+ G4NavigationHistory * fhistory;
+ G4int fDelate;
+ G4int fCheck;
+};
+
+#include "NavHistWithCount.icc"
+
+#endif
+
+
+
--- /dev/null
+// $Id$
+// Flugg tag $Name$
+
+//
+// NavHistWithCount.icc - Sara Vanini
+// last modified: 2/II/1999
+//
+// NavHistWithCount.hh inline implementation
+//
+//
+
+inline NavHistWithCount::NavHistWithCount(const G4NavigationHistory &history)
+ {
+ G4cout << "NavHistWithCount::NavHistWithCount created" << G4endl;
+ fhistory = new G4NavigationHistory(history);
+ fDelate=0;
+ count=0;
+ }
+
+inline NavHistWithCount::~NavHistWithCount()
+ {
+ G4cout << "NavHistWithCount::NavHistWithCount deleted" << G4endl;
+ delete fhistory;
+ fDelate=1;
+ fhistory=0;
+ count=0;
+ }
+
+inline void NavHistWithCount::UpdateCount(G4int incrCount)
+ {
+ count=count+incrCount;
+ }
+
+inline G4NavigationHistory * NavHistWithCount::GetNavHistPtr()
+ {
+ return fhistory;
+ }
+
+inline G4int NavHistWithCount::GetCount()
+ {
+ return count;
+ }
+
+inline G4int NavHistWithCount::GetDelateFlag()
+ {
+ return fDelate;
+ }
+
+inline G4int NavHistWithCount::GetCheckInd()
+ {
+ return fCheck;
+ }
+
+inline void NavHistWithCount::SaveCheckInd(G4int index)
+ {
+ fCheck=index;
+ }
+
+
+
--- /dev/null
+// $Id$
+// Flugg tag $Name$
+
+///////////////////////////////////////////////////////////////////
+//
+// Interface for Flugg Wrappers
+//
+///////////////////////////////////////////////////////////////////
+
+#ifndef WRAPPERS_HH
+#define WRAPPERS_HH
+
+#include "globals.hh"
+
+#define idnrwr idnrwr_
+#define g1wr g1wr_
+#define g1rtwr g1rtwr_
+#define conhwr conhwr_
+#define inihwr inihwr_
+#define jomiwr jomiwr_
+#define lkdbwr lkdbwr_
+#define lkfxwr lkfxwr_
+#define lkmgwr lkmgwr_
+#define lkwr lkwr_
+#define magfld magfld_
+#define nrmlwr nrmlwr_
+#define rgrpwr rgrpwr_
+#define isvhwr isvhwr_
+
+// WrapDN
+
+extern "C" G4int idnrwr(const G4int & nreg, const G4int & mlat);
+
+// WrapG1
+
+extern "C" void g1wr(G4double& pSx, G4double& pSy, G4double& pSz, G4double* pV,
+ G4int& oldReg, const G4int& oldLttc, G4double& propStep,
+ G4int& nascFlag, G4double& retStep, G4int& newReg,
+ G4double& saf, G4int& newLttc, G4int& LttcFlag,
+ G4double* sLt, G4int* jrLt);
+
+// WrapG1RT
+
+extern "C" void g1rtwr(void);
+
+// WrapIncrHist
+
+extern "C" void conhwr(G4int& intHist, G4int* incrCount);
+
+// WrapIniHist
+
+extern "C" void inihwr(G4int& intHist);
+
+// WrapInit
+
+extern "C" void jomiwr(const G4int & nge, const G4int& lin, const G4int& lou,
+ G4int& flukaReg);
+
+// WrapLookDB
+
+extern "C" void lkdbwr(G4double& pSx, G4double& pSy, G4double& pSz,
+ G4double* pV, const G4int& oldReg, const G4int& oldLttc,
+ G4int& newReg, G4int& flagErr, G4int& newLttc);
+
+// WrapLookFX
+
+extern "C" void lkfxwr(G4double& pSx, G4double& pSy, G4double& pSz,
+ G4double* pV, const G4int& oldReg, const G4int& oldLttc,
+ G4int& newReg, G4int& flagErr, G4int& newLttc);
+
+// WrapLookMG
+
+extern "C" void lkmgwr(G4double& pSx, G4double& pSy, G4double& pSz,
+ G4double* pV, const G4int& oldReg, const G4int& oldLttc,
+ G4int& flagErr, G4int& newReg, G4int& newLttc);
+
+// WrapLookZ
+
+extern "C" void lkwr(G4double& pSx, G4double& pSy, G4double& pSz,
+ G4double* pV, const G4int& oldReg, const G4int& oldLttc,
+ G4int& newReg, G4int& flagErr, G4int& newLttc);
+
+// WrapMag
+
+extern "C" void magfld(const G4double& pX, const G4double& pY, const G4double& pZ,
+ G4double& cosBx, G4double& cosBy, G4double& cosBz,
+ G4double& Bmag, G4int& reg, G4int& idiscflag);
+
+// WrapNorml
+
+extern "C" void nrmlwr(G4double& pSx, G4double& pSy, G4double& pSz,
+ G4double& pVx, G4double& pVy, G4double& pVz,
+ G4double* norml, const G4int& oldReg,
+ const G4int& newReg, G4int& flagErr);
+
+// WrapReg
+
+extern "C" void rgrpwr(const G4int& flukaReg, const G4int& ptrLttc, G4int& g4Reg,
+ G4int* indMother, G4int* repMother, G4int& depthFluka);
+
+// WrapSavHist
+
+extern "C" G4int isvhwr(const G4int& fCheck, const G4int& intHist);
+
+#endif //WRAPPERS_HH
+
--- /dev/null
+// $Id$
+// Flugg tag $Name$
+
+#include "FGeometryInit.hh"
+#include <stdio.h>
+
+FGeometryInit * FGeometryInit::flagInstance=0;
+
+FGeometryInit* FGeometryInit::GetInstance()
+{
+ if (!flagInstance) new FGeometryInit();
+
+ return flagInstance;
+}
+
+
+FGeometryInit::FGeometryInit()
+ {
+ flagInstance = this;
+ fTransportationManager = G4TransportationManager::GetTransportationManager();
+ }
+
+
+FGeometryInit::~FGeometryInit()
+ {
+ DeleteHistories();
+ ptrGeoMan->OpenGeometry();
+ delete fTransportationManager;
+ delete ptrJrLtGeant;
+ DelHistArray();
+
+ //keep ATTENTION: never delete a pointer twice!
+ }
+
+
+G4Navigator* FGeometryInit::getNavigatorForTracking()
+{
+ return fTransportationManager->GetNavigatorForTracking();
+}
+
+void FGeometryInit::setDetConstruction(G4VUserDetectorConstruction* detector)
+{
+ fDetector = detector;;
+}
+
+void FGeometryInit::setDetector()
+{
+ myTopNode = fDetector->Construct();
+}
+
+void FGeometryInit::setMotherVolume()
+{
+ fTransportationManager->GetNavigatorForTracking()->SetWorldVolume(myTopNode);
+}
+
+void FGeometryInit::closeGeometry()
+{
+ ptrGeoMan = G4GeometryManager::GetInstance();
+ ptrGeoMan->OpenGeometry();
+
+ //true argoment allows voxel construction; if false voxels are built
+ //only for replicated volumes
+ ptrGeoMan->CloseGeometry(true);
+}
+
+G4FieldManager * FGeometryInit::getFieldManager()
+{
+ return fTransportationManager->GetFieldManager();
+}
+
+//*************************************************************************
+
+void FGeometryInit::InitHistArray()
+{
+ ptrArray = new G4int[1000000];
+ for(G4int i=0;i<1000000;i++) ptrArray[i]=0;
+}
+
+void FGeometryInit::DelHistArray()
+{
+ delete ptrArray;
+}
+
+G4int * FGeometryInit::GetHistArray()
+{
+ return ptrArray;
+}
+
+
+
+//*************************************************************************
+//jrLtGeant stores all crossed lattice volume histories.
+
+void FGeometryInit::InitJrLtGeantArray()
+{
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"Initializing JrLtGeant array"<<G4endl;
+#endif
+ ptrJrLtGeant = new G4int[10000];
+ for(G4int x=0;x<10000;x++) ptrJrLtGeant[x]=-1;
+ flagLttcGeant = -1;
+}
+
+
+G4int * FGeometryInit::GetJrLtGeantArray()
+{
+ return ptrJrLtGeant;
+}
+
+
+G4int FGeometryInit::GetLttcFlagGeant()
+{
+ return flagLttcGeant;
+}
+
+void FGeometryInit::SetLttcFlagGeant(G4int newFlagLttc)
+{
+ // Added by A.Solodkov
+ if (newFlagLttc >= 10000) {
+ G4cout<<"Problems in FGeometryInit::SetLttcFlagGeant"<<G4endl;
+ G4cout<<"Index newFlagLttc="<<newFlagLttc<<" is outside array bounds"<<G4endl;
+ G4cout<<"Better to stop immediately !"<<G4endl;
+ exit(1);
+ }
+ flagLttcGeant = newFlagLttc;
+}
+
+void FGeometryInit::PrintJrLtGeant()
+{
+#ifdef G4GEOMETRY_DEBUG
+ //G4cout<<"jrLtGeant:"<<G4endl;
+ //for(G4int y=0;y<=flagLttcGeant;y++)
+ //
+ // G4cout<<"jrLtGeant["<<y<<"]="<<ptrJrLtGeant[y]<<G4endl;
+#endif
+}
+
+//**************************************************************************
+
+void FGeometryInit::PrintHistories()
+{
+/*
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"Touch hist:"<<G4endl;
+ G4cout<<*(ptrTouchHist->GetHistory())<<G4endl;
+ G4cout<<"Tmp hist:"<<G4endl;
+ G4cout<<*(ptrTempNavHist->GetHistory())<<G4endl;
+ G4cout<<"Old hist:"<<G4endl;
+ G4cout<<*(ptrOldNavHist->GetHistory())<<G4endl;
+#endif
+*/
+}
+
+
+
+
+void FGeometryInit::InitHistories()
+{
+#ifdef G4GEOMETRY_DEBUG
+ G4cout <<" InitHistories start" << G4endl;
+#endif
+ //init utility histories with navigator history
+
+ G4cout << fTransportationManager<< G4endl;
+ G4cout << fTransportationManager->GetNavigatorForTracking()<< G4endl;
+
+ ptrTouchHist = fTransportationManager->GetNavigatorForTracking()->CreateTouchableHistory();
+ G4cout << "Touchable history " << G4endl;
+ ptrTempNavHist = fTransportationManager->GetNavigatorForTracking()->CreateTouchableHistory();
+ ptrOldNavHist = new G4TouchableHistory();
+#ifdef G4GEOMETRY_DEBUG
+ G4cout <<" InitHistories end" << G4endl;
+#endif
+}
+
+void FGeometryInit::DeleteHistories()
+ {
+ delete ptrTouchHist;
+ delete ptrOldNavHist;
+ delete ptrTempNavHist;
+
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"Deleting step-history objects at end of run!"<<G4endl;
+#endif
+ }
+
+G4TouchableHistory * FGeometryInit::GetTouchableHistory()
+{
+ return ptrTouchHist;
+}
+
+G4TouchableHistory * FGeometryInit::GetOldNavHist()
+{
+ return ptrOldNavHist;
+}
+
+G4TouchableHistory * FGeometryInit::GetTempNavHist()
+{
+ return ptrTempNavHist;
+}
+
+
+void FGeometryInit::UpdateHistories(const G4NavigationHistory * history,
+ const G4int & flagHist)
+{
+ PrintHistories();
+
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"...updating histories!"<<G4endl;
+#endif
+
+ G4VPhysicalVolume * pPhysVol = history->GetTopVolume();
+
+ switch (flagHist)
+ {
+ case 0:
+ {
+ //this is the case when a new history is given to the
+ //navigator and old history has to be resetted
+ //touchable history has not been updated jet, so:
+
+ ptrTouchHist->UpdateYourself(pPhysVol,history);
+ ptrTempNavHist->UpdateYourself(pPhysVol,history);
+ G4NavigationHistory * ptrOldNavHistNotConst =
+ const_cast<G4NavigationHistory * >(ptrOldNavHist->GetHistory());
+ ptrOldNavHistNotConst->Reset();
+ ptrOldNavHistNotConst->Clear();
+ PrintHistories();
+ break;
+ }
+
+ case 1:
+ {
+ //this is the case when a new history is given to the
+ //navigator but old history has to be kept (e.g. LOOKZ
+ //is call during an event);
+ //touchable history has not been updated jet, so:
+
+ ptrTouchHist->UpdateYourself(pPhysVol,history);
+ ptrTempNavHist->UpdateYourself(pPhysVol,history);
+ PrintHistories();
+ break;
+ }
+
+ case 2:
+ {
+ //this is the case when the touchable history has been
+ //updated by a LocateGlobalPointAndUpdateTouchable call
+
+ G4VPhysicalVolume * pPhysVolTemp = ptrTempNavHist->GetVolume();
+ ptrOldNavHist->UpdateYourself(pPhysVolTemp,
+ ptrTempNavHist->GetHistory());
+
+ ptrTempNavHist->UpdateYourself(pPhysVol,history);
+ PrintHistories();
+ break;
+ }
+ default:
+ {
+ G4cout<<"ERROR in updating step-histories!"<<G4endl;
+ break;
+ }
+ }
+
+}
+
+//*****************************************************************************
+
+
+void FGeometryInit::createFlukaMatFile()
+{
+// ultima modifica Sara Vanini 1/III/99
+// NOMI DI ELEMENTI E COMPOSTI: i nomi devono essere scritti maiuscolo,
+// secondo lo standard di fluka. Devono inoltre essere uguali ai nomi dei
+// materiali fluka - vedere il manuale di fluka - perche` il programma
+// carichi le giuste sezioni d`urto, e uguali ai nomi inclusi nel .pemf.
+// Altrimenti l`utente deve definirsi le CARDS LOW-MAT, e costruirsi il
+// .pemf, per avere le giuste sezioni d`urto caricate in memoria.
+
+ //flag
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"================== FILEWR ================="<<G4endl;
+#endif
+
+ //open file for output
+ ofstream fout("flukaMat.inp");
+
+ //PhysicalVolumeStore, Volume and MaterialTable pointers
+ G4PhysicalVolumeStore * pVolStore = G4PhysicalVolumeStore::GetInstance();
+ G4int numVol = G4int(pVolStore->size());
+
+ G4int* indexMatFluka = 0;
+ static G4Material * ptrMat = 0;
+ G4int x = 0;
+ while(!ptrMat && x<numVol)
+ {
+ G4VPhysicalVolume * ptrVol = (*pVolStore)[x];
+ G4LogicalVolume * ptrLogVol = ptrVol->GetLogicalVolume();
+ ptrMat = ptrLogVol->GetMaterial();
+ x+=1;
+ }
+
+ if(ptrMat)
+ {
+ static const G4MaterialTable * ptrMatTab = G4Material::GetMaterialTable();
+
+ //number of materials, elements, variable initialisations
+ static size_t totNumMat = G4Material::GetNumberOfMaterials();
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"Number of materials: "<<totNumMat<<G4endl;
+#endif
+ const G4Element * ptrElem = ptrMat->GetElement(0);
+ static size_t totNumElem = ptrElem->GetNumberOfElements();
+ static const G4ElementTable * ptrElemTab = ptrElem->GetElementTable();
+ G4int * elemIndexInMATcard = new G4int[totNumElem];
+ for(G4int t=0; t<totNumElem; t++)
+ elemIndexInMATcard[t] = 0;
+ static const G4IsotopeTable * ptrIsotTab;
+ G4int initIsot = 0;
+ static size_t totNumIsot;
+ G4int* isotIndexInMATcard = 0;
+ G4int isotPresence = 0;
+
+
+ // title
+ fout<<"*\n"<<"*\n"<<"*\n";
+ fout<<"********************* GEANT4 ELEMENTS AND COMPOUNDS *********************\n"<<"*\n";
+ fout<<("*...+....1....+....2....+....3....+....4....+....5....+....6....+....7...")<<G4endl;
+ fout<<("*")<<G4endl;
+
+ // *** loop over G4Materials to assign Fluka index
+ G4int indexCount=3;
+ indexMatFluka = new G4int[totNumMat];
+ for(G4int i=0; i<totNumMat; i++)
+ {
+ //pointer material, state
+ ptrMat = (*ptrMatTab)[i];
+ G4double denMat = ptrMat->GetDensity();
+ G4String nameMat = ptrMat->GetName();
+ // Fluka index: bh=1, vacuum=2, others=3,4..
+ if(denMat<=1.00e-10*g/cm3)
+ //N.B. fluka density limit decided on XI-`98
+ {
+ indexMatFluka[i]=2;
+ }
+ else
+ {
+ indexMatFluka[i]=indexCount;
+ indexCount+=1;
+ }
+
+ // *** write single-element material MATERIAL card
+ size_t numElem = ptrMat->GetNumberOfElements();
+ if(numElem==1)
+ {
+ G4int index = indexMatFluka[i];
+ const G4Element * ptrElem = ptrMat->GetElement(0);
+ size_t indElemTab = ptrElem->GetIndex();
+ size_t numIsot = ptrElem->GetNumberOfIsotopes();
+ G4double A = (ptrElem->GetA())/(g);
+ if(!numIsot)
+ {
+ if(index!=2 && !elemIndexInMATcard[indElemTab])
+ {
+ G4double Z = ptrElem->GetZ();
+ elemIndexInMATcard[indElemTab] = index;
+ G4String nameEl = ptrElem->GetName();
+ nameEl.toUpper();
+
+ //write on file MATERIAL card of element
+ fout<<G4std::setw(10)<<"MATERIAL ";
+ fout.setf(0,G4std::ios::floatfield);
+ fout<<G4std::setw(10)<<G4std::setiosflags(G4std::ios::fixed)
+ <<G4std::setprecision(1)<<Z;
+ fout<<G4std::setw(10)<<G4std::setprecision(3)<<A;
+ fout.setf(0,G4std::ios::floatfield);
+ fout<<G4std::setw(10)<<G4std::setiosflags(G4std::ios::scientific)
+ <<G4std::setprecision(3)<<denMat/(g/cm3);
+ fout.setf(0,G4std::ios::floatfield);
+ fout<<G4std::setw(10)<<G4std::setiosflags(G4std::ios::fixed)<<
+ G4std::setprecision(1)<<G4double(index);
+ fout<<G4std::setw(10)<<" ";
+ fout<<G4std::setw(10)<<" ";
+ fout<<nameEl<<G4endl;
+ }
+ }
+ if(numIsot==1)
+ {
+ // G4Isotope pointer
+ const G4Isotope* ptrIsot = ptrElem->GetIsotope(0);
+ size_t indIsotTab = ptrIsot->GetIndex();
+ //initialize variables
+ if(!initIsot)
+ {
+ totNumIsot = ptrIsot->GetNumberOfIsotopes();
+ ptrIsotTab = ptrIsot->GetIsotopeTable();
+ isotIndexInMATcard = new G4int[totNumIsot];
+ for(G4int t=0; t<totNumIsot; t++) isotIndexInMATcard[t] = 0;
+ initIsot = 1;
+ }
+ if(!isotIndexInMATcard[indIsotTab])
+ {//compute physical data and counters
+ G4int ZIs = ptrIsot->GetZ();
+ G4double AIs = (ptrIsot->GetA())/(g);
+ G4int NIs = ptrIsot->GetN();
+ G4String nameIsot = ptrIsot->GetName();
+ nameIsot.toUpper();
+ G4double* ptrRelAbVect = ptrElem->GetRelativeAbundanceVector();
+ isotIndexInMATcard[indIsotTab] = index;
+
+ //write on file MATERIAL card of isotope
+ fout<<G4std::setw(10)<<"MATERIAL ";
+ fout.setf(0,G4std::ios::floatfield);
+ fout<<G4std::setw(10)<<G4std::setiosflags(G4std::ios::fixed)
+ <<G4std::setprecision(1)<<G4double(ZIs);
+ fout<<G4std::setw(10)<<G4std::setprecision(3)<<AIs;
+ fout.setf(0,ios::floatfield);
+ fout<<G4std::setw(10)<<G4std::setiosflags(G4std::ios::scientific)
+ <<G4std::setprecision(3)<<denMat/(g/cm3);
+ fout.setf(0,G4std::ios::floatfield);
+ fout<<G4std::setw(10)<<G4std::setiosflags(G4std::ios::fixed)
+ <<G4std::setprecision(1)<<G4double(index);
+ fout<<G4std::setw(10)<<" ";
+ fout<<G4std::setw(10)<<G4double(NIs);
+ fout<<nameIsot<<G4endl;
+ }
+ }// end if(numIsot==1)
+ }// end if(numElem==1)
+ }// end for loop
+
+
+ // *** material definitions: elements, compound made of G4Elements
+ // or made of G4Materials
+ for(G4int j=0; j<totNumMat; j++)
+ {
+ //pointer material, and material data
+ ptrMat = (*ptrMatTab)[j];
+ size_t numElem = ptrMat->GetNumberOfElements();
+ G4double densityMat = (ptrMat->GetDensity())/(g/cm3);
+ G4String nameMat = ptrMat->GetName();
+ nameMat.toUpper();
+ isotPresence = 0;
+
+ //fraction vector of compounds of the material
+ const G4double* ptrFracVect = ptrMat->GetFractionVector();
+
+ //loop on elements of the material
+ for(G4int el=0; el<numElem; el++)
+ {
+ //compute physical data, initialize variables
+ const G4Element * ptrElem = ptrMat->GetElement(el);
+ size_t indElemTab = ptrElem->GetIndex();
+ G4String nameElem = ptrElem->GetName();
+ nameElem.toUpper();
+ size_t numIsot = ptrElem->GetNumberOfIsotopes();
+ G4double A = (ptrElem->GetA())/(g);
+
+ if(!numIsot)
+ {
+ if(!elemIndexInMATcard[indElemTab])
+ {
+ G4double Z = ptrElem->GetZ();
+ G4double density = ptrFracVect[el]*densityMat;
+ elemIndexInMATcard[indElemTab] = indexCount;
+
+ //write on file MATERIAL card of element
+ fout<<G4std::setw(10)<<"MATERIAL ";
+ fout.setf(0,G4std::ios::floatfield);
+ fout<<G4std::setw(10)<<G4std::setiosflags(G4std::ios::fixed)
+ <<G4std::setprecision(1)<<Z;
+ fout<<G4std::setw(10)<<G4std::setprecision(3)<<A;
+ fout.setf(0,G4std::ios::floatfield);
+ fout<<G4std::setw(10)<<G4std::setiosflags(G4std::ios::scientific)
+ <<G4std::setprecision(3)<<density;
+ fout.setf(0,G4std::ios::floatfield);
+ fout<<G4std::setw(10)<<G4std::setiosflags(G4std::ios::fixed)<<
+ G4std::setprecision(1)<<G4double(indexCount);
+ fout<<G4std::setw(10)<<" ";
+ fout<<G4std::setw(10)<<" ";
+ fout<<nameElem<<G4endl;
+ indexCount+=1;
+ }
+ }
+
+ else
+ {
+ if(numIsot>=2) isotPresence = 1;
+ //loop on isotopes
+ for(G4int nis=0; nis<numIsot; nis++)
+ {
+ // G4Isotope pointer
+ const G4Isotope* ptrIsot = ptrElem->GetIsotope(nis);
+ size_t indIsotTab = ptrIsot->GetIndex();
+ //initialize variables
+ if(!initIsot)
+ {
+ totNumIsot = ptrIsot->GetNumberOfIsotopes();
+ ptrIsotTab = ptrIsot->GetIsotopeTable();
+ isotIndexInMATcard = new G4int[totNumIsot];
+ for(G4int t=0; t<totNumIsot; t++) isotIndexInMATcard[t] = 0;
+ initIsot = 1;
+ }
+ if(!isotIndexInMATcard[indIsotTab])
+ {//compute physical data and counters
+ G4int ZIs = ptrIsot->GetZ();
+ G4double AIs = (ptrIsot->GetA())/(g);
+ G4int NIs = ptrIsot->GetN();
+ G4String nameIsot = ptrIsot->GetName();
+ nameIsot.toUpper();
+ G4double* ptrRelAbVect = ptrElem->GetRelativeAbundanceVector();
+ G4double density = ptrFracVect[el]*densityMat*
+ ptrRelAbVect[nis]*AIs/A;
+ G4int index = indexCount;
+ isotIndexInMATcard[indIsotTab] = indexCount;
+ indexCount+=1;
+
+ //write on file MATERIAL card of isotope
+ fout<<G4std::setw(10)<<"MATERIAL ";
+ fout.setf(0,G4std::ios::floatfield);
+ fout<<G4std::setw(10)<<G4std::setiosflags(G4std::ios::fixed)
+ <<G4std::setprecision(1)<<G4double(ZIs);
+ fout<<G4std::setw(10)<<G4std::setprecision(3)<<AIs;
+ fout.setf(0,G4std::ios::floatfield);
+ fout<<G4std::setw(10)<<G4std::setiosflags(G4std::ios::scientific)
+ <<G4std::setprecision(3)<<density;
+ fout.setf(0,G4std::ios::floatfield);
+ fout<<G4std::setw(10)<<G4std::setiosflags(G4std::ios::fixed)
+ <<G4std::setprecision(1)<<G4double(index);
+ fout<<G4std::setw(10)<<" ";
+ fout<<G4std::setw(10)<<G4double(NIs);
+ fout<<nameIsot<<G4endl;
+ }
+ }
+ }
+
+ }
+
+ if(numElem>1 || isotPresence==1)
+ {
+ // write MATERIAL+COMPOUND card specifing the compound
+
+ //flags for writing COMPOUND card
+ G4int treCount=0;
+
+ //make MATERIAL card for compound, start COMPOUND card
+ fout<<"*"<<G4endl;
+ fout<<"* Define GEANT4 compound "<<nameMat<<G4endl;
+ fout<<G4std::setw(10)<<"MATERIAL ";
+ fout.setf(0,G4std::ios::floatfield);
+ fout<<G4std::setw(10)<<" "<<G4std::setw(10)<<" ";
+ fout<<G4std::setw(10)<<G4std::setiosflags(G4std::ios::scientific)
+ <<G4std::setprecision(3)<<densityMat;
+ fout.setf(0,G4std::ios::floatfield);
+ fout<<G4std::setw(10)<<G4std::setiosflags(G4std::ios::fixed)<<G4std::setprecision(1)
+ <<G4double(indexMatFluka[j]);
+ fout<<G4std::setw(10)<<" ";
+ fout<<G4std::setw(10)<<" ";
+ fout<<nameMat<<G4endl;
+ fout<<G4std::setw(10)<<"COMPOUND ";
+
+
+ //write elements in COMPOUND card
+ for(G4int h=0; h<numElem; h++)
+ {
+ const G4Element * ptrElemMat = ptrMat->GetElement(h);
+ size_t indexElemMat = ptrElemMat->GetIndex();
+ size_t numIsotElem = ptrElemMat->GetNumberOfIsotopes();
+ if(!numIsotElem)
+ {
+ if(treCount==3)
+ {
+ treCount=0;
+ fout<<nameMat<<G4endl;
+ fout<<G4std::setw(10)<<"COMPOUND ";
+ }
+
+ fout.setf(0,G4std::ios::floatfield);
+ fout<<G4std::setw(10)<<G4std::setiosflags(G4std::ios::scientific)
+ <<G4std::setprecision(2)<<-ptrFracVect[h];
+ fout.setf(0,G4std::ios::floatfield);
+ fout<<G4std::setw(10)<<G4std::setiosflags(G4std::ios::fixed)<<
+ G4std::setprecision(1)<<G4double(elemIndexInMATcard[indexElemMat]);
+ treCount+=1;
+ }
+ else
+ {
+ G4double * ptrIsotAbbVect = ptrElemMat->GetRelativeAbundanceVector();
+
+ for(G4int iso=0; iso<numIsotElem; iso++)
+ {
+ const G4Isotope * ptrIsotElem =ptrElemMat->GetIsotope(iso);
+ size_t indexIsotMat = ptrIsotElem->GetIndex();
+ G4double isotAbundPerVol =
+ ptrIsotAbbVect[iso]*Avogadro*densityMat*
+ ptrFracVect[h]/(ptrElemMat->GetA()/(g));
+
+ if(treCount==3)
+ {
+ treCount=0;
+ fout<<nameMat<<G4endl;
+ fout<<G4std::setw(10)<<"COMPOUND ";
+ }
+ fout.setf(0,G4std::ios::floatfield);
+ fout<<G4std::setw(10)<<G4std::setiosflags(G4std::ios::scientific)
+ <<G4std::setprecision(2)<<isotAbundPerVol;
+ fout.setf(0,G4std::ios::floatfield);
+ fout<<G4std::setw(10)<<G4std::setiosflags(G4std::ios::fixed)<<
+ G4std::setprecision(1)<<G4double(isotIndexInMATcard[indexIsotMat]);
+ treCount+=1;
+ }
+ }
+ }
+
+ //end COMPOUND card
+ if(treCount==1) fout<<G4std::setw(10)<<" "<<G4std::setw(10)<<" "<<
+ G4std::setw(10)<<" "<<G4std::setw(10)<<" "<<nameMat<<G4endl;
+ if(treCount==2) fout<<G4std::setw(10)<<" "<<G4std::setw(10)<<
+ " "<<nameMat<<G4endl;
+ if(treCount==3) fout<<nameMat<<G4endl;
+ fout<<"*"<<G4endl;
+ }
+
+
+ } // end for loop
+ delete elemIndexInMATcard;
+ if(initIsot) delete isotIndexInMATcard;
+
+ } // end if (ptrMat)
+
+ // *** material-volume correspondence
+ fout<<"*\n"<<"*\n"<<"*\n";
+ fout<<"******************** GEANT4 MATERIAL ASSIGNMENTS *******************\n"<<"*\n";
+ fout<<("*...+....1....+....2....+....3....+....4....+....5....+....6....+....7...")<<G4endl;
+ fout<<("*")<<G4endl;
+
+ //initializations
+ G4int indexMatOld = 0;
+ G4int indexRegFlukaFrom = 0;
+ G4int indexRegFlukaTo = 0;
+ G4int existTo = 0;
+ G4int flagField = 0;
+ G4int lastFlagField = 0;
+
+ //open file for volume-index correspondence
+ ofstream vout("Volumes_index.inp");
+
+ //... and write title
+ vout<<"*"<<G4endl;
+ vout<<"******************** GEANT4 VOLUMES *******************\n";
+ vout<<("*")<<G4endl;
+
+ //loop su tutti i volumi
+ for(G4int l=0;l<numVol;l++)
+ {
+ //index of the region
+ G4VPhysicalVolume * ptrVol = (*pVolStore)[l];
+ G4LogicalVolume * ptrLogVol = ptrVol->GetLogicalVolume();
+ G4int indexRegFluka = l+1;
+
+
+ //write index volume and name on file Volumes_index.inp
+ vout.setf(G4std::ios::left,G4std::ios::adjustfield);
+ vout<<G4std::setw(10)<<indexRegFluka;
+ vout<<G4std::setw(20)<<ptrVol->GetName()<<G4std::setw(20)<<"";
+ if(ptrVol->IsReplicated())
+ {
+ EAxis axis;
+ G4int nRep;
+ G4double width;
+ G4double offset;
+ G4bool consum;
+ ptrVol->GetReplicationData(axis,nRep,width,offset,consum);
+ vout.setf(G4std::ios::left,G4std::ios::adjustfield);
+ vout<<G4std::setw(10)<<"Repetion Nb: "<<G4std::setw(3)<<nRep;
+ }
+ vout<<G4endl;
+
+ //check if Magnetic Field is present in the region
+ G4FieldManager * pMagFieldMan = ptrLogVol->GetFieldManager();
+ const G4Field * pMagField = 0;
+ if(pMagFieldMan) pMagField = pMagFieldMan->GetDetectorField();
+ if(pMagField) flagField = 1;
+ else flagField = 0;
+
+
+ //index of material in the region
+ G4Material * ptrMat = ptrLogVol->GetMaterial();
+ G4int indexMat;
+ if(ptrMat)
+ {
+ size_t indexMatGeant = ptrMat->GetIndex();
+ indexMat = indexMatFluka[indexMatGeant];
+ }
+ else indexMat = 2;
+
+ //if materials are repeated
+ if(indexMat==indexMatOld && flagField==lastFlagField)
+ {
+ indexRegFlukaTo=indexRegFluka;
+ existTo=1;
+ if(l==(numVol-1))
+ {
+ fout<<G4std::setw(10)<<G4double(indexRegFlukaTo);
+ fout<<G4std::setw(10)<<"0.0";
+ fout<<G4std::setw(10)<<G4double(flagField);
+ fout<<G4std::setw(10)<<"0.0"<<G4endl;
+ }
+
+ }
+ else
+ {
+ //write on file ASSIGNMAT card
+
+ //first complete last material card
+ if(!existTo)
+ {
+ if(l)
+ {
+ fout<<G4std::setw(10)<<"0.0";
+ fout<<G4std::setw(10)<<"0.0";
+ fout<<G4std::setw(10)<<G4double(lastFlagField);
+ fout<<G4std::setw(10)<<"0.0"<<G4endl;
+ }
+ }
+ else
+ {
+ fout<<G4std::setw(10)<<G4double(indexRegFlukaTo);
+ fout<<G4std::setw(10)<<"0.0";
+ fout<<G4std::setw(10)<<G4double(lastFlagField);
+ fout<<G4std::setw(10)<<"0.0"<<G4endl;
+ }
+
+ // begin material card
+ fout<<G4std::setw(10)<<"ASSIGNMAT ";
+ fout.setf(0,G4std::ios::floatfield);
+ fout<<G4std::setw(10)<<G4std::setiosflags(G4std::ios::fixed)<<
+ G4std::setprecision(1)<<G4double(indexMat);
+ fout<<G4std::setw(10)<<G4double(indexRegFluka);
+
+ existTo=0;
+ indexRegFlukaFrom=indexRegFluka;
+
+ if(l==(numVol-1))
+ {
+ fout<<G4std::setw(10)<<"0.0";
+ fout<<G4std::setw(10)<<"0.0";
+ fout<<G4std::setw(10)<<G4double(flagField);
+ fout<<G4std::setw(10)<<"0.0"<<G4endl;
+ }
+ }
+ lastFlagField = flagField;
+ indexMatOld = indexMat;
+ } // end of loop ??
+
+ //assign material 1 to black-hole=n.vol+1
+ fout<<G4std::setw(10)<<"ASSIGNMAT ";
+ fout<<G4std::setw(10)<<"1.0";
+ fout<<G4std::setw(10)<<G4double(numVol+1);
+ fout<<G4std::setw(10)<<"0.0";
+ fout<<G4std::setw(10)<<"0.0";
+ fout<<G4std::setw(10)<<"0.0";
+ fout<<G4std::setw(10)<<"0.0"<<G4endl;
+
+ // *** magnetic field ***
+ if(fTransportationManager->GetFieldManager()->DoesFieldExist())
+ {
+ fout<<"*\n"<<"*\n"<<"*\n";
+ fout<<"*********************** GEANT4 MAGNETIC FIELD ************************\n"<<"*\n";
+ fout<<("*...+....1....+....2....+....3....+....4....+....5....+....6....+....7...")<<G4endl;
+ fout<<("*")<<G4endl;
+
+ //get magnetic field pointer
+ const G4Field * pMagField = fTransportationManager->GetFieldManager()->GetDetectorField();
+
+ //if uniform magnetic field, get value
+ G4double Bx=0.0;
+ G4double By=0.0;
+ G4double Bz=0.0;
+
+ if(pMagField)
+ {
+ G4ThreeVector*Field = new G4ThreeVector(1.,2.,3.);
+ const G4UniformMagField *pUnifMagField =
+ dynamic_cast<const G4UniformMagField*>(pMagField);
+ if(pUnifMagField)
+ {
+ G4double *pFieldValue = 0;
+ G4double *point = new G4double[3];
+ point[0] = 0.;
+ point[1] = 0.;
+ point[2] = 0.;
+ pUnifMagField->GetFieldValue(point,pFieldValue);
+ //non capisco perche' l'instruzione seguente non fa linkare. Indaga!!
+ //per ora posso usare GetFieldValue: va bene lo stesso.
+ //G4ThreeVector FieldValue = pUnifMagField->GetConstantFieldValue();
+ Bx = pFieldValue[0];
+ By = pFieldValue[1];
+ Bz = pFieldValue[2];
+ }
+
+ }
+
+ //write MGNFIELD card
+ fout<<G4std::setw(10)<<"MGNFIELD ";
+ fout<<G4std::setw(10)<<"";
+ fout<<G4std::setw(10)<<"";
+ fout<<G4std::setw(10)<<"";
+ fout.setf(0,G4std::ios::floatfield);
+ fout<<G4std::setw(10)<<G4std::setiosflags(G4std::ios::fixed)<<G4std::setprecision(4)<<Bx;
+ fout<<G4std::setw(10)<<By;
+ fout<<G4std::setw(10)<<Bz<<G4endl;
+ } // end if magnetic field
+
+ vout.close();
+ fout.close();
+ delete [] indexMatFluka;
+}
--- /dev/null
+// $Id$
+// Flugg tag $Name$
+
+///////////////////////////////////////////////////////////////////
+//
+// WrapDN.hh - Sara Vanini - 17/XI/98
+//
+// Wrapper for setting DNEAR option on fluka side. Must return 0
+// if user doesn't want Fluka to use DNEAR to compute the
+// step (the same effect is obtained with the GLOBAL (WHAT(3)=-1)
+// card in fluka input), returns 1 if user wants Fluka always to
+// use DNEAR (in this case, be sure that GEANT4 DNEAR is unique,
+// coming from all directions!!!).
+//
+// modified 24.10.01: by I. Hrivnacova
+// functions declarations separated from implementation
+// (moved to Wrappers.hh);
+//
+///////////////////////////////////////////////////////////////////
+
+//#ifndef idnrwr
+//#define idnrwr idnrwr_
+
+#include "Wrappers.hh"
+#include "globals.hh"
+
+G4int idnrwr(const G4int & nreg, const G4int & mlat)
+
+{
+//flag
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"================== IDNRWR ================="<<G4endl;
+#endif
+
+// returns 0 if user doesn't want Fluka to use DNEAR to compute the
+// step (the same effect is obtained with the GLOBAL (WHAT(3)=-1)
+// card in fluka input), returns 1 if (be sure that GEANT4 DNEAR is unique,
+// coming from all directions!!!) user wants Fluka always to use DNEAR.
+
+return 0;
+}
+//#endif
--- /dev/null
+// $Id$
+// Flugg tag $Name$
+
+///////////////////////////////////////////////////////////////////
+//
+// WrapG1.hh - Sara Vanini
+//
+// Wrapper for geometry tracking: returns approved step of
+// particle and alla variables that fluka G1 computes.
+//
+// modified 11/III/99 : included jrLtGeant array for storing
+// lattice histories; fixed jump-on-boundaries and back-scattering
+// modified 20/IV/99 : history counters of jrLt array are
+// incremented when created and decremented when check is required:
+// this for not deleting histories twice.
+// modified 18/X/99 : LocateGlobalPointWithinVolume used when position
+// is changed from last located point.
+// modified 1/III/00 : update utilities histories when crossing
+// identical volume boundaries.
+//
+// modified 22/III/00 : fixed LttcFlag and jrLt return values.
+// modified 12/VI/00 : end-step on Boundary bug fixed.
+// modified 5/VII/00 : boundary not seen by G4 geometry bug fixed.
+// modified 24.10.01: by I. Hrivnacova
+// functions declarations separated from implementation
+// (moved to Wrappers.hh);
+//
+/////////////////////////////////////////////////////////////////////
+
+#include "Wrappers.hh"
+#include "FGeometryInit.hh"
+#include "NavHistWithCount.hh"
+#include "G4VPhysicalVolume.hh"
+#include "G4NavigationHistory.hh"
+#include "G4Navigator.hh"
+#include "G4ThreeVector.hh"
+#include "G4PhysicalVolumeStore.hh"
+#include "globals.hh"
+
+
+//StepAndLocation declaration
+extern G4int StepAndLocation(G4ThreeVector &, const G4ThreeVector &,
+ const G4double &, G4double &, G4double &, G4bool &,
+ G4bool &, const G4int &);
+
+//EqualHistories declaration: true if histories are identical, otherwise false
+extern bool EqualHistories(const G4NavigationHistory*,
+ const G4NavigationHistory*);
+
+
+
+void g1wr(G4double& pSx, G4double& pSy, G4double& pSz, G4double* pV,
+ G4int& oldReg, const G4int& oldLttc, G4double& propStep,
+ G4int& nascFlag, G4double& retStep, G4int& newReg,
+ G4double& saf, G4int& newLttc, G4int& LttcFlag,
+ G4double* sLt, G4int* jrLt)
+{
+//flag
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"============= G1WR =============="<<G4endl;
+#endif
+
+//static G4int count=0;
+//count+=1;
+//G4cout<<"contatore G1="<<count<<G4endl;
+
+///////////////////////// INPUT ///////////////////////////
+//Geoinit, Navigator, TouchableHistory pointers
+ static FGeometryInit * ptrGeoInit = FGeometryInit::GetInstance();
+ G4Navigator * ptrNavig = ptrGeoInit->getNavigatorForTracking();
+ G4TouchableHistory * ptrTouchHist = ptrGeoInit->GetTouchableHistory();
+ G4PhysicalVolumeStore * pVolStore = G4PhysicalVolumeStore::GetInstance();
+
+//setting variables (and dimension: Fluka uses cm.!)
+ G4ThreeVector partLoc(pSx,pSy,pSz);
+ partLoc *= 10.0; // in millimeters!
+ static G4ThreeVector partLocOld = partLoc;
+ static G4ThreeVector oldLocalPoint =
+ ptrNavig->ComputeLocalPoint(partLocOld);
+
+ G4ThreeVector pVec(pV[0],pV[1],pV[2]);
+ const G4double physStep=G4double(propStep*10.);
+
+ G4int LttcFlagGeant = ptrGeoInit->GetLttcFlagGeant();
+
+
+#ifdef G4GEOMETRY_DEBUG
+ G4cout.precision(10);
+ G4cout<<"Position (cm):"<<pSx<<","<<pSy<<","<<pSz<<G4endl;
+ G4cout<<"Direction: "<<pVec<<G4endl;
+ G4cout<<"Proposed step :"<<propStep<<G4endl;
+#endif
+
+
+
+///////////////////// FLUKA/G4 REGIONS COMPARISON //////////////////////
+//get oldReg pointer and G4volume of previous step end-point pointer
+ G4VPhysicalVolume * ptrOldReg = (*pVolStore)[oldReg-1];
+ G4VPhysicalVolume * lastVolume = ptrTouchHist->GetVolume();
+ G4int fluVolCpNb = ptrOldReg->GetCopyNo();
+ G4int touVolCpNb = 0;
+ if (lastVolume) touVolCpNb = lastVolume->GetCopyNo();
+
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"Fluka volume before step: "<<ptrOldReg->GetName()<<
+ ","<<fluVolCpNb<<G4endl;
+ if(lastVolume) G4cout<<"G4 Touch Hist volume: "<<
+ lastVolume->GetName()<<","<<touVolCpNb<<G4endl;
+ G4cout <<"------------------------------------------------"<<G4endl;
+#endif
+
+
+//if volume is changed, this is a new particle tracking, or fluka tries
+//to reach a boundary more softly with the same particle. In this case
+//fluka restart tracking from old history, in general. For tracking in
+//lattice-volume fluka goes back to one of the previous lattice volumes.
+//Check if ptrOldReg is equal to old history, or to one of the N lattice
+//volumes stored in jrLt. Then reinitialise step-histories! Otherwise
+//must relocate.
+//NB. jrLtGeant stores lattice volume histories until LttcFlag==-1,
+//then all histories are checked and deleted, and array is reinitialised
+
+
+ G4int haveHistNb = -1;
+ G4int newRegErr=0;
+ G4int indHist = LttcFlagGeant;
+ G4int * jrLtGeant = ptrGeoInit->GetJrLtGeantArray();
+
+
+ G4NavigationHistory* ptrLttcHist;
+ if(oldLttc) ptrLttcHist = reinterpret_cast
+ <NavHistWithCount*>(oldLttc)->GetNavHistPtr();
+
+
+ while(indHist>=0 && haveHistNb==-1)
+ {
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"Searching in jrLtc...."<<G4endl;
+#endif
+ if(oldLttc==jrLtGeant[indHist]) haveHistNb=indHist;
+ indHist-=1;
+ }
+
+ if(haveHistNb!=-1)
+ {
+ //fluka history found in jrLtGeant
+ if(haveHistNb<LttcFlagGeant)
+ {
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"* Fluka reaches boundary more softly..."<<G4endl;
+ G4cout<<"* Re-initializing G4Navigator history"<<G4endl;
+ G4cout<<"* and updating step-histories"<<G4endl;
+#endif
+
+ ptrNavig->UpdateNavigatorHistory(ptrLttcHist);
+ ptrGeoInit->UpdateHistories(ptrLttcHist,0);
+ }
+#ifdef G4GEOMETRY_DEBUG
+ if(haveHistNb==LttcFlagGeant) G4cout<<"Continuing step...."<<G4endl;
+#endif
+ jrLt[0]=oldLttc;
+ }
+ else
+ {
+ //not found fluka history in jrLttGeant!
+ G4cout<<"* ERROR! Geometry not correctly initialised in fluka history!"
+ <<G4endl;
+
+ //relocation!
+ ptrNavig->LocateGlobalPointAndUpdateTouchable
+ (partLoc,0,ptrTouchHist,true);
+
+ G4cout<<"* ATTENTION: point relocation in: "<<
+ ptrTouchHist->GetVolume()->GetName()<<G4endl;
+
+ ptrGeoInit->UpdateHistories(ptrTouchHist->GetHistory(),1);
+
+ if(ptrTouchHist->GetVolume() != ptrOldReg)
+ {
+ G4cout<<"* ERROR! Point not in fluka volume!"<<G4endl;
+ newRegErr=-3;
+ }
+
+ //save new history in jrLt[0] and increment its counter
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"* ISVHWR call to store new NavHistWithCount in jrLt[0]"
+ <<G4endl;
+#endif
+ jrLt[0]=isvhwr(0,0);
+
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"* CONHWR call to increment counter"<<G4endl;
+#endif
+ G4int incrCount2=1;
+ conhwr(jrLt[0],&incrCount2);
+ }
+
+
+//jrLtGeant - history check: decrement counter and delete
+//histories, if LttcFlag=-1, then reinitialise array with -1.
+ if(LttcFlag==-1 && LttcFlagGeant>=0)
+ {
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"* CONHWR call to check and delete histories in jrLtGeant[]:"
+ <<G4endl;
+#endif
+
+ for(G4int ind=0; ind<=LttcFlagGeant; ind++)
+ {
+ G4int incrCount1=-1;
+ if(jrLtGeant[ind]!=jrLt[0]) conhwr(jrLtGeant[ind],&incrCount1);
+ jrLtGeant[ind]=-1;
+ }
+ LttcFlagGeant=-1;
+ }
+
+
+//update jrLt and sLt arrays
+ G4int end;
+ if(LttcFlag>=0) end=LttcFlag;
+ else end=99;
+ // Added by A.Solodkov
+ if (end>=100) {
+ G4cout<<"Problems in WrapG1 routine"<<G4endl;
+ G4cout<<"Index LttcFlag="<<end<<" is outside array bounds"<<G4endl;
+ G4cout<<"Better to stop immediately !"<<G4endl;
+ exit(1);
+ }
+ //jrLt re-initialization with -1 (jrLt[0] is already set)
+ for(G4int vv=1;vv<=end;vv++) jrLt[vv]=-1;
+ //sLt re-initialization
+ for(G4int vs=0;vs<=end;vs++) sLt[vs]=0;
+
+ LttcFlag=0;
+
+
+///////////////////// COMPUTE STEP ////////////////////////
+//update Navigator private flags and voxel stack if point is
+//changed from last located point (otherwise troubles come
+//when fluka changes location or particle because G4 computes
+//from last located point).
+ G4ThreeVector newLocalPoint = ptrNavig->ComputeLocalPoint(partLoc);
+ G4double moveLenSq = (newLocalPoint-oldLocalPoint).mag2();
+ if(moveLenSq>=kCarTolerance*kCarTolerance)
+ ptrNavig->LocateGlobalPointWithinVolume(partLoc);
+
+
+//compute step and new location
+ newReg = oldReg;
+ G4double appStep = 0;
+ G4double safety = 0;
+ G4bool onBoundaryRound = false;
+ G4bool crossBound = false;
+ G4double physStepTmp = physStep;
+ G4bool flagError = false;
+
+ while( (oldReg==newReg && appStep<physStepTmp) || onBoundaryRound )
+ {
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"* Computing step..."<<G4endl;
+#endif
+
+ //update variables
+ oldReg = newReg;
+
+ if(onBoundaryRound)
+ {
+ physStepTmp=10.e-10;
+ //compute step and location: returns newReg
+ newReg=StepAndLocation(partLoc,pVec,physStepTmp,appStep,
+ safety,onBoundaryRound,flagError,oldReg);
+ physStepTmp=0.;
+ crossBound=true;
+ }
+ else
+ {
+ physStepTmp -= appStep;
+ //compute step and location: returns newReg
+ newReg=StepAndLocation(partLoc,pVec,physStepTmp,appStep,
+ safety,onBoundaryRound,flagError,oldReg);
+ }
+
+ G4bool EqualHist;
+ EqualHist = EqualHistories(ptrTouchHist->GetHistory(),
+ ptrGeoInit->GetTempNavHist()->GetHistory());
+
+ if(!EqualHist && flagError)
+ {
+ pVec=-pVec;
+ newReg=StepAndLocation(partLoc,pVec,physStepTmp,appStep,
+ safety,onBoundaryRound,flagError,oldReg);
+ pVec=-pVec;
+ physStepTmp+=1;
+ newReg=StepAndLocation(partLoc,pVec,physStepTmp,appStep,
+ safety,onBoundaryRound,flagError,oldReg);
+
+ EqualHist = EqualHistories(ptrTouchHist->GetHistory(),
+ ptrGeoInit->GetTempNavHist()->GetHistory());
+ }
+
+ //update sLt
+ G4double pas = G4double(appStep);
+ sLt[LttcFlag] += pas/cm;
+ safety = (oldReg!=newReg)?0.:safety;
+
+ if(!EqualHist)
+ {
+ //end-step point is on boundary between volumes;
+ //==> update step-histories, save new NavHistWithCount
+ //and save its pointer in jrLt; save step in sLt.
+
+ //set onBoundaryRound=false to avoid re-compute step!
+ onBoundaryRound=false;
+
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"* History is changed!"<<G4endl;
+ G4cout<<"* updating step-histories, jrLt, LttcFlag"<<G4endl;
+#endif
+
+ ptrGeoInit->UpdateHistories(ptrTouchHist->GetHistory(),2);
+
+ LttcFlag += 1;
+
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"* ISVHWR call to store new NavHistWithCount in jrLt"<<G4endl;
+#endif
+
+ jrLt[LttcFlag] = isvhwr(0,0);
+
+ #ifdef G4GEOMETRY_DEBUG
+ G4cout<<"* CONHWR call to increment counter"<<G4endl;
+ #endif
+ G4int incrCount3=1;
+ conhwr(jrLt[LttcFlag],&incrCount3);
+
+ sLt[LttcFlag] = sLt[LttcFlag-1];
+ }
+ }
+
+////////////////////// OUTPUT //////////////////////////
+//If back-scattering occured, and fluka is in the wrong region, return -3.
+//(N. B. Boundary between replicans are not seen when physStep=distance
+//particle-boundary: in this case step=kInfinity and history is unchanged.
+//Following step is =0 and then history changes.)
+ if(nascFlag<0 && !appStep && physStep && newReg!=oldReg && !crossBound)
+ {
+ //don't need to compare histories because boundary between
+ //identical volumes in different replicans are not seen
+#ifdef G4GEOMETRY_DEBUG
+ G4cout <<"* Back-scattering!"<<G4endl;
+#endif
+
+ newReg=-3;
+ }
+ else if(newRegErr<0) newReg=newRegErr;
+
+
+//compute output variables (in cm.!)
+ //final step
+ retStep = sLt[LttcFlag];
+
+ //safety (Fluka sottracts a bit to safety to be sure
+ //not to jump on a boundary)
+ G4double s = G4double(safety);
+ s -= s*3.0e-09;
+ saf=s/cm;
+
+//update wrapper utility variables
+ //copy jrLt in jrLtGeant
+ G4int start=0;
+ if(haveHistNb!=-1 && LttcFlagGeant!=-1) start=1;
+ for(G4int lt=start;lt<=LttcFlag;lt++)
+ jrLtGeant[LttcFlagGeant+1+lt-start]=jrLt[lt];
+ LttcFlagGeant+=(1+LttcFlag-start);
+ newLttc = jrLt[LttcFlag];
+ ptrGeoInit->SetLttcFlagGeant(LttcFlagGeant);
+
+ partLocOld=partLoc;
+ oldLocalPoint = ptrNavig->ComputeLocalPoint(partLocOld);
+
+//compute new position
+ G4ThreeVector oldPos = G4ThreeVector(pSx,pSy,pSz);
+ G4ThreeVector newPos = oldPos + retStep*pVec;
+
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"New position: "<<newPos<<G4endl;
+ G4cout<<"Output region: "<<newReg<<G4endl;
+ G4cout<<"G4 safety (cm): "<<(safety*0.1)<<G4endl;
+ G4cout<<"Fluka safety (cm): "<<saf<<G4endl;
+ G4cout<<"Approved step: "<<retStep<<G4endl;
+ G4cout<<"LttcFlag = "<<LttcFlag<<G4endl;
+ for(G4int i=0;i<=LttcFlag+1;i++)
+ {
+ G4cout<<"jrLt["<<i<<"]="<<jrLt[i]<<G4endl;
+ G4cout<<"sLt["<<i<<"]="<<sLt[i]<<G4endl;
+ }
+
+ G4cout<<"LttcFlagGeant ="<<LttcFlagGeant<<G4endl;
+ for(G4int ib=0;ib<=LttcFlagGeant+1;ib++)
+ {
+ G4cout<<"jrLtGeant["<<ib<<"]="<<jrLtGeant[ib]<<G4endl;
+ }
+ G4cout<<"newLttc="<<newLttc<<G4endl;
+#endif
+}
+
+
+
+
+extern G4int StepAndLocation(G4ThreeVector &partLoc, const G4ThreeVector &pVec,
+ const G4double &physStep, G4double &appStep,
+ G4double &safety, G4bool & onBound,
+ G4bool & flagErr, const G4int & oldReg)
+{
+ //NB onBound=true in the particular case when particle is in boundary
+ //rounding BUT geometry hasn't crossed it.
+ //flagErr=true when particle is on boundary but step=infinity,
+ //newSafety>10.e-10 and lLocate function locates end step point in
+ // a new region. This is absurb!
+
+
+ //Geoinit, Navigator, TouchableHistory, etc. pointers
+ static FGeometryInit * ptrGeoInit = FGeometryInit::GetInstance();
+ G4Navigator * ptrNavig = ptrGeoInit->getNavigatorForTracking();
+ G4TouchableHistory * ptrTouchableHistory = ptrGeoInit->
+ GetTouchableHistory();
+ G4PhysicalVolumeStore * pVolStore = G4PhysicalVolumeStore::
+ GetInstance();
+
+ //compute step
+ G4double step=ptrNavig->ComputeStep(partLoc,pVec,physStep,safety);
+
+ //compute approved step
+ if(step<physStep)
+ {
+ //NB:to check if point is really on boundary:
+ //see G4AuxiliaryNavServices.hh
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"* Boundary crossing!"<<G4endl;
+#endif
+
+ appStep=step;
+ ptrNavig->SetGeometricallyLimitedStep();
+
+ //if SetGeometricallyLimitedStep() is called, next
+ //LocateGlobalPointAndUpdateTouchable(...,true) will
+ //start searching from the end of the previous step,
+ //otherwise will start from last located point.
+ //(e.g.PropagatorInField and SteppingManger.
+ }
+ else
+ {
+ //step=kInfinity (the nearest boundary is >physStep)
+ //Fluka always wants step lenght approved, so:
+ appStep=physStep;
+ }
+
+ //new position
+ partLoc+=(pVec*appStep);
+
+ //locate point and update touchable history
+ ptrNavig->LocateGlobalPointAndUpdateTouchable(partLoc,0,
+ ptrTouchableHistory,true);
+
+ G4VPhysicalVolume * touchvolume=ptrTouchableHistory->GetVolume();
+
+ //if volume not found, out of mother volume:
+ //returns [number of volumes]+1
+ G4int newReg;
+ if(!touchvolume)
+ {
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"Out of mother volume! (G1WR)"<<G4endl;
+#endif
+ G4int numVol = G4int(pVolStore->size());
+ newReg = numVol + 1;
+ }
+ else
+ {
+#ifdef G4GEOMETRY_DEBUG
+ G4cout <<"Volume after step: "<<touchvolume->GetName()<<G4endl;
+#endif
+
+ //compute new volume index
+ G4int volIndex = 0;
+ for (G4int i=0; i<pVolStore->size(); i++)
+ if ((*pVolStore)[i] == touchvolume) volIndex = i;
+ // G4int volIndex=G4int(pVolStore->index(touchvolume));
+ newReg=volIndex+1;
+ }
+
+ onBound=false;
+ flagErr=false;
+ //check if position is in a boundary rounding while volume isn't changed
+ if(step==kInfinity || step==physStep)
+ {
+ G4ThreeVector globalpoint = ptrNavig->
+ GetLocalToGlobalTransform().TransformPoint
+ (ptrNavig->GetCurrentLocalCoordinate());
+
+ //compute new safety
+ G4double newSafetydbg = ptrNavig->ComputeSafety(globalpoint,DBL_MAX );
+
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"|From StepAndLocation:"<<G4endl;
+ G4cout<<"|step="<<step<<G4endl;
+ G4cout<<"|phystep="<<physStep<<G4endl;
+ G4cout<<"|safety="<<safety<<G4endl;
+ G4cout<<"|newSafetydbg ="<<newSafetydbg<<G4endl;
+#endif
+
+ if(newSafetydbg<1.0e-10) onBound=true;
+ else if(newReg != oldReg)
+ {
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"New Volume but ComputeStep didn't notice!"<<G4endl;
+#endif
+ flagErr=true;
+ }
+ }
+
+ //return
+ return newReg;
+}
+
+
+
+
+
+extern bool EqualHistories(const G4NavigationHistory* ptrFirstHist,
+ const G4NavigationHistory* ptrSecHist)
+ {
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"* Testing if histories are equal..."<<G4endl;
+#endif
+
+ G4int depth1 = ptrFirstHist->GetDepth();
+ G4int depth2 = ptrSecHist->GetDepth();
+
+ if(depth1!=depth2) return false;
+
+ for(G4int w=0;w<=depth1;w++)
+ {
+ if (*(ptrFirstHist->GetVolume(w))==*(ptrSecHist->GetVolume(w)))
+ {
+ //kNormal volume
+ if(ptrFirstHist->GetVolumeType(w) == kNormal)
+ {
+ if ( ptrFirstHist->GetVolume(w)->GetCopyNo() !=
+ ptrSecHist->GetVolume(w)->GetCopyNo() )
+ return false;
+ }
+
+ //Replica or Parametric volume
+ else
+ {
+ if ( ptrFirstHist->GetReplicaNo(w) !=
+ ptrSecHist->GetReplicaNo(w) )
+ return false;
+ }
+ }
+ else return false;
+ }
+
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"Histories are equal!"<<G4endl;
+#endif
+
+ return true;
+ }
+
+
+
+
--- /dev/null
+// $Id$
+// Flugg tag $Name$
+
+///////////////////////////////////////////////////////////////////
+//
+// WrapG1.hh - Sara Vanini
+//
+// Dummy wrapper for geometry tracking.
+//
+// modified 24.10.01: by I. Hrivnacova
+// functions declarations separated from implementation
+// (moved to Wrappers.hh);
+//
+///////////////////////////////////////////////////////////////////
+
+
+#include "Wrappers.hh"
+#include "globals.hh"
+
+void g1rtwr(void)
+{
+//flag
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"============ G1RTWR ============="<<G4endl;
+#endif
+
+//dummy wrapper
+}
--- /dev/null
+// $Id$
+// Flugg tag $Name$
+
+///////////////////////////////////////////////////////////////////
+//
+// WrapIncrHist.hh - Sara Vanini
+//
+// Wrapper for updating secondary particles history counter.
+// If counter=0 the history is deleted.
+//
+// modified 14/I/9999
+// modified 24.10.01: by I. Hrivnacova
+// functions declarations separated from implementation
+// (moved to Wrappers.hh);
+//
+//////////////////////////////////////////////////////////////////
+
+
+#include "Wrappers.hh"
+#include "FGeometryInit.hh"
+#include "NavHistWithCount.hh"
+#include "globals.hh"
+
+
+void conhwr(G4int& intHist, G4int* incrCount)
+{
+//flag
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"============= CONHWR =============="<<G4endl;
+ G4cout<<"Ptr History = "<<intHist<<G4endl;
+#endif
+
+//get NavHistWithCount pointer
+ if(intHist!=-1)
+ {
+ NavHistWithCount* ptrNavHistCount=reinterpret_cast<NavHistWithCount*>
+ (intHist);
+
+ //for debugging...
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"Secondary counter="<<ptrNavHistCount->GetCount();
+ if(*incrCount>0) G4cout<<"+"<<*incrCount<<G4endl;
+ if(*incrCount<0) G4cout<<*incrCount<<G4endl;
+ if(*incrCount==0) G4cout<<G4endl;
+#endif
+
+ //update secondary particles counter
+ ptrNavHistCount->UpdateCount(*incrCount);
+
+ //delete history if counter=0 or if counter=-1
+ G4int counter = ptrNavHistCount->GetCount();
+ if(!counter || counter==-1)
+ {
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"Delating Nav Hist object..."<<G4endl;
+#endif
+/*
+ //for history checking....
+ G4int index = ptrNavHistCount->GetCheckInd();
+ static FGeometryInit * ptrGeoInit = FGeometryInit::GetInstance();
+ G4int * ptrArray = ptrGeoInit->GetHistArray();
+ ptrArray[index]=0;
+*/
+
+ delete ptrNavHistCount;
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"end delete"<<G4endl;
+#endif
+ intHist=-1;
+ }
+ }
+}
+
+
+
+
+
+
+
+
+
+
--- /dev/null
+// $Id$
+// Flugg tag $Name$
+
+///////////////////////////////////////////////////////////////////
+//
+// WrapIniHist.hh - Sara Vanini
+//
+// Wrapper for reinitialization of G4Navigator history.
+//
+// modified 14/I/99
+// modified 24.10.01: by I. Hrivnacova
+// functions declarations separated from implementation
+// (moved to Wrappers.hh);
+//
+///////////////////////////////////////////////////////////////////
+
+
+#include "Wrappers.hh"
+#include "FGeometryInit.hh"
+#include "NavHistWithCount.hh"
+#include "G4NavigationHistory.hh"
+#include "G4Navigator.hh"
+#include "globals.hh"
+
+void inihwr(G4int& intHist)
+{
+//flag
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"============= INIHWR =============="<<G4endl;
+ G4cout<<"Ptr History="<<intHist<<G4endl;
+#endif
+ if(intHist==-1)
+ {
+ G4cout<<"ERROR! This history has been deleted!"<<G4endl;
+ return;
+ }
+ else
+ {
+ //get NavHistWithCount,G4NavigationHistory,FGeometryInit,
+ //G4Navigator pointers
+ NavHistWithCount* ptrNavHistCount=reinterpret_cast
+ <NavHistWithCount*>(intHist);
+ G4NavigationHistory* ptrNavHist=ptrNavHistCount->GetNavHistPtr();
+ static FGeometryInit * ptrGeoInit = FGeometryInit::GetInstance();
+ G4Navigator* ptrNavig = ptrGeoInit->getNavigatorForTracking();
+
+ //reinitialize navigator history
+ ptrNavig->UpdateNavigatorHistory(ptrNavHist);
+
+ //update utility histories: touch,temp, and reset old history
+ ptrGeoInit->UpdateHistories(ptrNavHist,0);
+
+ //save new history in jrLtGeant if not present
+ G4int LttcFlagGeant = ptrGeoInit->GetLttcFlagGeant();
+ G4int * jrLtGeant = ptrGeoInit->GetJrLtGeantArray();
+
+ G4bool intHistInJrLtGeant = false;
+ for(G4int h=0; h<=LttcFlagGeant; h++)
+ if(jrLtGeant[h]==intHist) intHistInJrLtGeant = true;
+
+ if(!intHistInJrLtGeant)
+ {
+ LttcFlagGeant += 1;
+ ptrGeoInit->SetLttcFlagGeant(LttcFlagGeant);
+
+ jrLtGeant[LttcFlagGeant]=intHist;
+
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"* CONHWR call to increment counter"<<G4endl;
+#endif
+ G4int incrCount=1;
+ conhwr(jrLtGeant[LttcFlagGeant],&incrCount);
+ }
+
+ //print history....
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"History reinitialized in:"<<G4endl;
+ G4cout<<*ptrNavHist<<G4endl;
+ ptrGeoInit->PrintJrLtGeant();
+#endif
+ }
+}
+
+
+
+
+
--- /dev/null
+// $Id$
+// Flugg tag $Name$
+
+///////////////////////////////////////////////////////////////////
+//
+// WrapInit.hh - Sara Vanini
+//
+// Wrapper for geometry initialisation.
+//
+// modified 12-IV-2000
+// modified 24.10.01: by I. Hrivnacova
+// functions declarations separated from implementation
+// (moved to Wrappers.hh);
+//
+//////////////////////////////////////////////////////////////////
+
+
+#include "Wrappers.hh"
+#include "FGeometryInit.hh"
+#include "G4PhysicalVolumeStore.hh"
+#include "G4VPhysicalVolume.hh"
+#include "globals.hh"
+
+void jomiwr(const G4int & nge, const G4int& lin, const G4int& lou,
+ G4int& flukaReg)
+{
+//flag
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"================== JOMIWR ================="<<G4endl;
+#endif
+
+
+//Geoinit Pointer
+ FGeometryInit * ptrGeoInit=FGeometryInit::GetInstance();
+
+//initialize geometry:construct detector and set world volume
+ ptrGeoInit->setDetector();
+ ptrGeoInit->setMotherVolume();
+
+#ifdef G4GEOMETRY_DEBUG
+ G4cout << "settings1 " << G4endl;
+#endif
+
+//close geometry for optimization
+ ptrGeoInit->closeGeometry();
+
+#ifdef G4GEOMETRY_DEBUG
+ G4cout << "close geometry "<< flukaReg << G4endl;
+#endif
+
+//initialize wrappers utility histories at the beginning of run and set flag
+
+ ptrGeoInit->InitHistories();
+
+#ifdef G4GEOMETRY_DEBUG
+ G4cout << " InitHistories" << G4endl;
+#endif
+
+//initialize lattice array
+ ptrGeoInit->InitJrLtGeantArray();
+
+#ifdef G4GEOMETRY_DEBUG
+ G4cout << "InitJrLtGeantArray " << G4endl;
+#endif
+
+//initialize debug-array
+ ptrGeoInit->InitHistArray();
+
+#ifdef G4GEOMETRY_DEBUG
+ G4cout << "InitHistArray " << G4endl;
+#endif
+
+
+//create Fluka material cards in flukaMat.inp file
+ ptrGeoInit->createFlukaMatFile();
+
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"createFlukaMatFile "<<flukaReg<<G4endl;
+#endif
+
+//returns number of volumes + 1
+ G4PhysicalVolumeStore * pVolStore = G4PhysicalVolumeStore::GetInstance();
+ G4int numVol = G4int(pVolStore->size());
+ flukaReg = numVol + 1;
+
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"Number of volumes + 1: "<<flukaReg<<G4endl;
+#endif
+}
+
+
+
--- /dev/null
+// $Id$
+// Flugg tag $Name$
+
+///////////////////////////////////////////////////////////////////
+//
+// WrapG1.hh - Sara Vanini
+//
+// Dummy wrapper (in fluka: for geometry debugging)
+//
+//////////////////////////////////////////////////////////////////
+
+//#ifndef lkdbwr
+//#define lkdbwr lkdbwr_
+
+#include "Wrappers.hh"
+#include "globals.hh"
+
+extern "C" void lkdbwr(G4double& pSx, G4double& pSy, G4double& pSz,
+ G4double* pV, const G4int& oldReg, const G4int& oldLttc,
+ G4int& newReg, G4int& flagErr, G4int& newLttc)
+{
+//flag
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"============= LKDBWR =============="<<G4endl;
+#endif
+
+//return region number and dummy variables
+ newReg=0;
+ newLttc=0;
+ flagErr=-1;
+}
+//#endif
--- /dev/null
+// $Id$
+// Flugg tag $Name$
+
+///////////////////////////////////////////////////////////////////
+//
+// WrapLookFX.hh - Sara Vanini - 24/III/00
+//
+// Wrapper for localisation of particle to fix particular conditions.
+// At the moment is the same as WrapLookZ.hh.
+//
+// modified 24.10.01: by I. Hrivnacova
+// functions declarations separated from implementation
+// (moved to Wrappers.hh);
+//
+//////////////////////////////////////////////////////////////////
+
+
+#include "Wrappers.hh"
+#include "FGeometryInit.hh"
+#include "G4VPhysicalVolume.hh"
+#include "G4Navigator.hh"
+#include "G4ThreeVector.hh"
+#include "G4PhysicalVolumeStore.hh"
+#include "globals.hh"
+
+void lkfxwr(G4double& pSx, G4double& pSy, G4double& pSz,
+ G4double* pV, const G4int& oldReg, const G4int& oldLttc,
+ G4int& newReg, G4int& flagErr, G4int& newLttc)
+{
+//flag
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"======= LKFXWR ======="<<G4endl;
+#endif
+
+//FGeometryInit, navigator, volumeStore pointers
+ static FGeometryInit * ptrGeoInit = FGeometryInit::GetInstance();
+ G4Navigator * ptrNavig = ptrGeoInit->getNavigatorForTracking();
+ G4PhysicalVolumeStore * pVolStore = G4PhysicalVolumeStore::GetInstance();
+
+//coordinates in mm.
+ G4ThreeVector pSource(pSx,pSy,pSz);
+ pSource *= 10.0; //in millimeters!
+
+//locate point and update histories
+ G4TouchableHistory * ptrTouchableHistory =
+ ptrGeoInit->GetTouchableHistory();
+ ptrNavig->LocateGlobalPointAndUpdateTouchable(pSource,0,
+ ptrTouchableHistory,true);
+ //updating tmp but not old histories, they are useful in
+ //case of RGRPWR call, or when fluka, after a LOOKZ call,
+ //descards step for multiple scattering and returns to old history
+ //NO, after lattice-fix we don't need old history anymore!
+
+ ptrGeoInit->UpdateHistories(ptrTouchableHistory->GetHistory(),0);
+ G4VPhysicalVolume * located = ptrTouchableHistory->GetVolume();
+
+//if volume not found, out of mother volume: returns "number of volumes"+1
+ if(!located)
+ {
+#ifdef G4GEOMETRY_DEBUG
+ G4cout << "Out of mother volume!";
+#endif
+ G4int numVol = G4int(pVolStore->size());
+ newReg = numVol + 1;
+ }
+ else
+ {
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"* ISVHWR call to store current NavHistWithCount in jrLtGeant"
+ <<G4endl;
+#endif
+
+ //save history in jrLtGeant and increment counter
+ G4int * jrLtGeant = ptrGeoInit->GetJrLtGeantArray();
+ G4int LttcFlagGeant = ptrGeoInit->GetLttcFlagGeant();
+ LttcFlagGeant += 1;
+ jrLtGeant[LttcFlagGeant] = isvhwr(0,0);
+
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"* CONHWR call to increment counter"<<G4endl;
+#endif
+ G4int incrCount=1;
+ conhwr(jrLtGeant[LttcFlagGeant],&incrCount);
+
+ //update LttcFlagGeant
+ ptrGeoInit->SetLttcFlagGeant(LttcFlagGeant);
+
+ //return region number and dummy variables
+ G4int volIndex = 0;
+ for (G4int i=0; i<pVolStore->size(); i++)
+ if ((*pVolStore)[i] == located) volIndex = i;
+ // G4int volIndex=G4int(pVolStore->index(located));
+ newReg=volIndex+1;
+ newLttc=jrLtGeant[LttcFlagGeant];
+ flagErr=newReg;
+#ifdef G4GEOMETRY_DEBUG
+ G4cout << "Located Physical volume = ";
+ G4cout << located->GetName() << G4endl;
+#endif
+ }
+}
+
+
+
+
--- /dev/null
+// $Id$
+// Flugg tag $Name$
+
+///////////////////////////////////////////////////////////////////
+//
+// WrapLookMG.hh - Sara Vanini 26/X/99
+//
+// Wrapper for localisation of particle for magnetic field tracking
+//
+// modified 13/IV/00: check if point belongs to one of the lattice
+// histories stored in jrLtGeant
+//
+// modified 24.10.01: by I. Hrivnacova
+// functions declarations separated from implementation
+// (moved to Wrappers.hh);
+//
+///////////////////////////////////////////////////////////////////
+
+
+#include "Wrappers.hh"
+#include "FGeometryInit.hh"
+#include "NavHistWithCount.hh"
+#include "G4PhysicalVolumeStore.hh"
+#include "G4NormalNavigation.hh"
+#include "G4VoxelNavigation.hh"
+#include "G4ParameterisedNavigation.hh"
+#include "G4ReplicaNavigation.hh"
+#include "globals.hh"
+
+
+//auxiliary function declarations
+extern G4bool PointLocate(const G4NavigationHistory &,
+ const G4ThreeVector &,
+ const G4ThreeVector *,
+ G4int &);
+extern EVolume CharacteriseDaughters(const G4LogicalVolume *);
+
+
+void lkmgwr(G4double& pSx, G4double& pSy, G4double& pSz,
+ G4double* pV, const G4int& oldReg, const G4int& oldLttc,
+ G4int& flagErr, G4int& newReg, G4int& newLttc)
+{
+//flag
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"============= LKMGWR =============="<<G4endl;
+#endif
+
+//Geoinit, Navigator, etc. pointers
+ static FGeometryInit * ptrGeoInit = FGeometryInit::GetInstance();
+ G4Navigator * ptrNavig = ptrGeoInit->getNavigatorForTracking();
+ G4PhysicalVolumeStore * pVolStore = G4PhysicalVolumeStore::GetInstance();
+
+//setting variables (and dimension: Fluka uses cm.!)
+ G4ThreeVector globalPointcm(pSx,pSy,pSz);
+ G4ThreeVector globalPoint = globalPointcm * 10.; //in mm.
+ G4ThreeVector globalDirection(pV[0],pV[1],pV[2]);
+
+//get jrLtGeant array and initialize variables
+ G4int * jrLtGeant = ptrGeoInit->GetJrLtGeantArray();
+ G4int LttcFlagGeant = ptrGeoInit->GetLttcFlagGeant();
+ G4bool belongToVolume = false;
+ G4int i = LttcFlagGeant;
+ G4int regionIn = 0;
+ newReg = -1;
+ newLttc = -1;
+
+ while(!belongToVolume && i>=0)
+ {
+ //get history from jrLtGeant
+ NavHistWithCount * ptrNavHistCount = reinterpret_cast
+ <NavHistWithCount*>(jrLtGeant[i]);
+ const G4NavigationHistory * ptrNavHist =
+ ptrNavHistCount->GetNavHistPtr();
+
+ //check if globalPoint belongs to volume (can't call
+ //LocateGlobalPoint... because of flag settings)
+ belongToVolume = PointLocate(*ptrNavHist,globalPoint,
+ &globalDirection,regionIn);
+
+
+ //if point belongs to surface, check scalar product direction*normal
+ if(regionIn==-100)
+ {
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"On surface!"<<G4endl;
+#endif
+
+ //if entering, then point belongs to volume,
+ //if exiting, point doesn't belong to volume.
+ G4int oldReg,flagErr,reg;
+ G4double x,y,z,px,py,pz;
+ G4double * norml = new G4double[3];
+ x = globalPoint.x();
+ y = globalPoint.y();
+ z = globalPoint.z();
+ px = globalDirection.x();
+ py = globalDirection.y();
+ pz = globalDirection.z();
+
+ nrmlwr(x,y,z,px,py,pz,norml,oldReg,reg,flagErr);
+
+ G4ThreeVector normal(norml[0],norml[1],norml[2]);
+#ifdef G4GEOMETRY_DEBUG
+ // G4cout<<"Scalar product="<<globalDirection.dot(normal)<<G4endl;
+#endif
+ if(globalDirection.dot(normal)>0)
+ {
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"entering volume!"<<G4endl;
+#endif
+ G4int volIndex = 0;
+ for (G4int i=0; i<pVolStore->size(); i++)
+ if ((*pVolStore)[i] == ptrNavHist->GetTopVolume()) volIndex = i;
+
+ //regionIn = G4int(pVolStore->index(ptrNavHist->GetTopVolume()))+1;
+ regionIn = volIndex+1;
+ belongToVolume = true;
+ }
+ }
+
+ i -= 1;
+ }
+
+//output variables
+ if(belongToVolume)
+ {
+ newReg = regionIn;
+ newLttc = jrLtGeant[i+1];
+ }
+ G4int numVol = G4int(pVolStore->size());
+ flagErr=numVol+2; //flagErr=fluka region number + 1
+
+
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"Global point (cm): "<<globalPointcm<<G4endl;
+ G4cout<<"Direction: "<<globalDirection<<G4endl;
+ if(newReg!=-1) G4cout<<"Point belongs to region "<<newReg<<
+ " ptr history="<<newLttc<<G4endl;
+ else G4cout<<"No containing volume found!"<<G4endl;
+#endif
+}
+
+
+
+
+//returns false if the point doesn't belong to history top volume (can either
+//belong to one of its daughter volumes or none), otherwise returns true.
+
+extern G4bool PointLocate(const G4NavigationHistory & blockedHistConst,
+ const G4ThreeVector & globalPoint,
+ const G4ThreeVector * pGlobalDirection,
+ G4int & reg)
+{
+
+//variables
+ G4NavigationHistory * fHistory = new G4NavigationHistory(blockedHistConst);
+ G4bool belongVolume;
+
+ //G4 flags resetted (see: ResetStackAndState)
+ G4bool fExiting = false;
+ G4VPhysicalVolume * fBlockedPhysicalVolume=0;
+ G4int fBlockedReplicaNo=-1;
+ G4bool fLocatedOnEdge=false;
+
+ G4bool notKnownContained=true,noResult;
+ G4VPhysicalVolume *targetPhysical;
+ G4LogicalVolume *targetLogical;
+ G4VSolid *targetSolid;
+ G4ThreeVector localPoint,localDirection;
+ EInside insideCode;
+
+
+//Helpers/Utility classes
+ G4NormalNavigation fnormalNav;
+ G4VoxelNavigation fvoxelNav;
+ G4ParameterisedNavigation fparamNav;
+ G4ReplicaNavigation freplicaNav;
+ G4PhysicalVolumeStore * pVolStore = G4PhysicalVolumeStore::GetInstance();
+
+//local variables
+ localPoint=fHistory->GetTopTransform().TransformPoint(globalPoint);
+ localDirection=fHistory->GetTopTransform().TransformPoint(*pGlobalDirection);
+
+//search if volume contains point
+ if (fHistory->GetTopVolumeType()!=kReplica)
+ {
+ targetSolid=fHistory->GetTopVolume()->GetLogicalVolume()->GetSolid();
+ insideCode=targetSolid->Inside(localPoint);
+ }
+ else
+ {
+ insideCode=freplicaNav.BackLocate(*fHistory,globalPoint,
+ localPoint,fExiting,notKnownContained);
+ // !CARE! if notKnownContained returns false then the point is within
+ // the containing placement volume of the replica(s). If insidecode
+ // will result in the history being backed up one level, then the
+ // local point returned is the point in the system of this new level
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"Replica: fExiting="<<fExiting<<G4endl;
+ G4cout<<" notKnownContained="<<notKnownContained<<G4endl;
+#endif
+ }
+
+ if (insideCode==kOutside) belongVolume = false;
+
+ else if (insideCode==kSurface)
+ {
+ belongVolume = false;
+ reg = -100;
+ }
+ else
+ {
+ // Search downwards in daughter volumes
+ // until deepest containing volume found
+ //
+ // 3 Cases:
+ //
+ // o Parameterised daughters
+ // =>Must be one G4PVParameterised daughter & voxels
+ // o Positioned daughters & voxels
+ // o Positioned daughters & no voxels
+
+ belongVolume = true;
+ noResult=true;
+
+ do
+ {
+ // Determine `type' of current mother volume
+ targetPhysical=fHistory->GetTopVolume();
+ targetLogical=targetPhysical->GetLogicalVolume();
+ switch(CharacteriseDaughters(targetLogical))
+ {
+ case kNormal:
+ if (targetLogical->GetVoxelHeader())
+ {
+ noResult=fvoxelNav.LevelLocate(*fHistory,
+ fBlockedPhysicalVolume,
+ fBlockedReplicaNo,
+ globalPoint,
+ pGlobalDirection,
+ fLocatedOnEdge,
+ localPoint);
+ }
+ else
+ {
+ noResult=fnormalNav.LevelLocate(*fHistory,
+ fBlockedPhysicalVolume,
+ fBlockedReplicaNo,
+ globalPoint,
+ pGlobalDirection,
+ fLocatedOnEdge,
+ localPoint);
+ }
+ break;
+ case kReplica:
+ noResult=freplicaNav.LevelLocate(*fHistory,
+ fBlockedPhysicalVolume,
+ fBlockedReplicaNo,
+ globalPoint,
+ pGlobalDirection,
+ fLocatedOnEdge,
+ localPoint);
+ break;
+ case kParameterised:
+ noResult=fparamNav.LevelLocate(*fHistory,
+ fBlockedPhysicalVolume,
+ fBlockedReplicaNo,
+ globalPoint,
+ pGlobalDirection,
+ fLocatedOnEdge,
+ localPoint);
+ break;
+ }
+
+ // LevelLocate search in the first daughter level.
+ // LevelLocate returns noResult=true if it finds a daughter volume
+ // in which globalPoint is inside (or on the surface). So point
+ // doesn't belong only to mother volume ==> belongVolume=false.
+
+ if (noResult)
+ {
+ // The blocked volume no longer valid - it was for another level
+ fBlockedPhysicalVolume= 0;
+ fBlockedReplicaNo= -1;
+ belongVolume=false;
+ }
+ } while (noResult);
+
+ //on exit targetPhysical is the volume globalPoint belongs to;
+ G4int volIndex = 0;
+ for (G4int i=0; i<pVolStore->size(); i++)
+ if ((*pVolStore)[i] == targetPhysical) volIndex = i;
+ //reg = G4int(pVolStore->index(targetPhysical))+1;
+ reg = volIndex+1;
+ }
+
+ delete fHistory;
+ return belongVolume;
+}
+
+extern EVolume CharacteriseDaughters(const G4LogicalVolume *pLog)
+{
+ EVolume type;
+ EAxis axis;
+ G4int nReplicas;
+ G4double width,offset;
+ G4bool consuming;
+ G4VPhysicalVolume *pVol;
+
+ if (pLog->GetNoDaughters()==1)
+ {
+ pVol=pLog->GetDaughter(0);
+ if (pVol->IsReplicated())
+ {
+ pVol->GetReplicationData(axis,nReplicas,width,offset,consuming);
+ type=(consuming) ? kReplica : kParameterised;
+ }
+ else
+ {
+ type=kNormal;
+ }
+ }
+ else
+ {
+ type=kNormal;
+ }
+ return type;
+}
+
+
+
--- /dev/null
+// $Id$
+// Flugg tag $Name$
+
+///////////////////////////////////////////////////////////////////
+//
+// WrapLookZ.hh - Sara Vanini
+//
+// Wrapper for localisation of starting point of particle.
+//
+// modified 20/III/00: history initialization moved to ISVHWR
+// modified 13/IV/00: located history saved in jrLtcGeant and
+// incremented
+// modified 24.10.01: by I. Hrivnacova
+// functions declarations separated from implementation
+// (moved to Wrappers.hh);
+//
+//////////////////////////////////////////////////////////////////
+
+
+#include "Wrappers.hh"
+#include "FGeometryInit.hh"
+#include "G4VPhysicalVolume.hh"
+#include "G4Navigator.hh"
+#include "G4ThreeVector.hh"
+#include "G4PhysicalVolumeStore.hh"
+#include "globals.hh"
+
+void lkwr(G4double& pSx, G4double& pSy, G4double& pSz,
+ G4double* pV, const G4int& oldReg, const G4int& oldLttc,
+ G4int& newReg, G4int& flagErr, G4int& newLttc)
+{
+//flag
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"======= LKWR ======="<<G4endl;
+#endif
+
+//FGeometryInit, navigator, volumeStore pointers
+ static FGeometryInit * ptrGeoInit = FGeometryInit::GetInstance();
+ G4Navigator * ptrNavig = ptrGeoInit->getNavigatorForTracking();
+ G4PhysicalVolumeStore * pVolStore = G4PhysicalVolumeStore::GetInstance();
+
+//coordinates in mm.
+ G4ThreeVector pSource(pSx,pSy,pSz);
+ pSource *= 10.0; //in millimeters!
+
+//locate point and update histories
+ G4TouchableHistory * ptrTouchableHistory =
+ ptrGeoInit->GetTouchableHistory();
+ ptrNavig->LocateGlobalPointAndUpdateTouchable(pSource,0,
+ ptrTouchableHistory,true);
+ //updating tmp but not old histories, they are useful in
+ //case of RGRPWR call, or when fluka, after a LOOKZ call,
+ //descards step for multiple scattering and returns to old history
+ //NO, after lattice-fix we don't need old history anymore!
+
+ ptrGeoInit->UpdateHistories(ptrTouchableHistory->GetHistory(),0);
+ G4VPhysicalVolume * located = ptrTouchableHistory->GetVolume();
+
+//if volume not found, out of mother volume: returns "number of volumes"+1
+ if(!located)
+ {
+#ifdef G4GEOMETRY_DEBUG
+ G4cout << "Out of mother volume!";
+#endif
+ G4int numVol = G4int(pVolStore->size());
+ newReg = numVol + 1;
+ }
+ else
+ {
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"* ISVHWR call to store current NavHistWithCount in jrLtGeant"
+ <<G4endl;
+#endif
+
+ //save history in jrLtGeant and increment counter
+ G4int * jrLtGeant = ptrGeoInit->GetJrLtGeantArray();
+ G4int LttcFlagGeant = ptrGeoInit->GetLttcFlagGeant();
+ LttcFlagGeant += 1;
+ jrLtGeant[LttcFlagGeant] = isvhwr(0,0);
+
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"* CONHWR call to increment counter"<<G4endl;
+#endif
+ G4int incrCount=1;
+ conhwr(jrLtGeant[LttcFlagGeant],&incrCount);
+
+ //update LttcFlagGeant
+ ptrGeoInit->SetLttcFlagGeant(LttcFlagGeant);
+
+ //return region number and dummy variables
+ G4int volIndex = 0;
+ for (G4int i=0; i<pVolStore->size(); i++)
+ if ((*pVolStore)[i] == located) volIndex = i;
+ //G4int volIndex=G4int(pVolStore->index(located));
+ newReg=volIndex+1;
+ newLttc=jrLtGeant[LttcFlagGeant];
+ flagErr=newReg;
+#ifdef G4GEOMETRY_DEBUG
+ G4cout << "Located Physical volume = ";
+ G4cout << located->GetName() << G4endl;
+#endif
+ }
+}
+
+
+
+
--- /dev/null
+// $Id$
+// Flugg tag $Name$
+
+///////////////////////////////////////////////////////////////////
+//
+// WrapMag.hh - Sara Vanini
+//
+// Wrapper for geometry tracking in magnetic field: returns magnetic
+// field values in a given position.
+//
+// modified 26/X/1998
+// modified 18/XI/1999
+// modified 24.10.01: by I. Hrivnacova
+// functions declarations separated from implementation
+// (moved to Wrappers.hh);
+//
+/////////////////////////////////////////////////////////////////
+
+
+#include "Wrappers.hh"
+#include "FGeometryInit.hh"
+#include "globals.hh"
+
+void magfld(const G4double& pX, const G4double& pY, const G4double& pZ,
+ G4double& cosBx, G4double& cosBy, G4double& cosBz,
+ G4double& Bmag, G4int& reg, G4int& idiscflag)
+
+{
+//flag
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"================== MAGFLD ================="<<G4endl;
+#endif
+
+//Geoinit Pointer
+ FGeometryInit * ptrGeoInit=FGeometryInit::GetInstance();
+
+//get FieldManager, Field pointers for magnetic field handling
+ G4FieldManager * pFieldMgr = ptrGeoInit->getFieldManager();
+ const G4Field * ptrField = pFieldMgr->GetDetectorField();
+
+//compute field
+ G4double point[3];
+ point[0] = pX*10.;
+ point[1] = pY*10.;
+ point[2] = pZ*10.;
+ G4double B[3];
+ ptrField->GetFieldValue(point,B);
+ G4double Bnor = sqrt(sqr(B[0])+sqr(B[1])+sqr(B[2]));
+ if(Bnor)
+ {
+ cosBx = B[0]/Bnor;
+ cosBy = B[1]/Bnor;
+ cosBz = B[2]/Bnor;
+ }
+ else
+ {
+ cosBx = 0;
+ cosBy = 0;
+ cosBz = 1;
+ }
+
+ Bmag = Bnor/tesla;
+ idiscflag = 0;
+}
+
+
+
+
--- /dev/null
+// $Id$
+// Flugg tag $Name$
+
+////////////////////////////////////////////////////////////////////
+//
+// WrapNorml.hh - Sara Vanini
+//
+// Wrapper for computing normal unit-vector in global coordinates.
+//
+// Fluka requires normal vector exiting from final position (of
+// particle) volume, that is: entering in volume of initial position.
+// Geant4 always computes the normal vector exiting from the volume.
+// In GetLocalExitNormal() call the volume is the pre-step volume
+// (so G4 normal vector sign is opposite of fluka-required normal).
+// If IsLocalExitNormalValid=false, normal value is computed from
+// init-step volume (in this case sign must change), or from
+// end-step volume (the sign is the same). Normal vector is computed
+// always on boundary between volumes, in global coordinates (to take
+// rotation of parameterised volumes in hierarchy in consideration).
+// So: nrmlwr returns inwards pointing unit normal of the shape for
+// surface closest to the point returned by the navigator (last step
+// end-point).
+//
+// modified 10/III/99
+// modified 25/V/00
+// modified 7/VI/00 for boundary-crossing in case of relocation
+// modified 5/VII/00 geometry error on boundary fixed
+// modified 24.10.01: by I. Hrivnacova
+// functions declarations separated from implementation
+// (moved to Wrappers.hh);
+//
+////////////////////////////////////////////////////////////////////
+
+#include "Wrappers.hh"
+#include "FGeometryInit.hh"
+#include "G4VPhysicalVolume.hh"
+#include "G4Navigator.hh"
+#include "G4ThreeVector.hh"
+#include "globals.hh"
+
+
+//StepAndLocation declaration
+extern G4int StepAndLocation(G4ThreeVector &, const G4ThreeVector &,
+ const G4double &, G4double &, G4double &,
+ G4bool &, G4bool &, const G4int &);
+
+void nrmlwr(G4double& pSx, G4double& pSy, G4double& pSz,
+ G4double& pVx, G4double& pVy, G4double& pVz,
+ G4double* norml, const G4int& oldReg,
+ const G4int& newReg, G4int& flagErr)
+{
+//flag
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"============ NRMLWR-DBG ============="<<G4endl;
+#endif
+
+//dummy variables
+ flagErr=0;
+
+//navigator pointer
+ static FGeometryInit * ptrGeoInit;
+ ptrGeoInit = FGeometryInit::GetInstance();
+ G4Navigator * ptrNavig = ptrGeoInit->getNavigatorForTracking();
+
+//variables
+ G4ThreeVector normalLoc;
+ G4ThreeVector normalGlob;
+
+//normal computing
+ if(ptrNavig->IsExitNormalValid())
+ {
+ normalLoc=ptrNavig->GetLocalExitNormal();
+ normalLoc *= -1;
+
+ //global cooordinates normal
+ normalGlob = ptrNavig->GetLocalToGlobalTransform().
+ TransformAxis(normalLoc);
+ }
+ else
+ {
+ G4VPhysicalVolume *touchvolume;
+ G4ThreeVector theLocalPoint;
+
+ if(ptrNavig->EnteredDaughterVolume())
+ {
+ //volume from touchable history
+ G4TouchableHistory *ptrTouchableHistory=ptrGeoInit->
+ GetTouchableHistory();
+ touchvolume = ptrTouchableHistory->GetVolume();
+
+ //local point from navigator and normal
+ theLocalPoint = ptrNavig->GetCurrentLocalCoordinate();
+ normalLoc = touchvolume->GetLogicalVolume()->GetSolid()->
+ SurfaceNormal(theLocalPoint);
+
+ //global cooordinates normal
+ normalGlob = ptrNavig->GetLocalToGlobalTransform().
+ TransformAxis(normalLoc);
+ }
+ else
+ {
+ //volume from old history
+ const G4NavigationHistory * ptrOldNavHist =
+ ptrGeoInit->GetOldNavHist()->GetHistory();
+ touchvolume = ptrOldNavHist->GetTopVolume();
+
+ if(!touchvolume)
+ {
+ // Old history has been reseted by LOOKZ relocation,
+ // so is necessary to track back and forward to find
+ // the right histories.
+
+
+ //////////// COMPUTE STEP BACKWARD //////////////////
+ G4ThreeVector theGlobalPoint = ptrNavig->
+ GetLocalToGlobalTransform().TransformPoint
+ (ptrNavig->GetCurrentLocalCoordinate());
+
+ //compute step and new location
+ G4ThreeVector pVec(pVx,pVy,pVz);
+ pVec=-pVec;
+ G4double appStep = 0;
+ G4double safety = 0;
+ G4bool onBoundary = false;
+ G4double physStep = 1000000000;
+ G4int newRegStep;
+ G4ThreeVector partLoc = theGlobalPoint;
+ G4bool fErr=false;
+
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"Old history not found"<<G4endl;
+ G4cout<<"* NRML needs boundary-crossing: computing step backward..."<<G4endl;
+#endif
+
+ //compute step and location
+ newRegStep=StepAndLocation(partLoc,pVec,physStep,
+ appStep,safety,onBoundary,
+ fErr,oldReg);
+
+ G4PhysicalVolumeStore * pVolStore = G4PhysicalVolumeStore::
+ GetInstance();
+
+ if(appStep<physStep && newRegStep!=G4int(pVolStore->size())+1)
+ {
+ //end-step point is on boundary between volumes;
+ //==> update step-histories
+
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"* updating step-histories"<<G4endl;
+#endif
+
+ G4TouchableHistory * ptrTouchHist =
+ ptrGeoInit->GetTouchableHistory();
+ ptrGeoInit->UpdateHistories(ptrTouchHist->GetHistory(),2);
+ }
+ else
+ {
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"ERROR! Boundary not found"<<G4endl;
+#endif
+ }
+
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"* computing step forward..."<<G4endl;
+#endif
+ pVec=-pVec;
+ safety = 0;
+ onBoundary = false;
+
+ //compute step and location for boundary crossing
+ newRegStep=StepAndLocation(partLoc,pVec,physStep,
+ appStep,safety,onBoundary,fErr,oldReg);
+ if(appStep<physStep)
+ {
+ //end-step point is on boundary between volumes;
+ //==> update step-histories
+
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"* updating step-histories"<<G4endl;
+#endif
+
+ G4TouchableHistory * ptrTouchHist =
+ ptrGeoInit->GetTouchableHistory();
+ ptrGeoInit->UpdateHistories(ptrTouchHist->GetHistory(),2);
+ }
+ }
+
+ // now touchvolume exist.
+ // local point from navigator and global point
+ // N.B. if particle has exited world volume,
+ // G4Navigator doesn't update lastLocatedPoint.
+ // So be carefull in building geometry always to have a
+ // big world volume that fluka won't exit.
+
+ touchvolume = ptrOldNavHist->GetTopVolume();
+
+ G4ThreeVector theGlobalPoint = ptrNavig->
+ GetLocalToGlobalTransform().TransformPoint
+ (ptrNavig->GetCurrentLocalCoordinate());
+ theLocalPoint = ptrOldNavHist->GetTopTransform().
+ TransformPoint(theGlobalPoint);
+ normalLoc = (touchvolume->GetLogicalVolume()
+ ->GetSolid()->
+ SurfaceNormal(theLocalPoint));
+ normalLoc *= -1;
+
+ //global cooordinates normal
+ normalGlob = ptrOldNavHist->GetTopTransform().
+ Inverse().TransformAxis(normalLoc);
+ }
+ }
+
+ //return normal:
+ norml[0]=G4double(normalGlob.x());
+ norml[1]=G4double(normalGlob.y());
+ norml[2]=G4double(normalGlob.z());
+
+ //for debugging
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"Normal: "<<normalGlob<<G4endl;
+#endif
+}
+
+
--- /dev/null
+// $Id$
+// Flugg tag $Name$
+
+///////////////////////////////////////////////////////////////////
+//
+// WrapReg.hh - Sara Vanini
+//
+// Wrapper for scoring hits: previous step end-point is taken from
+// history (and compared with fluka region index, flukaReg),
+// then the wrapper returns all the information regarding the
+// volume tree, i.e. returns indMother[] array with all the
+// mother volumes index and repMother[] array with all the
+// mother volumes repetition number.
+//
+// modified: 16/III/99
+// modified: 14/IV/00 ptrLttc included
+// modified 24.10.00: by I. Hrivnacova
+// functions declarations separated from implementation
+// (moved to Wrappers.hh);
+//
+///////////////////////////////////////////////////////////////////
+
+#include "Wrappers.hh"
+#include "FGeometryInit.hh"
+#include "NavHistWithCount.hh"
+#include "G4VPhysicalVolume.hh"
+#include "G4Navigator.hh"
+#include "G4ThreeVector.hh"
+#include "G4PhysicalVolumeStore.hh"
+#include "globals.hh"
+
+
+void rgrpwr(const G4int& flukaReg, const G4int& ptrLttc, G4int& g4Reg,
+ G4int* indMother, G4int* repMother, G4int& depthFluka)
+{
+//flag
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"============= RGRPWR =============="<<G4endl;
+ G4cout<<"ptrLttc="<<ptrLttc<<G4endl;
+#endif
+
+//Geoinit, Navigator, VolStore pointers
+ static FGeometryInit * ptrGeoInit = FGeometryInit::GetInstance();
+ G4Navigator * ptrNavig = ptrGeoInit->getNavigatorForTracking();
+ G4PhysicalVolumeStore * pVolStore = G4PhysicalVolumeStore::GetInstance();
+
+//get jrLtGeant array and flag
+ G4int * jrLtGeant = ptrGeoInit->GetJrLtGeantArray();
+ G4int LttcFlagGeant = ptrGeoInit->GetLttcFlagGeant();
+
+ G4bool foundHistory = false;
+ G4int i = LttcFlagGeant;
+
+ while(!foundHistory && i>=0)
+ {
+ if(jrLtGeant[i]==ptrLttc) foundHistory = true;
+ i -= 1;
+ }
+
+ if(!foundHistory)
+ {
+ G4cout<<"* ERROR! History not in jrLtGeant!"<<G4endl;
+ //only in debugging version....
+ assert(foundHistory);
+ }
+ else
+ {
+ //get history pointer from ptrLttc
+ NavHistWithCount* ptrNavHistCount = reinterpret_cast
+ <NavHistWithCount*>(ptrLttc);
+ G4NavigationHistory* ptrNavHist = ptrNavHistCount->GetNavHistPtr();
+
+ G4VPhysicalVolume* ptrVolHistory;
+ G4int volHistIndex = 0;
+ G4int depth = ptrNavHist->GetDepth();
+ for(G4int h=0; h<=depth; h++)
+ {
+ ptrVolHistory = ptrNavHist->GetVolume(h);
+ for (G4int i=0; i<pVolStore->size(); i++)
+ if ((*pVolStore)[i] == ptrVolHistory) volHistIndex = i;
+ //volHistIndex = G4int(pVolStore->index(ptrVolHistory));
+ indMother[h] = volHistIndex+1;
+ if(ptrVolHistory->IsReplicated())
+ {
+ //true if volume is replica or parameterized,
+ //false for placements; repetition numbers
+ //are set: 1,2,3,etc.; 0 for placed volumes.
+ repMother[h] = 1+G4int(ptrNavHist->GetReplicaNo(h));
+ }
+ else
+ {
+ repMother[h] = 0;
+ }
+
+#ifdef G4GEOMETRY_DEBUG
+ // G4cout<<"Level="<<h<<" : ";
+ // G4cout<<"Region="<<indMother[h]<<" (repetition="<<
+ // repMother[h]<<")"<<G4endl;
+#endif
+ }
+
+ //compute new region index
+ G4int volIndex = 0;
+ for (G4int i=0; i<pVolStore->size(); i++)
+ if ((*pVolStore)[i] == ptrVolHistory) volIndex = i;
+ //G4int volIndex=G4int(pVolStore->index(ptrVolHistory));
+ g4Reg=volIndex+1;
+
+ depthFluka = G4int(depth);
+ }
+
+}
+
+
+
+
+
--- /dev/null
+// $Id$
+// Flugg tag $Name$
+
+///////////////////////////////////////////////////////////////////
+//
+// WrapSavHist.hh - Sara Vanini
+//
+// Wrapper for saving current navigation history (fCheck=default)
+// and returning its pointer. If fCheck=-1 copy of history pointed
+// by intHist is made in NavHistWithCount object, and its pointer
+// is returned. fCheck=1 and fCheck=2 cases are only in debugging
+// version: an array is created by means of FGeometryInit functions
+// (but could be a static int * ptrArray = new int[10000] with
+// file scope as well) that stores a flag for deleted/undeleted
+// histories and at the end of event is checked to verify that
+// all saved history objects have been deleted.
+//
+// modified 6/III/99: history check array implemented
+// modified 14/IV/00: fCheck=-1 case modified
+// modified 24.10.01: by I. Hrivnacova
+// functions declarations separated from implementation
+// (moved to Wrappers.hh);
+//
+//////////////////////////////////////////////////////////////////
+
+
+#include "Wrappers.hh"
+#include "FGeometryInit.hh"
+#include "NavHistWithCount.hh"
+#include "G4TouchableHistory.hh"
+#include "globals.hh"
+
+G4int isvhwr(const G4int& fCheck, const G4int& intHist)
+{
+//flag
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"============= ISVHWR =============="<<endl;
+ G4cout<<"fCheck="<<fCheck<<endl;
+ if(fCheck==-1) G4cout<<"intHist="<<intHist<<endl;
+#endif
+
+//Geoinit pointer
+ static FGeometryInit * ptrGeoInit = FGeometryInit::GetInstance();
+ static G4int j=0;
+
+ switch (fCheck)
+ {
+ case 1:
+ {
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"Start event."<<endl;
+#endif
+
+ return 0;
+ }
+
+ case 2:
+ {
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"End event. Check histories in debug-array..."<<endl;
+#endif
+
+ //check that all fluka-banked histories have been delated
+ // commented by A.Solodkov
+/*
+ G4int * ptrArray = ptrGeoInit->GetHistArray();
+
+ for(G4int k=0;k<j;k++)
+ {
+ NavHistWithCount* ptrNavHistCount=reinterpret_cast
+ <NavHistWithCount*>(ptrArray[k]);
+
+ if(ptrArray[k] && !ptrNavHistCount->GetDelateFlag())
+ G4cout<<"WARNING! History pointed by "<<ptrArray[k]<<
+ " has not been deleted at end of event"<<endl;
+ }
+
+ //reinitialise debug histories array
+ for(G4int i=0;i<1000000;i++) ptrArray[i]=0;
+*/
+ j=0;
+
+ return 0;
+ }
+
+ case -1:
+ {
+ //get history object from intHist
+ NavHistWithCount* ptrNavHistCountCopy = reinterpret_cast
+ <NavHistWithCount*>(intHist);
+ G4NavigationHistory* ptrNavHistCopy =
+ ptrNavHistCountCopy->GetNavHistPtr();
+
+ //copy history in another NavHistWithCount object
+ //and save index of check-array
+ NavHistWithCount * ptrNavHistCount = new NavHistWithCount
+ (*(ptrNavHistCopy));
+ ptrNavHistCount->SaveCheckInd(j);
+ G4int intHistCopy = G4int(ptrNavHistCount);
+
+ //store ptr in array
+ // commented by PS
+ //G4int * ptrArray = ptrGeoInit->GetHistArray();
+ //ptrArray[j]=intHistCopy;
+ j+=1;
+
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"Copying history..."<<endl;
+ G4cout<<"Ptr History-copy ="<<intHistCopy<<endl;
+ G4cout<<*ptrNavHistCopy<<endl;
+#endif
+
+ return intHistCopy;
+ }
+
+ default:
+ {
+ //TouchableHistory and prtArray pointers
+ G4TouchableHistory * ptrTouchHist=ptrGeoInit->GetTouchableHistory();
+ G4int * ptrArray = ptrGeoInit->GetHistArray();
+
+ //save G4NavigationHistory and index of check-array
+ NavHistWithCount *ptrNavHistCount = new NavHistWithCount(*(ptrGeoInit->
+ GetTempNavHist()->GetHistory()));
+
+ ptrNavHistCount->SaveCheckInd(j);
+ G4int histInt=G4int(ptrNavHistCount);
+
+ //store ptr in array
+ // comented by PS
+ // ptrArray[j]=histInt;
+ j+=1;
+
+#ifdef G4GEOMETRY_DEBUG
+ G4cout<<"Saving history..."<<endl;
+ G4cout<<"Ptr saved History="<<histInt<<endl;
+ G4cout<<*(ptrTouchHist->GetHistory())<<endl;
+#endif
+
+ return histInt;
+ }
+ }
+}
+
+
+
+
+
+
--- /dev/null
+# Sara Vanini 3/III/2000
+# -----------------------------------------------------------
+# GNUmakefile for dummyG4 classes library.
+# -----------------------------------------------------------
+
+name := G4dummy
+
+ifndef FLUGGINSTALL
+ FLUGGINSTALL = ../..
+endif
+
+include $(FLUGGINSTALL)/config/architecture.gmk
+
+CPPFLAGS += \
+ -I$(G4BASE_G4)/global/management/include \
+ -I$(G4BASE_G4)/global/STLInterface \
+ -I$(G4BASE_G4)/global/HEPRandom/include \
+ -I$(G4BASE_G4)/global/HEPGeometry/include \
+ -I$(G4BASE_G4)/global/HEPNumerics/include \
+ -I$(G4BASE_G4)/geometry/management/include
+
+include $(FLUGGINSTALL)/config/common.gmk
+
+.PHONY: global
+
+global: lib
+
--- /dev/null
+// 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$
+// GEANT4 tag $Name$
+//
+
+// dummy (required by G3toG4)
+
+#ifndef G4Decay_h
+#define G4Decay_h 1
+
+#include "globals.hh"
+
+class G4Decay
+{
+ public:
+ G4Decay(const G4String&);
+ ~G4Decay();
+};
+
+
+
+
+#endif
+
--- /dev/null
+//---------------------------------------------------------------
+//
+// dummy G4FastSimulationManager.hh
+//
+//---------------------------------------------------------------
+
+
+#ifndef G4FastSimulationManager_h
+#define G4FastSimulationManager_h 1
+
+#include "G4LogicalVolume.hh"
+
+class G4FastSimulationManager
+{
+public:
+ G4FastSimulationManager(G4LogicalVolume* logVol);
+ ~G4FastSimulationManager();
+};
+
+#endif
--- /dev/null
+// 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$
+// GEANT4 tag $Name$
+//
+
+// dummy (required by G3toG4)
+
+#ifndef G4ParticleDefinition_h
+#define G4ParticleDefinition_h 1
+
+#include "globals.hh"
+
+class G4ParticleDefinition
+{
+ public:
+ G4ParticleDefinition();
+ ~G4ParticleDefinition();
+
+ const G4String& GetParticleName() const;
+ const G4String& GetParticleType() const;
+ G4double GetPDGCharge() const;
+
+ private:
+ G4String theParticleName;
+ G4String theParticleType;
+};
+
+#endif
+
--- /dev/null
+// 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$
+// GEANT4 tag $Name$
+//
+
+#ifndef G4SDManager_h
+#define G4SDManager_h 1
+
+class G4SDManager
+{
+ protected:
+ G4SDManager();
+
+ public:
+ ~G4SDManager();
+
+};
+
+
+
+
+#endif
+
--- /dev/null
+// 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$
+// GEANT4 tag $Name$
+//
+
+// dummy (required by TGeant4)
+
+#ifndef G4Track_h
+#define G4Track_h 1
+
+#include "globals.hh"
+#include "G4ParticleDefinition.hh"
+#include "G4VProcess.hh"
+
+class G4Track
+{
+ public:
+ G4Track();
+ ~G4Track();
+
+ G4ParticleDefinition* GetDefinition() const {return 0;}
+ const G4VProcess* GetCreatorProcess() const {return 0;}
+};
+
+#endif
+
--- /dev/null
+// 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$
+// GEANT4 tag $Name$
+//
+
+// dummy (required by TGeant4)
+
+#ifndef G4VProcess_h
+#define G4VProcess_h 1
+
+#include "globals.hh"
+
+class G4VProcess
+{
+ public:
+ G4VProcess(const G4String&);
+ ~G4VProcess();
+
+ const G4String& GetProcessName() const {return theProcessName;}
+ // Returns the name of the process.
+
+ private:
+ G4String theProcessName;
+};
+
+
+
+
+#endif
+
--- /dev/null
+// 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$
+// GEANT4 tag $Name$
+//
+
+// dummy (required by G3toG4)
+
+#ifndef G4VSensitiveDetector_h
+#define G4VSensitiveDetector_h 1
+
+#include "globals.hh"
+
+class G4VSensitiveDetector
+{
+ public:
+ G4VSensitiveDetector();
+ ~G4VSensitiveDetector();
+
+ G4String GetName();
+};
+
+
+
+
+#endif
+
--- /dev/null
+// 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$
+// GEANT4 tag $Name$
+//
+
+#ifndef G4VUserDetectorConstruction_h
+#define G4VUserDetectorConstruction_h 1
+
+class G4VPhysicalVolume;
+
+// class description:
+//
+// This is the abstract base class of the user's mandatory initialization class
+// for detector setup. It has only one pure virtual method Construct() which is
+// invoked by G4RunManager when it's Initialize() method is invoked.
+// The Construct() method must return the G4VPhysicalVolume pointer which represents
+// the world volume.
+//
+
+class G4VUserDetectorConstruction
+{
+ public:
+ G4VUserDetectorConstruction();
+ virtual ~G4VUserDetectorConstruction();
+
+ public:
+ virtual G4VPhysicalVolume* Construct() = 0;
+};
+
+#endif
+
+
+
+
--- /dev/null
+// 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$
+// GEANT4 tag $Name$
+//
+
+// dummy (required by G3toG4)
+
+#include "G4Decay.hh"
+
+G4Decay::G4Decay(const G4String&)
+{
+}
+
+G4Decay::~G4Decay()
+{
+}
+
--- /dev/null
+//---------------------------------------------------------------
+//
+// dummy G4FastSimulationManager.cc
+//
+//---------------------------------------------------------------
+
+#include "G4FastSimulationManager.hh"
+#include "G4LogicalVolume.hh"
+
+
+G4FastSimulationManager::G4FastSimulationManager(G4LogicalVolume* logVol)
+{;}
+
+G4FastSimulationManager::~G4FastSimulationManager()
+{;}
--- /dev/null
+// 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$
+// GEANT4 tag $Name$
+//
+
+// dummy (required by G3toG4)
+
+#include "G4ParticleDefinition.hh"
+
+G4ParticleDefinition::G4ParticleDefinition()
+ : theParticleName(""),
+ theParticleType("")
+{
+}
+
+G4ParticleDefinition::~G4ParticleDefinition()
+{
+}
+
+const G4String& G4ParticleDefinition::GetParticleName() const
+{
+ return theParticleName;
+}
+
+const G4String& G4ParticleDefinition::GetParticleType() const
+{
+ return theParticleType;
+}
+
+G4double G4ParticleDefinition::GetPDGCharge() const
+{
+ return 0;
+}
--- /dev/null
+// 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$
+// GEANT4 tag $Name$
+//
+
+#include "G4SDManager.hh"
+
+G4SDManager::G4SDManager()
+{
+}
+
+G4SDManager::~G4SDManager()
+{
+}
+
--- /dev/null
+// 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$
+// GEANT4 tag $Name$
+//
+
+// dummy (required by TGeant4)
+
+#include "G4Track.hh"
+
+G4Track::G4Track()
+{
+}
+
+G4Track::~G4Track()
+{
+}
+
+
--- /dev/null
+// 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$
+// GEANT4 tag $Name$
+//
+
+// dummy (required by TGeant4)
+
+#include "G4VProcess.hh"
+
+G4VProcess::G4VProcess(const G4String& name)
+ : theProcessName(name)
+{
+}
+
+G4VProcess::~G4VProcess()
+{
+}
+
+
--- /dev/null
+// 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$
+// GEANT4 tag $Name$
+//
+
+// dummy (required by G3toG4)
+
+#include "G4VSensitiveDetector.hh"
+
+G4VSensitiveDetector::G4VSensitiveDetector()
+{
+}
+
+G4VSensitiveDetector::~G4VSensitiveDetector()
+{
+}
+
+G4String G4VSensitiveDetector::GetName()
+{
+ G4String name = "";
+ return name;
+}
--- /dev/null
+// 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$
+// GEANT4 tag $Name$
+//
+
+#include "G4VUserDetectorConstruction.hh"
+#include "G4VPhysicalVolume.hh"
+
+G4VUserDetectorConstruction::G4VUserDetectorConstruction()
+{;}
+
+G4VUserDetectorConstruction::~G4VUserDetectorConstruction()
+{;}
+