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