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"
30 void lkwr(G4double& pSx, G4double& pSy, G4double& pSz,
31 G4double* pV, const G4int& oldReg, const G4int& oldLttc,
32 G4int& newReg, G4int& flagErr, G4int& newLttc)
35 #ifdef G4GEOMETRY_DEBUG
36 G4cout << "======= LKWR =======" << G4endl;
39 //FGeometryInit, navigator, volumeStore pointers
40 static FGeometryInit * ptrGeoInit = FGeometryInit::GetInstance();
41 FluggNavigator * ptrNavig = ptrGeoInit->getNavigatorForTracking();
42 G4PhysicalVolumeStore * pVolStore = G4PhysicalVolumeStore::GetInstance();
45 G4ThreeVector pSource(pSx,pSy,pSz);
46 pSource *= 10.0; //in millimeters!
48 //locate point and update histories
49 G4TouchableHistory * ptrTouchableHistory =
50 ptrGeoInit->GetTouchableHistory();
51 ptrNavig->LocateGlobalPointAndUpdateTouchable(pSource,0,
52 ptrTouchableHistory,true);
53 //updating tmp but not old histories, they are useful in
54 //case of RGRPWR call, or when fluka, after a LOOKZ call,
55 //descards step for multiple scattering and returns to old history
56 //NO, after lattice-fix we don't need old history anymore!
58 ptrGeoInit->UpdateHistories(ptrTouchableHistory->GetHistory(),0);
59 G4VPhysicalVolume * located = ptrTouchableHistory->GetVolume();
61 //if volume not found, out of mother volume: returns "number of volumes"+1
63 #ifdef G4GEOMETRY_DEBUG
64 G4cout << "Out of mother volume!";
66 G4int numVol = G4int(pVolStore->size());
70 #ifdef G4GEOMETRY_DEBUG
71 G4cout << "* ISVHWR call to store current NavHistWithCount in jrLtGeant"
75 //save history in jrLtGeant and increment counter
76 G4int * jrLtGeant = ptrGeoInit->GetJrLtGeantArray();
77 G4int LttcFlagGeant = ptrGeoInit->GetLttcFlagGeant();
79 jrLtGeant[LttcFlagGeant] = isvhwr(0,0);
81 #ifdef G4GEOMETRY_DEBUG
82 G4cout << "* CONHWR call to increment counter" << G4endl;
85 conhwr(jrLtGeant[LttcFlagGeant],&incrCount);
87 //update LttcFlagGeant
88 ptrGeoInit->SetLttcFlagGeant(LttcFlagGeant);
90 //return region number and dummy variables
92 for (unsigned int i=0; i<pVolStore->size(); i++)
93 if ((*pVolStore)[i] == located) volIndex = i;
94 //G4int volIndex=G4int(pVolStore->index(located));
96 G4cerr << "FLUGG: Problem in routine WrapG1 tryingto find volume after step" << G4endl;
100 newLttc=jrLtGeant[LttcFlagGeant];
102 #ifdef G4GEOMETRY_DEBUG
103 G4cout << "LKWR Located Physical volume = ";
104 G4cout << located->GetName() << G4endl;
107 #ifdef G4GEOMETRY_DEBUG
108 G4cout << "======= Out of LKWR =======" << G4endl;