#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 "TRotation.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 "PndDrcSurfPolyCyl.h" #include "PndDrcOptMatAbs.h" #include "PndDrcOptDev.h" //---------------------------------------------------------------------- PndDrcSurfPolyCyl::PndDrcSurfPolyCyl() { m_radius = -999; m_checked = false; } //---------------------------------------------------------------------- PndDrcSurfPolyCyl* PndDrcSurfPolyCyl::clone() const { return new PndDrcSurfPolyCyl(*this); } //---------------------------------------------------------------------- void PndDrcSurfPolyCyl::copy(const PndDrcSurfPolyCyl& s) { m_radius = s.m_radius; m_checked = s.m_checked; m_trans = s.m_trans; m_transInv = s.m_transInv; } //---------------------------------------------------------------------- PndDrcSurfPolyCyl::PndDrcSurfPolyCyl(const PndDrcSurfPolyCyl& s) : PndDrcSurfPolyFlat(s) { if (s.m_verbosity>=1) cout<<" PndDrcSurfPolyCyl::PndDrcSurfPolyCyl" <<"(const PndDrcSurfPolyCyl&) name,copy: " <=1) cout<<" PndDrcSurfPolyCyl::operator=" <<"(const PndDrcSurfPolyCyl&) name,copy: " <((*this)) = s; // assignment of base class part. copy(s); } return *this; } //---------------------------------------------------------------------- XYZVector PndDrcSurfPolyCyl::normal(const XYZPoint& point) const { if (!m_checked) m_checked = check();// check dimensions // transform point back, where sphere was defined. XYZPoint point0(m_transInv*point); // normal vector points from origin (0,0,0) to point of surface. XYZVector pn(point0); // but y-component is zero pn.SetY(0); // transform back return m_trans(pn).Unit();//p1.Unit(); } //---------------------------------------------------------------------- bool PndDrcSurfPolyCyl::surfaceHit(PndDrcPhoton& ph, XYZPoint& pos_new, double& path_length) const { if (!m_checked) m_checked = check();// check dimensions // transform back in sphere definitions space XYZPoint pos(m_transInv*ph.position()); XYZVector dir(m_transInv*ph.direction()); // 2 positions for photon to have distance=radius from y-axis // // (pos+a*dir)^2=R^2 // pos^2 + 2 a dir pos + a^2 dir^2 = R^2 // a^2 + a 2*dir*pos/dir2 + (pos2-R2)/dir2 = 0 // // a1/2 = ... double pos2 = XYZVector(pos).Dot(XYZVector(pos)); double dir2 = dir.Dot(dir); double posdir = dir.Dot(pos); double p = 2*posdir/dir2; double q = (pos2-m_radius*m_radius)/dir2; double root2 = p*p/4-q; if (root2<0) return false; // no hit double lambda1 = -posdir + sqrt(root2); double lambda2 = -posdir - sqrt(root2); const double eps = 0.001; if (m_verbosity>=4) cout<<" PndDrcSurfPolyCyl::surfaceHit lambda_1,2=" <eps && lambda2>eps) { // check both lambdas XYZPoint pos_new1 = pos + lambda1*dir; XYZPoint pos_check(pos_new1); bool hit1 = (pos_new1.Z()>0); pos_check.SetZ(0); if (hit1) hit1 = withinSurface(pos_check); XYZPoint pos_new2 = pos + lambda2*dir; pos_check = pos_new2; bool hit2 = (pos_new2.Z()>0); pos_check.SetZ(0); if (hit2) hit2 = withinSurface(pos_check); if (hit1 && hit2) { // take closest double lambda = (lambda1eps && lambda2<=eps) { path_length = lambda1; } else if (lambda1<=eps && lambda2>eps) { path_length = lambda2; } else { //cout<<" not taken"<=4) cout<<" PndDrcSurfPolyCyl::surfaceHit pos_new_z=" <=4) cout<<" PndDrcSurfPolyCyl::surfaceHit false"<=4) cout<<" PndDrcSurfPolyCyl::surfaceHit false"<(isize-1) || i<0) { cerr<<" *** PndDrcSurfPolyCyl::limitingPoint: index out of range, i="<=3) cout<<" PndDrcSurfPolyCyl::addTransform() name="<SetPoint("<<(icnt++)<<"," <SetPoint("<<(icnt++)<<"," <SetLineColor("<Draw();"<