4 ///////////////////////////////////////////////////////////////////
6 // WrapReg.hh - Sara Vanini
8 // Wrapper for scoring hits: previous step end-point is taken from
9 // history (and compared with fluka region index, flukaReg),
10 // then the wrapper returns all the information regarding the
11 // volume tree, i.e. returns indMother[] array with all the
12 // mother volumes index and repMother[] array with all the
13 // mother volumes repetition number.
15 // modified: 16/III/99
16 // modified: 14/IV/00 ptrLttc included
17 // modified: 24.10.00: by I. Hrivnacova
18 // functions declarations separated from implementation
19 // (moved to Wrappers.hh);
20 // modified: 17/06/02 by I. Gonzalez. STL migration.
22 ///////////////////////////////////////////////////////////////////
24 #include "Wrappers.hh"
25 #include "FGeometryInit.hh"
26 #include "NavHistWithCount.hh"
27 #include "G4VPhysicalVolume.hh"
28 #include "G4ThreeVector.hh"
29 #include "G4PhysicalVolumeStore.hh"
33 void rgrpwr(const G4int& flukaReg, const G4int& ptrLttc, G4int& g4Reg,
34 G4int* indMother, G4int* repMother, G4int& depthFluka)
37 #ifdef G4GEOMETRY_DEBUG
38 G4cout << "============= RGRPWR ==============" << G4endl;
39 G4cout << "ptrLttc=" << ptrLttc << G4endl;
42 //Geoinit, Navigator, VolStore pointers
43 static FGeometryInit * ptrGeoInit = FGeometryInit::GetInstance();
44 G4PhysicalVolumeStore * pVolStore = G4PhysicalVolumeStore::GetInstance();
46 //get jrLtGeant array and flag
47 G4int * jrLtGeant = ptrGeoInit->GetJrLtGeantArray();
48 G4int LttcFlagGeant = ptrGeoInit->GetLttcFlagGeant();
50 G4bool foundHistory = false;
51 G4int i = LttcFlagGeant;
53 while(!foundHistory && i>=0) {
54 if(jrLtGeant[i]==ptrLttc) foundHistory = true;
59 G4cout << "* ERROR! History not in jrLtGeant!" << G4endl;
60 //only in debugging version....
64 //get history pointer from ptrLttc
65 NavHistWithCount* ptrNavHistCount =
66 reinterpret_cast<NavHistWithCount*>(ptrLttc);
67 G4NavigationHistory* ptrNavHist = ptrNavHistCount->GetNavHistPtr();
69 G4VPhysicalVolume* ptrVolHistory = 0;
70 G4int volHistIndex = 0;
71 G4int depth = ptrNavHist->GetDepth();
72 for(G4int h=0; h<=depth; h++) {
73 ptrVolHistory = ptrNavHist->GetVolume(h);
76 for (unsigned int i=0; i<pVolStore->size(); i++)
77 if ((*pVolStore)[i] == ptrVolHistory)
79 if (volHistIndex==(~0)) {
80 G4cerr << "FLUGG: Problem in routine WrapReg tryingto find volume after step" << G4endl;
83 //volHistIndex = G4int(pVolStore->index(ptrVolHistory));
85 indMother[h] = volHistIndex+1;
86 if(ptrVolHistory->IsReplicated()) {
87 //true if volume is replica or parameterized,
88 //false for placements; repetition numbers
89 //are set: 1,2,3,etc.; 0 for placed volumes.
90 repMother[h] = 1+G4int(ptrNavHist->GetReplicaNo(h));
96 #ifdef G4GEOMETRY_DEBUG
97 // G4cout<<"Level="<<h<<" : ";
98 // G4cout<<"Region="<<indMother[h]<<" (repetition="<<
99 // repMother[h]<<")"<<G4endl;
103 //compute new region index
105 for (unsigned int i=0; i<pVolStore->size(); i++)
106 if ((*pVolStore)[i] == ptrVolHistory)
108 //G4int volIndex=G4int(pVolStore->index(ptrVolHistory));
109 if (volIndex==(~0)) {
110 G4cerr << "FLUGG: Problem in routine WrapReg tryingto find volume after step" << G4endl;