00001
00002
00003
00004
00005 #ifndef __DETDESC_TRANSPORTSVC_TRANSPORTSVCINTERSECTIONS_H__
00006 #define __DETDESC_TRANSPORTSVC_TRANSPORTSVCINTERSECTIONS_H__ 1
00007
00008 #include "TransportSvc.h"
00009
00010
00022
00023
00024
00040
00041 unsigned long TransportSvc::intersections
00042 ( const Gaudi::XYZPoint& point ,
00043 const Gaudi::XYZVector& vect ,
00044 const ISolid::Tick& tickMin ,
00045 const ISolid::Tick& tickMax ,
00046 ILVolume::Intersections& intersept ,
00047 double threshold ,
00048 IGeometryInfo* alternativeGeometry ,
00049 IGeometryInfo* guessGeometry )
00050 {
00051
00052 try {
00053
00054 intersept.clear();
00055
00057 if( tickMin >= tickMax && vect.mag2() <= 0 ) { return 0;}
00058
00059
00060 IGeometryInfo* topGeometry = alternativeGeometry ? alternativeGeometry : standardGeometry() ;
00061
00063 Gaudi::XYZPoint point1( point + vect * tickMin ) ;
00064 Gaudi::XYZPoint point2( point + vect * tickMax ) ;
00066 if( point1 == m_prevPoint1 &&
00067 point2 == m_prevPoint2 &&
00068 threshold == m_previousThreshold &&
00069 topGeometry == m_previousTopGeometry &&
00070 guessGeometry == m_previousGuess )
00071 {
00073 intersept.reserve( m_localIntersections.size() );
00074 intersept.insert(intersept.begin(),
00075 m_localIntersections.begin() ,
00076 m_localIntersections.end());
00078 return intersept.size();
00079 }
00080
00093 IGeometryInfo* giLocal = 0 ;
00094 IGeometryInfo* gi =
00095
00096 ( 0 != guessGeometry &&
00097 0 != ( giLocal = findLocalGI( point1 ,
00098 point2 ,
00099 guessGeometry ,
00100 alternativeGeometry ) ) ) ?
00101 guessGeometry :
00102
00103 ( previousGeometry() && topGeometry == m_previousTopGeometry &&
00104 0 != ( giLocal = findLocalGI( point1 ,
00105 point2 ,
00106 previousGeometry() ,
00107 topGeometry ) ) ) ?
00108
00109 previousGeometry() :
00110 ( 0 != ( giLocal = findLocalGI( point1 ,
00111 point2 ,
00112 topGeometry,
00113 topGeometry ) ) ) ?
00114
00115 topGeometry : 0 ;
00116
00118 if( 0 == giLocal )
00119 throw TransportSvcException( "TransportSvc::(1) unable to locate points",
00120 StatusCode::FAILURE );
00121 if( 0 == gi )
00122 throw TransportSvcException( "TransportSvc::(2) unable to locate points",
00123 StatusCode::FAILURE );
00124
00126 setPreviousGeometry( giLocal );
00127
00129 const ILVolume* lv = giLocal->lvolume();
00130 lv->intersectLine
00131 ( giLocal->toLocalMatrix() * point ,
00132 giLocal->toLocalMatrix() * vect ,
00133 intersept ,
00134 tickMin ,
00135 tickMax ,
00136 threshold );
00137
00139 m_prevPoint1 = point1 ;
00140 m_prevPoint2 = point2 ;
00141 m_previousThreshold = threshold ;
00142 m_previousGuess = guessGeometry ;
00143 m_previousTopGeometry = topGeometry ;
00144
00146 m_localIntersections.clear();
00147 m_localIntersections.reserve( intersept.size());
00148 m_localIntersections.insert(m_localIntersections.begin(),
00149 intersept.begin() ,
00150 intersept.end());
00151 }
00152 catch ( const GaudiException& Exception )
00153 {
00155 m_prevPoint1 = Gaudi::XYZPoint() ;
00156 m_prevPoint2 = Gaudi::XYZPoint() ;
00157 m_previousThreshold = -1000.0 ;
00158 m_previousGuess = 0 ;
00159 m_previousTopGeometry = 0 ;
00160 m_localIntersections.clear() ;
00161
00163 std::string message
00164 ("TransportSvc::intersection(...), exception caught; Params: ");
00165 {
00166 std::ostringstream ost;
00167 ost << "Point=" << point
00168 << ",Vect=" << vect
00169 << ",Tick=" << tickMin << "/" << tickMax
00170 << "Thrsh=" << threshold;
00171 if( 0 != alternativeGeometry ) { ost << "A.Geo!=NULL" ; }
00172 if( 0 != guessGeometry ) { ost << "G.Geo!=NULL" ; }
00173 message += ost.str();
00174 Assert( false , message , Exception );
00175 }
00176 }
00177 catch( ... )
00178 {
00180 m_prevPoint1 = Gaudi::XYZPoint() ;
00181 m_prevPoint2 = Gaudi::XYZPoint() ;
00182 m_previousThreshold = -1000.0 ;
00183 m_previousGuess = 0 ;
00184 m_previousTopGeometry = 0 ;
00185 m_localIntersections.clear() ;
00186
00188 std::string message
00189 ("TransportSvc::intersection(...), unknown exception caught; Params: ");
00190 {
00191 std::ostringstream ost;
00192 ost << "Point=" << point
00193 << ",Vect=" << vect
00194 << ",Tick=" << tickMin << "/" << tickMax
00195 << "Thrsh=" << threshold;
00196 if( 0 != alternativeGeometry ) { ost << "A.Geo!=NULL" ; }
00197 if( 0 != guessGeometry ) { ost << "G.Geo!=NULL" ; }
00198 message += ost.str();
00199 Assert( false , message );
00200 }
00201 }
00202
00203 return intersept.size() ;
00205 };
00206
00207
00208
00209
00210 #endif // __DETDESC_TRANSPORTSVC_TRANSPORTSVCINTERSECTIONS_H__
00211