4 ///////////////////////////////////////////////////////////////////
6 // WrapLookZ.hh - Sara Vanini
8 // Wrapper for localisation of starting point of particle.
10 // modified 20/III/00: history initialization moved to ISVHWR
11 // modified 13/IV/00: located history saved in jrLtcGeant and
13 // modified 24.10.01: by I. Hrivnacova
14 // functions declarations separated from implementation
15 // (moved to Wrappers.hh);
16 // modified 17/06/02: by I. Gonzalez. STL migration
18 //////////////////////////////////////////////////////////////////
21 #include "Wrappers.hh"
22 #include "FGeometryInit.hh"
23 #include "G4VPhysicalVolume.hh"
24 #include "FluggNavigator.hh"
25 #include "G4ThreeVector.hh"
26 #include "G4PhysicalVolumeStore.hh"
29 #define G4GEOMETRY_DEBUG 1
31 void lkwr(G4double& pSx, G4double& pSy, G4double& pSz,
32 G4double* pV, const G4int& oldReg, const G4int& oldLttc,
33 G4int& newReg, G4int& flagErr, G4int& newLttc)
36 #ifdef G4GEOMETRY_DEBUG
37 G4cout << "======= LKWR =======" << G4endl;
40 //FGeometryInit, navigator, volumeStore pointers
41 static FGeometryInit * ptrGeoInit = FGeometryInit::GetInstance();
42 FluggNavigator * ptrNavig = ptrGeoInit->getNavigatorForTracking();
43 G4PhysicalVolumeStore * pVolStore = G4PhysicalVolumeStore::GetInstance();
46 G4ThreeVector pSource(pSx,pSy,pSz);
47 pSource *= 10.0; //in millimeters!
49 //locate point and update histories
50 G4TouchableHistory * ptrTouchableHistory =
51 ptrGeoInit->GetTouchableHistory();
52 ptrNavig->LocateGlobalPointAndUpdateTouchable(pSource,0,
53 ptrTouchableHistory,true);
54 //updating tmp but not old histories, they are useful in
55 //case of RGRPWR call, or when fluka, after a LOOKZ call,
56 //descards step for multiple scattering and returns to old history
57 //NO, after lattice-fix we don't need old history anymore!
59 ptrGeoInit->UpdateHistories(ptrTouchableHistory->GetHistory(),0);
60 G4VPhysicalVolume * located = ptrTouchableHistory->GetVolume();
62 //if volume not found, out of mother volume: returns "number of volumes"+1
64 #ifdef G4GEOMETRY_DEBUG
65 G4cout << "Out of mother volume!";
67 G4int numVol = G4int(pVolStore->size());
71 #ifdef G4GEOMETRY_DEBUG
72 G4cout << "* ISVHWR call to store current NavHistWithCount in jrLtGeant"
76 //save history in jrLtGeant and increment counter
77 G4int * jrLtGeant = ptrGeoInit->GetJrLtGeantArray();
78 G4int LttcFlagGeant = ptrGeoInit->GetLttcFlagGeant();
80 jrLtGeant[LttcFlagGeant] = isvhwr(0,0);
82 #ifdef G4GEOMETRY_DEBUG
83 G4cout << "* CONHWR call to increment counter" << G4endl;
86 conhwr(jrLtGeant[LttcFlagGeant],&incrCount);
88 //update LttcFlagGeant
89 ptrGeoInit->SetLttcFlagGeant(LttcFlagGeant);
91 //return region number and dummy variables
93 for (unsigned int i=0; i<pVolStore->size(); i++)
94 if ((*pVolStore)[i] == located) volIndex = i;
95 //G4int volIndex=G4int(pVolStore->index(located));
97 G4cerr << "FLUGG: Problem in routine WrapG1 tryingto find volume after step" << G4endl;
101 newLttc=jrLtGeant[LttcFlagGeant];
103 #ifdef G4GEOMETRY_DEBUG
104 G4cout << "LKWR Located Physical volume = ";
105 G4cout << located->GetName() << G4endl;
108 #ifdef G4GEOMETRY_DEBUG
109 G4cout << "======= Out of LKWR =======" << G4endl;