57{
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
83
84 Double_t bparam[6];
85 Double_t lparam[6];
86
87 for (Int_t i=0;
i<6;
i++) bparam[i]=0;
88
89 if (!gGeoManager) {
90
91 return 0.;
92 }
93
95 Double_t dir[3];
96 length = TMath::Sqrt((end[0]-start[0])*(end[0]-start[0])+
97 (end[1]-start[1])*(end[1]-start[1])+
98 (end[2]-start[2])*(end[2]-start[2]));
100 if (length<TGeoShape::Tolerance()) return 0.0;
101 Double_t invlen = 1./
length;
105
106
107 TGeoNode *currentnode = 0;
108 TGeoNode *startnode = gGeoManager->InitTrack(start, dir);
109 if (!startnode) {
110
111
112 return 0.0;
113 }
114 TGeoMaterial *
material = startnode->GetVolume()->GetMedium()->GetMaterial();
116 if (lparam[0] > mparam[7])
mparam[7]=lparam[0];
121 lparam[5] = lparam[3]/lparam[2];
123 TGeoMixture * mixture = (TGeoMixture*)material;
124 lparam[5] =0;
125 Double_t sum =0;
126 for (Int_t iel=0;iel<mixture->GetNelements();iel++){
127 sum += mixture->GetWmixt()[iel];
128 lparam[5]+= mixture->GetZmixt()[iel]*mixture->GetWmixt()[iel]/mixture->GetAmixt()[iel];
129 }
130 lparam[5]/=sum;
131 }
132
133
134
135 gGeoManager->FindNextBoundaryAndStep(length, kFALSE);
137 Double_t snext = gGeoManager->GetStep();
138
139 if (!gGeoManager->IsOnBoundary()) {
141 mparam[1] = lparam[4]/lparam[1];
145 return lparam[0];
146 }
147
148 Int_t nzero = 0;
149 while (length>TGeoShape::Tolerance()) {
150 currentnode = gGeoManager->GetCurrentNode();
151 if (snext<2.*TGeoShape::Tolerance()) nzero++;
152 else nzero = 0;
153 if (nzero>3) {
154
155
156
165 return bparam[0]/
step;
166 }
169 bparam[1] += snext/lparam[1];
170 bparam[2] += snext*lparam[2];
171 bparam[3] += snext*lparam[3];
172 bparam[5] += snext*lparam[5];
173 bparam[0] += snext*lparam[0];
174
175 if (snext>=length) break;
176 if (!currentnode) break;
178 material = currentnode->GetVolume()->GetMedium()->GetMaterial();
180 if (lparam[0] > mparam[7])
mparam[7]=lparam[0];
184 lparam[5] = lparam[3]/lparam[2];
186 TGeoMixture * mixture = (TGeoMixture*)material;
187 lparam[5]=0;
188 Double_t sum =0;
189 for (Int_t iel=0;iel<mixture->GetNelements();iel++){
190 sum+= mixture->GetWmixt()[iel];
191 lparam[5]+= mixture->GetZmixt()[iel]*mixture->GetWmixt()[iel]/mixture->GetAmixt()[iel];
192 }
193 lparam[5]/=sum;
194 }
195 gGeoManager->FindNextBoundaryAndStep(length, kFALSE);
196 snext = gGeoManager->GetStep();
197 }
203 return bparam[0]/
step;
204}