147 {
148
149
150
151
152
153
154
155
156
157
158 TrkExchangePar tt( _d0, _phi0, _omega, 0, 0 );
160 cout << "q d0 phi0 omega: " << _charge << " " << _d0 << " " << _phi0 << " " << _omega
161 << endl;
163 float chisum = 0.;
165 bool permitFlips = true;
166 bool lPickHits = true;
167 circlefactory.
setFlipAndDrop( *newTrack, permitFlips, lPickHits );
168
169 TrkHitList* trkHitList = newTrack->hits();
170 int digiId = 0;
171 vector<MdcHit*> t_hitCol;
172 std::vector<HoughRecHit>::iterator
iter = _recHitVec.begin();
173 for ( ;
iter != _recHitVec.end();
iter++, digiId++ )
174 {
175 if ( ( *iter ).getflag() != 0 ) continue;
176
177
178 const MdcDigi* aDigi = ( *iter ).digi();
179
180
182
183
184 t_hitCol.push_back( hit );
188
189
192
193 int newAmbig = 0;
194
195 MdcRecoHitOnTrack temp( *hit, newAmbig, _bunchT0 * 1.e9 );
196 MdcHitOnTrack* newhot = &temp;
197 newhot->
setFltLen( ( *iter ).getRet().second );
198 double distoTrack = ( *iter ).getDisToTrack();
199
200
201 double ddCut = 1.0;
202 int use_in2d = 1;
203 if ( hit->
driftTime( _bunchT0, 0 ) > 1000 ) use_in2d = 0;
204 if ( hit->
driftDist( _bunchT0, 0 ) > ddCut ) use_in2d = 0;
205
207 std::cout <<
" (" << layer <<
"," << wire <<
",rt " << hit->
rawTime() <<
",dt "
211 <<
"dist: " << hit->
driftDist( _bunchT0, 0 ) <<
" disToTrk " << distoTrack
212 << " use?: " << use_in2d << endl;
213 if ( use_in2d == 0 ) continue;
215 }
216
217
218 TrkHitList* qhits = newTrack->hits();
219 TrkErrCode err = qhits->
fit();
220 const TrkFit* newFit = newTrack->fitResult();
221 int nActiveHit = newTrack->hots()->nActive();
222 int fit_stat = false;
223 double chi2 = -999.;
225 {
227 {
228 cout << " global 2d fit failed ";
229 if ( newFit ) cout <<
" nAct " << newFit->
nActive();
230 cout <<
"ERR1 failure =" << err.
failure() << endl;
231 fit_stat = 0;
232 }
233 }
234 else
235 {
236 TrkExchangePar par = newFit->
helix( 0. );
237 if (
abs( 1 / ( par.
omega() ) ) > 0.03 )
238 {
239 fit_stat = 1;
240 chi2 = newFit->
chisq();
241 if (
m_debug > 0 ) cout <<
"chi2 " << chi2 << endl;
242 }
243 else
244 {
245 fit_stat = 0;
246 chi2 = -999;
247 }
248
249 bool badQuality = false;
251 {
253 {
254 std::cout << __FILE__ << " " << __LINE__ << " drop track by chi2 " << chi2 << " > "
256 }
257 badQuality = 1;
258 }
260 {
262 {
263 std::cout << __FILE__ <<
" " << __LINE__ <<
" drop track by d0 " << par.
d0() <<
" > "
265 }
266 badQuality = 1;
267 }
269 {
271 {
272 std::cout << __FILE__ << " " << __LINE__ << " drop track by chi2/ndf"
275 }
276 badQuality = 1;
277 }
279 {
281 {
282 std::cout << __FILE__ << " " << __LINE__ << " drop track by nhit" << nActiveHit
284 }
285 badQuality = 1;
286 }
287 if ( badQuality ) fit_stat = 0;
288 }
289 if ( fit_stat == 1 )
290 {
292 {
293 cout << " global 2d fit success" << endl;
294 cout << __FILE__ << __LINE__ << "AFTER fit 2d " << endl;
295 newTrack->print( std::cout );
296 }
297 TrkExchangePar par = newFit->
helix( 0. );
298 double d0 = par.
d0();
299 double phi0 = par.
phi0();
300 double omega = par.
omega();
301 double r_temp = -1. / par.
omega();
302 double x_cirtemp =
sin( par.
phi0() ) * ( par.
d0() + 1 / par.
omega() ) *
303 -1.;
304 double y_cirtemp = -1. *
cos( par.
phi0() ) * ( par.
d0() + 1 / par.
omega() ) * -1;
306 {
307 cout << " circle after globle 2d: "
308 << "(" << x_cirtemp << "," << y_cirtemp << "," << r_temp << ")" << endl;
309 cout << "pt_rec: " << 1. / omega / 333.567 << endl;
310 }
311 _pt = 1. / omega / 333.567;
312 _circleX = x_cirtemp;
313 _circleY = y_cirtemp;
314 _circleR = _charge / omega;
317 _omega = par.
omega();
318
319 int nfit2d = 0;
320 if (
m_debug > 1 ) cout <<
" hot list:" << endl;
322 int lay = ( (MdcHit*)( hotIter->
hit() ) )->layernumber();
323 int wir = ( (MdcHit*)( hotIter->
hit() ) )->wirenumber();
324 int hittemp = lay * 1000 + wir;
326 {
328 {
329 cout <<
"(" << ( (MdcHit*)( hotIter->
hit() ) )->layernumber() <<
","
330 << ( (MdcHit*)( hotIter->
hit() ) )->wirenumber() <<
":" << hotIter->
isActive()
331 << ") ";
332 }
333 if ( hotIter->
isActive() == 1 ) nfit2d++;
334 hotIter++;
335 }
336 _nfit = nfit2d;
337 }
338 _chi2_aver2D = chi2 / _nfit;
339
340 for ( int i = 0; i < t_hitCol.size(); i++ ) { delete t_hitCol[i]; }
341 delete newTrack;
342
343 if (
m_debug > 0 ) cout <<
" in 2D fit number of Active hits : " << _nfit << endl;
344 return fit_stat;
345}
double sin(const BesAngle a)
double cos(const BesAngle a)
TrkSimpleMaker< TrkCircleRep > TrkCircleMaker
static double m_dropTrkChi2NdfCut
static TrkContextEv * _context
static int m_qualityFactor
static double m_dropTrkChi2Cut
static const IMdcCalibFunSvc * _mdcCalibFunSvc
static double m_dropTrkNhitCut
static double m_dropTrkDrCut
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