CGEM BOSS 6.6.5.f
BESIII Offline Software System
Loading...
Searching...
No Matches
TCircleFitter.cxx
Go to the documentation of this file.
1//-----------------------------------------------------------------------------
2// $Id: TCircleFitter.cxx,v 1.8 2010/03/31 09:58:59 liucy Exp $
3//-----------------------------------------------------------------------------
4// Filename : TCircleFitter.cc
5// Section : Tracking
6// Owner : Yoshi Iwasaki
7// Email : [email protected]
8//-----------------------------------------------------------------------------
9// Description : A class to fit a TTrackBase object to a circle.
10// See http://bsunsrv1.kek.jp/~yiwasaki/tracking/
11//-----------------------------------------------------------------------------
12
13#include "TrkReco/TCircleFitter.h"
14#include "TrkReco/TTrackBase.h"
15#include "TrkReco/TCircle.h"
16#include "TrkReco/TMLink.h"
17//#include "lpav/Lpav.h"
18//#include "TrkReco/Lpav.h"
19#include "TrackUtil/Lpav.h"
20
21TCircleFitter::TCircleFitter(const std::string & name)
22: TMFitter(name), _charge(0.), _radius(0.), _center(HepPoint3D(0., 0., 0.)) {
23}
24
26}
27
28int
30
31#ifdef TRKRECO_DEBUG_DETAIL
32 std::cout << " TCircleFitter::fit ..." << std::endl;
33#endif
34
35 //...Already fitted ?...
36 if (t.fitted()) return TFitAlreadyFitted;
37
38 //...Check # of hits...
39 if (t.links().length() < 3) return TFitErrorFewHits;
40
41 //...Hit loop...
42 Lpav circle;
43/*
44 circle.add_point(-173.011, 94.3169);
45 circle.add_point(-187.6, 101.528);
46 circle.add_point(-202.018, 108.601);
47 circle.add_point(-216.639, 115.691);
48 circle.add_point(-231.152, 122.49);
49 circle.add_point(-246.207, 129.496);
50 circle.add_point(-261.179, 136.407);
51 circle.add_point(-275.198, 142.764);
52 circle.add_point(-290.519, 149.572);
53 circle.add_point(-304.42, 155.7);
54 circle.add_point(-319.947, 162.285);
55 circle.add_point(-335.495, 168.731);
56 circle.add_point(-608.394, 264.577);
57 circle.add_point(-612.842, 265.869);
58 circle.add_point(-627.175, 270.011);
59 circle.add_point(-643.654, 274.719);
60 circle.add_point(-657.809, 278.683);
61 circle.add_point(-674.464, 283.209);
62 circle.add_point(-690.7, 287.541);
63 circle.add_point(-704.925, 291.091);
64 */
65 unsigned n = t.links().length();
66
67 for (unsigned i = 0; i < n; i++) {
68 TMLink * l = t.links()[i];
69 const TMDCWireHit * h = l->hit();
70
71 //...Check next hit...
72 HepPoint3D point;
73 if (h->state() & WireHitPatternLeft)
74 point = h->position(WireHitLeft);
75 else if (h->state() & WireHitPatternRight)
76 point = h->position(WireHitRight);
77 else
78 point = h->xyPosition();
79 // float weight = 1. / (h->distance() * h->distance());
80 // float weight = 1. / h->distance();
81
82// if (h->state() & WireHitPatternLeft) cout<<"h: "<<h->wire()->layerId()<<" local: "
83// <<h->wire()->localId()<<" TCirclefitter: L"<<endl;
84// else cout<<"h: "<<h->wire()->layerId()<<" local: "
85// <<h->wire()->localId()<<" TCirclefitter: R"<<endl;
86
87 circle.add_point(point.x(), point.y()); //, weight);
88 //yuany
89
90// cout<<"TCirclefitter("<<sqrt(point.x()*point.x()+point.y()*point.y())<<","
91// <<point.y()/point.x()<<") dis:"
92// <<(h->drift(0))*10000/40<<" point "<<point<<" L "<<(h->state()&WireHitPatternLeft)
93// <<" R "<<(h->state()&WireHitPatternRight)<<endl;
94
95// cout<<"TCirclefitter "<<point.x()<<" "<<point.y()<<" L "<<(h->state()&WireHitPatternLeft)<<" R "<<(h->state()&WireHitPatternRight)<<endl;
96 }
97
98 if (circle.fit() < 0.0 || circle.kappa() == 0.0) return TFitFailed;
99 //yuany
100// cout<<"circle chi2:"<<circle.fit()<<" kappa:"<<circle.kappa()<<" center:"<<circle.center()<<" radius:"<<circle.radius()<<endl;
101
102 HepVector v(circle.center());
103 _center.setX(v(1));
104 _center.setY(v(2));
105 _radius = circle.radius();
106
107 //...Determine charge...Better way???
108 int qSum = 0;
109 for (unsigned i = 0; i < n; i++) {
110 TMLink * l = t.links()[i];
111 if (l == 0) continue;
112
113 const TMDCWireHit * h = l->hit();
114 if (h == 0) continue;
115
116 float q = (_center.cross(h->xyPosition())).z();
117 if (q > 0.) qSum += 1;
118 else qSum -= 1;
119 }
120 if (qSum >= 0) _charge = +1.;
121 else _charge = -1.;
122 _radius *= _charge;
123
124 if (t.objectType() == Circle)
125 ((TCircle &) t).property(_charge, _radius, _center);
126 fitDone(t);
127 return 0;
128}
const Int_t n
****INTEGER imax DOUBLE PRECISION m_pi *DOUBLE PRECISION m_amfin DOUBLE PRECISION m_Chfin DOUBLE PRECISION m_Xenph DOUBLE PRECISION m_sinw2 DOUBLE PRECISION m_GFermi DOUBLE PRECISION m_MfinMin DOUBLE PRECISION m_ta2 INTEGER m_out INTEGER m_KeyFSR INTEGER m_KeyQCD *COMMON c_Semalib $ !copy of input $ !CMS energy $ !beam mass $ !final mass $ !beam charge $ !final charge $ !smallest final mass $ !Z mass $ !Z width $ !EW mixing angle $ !Gmu Fermi $ alphaQED at q
Definition: KKsem.h:33
**********Class see also m_nmax DOUBLE PRECISION m_amel DOUBLE PRECISION m_x2 DOUBLE PRECISION m_alfinv DOUBLE PRECISION m_Xenph INTEGER m_KeyWtm INTEGER m_idyfs DOUBLE PRECISION m_zini DOUBLE PRECISION m_q2 DOUBLE PRECISION m_Wt_KF DOUBLE PRECISION m_WtCut INTEGER m_KFfin *COMMON c_KarLud $ !Input CMS energy[GeV] $ !CMS energy after beam spread beam strahlung[GeV] $ !Beam energy spread[GeV] $ !z boost due to beam spread $ !electron beam mass *ff pair spectrum $ !minimum v
Definition: KarLud.h:35
void add_point(double x, double y, double w=1)
TCircleFitter(const std::string &name)
Constructor.
virtual int fit(TTrackBase &) const
virtual ~TCircleFitter()
Destructor.
A class to represent a circle in tracking.
HepPoint3D position(unsigned) const
returns left position. z is always zero.
Definition: TMDCWireHit.cxx:93
unsigned state(void) const
returns state.
const HepPoint3D & xyPosition(void) const
returns drift time
A class to fit a TTrackBase object.
void fitDone(TTrackBase &) const
sets the fitted flag. (Bad implementation)
Definition: TMFitter.cxx:24
A virtual class for a track class in tracking.
int t()
Definition: t.c:1