]>
Commit | Line | Data |
---|---|---|
26911512 | 1 | |
2 | // Flugg tag | |
3 | ||
4 | /////////////////////////////////////////////////////////////////// | |
5 | // | |
6 | // WrapSavHist.hh - Sara Vanini | |
7 | // | |
8 | // Wrapper for saving current navigation history (fCheck=default) | |
9 | // and returning its pointer. If fCheck=-1 copy of history pointed | |
10 | // by intHist is made in NavHistWithCount object, and its pointer | |
11 | // is returned. fCheck=1 and fCheck=2 cases are only in debugging | |
12 | // version: an array is created by means of FGeometryInit functions | |
13 | // (but could be a static int * ptrArray = new int[10000] with | |
14 | // file scope as well) that stores a flag for deleted/undeleted | |
15 | // histories and at the end of event is checked to verify that | |
16 | // all saved history objects have been deleted. | |
17 | // | |
18 | // modified 6/III/99: history check array implemented | |
19 | // modified 14/IV/00: fCheck=-1 case modified | |
20 | // modified 24.10.01: by I. Hrivnacova | |
21 | // functions declarations separated from implementation | |
22 | // (moved to Wrappers.hh); | |
23 | // | |
24 | ////////////////////////////////////////////////////////////////// | |
25 | ||
26 | ||
27 | #include "Wrappers.hh" | |
28 | #include "FGeometryInit.hh" | |
29 | #include "NavHistWithCount.hh" | |
30 | #include "G4TouchableHistory.hh" | |
31 | #include "globals.hh" | |
32 | ||
33 | G4int isvhwr(const G4int& fCheck, const G4int& intHist) | |
34 | { | |
35 | //flag | |
36 | #ifdef G4GEOMETRY_DEBUG | |
37 | G4cout << "============= ISVHWR ==============" << G4endl; | |
38 | G4cout << "fCheck=" << fCheck << G4endl; | |
39 | if(fCheck==-1) | |
40 | G4cout << "intHist=" << intHist << G4endl; | |
41 | #endif | |
42 | ||
43 | //Geoinit pointer | |
44 | static FGeometryInit * ptrGeoInit = FGeometryInit::GetInstance(); | |
45 | static G4int j=0; | |
46 | ||
47 | switch (fCheck) { | |
48 | case 1: | |
49 | { | |
50 | #ifdef G4GEOMETRY_DEBUG | |
51 | G4cout << "Start event." << G4endl; | |
52 | #endif | |
53 | ||
54 | return 0; | |
55 | } | |
56 | ||
57 | case 2: | |
58 | { | |
59 | #ifdef G4GEOMETRY_DEBUG | |
60 | G4cout << "End event. Check histories in debug-array..." << G4endl; | |
61 | #endif | |
62 | ||
63 | //check that all fluka-banked histories have been delated | |
64 | // commented by A.Solodkov | |
65 | /* | |
66 | G4int * ptrArray = ptrGeoInit->GetHistArray(); | |
67 | ||
68 | for(G4int k=0;k<j;k++) { | |
69 | NavHistWithCount* ptrNavHistCount=reinterpret_cast | |
70 | <NavHistWithCount*>(ptrArray[k]); | |
71 | ||
72 | if(ptrArray[k] && !ptrNavHistCount->GetDelateFlag()) | |
73 | G4cout << "WARNING! History pointed by " <<ptrArray[k]<< | |
74 | " has not been deleted at end of event" << G4endl; | |
75 | } | |
76 | ||
77 | //reinitialise debug histories array | |
78 | for(G4int i=0;i<1000000;i++) ptrArray[i]=0; | |
79 | */ | |
80 | j=0; | |
81 | ||
82 | return 0; | |
83 | } | |
84 | ||
85 | case -1: | |
86 | { | |
87 | //get history object from intHist | |
88 | NavHistWithCount* ptrNavHistCountCopy = | |
89 | reinterpret_cast<NavHistWithCount*>(intHist); | |
90 | G4NavigationHistory* ptrNavHistCopy = | |
91 | ptrNavHistCountCopy->GetNavHistPtr(); | |
92 | ||
93 | //copy history in another NavHistWithCount object | |
94 | //and save index of check-array | |
95 | NavHistWithCount * ptrNavHistCount = | |
96 | new NavHistWithCount(*(ptrNavHistCopy)); | |
97 | ptrNavHistCount->SaveCheckInd(j); | |
98 | G4int intHistCopy = G4int(ptrNavHistCount); | |
99 | ||
100 | //store ptr in array | |
101 | // commented by PS | |
102 | //G4int * ptrArray = ptrGeoInit->GetHistArray(); | |
103 | //ptrArray[j]=intHistCopy; | |
104 | j+=1; | |
105 | ||
106 | #ifdef G4GEOMETRY_DEBUG | |
107 | G4cout << "Copying history..." << G4endl; | |
108 | G4cout << "Ptr History-copy =" <<intHistCopy<< G4endl; | |
109 | G4cout<<*ptrNavHistCopy<< G4endl; | |
110 | #endif | |
111 | ||
112 | return intHistCopy; | |
113 | } | |
114 | ||
115 | default: | |
116 | { | |
117 | //save G4NavigationHistory and index of check-array | |
118 | NavHistWithCount *ptrNavHistCount = | |
119 | new NavHistWithCount(*(ptrGeoInit->GetTempNavHist()->GetHistory())); | |
120 | ||
121 | ptrNavHistCount->SaveCheckInd(j); | |
122 | G4int histInt=G4int(ptrNavHistCount); | |
123 | ||
124 | //store ptr in array | |
125 | // comented by PS | |
126 | //G4int * ptrArray = ptrGeoInit->GetHistArray(); | |
127 | // ptrArray[j]=histInt; | |
128 | j+=1; | |
129 | ||
130 | #ifdef G4GEOMETRY_DEBUG | |
131 | //TouchableHistory | |
132 | G4TouchableHistory * ptrTouchHist = ptrGeoInit->GetTouchableHistory(); | |
133 | G4cout << "Saving history..." << G4endl; | |
134 | G4cout << "Ptr saved History=" << histInt << G4endl; | |
135 | G4cout << *(ptrTouchHist->GetHistory()) << G4endl; | |
136 | #endif | |
137 | ||
138 | return histInt; | |
139 | } | |
140 | } | |
141 | } | |
142 | ||
143 | ||
144 | ||
145 | ||
146 | ||
147 |