17 #include "TGeoVolume.h"
18 #include "TGeoManager.h"
20 #include "TVirtualGeoTrack.h"
41 if( ( p0 !=
_p0 ) || ( p1 !=
_p1 ) ) {
49 double startpoint[3], endpoint[3], direction[3];
51 for(
unsigned int i=0; i<3; i++) {
52 startpoint[i] = p0[i];
54 direction[i] = endpoint[i] - startpoint[i];
55 L+=direction[i]*direction[i];
57 double totDist = sqrt( L ) ;
60 for(
unsigned int i=0; i<3; i++)
61 direction[i]=direction[i]/totDist;
65 TGeoNode *node1 =
_tgeoMgr->InitTrack(startpoint, direction);
69 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.");
77 TGeoNode * node2 =
_tgeoMgr->FindNextBoundaryAndStep( 500, 1) ;
79 if( !node2 ||
_tgeoMgr->IsOutside() )
82 const double *position =
_tgeoMgr->GetCurrentPoint();
83 const double *previouspos =
_tgeoMgr->GetLastPoint();
87 TVirtualGeoTrack *track =
_tgeoMgr->GetLastTrack();
93 #if 1 //fg: is this still needed ?
97 position[1] +
MINSTEP * direction[1],
98 position[2] +
MINSTEP * direction[2] );
101 node2 =
_tgeoMgr->FindNextBoundaryAndStep(500, 1) ;
103 position =
_tgeoMgr->GetCurrentPoint();
104 previouspos =
_tgeoMgr->GetLastPoint();
112 double currDistance = ( posV - p0 ).r() ;
119 if( currDistance > totDist ) {
121 length = sqrt( pow(endpoint[0]-previouspos[0],2) +
122 pow(endpoint[1]-previouspos[1],2) +
123 pow(endpoint[2]-previouspos[2],2) );
125 track->AddPoint( endpoint[0], endpoint[1], endpoint[2], 0. );
129 _mV.emplace_back(node1->GetMedium(), length );
130 _placeV.emplace_back(node1,length);
135 track->AddPoint( position[0], position[1], position[2], 0.);
138 _mV.emplace_back(node1->GetMedium(), length);
139 _placeV.emplace_back(node1,length);
147 _mV.emplace_back(node1->GetMedium(), totDist);
148 _placeV.emplace_back(node1,totDist);
168 TGeoNode *node =
_tgeoMgr->FindNode( pos[0], pos[1], pos[2] ) ;
170 std::stringstream err ;
171 err <<
" MaterialManager::material: No geometry node found at location: " << pos ;
172 throw std::runtime_error( err.str() );
183 TGeoNode *node =
_tgeoMgr->FindNode( pos[0], pos[1], pos[2] ) ;
185 std::stringstream err ;
186 err <<
" MaterialManager::material: No geometry node found at location: " << pos ;
187 throw std::runtime_error( err.str() );
198 std::stringstream sstr ;
201 double sum_rho_l = 0 ;
202 double sum_rho_l_over_A = 0 ;
203 double sum_rho_l_Z_over_A = 0 ;
205 double sum_l_over_x = 0 ;
207 double sum_l_over_lambda = 0 ;
209 for(
unsigned i=0,n=materials.size(); i<n ; ++i){
212 double l = materials[i].second ;
214 if( i != 0 ) sstr <<
"_" ;
215 sstr << mat.
name() <<
"_" << l ;
224 sum_rho_l += rho * l ;
225 sum_rho_l_over_A += rho * l / A ;
226 sum_rho_l_Z_over_A += rho * l * Z / A ;
227 sum_l_over_x += l / x ;
228 sum_l_over_lambda += l / lambda ;
233 double rho = sum_rho_l / sum_l ;
235 double A = sum_rho_l / sum_rho_l_over_A ;
236 double Z = sum_rho_l_Z_over_A / sum_rho_l_over_A ;
241 double x = sum_l / sum_l_over_x ;
244 double lambda = sum_l / sum_l_over_lambda ;
247 return MaterialData( sstr.str() , Z, A, rho, x, lambda ) ;