80 {
81 if ( _charge == -1 )
82 {
83
84
85
86 }
87 if ( _charge == 1 )
88 {
89
90
91
92
93 }
94
95
96
97 TrkExchangePar tt( _d0, _phi0, _omega, _z0, _tanl );
99 cout << "q d0 phi0 omega: " << _charge << " " << _d0 << " " << _phi0 << " " << _omega
100 << " " << _tanl << " " << _z0 << endl;
101 TrkHelixMaker helixfactory;
102 float chisum = 0.;
104
105 bool permitFlips = true;
106 bool lPickHits = true;
108 TrkHitList* trkHitList = newTrack->hits();
109 int digiId = 0;
110 std::vector<HoughRecHit>::iterator
iter = _recHitVec.begin();
111 for ( ;
iter != _recHitVec.end();
iter++, digiId++ )
112 {
113 if ( ( *iter ).getflag() != 0 ) continue;
114
115
116
117
118
119 const MdcDigi* aDigi = ( *iter ).digi();
120 MdcHit* hit = nullptr;
121
122 vector<MdcHit*>::const_iterator iter_digi = ( *vec_mdcHit ).begin();
123 for ( ; iter_digi != ( *vec_mdcHit ).end(); iter_digi++ )
124 {
125 if ( ( *iter_digi )->digi() == ( *iter ).digi() ) { hit = ( *iter_digi ); }
126 }
132
133 int newAmbig = 0;
134
135 MdcRecoHitOnTrack temp( *hit, newAmbig, _bunchT0 * 1.e9 );
136 MdcHitOnTrack* newhot = &temp;
137 double flight;
138 double z_flight;
139
140
141
142 flight = ( *iter ).getRet().second;
143 double distoTrack = ( *iter ).getDisToTrack();
144
145
147
148
149 int use_in3d = 1;
150
151 if ( hit->
driftTime( _bunchT0, 0 ) > 1000 ) use_in3d = 0;
152
153 if (
m_debug > 0 ) cout <<
"flt : " << flight << endl;
155 std::cout <<
" (" << layer <<
"," << wire <<
",rt " << hit->
rawTime() <<
",dt "
156 << hit->
driftTime( _bunchT0, 0 ) <<
") T0 "
159 <<
"dist: " << hit->
driftDist( _bunchT0, 0 ) <<
" disToTrk " << distoTrack
160 << " use?: " << use_in3d << endl;
161
162 if ( use_in3d == 0 ) continue;
164 }
165 if (
m_debug > 0 ) newTrack->printAll( std::cout );
166
167 TrkHitList* qhits = newTrack->hits();
168 TrkErrCode err = qhits->
fit();
169 const TrkFit* newFit = newTrack->fitResult();
170 int nActiveHit = newTrack->hots()->nActive();
171 int fit_stat = false;
172 double chi2 = -999.;
174 {
175
177 {
178 cout << " global 3d fit failed ";
179 if ( newFit ) cout <<
" nAct " << newFit->
nActive();
180 cout <<
"ERR1 failure =" << err.
failure() << endl;
181 fit_stat = 0;
182 }
183 }
184 else
185 {
186 TrkExchangePar par = newFit->
helix( 0. );
187 if (
abs( 1 / ( par.
omega() ) ) > 0.03 )
188 {
189 fit_stat = 1;
190 chi2 = newFit->
chisq();
191 }
192 else
193 {
194 fit_stat = 0;
195 chi2 = -999;
196 }
197
198 bool badQuality = false;
200 {
202 {
203 std::cout << __FILE__ << " " << __LINE__ << " drop track by chi2 " << chi2 << " > "
205 }
206 badQuality = 1;
207 }
209 {
211 {
212 std::cout << __FILE__ <<
" " << __LINE__ <<
" drop track by d0 " << par.
d0() <<
" > "
214 }
215 badQuality = 1;
216 }
218 {
220 {
221 std::cout << __FILE__ <<
" " << __LINE__ <<
" drop track by z0 " << par.
z0() <<
" > "
223 }
224 badQuality = 1;
225 }
227 {
229 {
230 std::cout << __FILE__ << " " << __LINE__ << " drop track by chi2/ndf"
233 }
234 badQuality = 1;
235 }
237 {
239 {
240 std::cout << __FILE__ << " " << __LINE__ << " drop track by nhit" << nActiveHit
242 }
243 badQuality = 1;
244 }
245
246 if ( badQuality ) fit_stat = 0;
247 }
248 if ( fit_stat != 1 )
249 {
250 delete newTrack;
252 }
253 if ( fit_stat == 1 )
254 {
256 {
257 cout << " global 3d fit success" << endl;
258 cout << __FILE__ << __LINE__ << "AFTER fit 3d " << endl;
259 newTrack->print( std::cout );
260 }
261 TrkExchangePar par = newFit->
helix( 0. );
264 _omega = par.
omega();
267
268 _circleR = _charge / par.
omega();
270 -1.;
271 _circleY = -1. *
cos( par.
phi0() ) * ( par.
d0() + 1 / par.
omega() ) * -1;
272 double pxy = fabs( _circleR / 333.567 );
273 double pz = pxy * par.
tanDip();
274 double pxyz = _charge * sqrt( pxy * pxy + pz * pz );
275 _pt = pxy;
276 _pz = pz;
277 _p = pxyz;
279 {
280 cout << " circle after globle 3d: "
281 << "(" << _circleX << "," << _circleY << "," << _circleR << ")" << endl;
282 cout << "pt_rec: " << _pt << endl;
283 cout << "pz_rec: " << _pz << endl;
284 cout << "p_rec: " << _p << endl;
285 }
286
287 int nfit3d = 0;
288 if (
m_debug > 0 ) cout <<
" hot list:" << endl;
290 int lay = ( (MdcHit*)( hotIter->
hit() ) )->layernumber();
291 int wir = ( (MdcHit*)( hotIter->
hit() ) )->wirenumber();
293 {
295 {
296 cout <<
"(" << ( (MdcHit*)( hotIter->
hit() ) )->layernumber() <<
","
297 << ( (MdcHit*)( hotIter->
hit() ) )->wirenumber() <<
":" << hotIter->
isActive()
298 << ") ";
299 }
300
301 if ( hotIter->
isActive() == 1 ) nfit3d++;
302 hotIter++;
303 }
304 _nfit = nfit3d;
305 }
306 _chi2_aver = chi2 / _nfit;
307
308
309
310 if (
m_debug > 0 ) cout <<
" in 3D fit number of Active hits : " << _nfit << endl;
311 return fit_stat;
312}
vector< TrkRecoTrk * > vectrk_for_clean
double sin(const BesAngle a)
double cos(const BesAngle a)
static double m_dropTrkDzCut
static double m_dropTrkNhitCut
static TrkContextEv * _context
static double m_dropTrkDrCut
static const IMdcCalibFunSvc * _mdcCalibFunSvc
static double m_dropTrkChi2NdfCut
static double m_dropTrkChi2Cut
static int m_qualityFactor
double driftTime(double tof, double z) const
void setCountPropTime(const bool count)
double driftDist(double, int, double, double, double) const
void setCalibSvc(const IMdcCalibFunSvc *calibSvc)
static int layer(const Identifier &id)
Values of different levels (failure returns 0).
static int wire(const Identifier &id)
virtual Identifier identify() const
unsigned int getChargeChannel() const
virtual double chisq() const =0
virtual int nActive() const =0
virtual TrkExchangePar helix(double fltL) const =0
TrkHitOnTrk * appendHot(const TrkHitOnTrk *theHot)
const TrkHotList & hotList() const
const TrkFundHit * hit() const
TrkHitOnTrkIter< TrkHotList::const_iterator_traits > hot_iterator
hot_iterator begin() const
bool setFlipAndDrop(TrkRecoTrk &, bool allowFlips, bool allowDrops) const
TrkRecoTrk * makeTrack(const TrkExchangePar &helix, const double chi2, const TrkContext &, double trackT0) const