14 #define TRGCDC_SHORT_NAMES
16 #include "cdc/dataobjects/CDCSimHit.h"
17 #include "trg/trg/Debug.h"
18 #include "trg/trg/Constants.h"
19 #include "trg/cdc/Track.h"
20 #include "trg/cdc/Circle.h"
21 #include "trg/cdc/Wire.h"
22 #include "trg/cdc/SegmentHit.h"
23 #include "trg/cdc/Link.h"
24 #include "trg/cdc/Helix.h"
25 #include "trg/cdc/TRGCDC.h"
35 vector<const TRGCDCTrack*>
36 TRGCDCTrack::_list = vector<const TRGCDCTrack*>();
38 TRGCDCTrack::TRGCDCTrack()
39 : TCTBase(
"unknown", 0),
40 _helix(
ORIGIN, CLHEP::HepVector(5, 0), CLHEP::HepSymMatrix(5, 0)), m_2DFitChi2(9999), m_3DFitChi2(9999), m_debugValue(0)
45 : TCTBase((const TCTBase&) c),
46 _helix(
ORIGIN, CLHEP::HepVector(5, 0), CLHEP::HepSymMatrix(5, 0)), m_2DFitChi2(9999), m_3DFitChi2(9999), m_debugValue(0)
51 name(
"ConvFrom" + c.name());
58 CLHEP::HepVector a(5);
63 a[2] = TCHelix::ConstantAlpha / c.radius();
64 a[0] = (c.center().x() -
ORIGIN.x()) / cos(a[1]) - c.radius();
70 unsigned n =
_tsAll.size();
71 for (
unsigned i = 0; i < n; i++)
80 for (
unsigned i = 0; i <
_list.size(); i++)
86 vector<const TRGCDCTrack*>
89 vector<const TRGCDCTrack*> t;
100 double wp[3]; w.xyPosition(wp);
101 double wb[3]; w.backwardPosition(wb);
103 v[0] = w.direction().x();
104 v[1] = w.direction().y();
105 v[2] = w.direction().z();
108 if (doSagCorrection) {
109 std::cout <<
"TTrack::approach !!! sag correction is not implemented"
132 double xt[3];
_helix.
x(0., xt);
133 double x0 = - xc.x();
134 double y0 = - xc.y();
135 double x1 = wp[0] + x0;
136 double y1 = wp[1] + y0;
139 dPhi = atan2(x0 * y1 - y0 * x1, x0 * x1 + y0 * y1);
156 double firstdfdphi = 0.;
157 static bool first =
true;
166 double rho = TCHelix::ConstantAlpha / kappa;
168 static CLHEP::HepVector
x(3);
171 const double convergence = 1.0e-5;
174 while (nTrial < 100) {
181 l = v[0] * t_x[0] + v[1] * t_x[1] + v[2] * t_x[2]
182 - v[0] * wb[0] - v[1] * wb[1] - v[2] * wb[2];
184 double rcosPhi = rho * cos(phi0 + dPhi);
185 double rsinPhi = rho * sin(phi0 + dPhi);
186 t_dXdPhi[0] = rsinPhi;
187 t_dXdPhi[1] = - rcosPhi;
188 t_dXdPhi[2] = - rho * tanLambda;
191 double t_d2Xd2Phi[2];
192 t_d2Xd2Phi[0] = rcosPhi;
193 t_d2Xd2Phi[1] = rsinPhi;
197 n[0] = t_x[0] - wb[0];
198 n[1] = t_x[1] - wb[1];
199 n[2] = t_x[2] - wb[2];
202 a[0] = n[0] - l * v[0];
203 a[1] = n[1] - l * v[1];
204 a[2] = n[2] - l * v[2];
205 double dfdphi = a[0] * t_dXdPhi[0]
207 + a[2] * t_dXdPhi[2];
212 firstdfdphi = dfdphi;
217 std::cout << Tab() <<
"TTrack::approach:" << w.name() <<
" "
218 <<
"dfdphi(0)=" << firstdfdphi
219 <<
",(" << nTrial <<
")=" << dfdphi << std::endl;
224 if (fabs(dfdphi) < convergence)
227 double dv = v[0] * t_dXdPhi[0]
229 + v[2] * t_dXdPhi[2];
230 double t0 = t_dXdPhi[0] * t_dXdPhi[0]
231 + t_dXdPhi[1] * t_dXdPhi[1]
232 + t_dXdPhi[2] * t_dXdPhi[2];
233 double d2fd2phi = t0 - dv * dv
234 + a[0] * t_d2Xd2Phi[0]
235 + a[1] * t_d2Xd2Phi[1];
238 dPhi -= dfdphi / d2fd2phi;
259 std::vector<HepGeom::Point3D<double> >
267 vector<HepGeom::Point3D<double> > posv;
270 for (
unsigned i = 0; i < cdc.nSuperLayers(); i++) {
273 if ((
links(i).size() == 0) || (
links(i).size() > 1)) {
275 cout <<
TRGDebug::tab() <<
"TRGCDCTrack::perfectPosition !!! #links in superlayer "
276 << i <<
" is " <<
links(i).size() << endl;
282 const TCSHit* h =
dynamic_cast<const TCSHit*
>(
links(i)[0]->hit());
284 cout <<
"TRGCDCTrack::perfectPosition !!! hit is not a TCSHit"
292 cout <<
"TRGCDCTrack::perfectPosition !!! no CDCSimHit found"
299 s->getPosTrack().y(),
300 s->getPosTrack().z()));
304 <<
" : " << posv.back() << endl;