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);
17 //////////////////////////////////////////////////////////////////
20 #include "Wrappers.hh"
21 #include "FGeometryInit.hh"
22 #include "G4VPhysicalVolume.hh"
23 #include "G4Navigator.hh"
24 #include "G4ThreeVector.hh"
25 #include "G4PhysicalVolumeStore.hh"
28 void lkwr(G4double& pSx, G4double& pSy, G4double& pSz,
29 G4double* pV, const G4int& oldReg, const G4int& oldLttc,
30 G4int& newReg, G4int& flagErr, G4int& newLttc)
33 #ifdef G4GEOMETRY_DEBUG
34 G4cout<<"======= LKWR ======="<<G4endl;
37 //FGeometryInit, navigator, volumeStore pointers
38 static FGeometryInit * ptrGeoInit = FGeometryInit::GetInstance();
39 G4Navigator * ptrNavig = ptrGeoInit->getNavigatorForTracking();
40 G4PhysicalVolumeStore * pVolStore = G4PhysicalVolumeStore::GetInstance();
43 G4ThreeVector pSource(pSx,pSy,pSz);
44 pSource *= 10.0; //in millimeters!
46 //locate point and update histories
47 G4TouchableHistory * ptrTouchableHistory =
48 ptrGeoInit->GetTouchableHistory();
49 ptrNavig->LocateGlobalPointAndUpdateTouchable(pSource,0,
50 ptrTouchableHistory,true);
51 //updating tmp but not old histories, they are useful in
52 //case of RGRPWR call, or when fluka, after a LOOKZ call,
53 //descards step for multiple scattering and returns to old history
54 //NO, after lattice-fix we don't need old history anymore!
56 ptrGeoInit->UpdateHistories(ptrTouchableHistory->GetHistory(),0);
57 G4VPhysicalVolume * located = ptrTouchableHistory->GetVolume();
59 //if volume not found, out of mother volume: returns "number of volumes"+1
62 #ifdef G4GEOMETRY_DEBUG
63 G4cout << "Out of mother volume!";
65 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 (G4int i=0; i<pVolStore->size(); i++)
93 if ((*pVolStore)[i] == located) volIndex = i;
94 //G4int volIndex=G4int(pVolStore->index(located));
96 newLttc=jrLtGeant[LttcFlagGeant];
98 #ifdef G4GEOMETRY_DEBUG
99 G4cout << "Located Physical volume = ";
100 G4cout << located->GetName() << G4endl;