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),
44 : TCTBase((const TCTBase&) c),
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;
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);
141 double kappa =
_helix.kappa();
142 double phi0 =
_helix.phi0();
155 double firstdfdphi = 0.;
156 static bool first =
true;
165 double rho = TCHelix::ConstantAlpha / kappa;
166 double tanLambda =
_helix.tanl();
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 relate TRGCDCCellHit and TRGCDCTrack objects.
std::vector< TRGCDCLink * > _tsAll
Links for all super layers.
bool _fitted
Fitting status.
int m_debugValue
Debugging variable.
double m_2DFitChi2
2D fit chi2
TRGCDCHelix _helix
Helix parameter.
double m_3DFitChi2
3D fit chi2
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.
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.
const Vector3D & direction(void) const
returns direction vector of the wire.
const HepGeom::Point3D< double > & backwardPosition(void) const
returns position in backward endplate.
static std::vector< const TRGCDCTrack * > _list
a vector to keep all TRGCDCTrack objects.
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.
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.
std::string name(void) const override
returns name.
double dPhi(void) const
returns dPhi to the closest point.
const HepGeom::Point3D< double > & xyPosition(void) const
returns middle position of a wire. z component is 0.
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.
static std::vector< const TRGCDCTrack * > list(void)
returns a list of TRGCDCTrack's.
const HepGeom::Point3D< double > ORIGIN
Origin 3D point.
bool axial(void) const
returns true if this wire is in an axial layer.
virtual ~TRGCDCTrack()
Destructor.
Abstract base class for different kinds of events.