4 ///////////////////////////////////////////////////////////////////
6 // WrapLookFX.hh - Sara Vanini - 24/III/00
8 // Wrapper for localisation of particle to fix particular conditions.
9 // At the moment is the same as WrapLookZ.hh.
11 // modified 24.10.01: by I. Hrivnacova
12 // functions declarations separated from implementation
13 // (moved to Wrappers.hh);
14 // modified 17/06/02: by I. Gonzalez. STL migration
16 //////////////////////////////////////////////////////////////////
19 #include "Wrappers.hh"
20 #include "FGeometryInit.hh"
21 #include "G4VPhysicalVolume.hh"
22 #include "FluggNavigator.hh"
23 #include "G4ThreeVector.hh"
24 #include "G4PhysicalVolumeStore.hh"
27 void lkfxwr(G4double& pSx, G4double& pSy, G4double& pSz,
28 G4double* pV, const G4int& oldReg, const G4int& oldLttc,
29 G4int& newReg, G4int& flagErr, G4int& newLttc)
32 #ifdef G4GEOMETRY_DEBUG
33 G4cout << "======= LKFXWR =======" << G4endl;
36 //FGeometryInit, navigator, volumeStore pointers
37 static FGeometryInit * ptrGeoInit = FGeometryInit::GetInstance();
38 FluggNavigator * ptrNavig = ptrGeoInit->getNavigatorForTracking();
39 G4PhysicalVolumeStore * pVolStore = G4PhysicalVolumeStore::GetInstance();
42 G4ThreeVector pSource(pSx,pSy,pSz);
43 pSource *= 10.0; //in millimeters!
45 //locate point and update histories
46 G4TouchableHistory * ptrTouchableHistory =
47 ptrGeoInit->GetTouchableHistory();
48 ptrNavig->LocateGlobalPointAndUpdateTouchable(pSource,0,
49 ptrTouchableHistory,true);
50 //updating tmp but not old histories, they are useful in
51 //case of RGRPWR call, or when fluka, after a LOOKZ call,
52 //descards step for multiple scattering and returns to old history
53 //NO, after lattice-fix we don't need old history anymore!
55 ptrGeoInit->UpdateHistories(ptrTouchableHistory->GetHistory(),0);
56 G4VPhysicalVolume * located = ptrTouchableHistory->GetVolume();
58 //if volume not found, out of mother volume: returns "number of volumes"+1
60 #ifdef G4GEOMETRY_DEBUG
61 G4cout << "Out of mother volume!";
63 G4int numVol = G4int(pVolStore->size());
67 #ifdef G4GEOMETRY_DEBUG
68 G4cout << "* ISVHWR call to store current NavHistWithCount in jrLtGeant"
72 //save history in jrLtGeant and increment counter
73 G4int * jrLtGeant = ptrGeoInit->GetJrLtGeantArray();
74 G4int LttcFlagGeant = ptrGeoInit->GetLttcFlagGeant();
76 jrLtGeant[LttcFlagGeant] = isvhwr(0,0);
78 #ifdef G4GEOMETRY_DEBUG
79 G4cout << "* CONHWR call to increment counter" << G4endl;
82 conhwr(jrLtGeant[LttcFlagGeant],&incrCount);
84 //update LttcFlagGeant
85 ptrGeoInit->SetLttcFlagGeant(LttcFlagGeant);
87 //return region number and dummy variables
89 for (unsigned int i=0; i<pVolStore->size(); i++)
90 if ((*pVolStore)[i] == located)
92 // G4int volIndex=G4int(pVolStore->index(located));
94 G4cerr << "FLUGG: Problem in file WrapLookFX trying to find volume after step" << G4endl;
97 //G4int volIndex=G4int(pVolStore->index(located));
99 newLttc=jrLtGeant[LttcFlagGeant];
101 #ifdef G4GEOMETRY_DEBUG
102 G4cout << "LKFXWR Located Physical volume = ";
103 G4cout << located->GetName() << G4endl;