#include <TBuilder0.h>
Inheritance diagram for TBuilder0:
Public Member Functions | |
TBuilder0 (const std::string &name) | |
Constructor. | |
TBuilder0 (const std::string &name, float salvageLevel) | |
Constructor with salvage level. | |
TBuilder0 (const std::string &name, float stereoZ3, float stereoZ4, float stereoChisq3, float stereoChisq4, float stereoMaxSigma, unsigned fittingCorrections, float salvageLevel) | |
Constructor with parameters. | |
virtual | ~TBuilder0 () |
Destructor. | |
const std::string & | name (void) const |
returns name. | |
void | dump (const std::string &message=std::string(""), const std::string &prefix=std::string("")) const |
dumps debug information. | |
const TMSelector & | trackSelector (void) const |
returns a track selector. | |
TTrack * | buildRphi (const AList< TMLink > &) const |
builds a r/phi track from TMLinks or from Segments. | |
TTrack * | buildStereo0 (TTrack &track, const AList< TMLink > &) const |
appends stereo hits to a track. (old version) | |
virtual TTrack * | buildStereo (TTrack &track, const AList< TMLink > &) const |
appends stereo hits to a track. | |
void | appendClusters (TTrack &track, const AList< TMLink > &) const |
appends TMLinks in a list. | |
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. | |
virtual const TMSelector & | trackSelector (const TMSelector &) |
sets a track selector. | |
Protected Attributes | |
TMSelector | _circleSelector |
TMSelector | _trackSelector |
TMSelector | _lineSelector |
float | _stereoZ3 |
float | _stereoZ4 |
float | _stereoChisq3 |
float | _stereoChisq4 |
float | _stereoMaxSigma |
Private Member Functions | |
void | selectHits (AList< TMLink > &list) const |
int | consectiveHits (TMLink &l, TMLink &s, int ichg) const |
int | check2CnHits (TMLink &l, TMLink &s, int ichg) const |
int | checkHits (unsigned i, unsigned j, unsigned k) const |
void | salvageNormal (TTrack &track, AList< TMLink > &list) const |
Private Attributes | |
std::string | _name |
TCosmicFitter | _fitter |
double | _salvageLevel |
Definition at line 35 of file TBuilder0.h.
TBuilder0::TBuilder0 | ( | const std::string & | name | ) |
Constructor.
Definition at line 31 of file TBuilder0.cxx.
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 }
TBuilder0::TBuilder0 | ( | const std::string & | name, | |
float | salvageLevel | |||
) |
Constructor with salvage level.
Definition at line 42 of file TBuilder0.cxx.
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 }
TBuilder0::TBuilder0 | ( | const std::string & | name, | |
float | stereoZ3, | |||
float | stereoZ4, | |||
float | stereoChisq3, | |||
float | stereoChisq4, | |||
float | stereoMaxSigma, | |||
unsigned | fittingCorrections, | |||
float | salvageLevel | |||
) |
Constructor with parameters.
Definition at line 53 of file TBuilder0.cxx.
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 // if (corrections & 1) _fitter.sag(true); 00070 // if (corrections & 2) _fitter.propagation(true); 00071 // if (corrections & 4) _fitter.tof(true); 00072 // if (corrections & 8) _fitter.freeT0(true); 00073 }
TBuilder0::~TBuilder0 | ( | ) | [virtual] |
appends TMLinks in a list.
Definition at line 1417 of file TBuilder0.cxx.
References _trackSelector, TTrackBase::appendByApproach(), fit(), TMSelector::maxSigma(), and TTrackBase::refine().
Referenced by TConformalFinder0::appendClusters2().
01418 { 01419 01420 AList<TMLink> tmp = list; 01421 01422 //...Append them... 01423 track.appendByApproach(tmp, _trackSelector.maxSigma() * 2. / 3.); 01424 01425 //...Refine it... 01426 AList<TMLink> bad; 01427 fit(track); 01428 track.refine(bad, _trackSelector.maxSigma()); 01429 }
builds a r/phi track from TMLinks or from Segments.
Definition at line 83 of file TBuilder0.cxx.
References _circleSelector, _name, _trackSelector, check_raw_filter::dist, Dump(), showlog::err, fit(), TTrackBase::fit(), genRecEmupikp::i, ganga-rec::j, TMSelector::maxSigma(), NLayers(), TMSelector::nLinks(), NSuperLayers(), TMSelector::preSelect(), SameSuperLayer(), TMSelector::select(), selectHits(), SuperLayer(), t(), and WireHitFittingValid.
Referenced by TFastFinder::doit(), and TConformalFinder0::makeTrack().
00083 { 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 // TTrackBase tmp; 00088 // tmp.append(list); 00089 // rphiWindow->append(tmp, leda_red); 00090 #endif 00091 00092 //...Check # of links... 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 //...Select core hits... 00102 AList<TMLink> cores = list; 00103 selectHits(cores); 00104 if (cores.length() < 5) cores = list; 00105 //cout<<"list: "<<list.length()<<" core: "<<cores.length()<<endl; 00106 00107 //...Core check... 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 //if (diff & (1 << ((5 - j) * 2))) { 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 //...Check cores again... 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 //...Make a circle... 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 //...Test it... 00191 if (! _circleSelector.preSelect(c)) return NULL; 00192 00193 //...Fitting... 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 //...Test it... 00204 if (! _circleSelector.select(c)) return NULL; 00205 00206 //...Make a track... 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 //...Fitting... 00217 AList<TMLink> bad; 00218 //cout<<"track0: "<<t->nLinks()<<endl; 00219 err = fit(* t); 00220 if (err < 0) goto discard; 00221 t->refine(bad, _trackSelector.maxSigma() * 100.); 00222 //cout<<"track1: "<<t->nLinks()<<endl; 00223 err = fit(* t); 00224 if (err < 0) goto discard; 00225 #ifdef TRKRECO_DEBUG_DETAIL 00226 t->dump("detail", " 1st> "); 00227 #endif 00228 00229 //...Test it... 00230 if (! _trackSelector.select(* t)) goto discard; 00231 00232 //...Try to append non-core hits... 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 // cout<<" 2D track1: "<<t->links().length()<<endl; 00240 t->refine(bad, _trackSelector.maxSigma() * 10.); 00241 err = fit(* t); 00242 if (err < 0) goto discard; 00243 // cout<<" 2D track2: "<<t->links().length()<<endl; 00244 t->refine(bad, _trackSelector.maxSigma()); 00245 err = fit(* t); 00246 if (err < 0) goto discard; 00247 // cout<<" 2D track3: "<<t->links().length()<<endl; 00248 #ifdef TRKRECO_DEBUG_DETAIL 00249 t->dump("detail", " 2nd> "); 00250 #endif 00251 00252 //...Test it... 00253 if (! _trackSelector.select(* t)) goto discard; 00254 00255 //...OK... 00256 #ifdef TRKRECO_DEBUG_DETAIL 00257 // rphiWindow->append(* t, leda_blue); 00258 // rphiWindow->draw(); 00259 // rphiWindow->wait(); 00260 // rphiWindow->remove(tmp); 00261 // rphiWindow->remove(* t); 00262 #endif 00263 00264 return t; 00265 00266 //...Something happened... 00267 discard: 00268 #ifdef TRKRECO_DEBUG_DETAIL 00269 std::cout << " ... rejected by fitting failure : "; 00270 std::cout << " err = " << err << std::endl; 00271 // rphiWindow->append(* t, leda_blue); 00272 // rphiWindow->draw(); 00273 // rphiWindow->wait(); 00274 // rphiWindow->remove(tmp); 00275 // rphiWindow->remove(* t); 00276 #endif 00277 delete t; 00278 return NULL; 00279 }
appends stereo hits to a track.
Reimplemented in TBuilderCosmic, and TBuilderCurl.
Definition at line 535 of file TBuilder0.cxx.
References TTrack::_helix, _lineSelector, _name, _stereoChisq3, _stereoChisq4, _stereoMaxSigma, _stereoZ3, _stereoZ4, _trackSelector, Helix::a(), TTrackBase::append(), TTrack::charge(), checkHits(), consectiveHits(), Helix::curv(), Dump(), showlog::err, first, fit(), TMDC::getTMDC(), TTrack::helix(), TMLink::hit(), genRecEmupikp::i, ganga-rec::j, TMLink::leftRight(), genRecEmupikp::line, TMLink::link(), TMDCWire::localId(), TMSelector::nLinks(), TMSelector::nLinksStereo(), rb::R(), TTrackBase::refine(), TMSelector::select(), TMDC::superLayer(), TTrack::szPosition(), t(), tr, TMDCWireHit::wire(), WireHitLeft, WireHitRight, TMLink::zPair(), and TMLink::zStatus().
Referenced by TFastFinder::doit(), TConformalFinder0::specialFinding(), and TConformalFinder0::standardFinding().
00535 { 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 //...Check # of links... 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 //...Setup... 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 //...Check 00560 //... # of hits in a wire, 00561 //... 2 contineus hits or not 00562 //... 00563 //...and Calculate s and z for every links... 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 //...2 consective hits ?... 00574 // int LorR = check2CnHits(* l, * lnext, ichg); 00575 int LorR = consectiveHits(* l, * lnext, ichg); 00576 //...For debug... 00577 // if (check2CnHits(* l, * lnext, ichg) != 00578 // consectiveHits(* l, * lnext, ichg)) { 00579 // AList<TMLink> tmp; 00580 // tmp.append(l); 00581 // tmp.append(lnext); 00582 // std::cout << "!!! consective diff !!!" << std::endl; 00583 // std::cout << " original = " << check2CnHits(* l, * lnext, ichg); 00584 // std::cout << ", iw = " << consectiveHits(* l, * lnext, ichg); 00585 // std::cout << std::endl; 00586 // Dump(tmp, "detail"); 00587 // } 00588 //...For debug end... 00589 00590 //...Left/right solved by two consective hits... 00591 if (LorR == WireHitLeft || LorR == WireHitRight) { 00592 00593 //... Set Left/Right 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 //...Calculate z... 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 //... O.K. l and lnext should be good 2 consectvie hits 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 //... Calculate s and z... 00640 //... Aleady solved 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 //...Store the sz link... 00652 t->link(l); 00653 forLine.append(t); 00654 //... Check # of hits in a wire layer and Clustering them 00655 // nlyr[layertoStlayer(l->wire()->layerId())] += 1; 00656 nlyr[l->wire()->layer()->axialStereoLayerId()] += 1; 00657 // llyr[layertoStlayer(l->wire()->layerId())] = iforLine; 00658 llyr[l->wire()->layer()->axialStereoLayerId()] = iforLine; 00659 iforLine += 1; 00660 } 00661 } 00662 else { 00663 //...Assuming wire position... 00664 //... for left 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 //...Store the sz link... 00675 tl->link(l); 00676 forLine.append(tl); 00677 //... Check # of hits in a wire layer and Clustering them 00678 // nlyr[layertoStlayer(l->wire()->layerId())] += 1; 00679 nlyr[l->wire()->layer()->axialStereoLayerId()] += 1; 00680 // llyr[layertoStlayer(l->wire()->layerId())] = iforLine; 00681 llyr[l->wire()->layer()->axialStereoLayerId()] = iforLine; 00682 //... 00683 iforLine += 1; 00684 } 00685 00686 //... for right 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 //...Store the sz link... 00697 tr->link(l); 00698 forLine.append(tr); 00699 //... Check # of hits in a wire layer and Clustering them 00700 // nlyr[layertoStlayer(l->wire()->layerId())] += 1; 00701 nlyr[l->wire()->layer()->axialStereoLayerId()] += 1; 00702 // llyr[layertoStlayer(l->wire()->layerId())] = iforLine; 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 //...Check # of sz links... 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 //... Select the best segment in each Superlayer 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 // TTrackBase base; 00739 // base.append(forLine); 00740 // TWindow baseWindow("s-z window"); 00741 // baseWindow.append(base); 00742 00743 bool display = false; 00744 // for (unsigned i = 0; i < forLine.length(); i++) { 00745 // if (forLine[i]->wire()->name() == "15=31") 00746 // display = true; 00747 // } 00748 #endif 00749 00750 //...For all stereo super layers... 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 //...3-stereo-layer case... 00760 if (isl < 2) { 00761 00762 //...Initialize... 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 //...Loop for the first layer... 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 //...Already considered... 00781 tmpLine.remove(l); 00782 continue; 00783 } 00784 } 00785 00786 //...Loop for the second layer... 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 //...Already considered. 00799 tmpLine.remove(l2); 00800 continue; 00801 } 00802 } 00803 00804 //...Loop for the third layer... 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 //...Already considered. 00817 tmpLine.remove(l3); 00818 continue; 00819 } 00820 } 00821 00822 //... Check the hits in neighbor wirelayer 00823 //... 00824 //... x|o|o|x | 00825 //... |o| | 00826 //... V IP , o means OK. 00827 //... 00828 int relation12 = -1; 00829 int relation23 = -1; 00830 00831 //... Check the hit in fist and it in the second layer 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 //...Check the hit in second and it in the third layer 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 //...Bad relation... 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 // baseWindow.append(line); 00860 // baseWindow.draw(); 00861 // baseWindow.wait(); 00862 // baseWindow.remove(line); 00863 } 00864 #endif 00865 00866 tmpLine.remove(l3); 00867 if (l3.zStatus() == 20) tmpLine.remove(m3); 00868 continue; 00869 } 00870 00871 //...Make a segment 00872 unsigned ntmp = tmpLine.length(); 00873 if(ntmp < 3) { //...Is this needed???... 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 //...Do the linear fit 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 // baseWindow.append(line); 00891 // baseWindow.draw(); 00892 // baseWindow.wait(); 00893 // baseWindow.remove(line); 00894 } 00895 #endif 00896 00897 tmpLine.remove(l3); 00898 if(l3.zStatus() == 20) tmpLine.remove(m3); 00899 continue; 00900 } 00901 00902 //...Check quality for the fit 00903 //... if |z0| > 70 or chi2 > 0.7, remove it 00904 // double chi2 = line.chi2()/(ntmp-2); 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 // baseWindow.append(line); 00925 // baseWindow.draw(); 00926 // baseWindow.wait(); 00927 // baseWindow.remove(line); 00928 } 00929 #endif 00930 00931 //...end of third loop 00932 if(l3.zStatus() ==20) tmpLine.remove(m3); 00933 tmpLine.remove(l3); 00934 } 00935 //... end of second loop 00936 if(l2.zStatus() ==20) tmpLine.remove(m2); 00937 tmpLine.remove(l2); 00938 } 00939 //... end of first loop 00940 if(l.zStatus() ==20) tmpLine.remove(m); 00941 tmpLine.remove(l); 00942 } 00943 00944 //... Keep best segments 00945 if(isl==0) gdSLine0 = goodLine; 00946 if(isl==1) gdSLine1 = goodLine; 00947 goodLine.removeAll(); 00948 00949 } 00950 else { 00951 00952 //... Nlayer == 4 00953 00954 //...Initialize 00955 // unsigned ily1 = firstStlayer(isl); 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 //...loop for the first layer 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 //...loop for the second layer 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 //...loop for the third layer 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 //...loop for the 4th layer 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 //...Check the relation between the hit 01031 // in neighbor wirelayer 01032 //... 01033 //... x|o|o|x | 01034 //... |o| | 01035 //... V IP , o means OK. 01036 //... 01037 int relation12 = -1; 01038 int relation23 = -1; 01039 int relation34 = -1; 01040 01041 //...For debug... 01042 // if (l.hit()->wire()->consective(* l2.hit()->wire()) 01043 //...For debug end... 01044 01045 01046 //... Check the hit in fist and it in the second 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 //... Check the hit in second and it in the third 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 //... Check the hit in second and it in the forth 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 //...remove Bad segments 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 // baseWindow.append(line); 01087 // baseWindow.draw(); 01088 // baseWindow.wait(); 01089 // baseWindow.remove(line); 01090 } 01091 #endif 01092 01093 tmpLine.remove(l4); 01094 if(l4.zStatus() == 20) tmpLine.remove(m4); 01095 continue; 01096 } 01097 01098 //...Make a segment 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 //...Do the linear fit 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 // baseWindow.append(line); 01116 // baseWindow.draw(); 01117 // baseWindow.wait(); 01118 // baseWindow.remove(line); 01119 } 01120 #endif 01121 01122 tmpLine.remove(l4); 01123 if(l4.zStatus() == 20) tmpLine.remove(m4); 01124 continue; 01125 } 01126 01127 //...Check qualit of the fit 01128 //... if |z0| > 20 or chi2 > 0.5, remove it 01129 double chi2 = line.reducedChi2(); 01130 if (fabs(line.b()) < _stereoZ4 && 01131 chi2 < _stereoChisq4 && 01132 chi2 < min_chi2[isl]) { 01133 01134 //...Keep good segments 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 // baseWindow.append(line); 01152 // baseWindow.draw(); 01153 // baseWindow.wait(); 01154 // baseWindow.remove(line); 01155 } 01156 #endif 01157 01158 //...end of the 4th loop 01159 if(l4.zStatus() ==20) tmpLine.remove(m4); 01160 tmpLine.remove(l4); 01161 } 01162 //...end of the third loop 01163 if(l3.zStatus() ==20) tmpLine.remove(m3); 01164 tmpLine.remove(l3); 01165 } 01166 //...end of the second loop 01167 if(l2.zStatus() ==20) tmpLine.remove(m2); 01168 tmpLine.remove(l2); 01169 } 01170 //... end of the first loop 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 //... Link segments 01185 01186 //...Check how many segments are made 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 //...Require at least one Segment 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 //... Make a line 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 //...Do linear fit 01222 int err = newLine.fit(); 01223 // double newLine_chi2 = newLine.chi2()/(nNewLine - 2); 01224 double newLine_chi2 = newLine.reducedChi2(); 01225 double newLine_a = newLine.a(); 01226 01227 //...Check the quality of the line. 01228 01229 //...If chi2 > 0.25 for R > 80.( > 0.8 for R < 80.), refine the line. 01230 // if(((R > 80. && newLine_chi2 > 0.25) ||(R < 80. && newLine_chi2 > 0.8))&& NusedSgmnts > 1){ 01231 if(((R > 80. && newLine_chi2 > 4.0) ||(R < 80. && newLine_chi2 > 13.0))&& NusedSgmnts > 1){ 01232 //...Look at difference between the slope of the line and that of segment 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 //...If max slope diff. > 0.4 for R < 50.(> 0.3 for R < 50), remove it. 01245 if((R< 50. && max_diff_a > 0.4) || (R > 50. && max_diff_a > 0.3)) { 01246 01247 //...clear # of entries in the segement 01248 Nsgmnts[this_sly]=0; 01249 01250 //... remove the worst setment 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 //... fit again 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 //...Remove bad points... 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 //...Append hits, if the distance between the line and hits < 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 //...Remove bad points again... 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 //...Linear fit again... 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 //... Do we need quality cut? 01353 // if(newLine_chi2_3 > 10.) return NULL; 01354 01355 //...3D fit... 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 //...Set initial values 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 //...Refine... 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 //...Test it... 01383 if (! _trackSelector.select(track)) goto discard; 01384 01385 //...Termination... 01386 HepAListDeleteAll(forLine); 01387 return & track; 01388 01389 //...Something happened... 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 }
appends stereo hits to a track. (old version)
Definition at line 307 of file TBuilder0.cxx.
References TTrack::_helix, _lineSelector, _name, _trackSelector, TLine0::a(), Helix::a(), TTrackBase::append(), TTrack::charge(), Helix::curv(), Dump(), showlog::err, fit(), TTrackBase::fit(), TLine0::fit2p(), TLine0::fit2sp(), TTrack::helix(), genRecEmupikp::i, TMLink::leftRight(), genRecEmupikp::line, TMLink::link(), TTrackBase::links(), TMSelector::maxSigma(), TMSelector::nLinks(), TMSelector::nLinksStereo(), TMLink::position(), rb::R(), TTrackBase::refine(), TLine0::refine(), TLine0::removeChits(), TMSelector::select(), TTrack::szPosition(), t(), tr, WireHitLeft, and WireHitRight.
00307 { 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 //...Check # of links... 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 //...Calculate s and z for every links... 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 //...Assuming wire position... 00331 t->leftRight(2); 00332 int err = track.szPosition(* t); 00333 if (err) { 00334 delete t; 00335 continue; 00336 } 00337 00338 //...Store the sz link... 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 //...Check # of sz links... 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 //...Make a line... 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 //...Linear fit... 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 //...Decide Left or Right... 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 //...Check # of sz links... 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 //...Create new line... 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 //... Remove extremely bad points 00453 newLine.removeChits(); 00454 00455 //...Make a seed track again 00456 err = newLine.fit2sp(); 00457 if (err < 0) { 00458 err = newLine.fit2p(); 00459 if (err < 0) err = newLine.fit(); 00460 } 00461 00462 //...Linear fit... 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 //...Remove bad points... 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 //...Linear fit again... 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 //...3D fit... 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 //...Refine... 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 //...Test it... 00522 if (! _trackSelector.select(track)) { 00523 HepAListDeleteAll(forLine); 00524 HepAListDeleteAll(forNewLine); 00525 return NULL; 00526 } 00527 00528 //...Termination... 00529 HepAListDeleteAll(forLine); 00530 HepAListDeleteAll(forNewLine); 00531 return & track; 00532 }
Definition at line 1552 of file TBuilder0.cxx.
References abs, TMDCWireHit::drift(), TMLink::hit(), TMDCWire::layerId(), TMDCWire::localId(), s, TMDCWire::superLayerId(), and TMDCWireHit::wire().
01552 { 01553 01554 //...Check same layer ?... 01555 if(l.hit()->wire()->layerId() != s.hit()->wire()->layerId()) return -1; 01556 01557 //...Initialization... 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 //...Case by case... 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 //...O.K. 2 consective hits 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 //...O.K. 2 consective hits 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 //...O.K. 2 consective hits 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 //...fails 01650 return -50; 01651 }
int TBuilder0::checkHits | ( | unsigned | i, | |
unsigned | j, | |||
unsigned | k | |||
) | const [private] |
Definition at line 1432 of file TBuilder0.cxx.
Referenced by buildStereo().
01432 { 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 }
Definition at line 1654 of file TBuilder0.cxx.
References TMDCWire::consective(), TMDCWireHit::drift(), TMLink::hit(), TMDCWire::layer(), TMDCWire::layerId(), next, TMDCLayer::nWires(), s, and TMDCWireHit::wire().
Referenced by buildStereo().
01654 { 01655 01656 //...Diagonal length of a cell... 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 //...Check same layer ?... 01672 if (wire.layerId() != next.layerId()) return -1; 01673 01674 //...Are these consective ?... 01675 if (! wire.consective(next)) return -20; 01676 01677 //...Drift distance... 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 //...Distance check... 01685 if (ddist > 0.65 && 01686 ((ddist1 > 0.7 && ddist2 > 0.7) || (ddist1 > 0.95 || ddist2 > 0.95))) { 01687 01688 //...O.K. 2 consective hits 01689 if (ichg > 0) return 1; 01690 else return 0; 01691 } 01692 else { 01693 return -50; 01694 } 01695 }
void TBuilder0::dump | ( | const std::string & | message = std::string("") , |
|
const std::string & | prefix = std::string("") | |||
) | const |
int TBuilder0::fit | ( | TTrackBase & | ) | const [inline, virtual] |
fits a track using a private fitter.
Definition at line 143 of file TBuilder0.h.
References _fitter, and TCosmicFitter::fit().
Referenced by appendClusters(), buildRphi(), buildStereo(), buildStereo0(), TBuilderCurl::resetHelixFit(), salvage(), and salvageNormal().
const std::string & TBuilder0::name | ( | void | ) | const [inline] |
returns name.
Definition at line 137 of file TBuilder0.h.
References _name.
Referenced by TBuilderCosmic::buildStereo(), salvage(), and salvageNormal().
00137 { 00138 return _name; 00139 }
salvages links in a list. Used links will be removed from a list.
Definition at line 1479 of file TBuilder0.cxx.
References _salvageLevel, fit(), genRecEmupikp::i, name(), salvageNormal(), TMDCWireHit::state(), t(), TrackOldConformalFinder, WireHitConformalFinder, and WireHitUsed.
01479 { 01480 01481 // if (t.type() == TrackTypeNormal) { 01482 salvageNormal(t, hits); //Pt high enough; fromIP. 01483 return; 01484 // } 01485 //tmply for cosmic ray... 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 //...Hit loop... 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 //...Already used?... 01501 if (h.state() & WireHitUsed) continue; 01502 candidates.append(l); 01503 } 01504 01505 //...Try to append this hit... 01506 // t.appendByApproach(candidates, 10.); 01507 t.appendByApproach(candidates, _salvageLevel); 01508 fit(t); 01509 hits.remove(candidates); 01510 t.assign(WireHitConformalFinder); 01511 t.finder(TrackOldConformalFinder); 01512 // t.assign(WireHitConformalFinder, TrackOldConformalFinder); 01513 }
Definition at line 1516 of file TBuilder0.cxx.
References fit(), genRecEmupikp::i, name(), ORIGIN, TMDCWireHit::state(), t(), TrackOldConformalFinder, WireHitConformalFinder, WireHitUsed, and TMDCWireHit::xyPosition().
Referenced by salvage().
01516 { 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 //...Determine direction to salvage... 01527 const HepPoint3D & center = t.helix().center(); 01528 const HepVector3D a = ORIGIN - center; 01529 01530 //...Hit loop... 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 //...Already used?... 01538 if (h.state() & WireHitUsed) continue; 01539 candidates.append(l); 01540 } 01541 01542 //...Try to append this hit... 01543 t.appendByApproach(candidates, 30.); 01544 fit(t); 01545 hits.remove(candidates); 01546 t.assign(WireHitConformalFinder); 01547 t.finder(TrackOldConformalFinder); 01548 // t.assign(WireHitConformalFinder, TrackOldConformalFinder); 01549 }
void TBuilder0::selectHits | ( | AList< TMLink > & | list | ) | const [private] |
Definition at line 282 of file TBuilder0.cxx.
References _name, Dump(), genRecEmupikp::i, WireHitContinuous, and WireHitIsolated.
Referenced by buildRphi().
00282 { 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 /* if ((! (state & WireHitPatternLeft)) && 00292 (! (state & WireHitPatternRight))) { 00293 bad.append(list[i]); 00294 continue; 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 }
const TMSelector & TBuilder0::trackSelector | ( | const TMSelector & | ) | [virtual] |
sets a track selector.
Definition at line 1400 of file TBuilder0.cxx.
References _circleSelector, _lineSelector, _trackSelector, TMSelector::maxDistance(), TMSelector::maxImpact(), TMSelector::maxSigma(), TMSelector::minPt(), TMSelector::nLinks(), TMSelector::nLinksStereo(), and TMSelector::nSuperLayers().
01400 { 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 }
const TMSelector & TBuilder0::trackSelector | ( | void | ) | const [inline] |
returns a track selector.
Definition at line 131 of file TBuilder0.h.
References _trackSelector.
Referenced by TConformalFinder0::TConformalFinder0(), and TFastFinder::TFastFinder().
00131 { 00132 return _trackSelector; 00133 }
TMSelector TBuilder0::_circleSelector [protected] |
TCosmicFitter TBuilder0::_fitter [private] |
Reimplemented in TBuilderCosmic, and TBuilderCurl.
Definition at line 102 of file TBuilder0.h.
Referenced by fit().
TMSelector TBuilder0::_lineSelector [protected] |
Definition at line 110 of file TBuilder0.h.
Referenced by TBuilderCosmic::buildStereo(), buildStereo(), buildStereo0(), and trackSelector().
std::string TBuilder0::_name [private] |
Definition at line 100 of file TBuilder0.h.
Referenced by buildRphi(), buildStereo(), buildStereo0(), name(), and selectHits().
double TBuilder0::_salvageLevel [private] |
float TBuilder0::_stereoChisq3 [protected] |
float TBuilder0::_stereoChisq4 [protected] |
float TBuilder0::_stereoMaxSigma [protected] |
float TBuilder0::_stereoZ3 [protected] |
float TBuilder0::_stereoZ4 [protected] |
TMSelector TBuilder0::_trackSelector [protected] |
Definition at line 107 of file TBuilder0.h.
Referenced by appendClusters(), buildRphi(), TBuilderCosmic::buildStereo(), buildStereo(), buildStereo0(), and trackSelector().