]> git.uio.no Git - u/mrichter/AliRoot.git/blame - Flugg/WrapReg.cxx
fortran loop removed
[u/mrichter/AliRoot.git] / Flugg / WrapReg.cxx
CommitLineData
26911512 1
2// Flugg tag
3
4///////////////////////////////////////////////////////////////////
5//
6// WrapReg.hh - Sara Vanini
7//
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.
14//
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.
21//
22///////////////////////////////////////////////////////////////////
23
24#include "Wrappers.hh"
25#include "FGeometryInit.hh"
26#include "NavHistWithCount.hh"
27#include "G4VPhysicalVolume.hh"
28#include "G4ThreeVector.hh"
29#include "G4PhysicalVolumeStore.hh"
30#include "globals.hh"
31
32
33void rgrpwr(const G4int& flukaReg, const G4int& ptrLttc, G4int& g4Reg,
34 G4int* indMother, G4int* repMother, G4int& depthFluka)
35{
36 //flag
37#ifdef G4GEOMETRY_DEBUG
38 G4cout << "============= RGRPWR ==============" << G4endl;
39 G4cout << "ptrLttc=" << ptrLttc << G4endl;
40#endif
41
42 //Geoinit, Navigator, VolStore pointers
43 static FGeometryInit * ptrGeoInit = FGeometryInit::GetInstance();
44 G4PhysicalVolumeStore * pVolStore = G4PhysicalVolumeStore::GetInstance();
45
46 //get jrLtGeant array and flag
47 G4int * jrLtGeant = ptrGeoInit->GetJrLtGeantArray();
48 G4int LttcFlagGeant = ptrGeoInit->GetLttcFlagGeant();
49
50 G4bool foundHistory = false;
51 G4int i = LttcFlagGeant;
52
53 while(!foundHistory && i>=0) {
54 if(jrLtGeant[i]==ptrLttc) foundHistory = true;
55 i -= 1;
56 }
57
58 if(!foundHistory) {
59 G4cout << "* ERROR! History not in jrLtGeant!" << G4endl;
60 //only in debugging version....
61 assert(foundHistory);
62 }
63 else {
64 //get history pointer from ptrLttc
65 NavHistWithCount* ptrNavHistCount =
66 reinterpret_cast<NavHistWithCount*>(ptrLttc);
67 G4NavigationHistory* ptrNavHist = ptrNavHistCount->GetNavHistPtr();
68
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);
74 //
75 volHistIndex = ~0;
76 for (unsigned int i=0; i<pVolStore->size(); i++)
77 if ((*pVolStore)[i] == ptrVolHistory)
78 volHistIndex = i;
79 if (volHistIndex==(~0)) {
80 G4cerr << "FLUGG: Problem in routine WrapReg tryingto find volume after step" << G4endl;
81 exit(-999);
82 }
83 //volHistIndex = G4int(pVolStore->index(ptrVolHistory));
84 //
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));
91 }
92 else {
93 repMother[h] = 0;
94 }
95
96#ifdef G4GEOMETRY_DEBUG
97 // G4cout<<"Level="<<h<<" : ";
98 // G4cout<<"Region="<<indMother[h]<<" (repetition="<<
99 // repMother[h]<<")"<<G4endl;
100#endif
101 }
102
103 //compute new region index
104 G4int volIndex = ~0;
105 for (unsigned int i=0; i<pVolStore->size(); i++)
106 if ((*pVolStore)[i] == ptrVolHistory)
107 volIndex = i;
108 //G4int volIndex=G4int(pVolStore->index(ptrVolHistory));
109 if (volIndex==(~0)) {
110 G4cerr << "FLUGG: Problem in routine WrapReg tryingto find volume after step" << G4endl;
111 exit(-999);
112 }
113
114 g4Reg=volIndex+1;
115
116 depthFluka = depth;
117 }
118
119}
120
121
122
123
124