BOSS 7.0.1
BESIII Offline Software System
Loading...
Searching...
No Matches
TPerfectFinder.cxx
Go to the documentation of this file.
1//-----------------------------------------------------------------------------
2// $Id: TPerfectFinder.cxx,v 1.9 2010/03/31 09:58:59 liucy Exp $
3//-----------------------------------------------------------------------------
4// Filename : TPerfectFinder.cc
5// Section : Tracking
6// Owner : Yoshi Iwasaki
7// Email : [email protected]
8//-----------------------------------------------------------------------------
9// Description : A class to find tracks using MC info.
10// See http://bsunsrv1.kek.jp/~yiwasaki/tracking/
11//-----------------------------------------------------------------------------
12
13#include "TrkReco/TPerfectFinder.h"
14#include "TrkReco/TMDCWireHitMC.h"
15#include "TrkReco/TTrackHEP.h"
16#include "TrkReco/TTrack.h"
17//#include "helix/Helix.h"
18//#include "TrkReco/Helix.h"
19#include "TrackUtil/Helix.h"
20
22 float maxSigma,
23 float maxSigmaStereo,
24 unsigned fittingFlag)
25: _perfectFitting(perfectFitting),
26 _builder("conformal builder",
27 maxSigma,
28 maxSigmaStereo,
29 0,
30 0,
31 0,
32 fittingFlag),
33 _fitter("helix fitter") {
34}
35
37}
38
39std::string
41 return "2.04";
42}
43
44void
45TPerfectFinder::dump(const std::string & msg, const std::string & pre) const {
46 std::cout << pre;
48}
49
50int
52 const AList<TMDCWireHit> & stereoHits,
53 AList<TTrack> & tracks,
54 AList<TTrack> & tracks2D) {
55
56 //...Preparations...
57 static const HepPoint3D dummy(0, 0, 0);
59 hits.append(axialHits);
60 hits.append(stereoHits);
61
62 //...Make a list of HEP track...
64 const unsigned nHits = hits.length();
65 for (unsigned i = 0; i < nHits; i++) {
66 const TMDCWireHitMC * const mc = hits[i]->mc();
67 if (! mc) continue;
68 const TTrackHEP * const hep = mc->hep();
69
70 if (! hep) continue;
71 heps.append(hep);
72 }
73 heps.purge();
74
75 //...Create tracks...
76 const AList<TMDCWireHitMC> & mcHits = TMDC::getTMDC()->hitsMC();
77 const unsigned nHitsMC = mcHits.length();
78 const unsigned nHeps = heps.length();
79 for (unsigned i = 0; i < nHeps; i++) {
80 const TTrackHEP & hep = * heps[i];
81 const float chg = charge(hep.pType());
82 AList<TMLink> hepLinks;
83 HepPoint3D posIn, posOut;
84 HepVector3D momIn, momOut;
85 float rMin = 99999;
86 float rMax = 0.;
87 TMLink * linkIn;
88 unsigned lastLayer = 0;
89 for (unsigned j = 0; j < mcHits.length(); j++) {
90 const TMDCWireHitMC * const mc = mcHits[j];
91 if (! mc) continue;
92 if (! mc->hit()) continue;
93 if (& hep != mc->hep()) continue;
94 if (! hits.hasMember(mc->hit())) continue;
95
96 //...Remove hits by curl back...(assuming order of mc hits)
97 if (mc->wire()->layerId() < lastLayer) break;
98 lastLayer = mc->wire()->layerId();
99 HepPoint3D ent = mc->entrance();
100 HepVector3D dir = mc->direction();
101 ent.setZ(0.);
102 dir.setZ(0.);
103 if ((ent.unit()).dot(dir.unit()) < 0.5) continue;
104
105 //...Hit...
106 TMLink * l = new TMLink(0, mc->hit(), dummy);
107 l->leftRight(mc->leftRight());
108 hepLinks.append(l);
109 _links.append(l);
110
111 //...Check r to get MC mom...
112 const float r = ent.mag();
113 if (r < rMin) {
114 posIn = mc->entrance();
115 momIn = mc->momentum();
116 rMin = r;
117 linkIn = l;
118 }
119 if (r > rMax) {
120 posOut = mc->entrance();
121 momOut = mc->momentum();
122 rMax = r;
123 }
124 }
125 if (_links.length() == 0) continue;
126
127 //...Do perfect fitting...
128 TTrack * t = 0;
129// Helix h(posIn, momIn, chg);
130 Helix h(posOut, momOut, chg);
131// h.pivot(posIn);
132 h.pivot(linkIn->wire()->xyPosition());
133 t = new TTrack(h);
134 t->append(hepLinks);
135 t->assign(0);
136
137// Helix hX(posOut, momOut, chg);
138
139// std::cout << " gen@cdc i = " << h.a() << std::endl;
140// std::cout << " pivot = " << h.pivot() << std::endl;
141// std::cout << " mom = " << h.momentum() << std::endl;
142// std::cout << " gen@cdc o = " << hX.a() << std::endl;
143// std::cout << " pivot = " << hX.pivot() << std::endl;
144// std::cout << " mom = " << hX.momentum() << std::endl;
145// std::cout << " momOut = " << momOut << std::endl;
146// std::cout << " posOut = " << posOut << std::endl;
147// std::cout << " ptOut = " << momOut.perp() << std::endl;
148// std::cout << " costhOut = " << momOut.z() / momOut.mag();
149// std::cout << std::endl;
150
151 if (_perfectFitting == 0) {
152 std::cout << "special test in perfect finder" << std::endl;
153 AList<TMLink> tmp;
154 for (unsigned i = 0; i < t->nLinks(); i++) {
155 bool rem = false;
156 if (t->links()[i]->wire()->name() == "0-56")
157 rem = true;
158 else if (t->links()[i]->wire()->name() == "2-56")
159 rem = true;
160 else if (t->links()[i]->wire()->name() == "5-57")
161 rem = true;
162 else if (t->links()[i]->wire()->name() == "6=68")
163 rem = true;
164 else if (t->links()[i]->wire()->name() == "7=69")
165 rem = true;
166 else if (t->links()[i]->wire()->name() == "8=68")
167 rem = true;
168 else if (t->links()[i]->wire()->name() == "10-85")
169 rem = true;
170 else if (t->links()[i]->wire()->name() == "20-126")
171 rem = true;
172 else if (t->links()[i]->wire()->name() == "39-210")
173 rem = true;
174 else if (t->links()[i]->wire()->name() == "41=221")
175 rem = true;
176 else if (t->links()[i]->wire()->name() == "43=221")
177 rem = true;
178 else if (t->links()[i]->wire()->name() == "46-251")
179 rem = true;
180 else if (t->links()[i]->wire()->name() == "48-251")
181 rem = true;
182 if (rem) {
183 std::cout << t->links()[i]->wire()->name() << " removed" << std::endl;
184 tmp.append(* t->links()[i]);
185 }
186 }
187 t->remove(tmp);
188 t->dump("detail","@lastHit");
189 Helix & h = (Helix &) t->helix();
190 h.pivot(HepVector3D(0., 0., 0.));
191 t->dump("detail","@origin ");
192 _fitter.fit(* t);
193 t->dump("detail","fitted ");
194 static const HepVector3D p0(1.226, -1.025, 0.120);
195 std::cout << "Pdif mag=" << (t->p() - p0).mag() << std::endl;
196 }
197
198 tracks.append(t);
199 }
200 return 0;
201}
202
203void
205 HepAListDeleteAll(_links);
206}
207
208float
209TPerfectFinder::charge(int pType) const {
210 float chg;
211
212 if (pType == 11) chg = -1;
213 else if (pType == -11) chg = 1;
214 else if (pType == 13) chg = -1;
215 else if (pType == -13) chg = 1;
216 else if (pType == 211) chg = 1;
217 else if (pType == -211) chg = -1;
218 else if (pType == 321) chg = 1;
219 else if (pType == -321) chg = -1;
220 else if (pType == 2212) chg = 1;
221 else if (pType == -2212) chg = -1;
222 else {
223 std::cout << "TPerfectFinder !!! charge of particle type=";
224 std::cout << pType << " is unknown" << std::endl;
225 }
226
227 return chg;
228}
HepGeom::Vector3D< double > HepVector3D
const HepPoint3D & pivot(void) const
returns pivot position.
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 to represent a MC wire hit in MDC.
const Hep3Vector & momentum(void) const
returns momentum vector at the entrance.
const TTrackHEP *const hep(void) const
returns a pointer to a GEN_HEPEVT.
const HepVector3D & direction(void) const
returns vector from entrance to exit point.
const TMDCWire *const wire(void) const
returns a pointer to a TMDCWire.
const HepPoint3D & entrance(void) const
returns an entrance point.
const TMDCWireHit *const hit(void) const
returns a pointer to a TMDCWireHit.
int leftRight(void) const
returns left or right.
unsigned layerId(void) const
returns layer id.
const HepPoint3D & xyPosition(void) const
returns middle position of a wire. z componet is 0.
static TMDC * getTMDC(void)
Definition: TMDC.cxx:95
const AList< TMDCWireHitMC > & hitsMC(void) const
returns a list of TMDCWireHitMC. 'updateMC()' must be called before calling this function.
std::string version(void) const
returns version.
virtual ~TPerfectFinder()
Destructor.
void clear(void)
clear internal information.
TPerfectFinder(int perfectFitting, float maxSigma, float maxSigmaStereo, unsigned fittingFlag)
Constructor.
void dump(const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
dumps debug information.
int doit(const AList< TMDCWireHit > &axialHits, const AList< TMDCWireHit > &stereoHits, AList< TTrack > &tracks, AList< TTrack > &tracks2D)
finds tracks.
A class to represent a GEN_HEPEVT particle in tracking.
int pType(void) const
returns particle type.
A class to represent a track in tracking.
int t()
Definition: t.c:1