13#ifdef TRKRECO_DEBUG_DETAIL
18#include "TrkReco/TBuilder0.h"
19#include "TrkReco/TCircle.h"
20#include "TrkReco/TLine0.h"
21#include "TrkReco/TMDC.h"
22#include "TrkReco/TMDCWire.h"
23#include "TrkReco/TMDCWireHit.h"
24#include "TrkReco/TMLink.h"
25#include "TrkReco/TTrack.h"
28# include "TrkReco/TWindow.h"
33 , _fitter(
"TBuilder0 Fitter" )
34 , _salvageLevel( 30. )
43 , _fitter(
"TBuilder0 Fitter" )
44 , _salvageLevel( salvageLevel )
52 float stereoChisq4,
float stereoMaxSigma,
unsigned corrections,
55 , _fitter(
"TBuilder0 Fitter" )
61 , _salvageLevel( salvageLevel ) {
73#ifdef TRKRECO_DEBUG_DETAIL
74 std::cout << _name <<
" ... building a rphi track" << std::endl;
75 std::cout << _name <<
" ... selecting good hits" << std::endl;
84#ifdef TRKRECO_DEBUG_DETAIL
85 std::cout << _name <<
" ... rejected by nLinks(";
86 std::cout << list.length() <<
") < ";
94 if ( cores.length() < 5 ) cores = list;
98#ifdef TRKRECO_DEBUG_DETAIL
99 std::cout << _name <<
" ... checking cores : cores=" << std::endl;
100 Dump( cores,
"detail" );
104#ifdef TRKRECO_DEBUG_DETAIL
105 std::cout <<
" super layer ptn=" << sLinks;
106 std::cout <<
",super layer used=" << sUsed << std::endl;
108 if ( sLinks != sUsed )
110#ifdef TRKRECO_DEBUG_DETAIL
111 std::cout << _name <<
" ... appending hits to cores" << std::endl;
113 unsigned diff = sLinks - sUsed;
114 unsigned asl[5] = { 2, 3, 4, 9, 10 };
115 for (
unsigned j = 0; j < 5; j++ )
119 if ( diff & ( 1 << asl[4 - j] ) )
121#ifdef TRKRECO_DEBUG_DETAIL
122 std::cout <<
" super layer " << ( 5 - j ) * 2 <<
"searching";
123 std::cout << std::endl;
129 for (
unsigned i = 0; i < links.length(); i++ )
131 double dist = links[i]->hit()->drift();
134#ifdef TRKRECO_DEBUG_DETAIL
135 std::cout <<
" " << links[i]->wire()->name();
136 std::cout <<
" appended (small dist)" << std::endl;
138 cores.append( links[i] );
149 cores.append( best );
150#ifdef TRKRECO_DEBUG_DETAIL
151 std::cout <<
" " << best->
wire()->
name();
152 std::cout <<
" appended (best)" << std::endl;
160 unsigned nCores = cores.length();
162 for (
unsigned i = 0; i < nCores; i++ )
169#ifdef TRKRECO_DEBUG_DETAIL
170 std::cout <<
" ... rejected by small number of super layers" << std::endl;
174 if (
NLayers( realCores ) < 5 )
176#ifdef TRKRECO_DEBUG_DETAIL
177 std::cout <<
" ... rejected by small number of layers" << std::endl;
183#ifdef TRKRECO_DEBUG_DETAIL
184 std::cout << _name <<
" ... making a circle : #cores=" << cores.length();
185 std::cout << std::endl;
188 hits.remove( cores );
198#ifdef TRKRECO_DEBUG_DETAIL
199 std::cout <<
" ... rejected by failure of the 1st fit : ";
200 std::cout <<
"err = " << err << std::endl;
209#ifdef TRKRECO_DEBUG_DETAIL
210 std::cout << _name <<
" ... making a track" << std::endl;
223 if ( err < 0 )
goto discard;
227 if ( err < 0 )
goto discard;
228#ifdef TRKRECO_DEBUG_DETAIL
229 t->dump(
"detail",
" 1st> " );
236#ifdef TRKRECO_DEBUG_DETAIL
237 std::cout << _name <<
" ... appending non-core hits" << std::endl;
241 if ( err < 0 )
goto discard;
245 if ( err < 0 )
goto discard;
249 if ( err < 0 )
goto discard;
251#ifdef TRKRECO_DEBUG_DETAIL
252 t->dump(
"detail",
" 2nd> " );
259#ifdef TRKRECO_DEBUG_DETAIL
271#ifdef TRKRECO_DEBUG_DETAIL
272 std::cout <<
" ... rejected by fitting failure : ";
273 std::cout <<
" err = " << err << std::endl;
286 for (
unsigned i = 0; i < list.length(); i++ )
288 unsigned state = list[i]->hit()->state();
291 bad.append( list[i] );
301#ifdef TRKRECO_DEBUG_DETAIL
302std::cout << _name <<
"(TBuilder0::selectHits) ... dump of candidates" << std::endl;
303Dump( list,
"detail" );
310#ifdef TRKRECO_DEBUG_DETAIL
311 std::cout << _name <<
"(stereo) ... dump of stereo candidate hits" << std::endl;
312 Dump( list,
"sort flag",
" " );
318#ifdef TRKRECO_DEBUG_DETAIL
319 std::cout << _name <<
"(stereo) ... rejected by nLinks(";
320 std::cout << list.length() <<
") < ";
327 unsigned n = list.length();
329 for (
unsigned i = 0; i <
n; i++ )
348#ifdef TRKRECO_DEBUG_DETAIL
349 std::cout << _name <<
"(stereo) ... dump of sz links" << std::endl;
350 Dump( forLine,
"sort flag",
" " );
356#ifdef TRKRECO_DEBUG_DETAIL
357 std::cout << _name <<
"(stereo) ... rejected by sz nLinks(";
358 std::cout << forLine.length() <<
") < ";
361 HepAListDeleteAll( forLine );
366 unsigned nLine = forLine.length();
372 if ( err < 0 ) err = line.
fit();
378#ifdef TRKRECO_DEBUG_DETAIL
379 std::cout << _name <<
"(stereo) ... linear fit failure. nLinks(";
380 std::cout << forLine.length() <<
")" << std::endl;
382 HepAListDeleteAll( forLine );
386#ifdef TRKRECO_DEBUG_DETAIL
387 std::cout << _name <<
"(stereo) ... dump of left-right" << std::endl;
392 for (
unsigned i = 0; i < nLine; i++ )
413 if ( ( tl == NULL ) && (
tr == NULL ) )
continue;
416 if ( tl == NULL ) best =
tr;
417 else if (
tr == NULL ) best = tl;
432#ifdef TRKRECO_DEBUG_DETAIL
434 std::cout <<
t->wire()->layerId() <<
"-";
435 std::cout <<
t->wire()->localId();
436 if ( tl != NULL ) std::cout <<
",left " << tl->
position() <<
"," << line.
distance( *tl );
437 if (
tr != NULL ) std::cout <<
",right " <<
tr->position() <<
"," << line.
distance( *
tr );
438 std::cout << std::endl;
441 best->
link(
t->link() );
442 forNewLine.append( best );
448#ifdef TRKRECO_DEBUG_DETAIL
449 std::cout << _name <<
"(stereo) ... rejected by lr nLinks(";
450 std::cout << forNewLine.length() <<
") < ";
453 HepAListDeleteAll( forLine );
454 HepAListDeleteAll( forNewLine );
459#ifdef TRKRECO_DEBUG_DETAIL
460 std::cout << _name <<
"(stereo) ... creating a new line" << std::endl;
462 unsigned nNewLine = forNewLine.length();
463 TLine0 newLine( forNewLine );
472 err = newLine.
fit2p();
473 if ( err < 0 ) err = newLine.
fit();
479#ifdef TRKRECO_DEBUG_DETAIL
480 std::cout << _name <<
"(stereo) ... 2nd linear fit failure. nLinks(";
481 std::cout << forNewLine.length() <<
")" << std::endl;
483 HepAListDeleteAll( forLine );
484 HepAListDeleteAll( forNewLine );
490 newLine.
refine( bad, 40. );
492 newLine.
refine( bad, 30. );
494 newLine.
refine( bad, 20. );
496 newLine.
refine( bad, 10. );
501 newLine.
refine( bad, 5. );
508 HepAListDeleteAll( forLine );
509 HepAListDeleteAll( forNewLine );
510#ifdef TRKRECO_DEBUG_DETAIL
511 std::cout <<
" appendStereo cut ... new line 2nd linear fit failure. ";
512 std::cout <<
"# of links = " <<
n <<
"," << nLine;
513 std::cout <<
"," << nNewLine << std::endl;
520 unsigned nn = good.length();
521 for (
unsigned i = 0; i < nn; i++ ) { track.
append( *good[i]->link() ); }
524 a[4] = track.
charge() * newLine.
a();
525 track._helix->
a( a );
539 HepAListDeleteAll( forLine );
540 HepAListDeleteAll( forNewLine );
545 HepAListDeleteAll( forLine );
546 HepAListDeleteAll( forNewLine );
551#ifdef TRKRECO_DEBUG_DETAIL
552 std::cout << _name <<
"(stereo) ... building in 3D" << std::endl;
553 std::cout <<
"... dump of stereo candidate hits" << std::endl;
554 Dump( list,
"sort flag",
" " );
560#ifdef TRKRECO_DEBUG_DETAIL
561 std::cout <<
"... rejected by nLinks(";
562 std::cout << list.length() <<
") < ";
570 if ( track.
helix().
curv() > 0. ) ichg = 1;
572 unsigned nlyr[18] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
573 unsigned llyr[18] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
580 unsigned n = list.length();
582 unsigned iforLine = 0;
583 for (
unsigned i = 0; i <
n; i++ )
589 TMLink* lnext = list[i + 1];
593 int LorR = consectiveHits( *l, *lnext, ichg );
627 if ( err1 == 0 && err2 == 0 )
636 l->
zPair( iforLine + 1 );
637 lnext->
zPair( iforLine );
639#ifdef TRKRECO_DEBUG_DETAIL
642 std::cout <<
" ... rejected because delta z > 1.5";
643 std::cout << std::endl;
647#ifdef TRKRECO_DEBUG_DETAIL
652 std::cout <<
" ... s-z calculation error with ";
653 std::cout << l->
wire()->
name() << std::endl;
657 std::cout <<
" ... s-z calculation error with ";
658 std::cout << lnext->
wire()->
name() << std::endl;
700 if ( err ) {
delete tl; }
705 forLine.append( tl );
721 if ( err ) {
delete tr; }
726 forLine.append(
tr );
737#ifdef TRKRECO_DEBUG_DETAIL
738 std::cout <<
"... dump of sz links" << std::endl;
739 Dump( forLine,
"sort flag",
" " );
740 for (
unsigned i = 0; i < 18; i++ )
741 { std::cout << i <<
" : " << nlyr[i] <<
", " << llyr[i] << std::endl; }
747#ifdef TRKRECO_DEBUG_DETAIL
748 std::cout <<
"... rejected by sz nLinks(";
749 std::cout << forLine.length() <<
") < ";
752 HepAListDeleteAll( forLine );
762 double min_chi2[5] = { 9999., 9999., 9999., 9999., 9999. };
763 double min_a[5] = { 9999., 9999., 9999., 9999., 9999. };
765#ifdef TRKRECO_DEBUG_DETAIL
771 bool display =
false;
779 for (
unsigned isl = 0; isl < 5; isl++ )
784#ifdef TRKRECO_DEBUG_DETAIL
785 std::cout <<
" ... stereo supter layer " << isl << std::endl;
795 unsigned ily2 = ily1 + 1;
796 unsigned ily3 = ily2 + 1;
799 unsigned ilst = llyr[ily1] + 1;
800 unsigned ifst = ilst - nlyr[ily1];
801 for (
unsigned i = ifst; i < ilst; i++ )
808 if ( l.
zPair() < i ) { tmpLine.append( m ); }
818 unsigned jlst = llyr[ily2] + 1;
819 unsigned jfst = jlst - nlyr[ily2];
820 for (
unsigned j = jfst; j < jlst; j++ )
823 tmpLine.append( l2 );
827 if ( l2.
zPair() < j ) { tmpLine.append(
m2 ); }
831 tmpLine.remove( l2 );
837 unsigned klst = llyr[ily3] + 1;
838 unsigned kfst = klst - nlyr[ily3];
839 for (
unsigned k = kfst; k < klst; k++ )
842 tmpLine.append( l3 );
846 if ( l3.
zPair() < k ) { tmpLine.append( m3 ); }
850 tmpLine.remove( l3 );
868 if ( l.
zStatus() == 20 && relation12 < 0 )
875 if ( l.
zStatus() == 20 && relation23 < 0 )
880 if ( relation12 || relation23 )
882#ifdef TRKRECO_DEBUG_DETAIL
883 std::cout <<
" ... bad relations";
884 std::cout <<
" : segment rejected";
885 Dump( tmpLine,
"detail stereo",
" " );
889 int err = line.
fit();
897 tmpLine.remove( l3 );
898 if ( l3.
zStatus() == 20 ) tmpLine.remove( m3 );
903 unsigned ntmp = tmpLine.length();
906 std::cout <<
"!!! is this possible !!!???" << std::endl;
908 tmpLine.remove( l3 );
909 if ( l3.
zStatus() == 20 ) tmpLine.remove( m3 );
915 int err = line.
fit();
918#ifdef TRKRECO_DEBUG_DETAIL
919 std::cout <<
" ... line fit error";
920 std::cout <<
" : segment rejected" << std::endl;
921 Dump( line.
links(),
"detail stereo",
" " );
931 tmpLine.remove( l3 );
932 if ( l3.
zStatus() == 20 ) tmpLine.remove( m3 );
943 min_chi2[isl] = chi2;
944 min_a[isl] = line.
a();
945#ifdef TRKRECO_DEBUG_DETAIL
946 std::cout <<
" ... segment accepted : " << std::endl;
949#ifdef TRKRECO_DEBUG_DETAIL
952 std::cout <<
" ... bad quality : segment rejected :";
953 std::cout <<
"chi2=" << chi2;
954 std::cout <<
", b=" << line.
b() << std::endl;
956 Dump( line.
links(),
"detail stereo",
" " );
967 if ( l3.
zStatus() == 20 ) tmpLine.remove( m3 );
968 tmpLine.remove( l3 );
971 if ( l2.
zStatus() == 20 ) tmpLine.remove(
m2 );
972 tmpLine.remove( l2 );
975 if ( l.
zStatus() == 20 ) tmpLine.remove( m );
980 if ( isl == 0 ) gdSLine0 = goodLine;
981 if ( isl == 1 ) gdSLine1 = goodLine;
982 goodLine.removeAll();
993 unsigned ily2 = ily1 + 1;
994 unsigned ily3 = ily2 + 1;
995 unsigned ily4 = ily3 + 1;
996 if ( nlyr[ily1] == 0 || nlyr[ily2] == 0 || nlyr[ily3] == 0 || nlyr[ily4] == 0 )
continue;
999 unsigned ilst = llyr[ily1] + 1;
1000 unsigned ifst = ilst - nlyr[ily1];
1001 for (
unsigned i = ifst; i < ilst; i++ )
1004 tmpLine.append( l );
1008 if ( l.
zPair() < i ) { tmpLine.append( m ); }
1011 tmpLine.remove( l );
1017 unsigned jlst = llyr[ily2] + 1;
1018 unsigned jfst = jlst - nlyr[ily2];
1019 for (
unsigned j = jfst; j < jlst; j++ )
1021 TMLink& l2 = *forLine[j];
1022 tmpLine.append( l2 );
1026 if ( l2.
zPair() < j ) { tmpLine.append(
m2 ); }
1029 tmpLine.remove( l2 );
1035 unsigned klst = llyr[ily3] + 1;
1036 unsigned kfst = klst - nlyr[ily3];
1037 for (
unsigned k = kfst; k < klst; k++ )
1039 TMLink& l3 = *forLine[k];
1040 tmpLine.append( l3 );
1044 if ( l3.
zPair() < k ) { tmpLine.append( m3 ); }
1047 tmpLine.remove( l3 );
1053 unsigned hlst = llyr[ily4] + 1;
1054 unsigned hfst = hlst - nlyr[ily4];
1055 for (
unsigned h = hfst; h < hlst; h++ )
1057 TMLink& l4 = *forLine[h];
1058 tmpLine.append( l4 );
1062 if ( l4.
zPair() < h ) { tmpLine.append( m4 ); }
1065 tmpLine.remove( l4 );
1077 int relation12 = -1;
1078 int relation23 = -1;
1079 int relation34 = -1;
1088 if ( l.
zStatus() == 20 && relation12 < 0 )
1095 if ( l.
zStatus() == 20 && relation23 < 0 )
1097 checkHits(
m2.hit()->wire()->localId(), l3.
hit()->
wire()->
localId(), isl );
1102 if ( l3.
zStatus() == 20 && relation34 < 0 )
1107 if ( relation12 || relation23 || relation34 )
1110#ifdef TRKRECO_DEBUG_DETAIL
1111 std::cout <<
" ... bad relations";
1112 std::cout <<
" : segment rejected";
1113 Dump( tmpLine,
"detail stereo",
" " );
1117 int err = line.
fit();
1125 tmpLine.remove( l4 );
1126 if ( l4.
zStatus() == 20 ) tmpLine.remove( m4 );
1131 unsigned ntmp = tmpLine.length();
1134 tmpLine.remove( l4 );
1135 if ( l4.
zStatus() == 20 ) tmpLine.remove( m4 );
1141 int err = line.
fit();
1144#ifdef TRKRECO_DEBUG_DETAIL
1145 std::cout <<
" ... line fit error";
1146 std::cout <<
" : segment rejected" << std::endl;
1147 Dump( line.
links(),
"detail stereo",
" " );
1157 tmpLine.remove( l4 );
1158 if ( l4.
zStatus() == 20 ) tmpLine.remove( m4 );
1166 chi2 < min_chi2[isl] )
1171 min_chi2[isl] = chi2;
1172 min_a[isl] = line.
a();
1174#ifdef TRKRECO_DEBUG_DETAIL
1175 std::cout <<
" segment accepted : " << std::endl;
1178#ifdef TRKRECO_DEBUG_DETAIL
1181 std::cout <<
" ... bad quality : segment rejected :";
1182 std::cout <<
" chi2=" << chi2;
1183 std::cout <<
", b=" << line.
b() << std::endl;
1185 Dump( line.
links(),
"detail stereo",
" " );
1196 if ( l4.
zStatus() == 20 ) tmpLine.remove( m4 );
1197 tmpLine.remove( l4 );
1200 if ( l3.
zStatus() == 20 ) tmpLine.remove( m3 );
1201 tmpLine.remove( l3 );
1204 if ( l2.
zStatus() == 20 ) tmpLine.remove(
m2 );
1205 tmpLine.remove( l2 );
1208 if ( l.
zStatus() == 20 ) tmpLine.remove( m );
1209 tmpLine.remove( l );
1213 if ( isl == 2 ) gdSLine2 = goodLine;
1214 if ( isl == 3 ) gdSLine3 = goodLine;
1215 if ( isl == 4 ) gdSLine4 = goodLine;
1216 goodLine.removeAll();
1223 unsigned Nsgmnts[5] = { 0, 0, 0, 0, 0 };
1224 Nsgmnts[0] = gdSLine0.length();
1225 Nsgmnts[1] = gdSLine1.length();
1226 Nsgmnts[2] = gdSLine2.length();
1227 Nsgmnts[3] = gdSLine3.length();
1228 Nsgmnts[4] = gdSLine4.length();
1230 unsigned NusedSgmnts = 0;
1231 for (
unsigned jsl = 0; jsl < 5; jsl++ )
1233 if ( Nsgmnts[jsl] > 0 ) NusedSgmnts += 1;
1237 if ( NusedSgmnts == 0 )
1239#ifdef TRKRECO_DEBUG_DETAIL
1240 std::cout <<
"... rejected because no segment found" << std::endl;
1242 HepAListDeleteAll( forLine );
1248 forNewLine.append( gdSLine0 );
1249 forNewLine.append( gdSLine1 );
1250 forNewLine.append( gdSLine2 );
1251 forNewLine.append( gdSLine3 );
1252 forNewLine.append( gdSLine4 );
1255 unsigned nNewLine = forNewLine.length();
1257 TLine0 newLine( forNewLine );
1260 int err = newLine.
fit();
1263 double newLine_a = newLine.
a();
1270 if ( ( ( R > 80. && newLine_chi2 > 4.0 ) || ( R < 80. && newLine_chi2 > 13.0 ) ) &&
1274 double max_diff_a = 0.;
1275 unsigned this_sly = 999;
1276 for (
unsigned isl = 0; isl < 5; isl++ )
1278 if ( Nsgmnts[isl] == 0 )
continue;
1279 double diff_a = fabs( ( min_a[isl] - newLine_a ) / newLine_a );
1280 if ( diff_a > max_diff_a )
1282 max_diff_a = diff_a;
1288 if ( ( R < 50. && max_diff_a > 0.4 ) || ( R > 50. && max_diff_a > 0.3 ) )
1292 Nsgmnts[this_sly] = 0;
1295 if ( this_sly == 0 ) { newLine.
removeSLY( gdSLine0 ); }
1296 else if ( this_sly == 1 ) { newLine.
removeSLY( gdSLine1 ); }
1297 else if ( this_sly == 2 ) { newLine.
removeSLY( gdSLine2 ); }
1298 else if ( this_sly == 3 ) { newLine.
removeSLY( gdSLine3 ); }
1299 else if ( this_sly == 4 ) { newLine.
removeSLY( gdSLine4 ); }
1302 unsigned NnewLine_2 = newLine.
links().length();
1303 if ( NnewLine_2 < 3 )
1305#ifdef TRKRECO_DEBUG_DETAIL
1306 std::cout <<
"... rejected because of few links for line" << std::endl;
1308 HepAListDeleteAll( forLine );
1312 int err = newLine.
fit();
1315#ifdef TRKRECO_DEBUG_DETAIL
1316 std::cout <<
"... rejected because of line fit failure" << std::endl;
1318 HepAListDeleteAll( forLine );
1321 double newLine_chi2_2 = newLine.
chi2() / NnewLine_2;
1327 double maxSigma = 1.0;
1328 if ( R < 80 ) maxSigma = 1.5;
1329 newLine.
refine( bad, maxSigma );
1330 if ( newLine.
links().length() < 2 )
1332#ifdef TRKRECO_DEBUG_DETAIL
1333 std::cout <<
"... rejected because of few links for line after refine";
1334 std::cout << std::endl;
1336 HepAListDeleteAll( forLine );
1339 err = newLine.
fit();
1342#ifdef TRKRECO_DEBUG_DETAIL
1343 std::cout <<
"... rejected because of line fit failure(2)" << std::endl;
1345 HepAListDeleteAll( forLine );
1350 for (
unsigned isl = 0; isl < 5; isl++ )
1352 if ( Nsgmnts[isl] == 0 )
1354 double maxdist = 0.5;
1355 if ( R < 80 ) maxdist = 1.25;
1359 err = newLine.
fit();
1362#ifdef TRKRECO_DEBUG_DETAIL
1363 std::cout <<
"... rejected because of line fit failure(3)" << std::endl;
1365 HepAListDeleteAll( forLine );
1371 newLine.
refine( bad, maxSigma );
1372 if ( newLine.
links().length() < 2 )
1374#ifdef TRKRECO_DEBUG_DETAIL
1375 std::cout <<
"... rejected because of few links for line after 2nd refine";
1376 std::cout << std::endl;
1378 HepAListDeleteAll( forLine );
1383 err = newLine.
fit();
1386 HepAListDeleteAll( forLine );
1387#ifdef TRKRECO_DEBUG_DETAIL
1388 std::cout <<
" appendStereo cut ... new line 2nd linear fit failure. ";
1389 std::cout <<
"# of links = " <<
n <<
",";
1390 std::cout <<
"," << nNewLine << std::endl;
1396 unsigned NnewLine_3 = newLine.
links().length();
1397 double newLine_chi2_3 = newLine.
chi2() / NnewLine_3;
1404 unsigned nn = good.length();
1405 for (
unsigned i = 0; i < nn; i++ ) { track.
append( *good[i]->link() ); }
1411 a[4] = track.
charge() * newLine.
a();
1412 track._helix->
a( a );
1416 if ( err < 0 )
goto discard;
1419 if ( err < 0 )
goto discard;
1422 if ( err < 0 )
goto discard;
1425 if ( err < 0 )
goto discard;
1431 HepAListDeleteAll( forLine );
1436#ifdef TRKRECO_DEBUG_DETAIL
1437 std::cout <<
" ... rejected by fitting failure : ";
1438 std::cout <<
" err = " << err << std::endl;
1440 HepAListDeleteAll( forLine );
1473int TBuilder0::checkHits(
unsigned i,
unsigned j,
unsigned isl )
const {
1475 int nWr[5] = { 80, 128, 160, 208, 256 };
1476 int ilast = nWr[isl] - 1;
1477 int ilocal = (int)i;
1478 int jlocal = (int)j;
1480 if ( ilocal > 0 && ilocal < ilast )
1482 if ( fabs(
float( jlocal - ilocal ) ) > 1 ) {
return -1; }
1485 else if ( ilocal == 0 )
1487 if ( jlocal > 1 && jlocal < ilast ) {
return -1; }
1490 if ( jlocal == ilast ) {
return 0; }
1491 else if ( jlocal == 0 ) {
return 0; }
1492 else if ( jlocal == 1 ) {
return 0; }
1496 else if ( ilocal == ilast )
1498 if ( jlocal > 0 && jlocal < ilast - 1 ) {
return -1; }
1501 if ( jlocal == ilast - 1 ) {
return 0; }
1502 else if ( jlocal == ilast ) {
return 0; }
1503 else if ( jlocal == 0 ) {
return 0; }
1514 salvageNormal(
t, hits );
1518#ifdef TRKRECO_DEBUG_DETAIL
1519 std::cout <<
name() <<
" ... salvaging" << std::endl;
1520 std::cout <<
" # of given hits=" << hits.length() << std::endl;
1523 unsigned nHits = hits.length();
1524 if ( nHits == 0 )
return;
1528 for (
unsigned i = 0; i < nHits; i++ )
1535 candidates.append( l );
1540 t.appendByApproach( candidates, _salvageLevel );
1542 hits.remove( candidates );
1550#ifdef TRKRECO_DEBUG_DETAIL
1551 std::cout <<
name() <<
" ... normal salvaging : ";
1552 std::cout <<
" # of hits=" << hits.length() << std::endl;
1555 unsigned nHits = hits.length();
1556 if ( nHits == 0 )
return;
1564 for (
unsigned i = 0; i < nHits; i++ )
1568 if ( a.cross( h.
xyPosition() ).z() *
t.charge() > 0. )
continue;
1572 candidates.append( l );
1576 t.appendByApproach( candidates, 30. );
1578 hits.remove( candidates );
1584int TBuilder0::check2CnHits(
TMLink& l,
TMLink&
s,
int ichg )
const {
1587 if ( l.
hit()->
wire()->
layerId() !=
s.hit()->wire()->layerId() )
return -1;
1590 int nsl[11] = { 64, 80, 96, 128, 144, 160, 192, 208, 240, 256, 288 };
1591 float hcell[50] = { 0., 0., 0., 0., 0., 0., 0.687499, 0.747198, 0.806896,
1592 0., 0., 0., 0., 0., 0., 0.782967, 0.820598, 0.858229,
1593 0., 0., 0., 0., 0., 0.878423, 0.908646, 0.939845, 0.970068,
1594 0., 0., 0., 0., 0., 0.892908, 0.916188, 0.940219, 0.963499,
1595 0., 0., 0., 0., 0., 0.901912, 0.920841, 0.940382, 0.959312,
1596 0., 0., 0., 0., 0. };
1600 int jlocal =
s.hit()->wire()->localId();
1603 double ddist2 =
s.hit()->drift() / hcell[
s.hit()->wire()->layerId()];
1604 double ddist = 0.5 * ( ddist1 + ddist2 );
1607 if ( ilocal > 0 && ilocal < ilast )
1609 if (
abs( jlocal - ilocal ) > 1 ) {
return -20; }
1612 if ( ddist > 0.65 &&
1613 ( ( ddist1 > 0.7 && ddist2 > 0.7 ) || ( ddist1 > 0.95 || ddist2 > 0.95 ) ) )
1617 if ( ichg > 0 ) {
return 1; }
1620 else {
return -20; }
1623 else if ( ilocal == 0 )
1625 if ( jlocal > 1 && jlocal < ilast ) {
return -20; }
1628 if ( ddist > 0.65 &&
1629 ( ( ddist1 > 0.7 && ddist2 > 0.7 ) || ( ddist1 > 0.95 || ddist2 > 0.95 ) ) )
1631 if ( jlocal == ilast )
1635 if ( ichg > 0 ) {
return 0; }
1638 else if ( jlocal == 1 )
1640 if ( ichg > 0 ) {
return 1; }
1646 else if ( ilocal == ilast )
1648 if ( jlocal > 0 && jlocal < ilast - 1 ) {
return -20; }
1651 if ( ddist > 0.65 &&
1652 ( ( ddist1 > 0.7 && ddist2 > 0.7 ) || ( ddist1 > 0.95 || ddist2 > 0.95 ) ) )
1654 if ( jlocal == ilast - 1 )
1657 if ( ichg > 0 ) {
return 0; }
1660 else if ( jlocal == 0 )
1662 if ( ichg > 0 ) {
return 1; }
1666 else {
return -20; }
1674int TBuilder0::consectiveHits(
TMLink& l,
TMLink&
s,
int ichg )
const {
1677 static float hcell[50] = { 0., 0., 0., 0., 0., 0., 0.687499, 0.747198, 0.806896,
1678 0., 0., 0., 0., 0., 0., 0.782967, 0.820598, 0.858229,
1679 0., 0., 0., 0., 0., 0.878423, 0.908646, 0.939845, 0.970068,
1680 0., 0., 0., 0., 0., 0.892908, 0.916188, 0.940219, 0.963499,
1681 0., 0., 0., 0., 0., 0.901912, 0.920841, 0.940382, 0.959312,
1682 0., 0., 0., 0., 0. };
1683 const TMDCWire& wire = *l.
hit()->
wire();
1684 const TMDCWire&
next = *
s.hit()->wire();
1687 if ( wire.
layerId() !=
next.layerId() )
return -1;
1694 unsigned layerId = wire.
layerId();
1695 double ddist1 = l.
hit()->
drift() / hcell[layerId];
1696 double ddist2 =
s.hit()->drift() / hcell[layerId];
1697 double ddist = 0.5 * ( ddist1 + ddist2 );
1700 if ( ddist > 0.65 &&
1701 ( ( ddist1 > 0.7 && ddist2 > 0.7 ) || ( ddist1 > 0.95 || ddist2 > 0.95 ) ) )
1705 if ( ichg > 0 )
return 1;
1708 else {
return -50; }
HepGeom::Vector3D< double > HepVector3D
HepGeom::Point3D< double > HepPoint3D
const HepPoint3D ORIGIN
Constants.
#define WireHitContinuous
#define WireHitFittingValid
#define WireHitConformalFinder
void Dump(const CAList< TMLink > &links, const std::string &message=std::string(""), const std::string &prefix=std::string(""))
dumps TMLinks.
AList< TMLink > SameSuperLayer(const AList< TMLink > &list, const TMLink &a)
returns links which are in the same super layer as 'a' or 'id'.
unsigned SuperLayer(const AList< TMLink > &list)
returns super layer pattern.
unsigned NLayers(const AList< TMLink > &links)
returns # of layers.
unsigned NSuperLayers(const AList< TMLink > &links)
returns # of layers.
#define TrackOldConformalFinder
const HepVector & a(void) const
returns helix parameters.
TTrack * buildRphi(const AList< TMLink > &) const
builds a r/phi track from TMLinks or from Segments.
const TMSelector & trackSelector(void) const
returns a track selector.
virtual ~TBuilder0()
Destructor.
TMSelector _circleSelector
TTrack * buildStereo0(TTrack &track, const AList< TMLink > &) const
appends stereo hits to a track. (old version)
TMSelector _trackSelector
void dump(const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
dumps debug information.
const std::string & name(void) const
returns name.
TBuilder0(const std::string &name)
Constructor.
virtual TTrack * buildStereo(TTrack &track, const AList< TMLink > &) const
appends stereo hits to a track.
void salvage(TTrack &track, AList< TMLink > &list) const
salvages links in a list. Used links will be removed from a list.
virtual int fit(TTrackBase &) const
fits a track using a private fitter.
void appendClusters(TTrack &track, const AList< TMLink > &) const
appends TMLinks in a list.
A class to represent a circle in tracking.
A class to represent a track in tracking.
double chi2(void) const
returns chi2.
double distance(const TMLink &) const
returns distance to a position of TMLink itself. (not to a wire)
void appendByszdistance(AList< TMLink > &list, unsigned isl, float maxSigma)
double b(void) const
returns coefficient b.
double reducedChi2(void) const
returns reduced-chi2.
void removeChits()
remove extremly bad points.
void removeSLY(AList< TMLink > &list)
int fit2p()
fits itself using isolated hits. Error was happened if return value is not zero.
void refine(AList< TMLink > &list, float maxSigma)
double a(void) const
returns coefficient a.
unsigned axialStereoLayerId(void) const
returns id of axial or stereo id.
unsigned nWires(void) const
returns # of wires.
unsigned state(void) const
returns state.
float drift(unsigned) const
returns drift distance.
const TMDCWire *const wire(void) const
returns a pointer to a TMDCWire.
const HepPoint3D & xyPosition(void) const
returns drift time
bool consective(const TMDCWire &) const
returns true if a given wire is consective in a layer.
const TMDCLayer *const layer(void) const
returns a pointer to a layer.
unsigned localId(void) const
returns local id in a wire layer.
unsigned layerId(void) const
returns layer id.
unsigned superLayerId(void) const
returns super layer id.
std::string name(void) const
returns name.
static TMDC * getTMDC(void)
const AList< TMDCLayer > *const superLayer(unsigned id) const
returns a pointer to a super-layer. 0 will be returned if 'id' is invalid.
A class to relate TMDCWireHit and TTrack objects.
TMLink * link(void) const
returns a pointer to a TMLink.
int zPair(void) const
returns id# of the pair, if zStatus == 20 (2 consective hits).
unsigned leftRight(void) const
returns left-right. 0:left, 1:right, 2:wire
int zStatus(void) const
returns stauts of stereo hit
const TMDCWireHit * hit(void) const
returns a pointer to a hit.
const HepPoint3D & position(void) const
returns position.
const TMDCWire *const wire(void) const
returns a pointer to a wire.
A class to select a TTrackBase object.
double maxDistance(void) const
returns max. distance required for stereo hits.
unsigned nSuperLayers(void) const
returns min. # of super layers required.
double maxImpact(void) const
returns max. impact(2D) required.
unsigned nLinks(void) const
returns min. # of hits(TMLinks) requried.
double maxSigma(void) const
returns max. sigma for each TMLink.
unsigned nLinksStereo(void) const
returns min. # of stereo hits(TMLinks) requried.
double minPt(void) const
returns min. pt required.
virtual int fit(void)
fits itself by a default fitter. Error was happened if return value is not zero.
virtual void refine(AList< TMLink > &list, double maxSigma)
void append(TMLink &)
appends a TMLink.
const AList< TMLink > & links(unsigned mask=0) const
void appendByApproach(AList< TMLink > &list, double maxSigma)
A class to represent a track in tracking.
const Helix & helix(void) const
returns helix parameter.
int szPosition(TMLink &link) const
calculates arc length and z for a stereo hit.
double charge(void) const
returns charge.