// ---------------------------------------------------- // This file belongs to the ray tracing framework // for the use with Cherenkov detectors // // created 2007 //----------------------------------------------------- #include "PndDrcEffiAbs.h" #include "PndDrcSurfCyl.h" #include "PndDrcPhoton.h" //#include "PndDrcOptReflAbs.h" //#include "PndDrcSurfAbs.h" //#include "PndDrcOptMatAbs.h" //#include "PndDrcOptDev.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 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 "TPolyLine3D.h" //---------------------------------------------------------------------- PndDrcSurfCyl::PndDrcSurfCyl() { } //---------------------------------------------------------------------- PndDrcSurfCyl* PndDrcSurfCyl::Clone() const { return new PndDrcSurfCyl(*this); } //---------------------------------------------------------------------- void PndDrcSurfCyl::Copy(const PndDrcSurfCyl& s) { fP1 = s.fP1; fP2 = s.fP2; fRadius = s.fRadius; } //---------------------------------------------------------------------- PndDrcSurfCyl::PndDrcSurfCyl(const PndDrcSurfCyl& s) : PndDrcSurfAbs(s) { if (s.fVerbosity>=1) cout<<" PndDrcSurfCyl::PndDrcSurfCyl" <<"(const PndDrcSurfCyl&) name,copy: " <=1) cout<<" PndDrcSurfCyl::operator=" <<"(const PndDrcSurfCyl&) name,copy: " <((*this)) = s; // assignment of base class part. Copy(s); } return *this; } //---------------------------------------------------------------------- void PndDrcSurfCyl::Set(XYZPoint r1, XYZPoint r2, double radius) { fP1 = r1; fP2 = r2; fRadius = radius; } //---------------------------------------------------------------------- XYZVector PndDrcSurfCyl::Normal(const XYZPoint& point) const { // normal vector is perpendicular to vector fP1-fP2 XYZVector diff(fP2-fP1); XYZVector cross1 = (point-fP1).Cross(diff); return (diff.Cross(cross1)).Unit(); } //---------------------------------------------------------------------- bool PndDrcSurfCyl::SurfaceHit(PndDrcPhoton& 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(fP1); XYZVector n(fP2-fP1); 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 pp = 2*(c.Dot(u) - c.Dot(p) - u.Dot(m) + p.Dot(m)); double qq = c.Dot(c) - 2*c.Dot(m) + m.Dot(m) - fRadius*fRadius; //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 (fPixel){ if (fEffiCathode ->EffiFlag(ph.Wavelength(), ph.Direction().Dot(Normal(pos_new)))) { ph.SetFate(Drc::kPhotMeasured); if (fPixelCorr) ph.SetPosition(fPixelPoint); } else { ph.SetFate(Drc::kPhotAbsorbed); } } //if (fPixel) ph.SetFate(Drc::kPhotMeasured); return true; } } return false; } //---------------------------------------------------------------------- void PndDrcSurfCyl::Print(fstream& stream) const { const double kPi=3.1415926535; TVector3 diff(fP2.X()-fP1.X(), fP2.Y()-fP1.Y(), fP2.Z()-fP1.Z()); TVector3 norm = fRadius * (diff.Orthogonal()).Unit(); stream<<" TPolyLine3D *l1 = new TPolyLine3D(49);"<SetPoint("<<0<<"," <SetPoint("<<1<<"," <SetLineColor("<Draw();"<SetPoint( 0, r1.X(), r1.Y(), r1.Z() ); l->SetPoint( 1, r2.X(), r2.Y(), r2.Z() ); l->SetLineColor(fPrintColor); l->Draw(); if (i==0) { r1_null = r1; r2_null = r2; } stream<<" l1->SetPoint("<SetPoint("<SetPoint( i, r1.X(), r1.Y(), r1.Z() ); l2->SetPoint( i, r2.X(), r2.Y(), r2.Z() ); } stream<<" l1->SetPoint("<<48<<"," <SetPoint("<<48<<"," <SetLineColor("<Draw();"<SetLineColor("<Draw();"<SetPoint( 48, r1_null.X(), r1_null.Y(), r1_null.Z() ); l2->SetPoint( 48, r2_null.X(), r2_null.Y(), r2_null.Z() ); l1->SetLineColor(fPrintColor); l2->SetLineColor(fPrintColor); l2->Draw(); } //---------------------------------------------------------------------- void PndDrcSurfCyl::Print() const { cout<<" Coordinates of PndDrcSurfCyl "<