00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifdef TRKRECO_DEBUG_DETAIL
00014 #ifndef TRKRECO_DEBUG
00015 #define TRKRECO_DEBUG
00016 #endif
00017 #endif
00018 #include "TrkReco/TBuilder0.h"
00019 #include "TrkReco/TMDC.h"
00020 #include "TrkReco/TMDCWire.h"
00021 #include "TrkReco/TMDCWireHit.h"
00022 #include "TrkReco/TMLink.h"
00023 #include "TrkReco/TCircle.h"
00024 #include "TrkReco/TLine0.h"
00025 #include "TrkReco/TTrack.h"
00027 #ifdef TRKRECO_WINDOW
00028 #include "TrkReco/TWindow.h"
00029 #endif
00030
00031 TBuilder0::TBuilder0(const std::string & a)
00032 : _name(a),
00033 _fitter("TBuilder0 Fitter"),
00034 _salvageLevel(30.),
00035 _stereoZ3(20.),
00036 _stereoZ4(20.),
00037 _stereoChisq3(15.),
00038 _stereoChisq4(9.),
00039 _stereoMaxSigma(30.) {
00040 }
00041
00042 TBuilder0::TBuilder0(const std::string & a, float salvageLevel)
00043 : _name(a),
00044 _fitter("TBuilder0 Fitter"),
00045 _salvageLevel(salvageLevel),
00046 _stereoZ3(20.),
00047 _stereoZ4(20.),
00048 _stereoChisq3(15.),
00049 _stereoChisq4(9.),
00050 _stereoMaxSigma(30.) {
00051 }
00052
00053 TBuilder0::TBuilder0(const std::string & a,
00054 float stereoZ3,
00055 float stereoZ4,
00056 float stereoChisq3,
00057 float stereoChisq4,
00058 float stereoMaxSigma,
00059 unsigned corrections,
00060 float salvageLevel)
00061 : _name(a),
00062 _fitter("TBuilder0 Fitter"),
00063 _stereoZ3(stereoZ3),
00064 _stereoZ4(stereoZ4),
00065 _stereoChisq3(stereoChisq3),
00066 _stereoChisq4(stereoChisq4),
00067 _stereoMaxSigma(stereoMaxSigma),
00068 _salvageLevel(salvageLevel) {
00069
00070
00071
00072
00073 }
00074
00075 TBuilder0::~TBuilder0() {
00076 }
00077
00078 void
00079 TBuilder0::dump(const std::string & msg, const std::string & pre) const {
00080 }
00081
00082 TTrack *
00083 TBuilder0::buildRphi(const AList<TMLink> & list) const {
00084 #ifdef TRKRECO_DEBUG_DETAIL
00085 std::cout << _name << " ... building a rphi track" << std::endl;
00086 std::cout << _name << " ... selecting good hits" << std::endl;
00087
00088
00089
00090 #endif
00091
00092
00093 if (list.length() < _circleSelector.nLinks()) {
00094 #ifdef TRKRECO_DEBUG_DETAIL
00095 std::cout << _name << " ... rejected by nLinks(";
00096 std::cout << list.length() << ") < ";
00097 std::cout << _circleSelector.nLinks() << std::endl;
00098 #endif
00099 }
00100
00101
00102 AList<TMLink> cores = list;
00103 selectHits(cores);
00104 if (cores.length() < 5) cores = list;
00105
00106
00107
00108 #ifdef TRKRECO_DEBUG_DETAIL
00109 std::cout << _name << " ... checking cores : cores=" << std::endl;
00110 Dump(cores, "detail");
00111 #endif
00112 unsigned sLinks = SuperLayer(list);
00113 unsigned sUsed = SuperLayer(cores);
00114 #ifdef TRKRECO_DEBUG_DETAIL
00115 std::cout << " super layer ptn=" << sLinks;
00116 std::cout << ",super layer used=" << sUsed << std::endl;
00117 #endif
00118 if (sLinks != sUsed) {
00119 #ifdef TRKRECO_DEBUG_DETAIL
00120 std::cout << _name << " ... appending hits to cores" << std::endl;
00121 #endif
00122 unsigned diff = sLinks - sUsed;
00123 unsigned asl[5] = {2, 3, 4, 9, 10};
00124 for (unsigned j = 0; j < 5; j++) {
00125
00126 if (diff & (1 << asl[5 - j])) {
00127 #ifdef TRKRECO_DEBUG_DETAIL
00128 std::cout << " super layer " << (5 - j) * 2 << "searching";
00129 std::cout << std::endl;
00130 #endif
00131 AList<TMLink> links = SameSuperLayer(list, asl[5 - j]);
00132 TMLink * best = NULL;
00133 double bestD = 999.;
00134 for (unsigned i = 0; i < links.length(); i++) {
00135 double dist = links[i]->hit()->drift();
00136 if (dist < 0.02) {
00137 #ifdef TRKRECO_DEBUG_DETAIL
00138 std::cout << " " << links[i]->wire()->name();
00139 std::cout << " appended (small dist)" << std::endl;
00140 #endif
00141 cores.append(links[i]);
00142 continue;
00143 }
00144 if (dist < bestD) {
00145 best = links[i];
00146 bestD = dist;
00147 }
00148 }
00149 if (best) {
00150 cores.append(best);
00151 #ifdef TRKRECO_DEBUG_DETAIL
00152 std::cout << " " << best->wire()->name();
00153 std::cout << " appended (best)" << std::endl;
00154 #endif
00155 }
00156 }
00157 }
00158 }
00159
00160
00161 unsigned nCores = cores.length();
00162 AList<TMLink> realCores;
00163 for (unsigned i = 0; i < nCores; i++) {
00164 TMLink * l = cores[i];
00165 if (l->hit()->state() & WireHitFittingValid)
00166 realCores.append(l);
00167 }
00168 if (NSuperLayers(realCores) < 2) {
00169 #ifdef TRKRECO_DEBUG_DETAIL
00170 std::cout << " ... rejected by small number of super layers" << std::endl;
00171 #endif
00172 return NULL;
00173 }
00174 if (NLayers(realCores) < 5) {
00175 #ifdef TRKRECO_DEBUG_DETAIL
00176 std::cout << " ... rejected by small number of layers" << std::endl;
00177 #endif
00178 return NULL;
00179 }
00180
00181
00182 #ifdef TRKRECO_DEBUG_DETAIL
00183 std::cout << _name << " ... making a circle : #cores=" << cores.length();
00184 std::cout << std::endl;
00185 #endif
00186 AList<TMLink> hits = list;
00187 hits.remove(cores);
00188 TCircle c(cores);
00189
00190
00191 if (! _circleSelector.preSelect(c)) return NULL;
00192
00193
00194 int err = c.fit();
00195 if (err < 0) {
00196 #ifdef TRKRECO_DEBUG_DETAIL
00197 std::cout << " ... rejected by failure of the 1st fit : ";
00198 std::cout << "err = " << err << std::endl;
00199 #endif
00200 return NULL;
00201 }
00202
00203
00204 if (! _circleSelector.select(c)) return NULL;
00205
00206
00207 #ifdef TRKRECO_DEBUG_DETAIL
00208 std::cout << _name << " ... making a track" << std::endl;
00209 #endif
00210 TTrack * t = new TTrack(c);
00211 if (! _trackSelector.preSelect(* t)) {
00212 delete t;
00213 return NULL;
00214 }
00215
00216
00217 AList<TMLink> bad;
00218
00219 err = fit(* t);
00220 if (err < 0) goto discard;
00221 t->refine(bad, _trackSelector.maxSigma() * 100.);
00222
00223 err = fit(* t);
00224 if (err < 0) goto discard;
00225 #ifdef TRKRECO_DEBUG_DETAIL
00226 t->dump("detail", " 1st> ");
00227 #endif
00228
00229
00230 if (! _trackSelector.select(* t)) goto discard;
00231
00232
00233 #ifdef TRKRECO_DEBUG_DETAIL
00234 std::cout << _name << " ... appending non-core hits" << std::endl;
00235 #endif
00236 t->appendByApproach(hits, sqrt(_trackSelector.maxSigma()));
00237 err = fit(* t);
00238 if (err < 0) goto discard;
00239
00240 t->refine(bad, _trackSelector.maxSigma() * 10.);
00241 err = fit(* t);
00242 if (err < 0) goto discard;
00243
00244 t->refine(bad, _trackSelector.maxSigma());
00245 err = fit(* t);
00246 if (err < 0) goto discard;
00247
00248 #ifdef TRKRECO_DEBUG_DETAIL
00249 t->dump("detail", " 2nd> ");
00250 #endif
00251
00252
00253 if (! _trackSelector.select(* t)) goto discard;
00254
00255
00256 #ifdef TRKRECO_DEBUG_DETAIL
00257
00258
00259
00260
00261
00262 #endif
00263
00264 return t;
00265
00266
00267 discard:
00268 #ifdef TRKRECO_DEBUG_DETAIL
00269 std::cout << " ... rejected by fitting failure : ";
00270 std::cout << " err = " << err << std::endl;
00271
00272
00273
00274
00275
00276 #endif
00277 delete t;
00278 return NULL;
00279 }
00280
00281 void
00282 TBuilder0::selectHits(AList<TMLink> & list) const {
00283 AList<TMLink> bad;
00284 for (unsigned i = 0; i < list.length(); i++) {
00285 unsigned state = list[i]->hit()->state();
00286 if ((! (state & WireHitContinuous)) ||
00287 (! (state & WireHitIsolated))) {
00288 bad.append(list[i]);
00289 continue;
00290 }
00291
00292
00293
00294
00295
00296 }
00297
00298 #ifdef TRKRECO_DEBUG_DETAIL
00299 std::cout << _name << "(TBuilder0::selectHits) ... dump of candidates" << std::endl;
00300 Dump(list, "detail");
00301 #endif
00302
00303 list.remove(bad);
00304 }
00305
00306 TTrack *
00307 TBuilder0::buildStereo0(TTrack & track, const AList<TMLink> & list) const {
00308 #ifdef TRKRECO_DEBUG_DETAIL
00309 std::cout << _name << "(stereo) ... dump of stereo candidate hits" << std::endl;
00310 Dump(list, "sort flag", " ");
00311 #endif
00312
00313
00314 if (list.length() < _lineSelector.nLinksStereo()) {
00315 #ifdef TRKRECO_DEBUG_DETAIL
00316 std::cout << _name << "(stereo) ... rejected by nLinks(";
00317 std::cout << list.length() << ") < ";
00318 std::cout << _lineSelector.nLinks() << std::endl;
00319 #endif
00320 return NULL;
00321 }
00322
00323
00324 unsigned n = list.length();
00325 AList<TMLink> forLine;
00326 for (unsigned i = 0; i < n; i++) {
00327 TMLink * l = list[i];
00328 TMLink * t = new TMLink(* l);
00329
00330
00331 t->leftRight(2);
00332 int err = track.szPosition(* t);
00333 if (err) {
00334 delete t;
00335 continue;
00336 }
00337
00338
00339 t->link(l);
00340 forLine.append(t);
00341 }
00342
00343 #ifdef TRKRECO_DEBUG_DETAIL
00344 std::cout << _name << "(stereo) ... dump of sz links" << std::endl;
00345 Dump(forLine, "sort flag", " ");
00346 #endif
00347
00348
00349 if (forLine.length() < _lineSelector.nLinksStereo()) {
00350 #ifdef TRKRECO_DEBUG_DETAIL
00351 std::cout << _name << "(stereo) ... rejected by sz nLinks(";
00352 std::cout << forLine.length() << ") < ";
00353 std::cout << _lineSelector.nLinks() << std::endl;
00354 #endif
00355 HepAListDeleteAll(forLine);
00356 return NULL;
00357 }
00358
00359
00360 unsigned nLine = forLine.length();
00361 TLine0 line(forLine);
00362 int err = line.fit2sp();
00363 if (err < 0) {
00364 err = line.fit2p();
00365 if (err < 0) err = line.fit();
00366 }
00367
00368
00369 if (err < 0) {
00370 #ifdef TRKRECO_DEBUG_DETAIL
00371 std::cout << _name << "(stereo) ... linear fit failure. nLinks(";
00372 std::cout << forLine.length() << ")" << std::endl;
00373 #endif
00374 HepAListDeleteAll(forLine);
00375 return NULL;
00376 }
00377
00378 #ifdef TRKRECO_DEBUG_DETAIL
00379 std::cout << _name << "(stereo) ... dump of left-right" << std::endl;
00380 #endif
00381
00382
00383 AList<TMLink> forNewLine;
00384 for (unsigned i = 0; i < nLine; i++) {
00385 TMLink * t = forLine[i];
00386 TMLink * tl = new TMLink(* t);
00387 TMLink * tr = new TMLink(* t);
00388
00389 tl->leftRight(WireHitLeft);
00390 tr->leftRight(WireHitRight);
00391
00392 int err = track.szPosition(* tl);
00393 if (err) {
00394 delete tl;
00395 tl = NULL;
00396 }
00397 err = track.szPosition(* tr);
00398 if (err) {
00399 delete tr;
00400 tr = NULL;
00401 }
00402 if ((tl == NULL) && (tr == NULL)) continue;
00403
00404 TMLink * best;
00405 if (tl == NULL) best = tr;
00406 else if (tr == NULL) best = tl;
00407 else {
00408 if (line.distance(* tl) < line.distance(* tr)) {
00409 best = tl;
00410 delete tr;
00411 }
00412 else {
00413 best = tr;
00414 delete tl;
00415 }
00416 }
00417
00418 #ifdef TRKRECO_DEBUG_DETAIL
00419 std::cout << " ";
00420 std::cout << t->wire()->layerId() << "-";
00421 std::cout << t->wire()->localId();
00422 if (tl != NULL)
00423 std::cout << ",left " << tl->position() << "," << line.distance(* tl);
00424 if (tr != NULL)
00425 std::cout << ",right " << tr->position() << "," << line.distance(* tr);
00426 std::cout << std::endl;
00427 #endif
00428
00429 best->link(t->link());
00430 forNewLine.append(best);
00431 }
00432
00433
00434 if (forNewLine.length() < _lineSelector.nLinksStereo()) {
00435 #ifdef TRKRECO_DEBUG_DETAIL
00436 std::cout << _name << "(stereo) ... rejected by lr nLinks(";
00437 std::cout << forNewLine.length() << ") < ";
00438 std::cout << _lineSelector.nLinks() << std::endl;
00439 #endif
00440 HepAListDeleteAll(forLine);
00441 HepAListDeleteAll(forNewLine);
00442 return NULL;
00443 }
00444
00445
00446 #ifdef TRKRECO_DEBUG_DETAIL
00447 std::cout << _name << "(stereo) ... creating a new line" << std::endl;
00448 #endif
00449 unsigned nNewLine = forNewLine.length();
00450 TLine0 newLine(forNewLine);
00451
00452
00453 newLine.removeChits();
00454
00455
00456 err = newLine.fit2sp();
00457 if (err < 0) {
00458 err = newLine.fit2p();
00459 if (err < 0) err = newLine.fit();
00460 }
00461
00462
00463 if (err < 0) {
00464 #ifdef TRKRECO_DEBUG_DETAIL
00465 std::cout << _name << "(stereo) ... 2nd linear fit failure. nLinks(";
00466 std::cout << forNewLine.length() << ")" << std::endl;
00467 #endif
00468 HepAListDeleteAll(forLine);
00469 HepAListDeleteAll(forNewLine);
00470 return NULL;
00471 }
00472
00473
00474 AList<TMLink> bad;
00475 newLine.refine(bad, 40.);
00476 err = newLine.fit();
00477 newLine.refine(bad, 30.);
00478 err = newLine.fit();
00479 newLine.refine(bad, 20.);
00480 err = newLine.fit();
00481 newLine.refine(bad, 10.);
00482 err = newLine.fit();
00483 float R = fabs(track.helix().curv());
00484 if (R > 80.) {
00485 newLine.refine(bad, 5.);
00486 err = newLine.fit();
00487 }
00488
00489
00490 if (err < 0) {
00491 HepAListDeleteAll(forLine);
00492 HepAListDeleteAll(forNewLine);
00493 #ifdef TRKRECO_DEBUG_DETAIL
00494 std::cout << " appendStereo cut ... new line 2nd linear fit failure. ";
00495 std::cout << "# of links = " << n << "," << nLine;
00496 std::cout << "," << nNewLine << std::endl;
00497 #endif
00498 return NULL;
00499 }
00500
00501
00502 const AList<TMLink> & good = newLine.links();
00503 unsigned nn = good.length();
00504 for (unsigned i = 0; i < nn; i++) {
00505 track.append(* good[i]->link());
00506 }
00507 Vector a(5);
00508 a = track.helix().a();
00509 a[4] = track.charge() * newLine.a();
00510 track._helix->a(a);
00511
00512
00513 err = fit(track);
00514 track.refine(bad, _trackSelector.maxSigma() * 100.);
00515 err = fit(track);
00516 track.refine(bad, _trackSelector.maxSigma() * 10.);
00517 err = fit(track);
00518 track.refine(bad, _trackSelector.maxSigma());
00519 err = fit(track);
00520
00521
00522 if (! _trackSelector.select(track)) {
00523 HepAListDeleteAll(forLine);
00524 HepAListDeleteAll(forNewLine);
00525 return NULL;
00526 }
00527
00528
00529 HepAListDeleteAll(forLine);
00530 HepAListDeleteAll(forNewLine);
00531 return & track;
00532 }
00533
00534 TTrack *
00535 TBuilder0::buildStereo(TTrack & track, const AList<TMLink> & list) const {
00536 #ifdef TRKRECO_DEBUG_DETAIL
00537 std::cout << _name << "(stereo) ... building in 3D" << std::endl;
00538 std::cout << "... dump of stereo candidate hits" << std::endl;
00539 Dump(list, "sort flag", " ");
00540 #endif
00541
00542
00543 if (list.length() < _lineSelector.nLinksStereo()) {
00544 #ifdef TRKRECO_DEBUG_DETAIL
00545 std::cout << "... rejected by nLinks(";
00546 std::cout << list.length() << ") < ";
00547 std::cout << _lineSelector.nLinks() << std::endl;
00548 #endif
00549 return NULL;
00550 }
00551
00552
00553 int ichg;
00554 if (track.helix().curv() > 0.) ichg = 1;
00555 else ichg = -1;
00556 unsigned nlyr[18] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
00557 unsigned llyr[18] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
00558
00559
00560
00561
00562
00563
00564 unsigned n = list.length();
00565 AList<TMLink> forLine;
00566 unsigned iforLine = 0;
00567 for (unsigned i = 0; i < n; i++) {
00568 TMLink * l = list[i];
00569
00570 if (i < n-1) {
00571 TMLink * lnext = list[i + 1];
00572
00573
00574
00575 int LorR = consectiveHits(* l, * lnext, ichg);
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591 if (LorR == WireHitLeft || LorR == WireHitRight) {
00592
00593
00594 if (LorR == WireHitLeft) {
00595 l->leftRight(WireHitLeft);
00596 lnext->leftRight(WireHitRight);
00597 }
00598 else {
00599 l->leftRight(WireHitRight);
00600 lnext->leftRight(WireHitLeft);
00601 }
00602
00603
00604 int err1 = track.szPosition(* l);
00605 int err2 = track.szPosition(* lnext);
00606 if(err1 == 0 && err2 == 0){
00607 double deltaZ = fabs(l->position().y() -
00608 lnext->position().y());
00609 if (deltaZ < 1.5) {
00610
00611
00612 l->zStatus(20);
00613 lnext->zStatus(20);
00614 l->zPair(iforLine + 1);
00615 lnext->zPair(iforLine);
00616 }
00617 #ifdef TRKRECO_DEBUG_DETAIL
00618 else {
00619 std::cout << " ... rejected because delta z > 1.5";
00620 std::cout << std::endl;
00621 }
00622 #endif
00623 }
00624 #ifdef TRKRECO_DEBUG_DETAIL
00625 else {
00626 if (err1) {
00627 std::cout << " ... s-z calculation error with ";
00628 std::cout << l->wire()->name() << std::endl;
00629 }
00630 if (err2) {
00631 std::cout << " ... s-z calculation error with ";
00632 std::cout << lnext->wire()->name() << std::endl;
00633 }
00634 }
00635 #endif
00636 }
00637 }
00638
00639
00640
00641 if(l->zStatus() == 20){
00642 TMLink * t = new TMLink(* l);
00643 t->zStatus(l->zStatus());
00644 t->zPair(l->zPair());
00645 int err = track.szPosition(* t);
00646 if (err) {
00647 delete t;
00648 continue;
00649 }
00650 else {
00651
00652 t->link(l);
00653 forLine.append(t);
00654
00655
00656 nlyr[l->wire()->layer()->axialStereoLayerId()] += 1;
00657
00658 llyr[l->wire()->layer()->axialStereoLayerId()] = iforLine;
00659 iforLine += 1;
00660 }
00661 }
00662 else {
00663
00664
00665 TMLink * tl = new TMLink(* l);
00666 tl->leftRight(WireHitLeft);
00667 tl->zStatus(-10);
00668 tl->zPair(0);
00669 int err = track.szPosition(* tl);
00670 if(err){
00671 delete tl;
00672 }
00673 else {
00674
00675 tl->link(l);
00676 forLine.append(tl);
00677
00678
00679 nlyr[l->wire()->layer()->axialStereoLayerId()] += 1;
00680
00681 llyr[l->wire()->layer()->axialStereoLayerId()] = iforLine;
00682
00683 iforLine += 1;
00684 }
00685
00686
00687 TMLink * tr = new TMLink(* l);
00688 tr->leftRight(WireHitRight);
00689 tr->zStatus(-10);
00690 tr->zPair(0);
00691 err = track.szPosition(* tr);
00692 if(err) {
00693 delete tr;
00694 }
00695 else{
00696
00697 tr->link(l);
00698 forLine.append(tr);
00699
00700
00701 nlyr[l->wire()->layer()->axialStereoLayerId()] += 1;
00702
00703 llyr[l->wire()->layer()->axialStereoLayerId()] = iforLine;
00704 iforLine += 1;
00705 }
00706 }
00707 }
00708
00709 #ifdef TRKRECO_DEBUG_DETAIL
00710 std::cout << "... dump of sz links" << std::endl;
00711 Dump(forLine, "sort flag", " ");
00712 for (unsigned i = 0; i < 18; i++) {
00713 std::cout << i << " : " << nlyr[i] << ", " << llyr[i] << std::endl;
00714 }
00715 #endif
00716
00717
00718 if (forLine.length() < _lineSelector.nLinksStereo()) {
00719 #ifdef TRKRECO_DEBUG_DETAIL
00720 std::cout << "... rejected by sz nLinks(";
00721 std::cout << forLine.length() << ") < ";
00722 std::cout << _lineSelector.nLinks() << std::endl;
00723 #endif
00724 HepAListDeleteAll(forLine);
00725 return NULL;
00726 }
00727
00728
00729 AList<TMLink> gdSLine0;
00730 AList<TMLink> gdSLine1;
00731 AList<TMLink> gdSLine2;
00732 AList<TMLink> gdSLine3;
00733 AList<TMLink> gdSLine4;
00734 double min_chi2[5] = {9999.,9999.,9999.,9999.,9999.};
00735 double min_a[5] = {9999.,9999.,9999.,9999.,9999.};
00736
00737 #ifdef TRKRECO_DEBUG_DETAIL
00738
00739
00740
00741
00742
00743 bool display = false;
00744
00745
00746
00747
00748 #endif
00749
00750
00751 for (unsigned isl=0; isl < 5; isl++) {
00752 AList<TMLink> tmpLine;
00753 AList<TMLink> goodLine;
00754
00755 #ifdef TRKRECO_DEBUG_DETAIL
00756 std::cout << " ... stereo supter layer " << isl << std::endl;
00757 #endif
00758
00759
00760 if (isl < 2) {
00761
00762
00763 unsigned ily1 = TMDC::getTMDC("1.0")->superLayer(isl * 2 + 1)
00764 ->first()->axialStereoLayerId();
00765 unsigned ily2 = ily1 + 1;
00766 unsigned ily3 = ily2 + 1;
00767
00768
00769 unsigned ilst = llyr[ily1] + 1;
00770 unsigned ifst = ilst - nlyr[ily1];
00771 for (unsigned i =ifst; i<ilst; i++) {
00772 TMLink & l = * forLine[i];
00773 tmpLine.append(l);
00774 TMLink & m = *forLine[l.zPair()];
00775 if (l.zStatus() == 20) {
00776 if (l.zPair() < i ) {
00777 tmpLine.append(m);
00778 }
00779 else {
00780
00781 tmpLine.remove(l);
00782 continue;
00783 }
00784 }
00785
00786
00787 unsigned jlst = llyr[ily2] + 1;
00788 unsigned jfst = jlst - nlyr[ily2];
00789 for (unsigned j =jfst; j< jlst; j++) {
00790 TMLink & l2 = * forLine[j];
00791 tmpLine.append(l2);
00792 TMLink & m2 = *forLine[l2.zPair()];
00793 if (l2.zStatus() == 20) {
00794 if (l2.zPair() < j) {
00795 tmpLine.append(m2);
00796 }
00797 else {
00798
00799 tmpLine.remove(l2);
00800 continue;
00801 }
00802 }
00803
00804
00805 unsigned klst = llyr[ily3] + 1;
00806 unsigned kfst = klst - nlyr[ily3];
00807 for (unsigned k=kfst; k < klst; k++) {
00808 TMLink & l3 = * forLine[k];
00809 tmpLine.append(l3);
00810 TMLink & m3 = * forLine[l3.zPair()];
00811 if (l3.zStatus() == 20) {
00812 if (l3.zPair() < k) {
00813 tmpLine.append(m3);
00814 }
00815 else {
00816
00817 tmpLine.remove(l3);
00818 continue;
00819 }
00820 }
00821
00822
00823
00824
00825
00826
00827
00828 int relation12 = -1;
00829 int relation23 = -1;
00830
00831
00832 relation12 = checkHits(l.hit()->wire()->localId(),
00833 l2.hit()->wire()->localId(),
00834 isl);
00835
00836 if (l.zStatus() == 20 && relation12 < 0)
00837 relation12 = checkHits(m.hit()->wire()->localId(),
00838 l2.hit()->wire()->localId(),
00839 isl);
00840
00841
00842 relation23 = checkHits(l2.hit()->wire()->localId(),
00843 l3.hit()->wire()->localId(),
00844 isl);
00845 if (l.zStatus() == 20 && relation23 < 0)
00846 relation23 = checkHits(m2.hit()->wire()->localId(),
00847 l3.hit()->wire()->localId(),
00848 isl);
00849
00850
00851 if(relation12 || relation23 ) {
00852 #ifdef TRKRECO_DEBUG_DETAIL
00853 std::cout << " ... bad relations";
00854 std::cout << " : segment rejected";
00855 Dump(tmpLine, "detail stereo", " ");
00856 if (display) {
00857 TLine0 line(tmpLine);
00858 int err = line.fit();
00859
00860
00861
00862
00863 }
00864 #endif
00865
00866 tmpLine.remove(l3);
00867 if (l3.zStatus() == 20) tmpLine.remove(m3);
00868 continue;
00869 }
00870
00871
00872 unsigned ntmp = tmpLine.length();
00873 if(ntmp < 3) {
00874 std::cout << "!!! is this possible !!!???" << std::endl;
00875
00876 tmpLine.remove(l3);
00877 if(l3.zStatus() == 20) tmpLine.remove(m3);
00878 continue;
00879 }
00880
00881
00882 TLine0 line(tmpLine);
00883 int err = line.fit();
00884 if (err < 0) {
00885 #ifdef TRKRECO_DEBUG_DETAIL
00886 std::cout << " ... line fit error";
00887 std::cout << " : segment rejected" << std::endl;
00888 Dump(line.links(), "detail stereo", " ");
00889 if (display) {
00890
00891
00892
00893
00894 }
00895 #endif
00896
00897 tmpLine.remove(l3);
00898 if(l3.zStatus() == 20) tmpLine.remove(m3);
00899 continue;
00900 }
00901
00902
00903
00904
00905 double chi2 = line.reducedChi2();
00906 if (fabs(line.b()) < _stereoZ3 &&
00907 chi2 < _stereoChisq3 &&
00908 chi2 < min_chi2[isl]) {
00909 goodLine = tmpLine;
00910 min_chi2[isl] = chi2;
00911 min_a[isl] = line.a();
00912 #ifdef TRKRECO_DEBUG_DETAIL
00913 std::cout << " ... segment accepted : " << std::endl;
00914 #endif
00915 }
00916 #ifdef TRKRECO_DEBUG_DETAIL
00917 else {
00918 std::cout << " ... bad quality : segment rejected :";
00919 std::cout << "chi2=" << chi2;
00920 std::cout << ", b=" << line.b() << std::endl;
00921 }
00922 Dump(line.links(), "detail stereo", " ");
00923 if (display) {
00924
00925
00926
00927
00928 }
00929 #endif
00930
00931
00932 if(l3.zStatus() ==20) tmpLine.remove(m3);
00933 tmpLine.remove(l3);
00934 }
00935
00936 if(l2.zStatus() ==20) tmpLine.remove(m2);
00937 tmpLine.remove(l2);
00938 }
00939
00940 if(l.zStatus() ==20) tmpLine.remove(m);
00941 tmpLine.remove(l);
00942 }
00943
00944
00945 if(isl==0) gdSLine0 = goodLine;
00946 if(isl==1) gdSLine1 = goodLine;
00947 goodLine.removeAll();
00948
00949 }
00950 else {
00951
00952
00953
00954
00955
00956 unsigned ily1 = TMDC::getTMDC("1.0")->superLayer(isl * 2 + 1)
00957 ->first()->axialStereoLayerId();
00958 unsigned ily2 = ily1 + 1;
00959 unsigned ily3 = ily2 + 1;
00960 unsigned ily4 = ily3 + 1;
00961 if (nlyr[ily1] == 0 ||
00962 nlyr[ily2] == 0 ||
00963 nlyr[ily3] == 0 ||
00964 nlyr[ily4] == 0) continue;
00965
00966
00967 unsigned ilst = llyr[ily1] + 1;
00968 unsigned ifst = ilst - nlyr[ily1];
00969 for(unsigned i =ifst; i<ilst;i++ ){
00970 TMLink & l = * forLine[i];
00971 tmpLine.append(l);
00972 TMLink & m = *forLine[l.zPair()];
00973 if(l.zStatus() == 20 ) {
00974 if(l.zPair()< i) {
00975 tmpLine.append(m);
00976 } else {
00977 tmpLine.remove(l);
00978 continue;
00979 }
00980 }
00981
00982
00983 unsigned jlst = llyr[ily2] + 1;
00984 unsigned jfst = jlst - nlyr[ily2];
00985 for(unsigned j =jfst; j< jlst; j++){
00986 TMLink & l2 = * forLine[j];
00987 tmpLine.append(l2);
00988 TMLink & m2 = *forLine[l2.zPair()];
00989 if(l2.zStatus() == 20 ) {
00990 if(l2.zPair()< j) {
00991 tmpLine.append(m2);
00992 } else {
00993 tmpLine.remove(l2);
00994 continue;
00995 }
00996 }
00997
00998
00999 unsigned klst = llyr[ily3] + 1;
01000 unsigned kfst = klst - nlyr[ily3];
01001 for( unsigned k=kfst; k < klst; k++ ){
01002 TMLink & l3 = * forLine[k];
01003 tmpLine.append(l3);
01004 TMLink & m3 = *forLine[l3.zPair()];
01005 if(l3.zStatus() == 20 ) {
01006 if(l3.zPair()< k) {
01007 tmpLine.append(m3);
01008 } else {
01009 tmpLine.remove(l3);
01010 continue;
01011 }
01012 }
01013
01014
01015 unsigned hlst = llyr[ily4] + 1;
01016 unsigned hfst = hlst - nlyr[ily4];
01017 for( unsigned h=hfst; h < hlst; h++ ){
01018 TMLink & l4 = * forLine[h];
01019 tmpLine.append(l4);
01020 TMLink & m4 = *forLine[l4.zPair()];
01021 if(l4.zStatus() == 20 ) {
01022 if(l4.zPair()< h) {
01023 tmpLine.append(m4);
01024 } else {
01025 tmpLine.remove(l4);
01026 continue;
01027 }
01028 }
01029
01030
01031
01032
01033
01034
01035
01036
01037 int relation12 = -1;
01038 int relation23 = -1;
01039 int relation34 = -1;
01040
01041
01042
01043
01044
01045
01046
01047 relation12 = checkHits(l.hit()->wire()->localId(),
01048 l2.hit()->wire()->localId(),
01049 isl);
01050 if (l.zStatus() == 20 && relation12 < 0)
01051 relation12 =
01052 checkHits(m.hit()->wire()->localId(),
01053 l2.hit()->wire()->localId(),
01054 isl);
01055
01056
01057 relation23 = checkHits(l2.hit()->wire()->localId(),
01058 l3.hit()->wire()->localId(),
01059 isl);
01060 if (l.zStatus() == 20 && relation23 < 0)
01061 relation23 =
01062 checkHits(m2.hit()->wire()->localId(),
01063 l3.hit()->wire()->localId(),
01064 isl);
01065
01066
01067 relation34 = checkHits(l3.hit()->wire()->localId(),
01068 l4.hit()->wire()->localId(),
01069 isl);
01070 if (l3.zStatus() == 20 && relation34 < 0)
01071 relation34 =
01072 checkHits(m3.hit()->wire()->localId(),
01073 l4.hit()->wire()->localId(),
01074 isl);
01075
01076
01077 if(relation12 || relation23 || relation34) {
01078
01079 #ifdef TRKRECO_DEBUG_DETAIL
01080 std::cout << " ... bad relations";
01081 std::cout << " : segment rejected";
01082 Dump(tmpLine, "detail stereo", " ");
01083 if (display) {
01084 TLine0 line(tmpLine);
01085 int err = line.fit();
01086
01087
01088
01089
01090 }
01091 #endif
01092
01093 tmpLine.remove(l4);
01094 if(l4.zStatus() == 20) tmpLine.remove(m4);
01095 continue;
01096 }
01097
01098
01099 unsigned ntmp = tmpLine.length();
01100 if(ntmp < 4) {
01101 tmpLine.remove(l4);
01102 if(l4.zStatus() == 20) tmpLine.remove(m4);
01103 continue;
01104 }
01105
01106
01107 TLine0 line(tmpLine);
01108 int err = line.fit();
01109 if (err < 0) {
01110 #ifdef TRKRECO_DEBUG_DETAIL
01111 std::cout << " ... line fit error";
01112 std::cout << " : segment rejected" << std::endl;
01113 Dump(line.links(), "detail stereo", " ");
01114 if (display) {
01115
01116
01117
01118
01119 }
01120 #endif
01121
01122 tmpLine.remove(l4);
01123 if(l4.zStatus() == 20) tmpLine.remove(m4);
01124 continue;
01125 }
01126
01127
01128
01129 double chi2 = line.reducedChi2();
01130 if (fabs(line.b()) < _stereoZ4 &&
01131 chi2 < _stereoChisq4 &&
01132 chi2 < min_chi2[isl]) {
01133
01134
01135 goodLine = tmpLine;
01136 min_chi2[isl] = chi2;
01137 min_a[isl] = line.a();
01138
01139 #ifdef TRKRECO_DEBUG_DETAIL
01140 std::cout << " segment accepted : " << std::endl;
01141 #endif
01142 }
01143 #ifdef TRKRECO_DEBUG_DETAIL
01144 else {
01145 std::cout << " ... bad quality : segment rejected :";
01146 std::cout << " chi2=" << chi2;
01147 std::cout << ", b=" << line.b() << std::endl;
01148 }
01149 Dump(line.links(), "detail stereo", " ");
01150 if (display) {
01151
01152
01153
01154
01155 }
01156 #endif
01157
01158
01159 if(l4.zStatus() ==20) tmpLine.remove(m4);
01160 tmpLine.remove(l4);
01161 }
01162
01163 if(l3.zStatus() ==20) tmpLine.remove(m3);
01164 tmpLine.remove(l3);
01165 }
01166
01167 if(l2.zStatus() ==20) tmpLine.remove(m2);
01168 tmpLine.remove(l2);
01169 }
01170
01171 if(l.zStatus() ==20) tmpLine.remove(m);
01172 tmpLine.remove(l);
01173 }
01174
01175
01176 if(isl==2) gdSLine2 = goodLine;
01177 if(isl==3) gdSLine3 = goodLine;
01178 if(isl==4) gdSLine4 = goodLine;
01179 goodLine.removeAll();
01180 }
01181 }
01182
01183
01184
01185
01186
01187 unsigned Nsgmnts[5] = {0,0,0,0,0};
01188 Nsgmnts[0] = gdSLine0.length();
01189 Nsgmnts[1] = gdSLine1.length();
01190 Nsgmnts[2] = gdSLine2.length();
01191 Nsgmnts[3] = gdSLine3.length();
01192 Nsgmnts[4] = gdSLine4.length();
01193
01194 unsigned NusedSgmnts = 0;
01195 for(unsigned jsl = 0; jsl < 5; jsl++) {
01196 if(Nsgmnts[jsl] > 0) NusedSgmnts +=1;
01197 }
01198
01199
01200 if (NusedSgmnts == 0) {
01201 #ifdef TRKRECO_DEBUG_DETAIL
01202 std::cout << "... rejected because no segment found" << std::endl;
01203 #endif
01204 HepAListDeleteAll(forLine);
01205 return NULL;
01206 }
01207
01208
01209 AList<TMLink> forNewLine;
01210 forNewLine.append(gdSLine0);
01211 forNewLine.append(gdSLine1);
01212 forNewLine.append(gdSLine2);
01213 forNewLine.append(gdSLine3);
01214 forNewLine.append(gdSLine4);
01215
01216
01217 unsigned nNewLine = forNewLine.length();
01218 float R = fabs(track.helix().curv());
01219 TLine0 newLine(forNewLine);
01220
01221
01222 int err = newLine.fit();
01223
01224 double newLine_chi2 = newLine.reducedChi2();
01225 double newLine_a = newLine.a();
01226
01227
01228
01229
01230
01231 if(((R > 80. && newLine_chi2 > 4.0) ||(R < 80. && newLine_chi2 > 13.0))&& NusedSgmnts > 1){
01232
01233 double max_diff_a = 0.;
01234 unsigned this_sly = 999;
01235 for(unsigned isl=0; isl < 5; isl++){
01236 if(Nsgmnts[isl]==0) continue;
01237 double diff_a = fabs((min_a[isl]-newLine_a)/newLine_a);
01238 if(diff_a > max_diff_a){
01239 max_diff_a = diff_a;
01240 this_sly = isl;
01241 }
01242 }
01243
01244
01245 if((R< 50. && max_diff_a > 0.4) || (R > 50. && max_diff_a > 0.3)) {
01246
01247
01248 Nsgmnts[this_sly]=0;
01249
01250
01251 if(this_sly == 0){
01252 newLine.removeSLY(gdSLine0);
01253 } else if (this_sly == 1){
01254 newLine.removeSLY(gdSLine1);
01255 } else if (this_sly == 2){
01256 newLine.removeSLY(gdSLine2);
01257 } else if (this_sly == 3){
01258 newLine.removeSLY(gdSLine3);
01259 } else if (this_sly == 4){
01260 newLine.removeSLY(gdSLine4);
01261 }
01262
01263
01264 unsigned NnewLine_2 = newLine.links().length();
01265 if(NnewLine_2 < 3) {
01266 #ifdef TRKRECO_DEBUG_DETAIL
01267 std::cout << "... rejected because of few links for line" << std::endl;
01268 #endif
01269 HepAListDeleteAll(forLine);
01270 return NULL;
01271 }
01272
01273 int err = newLine.fit();
01274 if (err < 0) {
01275 #ifdef TRKRECO_DEBUG_DETAIL
01276 std::cout << "... rejected because of line fit failure" << std::endl;
01277 #endif
01278 HepAListDeleteAll(forLine);
01279 return NULL;
01280 }
01281 double newLine_chi2_2 = newLine.chi2()/NnewLine_2;
01282 }
01283 }
01284
01285
01286 AList<TMLink> bad;
01287 double maxSigma = 1.0;
01288 if(R < 80) maxSigma = 1.5;
01289 newLine.refine(bad, maxSigma);
01290 if(newLine.links().length()< 2) {
01291 #ifdef TRKRECO_DEBUG_DETAIL
01292 std::cout << "... rejected because of few links for line after refine";
01293 std::cout << std::endl;
01294 #endif
01295 HepAListDeleteAll(forLine);
01296 return NULL;
01297 }
01298 err = newLine.fit();
01299 if (err < 0) {
01300 #ifdef TRKRECO_DEBUG_DETAIL
01301 std::cout << "... rejected because of line fit failure(2)" << std::endl;
01302 #endif
01303 HepAListDeleteAll(forLine);
01304 return NULL;
01305 }
01306
01307
01308 for(unsigned isl = 0; isl < 5; isl++){
01309 if(Nsgmnts[isl] == 0) {
01310 double maxdist = 0.5;
01311 if(R < 80) maxdist = 1.25;
01312 newLine.appendByszdistance(forLine, 2*isl+1, maxdist);
01313 }
01314 }
01315 err = newLine.fit();
01316 if (err < 0) {
01317 #ifdef TRKRECO_DEBUG_DETAIL
01318 std::cout << "... rejected because of line fit failure(3)" << std::endl;
01319 #endif
01320 HepAListDeleteAll(forLine);
01321 return NULL;
01322 }
01323
01324
01325 maxSigma = 1.0;
01326 newLine.refine(bad, maxSigma);
01327 if(newLine.links().length()< 2) {
01328 #ifdef TRKRECO_DEBUG_DETAIL
01329 std::cout << "... rejected because of few links for line after 2nd refine";
01330 std::cout << std::endl;
01331 #endif
01332 HepAListDeleteAll(forLine);
01333 return NULL;
01334 }
01335
01336
01337 err = newLine.fit();
01338 if (err < 0) {
01339 HepAListDeleteAll(forLine);
01340 #ifdef TRKRECO_DEBUG_DETAIL
01341 std::cout << " appendStereo cut ... new line 2nd linear fit failure. ";
01342 std::cout << "# of links = " << n << ",";
01343 std::cout << "," << nNewLine << std::endl;
01344 #endif
01345 return NULL;
01346 }
01347
01348
01349 unsigned NnewLine_3 = newLine.links().length();
01350 double newLine_chi2_3 = newLine.chi2()/NnewLine_3;
01351
01352
01353
01354
01355
01356 const AList<TMLink> & good = newLine.links();
01357 unsigned nn = good.length();
01358 for (unsigned i = 0; i < nn; i++) {
01359 track.append(* good[i]->link());
01360 }
01361
01362
01363 Vector a(5);
01364 a = track.helix().a();
01365 a[3] = newLine.b();
01366 a[4] = track.charge() * newLine.a();
01367 track._helix->a(a);
01368
01369
01370 err = fit(track);
01371 if (err < 0) goto discard;
01372 track.refine(bad, _stereoMaxSigma * 100.);
01373 err = fit(track);
01374 if (err < 0) goto discard;
01375 track.refine(bad, _stereoMaxSigma * 10.);
01376 err = fit(track);
01377 if (err < 0) goto discard;
01378 track.refine(bad, _stereoMaxSigma);
01379 err = fit(track);
01380 if (err < 0) goto discard;
01381
01382
01383 if (! _trackSelector.select(track)) goto discard;
01384
01385
01386 HepAListDeleteAll(forLine);
01387 return & track;
01388
01389
01390 discard:
01391 #ifdef TRKRECO_DEBUG_DETAIL
01392 std::cout << " ... rejected by fitting failure : ";
01393 std::cout << " err = " << err << std::endl;
01394 #endif
01395 HepAListDeleteAll(forLine);
01396 return NULL;
01397 }
01398
01399 const TMSelector &
01400 TBuilder0::trackSelector(const TMSelector & a) {
01401 _circleSelector.nLinks(a.nLinks());
01402 _circleSelector.nSuperLayers(a.nSuperLayers());
01403 _circleSelector.minPt(a.minPt());
01404 _circleSelector.maxImpact(a.maxImpact());
01405
01406 _trackSelector.nLinks(a.nLinks());
01407 _trackSelector.nSuperLayers(a.nSuperLayers());
01408 _trackSelector.maxSigma(a.maxSigma());
01409
01410 _lineSelector.nLinksStereo(a.nLinksStereo());
01411 _lineSelector.maxDistance(a.maxDistance());
01412
01413 return a;
01414 }
01415
01416 void
01417 TBuilder0::appendClusters(TTrack & track,
01418 const AList<TMLink> & list) const {
01419
01420 AList<TMLink> tmp = list;
01421
01422
01423 track.appendByApproach(tmp, _trackSelector.maxSigma() * 2. / 3.);
01424
01425
01426 AList<TMLink> bad;
01427 fit(track);
01428 track.refine(bad, _trackSelector.maxSigma());
01429 }
01430
01431 int
01432 TBuilder0::checkHits(unsigned i, unsigned j, unsigned isl) const {
01433
01434 int nWr[5] = {80,128,160,208,256};
01435 int ilast = nWr[isl]-1;
01436 int ilocal = (int) i;
01437 int jlocal = (int) j;
01438
01439 if(ilocal > 0 && ilocal < ilast){
01440 if(fabs(float(jlocal-ilocal)) > 1 ) {
01441 return -1;
01442 } else {
01443 return 0;
01444 }
01445 }else if(ilocal == 0){
01446 if(jlocal > 1 && jlocal < ilast){
01447 return -1;
01448 }else {
01449 if(jlocal == ilast){
01450 return 0;
01451 } else if(jlocal == 0){
01452 return 0;
01453 } else if(jlocal == 1){
01454 return 0;
01455 } else {
01456 return -1;
01457 }
01458 }
01459 }else if(ilocal == ilast){
01460 if(jlocal > 0 && jlocal < ilast-1){
01461 return -1;
01462 }else {
01463 if(jlocal == ilast-1){
01464 return 0;
01465 } else if(jlocal == ilast){
01466 return 0;
01467 } else if(jlocal == 0){
01468 return 0;
01469 } else {
01470 return -1;
01471 }
01472 }
01473 }
01474
01475 return -1;
01476 }
01477
01478 void
01479 TBuilder0::salvage(TTrack & t, AList<TMLink> & hits) const {
01480
01481
01482 salvageNormal(t, hits);
01483 return;
01484
01485
01486 #ifdef TRKRECO_DEBUG_DETAIL
01487 std::cout << name() << " ... salvaging" << std::endl;
01488 std::cout << " # of given hits=" << hits.length() << std::endl;
01489 #endif
01490
01491 unsigned nHits = hits.length();
01492 if (nHits == 0) return;
01493
01494
01495 AList<TMLink> candidates;
01496 for (unsigned i = 0; i < nHits; i++) {
01497 TMLink & l = * hits[i];
01498 const TMDCWireHit & h = * l.hit();
01499
01500
01501 if (h.state() & WireHitUsed) continue;
01502 candidates.append(l);
01503 }
01504
01505
01506
01507 t.appendByApproach(candidates, _salvageLevel);
01508 fit(t);
01509 hits.remove(candidates);
01510 t.assign(WireHitConformalFinder);
01511 t.finder(TrackOldConformalFinder);
01512
01513 }
01514
01515 void
01516 TBuilder0::salvageNormal(TTrack & t, AList<TMLink> & hits) const {
01517
01518 #ifdef TRKRECO_DEBUG_DETAIL
01519 std::cout << name() << " ... normal salvaging : ";
01520 std::cout << " # of hits=" << hits.length() << std::endl;
01521 #endif
01522
01523 unsigned nHits = hits.length();
01524 if (nHits == 0) return;
01525
01526
01527 const HepPoint3D & center = t.helix().center();
01528 const HepVector3D a = ORIGIN - center;
01529
01530
01531 AList<TMLink> candidates;
01532 for (unsigned i = 0; i < nHits; i++) {
01533 TMLink & l = * hits[i];
01534 const TMDCWireHit & h = * l.hit();
01535 if (a.cross(h.xyPosition()).z() * t.charge() > 0.) continue;
01536
01537
01538 if (h.state() & WireHitUsed) continue;
01539 candidates.append(l);
01540 }
01541
01542
01543 t.appendByApproach(candidates, 30.);
01544 fit(t);
01545 hits.remove(candidates);
01546 t.assign(WireHitConformalFinder);
01547 t.finder(TrackOldConformalFinder);
01548
01549 }
01550
01551 int
01552 TBuilder0::check2CnHits(TMLink &l, TMLink & s, int ichg) const {
01553
01554
01555 if(l.hit()->wire()->layerId() != s.hit()->wire()->layerId()) return -1;
01556
01557
01558 int nsl[11] = {64,80,96,128,144,160,192,208,240,256,288};
01559 float hcell[50] = {0.,0.,0.,0.,0.,0.,0.687499,0.747198,0.806896,0.,0.,0.,0.,0.,0.,0.782967,0.820598,0.858229,0.,0.,0.,0.,0.,0.878423,0.908646,0.939845,0.970068,0.,0.,0.,0.,0.,0.892908,0.916188,0.940219,0.963499,0.,0.,0.,0.,0.,0.901912,0.920841,0.940382,0.959312,0.,0.,0.,0.,0.};
01560
01561 int ilast = nsl[l.hit()->wire()->superLayerId()] - 1;
01562 int ilocal = l.hit()->wire()->localId();
01563 int jlocal = s.hit()->wire()->localId();
01564
01565 double ddist1 = l.hit()->drift() / hcell[l.hit()->wire()->layerId()];
01566 double ddist2 = s.hit()->drift() / hcell[s.hit()->wire()->layerId()];
01567 double ddist = 0.5 * (ddist1 + ddist2);
01568
01569
01570 if (ilocal > 0 && ilocal < ilast) {
01571 if (abs(jlocal - ilocal) > 1) {
01572 return -20;
01573 }
01574 else {
01575 if (ddist > 0.65 &&
01576 ((ddist1 > 0.7 && ddist2 > 0.7) ||
01577 (ddist1 > 0.95 || ddist2 >0.95))) {
01578
01579
01580 if (ichg > 0) {
01581 return 1;
01582 }
01583 else {
01584 return 0;
01585 }
01586 }
01587 else {
01588 return -20;
01589 }
01590 }
01591 }
01592 else if (ilocal == 0) {
01593 if (jlocal > 1 && jlocal < ilast) {
01594 return -20;
01595 }
01596 else {
01597 if (ddist > 0.65 &&
01598 ((ddist1 > 0.7 && ddist2 > 0.7) ||
01599 (ddist1 > 0.95 || ddist2 > 0.95))) {
01600 if (jlocal == ilast) {
01601
01602
01603 if(ichg > 0){
01604 return 0;
01605 }
01606 else {
01607 return 1;
01608 }
01609 }
01610 else if (jlocal == 1) {
01611 if (ichg > 0) {
01612 return 1;
01613 }
01614 else {
01615 return 0;
01616 }
01617 }
01618 }
01619 }
01620 }
01621 else if (ilocal == ilast) {
01622 if(jlocal > 0 && jlocal < ilast-1) {
01623 return -20;
01624 }
01625 else {
01626 if (ddist > 0.65 &&
01627 ((ddist1 > 0.7 && ddist2 > 0.7) ||
01628 (ddist1 > 0.95 || ddist2 > 0.95))) {
01629 if (jlocal == ilast-1) {
01630
01631 if(ichg > 0){
01632 return 0;
01633 } else {
01634 return 1;
01635 }
01636 } else if(jlocal == 0){
01637 if(ichg > 0){
01638 return 1;
01639 } else {
01640 return 0;
01641 }
01642 }
01643 } else {
01644 return -20;
01645 }
01646 }
01647 }
01648
01649
01650 return -50;
01651 }
01652
01653 int
01654 TBuilder0::consectiveHits(TMLink & l, TMLink & s, int ichg) const {
01655
01656
01657 static float hcell[50] = {0.,0.,0.,0.,0.,0.,
01658 0.687499,0.747198,0.806896,
01659 0.,0.,0.,0.,0.,0.,
01660 0.782967,0.820598,0.858229,
01661 0.,0.,0.,0.,0.,
01662 0.878423,0.908646,0.939845,0.970068,
01663 0.,0.,0.,0.,0.,
01664 0.892908,0.916188,0.940219,0.963499,
01665 0.,0.,0.,0.,0.,
01666 0.901912,0.920841,0.940382,0.959312,
01667 0.,0.,0.,0.,0.};
01668 const TMDCWire & wire = * l.hit()->wire();
01669 const TMDCWire & next = * s.hit()->wire();
01670
01671
01672 if (wire.layerId() != next.layerId()) return -1;
01673
01674
01675 if (! wire.consective(next)) return -20;
01676
01677
01678 int ilast = wire.layer()->nWires() - 1;
01679 unsigned layerId = wire.layerId();
01680 double ddist1 = l.hit()->drift() / hcell[layerId];
01681 double ddist2 = s.hit()->drift() / hcell[layerId];
01682 double ddist = 0.5 * (ddist1 + ddist2);
01683
01684
01685 if (ddist > 0.65 &&
01686 ((ddist1 > 0.7 && ddist2 > 0.7) || (ddist1 > 0.95 || ddist2 > 0.95))) {
01687
01688
01689 if (ichg > 0) return 1;
01690 else return 0;
01691 }
01692 else {
01693 return -50;
01694 }
01695 }