13 #define TRGCDC_SHORT_NAMES
15 #include "trg/trg/Debug.h"
16 #include "trg/cdc/CircleFitter.h"
17 #include "trg/cdc/TrackBase.h"
18 #include "trg/cdc/Circle.h"
19 #include "trg/cdc/Link.h"
20 #include "trg/cdc/Lpav.h"
30 TCCFitter::TCCFitter(
const std::string& name)
31 : TCFitter(name), _charge(0.), _radius(0.), _center(
Point3D(0., 0., 0.))
35 TCCFitter::~TCCFitter()
40 TCCFitter::fit(TCTBase& t)
const
43 TRGDebug::enterStage(
"TCCFitter::fit");
49 if (TRGDebug::level() > 1)
50 cout << TRGDebug::tab() <<
"Circle is fitted already" << endl;
51 TRGDebug::leaveStage(
"TCCFitter::fit");
56 if (t.links().size() < 3) {
57 if (TRGDebug::level() > 1)
58 cout << TRGDebug::tab() <<
"#links is less than 3" << endl;
59 TRGDebug::leaveStage(
"TCCFitter::fit");
65 const unsigned n = t.links().size();
66 for (
unsigned i = 0; i < n; i++) {
67 const TCLink* l = t.links()[i];
72 if (h->state() & CellHitPatternLeft)
73 point = h->position(CellHitLeft);
74 else if (h->state() & CellHitPatternRight)
75 point = h->position(CellHitRight);
77 point = h->xyPosition();
83 circle.add_point(point.x(), point.y());
85 if (TRGDebug::level() > 2) {
86 cout << TRGDebug::tab() <<
"point " << i;
87 cout << point << endl;
91 if (circle.fit() < 0.0 || circle.kappa() == 0.0) {
92 if (TRGDebug::level() > 1)
93 cout << TRGDebug::tab() <<
"fit failed" << endl;
94 TRGDebug::leaveStage(
"TCCFitter::fit");
97 CLHEP::HepVector v(circle.center());
100 _radius = circle.radius();
104 for (
unsigned i = 0; i < n; i++) {
105 const TCLink* l = t.links()[i];
106 if (l == 0)
continue;
109 if (h == 0)
continue;
111 float q = (_center.cross(h->xyPosition())).z();
112 if (q > 0.) qSum += 1;
115 if (qSum >= 0) _charge = +1.;
119 if (t.objectType() == TRGCDCCircleType)
120 ((TRGCDCCircle&) t).property(_charge, _radius, _center);
124 for (
unsigned i = 0; i < n; i++) {
125 TCLink* l = t.links()[i];
126 if (l == 0)
continue;
131 if (TRGDebug::level() > 1) {
132 cout << TRGDebug::tab() <<
"fitted successfully" << endl;
133 cout << TRGDebug::tab() <<
" charge=" << _charge
134 <<
",radius=" << _radius <<
",center=" << _center << endl;
136 TRGDebug::leaveStage(
"TCCFitter::fit");
A class to represent a wire hit in CDC.
#define TRGCDCFitAlreadyFitted
parameter to identify fit result
HepGeom::Point3D< double > Point3D
3D point
#define TRGCDCFitFailed
parameter to identify fit result
#define TRGCDCFitErrorFewHits
parameter to identify fit result
Abstract base class for different kinds of events.