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

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // $Id: TCircle.cxx,v 1.10 2010/03/31 09:58:59 liucy Exp $
00003 //-----------------------------------------------------------------------------
00004 // Filename : TCircle.cc
00005 // Section  : Tracking
00006 // Owner    : Yoshi Iwasaki
00007 // Email    : yoshihito.iwasaki@kek.jp
00008 //-----------------------------------------------------------------------------
00009 // Description : A class to represent a circle in tracking.
00010 //               See http://bsunsrv1.kek.jp/~yiwasaki/tracking/
00011 //-----------------------------------------------------------------------------
00012 
00013 #include "TrkReco/TCircle.h"
00014 #include "TrkReco/TMDCWire.h"
00015 #include "TrkReco/TMDCWireHit.h"
00016 #include "TrkReco/TMDCWireHitMC.h"
00017 #include "TrkReco/TMLink.h"
00018 
00019 const TCircleFitter
00020 TCircle::_fitter = TCircleFitter("TCircle Default Circle Fitter");
00021 
00022 TCircle::TCircle(const AList<TMLink> & a)
00023 : TTrackBase(a), _radius(0.), _charge(0.) {
00024 
00025     //...Set a defualt fitter...
00026     fitter(& TCircle::_fitter);
00027 }
00028 
00029 TCircle::~TCircle() {
00030 }
00031 
00032 void
00033 TCircle::dump(const std::string & msg, const std::string & pre) const {
00034     bool def = false;
00035     if (msg == "") def = true;
00036 
00037     if (def || msg.find("circle") != std::string::npos || msg.find("detail") != std::string::npos) {
00038         std::cout << pre;
00039         std::cout << "#links=" << _links.length();
00040         if (_fitted) {
00041             std::cout << ",charge=" << _charge;
00042             std::cout << ",center=" << _center;
00043             std::cout << ",radius=" << _radius;
00044             std::cout << std::endl << pre;
00045             std::cout << "pt=" << pt();
00046             std::cout << ",impact=" << impact();
00047             std::cout << std::endl;
00048         }
00049         else {
00050             std::cout << ", not fitted yet" << std::endl;
00051         }
00052     }
00053     if (! def) TTrackBase::dump(msg, pre);
00054 }
00055 
00056 //  int
00057 //  TCircle::fitx(void) {
00058 //  #ifdef TRKRECO_DEBUG_DETAIL
00059 //      std::cout << "    TCircle::fit ..." << std::endl;
00060 //  #endif
00061 //      if (_fitted) return 0;
00062 //      unsigned n = _links.length();
00063 //      if (n < 3) return -1;
00064 
00065 //      for (unsigned i = 0; i < n; i++) {
00066 //      TMLink * l = _links[i];
00067 //      const TMDCWireHit * h = l->hit();
00068 
00069 //      //...Check next hit...
00070 //      Point3D point;
00071 //      if (h->state() & WireHitPatternLeft)
00072 //          point = h->position(WireHitLeft);
00073 //      else if (h->state() & WireHitPatternRight)
00074 //          point = h->position(WireHitRight);
00075 //      else
00076 //          point = h->xyPosition();
00077 //      // float weight = 1. / (h->distance() * h->distance());
00078 //      // float weight = 1. / h->distance();
00079 
00080 //      _circle.add_point(point.x(), point.y()); //, weight);
00081 //      }
00082 
00083 //      if(_circle.fit()<0.0 || _circle.kappa()==0.0) return -1;
00084 //      HepVector v(_circle.center());
00085 //      _center.setX(v(1));
00086 //      _center.setY(v(2));
00087 //      _radius = _circle.radius();
00088 
00089 //      //...Determine charge...Better way???
00090 //      int qSum = 0;
00091 //      for (unsigned i = 0; i < n; i++) {
00092 //      TMLink * l = _links[i];
00093 //      if (l == 0) continue;
00094 
00095 //      const TMDCWireHit * h = l->hit();
00096 //      if (h == 0) continue;
00097 
00098 //      float q = (_center.cross(h->xyPosition())).z();
00099 //      if (q > 0.) qSum += 1;
00100 //      else        qSum -= 1;
00101 //      }
00102 //      if (qSum >= 0) _charge = +1.;
00103 //      else           _charge = -1.;
00104 //      _radius *= _charge;
00105 
00106 //      _fitted = true;
00107 //      return 0;
00108 //  }
00109 
00110 double
00111 TCircle::weight(const TMLink & l) const {
00112 
00113   //...Axial Wires
00114   int maxLink = 0;
00115   int localID[6];
00116   int layerID[6];
00117   int LayerID = l.hit()->wire()->layerId();
00118   for(int i=0;i<6;i++){
00119     if(l.neighbor(i)){
00120       maxLink = i;
00121       localID[i] = l.neighbor(i)->hit()->wire()->localId();
00122       layerID[i] = l.neighbor(i)->hit()->wire()->layerId();
00123     }else{
00124       break;
00125     }
00126   }
00127   if(maxLink != 1)return 1.0;
00128   if(layerID[0] == LayerID &&
00129      layerID[1] == LayerID)return 0.5;
00130   if(layerID[0]+layerID[1] != LayerID*2)return 1.0;
00131 //Liuqg  if(localID[0] != localID[1])return 1.5;//1.0 or 2.0 ??
00132   return 1.0;
00133 }
00134 
00135 int
00136 TCircle::fitForCurl(int ipConst) {
00137     unsigned n = _links.length();
00138     if (n < 3) return -1;
00139 
00140     //IP check
00141     unsigned flagIP = 1;
00142     unsigned layerID = _links[0]->hit()->wire()->layerId();
00143     for(unsigned i = 0; i < n; i++){
00144       if(layerID != _links[i]->hit()->wire()->layerId()){
00145         flagIP = 0;
00146         break;
00147       }
00148     }
00149     if(ipConst != 0)flagIP = 1;
00150     if(flagIP == 1){
00151       _circle.add_point(0., 0., 0.5);
00152       //++_nPointsForFit;
00153     }
00154     for (unsigned i = 0; i < n; i++) {
00155         TMLink * l = _links[i];
00156         if (l == 0) continue;
00157 
00158         const TMDCWireHit * h = l->hit();
00159         if (h == 0) continue;
00160 
00161         //...Check next hit...
00162         HepPoint3D point;
00163         point = h->xyPosition();
00164         
00165         double weight = 1.0;
00166         weight = this->weight(* l);
00167 
00168         _circle.add_point(point.x(), point.y(), weight);
00169         //++_nPointsForFit;
00170     }
00171 
00172     //if (_nPointsForFit < 3) return -1;
00173     if(_circle.fit()<0.0 || _circle.kappa()==0.0) return -1;
00174     HepVector v(_circle.center());
00175     _center.setX(v(1));
00176     _center.setY(v(2));
00177     _radius = _circle.radius();
00178 
00179     //...Determine charge...Better way???
00180     int qSum = 0;
00181     for (unsigned i = 0; i < n; i++) {
00182         TMLink * l = _links[i];
00183         if (l == 0) continue;
00184 
00185         const TMDCWireHit * h = l->hit();
00186         if (h == 0) continue;
00187 
00188         float q = (_center.cross(h->xyPosition())).z();
00189         if (q > 0.) qSum += 1;
00190         else        qSum -= 1;
00191     }
00192     if (qSum >= 0) _charge = +1.;
00193     else           _charge = -1.;
00194     _radius *= _charge;
00195 
00196     _fitted = true;
00197     return 0;
00198 }

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