BOSS 8.0.0
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 : yoshihito.iwasaki@kek.jp
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/TTrack.h"
16#include "TrkReco/TTrackHEP.h"
17// #include "helix/Helix.h"
18// #include "TrkReco/Helix.h"
19#include "TrackUtil/Helix.h"
20
21TPerfectFinder::TPerfectFinder( int perfectFitting, float maxSigma, float maxSigmaStereo,
22 unsigned fittingFlag )
23 : _perfectFitting( perfectFitting )
24 , _builder( "conformal builder", maxSigma, maxSigmaStereo, 0, 0, 0, fittingFlag )
25 , _fitter( "helix fitter" ) {}
26
28
29std::string TPerfectFinder::version( void ) const { return "2.04"; }
30
31void TPerfectFinder::dump( const std::string& msg, const std::string& pre ) const {
32 std::cout << pre;
33 TFinderBase::dump( msg );
34}
35
37 const AList<TMDCWireHit>& stereoHits, AList<TTrack>& tracks,
38 AList<TTrack>& tracks2D ) {
39
40 //...Preparations...
41 static const HepPoint3D dummy( 0, 0, 0 );
43 hits.append( axialHits );
44 hits.append( stereoHits );
45
46 //...Make a list of HEP track...
48 const unsigned nHits = hits.length();
49 for ( unsigned i = 0; i < nHits; i++ )
50 {
51 const TMDCWireHitMC* const mc = hits[i]->mc();
52 if ( !mc ) continue;
53 const TTrackHEP* const hep = mc->hep();
54
55 if ( !hep ) continue;
56 heps.append( hep );
57 }
58 heps.purge();
59
60 //...Create tracks...
61 const AList<TMDCWireHitMC>& mcHits = TMDC::getTMDC()->hitsMC();
62 const unsigned nHitsMC = mcHits.length();
63 const unsigned nHeps = heps.length();
64 for ( unsigned i = 0; i < nHeps; i++ )
65 {
66 const TTrackHEP& hep = *heps[i];
67 const float chg = charge( hep.pType() );
68 AList<TMLink> hepLinks;
69 HepPoint3D posIn, posOut;
70 HepVector3D momIn, momOut;
71 float rMin = 99999;
72 float rMax = 0.;
73 TMLink* linkIn = nullptr; // add initialize 25-05-15
74 unsigned lastLayer = 0;
75 for ( unsigned j = 0; j < mcHits.length(); j++ )
76 {
77 const TMDCWireHitMC* const mc = mcHits[j];
78 if ( !mc ) continue;
79 if ( !mc->hit() ) continue;
80 if ( &hep != mc->hep() ) continue;
81 if ( !hits.hasMember( mc->hit() ) ) continue;
82
83 //...Remove hits by curl back...(assuming order of mc hits)
84 if ( mc->wire()->layerId() < lastLayer ) break;
85 lastLayer = mc->wire()->layerId();
86 HepPoint3D ent = mc->entrance();
87 HepVector3D dir = mc->direction();
88 ent.setZ( 0. );
89 dir.setZ( 0. );
90 if ( ( ent.unit() ).dot( dir.unit() ) < 0.5 ) continue;
91
92 //...Hit...
93 TMLink* l = new TMLink( 0, mc->hit(), dummy );
94 l->leftRight( mc->leftRight() );
95 hepLinks.append( l );
96 _links.append( l );
97
98 //...Check r to get MC mom...
99 const float r = ent.mag();
100 if ( r < rMin )
101 {
102 posIn = mc->entrance();
103 momIn = mc->momentum();
104 rMin = r;
105 linkIn = l;
106 }
107 if ( r > rMax )
108 {
109 posOut = mc->entrance();
110 momOut = mc->momentum();
111 rMax = r;
112 }
113 }
114 if ( _links.length() == 0 ) continue;
115
116 //...Do perfect fitting...
117 TTrack* t = 0;
118 // Helix h(posIn, momIn, chg);
119 Helix h( posOut, momOut, chg );
120 // h.pivot(posIn);
121 h.pivot( linkIn->wire()->xyPosition() );
122 t = new TTrack( h );
123 t->append( hepLinks );
124 t->assign( 0 );
125
126 // Helix hX(posOut, momOut, chg);
127
128 // std::cout << " gen@cdc i = " << h.a() << std::endl;
129 // std::cout << " pivot = " << h.pivot() << std::endl;
130 // std::cout << " mom = " << h.momentum() << std::endl;
131 // std::cout << " gen@cdc o = " << hX.a() << std::endl;
132 // std::cout << " pivot = " << hX.pivot() << std::endl;
133 // std::cout << " mom = " << hX.momentum() << std::endl;
134 // std::cout << " momOut = " << momOut << std::endl;
135 // std::cout << " posOut = " << posOut << std::endl;
136 // std::cout << " ptOut = " << momOut.perp() << std::endl;
137 // std::cout << " costhOut = " << momOut.z() / momOut.mag();
138 // std::cout << std::endl;
139
140 if ( _perfectFitting == 0 )
141 {
142 std::cout << "special test in perfect finder" << std::endl;
143 AList<TMLink> tmp;
144 for ( unsigned i = 0; i < t->nLinks(); i++ )
145 {
146 bool rem = false;
147 if ( t->links()[i]->wire()->name() == "0-56" ) rem = true;
148 else if ( t->links()[i]->wire()->name() == "2-56" ) rem = true;
149 else if ( t->links()[i]->wire()->name() == "5-57" ) rem = true;
150 else if ( t->links()[i]->wire()->name() == "6=68" ) rem = true;
151 else if ( t->links()[i]->wire()->name() == "7=69" ) rem = true;
152 else if ( t->links()[i]->wire()->name() == "8=68" ) rem = true;
153 else if ( t->links()[i]->wire()->name() == "10-85" ) rem = true;
154 else if ( t->links()[i]->wire()->name() == "20-126" ) rem = true;
155 else if ( t->links()[i]->wire()->name() == "39-210" ) rem = true;
156 else if ( t->links()[i]->wire()->name() == "41=221" ) rem = true;
157 else if ( t->links()[i]->wire()->name() == "43=221" ) rem = true;
158 else if ( t->links()[i]->wire()->name() == "46-251" ) rem = true;
159 else if ( t->links()[i]->wire()->name() == "48-251" ) rem = true;
160 if ( rem )
161 {
162 std::cout << t->links()[i]->wire()->name() << " removed" << std::endl;
163 tmp.append( *t->links()[i] );
164 }
165 }
166 t->remove( tmp );
167 t->dump( "detail", "@lastHit" );
168 Helix& h = (Helix&)t->helix();
169 h.pivot( HepVector3D( 0., 0., 0. ) );
170 t->dump( "detail", "@origin " );
171 _fitter.fit( *t );
172 t->dump( "detail", "fitted " );
173 static const HepVector3D p0( 1.226, -1.025, 0.120 );
174 std::cout << "Pdif mag=" << ( t->p() - p0 ).mag() << std::endl;
175 }
176
177 tracks.append( t );
178 }
179 return 0;
180}
181
182void TPerfectFinder::clear( void ) { HepAListDeleteAll( _links ); }
183
184float TPerfectFinder::charge( int pType ) const {
185 float chg = -1;// add initialize 25-05-15
186
187 if ( pType == 11 ) chg = -1;
188 else if ( pType == -11 ) chg = 1;
189 else if ( pType == 13 ) chg = -1;
190 else if ( pType == -13 ) chg = 1;
191 else if ( pType == 211 ) chg = 1;
192 else if ( pType == -211 ) chg = -1;
193 else if ( pType == 321 ) chg = 1;
194 else if ( pType == -321 ) chg = -1;
195 else if ( pType == 2212 ) chg = 1;
196 else if ( pType == -2212 ) chg = -1;
197 else
198 {
199 std::cout << "TPerfectFinder !!! charge of particle type=";
200 std::cout << pType << " is unknown" << std::endl;
201 }
202
203 return chg;
204}
HepGeom::Vector3D< double > HepVector3D
HepGeom::Point3D< double > HepPoint3D
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.
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.
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:84
const AList< TMDCWireHitMC > & hitsMC(void) const
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.
bool perfectFitting(bool)
gets perfect momentum from MC info.
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