]>
Commit | Line | Data |
---|---|---|
26911512 | 1 | |
2 | // Flugg tag | |
3 | ||
4 | /////////////////////////////////////////////////////////////////// | |
5 | // | |
6 | // WrapLookZ.hh - Sara Vanini | |
7 | // | |
8 | // Wrapper for localisation of starting point of particle. | |
9 | // | |
10 | // modified 20/III/00: history initialization moved to ISVHWR | |
11 | // modified 13/IV/00: located history saved in jrLtcGeant and | |
12 | // incremented | |
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 | |
17 | // | |
18 | ////////////////////////////////////////////////////////////////// | |
19 | ||
20 | ||
21 | #include "Wrappers.hh" | |
22 | #include "FGeometryInit.hh" | |
23 | #include "G4VPhysicalVolume.hh" | |
24 | #include "FluggNavigator.hh" | |
25 | #include "G4ThreeVector.hh" | |
26 | #include "G4PhysicalVolumeStore.hh" | |
27 | #include "globals.hh" | |
28 | ||
26911512 | 29 | |
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) | |
33 | { | |
34 | //flag | |
35 | #ifdef G4GEOMETRY_DEBUG | |
36 | G4cout << "======= LKWR =======" << G4endl; | |
37 | #endif | |
38 | ||
39 | //FGeometryInit, navigator, volumeStore pointers | |
40 | static FGeometryInit * ptrGeoInit = FGeometryInit::GetInstance(); | |
41 | FluggNavigator * ptrNavig = ptrGeoInit->getNavigatorForTracking(); | |
42 | G4PhysicalVolumeStore * pVolStore = G4PhysicalVolumeStore::GetInstance(); | |
43 | ||
44 | //coordinates in mm. | |
45 | G4ThreeVector pSource(pSx,pSy,pSz); | |
46 | pSource *= 10.0; //in millimeters! | |
47 | ||
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! | |
57 | ||
58 | ptrGeoInit->UpdateHistories(ptrTouchableHistory->GetHistory(),0); | |
59 | G4VPhysicalVolume * located = ptrTouchableHistory->GetVolume(); | |
60 | ||
61 | //if volume not found, out of mother volume: returns "number of volumes"+1 | |
62 | if(!located) { | |
63 | #ifdef G4GEOMETRY_DEBUG | |
64 | G4cout << "Out of mother volume!"; | |
65 | #endif | |
66 | G4int numVol = G4int(pVolStore->size()); | |
67 | newReg = numVol + 1; | |
68 | } | |
69 | else { | |
70 | #ifdef G4GEOMETRY_DEBUG | |
71 | G4cout << "* ISVHWR call to store current NavHistWithCount in jrLtGeant" | |
72 | << G4endl; | |
73 | #endif | |
74 | ||
75 | //save history in jrLtGeant and increment counter | |
76 | G4int * jrLtGeant = ptrGeoInit->GetJrLtGeantArray(); | |
77 | G4int LttcFlagGeant = ptrGeoInit->GetLttcFlagGeant(); | |
78 | LttcFlagGeant += 1; | |
79 | jrLtGeant[LttcFlagGeant] = isvhwr(0,0); | |
80 | ||
81 | #ifdef G4GEOMETRY_DEBUG | |
82 | G4cout << "* CONHWR call to increment counter" << G4endl; | |
83 | #endif | |
84 | G4int incrCount=1; | |
85 | conhwr(jrLtGeant[LttcFlagGeant],&incrCount); | |
86 | ||
87 | //update LttcFlagGeant | |
88 | ptrGeoInit->SetLttcFlagGeant(LttcFlagGeant); | |
89 | ||
90 | //return region number and dummy variables | |
91 | G4int volIndex = ~0; | |
92 | for (unsigned int i=0; i<pVolStore->size(); i++) | |
93 | if ((*pVolStore)[i] == located) volIndex = i; | |
94 | //G4int volIndex=G4int(pVolStore->index(located)); | |
95 | if (volIndex==(~0)) { | |
96 | G4cerr << "FLUGG: Problem in routine WrapG1 tryingto find volume after step" << G4endl; | |
97 | exit(-999); | |
98 | } | |
99 | newReg=volIndex+1; | |
100 | newLttc=jrLtGeant[LttcFlagGeant]; | |
101 | flagErr=newReg; | |
102 | #ifdef G4GEOMETRY_DEBUG | |
103 | G4cout << "LKWR Located Physical volume = "; | |
104 | G4cout << located->GetName() << G4endl; | |
105 | #endif | |
106 | } | |
107 | #ifdef G4GEOMETRY_DEBUG | |
108 | G4cout << "======= Out of LKWR =======" << G4endl; | |
109 | #endif | |
110 | } | |
111 | ||
112 | ||
113 | ||
114 |