14 #include "DD4hep/Exceptions.h"
15 #include "DD4hep/Detector.h"
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. );
128 if( length > epsilon ) {
135 track->AddPoint( position[0], position[1], position[2], 0.);
137 if( length > epsilon ) {
168 TGeoNode *node =
_tgeoMgr->FindNode( pos[0], pos[1], pos[2] ) ;
171 err <<
" MaterialManager::material: No geometry node found at location: " << pos ;
174 _m = Material( node->GetMedium() );
183 TGeoNode *node =
_tgeoMgr->FindNode( pos[0], pos[1], pos[2] ) ;
186 err <<
" MaterialManager::material: No geometry node found at location: " << pos ;
189 _m = Material( node->GetMedium() );
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){
211 Material mat = materials[i].first ;
212 double l = materials[i].second ;
214 if( i != 0 ) sstr <<
"_" ;
215 sstr << mat.name() <<
"_" << l ;
217 double rho = mat.density() ;
220 double x = mat.radLength() ;
221 double lambda = mat.intLength() ;
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 ;
const Material & materialAt(const Vector3D &pos)
Get the material at the given position.
const PlacementVec & placementsBetween(const Vector3D &p0, const Vector3D &p1, double epsilon=1e-4)
Get a vector with all the placements between the two points p0 and p1.
Simple three dimensional vector providing the components for cartesian, cylindrical and spherical coo...
PlacedVolume placementAt(const Vector3D &pos)
Get the placed volume at the given position.
const MaterialVec & materialsBetween(const Vector3D &p0, const Vector3D &p1, double epsilon=1e-4)
Get a vector with all the materials between the two points p0 and p1 with the corresponding thickness...
Vector3D _p0
cached last points
MaterialData createAveragedMaterial(const MaterialVec &materials)
Create a material with averaged properties from all materials in the list.
MaterialVec _mV
Cached materials.
TGeoManager * _tgeoMgr
Reference to the TGeoManager.
Simple data class that implements the IMaterial interface and is used in the Surface implementation...
PlacedVolume _pv
Cached nodes.