#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 "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 "DrcPhoton.h" #include "DrcOptReflAbs.h" #include "DrcSurfAbs.h" #include "DrcSurfCyl.h" #include "DrcOptMatAbs.h" #include "DrcOptDev.h" //---------------------------------------------------------------------- DrcSurfCyl::DrcSurfCyl() { } //---------------------------------------------------------------------- DrcSurfCyl* DrcSurfCyl::clone() const { return new DrcSurfCyl(*this); } //---------------------------------------------------------------------- void DrcSurfCyl::copy(const DrcSurfCyl& s) { m_p1 = s.m_p1; m_p2 = s.m_p2; m_radius = s.m_radius; } //---------------------------------------------------------------------- DrcSurfCyl::DrcSurfCyl(const DrcSurfCyl& s) : DrcSurfAbs(s) { if (s.m_verbosity>=1) cout<<" DrcSurfCyl::DrcSurfCyl" <<"(const DrcSurfCyl&) name,copy: " <=1) cout<<" DrcSurfCyl::operator=" <<"(const DrcSurfCyl&) name,copy: " <((*this)) = s; // assignment of base class part. copy(s); } return *this; } //---------------------------------------------------------------------- void DrcSurfCyl::set(XYZPoint r1, XYZPoint r2, double radius) { m_p1 = r1; m_p2 = r2; m_radius = radius; } //---------------------------------------------------------------------- XYZVector DrcSurfCyl::normal(const XYZPoint& point) const { // normal vector is perpendicular to vector m_p1-m_p2 XYZVector diff(m_p2-m_p1); XYZVector cross1 = (point-m_p1).Cross(diff); return (diff.Cross(cross1)).Unit(); } //---------------------------------------------------------------------- bool DrcSurfCyl::surfaceHit(DrcPhoton& ph, XYZPoint& pos_new, double& path_length) const { //static const double eps = 1.0e-9; // for the methode look up // http://www.matheraum.de/read?t=77538&v=t // but watch out: the results are wrong. XYZPoint a(ph.position()); XYZVector u((ph.direction()).Unit()); // photon: a + mu*u; XYZPoint b(m_p1); XYZVector n(m_p2-m_p1); XYZVector c = a-b; XYZVector p = u.Dot(n)/n.Mag2()*n; XYZVector m = n.Dot(c)/n.Mag2()*n; // mu2 * s + mu * p + q = 0; double s = u.Dot(u) - 2*u.Dot(p) + p.Dot(p); double P = 2*(c.Dot(u) - c.Dot(p) - u.Dot(m) + p.Dot(m)); double Q = c.Dot(c) - 2*c.Dot(m) + m.Dot(m) - m_radius*m_radius; //cout<<" s P Q "<0) { mu = mu_low; } else if (mu_high>0) { mu = mu_high; } else { return false; } if (mu>0) { double lambda = (n.Dot(c)+mu*n.Dot(u))/n.Mag2(); //cout<<" lambda = "<0 && lambda<1) { pos_new = a + mu*u; path_length = mu; if (m_pixel) ph.setFate(Drc::PhotMeasured); return true; } } return false; } //---------------------------------------------------------------------- void DrcSurfCyl::print(fstream& stream) const { const double pi=3.1415926535; TVector3 diff(m_p2.X()-m_p1.X(), m_p2.Y()-m_p1.Y(), m_p2.Z()-m_p1.Z()); TVector3 norm = m_radius * (diff.Orthogonal()).Unit(); stream<<" TPolyLine3D *l1 = new TPolyLine3D(49);"<SetPoint("<<0<<"," <SetPoint("<<1<<"," <SetLineColor("<Draw();"<SetPoint("<SetPoint("<SetPoint("<<48<<"," <SetPoint("<<48<<"," <SetLineColor("<Draw();"<SetLineColor("<Draw();"<=3) cout<<" DrcSurfAbs::addTransform() name="<