CGEM BOSS 6.6.5.g
BESIII Offline Software System
Loading...
Searching...
No Matches
TFastFinder.cxx
Go to the documentation of this file.
1//-----------------------------------------------------------------------------
2// $Id: TFastFinder.cxx,v 1.7 2010/03/31 09:58:59 liucy Exp $
3//-----------------------------------------------------------------------------
4// Filename : TFastFinder.cc
5// Section : Tracking
6// Owner : Yoshi Iwasaki
7// Email : [email protected]
8//-----------------------------------------------------------------------------
9// Description : A class to find tracks with the conformal method.
10// See http://bsunsrv1.kek.jp/~yiwasaki/tracking/
11//-----------------------------------------------------------------------------
12
13#include "TrkReco/TFastFinder.h"
15#include "TrkReco/TMLink.h"
16#include "TrkReco/THistogram.h"
17#include "TrkReco/TMDCUtil.h"
18#include "TrkReco/TTrack.h"
19
20TFastFinder::TFastFinder() : _builder("fast find builder", 30) {
21 _selector.nLinks(4);
22 _selector.nSuperLayers(2);
23 _selector.minPt(0.05);
24 _selector.maxImpact(100.);
25 _selector.maxSigma(30.);
26 _selector.nLinksStereo(3);
27 _selector.maxDistance(30.);
28 _builder.trackSelector(_selector);
29}
30
32}
33
34std::string
36 return "0.00";
37}
38
39void
40TFastFinder::dump(const std::string & msg, const std::string & pre) const {
41 std::cout << pre;
43}
44
45void
47 _axialHits.removeAll();
48 _stereoHits.removeAll();
49 HepAListDeleteAll(_axialLinks);
50 HepAListDeleteAll(_stereoLinks);
51}
52
53int
55 const AList<TMDCWireHit> & stereoHits,
56 AList<TTrack> & tracks) {
57
58 //...Select good hits...
59 selectHits2(axialHits, stereoHits);
60
61 //...Conformal transformation with IP constraint...
63 _axialHits,
64 _axialLinks);
66 _stereoHits,
67 _stereoLinks);
68
69 //...Make a histogram...
70 THistogram hist(288);
71 hist.fillX(_axialLinks);
72 AList<TSegment0> clusters = hist.clusters0();
73
74 //...Cluster loop...
75 unsigned n = clusters.length();
76 for (unsigned i = 0; i < n; i++) {
77
78 //...2D track...
79 TTrack * t = _builder.buildRphi(clusters[i]->links());
80 if (t == NULL) continue;
81#ifdef TRKRECO_DEBUG_DETAIL
82 std::cout << "TFastFinder::doit ... 2D track found" << std::endl;
83#endif
84
85 //...Make it 3D...
86 TTrack * ts = t;
87 ts = _builder.buildStereo(* t,
88 findCloseHits(_stereoLinks,
89 * t));
90 if (ts == NULL) continue;
91#ifdef TRKRECO_DEBUG_DETAIL
92 std::cout << "TFastFinder::doit ... 3D track found" << std::endl;
93#endif
94
95 //...OK...
96 t->assign(WireHitFastFinder);
97 t->finder(TrackFastFinder);
98// t->assign(WireHitFastFinder, TrackFastFinder);
99 tracks.append(t);
100 _stereoLinks.remove(t->links());
101 }
102
103 //...Termination...
104 HepAListDeleteAll(clusters);
105 return 0;
106}
107
108void
109TFastFinder::selectHits(const AList<TMDCWireHit> & axialHits,
110 const AList<TMDCWireHit> & stereoHits) {
111 unsigned n = axialHits.length();
112 for (unsigned i = 0; i < n; i++) {
113 const TMDCWireHit & h = * axialHits[i];
114 if ((h.state() & WireHitIsolated) && (h.state() & WireHitContinuous))
115 _axialHits.append((TMDCWireHit &) h);
116 }
117 n = stereoHits.length();
118 for (unsigned i = 0; i < n; i++) {
119 const TMDCWireHit & h = * stereoHits[i];
120 if ((h.state() & WireHitIsolated) && (h.state() & WireHitContinuous))
121 _stereoHits.append((TMDCWireHit &) h);
122 }
123}
124
125void
126TFastFinder::selectHits2(const AList<TMDCWireHit> & axialHits,
127 const AList<TMDCWireHit> & stereoHits) {
128 selectSimpleSegments(axialHits, _axialHits);
129 selectSimpleSegments(stereoHits, _stereoHits);
130}
131
133TFastFinder::findCloseHits(const AList<TMLink> & links,
134 const TTrack & track) const {
135 //
136 // Coded by J.Suzuki
137 //
138 AList<TMLink> list;
139
140 //...Check condition...
141 if (track.links().length() == 0) {
142#ifdef TRKRECO_DEBUG_DETAIL
143 std::cout << "TConformalFinder::findCloseHits !!! ";
144 std::cout << " no links found in a track : This should not be happened";
145 std::cout << std::endl;
146#endif
147
148 return list;
149 }
150
151 //...Parameters...
152 // float dRcut[11] = {0, 3.5, 0., 5.5, 0., 6.5, 0., 7.5, 0., 9.5, 0.};
153 float dRcut[11] = {0., 4.3, 0., 6.5, 0., 7.5, 0., 8.0, 0., 9.5, 0.};
154
155 //...Select Stereo hits associated to the current r-phi curve...
156 double R0 = track.helix().curv();
157 double xInnerWire = track.links()[0]->wire()->xyPosition().x();
158 double yInnerWire = track.links()[0]->wire()->xyPosition().y();
159 unsigned nall = links.length();
160 for (unsigned j = 0; j < nall; j++) {
161 TMLink & t = * links[j];
162 const TMDCWire & w = * t.wire();
163 HepVector3D X = w.xyPosition() - track.helix().center();
164 double Rmag2 = X.mag2();
165 double DR = fabs(sqrt(Rmag2) - fabs(R0));
166 t.zStatus(-10);
167 t.zPair(0);
168 if (DR < dRcut[w.superLayerId()] &&
169 (xInnerWire*w.xyPosition().x()+yInnerWire*w.xyPosition().y())>0.){
170 list.append(t);
171 }
172 }
173
174 return list;
175}
176
177void
178TFastFinder::selectSimpleSegments(const AList<TMDCWireHit> & in,
179 AList<TMDCWireHit> & out) const {
180 AList<TMDCWireHit> hits = in;
181 while (hits.last()) {
182 TMDCWireHit & h = * hits.last();
183
184 //...Start clustering...
185 // AList<TMDCWireHit> & cluster = * new AList<TMDCWireHit>();
186 AList<TMDCWireHit> cluster;
187 AList<TMDCWireHit> toBeChecked;
188 bool ok = true;
189 toBeChecked.append(h);
190 while (toBeChecked.length()) {
191 TMDCWireHit & a = * toBeChecked.last();
192 toBeChecked.remove(a);
193 if (cluster.hasMember(a)) continue;
194
195 //...Check hit...
196 unsigned state = a.state();
197 if (! (state & WireHitIsolated)) ok = false;
198 if (! (state & WireHitContinuous)) ok = false;
199
200 //...Append...
201 cluster.append(a);
202
203 //...Neighbor hit...
204 unsigned ptn = (state & WireHitNeighborPattern) >> 12;
205 for (unsigned i = 0; i < 6; i++) {
206 if ((ptn >> i) % 2) {
207 const TMDCWireHit & b = * a.wire()->neighbor(i)->hit();
208 toBeChecked.append((TMDCWireHit &) b);
209 }
210 }
211 }
212
213 //...Check cluster size...
214 if ((cluster.length() < 4) || (cluster.length() > 8)) ok = false;
215
216 //...OK. Good hits...
217 if (ok) out.append(cluster);
218
219 //...Remove cluster...
220 hits.remove(cluster);
221
222 //...For debug...
223#ifdef TRKRECO_DEBUG_DETAIL
224 std::cout << "TFastFinder::selectSimpleSegment ... cluster : ok = ";
225 std::cout << ok << " : ";
226#endif
227 for (unsigned i = 0; i < cluster.length(); i++) {
228 TMDCWireHit & h = * cluster[i];
229#ifdef TRKRECO_DEBUG_DETAIL
230 std::cout << h.wire()->name() << ",";
231#endif
232 if (! ok) {
233 unsigned state = h.state();
234 if (state & WireHitIsolated) state ^= WireHitIsolated;
235 if (state & WireHitContinuous) state ^= WireHitContinuous;
236 h.state(state);
237 }
238 }
239#ifdef TRKRECO_DEBUG_DETAIL
240 std::cout << std::endl;
241#endif
242
243 remove:
244 hits.remove(h);
245 }
246}
const Int_t n
const HepPoint3D ORIGIN
Constants.
Definition: TMDCUtil.cxx:47
#define WireHitFastFinder
Definition: TMDCWireHit.h:56
#define WireHitContinuous
Definition: TMDCWireHit.h:36
#define WireHitNeighborPattern
Definition: TMDCWireHit.h:38
#define WireHitIsolated
Definition: TMDCWireHit.h:35
#define TrackFastFinder
Definition: TTrack.h:24
const HepPoint3D & center(void) const
returns position of helix center(z = 0.);
TTrack * buildRphi(const AList< TMLink > &) const
builds a r/phi track from TMLinks or from Segments.
Definition: TBuilder0.cxx:83
const TMSelector & trackSelector(void) const
returns a track selector.
Definition: TBuilder0.h:131
virtual TTrack * buildStereo(TTrack &track, const AList< TMLink > &) const
appends stereo hits to a track.
Definition: TBuilder0.cxx:535
static void conformalTransformationRphi(const HepPoint3D &center, const AList< TMDCWireHit > &hits, AList< TMLink > &links)
transforms hits into a conformal plane. 'center' is a center of the transformation....
std::string version(void) const
returns version.
Definition: TFastFinder.cxx:35
void dump(const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
dumps debug information.
Definition: TFastFinder.cxx:40
void clear(void)
clear internal information.
Definition: TFastFinder.cxx:46
int doit(const AList< TMDCWireHit > &axialHits, const AList< TMDCWireHit > &stereoHits, AList< TTrack > &tracks)
finds tracks.
Definition: TFastFinder.cxx:54
virtual ~TFastFinder()
Destructor.
Definition: TFastFinder.cxx:31
TFastFinder()
Constructor.
Definition: TFastFinder.cxx:20
virtual void dump(const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
dumps debug information.
Definition: TFinderBase.cxx:23
A class for a histogram used in tracking.
Definition: THistogram.h:34
AList< TSegment0 > clusters0(void) const
returns an AList<TSegment0> of clusters.
Definition: THistogram.cxx:162
void fillX(const AList< TMLink > &links)
fills with hits.
Definition: THistogram.cxx:76
unsigned state(void) const
returns state.
Definition: TMDCWireHit.h:230
const TMDCWire *const wire(void) const
returns a pointer to a TMDCWire.
Definition: TMDCWireHit.h:218
A class to represent a wire in MDC.
Definition: TMDCWire.h:55
const TMDCWireHit *const hit(void) const
returns a pointer to a TMDCWireHit.
Definition: TMDCWire.h:287
const HepPoint3D & xyPosition(void) const
returns middle position of a wire. z componet is 0.
Definition: TMDCWire.h:327
unsigned superLayerId(void) const
returns super layer id.
Definition: TMDCWire.h:225
const TMDCWire *const neighbor(unsigned) const
returns a pointer to a neighbor wire.
Definition: TMDCWire.cxx:95
std::string name(void) const
returns name.
Definition: TMDCWire.h:412
double maxDistance(void) const
returns max. distance required for stereo hits.
Definition: TMSelector.h:235
unsigned nSuperLayers(void) const
returns min. # of super layers required.
Definition: TMSelector.h:150
double maxImpact(void) const
returns max. impact(2D) required.
Definition: TMSelector.h:184
unsigned nLinks(void) const
returns min. # of hits(TMLinks) requried.
Definition: TMSelector.h:133
double maxSigma(void) const
returns max. sigma for each TMLink.
Definition: TMSelector.h:201
unsigned nLinksStereo(void) const
returns min. # of stereo hits(TMLinks) requried.
Definition: TMSelector.h:218
double minPt(void) const
returns min. pt required.
Definition: TMSelector.h:167
const AList< TMLink > & links(unsigned mask=0) const
returns a list of masked TMLinks assigned to this track. 'mask' will be applied if mask is not 0.
Definition: TTrackBase.cxx:297
A class to represent a track in tracking.
Definition: TTrack.h:129
const Helix & helix(void) const
returns helix parameter.
Definition: TTrack.h:477
int t()
Definition: t.c:1