Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

TMLine Class Reference

A class to represent a track in tracking. More...

#include <TMLine.h>

Inheritance diagram for TMLine:

TTrackBase TTrackBase List of all members.

Public Member Functions

double a (void) const
 returns coefficient a.
double a (void) const
 returns coefficient a.
void append (const AList< TMLink > &)
 appends TMLinks.
void append (TMLink &)
 appends a TMLink.
void append (const AList< TMLink > &)
 appends TMLinks.
void append (TMLink &)
 appends a TMLink.
void appendByApproach (AList< TMLink > &list, double maxSigma)
 appends TMLinks by approach. 'list' is an input. Unappended TMLinks will be removed from 'list' when returned.
void appendByApproach (AList< TMLink > &list, double maxSigma)
 appends TMLinks by approach. 'list' is an input. Unappended TMLinks will be removed from 'list' when returned.
void appendByDistance (AList< TMLink > &list, double maxDistance)
 appends TMLinks by distance. 'list' is an input. Unappended TMLinks will be removed from 'list' when returned.
void appendByDistance (AList< TMLink > &list, double maxDistance)
 appends TMLinks by distance. 'list' is an input. Unappended TMLinks will be removed from 'list' when returned.
void appendByszdistance (AList< TMLink > &list, unsigned isl, float maxSigma)
void appendByszdistance (AList< TMLink > &list, unsigned isl, float maxSigma)
void appendSLY (AList< TMLink > &list)
void appendSLY (AList< TMLink > &list)
virtual int approach (TMLink &) const
 calculates the closest approach to a wire in real space. Results are stored in TMLink. Return value is negative if error happened.
virtual int approach (TMLink &) const
 calculates the closest approach to a wire in real space. Results are stored in TMLink. Return value is negative if error happened.
double b (void) const
 returns coefficient b.
double b (void) const
 returns coefficient b.
double chi2 (void) const
 returns chi2.
double chi2 (void) const
 returns chi2.
const AList< TMLink > & cores (unsigned mask=0) const
 returns a list of masked TMLinks for fit. 'mask' will be applied if mask is not 0.
const AList< TMLink > & cores (unsigned mask=0) const
 returns a list of masked TMLinks for fit. 'mask' will be applied if mask is not 0.
double distance (const HepPoint3D &) const
double distance (const TMLink &) const
 returns distance to a position of TMLink itself. (not to a wire)
double distance (const HepPoint3D &) const
double distance (const TMLink &) const
 returns distance to a position of TMLink itself. (not to a wire)
void dump (const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
 dumps debug information.
void dump (const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
 dumps debug information.
void falseFit ()
 false Fit
void falseFit ()
 false Fit
virtual int fit (void)
 fits itself by a default fitter. Error was happened if return value is not zero.
virtual int fit (void)
 fits itself by a default fitter. Error was happened if return value is not zero.
int fit2 ()
 fits itself using isolated hits. Error was happened if return value is not zero.
int fit2 ()
 fits itself using isolated hits. Error was happened if return value is not zero.
int fit2p ()
 fits itself using isolated hits. Error was happened if return value is not zero.
int fit2p ()
 fits itself using isolated hits. Error was happened if return value is not zero.
int fit2s ()
 fits itself using single hits in a wire-layer. Error was happened if return value is not zero.
int fit2s ()
 fits itself using single hits in a wire-layer. Error was happened if return value is not zero.
int fit2sp ()
 fits itself using single hits in a wire-layer. Error was happened if return value is not zero.
int fit2sp ()
 fits itself using single hits in a wire-layer. Error was happened if return value is not zero.
bool fitted (void) const
 returns true if fitted.
bool fitted (void) const
 returns true if fitted.
bool fittedWithCathode (void) const
 returns true if fitted with cathode hits(TEMPORARY).
bool fittedWithCathode (void) const
 returns true if fitted with cathode hits(TEMPORARY).
const TMFitter *const fitter (const TMFitter *)
 sets a default fitter.
const TMFitter *const fitter (void) const
 returns a pointer to a default fitter.
const TMFitter *const fitter (const TMFitter *)
 sets a default fitter.
const TMFitter *const fitter (void) const
 returns a pointer to a default fitter.
const TTrackHEP *const hep (void) const
 returns TTrackHEP.
const TTrackHEP *const hep (void) const
 returns TTrackHEP.
const AList< TMLink > & links (unsigned mask=0) const
 returns a list of masked TMLinks assigned to this track. 'mask' will be applied if mask is not 0.
const AList< TMLink > & links (unsigned mask=0) const
 returns a list of masked TMLinks assigned to this track. 'mask' will be applied if mask is not 0.
const TTrackMC *const mc (void) const
 returns a pointer to TTrackMC.
const TTrackMC *const mc (void) const
 returns a pointer to TTrackMC.
unsigned nCores (unsigned mask=0) const
 returns # of masked TMLinks for fit. 'mask' will be applied if mask is not 0.
unsigned nCores (unsigned mask=0) const
 returns # of masked TMLinks for fit. 'mask' will be applied if mask is not 0.
unsigned nHeps (void) const
 returns # of contributed TTrackHEP tracks.
unsigned nHeps (void) const
 returns # of contributed TTrackHEP tracks.
unsigned nLinks (unsigned mask=0) const
 returns # of masked TMLinks assigned to this track object.
unsigned nLinks (unsigned mask=0) const
 returns # of masked TMLinks assigned to this track object.
virtual unsigned objectType (void) const
 returns type.
virtual unsigned objectType (void) const
 returns type.
TMLinkoperator[] (unsigned i) const
TMLinkoperator[] (unsigned i) const
void property (double a, double b, double det)
 sets circle properties.
void property (double a, double b, double det)
 sets circle properties.
double reducedChi2 (void) const
 returns reduced-chi2.
double reducedChi2 (void) const
 returns reduced-chi2.
virtual void refine (double maxSigma)
 removes bad points by pull. The bad points are masked not to be used in fit.
virtual void refine (AList< TMLink > &list, double maxSigma)
 removes bad points by pull. The bad points are removed from the track, and are returned in 'list'.
void refine (AList< TMLink > &list, float maxSigma)
 remove bad points by chi2. Bad points are returned in a 'list'. fit() should be called before calling this function.
void refine (AList< TMLink > &list, float maxSigma)
 remove bad points by chi2. Bad points are returned in a 'list'. fit() should be called before calling this function.
void remove (const AList< TMLink > &)
 removes TMLinks.
void remove (TMLink &a)
 removes a TMLink.
void remove (const AList< TMLink > &)
 removes TMLinks.
void remove (TMLink &a)
 removes a TMLink.
void removeChits ()
 remove extremly bad points.
void removeChits ()
 remove extremly bad points.
virtual void removeLinks (void)
virtual void removeLinks (void)
void removeSLY (AList< TMLink > &list)
void removeSLY (AList< TMLink > &list)
unsigned testByApproach (const AList< TMLink > &list, double sigma) const
unsigned testByApproach (const TMLink &list, double sigma) const
 returns # of good hits to be appended.
unsigned testByApproach (const AList< TMLink > &list, double sigma) const
unsigned testByApproach (const TMLink &list, double sigma) const
 returns # of good hits to be appended.
 TMLine (const AList< TMLink > &)
 Constructor.
 TMLine ()
 Constructor.
 TMLine (const AList< TMLink > &)
 Constructor.
 TMLine ()
 Constructor.
virtual unsigned type (void) const
 returns type. Definition is depending on an object class.
virtual unsigned type (void) const
 returns type. Definition is depending on an object class.
void update (void) const
 update cache.
void update (void) const
 update cache.
virtual ~TMLine ()
 Destructor.
virtual ~TMLine ()
 Destructor.

Protected Attributes

bool _fitted
bool _fittedWithCathode
AList< TMLink_links
AList< TMLink_links
TTrackMC_mc
TTrackMC_mc

Private Attributes

double _a
double _b
double _chi2
double _det
bool _fittedUpdated
double _reducedChi2

Static Private Attributes

const TLineFitter _fitter = TLineFitter("TMLine Default Line Fitter")

Detailed Description

A class to represent a track in tracking.


Constructor & Destructor Documentation

TMLine::TMLine  ) 
 

Constructor.

00024 : TTrackBase(),
00025   _a(0.),
00026   _b(0.),
00027   _det(0.),
00028   _fittedUpdated(false),
00029   _chi2(0.),
00030   _reducedChi2(0.) {
00031 
00032     //...Set a defualt fitter...
00033     fitter(& TMLine::_fitter);
00034 }

TMLine::TMLine const AList< TMLink > &   ) 
 

Constructor.

00037 : TTrackBase(a),
00038   _a(0.),
00039   _b(0.),
00040   _det(0.),
00041   _fittedUpdated(false),
00042   _chi2(0.),
00043   _reducedChi2(0.) {
00044 
00045     //...Set a defualt fitter...
00046     fitter(& TMLine::_fitter);
00047 }

TMLine::~TMLine  )  [virtual]
 

Destructor.

00049                 {
00050 }

TMLine::TMLine  ) 
 

Constructor.

TMLine::TMLine const AList< TMLink > &   ) 
 

Constructor.

virtual TMLine::~TMLine  )  [virtual]
 

Destructor.


Member Function Documentation

double TMLine::a void   )  const
 

returns coefficient a.

double TMLine::a void   )  const [inline]
 

returns coefficient a.

00147                     {
00148 #ifdef TRKRECO_DEBUG
00149     if (! _fitted) std::cout << "TMLine::a !!! fit not performed" << std::endl;
00150 #endif
00151     return _a;
00152 }

void TTrackBase::append const AList< TMLink > &   )  [inherited]
 

appends TMLinks.

void TTrackBase::append TMLink  )  [inherited]
 

appends a TMLink.

void TTrackBase::append const AList< TMLink > &   )  [inherited]
 

appends TMLinks.

00357                                           {
00358     AList<TMLink> tmp;
00359     for (unsigned i = 0; i < a.length(); i++) {
00360         if ((_links.hasMember(a[i])) || (a[i]->hit()->state() & WireHitUsed)) {
00361 #ifdef TRKRECO_DEBUG_DETAIL
00362             std::cout << "    TTrackBase::append(list) !!! ";
00363             std::cout << a[i]->wire()->name();
00364             std::cout << " Hey!, this is already used! Don't mess with me.";
00365             std::cout << std::endl;
00366 #endif
00367             continue;
00368         }
00369         else {
00370             tmp.append(a[i]);
00371         }
00372     }
00373     _links.append(tmp);
00374     _updated = false;
00375     _fitted = false;
00376     _fittedWithCathode = false; // added by matsu ( 1999/05/24 )
00377 }

void TTrackBase::append TMLink  )  [inherited]
 

appends a TMLink.

00335                              {
00336     if ((a.hit()->state() & WireHitUsed)) {
00337 #ifdef TRKRECO_DEBUG_DETAIL
00338         std::cout << "TTrackBase::append !!! " << a.wire()->name()
00339                   << " this is already used by another track!" << std::endl;
00340 #endif
00341         return;
00342     }
00343     if (_links.hasMember(a)) {
00344 #ifdef TRKRECO_DEBUG_DETAIL
00345         std::cout << "TTrackBase::append !!! " << a.wire()->name()
00346                   << " this is already included in this track!" << std::endl;
00347 #endif
00348         return;
00349     }
00350     _links.append(a);
00351     _updated = false;
00352     _fitted = false;
00353     _fittedWithCathode = false; // added by matsu ( 1999/05/24 )
00354 }

void TTrackBase::appendByApproach AList< TMLink > &  list,
double  maxSigma
[inherited]
 

appends TMLinks by approach. 'list' is an input. Unappended TMLinks will be removed from 'list' when returned.

void TTrackBase::appendByApproach AList< TMLink > &  list,
double  maxSigma
[inherited]
 

appends TMLinks by approach. 'list' is an input. Unappended TMLinks will be removed from 'list' when returned.

00101                                                                   {
00102 #ifdef TRKRECO_DEBUG_DETAIL
00103     std::cout << "    TTrackBase::appendByApproach ... sigma=" << maxSigma << std::endl;
00104 #endif
00105 
00106     AList<TMLink> unused;
00107     unsigned n = list.length();
00108     for (unsigned i = 0; i < n; i++) {
00109         TMLink & l = * list[i];
00110 
00111         if ((_links.hasMember(l)) || (l.hit()->state() & WireHitUsed))
00112             continue;
00113 
00114         //...Calculate closest approach...
00115         int err = approach(l);
00116         if (err < 0) {
00117             unused.append(l);
00118             continue;
00119         }
00120 
00121         //...Calculate sigma...
00122         float distance = (l.positionOnWire() - l.positionOnTrack()).mag();
00123         float diff = fabs(distance - l.drift());
00124         float sigma = diff / l.dDrift();
00125 
00126         //...For debug...
00127 #ifdef TRKRECO_DEBUG_DETAIL
00128         std::cout << "    sigma=" << sigma;
00129         std::cout << ",dist=" << distance;
00130         std::cout << ",diff=" << diff;
00131         std::cout << ",err=" << l.hit()->dDrift() << ",";
00132         if (sigma < maxSigma) std::cout << "ok,";
00133         else                  std::cout << "X,";
00134         l.dump("mc");
00135 #endif
00136                 
00137         //...Make sigma cut...
00138         if (sigma > maxSigma) {
00139             unused.append(l);
00140             continue;
00141         }
00142 
00143         //...OK...
00144         _links.append(l);
00145         _updated = false;
00146         _fitted = false;
00147     }
00148     list.remove(unused);
00149 }

void TTrackBase::appendByDistance AList< TMLink > &  list,
double  maxDistance
[inherited]
 

appends TMLinks by distance. 'list' is an input. Unappended TMLinks will be removed from 'list' when returned.

void TTrackBase::appendByDistance AList< TMLink > &  list,
double  maxDistance
[inherited]
 

appends TMLinks by distance. 'list' is an input. Unappended TMLinks will be removed from 'list' when returned.

00152                                                                {
00153     std::cout << "TTrackBase::appendByDistance !!! not implemented" << std::endl;
00154     list.removeAll();
00155 }

void TMLine::appendByszdistance AList< TMLink > &  list,
unsigned  isl,
float  maxSigma
 

void TMLine::appendByszdistance AList< TMLink > &  list,
unsigned  isl,
float  maxSigma
 

00566                                                                              {
00567 
00568     //... intialize
00569     unsigned nb = _links.length();
00570     
00571     //....Select good hit
00572     unsigned n = list.length();
00573     for (unsigned i = 0; i < n; i++) {
00574         TMLink & l = * list[i];
00575         if(l.hit()->wire()->superLayerId() == isl){
00576           double dist = distance(l);
00577           if (dist < maxSigma) {
00578             _links.append(l);
00579           }
00580         }
00581     }
00582 
00583     unsigned na = _links.length();
00584     if(nb != na){
00585       AList<TMLink> bad;
00586       //... remove duplicated hits
00587       for(unsigned i = 0; i<na ;i++){
00588          TMLink & l = * _links[i];
00589          if(i < na - 1) {
00590            TMLink & lnext = * _links[i+1];
00591            if(l.hit()->wire()->layerId() == lnext.hit()->wire()->layerId() ){
00592              if(l.hit()->wire()->localId() == lnext.hit()->wire()->localId()){
00593                bad.append(l);
00594              }
00595            }
00596          }
00597       }
00598       if(bad.length() > 0) _links.remove(bad);
00599       _fitted = false;
00600       _fittedUpdated = false;
00601     }
00602 }

void TMLine::appendSLY AList< TMLink > &  list  ) 
 

void TMLine::appendSLY AList< TMLink > &  list  ) 
 

00559                                       {
00560       _links.append(list);
00561       _fitted = false;
00562       _fittedUpdated = false;
00563 }

virtual int TTrackBase::approach TMLink  )  const [virtual, inherited]
 

calculates the closest approach to a wire in real space. Results are stored in TMLink. Return value is negative if error happened.

Reimplemented in TTrack, and TTrack.

int TTrackBase::approach TMLink  )  const [virtual, inherited]
 

calculates the closest approach to a wire in real space. Results are stored in TMLink. Return value is negative if error happened.

Reimplemented in TTrack, and TTrack.

00095                                    {
00096     std::cout << "TTrackBase::approach !!! not implemented" << std::endl;
00097     return -1;
00098 }

double TMLine::b void   )  const
 

returns coefficient b.

double TMLine::b void   )  const [inline]
 

returns coefficient b.

00156                     {
00157 #ifdef TRKRECO_DEBUG
00158     if (! _fitted) std::cout << "TMLine::b !!! fit not performed" << std::endl;
00159 #endif
00160     return _b;
00161 }

double TMLine::chi2 void   )  const
 

returns chi2.

double TMLine::chi2 void   )  const
 

returns chi2.

00113                        {
00114 #ifdef TRKRECO_DEBUG
00115     if (! _fitted)
00116         std::cout << "TMLine::chi2 !!! fit not performed" << std::endl;
00117 #endif
00118 
00119     if (_fittedUpdated) return _chi2;
00120     _chi2 = 0.;
00121     unsigned n = _links.length();
00122     for (unsigned i = 0; i < n; i++) {
00123         TMLink & l = * _links[i];
00124 
00125         double x = l.position().x();
00126         double y = l.position().y();
00127         double c = y - _a * x - _b;
00128         _chi2 += c * c;
00129     }
00130     _fittedUpdated = true;
00131     return _chi2;
00132 }

const AList<TMLink>& TTrackBase::cores unsigned  mask = 0  )  const [inherited]
 

returns a list of masked TMLinks for fit. 'mask' will be applied if mask is not 0.

const AList< TMLink > & TTrackBase::cores unsigned  mask = 0  )  const [inherited]
 

returns a list of masked TMLinks for fit. 'mask' will be applied if mask is not 0.

00290                                      {
00291     if (mask)
00292         std::cout << "TTrackBase::cores !!! mask is not supported" << std::endl;
00293     if (! _updated) update();
00294     return _cores;
00295 }

double TMLine::distance const HepPoint3D  )  const
 

double TMLine::distance const TMLink  )  const [virtual]
 

returns distance to a position of TMLink itself. (not to a wire)

Reimplemented from TTrackBase.

double TMLine::distance const HepPoint3D  )  const [inline]
 

00176                                            {
00177 #ifdef TRKRECO_DEBUG
00178     if (! _fitted) std::cout << "TMLine::distance !!! fit not performed" << std::endl;
00179 #endif
00180     double dy = fabs(_a * p.x() + _b - p.y());
00181     double invCos = sqrt(1. + _a * _a);
00182     return dy / invCos;
00183 }

double TMLine::distance const TMLink  )  const [inline, virtual]
 

returns distance to a position of TMLink itself. (not to a wire)

Reimplemented from TTrackBase.

00165                                        {
00166 #ifdef TRKRECO_DEBUG
00167     if (! _fitted) std::cout << "TMLine::distance !!! fit not performed" << std::endl;
00168 #endif
00169     double dy = fabs(_a * l.position().x() + _b - l.position().y());
00170     double invCos = sqrt(1. + _a * _a);
00171     return dy / invCos;
00172 }

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

dumps debug information.

Reimplemented from TTrackBase.

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

dumps debug information.

Reimplemented from TTrackBase.

00053                                                                {
00054     bool def = false;
00055     if (msg == "") def = true;
00056 
00057     if (def || msg.find("line") != std::string::npos || msg.find("detail") != std::string::npos) {
00058         std::cout << pre;
00059         std::cout << "#links=" << _links.length();
00060         std::cout << ",a=" << _a;
00061         std::cout << ",b=" << _b;
00062         std::cout << ",det=" << _det;
00063         std::cout << std::endl;
00064     }
00065     if (! def) TTrackBase::dump(msg, pre);
00066 }

void TTrackBase::falseFit  )  [inherited]
 

false Fit

void TTrackBase::falseFit  )  [inline, inherited]
 

false Fit

00227                     {
00228     _fitted = false;
00229     _fittedWithCathode = false;
00230 }

virtual int TTrackBase::fit void   )  [virtual, inherited]
 

fits itself by a default fitter. Error was happened if return value is not zero.

int TTrackBase::fit void   )  [virtual, inherited]
 

fits itself by a default fitter. Error was happened if return value is not zero.

00330                     {
00331     return _fitter->fit(* this);
00332 }

int TMLine::fit2  ) 
 

fits itself using isolated hits. Error was happened if return value is not zero.

int TMLine::fit2  ) 
 

fits itself using isolated hits. Error was happened if return value is not zero.

00174              {
00175   //    if (_fitted) return 0;
00176 
00177     unsigned n = _links.length();
00178     int mask[100] = {0};
00179     int nsl[11] = {64,80,96,128,144,160,192,208,240,256,288};
00180     int npos = 0, nneg = 0;
00181     for (unsigned i = 0; i < n -1 ; i++) {
00182         TMLink & l = * _links[i];
00183         for (unsigned j = i+1; j < n  ; j++) {
00184            TMLink & s = * _links[j];
00185            if(l.hit()->wire()->layerId() == s.hit()->wire()->layerId()){
00186              //... Check 3 consective hits
00187              if(i > 0 && (mask[i-1] == 1 && mask[j] == 1) ){
00188                TMLink & t = * _links[i-1];
00189                if(l.hit()->wire()->layerId() == t.hit()->wire()->layerId()){
00190                  mask[i] = 1;
00191                }
00192              }
00193              int ilast = nsl[l.hit()->wire()->superLayerId()]-1;
00194              int ilocal = l.hit()->wire()->localId();
00195              int jlocal = s.hit()->wire()->localId();
00196              if(ilocal > 0 && ilocal < ilast){
00197                if(abs(jlocal-ilocal) > 1 ) {
00198                   mask[i] = 1;
00199                   mask[j] = 1;
00200                }
00201              }else if(ilocal == 0){
00202                if(jlocal > 1 && jlocal < ilast){
00203                  mask[i] = 1;
00204                  mask[j] = 1;
00205                }
00206              }else if(ilocal == ilast){
00207                if(jlocal > 0 && jlocal < ilast-1){
00208                  mask[i] = 1;
00209                  mask[j] = 1;
00210                }
00211              }
00212            }
00213         }
00214         //...
00215         if(mask[i] == 0){
00216           if(l.position().y() >= 0) npos += 1;
00217           if(l.position().y() <  0) nneg += 1;
00218         }
00219     }            
00220 
00221     //....
00222     double sumX = 0., sumY = 0., sumX2 = 0., sumXY = 0., sumY2 = 0.;
00223     int nused = 0;
00224     int lyid[2];
00225     for (unsigned i = 0; i < n; i++) {
00226 
00227         if(mask[i] == 1) continue;
00228 
00229         TMLink & l = * _links[i];
00230 
00231         double x = l.position().x();
00232         double y = l.position().y();
00233         if(abs(npos-nneg) > 3){
00234           if(npos > nneg && y < 0 ) continue;
00235           if(npos < nneg && y > 0 ) continue;
00236         }
00237         sumX  += x;
00238         sumY  += y;
00239         sumX2 += x * x;
00240         sumXY += x * y;
00241         sumY2 += y * y;
00242         if(nused < 2){
00243           lyid[nused] = l.hit()->wire()->layerId();
00244         }
00245         nused += 1;
00246     }
00247 
00248      if(nused < 2 || (nused == 2 && lyid[0]==lyid[1])) {
00249        return -2;
00250      }
00251      double sum = double(nused);
00252     _det = sum * sumX2 - sumX * sumX;
00253     if(_det == 0.) {
00254         return -1;
00255     }
00256     _a = (sumXY * sum - sumX * sumY) / _det;
00257     _b = (sumX2 * sumY - sumX * sumXY) / _det;    
00258 
00259     _fitted = true;
00260     return 0;
00261 }

int TMLine::fit2p  ) 
 

fits itself using isolated hits. Error was happened if return value is not zero.

int TMLine::fit2p  ) 
 

fits itself using isolated hits. Error was happened if return value is not zero.

00402               {
00403   //    if (_fitted) return 0;
00404 
00405     unsigned n = _links.length();
00406     int mask[100] = {0};
00407     int nsl[11] = {64,80,96,128,144,160,192,208,240,256,288};
00408     double phi_ave = 0.;
00409     int nphi = 0;
00410     double Crad = 180./3.141592;
00411     for (unsigned i = 0; i < n -1 ; i++) {
00412         TMLink & l = * _links[i];
00413         for (unsigned j = i+1; j < n  ; j++) {
00414            TMLink & s = * _links[j];
00415            if(l.hit()->wire()->layerId() == s.hit()->wire()->layerId()){
00416              //... Check 3 consective hits
00417              if(i > 0 && (mask[i-1] == 1 && mask[j] == 1) ){
00418                TMLink & t = * _links[i-1];
00419                if(l.hit()->wire()->layerId() == t.hit()->wire()->layerId()){
00420                  mask[i] = 1;
00421                }
00422              }
00423              int ilast = nsl[l.hit()->wire()->superLayerId()]-1;
00424              int ilocal = l.hit()->wire()->localId();
00425              int jlocal = s.hit()->wire()->localId();
00426              if(ilocal > 0 && ilocal < ilast){
00427                if(abs(jlocal-ilocal) > 1 ) {
00428                   mask[i] = 1;
00429                   mask[j] = 1;
00430                }
00431              }else if(ilocal == 0){
00432                if(jlocal > 1 && jlocal < ilast){
00433                  mask[i] = 1;
00434                  mask[j] = 1;
00435                }
00436              }else if(ilocal == ilast){
00437                if(jlocal > 0 && jlocal < ilast-1){
00438                  mask[i] = 1;
00439                  mask[j] = 1;
00440                }
00441              }
00442            }
00443         }
00444         //...
00445         //...
00446         if(mask[i] != 1){
00447           double phi = Crad*atan2(l.position().y(), l.position().x());
00448           phi_ave += phi;
00449           nphi += 1;
00450         }
00451     }            
00452 
00453     //...
00454     if(mask[n-1] != 1){
00455       TMLink & l = * _links[n-1];
00456       double phi = Crad*atan2(l.position().y(), l.position().x());
00457       phi_ave += phi;
00458       nphi += 1;
00459     }
00460     double phi_max = 0.;
00461     double phi_min = 0.;
00462     if(nphi> 0){
00463       phi_max = phi_ave/n + 40;
00464       phi_min = phi_ave/n - 40;
00465     }
00466 
00467     //....
00468     double sumX = 0., sumY = 0., sumX2 = 0., sumXY = 0., sumY2 = 0.;
00469     int nused = 0;
00470     int lyid[2];
00471     for (unsigned i = 0; i < n; i++) {
00472 
00473         if(mask[i] == 1) continue;
00474 
00475         TMLink & l = * _links[i];
00476 
00477         double x = l.position().x();
00478         double y = l.position().y();
00479         double phi = Crad*atan2(l.position().y(), l.position().x());
00480         if(phi > phi_max && phi<phi_min ) continue;
00481 
00482         sumX  += x;
00483         sumY  += y;
00484         sumX2 += x * x;
00485         sumXY += x * y;
00486         sumY2 += y * y;
00487         if(nused < 2){
00488           lyid[nused] = l.hit()->wire()->layerId();
00489         }
00490         nused += 1;
00491     }
00492 
00493      if(nused < 2 || (nused == 2 && lyid[0]==lyid[1])) {
00494        return -2;
00495      }
00496      double sum = double(nused);
00497     _det = sum * sumX2 - sumX * sumX;
00498     if(_det == 0.) {
00499         return -1;
00500     }
00501     _a = (sumXY * sum - sumX * sumY) / _det;
00502     _b = (sumX2 * sumY - sumX * sumXY) / _det;    
00503 
00504     _fitted = true;
00505     return 0;
00506 }

int TMLine::fit2s  ) 
 

fits itself using single hits in a wire-layer. Error was happened if return value is not zero.

int TMLine::fit2s  ) 
 

fits itself using single hits in a wire-layer. Error was happened if return value is not zero.

00264               {
00265   //    if (_fitted) return 0;
00266 
00267     unsigned n = _links.length();
00268     int mask[100] = {0};
00269     int npos = 0, nneg = 0;
00270     for (unsigned i = 0; i < n -1 ; i++) {
00271         TMLink & l = * _links[i];
00272         for (unsigned j = i+1; j < n  ; j++) {
00273            TMLink & s = * _links[j];
00274            if(l.hit()->wire()->layerId() == s.hit()->wire()->layerId()){
00275               mask[i] = 1;
00276               mask[j] = 1;
00277            }
00278         }
00279         //...
00280         if(mask[i] == 0){
00281           if(l.position().y() >= 0) npos += 1;
00282           if(l.position().y() <  0) nneg += 1;
00283         }
00284     }            
00285 
00286     //....
00287     double sumX = 0., sumY = 0., sumX2 = 0., sumXY = 0., sumY2 = 0.;
00288     int nused = 0;
00289     int lyid[2];
00290     for (unsigned i = 0; i < n; i++) {
00291 
00292         if(mask[i] == 1) continue;
00293 
00294         TMLink & l = * _links[i];
00295 
00296         double x = l.position().x();
00297         double y = l.position().y();
00298         if(npos > nneg && y < 0 ) continue;
00299         if(npos < nneg && y > 0 ) continue;
00300 
00301         sumX  += x;
00302         sumY  += y;
00303         sumX2 += x * x;
00304         sumXY += x * y;
00305         sumY2 += y * y;
00306         nused += 1;
00307     }
00308 
00309      if(nused < 4) {
00310        return -2;
00311      }
00312      double sum = double(nused);
00313     _det = sum * sumX2 - sumX * sumX;
00314     if(_det == 0.) {
00315         return -1;
00316     }
00317     _a = (sumXY * sum - sumX * sumY) / _det;
00318     _b = (sumX2 * sumY - sumX * sumXY) / _det;    
00319 
00320     _fitted = true;
00321     return 0;
00322 }

int TMLine::fit2sp  ) 
 

fits itself using single hits in a wire-layer. Error was happened if return value is not zero.

int TMLine::fit2sp  ) 
 

fits itself using single hits in a wire-layer. Error was happened if return value is not zero.

00324                {
00325   //    if (_fitted) return 0;
00326 
00327     unsigned n = _links.length();
00328     int mask[100] = {0};
00329     double phi_ave = 0.;
00330     int nphi = 0;
00331     double Crad = 180./3.141592;
00332     for (unsigned i = 0; i < n -1 ; i++) {
00333         TMLink & l = * _links[i];
00334         for (unsigned j = i+1; j < n  ; j++) {
00335            TMLink & s = * _links[j];
00336            if(l.hit()->wire()->layerId() == s.hit()->wire()->layerId()){
00337               mask[i] = 1;
00338               mask[j] = 1;
00339            }
00340         }
00341         //...
00342         if(mask[i] != 1){
00343           double phi = Crad*atan2(l.position().y(), l.position().x());
00344           phi_ave += phi;
00345           nphi += 1;
00346         }
00347     }            
00348 
00349     //...
00350     if(mask[n-1] != 1){
00351       TMLink & l = * _links[n-1];
00352       double phi = Crad*atan2(l.position().y(), l.position().x());
00353       phi_ave += phi;
00354       nphi += 1;
00355     }
00356     double phi_max = 0.;
00357     double phi_min = 0.;
00358     if(nphi> 0){
00359       phi_max = phi_ave/n + 40;
00360       phi_min = phi_ave/n - 40;
00361     }
00362 
00363     //....
00364     double sumX = 0., sumY = 0., sumX2 = 0., sumXY = 0., sumY2 = 0.;
00365     int nused = 0;
00366     int lyid[2];
00367     for (unsigned i = 0; i < n; i++) {
00368 
00369         if(mask[i] == 1) continue;
00370 
00371         TMLink & l = * _links[i];
00372 
00373         double x = l.position().x();
00374         double y = l.position().y();
00375         double phi = Crad*atan2(l.position().y(), l.position().x());
00376         if(phi > phi_max && phi<phi_min ) continue;
00377 
00378         sumX  += x;
00379         sumY  += y;
00380         sumX2 += x * x;
00381         sumXY += x * y;
00382         sumY2 += y * y;
00383         nused += 1;
00384     }
00385 
00386      if(nused < 4) {
00387        return -2;
00388      }
00389      double sum = double(nused);
00390     _det = sum * sumX2 - sumX * sumX;
00391     if(_det == 0.) {
00392         return -1;
00393     }
00394     _a = (sumXY * sum - sumX * sumY) / _det;
00395     _b = (sumX2 * sumY - sumX * sumXY) / _det;    
00396 
00397     _fitted = true;
00398     return 0;
00399 }

bool TTrackBase::fitted void   )  const [inherited]
 

returns true if fitted.

bool TTrackBase::fitted void   )  const [inline, inherited]
 

returns true if fitted.

00220                              {
00221     return _fitted;
00222 }

bool TTrackBase::fittedWithCathode void   )  const [inherited]
 

returns true if fitted with cathode hits(TEMPORARY).

bool TTrackBase::fittedWithCathode void   )  const [inline, inherited]
 

returns true if fitted with cathode hits(TEMPORARY).

00241                                         {
00242     return _fittedWithCathode;
00243 }

const TMFitter* const TTrackBase::fitter const TMFitter  )  [inherited]
 

sets a default fitter.

const TMFitter* const TTrackBase::fitter void   )  const [inherited]
 

returns a pointer to a default fitter.

const TMFitter *const TTrackBase::fitter const TMFitter  )  [inline, inherited]
 

sets a default fitter.

00259                                      {
00260     _fitted = false;
00261     return _fitter = a;
00262 }

const TMFitter *const TTrackBase::fitter void   )  const [inline, inherited]
 

returns a pointer to a default fitter.

00253                              {
00254     return _fitter;
00255 }

const TTrackHEP* const TTrackBase::hep void   )  const [inherited]
 

returns TTrackHEP.

const TTrackHEP *const TTrackBase::hep void   )  const [inherited]
 

returns TTrackHEP.

00380                           {
00381     unsigned n = _links.length();
00382     CAList<TTrackHEP> hepList;
00383     CList<unsigned> hepCounter;
00384     for (unsigned i = 0; i < n; i++) {
00385         const TTrackHEP * hep = _links[i]->hit()->mc()->hep();
00386         unsigned nH = hepList.length();
00387         bool found = false;
00388         for (unsigned j = 0; j < nH; j++) {
00389             if (hepList[j] == hep) {
00390                 found = true;
00391                 ++(* hepCounter[j]);
00392             }
00393         }
00394 
00395         if (! found) {
00396             hepList.append(hep);
00397             unsigned c = 0;
00398             hepCounter.append(c);
00399         }
00400     }
00401 
00402     _nHeps = hepList.length();
00403     _hep = 0;
00404     unsigned max = 0;
00405     for (unsigned i = 0; i < _nHeps; i++) {
00406         if ((* hepCounter[i]) > max) {
00407             max = (* hepCounter[i]);
00408             _hep = hepList[i];
00409         }
00410     }
00411 
00412     return _hep;
00413 }

const AList<TMLink>& TTrackBase::links unsigned  mask = 0  )  const [inherited]
 

returns a list of masked TMLinks assigned to this track. 'mask' will be applied if mask is not 0.

const AList< TMLink > & TTrackBase::links unsigned  mask = 0  )  const [inherited]
 

returns a list of masked TMLinks assigned to this track. 'mask' will be applied if mask is not 0.

00270                                      {
00271     if (mask == 0) return _links;
00272 
00273     std::cout << "TTrackBase::links !!! mask is not supportted yet" << std::endl;
00274     return _links;
00275 }

const TTrackMC* const TTrackBase::mc void   )  const [inherited]
 

returns a pointer to TTrackMC.

const TTrackMC *const TTrackBase::mc void   )  const [inline, inherited]
 

returns a pointer to TTrackMC.

00247                          {
00248     return _mc;
00249 }

unsigned TTrackBase::nCores unsigned  mask = 0  )  const [inherited]
 

returns # of masked TMLinks for fit. 'mask' will be applied if mask is not 0.

unsigned TTrackBase::nCores unsigned  mask = 0  )  const [inherited]
 

returns # of masked TMLinks for fit. 'mask' will be applied if mask is not 0.

00298                                       {
00299     if (mask)
00300         std::cout << "TTrackBase::nCores !!! mask is not supported" << std::endl;
00301     if (! _updated) update();
00302     return _cores.length();
00303 }

unsigned TTrackBase::nHeps void   )  const [inherited]
 

returns # of contributed TTrackHEP tracks.

unsigned TTrackBase::nHeps void   )  const [inherited]
 

returns # of contributed TTrackHEP tracks.

00416                             {
00417     hep();
00418     return _nHeps;
00419 }

unsigned TTrackBase::nLinks unsigned  mask = 0  )  const [inherited]
 

returns # of masked TMLinks assigned to this track object.

unsigned TTrackBase::nLinks unsigned  mask = 0  )  const [inherited]
 

returns # of masked TMLinks assigned to this track object.

00278                                       {
00279     unsigned n = _links.length();
00280     if (mask == 0) return n;
00281     unsigned nn = 0;
00282     for (unsigned i = 0; i < n; i++) {
00283         const TMDCWireHit & h = * _links[i]->hit();
00284         if (h.state() & mask) ++nn;
00285     }
00286     return nn;
00287 }

virtual unsigned TMLine::objectType void   )  const [virtual]
 

returns type.

Reimplemented from TTrackBase.

unsigned TMLine::objectType void   )  const [inline, virtual]
 

returns type.

Reimplemented from TTrackBase.

00195                              {
00196     return Line;
00197 }

TMLink* TTrackBase::operator[] unsigned  i  )  const [inherited]
 

TMLink * TTrackBase::operator[] unsigned  i  )  const [inline, inherited]
 

00235                                        {
00236     return _links[i];
00237 }

void TMLine::property double  a,
double  b,
double  det
 

sets circle properties.

void TMLine::property double  a,
double  b,
double  det
[inline]
 

sets circle properties.

00187                                                {
00188     _a = a;
00189     _b = b;
00190     _det = det;
00191 }

double TMLine::reducedChi2 void   )  const
 

returns reduced-chi2.

double TMLine::reducedChi2 void   )  const
 

returns reduced-chi2.

00605                               {
00606 #ifdef TRKRECO_DEBUG
00607     if (! _fitted)
00608         std::cout << "TMLine::reducedChi2 !!! fit not performed" << std::endl;
00609 #endif
00610 
00611     if (_fittedUpdated) return _reducedChi2;
00612     double chi2 = 0.;
00613     double scale = 20.;
00614     unsigned n = _links.length();
00615     for (unsigned i = 0; i < n; i++) {
00616         TMLink & l = * _links[i];
00617 
00618         double x = l.position().x();
00619         double y = l.position().y();
00620         double c = y - _a * x - _b;
00621         double err = 1.;
00622         if (l.hit()) err = scale * l.hit()->dDrift();
00623         chi2 += c * c / err / err;
00624     }
00625 
00626     _reducedChi2 = chi2/(n-2);
00627     _fittedUpdated = true;
00628     return _reducedChi2;
00629 }

void TTrackBase::refine double  maxSigma  )  [virtual, inherited]
 

removes bad points by pull. The bad points are masked not to be used in fit.

00194                                {
00195     AList<TMLink> bad = refineMain(sigma);
00196 //      for (unsigned i = 0; i < bad.length(); i++) {
00197 //      const TMDCWireHit * hit = bad[i]->hit();
00198 //      hit->state(hit->state() | WireHitInvalidForFit);
00199 //      }
00200 
00201 #ifdef TRKRECO_DEBUG_DETAIL
00202     std::cout << "    refine ... sigma=" << sigma << std::endl;
00203     Dump(bad, "detail sort", "        ");
00204 #endif
00205 
00206     if (bad.length()) {
00207         _fitted = false;
00208         _updated = false;
00209     }
00210 }

void TTrackBase::refine AList< TMLink > &  list,
double  maxSigma
[virtual, inherited]
 

removes bad points by pull. The bad points are removed from the track, and are returned in 'list'.

00170                                                      {
00171     AList<TMLink> bad = refineMain(sigma);
00172 #ifdef TRKRECO_DEBUG
00173     std::cout << "    refine ... sigma=" << sigma << ", # of rejected hits=";
00174     std::cout << bad.length() << std::endl;
00175 #endif
00176 #ifdef TRKRECO_DEBUG
00177     Dump(bad, "sort pull mc", "        ");
00178 #endif
00179 
00180     if (bad.length()) {
00181         _links.remove(bad);
00182         list.append(bad);
00183         _fitted = false;
00184         _updated = false;
00185     }
00186 }

void TMLine::refine AList< TMLink > &  list,
float  maxSigma
 

remove bad points by chi2. Bad points are returned in a 'list'. fit() should be called before calling this function.

void TMLine::refine AList< TMLink > &  list,
float  maxSigma
 

remove bad points by chi2. Bad points are returned in a 'list'. fit() should be called before calling this function.

00135                                                    {
00136     AList<TMLink> bad;
00137     unsigned n = _links.length();
00138     for (unsigned i = 0; i < n; i++) {
00139         TMLink & l = * _links[i];
00140         double dist = distance(l);
00141         if (dist > maxSigma) bad.append(l);
00142     }
00143 
00144 #ifdef TRKRECO_DEBUG_DETAIL
00145     std::cout << "    TMLine::refine ... rejected hits:max distance=" << maxSigma;
00146     std::cout << std::endl;
00147     bad.sort(SortByWireId);
00148     for (unsigned i = 0; i < bad.length(); i++) {
00149         TMLink & l = * _links[i];
00150         std::cout << "        ";
00151         std::cout << l.wire()->layerId() << "-";
00152         std::cout << l.wire()->localId();
00153         std::cout << "(";
00154         if (l.hit()->mc()) {
00155             if (l.hit()->mc()->hep()) std::cout << l.hit()->mc()->hep()->id();
00156             else std::cout << "0";
00157         }
00158         std::cout << "),";
00159         std::cout << l.position() << "," << distance(l);
00160         if (distance(l) > maxSigma) std::cout << " X";
00161         std::cout << std::endl;
00162     }
00163 #endif
00164 
00165     if (bad.length()) {
00166         _links.remove(bad);
00167         list.append(bad);
00168         _fitted = false;
00169         _fittedUpdated = false;
00170     }
00171 }

void TTrackBase::remove const AList< TMLink > &   )  [inherited]
 

removes TMLinks.

void TTrackBase::remove TMLink a  )  [inherited]
 

removes a TMLink.

void TTrackBase::remove const AList< TMLink > &   )  [inline, inherited]
 

removes TMLinks.

00211                                           {
00212     _links.remove(a);
00213     _updated = false;
00214     _fitted = false;
00215     _fittedWithCathode = false; // mod. by matsu ( 1999/05/24 )
00216 }

void TTrackBase::remove TMLink a  )  [inline, inherited]
 

removes a TMLink.

00202                              {
00203     _links.remove(a);
00204     _updated = false;
00205     _fitted = false;
00206     _fittedWithCathode = false; // mod. by matsu ( 1999/05/24 )
00207 }

void TMLine::removeChits  ) 
 

remove extremly bad points.

void TMLine::removeChits  ) 
 

remove extremly bad points.

00509                     {
00510 
00511     unsigned n = _links.length();
00512     int nlyr[50] = {0};
00513     int nneg = 0, npos = 0;
00514     for (unsigned i = 0; i < n -1 ; i++) {
00515         TMLink & l = * _links[i];
00516         nlyr[l.hit()->wire()->layerId()] += 1;
00517         if(l.position().y() < 0.){
00518            nneg += 1;
00519         }else {
00520            npos += 1;
00521         }
00522     }            
00523 
00524     //...
00525     AList<TMLink> bad;
00526     for (unsigned i = 0; i < n; i++) {
00527 
00528         TMLink & l = * _links[i];
00529 
00530         //...if # of hits in a wire layer, don't use...
00531         if (nlyr[l.hit()->wire()->layerId()] > 3) {
00532             bad.append(l);
00533             continue;
00534         }
00535         //...remove extremely bad poinits
00536         if(abs(nneg - npos) > 3) {
00537           if(npos > nneg && l.position().y() < 0 ) bad.append(l);
00538           if(npos < nneg && l.position().y() > 0 ) bad.append(l);
00539         }
00540     }
00541     //...
00542     if (bad.length() > 0 && bad.length() < n) {
00543         _links.remove(bad);
00544     }
00545 
00546     //... For the next fit
00547    _fitted = false;
00548    _fittedUpdated = false;
00549 }

virtual void TTrackBase::removeLinks void   )  [virtual, inherited]
 

void TTrackBase::removeLinks void   )  [virtual, inherited]
 

00189                            {
00190   _links.removeAll();
00191 }

void TMLine::removeSLY AList< TMLink > &  list  ) 
 

void TMLine::removeSLY AList< TMLink > &  list  ) 
 

00552                                       {
00553       _links.remove(list);
00554       _fitted = false;
00555       _fittedUpdated = false;
00556 }

unsigned TTrackBase::testByApproach const AList< TMLink > &  list,
double  sigma
const [inherited]
 

unsigned TTrackBase::testByApproach const TMLink list,
double  sigma
const [inherited]
 

returns # of good hits to be appended.

unsigned TTrackBase::testByApproach const AList< TMLink > &  list,
double  sigma
const [inherited]
 

00213                                                                             {
00214 #ifdef TRKRECO_DEBUG_DETAIL
00215     std::cout << "    TTrackBase::testByApproach ... sigma=" << maxSigma << std::endl;
00216 #endif
00217 
00218     unsigned nOK = 0;
00219     unsigned n = list.length();
00220     for (unsigned i = 0; i < n; i++) {
00221         TMLink & l = * list[i];
00222         nOK += testByApproach(l, maxSigma);
00223     }
00224     return nOK;
00225 }

unsigned TTrackBase::testByApproach const TMLink list,
double  sigma
const [inherited]
 

returns # of good hits to be appended.

00228                                                                      {
00229 #ifdef TRKRECO_DEBUG_DETAIL
00230     std::cout << "    TTrackBase::testByApproach ... sigma=" << maxSigma << std::endl;
00231 #endif
00232     TMLink l = link;
00233 
00234     //...Calculate closest approach...
00235     int err = approach(l);
00236     if (err < 0) return 0;
00237     //...Calculate sigma...
00238     float distance = l.distance();
00239     float diff = fabs(distance - l.hit()->drift());
00240     float sigma = diff / l.hit()->dDrift();
00241     l.pull(sigma * sigma);
00242 
00243     //...For debug...
00244 #ifdef TRKRECO_DEBUG_DETAIL
00245     std::cout << "    sigma=" << sigma;
00246     std::cout << ",dist=" << distance;
00247     std::cout << ",diff=" << diff << ",";
00248     if (sigma < maxSigma) std::cout << "ok,";
00249     else                  std::cout << "X,";
00250     l.dump("mc");
00251 #endif
00252                 
00253     //...Make sigma cut...
00254     if (sigma < maxSigma) return 1;
00255 
00256     return 0;
00257 }

virtual unsigned TTrackBase::type void   )  const [virtual, inherited]
 

returns type. Definition is depending on an object class.

Reimplemented in TTrack, and TTrack.

unsigned TTrackBase::type void   )  const [inline, virtual, inherited]
 

returns type. Definition is depending on an object class.

Reimplemented in TTrack, and TTrack.

00272                            {
00273     return 0;
00274 }

void TTrackBase::update void   )  const [inherited]
 

update cache.

Reimplemented in TSegment, TSegment0, TSegment, and TSegment0.

void TTrackBase::update void   )  const [inherited]
 

update cache.

Reimplemented in TSegment, TSegment0, TSegment, and TSegment0.

00075                              {
00076     _cores.removeAll();
00077     unsigned n = _links.length();
00078     for (unsigned i = 0; i < n; i++) {
00079         TMLink * l = _links[i];
00080         const TMDCWireHit & h = * l->hit();
00081         if (h.state() & WireHitInvalidForFit) continue;
00082         if (! (h.state() & WireHitFittingValid)) continue;
00083         _cores.append(l);
00084     }
00085     _updated = true;
00086 }


Member Data Documentation

double TMLine::_a [private]
 

double TMLine::_b [private]
 

double TMLine::_chi2 [mutable, private]
 

double TMLine::_det [private]
 

bool TTrackBase::_fitted [mutable, protected, inherited]
 

bool TMLine::_fittedUpdated [mutable, private]
 

bool TTrackBase::_fittedWithCathode [mutable, protected, inherited]
 

const TLineFitter TMLine::_fitter = TLineFitter("TMLine Default Line Fitter") [static, private]
 

Reimplemented from TTrackBase.

AList<TMLink> TTrackBase::_links [protected, inherited]
 

AList<TMLink> TTrackBase::_links [protected, inherited]
 

TTrackMC* TTrackBase::_mc [protected, inherited]
 

TTrackMC* TTrackBase::_mc [protected, inherited]
 

double TMLine::_reducedChi2 [mutable, private]
 


The documentation for this class was generated from the following files:
Generated on Wed Feb 2 18:55:16 2011 for BOSS6.5.5 by  doxygen 1.3.9.1