60{
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
86
87 Double_t bparam[6];
88 Double_t lparam[6];
89
90 for (Int_t i=0;
i<6;
i++) bparam[i]=0;
91
92 if (!gGeoManager) {
93
94 return 0.;
95 }
96
98 Double_t dir[3];
99 length = TMath::Sqrt((end[0]-start[0])*(end[0]-start[0])+
100 (end[1]-start[1])*(end[1]-start[1])+
101 (end[2]-start[2])*(end[2]-start[2]));
103 if (length<TGeoShape::Tolerance()) return 0.0;
104 Double_t invlen = 1./
length;
108
109
110 TGeoNode *currentnode = 0;
111 TGeoNode *startnode = gGeoManager->InitTrack(start, dir);
112 if (!startnode) {
113
114
115 return 0.0;
116 }
117 TGeoMaterial *
material = startnode->GetVolume()->GetMedium()->GetMaterial();
119 if (lparam[0] > mparam[7])
mparam[7]=lparam[0];
124 lparam[5] = lparam[3]/lparam[2];
126 TGeoMixture * mixture = (TGeoMixture*)material;
127 lparam[5] =0;
128 Double_t sum =0;
129 for (Int_t iel=0;iel<mixture->GetNelements();iel++){
130 sum += mixture->GetWmixt()[iel];
131 lparam[5]+= mixture->GetZmixt()[iel]*mixture->GetWmixt()[iel]/mixture->GetAmixt()[iel];
132 }
133 lparam[5]/=sum;
134 }
135
136
137
138 gGeoManager->FindNextBoundaryAndStep(length, kFALSE);
140 Double_t snext = gGeoManager->GetStep();
141
142 if (!gGeoManager->IsOnBoundary()) {
144 mparam[1] = lparam[4]/lparam[1];
148 return lparam[0];
149 }
150
151 Int_t nzero = 0;
152 while (length>TGeoShape::Tolerance()) {
153 currentnode = gGeoManager->GetCurrentNode();
154 if (snext<2.*TGeoShape::Tolerance()) nzero++;
155 else nzero = 0;
156 if (nzero>3) {
157
158
159
168 return bparam[0]/
step;
169 }
172 bparam[1] += snext/lparam[1];
173 bparam[2] += snext*lparam[2];
174 bparam[3] += snext*lparam[3];
175 bparam[5] += snext*lparam[5];
176 bparam[0] += snext*lparam[0];
177
178 if (snext>=length) break;
179 if (!currentnode) break;
181 material = currentnode->GetVolume()->GetMedium()->GetMaterial();
183 if (lparam[0] > mparam[7])
mparam[7]=lparam[0];
187 lparam[5] = lparam[3]/lparam[2];
189 TGeoMixture * mixture = (TGeoMixture*)material;
190 lparam[5]=0;
191 Double_t sum =0;
192 for (Int_t iel=0;iel<mixture->GetNelements();iel++){
193 sum+= mixture->GetWmixt()[iel];
194 lparam[5]+= mixture->GetZmixt()[iel]*mixture->GetWmixt()[iel]/mixture->GetAmixt()[iel];
195 }
196 lparam[5]/=sum;
197 }
198 gGeoManager->FindNextBoundaryAndStep(length, kFALSE);
199 snext = gGeoManager->GetStep();
200 }
206 return bparam[0]/
step;
207}