13#define TRGCDC_SHORT_NAMES
15#include "cdc/dataobjects/CDCSimHit.h"
16#include "trg/trg/Debug.h"
17#include "trg/trg/Constants.h"
18#include "trg/cdc/TRGCDCTrack.h"
19#include "trg/cdc/Circle.h"
20#include "trg/cdc/Wire.h"
21#include "trg/cdc/SegmentHit.h"
22#include "trg/cdc/Link.h"
23#include "trg/cdc/Helix.h"
24#include "trg/cdc/TRGCDC.h"
34 vector<const TRGCDCTrack*>
38 : TCTBase(
"unknown", 0),
39 _helix(
ORIGIN, CLHEP::HepVector(5, 0), CLHEP::HepSymMatrix(5, 0)), m_2DFitChi2(9999), m_3DFitChi2(9999), m_debugValue(0)
44 : TCTBase((const TCTBase&) c),
45 _helix(
ORIGIN, CLHEP::HepVector(5, 0), CLHEP::HepSymMatrix(5, 0)), m_2DFitChi2(9999), m_3DFitChi2(9999), m_debugValue(0)
50 name(
"ConvFrom" + c.name());
57 CLHEP::HepVector a(5);
62 a[2] = TCHelix::ConstantAlpha / c.radius();
63 a[0] = (c.center().x() -
ORIGIN.x()) / cos(a[1]) - c.radius();
69 unsigned n =
_tsAll.size();
70 for (
unsigned i = 0; i < n; i++)
79 for (
unsigned i = 0; i <
_list.size(); i++)
85 vector<const TRGCDCTrack*>
88 vector<const TRGCDCTrack*> t;
99 double wp[3]; w.xyPosition(wp);
100 double wb[3]; w.backwardPosition(wb);
102 v[0] = w.direction().x();
103 v[1] = w.direction().y();
104 v[2] = w.direction().z();
107 if (doSagCorrection) {
108 std::cout <<
"TTrack::approach !!! sag correction is not implemented"
131 double xt[3];
_helix.
x(0., xt);
132 double x0 = - xc.x();
133 double y0 = - xc.y();
134 double x1 = wp[0] + x0;
135 double y1 = wp[1] + y0;
138 dPhi = atan2(x0 * y1 - y0 * x1, x0 * x1 + y0 * y1);
155 double firstdfdphi = 0.;
156 static bool first =
true;
165 double rho = TCHelix::ConstantAlpha / kappa;
167 static CLHEP::HepVector
x(3);
170 const double convergence = 1.0e-5;
173 while (nTrial < 100) {
180 l = v[0] * t_x[0] + v[1] * t_x[1] + v[2] * t_x[2]
181 - v[0] * wb[0] - v[1] * wb[1] - v[2] * wb[2];
183 double rcosPhi = rho * cos(phi0 + dPhi);
184 double rsinPhi = rho * sin(phi0 + dPhi);
185 t_dXdPhi[0] = rsinPhi;
186 t_dXdPhi[1] = - rcosPhi;
187 t_dXdPhi[2] = - rho * tanLambda;
190 double t_d2Xd2Phi[2];
191 t_d2Xd2Phi[0] = rcosPhi;
192 t_d2Xd2Phi[1] = rsinPhi;
196 n[0] = t_x[0] - wb[0];
197 n[1] = t_x[1] - wb[1];
198 n[2] = t_x[2] - wb[2];
201 a[0] = n[0] - l * v[0];
202 a[1] = n[1] - l * v[1];
203 a[2] = n[2] - l * v[2];
204 double dfdphi = a[0] * t_dXdPhi[0]
206 + a[2] * t_dXdPhi[2];
211 firstdfdphi = dfdphi;
216 std::cout << Tab() <<
"TTrack::approach:" << w.name() <<
" "
217 <<
"dfdphi(0)=" << firstdfdphi
218 <<
",(" << nTrial <<
")=" << dfdphi << std::endl;
223 if (fabs(dfdphi) < convergence)
226 double dv = v[0] * t_dXdPhi[0]
228 + v[2] * t_dXdPhi[2];
229 double t0 = t_dXdPhi[0] * t_dXdPhi[0]
230 + t_dXdPhi[1] * t_dXdPhi[1]
231 + t_dXdPhi[2] * t_dXdPhi[2];
232 double d2fd2phi = t0 - dv * dv
233 + a[0] * t_d2Xd2Phi[0]
234 + a[1] * t_d2Xd2Phi[1];
237 dPhi -= dfdphi / d2fd2phi;
258 std::vector<HepGeom::Point3D<double> >
266 vector<HepGeom::Point3D<double> > posv;
269 for (
unsigned i = 0; i < cdc.nSuperLayers(); i++) {
272 if ((
links(i).size() == 0) || (
links(i).size() > 1)) {
274 cout <<
TRGDebug::tab() <<
"TRGCDCTrack::perfectPosition !!! #links in superlayer "
275 << i <<
" is " <<
links(i).size() << endl;
281 const TCSHit* h =
dynamic_cast<const TCSHit*
>(
links(i)[0]->hit());
283 cout <<
"TRGCDCTrack::perfectPosition !!! hit is not a TCSHit"
291 cout <<
"TRGCDCTrack::perfectPosition !!! no CDCSimHit found"
298 s->getPosTrack().y(),
299 s->getPosTrack().z()));
303 <<
" : " << posv.back() << endl;
A class to represent a circle.
A class to relate TRGCDCCellHit and TRGCDCTrack objects.
std::vector< TRGCDCLink * > _tsAll
Links for all super layers.
bool _fitted
Fitting status.
TRGCDCHelix _helix
Helix parameter.
A class to represent a wire in CDC.
The instance of TRGCDC is a singleton.
const TRGCDCHelix & helix(void) const
returns helix parameter.
const TRGCDCWire * wire(void) const
returns a pointer to a wire.
HepGeom::Point3D< double > x(double dPhi=0.) const
returns position after rotating angle dPhi in phi direction.
static std::string tab(void)
returns tab spaces.
static TRGCDC * getTRGCDC(void)
returns TRGCDC object.
TRGCDCTrack()
Constructor.
HepGeom::Point3D< double > Point3D
3D point
const HepGeom::Point3D< double > & center(void) const
returns position of helix center(z = 0.);
int approach(TRGCDCLink &, bool sagCorrection=false) const
calculates the closest approach to a wire in real space. Results are stored in TLink....
double charge(void) const
returns charge.
static std::vector< const TRGCDCTrack * > _list
a vector to keep all TRGCDCTrack objects.
double tanl(void) const
returns tanl.
const HepGeom::Point3D< double > & positionOnTrack(void) const
returns the closest point on track to wire.
std::vector< HepGeom::Point3D< double > > perfectPosition(void) const
returns perfect position from GEANT.
double phi0(void) const
returns phi0.
const CLHEP::HepVector & a(void) const
returns helix parameters.
const HepGeom::Point3D< double > & positionOnWire(void) const
returns the closest point on wire to a track.
virtual const CLHEP::Hep3Vector & x(void) const override
returns position vector.
double dPhi(void) const
returns dPhi to the closest point.
std::string name(void) const
returns name.
static int level(void)
returns the debug level.
const std::vector< TRGCDCLink * > & links(void) const
returns a vector to track segments.
double kappa(void) const
returns kappa.
static std::vector< const TRGCDCTrack * > list(void)
returns a list of TRGCDCTrack's.
const HepGeom::Point3D< double > ORIGIN
Origin 3D point.
virtual ~TRGCDCTrack()
Destructor.
Abstract base class for different kinds of events.