/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Reconstruction/TrkReco/TrkReco-00-08-59-patch4-slc6tag/src/TFastFinder.cxx

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // $Id: TFastFinder.cxx,v 1.7 2010/03/31 09:58:59 liucy Exp $
00003 //-----------------------------------------------------------------------------
00004 // Filename : TFastFinder.cc
00005 // Section  : Tracking
00006 // Owner    : Yoshi Iwasaki
00007 // Email    : yoshihito.iwasaki@kek.jp
00008 //-----------------------------------------------------------------------------
00009 // Description : A class to find tracks with the conformal method.
00010 //               See http://bsunsrv1.kek.jp/~yiwasaki/tracking/
00011 //-----------------------------------------------------------------------------
00012 
00013 #include "TrkReco/TFastFinder.h"
00014 #include "TrkReco/TConformalFinder0.h"
00015 #include "TrkReco/TMLink.h"
00016 #include "TrkReco/THistogram.h"
00017 #include "TrkReco/TMDCUtil.h"
00018 #include "TrkReco/TTrack.h"
00019 
00020 TFastFinder::TFastFinder() : _builder("fast find builder", 30) {
00021     _selector.nLinks(4);
00022     _selector.nSuperLayers(2);
00023     _selector.minPt(0.05);
00024     _selector.maxImpact(100.);
00025     _selector.maxSigma(30.);
00026     _selector.nLinksStereo(3);
00027     _selector.maxDistance(30.);
00028     _builder.trackSelector(_selector);
00029 }
00030 
00031 TFastFinder::~TFastFinder() {
00032 }
00033 
00034 std::string
00035 TFastFinder::version(void) const {
00036     return "0.00";
00037 }
00038 
00039 void
00040 TFastFinder::dump(const std::string & msg, const std::string & pre) const {
00041     std::cout << pre;
00042     TFinderBase::dump(msg);
00043 }
00044 
00045 void
00046 TFastFinder::clear(void) {
00047     _axialHits.removeAll();
00048     _stereoHits.removeAll();
00049     HepAListDeleteAll(_axialLinks);
00050     HepAListDeleteAll(_stereoLinks);
00051 }
00052 
00053 int
00054 TFastFinder::doit(const AList<TMDCWireHit> & axialHits,
00055                   const AList<TMDCWireHit> & stereoHits,
00056                   AList<TTrack> & tracks) {
00057 
00058     //...Select good hits...
00059     selectHits2(axialHits, stereoHits);
00060 
00061     //...Conformal transformation with IP constraint...
00062     TConformalFinder0::conformalTransformationRphi(ORIGIN,
00063                                                    _axialHits,
00064                                                    _axialLinks);
00065     TConformalFinder0::conformalTransformationRphi(ORIGIN,
00066                                                    _stereoHits,
00067                                                    _stereoLinks);
00068 
00069     //...Make a histogram...
00070     THistogram hist(288);
00071     hist.fillX(_axialLinks);
00072     AList<TSegment0> clusters = hist.clusters0();
00073 
00074     //...Cluster loop...
00075     unsigned n = clusters.length();
00076     for (unsigned i = 0; i < n; i++) {
00077 
00078         //...2D track...
00079         TTrack * t = _builder.buildRphi(clusters[i]->links());
00080         if (t == NULL) continue;
00081 #ifdef TRKRECO_DEBUG_DETAIL
00082         std::cout << "TFastFinder::doit ... 2D track found" << std::endl;
00083 #endif
00084 
00085         //...Make it 3D...
00086         TTrack * ts = t;
00087         ts = _builder.buildStereo(* t,
00088                                   findCloseHits(_stereoLinks,
00089                                                 * t));
00090         if (ts == NULL) continue;
00091 #ifdef TRKRECO_DEBUG_DETAIL
00092         std::cout << "TFastFinder::doit ... 3D track found" << std::endl;
00093 #endif
00094 
00095         //...OK...
00096         t->assign(WireHitFastFinder);
00097         t->finder(TrackFastFinder);
00098 //      t->assign(WireHitFastFinder, TrackFastFinder);
00099         tracks.append(t);
00100         _stereoLinks.remove(t->links());
00101     }
00102 
00103     //...Termination...
00104     HepAListDeleteAll(clusters);
00105     return 0;
00106 }
00107 
00108 void
00109 TFastFinder::selectHits(const AList<TMDCWireHit> & axialHits,
00110                         const AList<TMDCWireHit> & stereoHits) {
00111     unsigned n = axialHits.length();
00112     for (unsigned i = 0; i < n; i++) {
00113         const TMDCWireHit & h = * axialHits[i];
00114         if ((h.state() & WireHitIsolated) && (h.state() & WireHitContinuous))
00115             _axialHits.append((TMDCWireHit &) h);
00116     }
00117     n = stereoHits.length();
00118     for (unsigned i = 0; i < n; i++) {
00119         const TMDCWireHit & h = * stereoHits[i];
00120         if ((h.state() & WireHitIsolated) && (h.state() & WireHitContinuous))
00121             _stereoHits.append((TMDCWireHit &) h);
00122     }
00123 }
00124 
00125 void
00126 TFastFinder::selectHits2(const AList<TMDCWireHit> & axialHits,
00127                          const AList<TMDCWireHit> & stereoHits) {
00128     selectSimpleSegments(axialHits, _axialHits);
00129     selectSimpleSegments(stereoHits, _stereoHits);
00130 }
00131 
00132 AList<TMLink>
00133 TFastFinder::findCloseHits(const AList<TMLink> & links,
00134                            const TTrack & track) const {
00135     //
00136     // Coded by J.Suzuki
00137     //
00138     AList<TMLink> list;
00139 
00140     //...Check condition...
00141     if (track.links().length() == 0) {
00142 #ifdef TRKRECO_DEBUG_DETAIL
00143         std::cout << "TConformalFinder::findCloseHits !!! ";
00144         std::cout << " no links found in a track : This should not be happened";
00145         std::cout << std::endl;
00146 #endif
00147 
00148         return list;
00149     }
00150 
00151     //...Parameters...
00152     //    float dRcut[11] = {0, 3.5, 0., 5.5, 0., 6.5, 0., 7.5, 0., 9.5, 0.};
00153     float dRcut[11] = {0., 4.3, 0., 6.5, 0., 7.5, 0., 8.0, 0., 9.5, 0.};
00154 
00155     //...Select Stereo hits associated to the current r-phi curve...
00156     double R0 = track.helix().curv();
00157     double xInnerWire = track.links()[0]->wire()->xyPosition().x();
00158     double yInnerWire = track.links()[0]->wire()->xyPosition().y();
00159     unsigned nall = links.length();
00160     for (unsigned j = 0; j < nall; j++) {
00161         TMLink & t = * links[j];
00162         const TMDCWire & w = * t.wire();
00163         HepVector3D X = w.xyPosition() - track.helix().center();
00164         double Rmag2 = X.mag2();
00165         double DR = fabs(sqrt(Rmag2) - fabs(R0));
00166         t.zStatus(-10);
00167         t.zPair(0);
00168         if (DR < dRcut[w.superLayerId()] &&
00169             (xInnerWire*w.xyPosition().x()+yInnerWire*w.xyPosition().y())>0.){
00170             list.append(t);
00171         }
00172     }
00173 
00174     return list;
00175 }
00176 
00177 void
00178 TFastFinder::selectSimpleSegments(const AList<TMDCWireHit> & in,
00179                                   AList<TMDCWireHit> & out) const {
00180     AList<TMDCWireHit> hits = in;
00181     while (hits.last()) {
00182         TMDCWireHit & h = * hits.last();
00183 
00184         //...Start clustering...
00185         // AList<TMDCWireHit> & cluster = * new AList<TMDCWireHit>();
00186         AList<TMDCWireHit> cluster;
00187         AList<TMDCWireHit> toBeChecked;
00188         bool ok = true;
00189         toBeChecked.append(h);
00190         while (toBeChecked.length()) {
00191             TMDCWireHit & a = * toBeChecked.last();
00192             toBeChecked.remove(a);
00193             if (cluster.hasMember(a)) continue;
00194 
00195             //...Check hit...
00196             unsigned state = a.state();
00197             if (! (state & WireHitIsolated)) ok = false;
00198             if (! (state & WireHitContinuous)) ok = false;
00199 
00200             //...Append...
00201             cluster.append(a);
00202 
00203             //...Neighbor hit...
00204             unsigned ptn = (state & WireHitNeighborPattern) >> 12;
00205             for (unsigned i = 0; i < 6; i++) {
00206                 if ((ptn >> i) % 2) {
00207                     const TMDCWireHit & b = * a.wire()->neighbor(i)->hit();
00208                     toBeChecked.append((TMDCWireHit &) b);
00209                 }
00210             }
00211         }
00212 
00213         //...Check cluster size...
00214         if ((cluster.length() < 4) || (cluster.length() > 8)) ok = false;
00215 
00216         //...OK. Good hits...
00217         if (ok) out.append(cluster);
00218 
00219         //...Remove cluster...
00220         hits.remove(cluster);
00221 
00222         //...For debug...
00223 #ifdef TRKRECO_DEBUG_DETAIL
00224         std::cout << "TFastFinder::selectSimpleSegment ... cluster : ok = ";
00225         std::cout << ok << " : ";
00226 #endif
00227         for (unsigned i = 0; i < cluster.length(); i++) {
00228             TMDCWireHit & h = * cluster[i];
00229 #ifdef TRKRECO_DEBUG_DETAIL
00230             std::cout << h.wire()->name() << ",";
00231 #endif
00232             if (! ok) {
00233                 unsigned state = h.state();
00234                 if (state & WireHitIsolated) state ^= WireHitIsolated;
00235                 if (state & WireHitContinuous) state ^= WireHitContinuous;
00236                 h.state(state);
00237             }
00238         }
00239 #ifdef TRKRECO_DEBUG_DETAIL
00240         std::cout << std::endl;
00241 #endif
00242 
00243     remove:
00244         hits.remove(h);
00245     }
00246 }

Generated on Tue Nov 29 23:14:15 2016 for BOSS_7.0.2 by  doxygen 1.4.7