4 ///////////////////////////////////////////////////////////////////
6 // WrapSavHist.hh - Sara Vanini
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.
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);
24 //////////////////////////////////////////////////////////////////
27 #include "Wrappers.hh"
28 #include "FGeometryInit.hh"
29 #include "NavHistWithCount.hh"
30 #include "G4TouchableHistory.hh"
33 G4int isvhwr(const G4int& fCheck, const G4int& intHist)
36 #ifdef G4GEOMETRY_DEBUG
37 G4cout << "============= ISVHWR ==============" << G4endl;
38 G4cout << "fCheck=" << fCheck << G4endl;
40 G4cout << "intHist=" << intHist << G4endl;
44 static FGeometryInit * ptrGeoInit = FGeometryInit::GetInstance();
50 #ifdef G4GEOMETRY_DEBUG
51 G4cout << "Start event." << G4endl;
59 #ifdef G4GEOMETRY_DEBUG
60 G4cout << "End event. Check histories in debug-array..." << G4endl;
63 //check that all fluka-banked histories have been delated
64 // commented by A.Solodkov
66 G4int * ptrArray = ptrGeoInit->GetHistArray();
68 for(G4int k=0;k<j;k++) {
69 NavHistWithCount* ptrNavHistCount=reinterpret_cast
70 <NavHistWithCount*>(ptrArray[k]);
72 if(ptrArray[k] && !ptrNavHistCount->GetDelateFlag())
73 G4cout << "WARNING! History pointed by " <<ptrArray[k]<<
74 " has not been deleted at end of event" << G4endl;
77 //reinitialise debug histories array
78 for(G4int i=0;i<1000000;i++) ptrArray[i]=0;
87 //get history object from intHist
88 NavHistWithCount* ptrNavHistCountCopy =
89 reinterpret_cast<NavHistWithCount*>(intHist);
90 G4NavigationHistory* ptrNavHistCopy =
91 ptrNavHistCountCopy->GetNavHistPtr();
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);
102 //G4int * ptrArray = ptrGeoInit->GetHistArray();
103 //ptrArray[j]=intHistCopy;
106 #ifdef G4GEOMETRY_DEBUG
107 G4cout << "Copying history..." << G4endl;
108 G4cout << "Ptr History-copy =" <<intHistCopy<< G4endl;
109 G4cout<<*ptrNavHistCopy<< G4endl;
117 //save G4NavigationHistory and index of check-array
118 NavHistWithCount *ptrNavHistCount =
119 new NavHistWithCount(*(ptrGeoInit->GetTempNavHist()->GetHistory()));
121 ptrNavHistCount->SaveCheckInd(j);
122 G4int histInt=G4int(ptrNavHistCount);
126 //G4int * ptrArray = ptrGeoInit->GetHistArray();
127 // ptrArray[j]=histInt;
130 #ifdef G4GEOMETRY_DEBUG
132 G4TouchableHistory * ptrTouchHist = ptrGeoInit->GetTouchableHistory();
133 G4cout << "Saving history..." << G4endl;
134 G4cout << "Ptr saved History=" << histInt << G4endl;
135 G4cout << *(ptrTouchHist->GetHistory()) << G4endl;