00001
00002 #include "TkrRecon/GFdata.h"
00003
00004
00005 GFbase::GFbase(double sigmaCut, double ene, int ist, const Ray& testRay):
00006 m_sigmaCut(sigmaCut),
00007 m_iniEnergy(ene),
00008 m_iniLayer(ist)
00009
00010 {
00011
00012 m_alive = true;
00013
00014
00015 if (m_iniEnergy < GFcontrol::minEnergy) m_iniEnergy = GFcontrol::minEnergy;
00016 m_inVertex = testRay.position();
00017 m_inDirection = testRay.direction();
00018
00019 }
00020
00021 void GFbase::doit()
00022
00023 {
00024 int kplane = m_iniLayer;
00025
00026 for ( ; -1 < kplane && kplane < GFtutor::numPlanes(); kplane++) {
00027 step(kplane);
00028 anastep(kplane);
00029 if (!alive()) {
00030 break;
00031 }
00032 }
00033 }
00034
00035
00036 void GFdata::ini()
00037
00038 {
00039 m_vertex = Point(0.,0.,0.);
00040 m_direction = Vector(0.,0.,0.);
00041 m_RCenergy=0.;
00042 m_quality=-100.;
00043 m_firstLayer=-1;
00044 m_nhits = -1;
00045 m_itower =-1;
00046 }
00047
00048 bool GFdata::empty() const
00049
00050 {
00051 bool empty = false;
00052 if (m_firstLayer < 0) empty = true;
00053 return empty;
00054 }
00055
00056
00057 void GFdata::writeOut(MsgStream& log) const
00058
00059 {
00060 log << MSG::DEBUG << " --- GFdata::writeOut --- " << endreq;
00061 log << MSG::DEBUG << " Quality = " << Q() << endreq;
00062 log << MSG::DEBUG << " Vertex = " << vertex().x() << " " << vertex().y() << " " << vertex().z() << endreq;
00063 log << MSG::DEBUG << " Direction = " << direction().x() << " " << direction().y() << " " << direction().z() << endreq;
00064 log << MSG::DEBUG << " RCenergy = " << RCenergy() << endreq;
00065 log << MSG::DEBUG << " first Layer = " << firstLayer() << endreq;
00066 log << MSG::DEBUG << " Tower = " << tower() << endreq;
00067 log << MSG::DEBUG << " num Hits = " << nhits() << endreq;
00068 }
00069
00070 Point GFdata::doVertex(const Ray& r1, const Ray& r2)
00071
00072 {
00073 Point Vertex(0.,0.,0.);
00074
00075 double z1 = r1.position().z();
00076 double z2 = r2.position().z();
00077 double cosz1 = r1.direction().z();
00078 double cosz2 = r2.direction().z();
00079 if (cosz2 == 0. || cosz1 == 0.) return Vertex;
00080
00081
00082 Vector Vdir = r2.direction();
00083 Point Porigin = r2.position((z1-z2)/cosz2);
00084
00085 Ray r2ref(Porigin,Vdir);
00086
00087 double deltaX = r1.position().x()-r2ref.position().x();
00088 double deltaY = r1.position().y()-r2ref.position().y();
00089 double deltaSlopeX = (r2ref.direction().x()/cosz2) - (r1.direction().x()/cosz1);
00090 double deltaSlopeY = (r2ref.direction().y()/cosz2) - (r1.direction().y()/cosz1);
00091
00092 bool xview = true;
00093 bool yview = true;
00094 double deltaZX = 0.;
00095 double deltaZY = 0.;
00096 if (deltaSlopeX == 0.) xview = false;
00097 if (deltaSlopeY == 0.) yview = false;
00098 if (xview) deltaZX = deltaX/deltaSlopeX;
00099 if (yview) deltaZY = deltaY/deltaSlopeY;
00100
00101 if (xview && !yview) Vertex = r1.position(deltaZX/cosz1);
00102 else if (!xview && yview) Vertex = r1.position(deltaZY/cosz1);
00103 else if (xview && yview) {
00104 Vertex = (z1 >= z2? r1.position(0.) : r2.position(0.));
00105
00106 if (Vertex.x() == 0.) {
00107 double x0 = r1.position((z2-z1)/cosz1).x();
00108 Vertex = Point( x0, r2.position().y(),r2.position().z());
00109 }
00110 if (Vertex.y() == 0.) {
00111 double y0 = r2.position((z1-z2)/cosz2).y();
00112 Vertex = Point(r1.position().x(), y0 , r1.position().z());
00113 }
00114 }
00115 return Vertex;
00116 }
00117
00118
00119 Vector GFdata::doDirection(const Vector& xdir, const Vector& ydir)
00120
00121 {
00122
00123 double slopeX = xdir.x()/xdir.z();
00124 double slopeY = ydir.y()/ydir.z();
00125
00126 double factor = -1;
00127 Vector dir = Vector(factor*slopeX,factor*slopeY,factor).unit();
00128
00129 return dir;
00130 }