#include using std::cout; using std::cerr; using std::cin; using std::endl; #include using std::valarray; #include using std::fstream; #include using std::string; #include using std::list; #include using std::vector; #include "TObject.h" #include "TVector3.h" #include "TRandom.h" #include "TMatrixD.h" #include "TVectorD.h" #include "TDecompSVD.h" #include "Math/Vector3D.h" using ROOT::Math::XYZVector; #include "Math/Point3D.h" using ROOT::Math::XYZPoint; #include "Math/Transform3D.h" using ROOT::Math::Transform3D; #include "Math/RotationX.h" using ROOT::Math::RotationX; #include "Math/RotationY.h" using ROOT::Math::RotationY; #include "Math/RotationZ.h" using ROOT::Math::RotationZ; #include "Math/Rotation3D.h" using ROOT::Math::Rotation3D; #include "PndDrcPhoton.h" #include "PndDrcOptReflAbs.h" #include "PndDrcSurfAbs.h" #include "PndDrcSurfPolyFlat.h" #include "PndDrcOptMatAbs.h" #include "PndDrcOptDev.h" //---------------------------------------------------------------------- PndDrcSurfPolyFlat::PndDrcSurfPolyFlat() { } //---------------------------------------------------------------------- PndDrcSurfPolyFlat* PndDrcSurfPolyFlat::clone() const { return new PndDrcSurfPolyFlat(*this); } //---------------------------------------------------------------------- void PndDrcSurfPolyFlat::copy(const PndDrcSurfPolyFlat& s) { m_p = s.m_p; m_normal = s.m_normal; } //---------------------------------------------------------------------- PndDrcSurfPolyFlat::PndDrcSurfPolyFlat(const PndDrcSurfPolyFlat& s) : PndDrcSurfAbs(s) { if (s.m_verbosity>=1) cout<<" PndDrcSurfPolyFlat::PndDrcSurfPolyFlat" <<"(const PndDrcSurfPolyFlat&) name,copy: " <=1) cout<<" PndDrcSurfPolyFlat::operator=" <<"(const PndDrcSurfPolyFlat&) name,copy: " <((*this)) = s; // assignment of base class part. copy(s); } return *this; } //---------------------------------------------------------------------- void PndDrcSurfPolyFlat::addPoint(XYZPoint point) { m_p.push_back(point); int isize = m_p.size(); // search normal vector from point differences with largest absolute // cross product. if (isize > 2) { double length2 = 0; for (int i=2; i length2) { length2 = normal.Mag2(); m_normal = normal.Unit(); } } } if (verbosity()>=5) { cout<<" PndDrcSurfPolyFlat::addPoint: vector size = "< 1.0L-eps) return false; // directions parallel // calculate closest distance TVector3 n0 = (p.Cross(q)).Unit(); double dist = fabs((pb-qb).Dot(n0)); if (dist>eps) return false; TVector3 P(pa.x(),pa.y(),pa.z()); TVector3 Q(qa.x(),qa.y(),qa.z()); // solve // P + p*s = Q + q*t // // d**2 = ((P+ps) - (Q+qt))**2 // // d/ds d**2 = d/dt d**2 => (P-Q) + (sp-tq) = 0 // // This linear equation is for the minimum distance between both lines // We prefer minimum distance over equality of both lines due to numerical // uncertainties. // // Solve linear equation // // px -qx s Qx-Px // py -qy t = Qy-Py // pz -qz Qz-Pz // TMatrixD A(3,2); A(0,0) = p.X(); A(1,0) = p.Y(); A(2,0) = p.Z(); A(0,1) = -q.X(); A(1,1) = -q.Y(); A(2,1) = -q.Z(); TVectorD B(3); B(0) = Q.X()-P.X(); B(1) = Q.Y()-P.Y(); B(2) = Q.Z()-P.Z(); TDecompSVD svd(A); if (!svd.Solve(B)) return false; //cout<<" crossing "<-eps && B[0]<1+eps && B[1]>-eps && B[1]<1+eps) return true; return false; } //---------------------------------------------------------------------- bool PndDrcSurfPolyFlat::surfaceHit(PndDrcPhoton& ph, XYZPoint& pos_new, double& path_length) const { if (verbosity()>=4) cout<<" PndDrcSurfPolyFlat::surfaceHit: name="<=4) cout<<" PndDrcSurfPolyFlat::surfaceHit: wrong dir " <<" lambda par ="< diff(isize); diff[isize-1] = (m_p[0] - m_p[isize-1]); XYZPoint p_out(diff[isize-1]); for (unsigned int i=0; i=4) { cout<<" PndDrcSurfPolyFlat::withinSurface:"<SetPoint("<SetPoint("<SetLineColor("<Draw();"<=3) cout<<" PndDrcSurfPolyFlat::addTransform() name="<