17 #include "TGeoVolume.h"
18 #include "TGeoManager.h"
20 #include "TVirtualGeoTrack.h"
41 if( ( p0 !=
_p0 ) || ( p1 !=
_p1 ) ) {
52 double startpoint[3], endpoint[3], direction[3];
54 for(
unsigned int i=0; i<3; i++) {
55 startpoint[i] = p0[i];
57 direction[i] = endpoint[i] - startpoint[i];
58 L+=direction[i]*direction[i];
60 double totDist = sqrt( L ) ;
63 for(
unsigned int i=0; i<3; i++)
64 direction[i]=direction[i]/totDist;
68 TGeoNode *node1 =
_tgeoMgr->InitTrack(startpoint, direction);
72 throw std::runtime_error(
"No geometry node found at given location. Either there is no node placed here or position is outside of top volume.");
80 TGeoNode * node2 =
_tgeoMgr->FindNextBoundaryAndStep( 500, 1) ;
82 if( !node2 ||
_tgeoMgr->IsOutside() )
85 const double *position =
_tgeoMgr->GetCurrentPoint();
86 const double *previouspos =
_tgeoMgr->GetLastPoint();
90 TVirtualGeoTrack *track =
_tgeoMgr->GetLastTrack();
96 #if 1 //fg: is this still needed ?
100 position[1] +
MINSTEP * direction[1],
101 position[2] +
MINSTEP * direction[2] );
104 node2 =
_tgeoMgr->FindNextBoundaryAndStep(500, 1) ;
106 position =
_tgeoMgr->GetCurrentPoint();
107 previouspos =
_tgeoMgr->GetLastPoint();
115 double currDistance = ( posV - p0 ).r() ;
122 if( currDistance > totDist ) {
124 length = sqrt( pow(endpoint[0]-previouspos[0],2) +
125 pow(endpoint[1]-previouspos[1],2) +
126 pow(endpoint[2]-previouspos[2],2) );
128 track->AddPoint( endpoint[0], endpoint[1], endpoint[2], 0. );
132 _mV.emplace_back(node1->GetMedium(), length );
133 _placeV.emplace_back(node1,length);
138 track->AddPoint( position[0], position[1], position[2], 0.);
141 _mV.emplace_back(node1->GetMedium(), length);
142 _placeV.emplace_back(node1,length);
150 _mV.emplace_back(node1->GetMedium(), totDist);
151 _placeV.emplace_back(node1,totDist);
173 TGeoNode *node =
_tgeoMgr->FindNode( pos[0], pos[1], pos[2] ) ;
175 std::stringstream err ;
176 err <<
" MaterialManager::material: No geometry node found at location: " << pos ;
177 throw std::runtime_error( err.str() );
188 TGeoNode *node =
_tgeoMgr->FindNode( pos[0], pos[1], pos[2] ) ;
190 std::stringstream err ;
191 err <<
" MaterialManager::material: No geometry node found at location: " << pos ;
192 throw std::runtime_error( err.str() );
203 std::stringstream sstr ;
206 double sum_rho_l = 0 ;
207 double sum_rho_l_over_A = 0 ;
208 double sum_rho_l_Z_over_A = 0 ;
210 double sum_l_over_x = 0 ;
212 double sum_l_over_lambda = 0 ;
214 for(
unsigned i=0,n=materials.size(); i<n ; ++i){
217 double l = materials[i].second ;
219 if( i != 0 ) sstr <<
"_" ;
220 sstr << mat.
name() <<
"_" << l ;
229 sum_rho_l += rho * l ;
230 sum_rho_l_over_A += rho * l / A ;
231 sum_rho_l_Z_over_A += rho * l * Z / A ;
232 sum_l_over_x += l / x ;
233 sum_l_over_lambda += l / lambda ;
238 double rho = sum_rho_l / sum_l ;
240 double A = sum_rho_l / sum_rho_l_over_A ;
241 double Z = sum_rho_l_Z_over_A / sum_rho_l_over_A ;
246 double x = sum_l / sum_l_over_x ;
249 double lambda = sum_l / sum_l_over_lambda ;
252 return MaterialData( sstr.str() , Z, A, rho, x, lambda ) ;