190 {
191#if (DEBUG_CURL_DUMP+DEBUG_CURL_GNUPLOT+DEBUG_CURL_MC)
192 Belle_event_Manager &evtMgr = Belle_event_Manager::get_manager();
193 debugMcFlag = 1;
194 if(evtMgr.count() != 0 &&
195 evtMgr[0].ExpMC() != 2)debugMcFlag = 0;
196#endif
197
199 unsigned nList = list.length();
200
201
202 for(
unsigned i = 0, size = track.
links().length(); i < size; ++i){
203 unsigned superID = (track.
links())[i]->wire()->superLayerId();
204 if(superID == 0 || superID == 1 || superID == 5 ||
205 superID == 6 || superID == 7 || superID == 8 ){
206 int ok = 1;
207 for (unsigned j = 0; j < nList; ++j) {
209 if(l->
hit()->
wire()->
id() == (track.
links())[i]->hit()->wire()->id()){
210 ok = 0; break;
211 }
212 }
213 if(ok == 1)list.append(((track.
links())[i]));
214 }
215
216 (track.
links())[i]->leftRight(2);
217 }
218 for(unsigned i = 0, size = list.length(); i < size; ++i){
219 track.
_links.remove(list[i]);
220
221 list[i]->leftRight(2);
222 }
223
224 if(list.length() < 2 ||
225 list.length()+track.
nLinks() < 5)
return NULL;
226#if DEBUG_CURL_DUMP
227 unsigned debug_stereo_counter1 = 0;
228 for(
unsigned i=0;i<track.
links().length();++i){
229 unsigned superID = (track.
links())[i]->hit()->wire()->superLayerId();
230 if(superID == 0 || superID == 1 ||
231 superID == 5 || superID == 6 ||
232 superID == 7 || superID == 8 )++debug_stereo_counter1;
233 }
234 std::cout << "(TBuilderCurl)Fitted Track:";
235 std::cout <<
", A# = " << track.
links().length()-debug_stereo_counter1;
236 std::cout << ", S# = " << debug_stereo_counter1 << "(==0)";
237 std::cout <<
", A+S# = " << track.
links().length();
238 std::cout << ", Cand Stereo Wires # = " << list.length() << std::endl;
239 double debugChg = -1.;
240 if(track.
charge() > 0.)debugChg = 1.;
241 if(debugChg > 0.)std::cout << "(TBuilderCurl) Positive Track" << std::endl;
242 else std::cout << "(TBuilderCurl) Negative Track" << std::endl;
243#endif
244
245
246 double xc2D;
247 double yc2D;
248 double r2D;
250 bool err2D = fitWDD(xc2D,yc2D,r2D,tmpAxialList);
251
252
253
254
255
256
257 setArcZ(track,list);
259 for(unsigned i = 0, size = list.length(); i < size; ++i){
260 if(list[i]->arcZ(0).
x() == -999. && list[i]->arcZ(1).
x() == -999.)removeList.append(list[i]);
261 }
262 list.remove(removeList);
263 if(list.length() < 2 ||
264 list.length()+track.
nLinks() < 5){
265#if DEBUG_CURL_DUMP
266 std::cout << "(TBuilderCurl) Fail...few wires which can be set Arc-Z # = "
267 << list.length() << std::endl;
268#endif
269 return NULL;
270 }
271#if DEBUG_CURL_DUMP
272 std::cout << "(TBuilderCurl) Cand Stereo Wires which can be set Arc-Z # = "
273 << list.length() << std::endl;
274 plotArcZ(list,0.,0.,0);
275#endif
276
277#if 0
278
280 for(unsigned i = 0, size = list.length(); i < size; ++i){
281 layer[list[i]->wire()->layer()->axialStereoLayerId()].append(*list[i]);
282 }
283
284#if DEBUG_CURL_DUMP
285 for(int i=0;i<18;++i){
287 std::cout << "(TBuilderCurl) Cand Stereo Wires which can be set Arc-Z # = "
288 << layer[i].length()
289 << " on " << i << " Layer." << std::endl;
290 }
291#endif
292#endif
293
294
297 double minChi2 = 9999.;
298 double goodA = 9999.;
299 double goodB = 9999.;
300 makeLine(track, list, allStereoList, goodL,
301 minChi2, goodA, goodB, goodP);
302 HepAListDeleteAll(goodP);
303
304#if DEBUG_CURL_DUMP
305 std::cout << "(TBuilderCurl) a = " << goodA << ", b = " << goodB
306 << " (after makeLine-function)" << std::endl;
307#endif
308
309
312 if(rfitter.fit(newLine0) != 0){
313#if DEBUG_CURL_DUMP
314 std::cout << "(TBuilderCurl) Fail...linefitting...fail." << std::endl;
315#endif
316 return NULL;
317 }
318
319#if DEBUG_CURL_DUMP
320 std::cout << "(TBuilderCurl) a = " << newLine0.a() << ", b = " << newLine0.b()
321 << " (after robustline-fit)" << std::endl;
322#endif
323
324
325 unsigned nGoodL = goodL.length();
326 list.remove(goodL);
329 if(fabs(newLine0.b()) < 10.){
330 appendPoints(list, goodL2,
332 }else{
333 appendPoints(list, goodL2,
335 }
336 }else{
337
338 appendPoints(list, goodL2,
340 }
341 goodL.append(goodL2);
343
344
345 if(rfitter.fit(newLine) != 0){
346#if DEBUG_CURL_DUMP
347 std::cout << "(TBuilderCurl) Fail...appending and re-fitting...fail." << std::endl;
348#endif
349 return NULL;
350 }
351
352#if DEBUG_CURL_DUMP
353 std::cout << "(TBuilderCurl) a = " << newLine.a() << ", b = " << newLine.b()
354 << " (after last-append + re-robustline-fit)" << std::endl;
355#endif
356
358 track.TTrackBase::append(good);
359 if(!check(track)){
360#if DEBUG_CURL_DUMP
361 std::cout << "(TBuilderCurl) Fail...checking wire numbers...fail." << std::endl;
362#endif
363 return NULL;
364 }
365
366
368 if(err2D){
369 double tmpA[3];
370 double tmpQ = track.
charge() > 0. ? 1. : -1.;
371 tmpA[1] = fmod(atan2(tmpQ * yc2D,
372 tmpQ * xc2D)
375
376
377 tmpA[2] = tmpQ*(333.564095/(-1000*(m_pmgnIMF->
getReferField())))/r2D;
378
379 tmpA[0] = xc2D/
cos(tmpA[1]) - tmpQ*r2D;
380
381
382
383
384 a[0] = tmpA[0];
385 a[1] = tmpA[1];
386 a[2] = tmpA[2];
387 }
388 a[3] = newLine.b();
389 a[4] = newLine.a();
390
391
392
393
394
395
397 if(fabs(a[3]) > 10. && fabs(goodB) < 10.){
398
399 a[3] = goodB;
400 a[4] = goodA;
401 }
402 }else{
403 if(fabs(a[3]) > 50. && fabs(goodB) < 50.){
404 a[3] = goodB;
405 a[4] = goodA;
406 track.TTrackBase::remove(goodL2);
407 }
408 }
409
411
412#if DEBUG_CURL_DUMP
413 std::cout << "(TBuilderCurl) Created Line: y = " << newLine.a()
414 << " * x + " << newLine.b()
415 << ", size = " << good.length() << std::endl;
416 plotArcZ(
const_cast< AList<TMLink>&
>(good), newLine.a(), newLine.b(), 0);
417#endif
418
419
420
421
422
423
424#if 1
425
426
427
428
429
433#endif
434
435
437 int err = _fitter.
fit(track);
438 if (err < 0){
439#if DEBUG_CURL_DUMP
440 std::cout << "(TBuilderCurl) Fail fitting(0)...error code = " << err << std::endl;
441#endif
442 return NULL;
443 }
else if ( fabs(track.
helix().
a()[3]) > fabs(a[3]) &&
444 (fabs(track.
helix().
a()[3]) > 50. ||
445 fabs(track.
helix().
a()[2]) > 100. ||
446 fabs(track.
helix().
a()[2]) < 0.1) ){
447
448
453
454
455
457
458 }else{
459 return NULL;
460 }
461 }
462
463
464
465
466
467
469 if (!check(track)){
470#if DEBUG_CURL_DUMP
471 std::cout << "(TBuilderCurl) Fail checking(1)..." << std::endl;
472#endif
473 return NULL;
474 }
475 err = _fitter.
fit(track);
476 if (err < 0){
477#if DEBUG_CURL_DUMP
478 std::cout << "(TBuilderCurl) Fail fitting(1)...error code = " << err << std::endl;
479#endif
480 return NULL;
481 }
483 if (!check(track)){
484#if DEBUG_CURL_DUMP
485 std::cout << "(TBuilderCurl) Fail checking(2)..." << std::endl;
486#endif
487 return NULL;
488 }
489 err = _fitter.
fit(track);
490 if (err < 0){
491#if DEBUG_CURL_DUMP
492 std::cout << "(TBuilderCurl) Fail fitting(2)...error code = " << err << std::endl;
493#endif
494 return NULL;
495 }
497 if (!check(track)){
498#if DEBUG_CURL_DUMP
499 std::cout << "(TBuilderCurl) Fail checking(3)..." << std::endl;
500#endif
501 return NULL;
502 }
503 err = _fitter.
fit(track);
504 if (err < 0){
505#if DEBUG_CURL_DUMP
506 std::cout << "(TBuilderCurl) Fail fitting(3)...error code = " << err << std::endl;
507#endif
508 return NULL;
509 }
510
511#if 0
513 if(track.
links()[i]->pull() > 36.){
514 std::cout << track.
links()[i]->wire()->id()
515 <<
" :+: " << track.
links()[i]->pull() << std::endl;
516 }
518 std::cout << "Not Valid For Fit!" << std::endl;
519
520
521 }
522#endif
524 if (!check(track)){
525#if DEBUG_CURL_DUMP
526 std::cout << "(TBuilderCurl) Fail checking(4)..." << std::endl;
527#endif
528 return NULL;
529 }
530 err = _fitter.
fit(track);
531 if (err < 0){
532#if DEBUG_CURL_DUMP
533 std::cout << "(TBuilderCurl) Fail fitting(4)...error code = " << err << std::endl;
534#endif
535 return NULL;
536 }
537
538#if 0
540 if(track.
links()[i]->pull() > 36.){
541 std::cout << track.
links()[i]->wire()->id()
542 <<
" :*: " << track.
links()[i]->pull() << std::endl;
543 }
545 std::cout << "Not Valid For Fit!" << std::endl;
546
547
548 }
549#endif
550
551
552
553
554
555
556
558#if DEBUG_CURL_DUMP
559 std::cout << "(TBuilderCurl) Success fitting, but pre-selection...fail." << std::endl;
560#endif
561 return NULL;
562 }
564 track.
pt() < 0.005 ||
566#if DEBUG_CURL_DUMP
567 std::cout << "(TBuilderCurl) Success fitting, but selection...fail." << std::endl;
568 std::cout <<
"(TBuilderCurl) impact = " << track.
impact() << std::endl;
569 std::cout <<
"(TBuilderCurl) pt = " << track.
pt() << std::endl;
570 std::cout <<
"(TBuilderCurl) pz = " << track.
pz() << std::endl;
571 std::cout <<
"(TBuilderCurl) dz = " << track.
helix().
a()[3] << std::endl;
572#endif
573 return NULL;
574 }
575
576
578 fabs(a[3]) < fabs(track.
helix().
a()[3])){
580 }
581#if DEBUG_CURL_DUMP
582 std::cout << "(TBuilderCurl) Success Build Stereo!!!" << std::endl;
583#endif
584 return & track;
585}
double cos(const BesAngle a)
#define WireHitInvalidForFit
const HepVector & a(void) const
returns helix parameters.
virtual double getReferField()=0
double SELECTOR_STRANGE_PZ
double SELECTOR_MAX_IMPACT
double Z_DIFF_FOR_LAST_ATTEND
double SELECTOR_REPLACE_DZ
double SELECTOR_MAX_SIGMA
int fit(TTrackBase &) const
const TMDCWire *const wire(void) const
returns a pointer to a TMDCWire.
unsigned id(void) const
returns id.
A class to represent a track in tracking.
A class to relate TMDCWireHit and TTrack objects.
const TMDCWireHit * hit(void) const
returns a pointer to a hit.
A class to fit a TTrackBase object to a line.
virtual void refine(AList< TMLink > &list, double maxSigma)
removes bad points by pull. The bad points are removed from the track, and are returned in 'list'.
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.
unsigned nLinks(unsigned mask=0) const
returns # of masked TMLinks assigned to this track object.
const Helix & helix(void) const
returns helix parameter.
double impact(void) const
returns signed impact parameter to the origin.
double pt(void) const
returns Pt.
double pz(void) const
returns Pz.
double charge(void) const
returns charge.