TConformalFinder0 Class Reference

A class to find tracks with the conformal method. More...

#include <TConformalFinder0.h>

Inheritance diagram for TConformalFinder0:

TFinderBase List of all members.

Public Member Functions

 TConformalFinder0 (float maxSigma, float fraction, float stereoZ3, float stereoZ4, float stereoChisq3, float stereoChisq4, float stereoMaxSigma, unsigned fittingCorrections, float salvageLevel, bool cosmic)
 Constructor.
virtual ~TConformalFinder0 ()
 Destructor.
std::string name (void) const
 returns name.
std::string version (void) const
 returns version.
void dump (const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
 dumps debug information.
const AList< TMLink > & axialConformalLinks (void) const
 returns a list of conformal links.
const AList< TMLink > & stereoConformalLinks (void) const
 returns a list of conformal links.
void clear (void)
 clear internal information.
int doit (const AList< TMDCWireHit > &axialHits, const AList< TMDCWireHit > &stereoHits, AList< TTrack > &tracks, AList< TTrack > &tracks3D)
 finds tracks.
AList< AList< TSegment0 > > findSegments (const AList< TMLink > &in) const
 finds segments.
AList< AList< TSegment0 > > findSegments2 (const AList< TMLink > &in) const
AList< TSegment0findClusters (const THistogram &) const
 finds segments. (obsolete functions)
AList< TSegment0findClusters2 (const THistogram &) const
bool doStereo (bool)
 sets swtich for stereo reconstruction.
bool doSalvage (bool)
 sets switch for salvaging.
virtual int debugLevel (void) const
 returns debug level.
virtual int debugLevel (int)
 sets debug level.

Static Public Member Functions

static void conformalTransformation (const HepPoint3D &center, const AList< TMDCWireHit > &hits, AList< TMLink > &links)
 transforms hits into a conformal plane. 'center' is a center of the transformation. Z position of 'center' must be zero. Transformed positions are newly created, and are stored in 'links'.
static void conformalTransformationDriftCircle (const HepPoint3D &center, const AList< TMDCWireHit > &hits, AList< TMLink > &links)
 transforms drift circle of hits into a conformal plane. transformed positions( x0, y0, r) are stored in 'links'.
static void conformalTransformationRphi (const HepPoint3D &center, const AList< TMDCWireHit > &hits, AList< TMLink > &links)
 transforms hits into a conformal plane. 'center' is a center of the transformation. Z position of 'center' must be zero. Transformed positions are newly created, and are stored in 'links'.

Private Member Functions

AList< TMLinkfindCloseHits (const AList< TMLink > &in, const TTrack &track) const
 returns a list of links close to a track.
TSegment0findBestLink (const TSegment0 &, const AList< TSegment0 > &in) const
 returns a pointer to the best cluster to be linked.
TSegment0appendCluster (TTrack &track, AList< TSegment0 > &in) const
 appends the best cluster in 'list' to 'track'.
AList< TSegment0findClusterLink (TSegment0 &, const AList< TSegment0 > *const) const
 returns a list of clusters to be a track.
TTrackmakeTrack (const AList< TSegment0 > &) const
 makes a track.
void appendClusters2 (TTrack &track, AList< TSegment0 > &) const
 appends TMLinks in a list.
AList< TSegment0findCloseClusters (const TTrack &, const AList< TSegment0 > &, double maxDistance) const
 returns a list of clusters close to a cluster.
void standardFinding (AList< TMLink > &seeds, AList< TMLink > &unusedLinks, double fraction)
 main loop with salvaging.
void specialFinding (AList< TMLink > &seeds, AList< TMLink > &unusedLinks, double fraction)
 main loop with salvaging for second trial.

Private Attributes

TBuilder0_builder
 Track builder.
TMSelector _circleSelector
 Parameters.
TMSelector _trackSelector
float _fraction
AList< TMLink_axialConfLinks
 List of hit positions in the conformal plane.
AList< TMLink_stereoConfLinks
AList< TMLink_unusedAxialConfLinks
AList< TMLink_unusedStereoConfLinks
AList< TMLink_goodAxialConfLinks
AList< TCircle_circles
 Internal lists.
AList< TTrack_tracks
bool _doStereo
 Switches.
bool _doSalvage

Detailed Description

A class to find tracks with the conformal method.

Definition at line 40 of file TConformalFinder0.h.


Constructor & Destructor Documentation

TConformalFinder0::TConformalFinder0 ( float  maxSigma,
float  fraction,
float  stereoZ3,
float  stereoZ4,
float  stereoChisq3,
float  stereoChisq4,
float  stereoMaxSigma,
unsigned  fittingCorrections,
float  salvageLevel,
bool  cosmic 
)

Constructor.

Definition at line 33 of file TConformalFinder0.cxx.

References _builder, _trackSelector, TMSelector::maxDistance(), TMSelector::maxImpact(), TMSelector::maxSigma(), TMSelector::minPt(), TMSelector::nLinks(), TMSelector::nLinksStereo(), TMSelector::nSuperLayers(), and TBuilder0::trackSelector().

00043 : TFinderBase(),
00044   _builder(0),
00045   _doStereo(true),
00046   _doSalvage(true),  //liuqg
00047   _fraction(fraction) {
00048 
00049     //...Parameters for a track...
00050     _trackSelector.nLinks(4);
00051     _trackSelector.nSuperLayers(2);
00052     _trackSelector.minPt(0.05);
00053     _trackSelector.maxImpact(100.);
00054     _trackSelector.maxSigma(maxSigma);
00055     _trackSelector.nLinksStereo(3);
00056     _trackSelector.maxDistance(30.);
00057 
00058     //...Make a builder...
00059     if (cosmic) _builder = new TBuilderCosmic("cosmic builder", salvageLevel);
00060     else        _builder = new TBuilder0("conformal builder",
00061                                          stereoZ3,
00062                                          stereoZ4,
00063                                          stereoChisq3,
00064                                          stereoChisq4,
00065                                          stereoMaxSigma,
00066                                          fittingCorrections,
00067                                          salvageLevel);
00068 
00069     //...Set up TBuilder...
00070     _builder->trackSelector(_trackSelector);
00071 }

TConformalFinder0::~TConformalFinder0 (  )  [virtual]

Destructor.

Definition at line 73 of file TConformalFinder0.cxx.

References _builder.

00073                                       {
00074     delete _builder;
00075 }


Member Function Documentation

TSegment0 * TConformalFinder0::appendCluster ( TTrack track,
AList< TSegment0 > &  in 
) const [private]

appends the best cluster in 'list' to 'track'.

Definition at line 367 of file TConformalFinder0.cxx.

References _trackSelector, TSegment0::dump(), ganga-rec::j, TTrackBase::links(), TMSelector::maxSigma(), and t().

00367                                                                           {
00368 
00369     //...Candidate loop...
00370     unsigned n = list.length();
00371     TSegment0 * best = NULL;
00372     unsigned nBest = 0;
00373     for (unsigned j = 0; j < n; j++) {
00374         TSegment0 * c = list[j];
00375 
00376         unsigned nOk = t.testByApproach(c->links(),
00377                                         _trackSelector.maxSigma());
00378         if (nOk > nBest) {
00379             nBest = nOk;
00380             best = c;
00381         }
00382     }
00383 
00384     //...Try to append...
00385     if (best) {
00386 #ifdef TRKRECO_DEBUG_DETAIL
00387         std::cout << "    ... appending a cluster" << std::endl;
00388         best->dump("hits mc", "        ");
00389 #endif
00390         AList<TMLink> links(best->links());
00391         t.appendByApproach(links, _trackSelector.maxSigma());
00392         return best;
00393     }
00394 
00395     return NULL;
00396 }

void TConformalFinder0::appendClusters2 ( TTrack track,
AList< TSegment0 > &   
) const [private]

appends TMLinks in a list.

Definition at line 520 of file TConformalFinder0.cxx.

References _builder, TBuilder0::appendClusters(), dump(), findCloseClusters(), genRecEmupikp::i, name(), and TTrackBase::remove().

Referenced by specialFinding(), and standardFinding().

00521                                                                 {
00522 
00523 #ifdef TRKRECO_DEBUG_DETAIL
00524     std::cout << name() << " ... appending clusters remained" << std::endl;
00525     std::cout << "    clusters to be tested : " << std::endl;
00526     for (unsigned i = 0; i < list.length(); i++) {
00527         list[i]->dump("cluster hits mc", "        ");
00528     }
00529 #endif
00530 
00531     unsigned n = list.length();
00532     if (n == 0) return;
00533 
00534     AList<TSegment0> closer;
00535     closer.append(findCloseClusters(track, list, 1.));
00536 
00537 #ifdef TRKRECO_DEBUG_DETAIL
00538     std::cout << "    found clusters" << std::endl;
00539     for (unsigned i = 0; i < closer.length(); i++) {
00540         closer[i]->dump("cluster hits mc", "        ");
00541     }
00542 #endif
00543     n = closer.length();
00544     if (closer.length() == 0) return;
00545 
00546     //...Append them...
00547     AList<TMLink> candidates;
00548     for (unsigned i = 0; i < n; i++)
00549         candidates.append(closer[i]->links());
00550     _builder->appendClusters(track, candidates);
00551 
00552     //...Remove TMLinks from clusters...
00553     for (unsigned i = 0; i < n; i++) {
00554         closer[i]->TTrackBase::remove(track.links());
00555         if (closer[i]->nLinks() == 0) list.remove(closer[i]);
00556     }
00557 }

const AList< TMLink > & TConformalFinder0::axialConformalLinks ( void   )  const [inline]

returns a list of conformal links.

Definition at line 190 of file TConformalFinder0.h.

References _axialConfLinks.

00190                                                  {
00191     return _axialConfLinks;
00192 }

void TConformalFinder0::clear ( void   )  [virtual]

clear internal information.

Implements TFinderBase.

Definition at line 89 of file TConformalFinder0.cxx.

References _axialConfLinks, _circles, _goodAxialConfLinks, _stereoConfLinks, _tracks, _unusedAxialConfLinks, and _unusedStereoConfLinks.

00089                              {
00090     HepAListDeleteAll(_axialConfLinks);
00091     HepAListDeleteAll(_stereoConfLinks);
00092     _unusedAxialConfLinks.removeAll();
00093     _unusedStereoConfLinks.removeAll();
00094     _goodAxialConfLinks.removeAll();
00095     HepAListDeleteAll(_circles);
00096     _tracks.removeAll();
00097 }

void TConformalFinder0::conformalTransformation ( const HepPoint3D center,
const AList< TMDCWireHit > &  hits,
AList< TMLink > &  links 
) [static]

transforms hits into a conformal plane. 'center' is a center of the transformation. Z position of 'center' must be zero. Transformed positions are newly created, and are stored in 'links'.

Definition at line 100 of file TConformalFinder0.cxx.

References genRecEmupikp::i, and ORIGIN.

00102                                                                  {
00103 
00104     unsigned nHits = hits.length();
00105     if (center == ORIGIN) {
00106         for (unsigned i = 0; i < nHits; i++) {
00107             TMDCWireHit * h = hits[i];
00108             const HepPoint3D & p = h->xyPosition();
00109             
00110 //zsl       HepPoint3D cp(2. * p.x() / p.mag2(), 2. * p.y() / p.mag2());
00111             HepPoint3D cp(2. * p.x() / p.mag2(), 2. * p.y() / p.mag2(), 0.);
00112 //          std::cout<<" xypo "<<p<<" pos "<<cp<<std::endl;
00113             links.append(new TMLink(0, h, cp));
00114         }
00115     }
00116     else {
00117         for (unsigned i = 0; i < nHits; i++) {
00118             TMDCWireHit * h = hits[i];
00119             HepPoint3D p(h->xyPosition() - center);
00120             HepPoint3D cp(2. * p.x() / p.mag2(), 2. * p.y() / p.mag2(), 0.);
00121             links.append(new TMLink(0, h, cp));
00122         }       
00123     }
00124 }

void TConformalFinder0::conformalTransformationDriftCircle ( const HepPoint3D center,
const AList< TMDCWireHit > &  hits,
AList< TMLink > &  links 
) [static]

transforms drift circle of hits into a conformal plane. transformed positions( x0, y0, r) are stored in 'links'.

Definition at line 127 of file TConformalFinder0.cxx.

References genRecEmupikp::i, and ORIGIN.

Referenced by TConformalFinder::doit(), and TrkReco::execute().

00129                                                                              { //added by Liuqg for Tsf
00130     unsigned nHits = hits.length();
00131     if (center == ORIGIN) {
00132         for (unsigned i = 0; i < nHits; i++) {
00133             TMDCWireHit * h = hits[i];
00134             const HepPoint3D & p = h->xyPosition();
00135                                                                                                                              
00136             const double r = 0.5*(h->drift(0) + h->drift(1));
00137             HepPoint3D cp(2. * p.x() / p.mag2(), 2. * p.y() / p.mag2(), 0.);
00138 //          HepPoint3D cp2(100 * 2. * p.x() / (p.mag2() - r*r), 100 * 2. * p.y() / (p.mag2() - r*r), 0.);
00139             HepPoint3D cp2(2. * p.x() / (p.mag2() - r*r), 2. * p.y() / (p.mag2() - r*r), 0.);
00140 //          float cDrift = 100 * 2. * r / (p.mag2() - r*r);
00141             double cDrift = 2. * r / (p.mag2() - r*r);
00142                                                                                                                              
00143             links.append(new TMLink(0, h, cp, cp2, cDrift));
00144         }
00145     }
00146     else {
00147         for (unsigned i = 0; i < nHits; i++) {
00148             TMDCWireHit * h = hits[i];
00149             HepPoint3D p(h->xyPosition() - center);
00150                                                                                                                              
00151             const double r = 0.5*(h->drift(0) + h->drift(1));
00152             HepPoint3D cp(2. * p.x() / p.mag2(), 2. * p.y() / p.mag2(), 0.);
00153             //unit of the following is km-1, origin is cm.
00154 //          HepPoint3D cp2(100 * 2. * p.x() / (p.mag2() - r*r), 100 * 2. * p.y() / (p.mag2() - r*r), 0.);
00155             HepPoint3D cp2(2. * p.x() / (p.mag2() - r*r), 2. * p.y() / (p.mag2() - r*r), 0.);
00156 //          float cDrift = 100 * 2. * r / (p.mag2() - r*r);
00157             double cDrift = 2. * r / (p.mag2() - r*r);
00158                                                                                                                              
00159             links.append(new TMLink(0, h, cp, cp2, cDrift));
00160         }
00161     }
00162 }

void TConformalFinder0::conformalTransformationRphi ( const HepPoint3D center,
const AList< TMDCWireHit > &  hits,
AList< TMLink > &  links 
) [static]

transforms hits into a conformal plane. 'center' is a center of the transformation. Z position of 'center' must be zero. Transformed positions are newly created, and are stored in 'links'.

Definition at line 165 of file TConformalFinder0.cxx.

References genRecEmupikp::i, M_PI, and ORIGIN.

Referenced by TFastFinder::doit(), and doit().

00167                                                                      {
00168 
00169     unsigned nHits = hits.length();
00170     if (center == ORIGIN) {
00171         for (unsigned i = 0; i < nHits; i++) {
00172             TMDCWireHit * h = hits[i];
00173             const HepPoint3D & p = h->xyPosition();
00174             HepPoint3D cp(2. * p.x() / p.mag2(), 2. * p.y() / p.mag2(), 0.);
00175             double r = log(cp.mag()) + 4.;
00176             double phi = atan2(cp.y(), cp.x()) + M_PI;
00177             HepPoint3D cpt(phi, r, 0.);
00178             links.append(new TMLink(0, h, cpt));
00179         }
00180     }
00181     else {
00182         for (unsigned i = 0; i < nHits; i++) {
00183             TMDCWireHit * h = hits[i];
00184             HepPoint3D p(h->xyPosition() - center);
00185             HepPoint3D cp(2. * p.x() / p.mag2(), 2. * p.y() / p.mag2(), 0.);
00186             double r = log(cp.mag()) + 4.;
00187             double phi = atan2(cp.y(), cp.x()) + M_PI;
00188             HepPoint3D cpt(phi, r, 0.);
00189             links.append(new TMLink(0, h, cpt));
00190         }       
00191     }
00192 }

int TFinderBase::debugLevel ( int   )  [inline, virtual, inherited]

sets debug level.

Definition at line 96 of file TFinderBase.h.

References TFinderBase::_debugLevel.

00096                              {
00097     return _debugLevel = a;
00098 }

int TFinderBase::debugLevel ( void   )  const [inline, virtual, inherited]

returns debug level.

Definition at line 90 of file TFinderBase.h.

References TFinderBase::_debugLevel.

Referenced by doit(), TConformalFinder::doit(), TrkReco::initialize(), specialFinding(), and standardFinding().

00090                                   {
00091     return _debugLevel;
00092 }

int TConformalFinder0::doit ( const AList< TMDCWireHit > &  axialHits,
const AList< TMDCWireHit > &  stereoHits,
AList< TTrack > &  tracks,
AList< TTrack > &  tracks3D 
) [virtual]

finds tracks.

Implements TFinderBase.

Definition at line 560 of file TConformalFinder0.cxx.

References _axialConfLinks, _doSalvage, _fraction, _stereoConfLinks, _tracks, _unusedAxialConfLinks, _unusedStereoConfLinks, conformalTransformationRphi(), TFinderBase::debugLevel(), genRecEmupikp::i, name(), ORIGIN, specialFinding(), and standardFinding().

00563                                          {
00564 
00565     //...For debug...
00566     if (debugLevel()) {
00567         std::cout << name() << " ... processing" << std::endl;
00568         std::cout << "    axialHits=" << axialHits.length();
00569         std::cout << ",stereoHits=" << stereoHits.length();
00570         std::cout << ",tracks=" << tracks.length();
00571         std::cout << std::endl;
00572 
00573         if (debugLevel() > 1)
00574             std::cout << name() << " ... conformal transformation0" << std::endl;
00575     }
00576 
00577     //...Conformal transformation with IP constraint...
00578     conformalTransformationRphi(ORIGIN, axialHits, _axialConfLinks);
00579     conformalTransformationRphi(ORIGIN, stereoHits, _stereoConfLinks);
00580     _unusedAxialConfLinks.append(_axialConfLinks);
00581     _unusedStereoConfLinks.append(_stereoConfLinks);
00582     AList<TMLink> unusedConfLinks;
00583     if (_doSalvage) {
00584         unusedConfLinks.append(_axialConfLinks);
00585         unusedConfLinks.append(_stereoConfLinks);
00586     }
00587 
00588     //...For debug...
00589     if (debugLevel() > 1)
00590         std::cout << name() << " ... selecting good hits" << std::endl;
00591 
00592     //...Select good axial hits...
00593     AList<TMLink> goodHits;
00594     int nLinks = _axialConfLinks.length();
00595     for (unsigned i = 0; i < nLinks; i++) {
00596         TMLink * l = _axialConfLinks[i];
00597         const TMDCWireHit & h = * l->hit();
00598 //liuqg if ((h.state() & WireHitIsolated) &&
00599 //          (h.state() & WireHitContinuous))
00600             goodHits.append(l);
00601     }
00602     //...Main algorithm...
00603     standardFinding(goodHits, unusedConfLinks, _fraction);
00604 
00605     //...Main algorithm for second trial...
00606     specialFinding(goodHits, unusedConfLinks, _fraction);
00607 
00608     //...For debug...
00609     if (debugLevel()) {
00610         std::cout << name() << " ... processed : ";
00611         std::cout << "good hits=" << goodHits.length();
00612         std::cout << ",tracks=" << _tracks.length();
00613         std::cout << std::endl;
00614     }
00615 
00616     tracks.append(_tracks);
00617     return 0;
00618 }

bool TConformalFinder0::doSalvage ( bool   )  [inline, virtual]

sets switch for salvaging.

Reimplemented from TFinderBase.

Definition at line 208 of file TConformalFinder0.h.

References _doSalvage.

00208                                    {
00209     return _doSalvage = a;
00210 }

bool TConformalFinder0::doStereo ( bool   )  [inline, virtual]

sets swtich for stereo reconstruction.

Reimplemented from TFinderBase.

Definition at line 202 of file TConformalFinder0.h.

References _doStereo.

00202                                   {
00203     return _doStereo = a;
00204 }

void TConformalFinder0::dump ( const std::string message = std::string(""),
const std::string prefix = std::string("") 
) const [virtual]

dumps debug information.

Reimplemented from TFinderBase.

Definition at line 78 of file TConformalFinder0.cxx.

References _axialConfLinks, _stereoConfLinks, TFinderBase::dump(), and RealDBUtil::npos.

Referenced by appendClusters2(), findCloseClusters(), specialFinding(), and standardFinding().

00078                                                                           {
00079     std::cout << pre;
00080     TFinderBase::dump(msg);
00081     std::cout << pre;
00082     if (msg.find("state") != std::string::npos) {
00083         std::cout << "#axialConfPos=" << _axialConfLinks.length();
00084         std::cout << ",#stereoConfPos=" << _stereoConfLinks.length();
00085     }
00086 }

TSegment0 * TConformalFinder0::findBestLink ( const TSegment0 ,
const AList< TSegment0 > &  in 
) const [private]

returns a pointer to the best cluster to be linked.

Definition at line 324 of file TConformalFinder0.cxx.

References TSegment0::direction(), TSegment0::distance(), and ganga-rec::j.

Referenced by findClusterLink().

00325                                                                           {
00326     //...Parameters...
00327     double minAngle = 0.80;
00328     double maxDistance = 0.3;
00329 //    double minAngle = 0.40;
00330 //    double maxDistance = 0.5;
00331 
00332     //...Candidate loop...
00333     unsigned n = candidates.length();
00334     double minDistance = 999.;
00335     TSegment0 * best = NULL;
00336     for (unsigned j = 0; j < n; j++) {
00337         TSegment0 * current = candidates[j];
00338         if (current->nLinks() < 2) continue;
00339 
00340         float angle = base.direction().dot(current->direction());
00341 #ifdef TRKRECO_DEBUG_DETAIL
00342         current->dump("vector hits mc", "    ");
00343         std::cout << "        angle=" << angle;
00344         if (angle < minAngle) std::cout << std::endl;
00345 #endif
00346 //      cout<<"             angle = "<<angle<<endl;
00347 //      if(angle < 0.3) cout<<" base.direction(): "<<base.direction()
00348 //      <<"  current->direction(): "<<current->direction()<<endl;
00349         if (angle < minAngle) continue;
00350 
00351         float distance = base.distance(* current);
00352         if (distance < minDistance) {
00353             minDistance = distance;
00354             best = current;
00355         }
00356 #ifdef TRKRECO_DEBUG_DETAIL
00357         std::cout << ",dist=" << distance << std::endl;
00358 #endif
00359     }
00360 
00361 //    if (minDistance < maxDistance) return best;
00362     return best;
00363 //    return NULL;  //Liuqg.....
00364 }

AList< TSegment0 > TConformalFinder0::findCloseClusters ( const TTrack ,
const AList< TSegment0 > &  ,
double  maxDistance 
) const [private]

returns a list of clusters close to a cluster.

Definition at line 464 of file TConformalFinder0.cxx.

References Helix::center(), dump(), TTrack::helix(), genRecEmupikp::i, ganga-rec::j, TTrackBase::links(), name(), ORIGIN, and Helix::radius().

Referenced by appendClusters2().

00466                                                               {
00467 
00468     //...Cal. direction of rotation of track...
00469     double radius = fabs(track.helix().radius());
00470     const HepPoint3D & center = track.helix().center();
00471     int rotation =
00472         (center.cross(track.links()[0]->xyPosition()).z() > 0.) ? 1 : -1;
00473 
00474 #ifdef TRKRECO_DEBUG_DETAIL
00475     std::cout << name() << " ... finding close clusters:maxDistance=";
00476     std::cout << maxDistance << std::endl;
00477     std::cout << "    radius,center,rotation=" << radius << ",";
00478     std::cout << center << "," << rotation << std::endl;
00479 #endif
00480 
00481     //...Cluster loop...
00482     AList<TSegment0> close;
00483     unsigned n = list.length();
00484     for (unsigned i = 0; i < n; i++) {
00485         TSegment0 & c = * list[i];
00486 
00487         //...Cal. position of cluster in the real plane...
00488         HepPoint3D position(ORIGIN);
00489         unsigned m = c.links().length();
00490         for (unsigned j = 0; j < m; j++) {
00491             position += c.links()[j]->xyPosition();
00492         }
00493         position *= 1. / double(m);
00494 
00495 #ifdef TRKRECO_DEBUG_DETAIL
00496         c.dump("cluster hits mc", "    ");
00497         std::cout << "        position=" << position;
00498         std::cout << ",diff=" << (position - center).mag() - radius << std::endl;
00499 #endif
00500         //...Cal. distance to a track...
00501         HepVector3D diff = position - center;
00502         if ((diff.mag() - radius) < maxDistance) {
00503 
00504             //...Same side?...
00505             int direction = (center.cross(position).z() > 0.) ? 1 : -1;
00506             if (direction == rotation) close.append(c);
00507         }
00508     }
00509 
00510 #ifdef TRKRECO_DEBUG_DETAIL
00511     std::cout << "    found clusters" << std::endl;
00512     for (unsigned i = 0; i < close.length(); i++) {
00513         close[i]->dump("hits mc", "    ");
00514     }
00515 #endif
00516     return close;
00517 }

AList< TMLink > TConformalFinder0::findCloseHits ( const AList< TMLink > &  in,
const TTrack track 
) const [private]

returns a list of links close to a track.

Definition at line 277 of file TConformalFinder0.cxx.

References Helix::center(), Helix::curv(), TTrack::helix(), ganga-rec::j, TTrackBase::links(), t(), and w.

Referenced by specialFinding(), and standardFinding().

00278                                                             {
00279     //
00280     // Coded by J.Suzuki
00281     //
00282     AList<TMLink> list;
00283 
00284     //...Check condition...
00285     if (track.links().length() == 0) {
00286 #ifdef TRKRECO_DEBUG_DETAIL
00287         std::cout << "TConformalFinder0::findCloseHits !!! ";
00288         std::cout << " no links found in a track : This should not be happened";
00289         std::cout << std::endl;
00290 #endif
00291 
00292         return list;
00293     }
00294 
00295     //...Parameters...
00296     //    float dRcut[11] = {0, 3.5, 0., 5.5, 0., 6.5, 0., 7.5, 0., 9.5, 0.};
00297 //    float dRcut[11] = {0., 4.3, 0., 6.5, 0., 7.5, 0., 8.0, 0., 9.5, 0.};
00298     float dRcut[11] = {4.3, 6.5, 0., 0., 0., 7.5, 8.0, 9.5, 11.0, 0., 0.};  //Liuqg, Bes
00299 
00300     //...Select Stereo hits associated to the current r-phi curve...
00301     double R0 = track.helix().curv();
00302     double xInnerWire = track.links()[0]->wire()->xyPosition().x();
00303     double yInnerWire = track.links()[0]->wire()->xyPosition().y();
00304     unsigned nall = links.length();
00305     for (unsigned j = 0; j < nall; j++) {
00306         TMLink & t = * links[j];
00307         const TMDCWire & w = * t.wire();
00308         HepVector3D X = w.xyPosition() - track.helix().center();
00309         double Rmag2 = X.mag2();
00310         double DR = fabs(sqrt(Rmag2) - fabs(R0));
00311         t.zStatus(-10);
00312         t.zPair(0);
00313         if (DR < dRcut[w.superLayerId()] &&
00314             (xInnerWire*w.xyPosition().x()+yInnerWire*w.xyPosition().y())>0.){
00315             list.append(t);
00316         }
00317     }
00318 
00319     //cout<<"stereo hits: "<<list.length()<<endl;
00320     return list;
00321 }

AList< TSegment0 > TConformalFinder0::findClusterLink ( TSegment0 ,
const AList< TSegment0 > *  const 
) const [private]

returns a list of clusters to be a track.

Definition at line 399 of file TConformalFinder0.cxx.

References TSegment0::dump(), findBestLink(), TTrackBase::links(), name(), next, and TSegment0::position().

Referenced by specialFinding(), and standardFinding().

00400                                                                              {
00401 
00402 #ifdef TRKRECO_DEBUG_DETAIL
00403     std::cout << name() << " ... finding cluster linkage" << std::endl;
00404     if (base.links().length() == 0)
00405         std::cout << name() << " !!! base doesn't have any TMLink." << std::endl;
00406     std::cout << "... base cluster" << std::endl;
00407     base.dump("cluster hits mc", "  ->");
00408 #endif
00409 
00410     //...Preparation of return value...
00411     AList<TSegment0> seeds;
00412     seeds.append(base);
00413 
00414     //...Which super layer?...
00415 //    unsigned outerMost = (base.links())[0]->wire()->superLayerId() / 2;
00416     unsigned outerMost = (base.links())[0]->wire()->axialStereoLayerId() / 4;
00417 
00418     //...Inner super layer loop...
00419     int next = outerMost;
00420     TSegment0 * last = & base;
00421     while (next) {
00422         --next;
00423         const AList<TSegment0> & candidates = list[next];
00424         if (candidates.length() == 0) continue;
00425         
00426 #ifdef TRKRECO_DEBUG_DETAIL
00427         std::cout << "... clusters in super layer " << next << std::endl;
00428 #endif
00429 
00430         //...Find best match...
00431         TSegment0 * best = findBestLink(* last, candidates);
00432         if (best != NULL) {
00433             seeds.append(best);
00434             last = best;
00435 #ifdef TRKRECO_DEBUG_DETAIL
00436             std::cout << "  ->Best is ";
00437             std::cout << best->position() << " ";
00438             best->dump("hits mc");
00439 #endif
00440         }
00441     }
00442 
00443     return seeds;
00444 }

AList< TSegment0 > TConformalFinder0::findClusters ( const THistogram  )  const

finds segments. (obsolete functions)

Definition at line 195 of file TConformalFinder0.cxx.

References THistogram::clusters0(), genRecEmupikp::i, and ganga-rec::j.

Referenced by findSegments().

00195                                                              {
00196 
00197     //...Obtain raw clusters...
00198     AList<TSegment0> list = hist.clusters0();
00199     unsigned n = list.length();
00200     if (n == 0) return list;
00201 
00202 #ifdef TRKRECO_DEBUG_DETAIL
00203     // static TChecker chk0("clusters before splitting");
00204     // chk0.check(list);
00205     // chk0.dump("detail", "    ");
00206 #endif
00207 
00208     //...Examine each cluster...
00209     AList<TSegment0> splitted;
00210     for (unsigned i = 0; i < n; i++) {
00211         TSegment0 * c = list[i];
00212 
00213         AList<TSegment0> newClusters = c->split();
00214         if (newClusters.length() == 0) {
00215             c->solveDualHits();
00216             continue;
00217         }
00218 
00219         list.append(newClusters);
00220         splitted.append(c);
00221 #ifdef TRKRECO_DEBUG_DETAIL
00222         c->dump("hits", "    ");
00223         std::cout << "    ... splitted as" << std::endl;
00224         for (unsigned j = 0; j < newClusters.length(); j++) {
00225             std::cout << "    " << j << " : ";
00226             newClusters[j]->dump("hits");
00227         }
00228 #endif
00229     }
00230     list.remove(splitted);
00231     HepAListDeleteAll(splitted);
00232 
00233 #ifdef TRKRECO_DEBUG_DETAIL
00234     // static TChecker chk1("clusters after splitting");
00235     // chk1.check(list);
00236     // chk1.dump("detail", "    ");
00237 #endif
00238 
00239     return list;
00240 }

AList< TSegment0 > TConformalFinder0::findClusters2 ( const THistogram  )  const

Definition at line 243 of file TConformalFinder0.cxx.

References THistogram::clusters0(), genRecEmupikp::i, and type.

00243                                                               {
00244 
00245     //...Obtain raw clusters...
00246     AList<TSegment0> list = hist.clusters0();
00247     unsigned n = list.length();
00248     if (n == 0) return list;
00249 
00250 #ifdef TRKRECO_DEBUG_DETAIL
00251     // static TChecker chk0("clusters before splitting (2)");
00252     // chk0.check(list);
00253     // chk0.dump("detail", "    ");
00254 #endif
00255 
00256     //...Examine each cluster...
00257     for (unsigned i = 0; i < n; i++) {
00258         TSegment0 * c = list[i];
00259         unsigned type = c->clusterType();
00260 
00261         if ((type == 1) || (type == 2)) {
00262             c->dump("hits mc", "    ");
00263             c->solveDualHits();
00264         }
00265     }
00266 
00267 #ifdef TRKRECO_DEBUG_DETAIL
00268     // static TChecker chk1("clusters after splitting (2)");
00269     // chk1.check(list);
00270     // chk1.dump("detail", "    ");
00271 #endif
00272 
00273     return list;
00274 }

AList< AList< TSegment0 > > TConformalFinder0::findSegments ( const AList< TMLink > &  in  )  const

finds segments.

Definition at line 869 of file TConformalFinder0.cxx.

References Dump(), findClusters(), genRecEmupikp::i, and name().

Referenced by specialFinding(), and standardFinding().

00869                                                               {
00870     AList< AList<TSegment0> > a;
00871 
00872 #ifdef TRKRECO_DEBUG_DETAIL
00873     std::cout << name() << " ... finding segments : given hits =" << std::endl;
00874     Dump(in, "sort");
00875 #endif
00876 
00877     //...Create lists of links for each super layer...
00878     AList<TMLink> links[5];
00879     unsigned n = in.length();
00880     for (unsigned i = 0; i < n; i++) {
00881         TMLink & l = * in[i];
00882 //      links[l.wire()->superLayerId() / 2].append(l);
00883         links[l.wire()->axialStereoLayerId()/4].append(l);
00884     }
00885 
00886     //...Create phi hists and clusters for each super layer...
00887     THistogram * hist[5];
00888     hist[0] = new THistogram(76);
00889     hist[1] = new THistogram(100);
00890     hist[2] = new THistogram(128);
00891     hist[3] = new THistogram(256);
00892     hist[4] = new THistogram(288);
00893     for (unsigned i = 0; i < 5; i++) {
00894         hist[i]->fillX(links[i]);
00895         AList<TSegment0> * b = new AList<TSegment0>();
00896         a.append(b);
00897         b->append(findClusters(* hist[i]));
00898         delete hist[i];
00899     }
00900 
00901     return a;
00902 }

AList< AList<TSegment0> > TConformalFinder0::findSegments2 ( const AList< TMLink > &  in  )  const

TTrack * TConformalFinder0::makeTrack ( const AList< TSegment0 > &   )  const [private]

makes a track.

Definition at line 447 of file TConformalFinder0.cxx.

References _builder, TBuilder0::buildRphi(), genRecEmupikp::i, ganga-rec::j, and t().

Referenced by specialFinding(), and standardFinding().

00447                                                                 {
00448     AList<TMLink> links;
00449     for (unsigned i = 0; i < list.length(); i++) {
00450         const AList<TMLink> & tmp = list[i]->links();
00451         unsigned n = tmp.length();
00452         for (unsigned j = 0; j < n; j++) {
00453             if (tmp[j]->hit()->track()) continue;
00454             links.append(tmp[j]);
00455         }
00456     }
00457 
00458     TTrack * t = _builder->buildRphi(links);
00459 
00460     return t;
00461 }

std::string TConformalFinder0::name ( void   )  const [inline, virtual]

returns name.

Implements TFinderBase.

Definition at line 214 of file TConformalFinder0.h.

Referenced by appendClusters2(), doit(), findCloseClusters(), findClusterLink(), findSegments(), specialFinding(), and standardFinding().

00214                                   {
00215     return "Conformal Finder 0";
00216 }

void TConformalFinder0::specialFinding ( AList< TMLink > &  seeds,
AList< TMLink > &  unusedLinks,
double  fraction 
) [private]

main loop with salvaging for second trial.

Definition at line 749 of file TConformalFinder0.cxx.

References _builder, _doStereo, _tracks, _unusedStereoConfLinks, appendClusters2(), TBuilder0::buildStereo(), TFinderBase::debugLevel(), dump(), Dump(), findCloseHits(), findClusterLink(), findSegments(), genRecEmupikp::i, ganga-rec::j, makeTrack(), name(), NCoreLinks(), TTrackBase::remove(), t(), TrackOldConformalFinder, and WireHitConformalFinder.

Referenced by doit().

00751                                                   {
00752 #ifdef TRKRECO_DEBUG_DETAIL
00753     std::cout << name() << " ... standard finding with salvage : given hits :";
00754     Dump(list, "sort");
00755 #endif
00756 
00757     //...Find segments...
00758     AList< AList<TSegment0> > segments = findSegments(list);
00759     AList<TSegment0> segmentList[5];
00760     AList<TSegment0> original[5];
00761     for (unsigned i = 0; i < 5; i++) {
00762         segmentList[i] = * segments[i];
00763         original[i] = * segments[i];
00764     }
00765 
00766 #ifdef TRKRECO_DEBUG_DETAIL
00767     for (unsigned i = 0; i < 5; i++) {
00768         std::cout << "... clusters in super layer " << i << std::endl;
00769         for (unsigned j = 0; j < segmentList[i].length(); j++) {
00770             segmentList[i][j]->dump("", "    ");
00771             segmentList[i][j]->dump("hits mc", "      ");
00772         }
00773     }
00774 #endif
00775 
00776     //...Main loop...
00777     AList<TSegment0> retryList;
00778     unsigned outerMost = 4;
00779     while (outerMost) {
00780 
00781         while (TSegment0 * base = segmentList[outerMost][0]) {
00782 
00783             //...Get linked clusters...
00784             AList<TSegment0> clusters = findClusterLink(* base, segmentList);
00785 
00786         again:;
00787 
00788             //...Check # of clusters...
00789             if (clusters.length() < 2) {
00790                 segmentList[outerMost].remove(base);
00791                 continue;
00792             }
00793 
00794             //...Make a track...
00795             TTrack * t = makeTrack(clusters); // don't change 'clusters'
00796             if (t == NULL) {
00797                 clusters.remove(clusters.last());
00798                 goto again;
00799             }
00800 
00801             //...Check track quality...
00802             // double f = float(t->nLinks()) / float(nTLinks(clusters));
00803             double f = float(t->nCores()) / float(NCoreLinks(clusters));
00804             if (f < fraction) {
00805 #ifdef TRKRECO_DEBUG_DETAIL
00806                 std::cout << "... fraction too low:" << f << std::endl;
00807                 std::cout << "    retry later" << std::endl;
00808 #endif
00809                 delete t;
00810                 clusters.remove(clusters.last());
00811                 goto again;
00812             }
00813 
00814             //...Append other hits...
00815             appendClusters2(* t, retryList);
00816 
00817             //...Make it 3D...
00818             
00819             TTrack * ts = t;
00820             if (_doStereo) {
00821                 ts = _builder->buildStereo(* t,
00822                           findCloseHits(_unusedStereoConfLinks, * t));
00823             }
00824 
00825             //...Check track quality...
00826             if (! ts) {
00827                 clusters.remove(clusters.last());
00828                 delete t;
00829                 goto again;
00830             }
00831 
00832             //...Salvaging...
00833 //          _builder->salvage(* t, unusedLinks);
00834 
00835             //...OK...
00836             t->assign(WireHitConformalFinder);
00837             t->finder(TrackOldConformalFinder);
00838 //                    TrackOldConformalFinder | TrackValid | Track3D);
00839             _tracks.append(t);
00840 
00841             //...Remove used links...
00842             const AList<TMLink> & usedLinks = t->links();
00843             list.remove(usedLinks);
00844             unusedLinks.remove(usedLinks);
00845             _unusedStereoConfLinks.remove(usedLinks);
00846             for (unsigned i = 0; i <= outerMost; i++)
00847                 segmentList[i].remove(clusters);
00848 
00849             //...For debug...
00850             if (debugLevel() > 1) {
00851                 std::cout << name() << " ... track # " << _tracks.length() - 1;
00852                 std::cout << " found" << std::endl;
00853                 t->dump("detail", "    ");
00854             }
00855         }
00856 
00857         //...Loop termination...
00858         --outerMost;
00859     }
00860 
00861     //...Termination...
00862     for (unsigned i = 0; i < 5; i++) {
00863         HepAListDeleteAll(original[i]);
00864         delete segments[i];
00865     }
00866 }

void TConformalFinder0::standardFinding ( AList< TMLink > &  seeds,
AList< TMLink > &  unusedLinks,
double  fraction 
) [private]

main loop with salvaging.

Definition at line 621 of file TConformalFinder0.cxx.

References _builder, _doStereo, _tracks, _unusedStereoConfLinks, TTrackBase::append(), appendClusters2(), TBuilder0::buildStereo(), TFinderBase::debugLevel(), dump(), Dump(), findCloseHits(), findClusterLink(), findSegments(), genRecEmupikp::i, ganga-rec::j, makeTrack(), name(), NCoreLinks(), t(), TrackOldConformalFinder, and WireHitConformalFinder.

Referenced by doit().

00623                                                    {
00624 #ifdef TRKRECO_DEBUG_DETAIL
00625     std::cout << name() << " ... standard finding with salvage : given hits :";
00626     Dump(list, "sort");
00627 #endif
00628 
00629     //...Find segments...
00630     AList< AList<TSegment0> > segments = findSegments(list);
00631     AList<TSegment0> segmentList[5];
00632     AList<TSegment0> original[5];
00633     for (unsigned i = 0; i < 5; i++) {
00634         segmentList[i] = * segments[i];
00635         original[i] = * segments[i];
00636 //      cout<< " segment: " << i << " : " << segmentList[i].length() << endl;
00637 //      for (unsigned j = 0; j < segmentList[i].length(); j++)
00638 //        cout<<"links in seg: "<<segmentList[i][j]->nLinks()<<endl;
00639     }
00640 
00641 #ifdef TRKRECO_DEBUG_DETAIL
00642     for (unsigned i = 0; i < 5; i++) {
00643         std::cout << "... clusters in super layer " << i << std::endl;
00644         for (unsigned j = 0; j < segmentList[i].length(); j++) {
00645             segmentList[i][j]->dump("", "    ");
00646             segmentList[i][j]->dump("hits mc", "      ");
00647         }
00648     }
00649 #endif
00650 
00651     //...Main loop...
00652     AList<TSegment0> retryList;
00653     AList<TTrack> salvageList;
00654     unsigned outerMost = 4;
00655     while (outerMost) {
00656 
00657         while (TSegment0 * base = segmentList[outerMost][0]) {
00658 
00659             //...Get linked clusters...
00660             AList<TSegment0> clusters = findClusterLink(* base, segmentList);
00661 
00662             //...Make a track...
00663             TTrack * t = makeTrack(clusters); // don't change 'clusters'
00664             if (t == NULL) {
00665                 retryList.append(base);
00666                 segmentList[outerMost].remove(base);
00667                 continue;
00668             }
00669 
00670             //...Check track quality...
00671             // double f = float(t->nLinks()) / float(nTLinks(clusters));
00672             double f = float(t->nCores()) / float(NCoreLinks(clusters));
00673             if (f < fraction) {
00674 #ifdef TRKRECO_DEBUG_DETAIL
00675                 std::cout << "... fraction too low:" << f << std::endl;
00676                 std::cout << "    used cores=" << t->nCores();
00677                 std::cout << ", candidate cores=" << NCoreLinks(clusters);
00678                 std::cout << " ... retry later" << std::endl;
00679 #endif
00680                 retryList.append(base);
00681                 segmentList[outerMost].remove(base);
00682                 delete t;
00683                 continue;
00684             }
00685 
00686             //...Append other hits...
00687             appendClusters2(* t, retryList);
00688 
00689 #ifdef TRKRECO_DEBUG_DETAIL
00690             std::cout << name() << " ... 2D result :" << std::endl;
00691             t->dump("detail", "    ");
00692 #endif
00693 
00694             //...Make it 3D...
00695             TTrack * ts = t;
00696             if (_doStereo) {
00697                 ts = _builder->buildStereo(* t,
00698                           findCloseHits(_unusedStereoConfLinks, * t));
00699             }
00700 
00701             //...Check track quality...
00702             if (! ts) {
00703 #ifdef TRKRECO_DEBUG_DETAIL
00704                 std::cout << "... failed to make a track 3D" << std::endl;
00705 #endif
00706                 retryList.append(base);
00707                 segmentList[outerMost].remove(base);
00708                 delete t;
00709                 continue;
00710             }
00711 
00712             //...Salvaging...
00713 //          _builder->salvage(* t, unusedLinks);
00714 
00715             //...OK...
00716             t->assign(WireHitConformalFinder);
00717             t->finder(TrackOldConformalFinder);
00718 //                    TrackOldConformalFinder | TrackValid | Track3D);
00719             _tracks.append(t);
00720 
00721             //...Remove used links...
00722             const AList<TMLink> & usedLinks = t->links();
00723             list.remove(usedLinks);
00724             unusedLinks.remove(usedLinks);
00725             _unusedStereoConfLinks.remove(usedLinks);
00726             for (unsigned i = 0; i <= outerMost; i++)
00727                 segmentList[i].remove(clusters);
00728 
00729             //...For debug...
00730             if (debugLevel() > 1) {
00731                 std::cout << name() << " ... track # " << _tracks.length() - 1;
00732                 std::cout << " found" << std::endl;
00733                 t->dump("detail", "    ");
00734             }
00735         }
00736 
00737         //...Loop termination...
00738         --outerMost;
00739     }
00740 
00741     //...Termination...
00742     for (unsigned i = 0; i < 5; i++) {
00743         HepAListDeleteAll(original[i]);
00744         delete segments[i];
00745     }
00746 }

const AList< TMLink > & TConformalFinder0::stereoConformalLinks ( void   )  const [inline]

returns a list of conformal links.

Definition at line 196 of file TConformalFinder0.h.

References _stereoConfLinks.

00196                                                   {
00197     return _stereoConfLinks;
00198 }

std::string TConformalFinder0::version ( void   )  const [virtual]

returns version.

Implements TFinderBase.

Definition at line 29 of file TConformalFinder0.cxx.

00029                                      {
00030     return "1.63";
00031 }


Member Data Documentation

AList<TMLink> TConformalFinder0::_axialConfLinks [private]

List of hit positions in the conformal plane.

Definition at line 162 of file TConformalFinder0.h.

Referenced by axialConformalLinks(), clear(), doit(), and dump().

TBuilder0* TConformalFinder0::_builder [private]

Track builder.

Definition at line 154 of file TConformalFinder0.h.

Referenced by appendClusters2(), makeTrack(), specialFinding(), standardFinding(), TConformalFinder0(), and ~TConformalFinder0().

AList<TCircle> TConformalFinder0::_circles [private]

Internal lists.

Definition at line 169 of file TConformalFinder0.h.

Referenced by clear().

TMSelector TConformalFinder0::_circleSelector [private]

Parameters.

Definition at line 157 of file TConformalFinder0.h.

bool TConformalFinder0::_doSalvage [private]

Definition at line 174 of file TConformalFinder0.h.

Referenced by doit(), and doSalvage().

bool TConformalFinder0::_doStereo [private]

Switches.

Definition at line 173 of file TConformalFinder0.h.

Referenced by doStereo(), specialFinding(), and standardFinding().

float TConformalFinder0::_fraction [private]

Definition at line 159 of file TConformalFinder0.h.

Referenced by doit().

AList<TMLink> TConformalFinder0::_goodAxialConfLinks [private]

Definition at line 166 of file TConformalFinder0.h.

Referenced by clear().

AList<TMLink> TConformalFinder0::_stereoConfLinks [private]

Definition at line 163 of file TConformalFinder0.h.

Referenced by clear(), doit(), dump(), and stereoConformalLinks().

AList<TTrack> TConformalFinder0::_tracks [private]

Definition at line 170 of file TConformalFinder0.h.

Referenced by clear(), doit(), specialFinding(), and standardFinding().

TMSelector TConformalFinder0::_trackSelector [private]

Definition at line 158 of file TConformalFinder0.h.

Referenced by appendCluster(), and TConformalFinder0().

AList<TMLink> TConformalFinder0::_unusedAxialConfLinks [private]

Definition at line 164 of file TConformalFinder0.h.

Referenced by clear(), and doit().

AList<TMLink> TConformalFinder0::_unusedStereoConfLinks [private]

Definition at line 165 of file TConformalFinder0.h.

Referenced by clear(), doit(), specialFinding(), and standardFinding().


Generated on Tue Nov 29 23:35:58 2016 for BOSS_7.0.2 by  doxygen 1.4.7