00001
00002
00003
00004
00005 #ifndef DETDESC_TRANSPORTSVC_TRANSPORTSVCFINDLOCALGI_H
00006 #define DETDESC_TRANSPORTSVC_TRANSPORTSVCFINDLOCALGI_H 1
00007
00008 #include <sstream>
00009
00010
00011 #include "TransportSvc.h"
00012
00022 IGeometryInfo* TransportSvc::findLocalGI ( const Gaudi::XYZPoint& point1 ,
00023 const Gaudi::XYZPoint& point2 ,
00024 IGeometryInfo* gi ,
00025 IGeometryInfo* topGi ) const {
00026 if( 0 == gi ) { return 0 ; }
00027
00028
00030 IGeometryInfo* goodGI = 0 ;
00031
00032 try {
00034 if ( !gi->isInside( point1 ) ) {
00035 return 0;
00036 }
00037 IGeometryInfo* gi1 = gi->belongsTo( point1, -1 ) ;
00038
00040 IGeometryInfo* gi2 = gi1 ;
00041 {
00042 bool loc = false ;
00043 for( loc = gi2->isInside( point2 ) ; !loc && 0 != gi2 ;
00044 gi2 = gi2->parentIGeometryInfo() ) {
00045 loc = gi2->isInside( point2 );
00046 if ( loc ) break;
00047 }
00048 if( 0 == gi2 ) {
00049 return 0;
00050 }
00051 }
00052
00053
00054
00055
00056 for( IGeometryInfo* gl = gi2 ; 0 != gl ;
00057 gl = gl->parentIGeometryInfo() ) {
00058 if ( 0 == gl ) return 0;
00059 if( goodLocalGI( point1 , point2 , gl ) ) {
00060 return gl;
00061 }
00062 if ( topGi == gl ) return 0;
00063 }
00065 return 0;
00066
00067 }
00068 catch( const GaudiException& Exception )
00069 {
00071 std::string message
00072 ("TransportSvc::findLocalGI(...), exception caught; Params: ");
00073 {
00074 std::ostringstream ost;
00075 ost << "Point1=" << point1
00076 << "Point2=" << point2 ;
00077 message += ost.str();
00078 Assert( false , message , Exception );
00079 }
00080 }
00081 catch( ... )
00082 {
00084 std::string message
00085 ("TransportSvc::findLocalGI(...), unknown exception caught; Params: ");
00086 {
00087 std::ostringstream ost;
00088 ost << "Point1=" << point1
00089 << "Point2=" << point2 ;
00090 message += ost.str();
00091 Assert( false , message );
00092 }
00093 }
00094
00096 return goodGI;
00097
00098 };
00099
00100
00101
00102
00103 #endif // __DETDESC_TRANSPORTSVC_TRANSPORTSVCFINDLOCALGI_H__
00104
00105