00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef FTSegment_FLAG_
00010 #define FTSegment_FLAG_
00011
00012 #include "MdcFastTrkAlg/FTList.h"
00013 #include "MdcFastTrkAlg/FTWire.h"
00014 #include "MdcFastTrkAlg/FTLayer.h"
00015 #include "MagneticField/IMagneticFieldSvc.h"
00016 #include "MagneticField/MagneticFieldSvc.h"
00017 #include <iostream>
00018
00019 class FTFinder;
00020 class FTWire;
00021 class FTLayer;
00022 class FTSuperLayer;
00023 class FTTrack;
00024 class FTSegment{
00025 public:
00026
00028 FTSegment(FTSuperLayer * super, FTList<FTWire *> & hits);
00029
00031 ~FTSegment();
00032
00033 public:
00035 int examine(void);
00036
00037 #ifndef OnlineMode
00040 void printout(void);
00041 #endif
00042
00044 void update(void);
00045
00047 int update3D(const FTTrack * track);
00048
00050 void linkStereoSegments(void);
00051
00053 void connect_outer(const FTList<FTWire *> &, const FTList<FTWire *> &);
00054 void connect_inner(const FTList<FTWire *> &, const FTList<FTWire *> &);
00055
00057 void connect_outer(const FTWire *);
00058
00060 void connect_inner(const FTWire *);
00061
00062 public:
00064 FTList<FTWire *>& wireHits(void) const;
00065
00067 FTSuperLayer & superLayer(void) const;
00068
00070 FTList<FTWire *> & innerBoundHits(void) const;
00071
00073 FTList<FTWire *> & outerBoundHits(void) const;
00074
00076 float outgoingX(void) const;
00077
00079 float outgoingY(void) const;
00080
00082 float incomingX(void) const;
00083
00085 float incomingY(void) const;
00086
00088 float incomingPhi(void) const;
00089
00091 float outgoingPhi(void) const;
00092
00094 float attr_const(void) const;
00095
00097 FTTrack * track(void) const;
00098
00100 float kappa(void) const;
00101
00103 float r(void) const;
00104
00106 float s(void) const;
00107
00109 float z(void) const;
00110
00111 public:
00113 FTTrack * track(FTTrack *);
00114 static MdcParameter * param;
00115
00116 private:
00117 IMagneticFieldSvc* m_pmgnIMF;
00118 FTList<FTWire *>& _wireHits;
00119 FTSuperLayer & _superLayer;
00120 FTList<FTWire *> & _innerBoundHits;
00121 FTList<FTWire *> & _outerBoundHits;
00122 FTList<float> * _sList;
00123 union{
00124 float _kappa;
00125 FTList<float> * _zList;
00126 };
00127 union{
00128 FTTrack * _track;
00129 FTList<FTTrack *> * _trackList;
00130 };
00131 float _r;
00132 float _outgoing_x;
00133 float _outgoing_y;
00134 float _incoming_x;
00135 float _incoming_y;
00136 };
00137
00138
00139 inline
00140 FTSegment::FTSegment(FTSuperLayer * super, FTList<FTWire *> & hits)
00141 : _wireHits(hits),
00142 _superLayer(*super),
00143 _innerBoundHits(*(new FTList<FTWire *>(3))),
00144 _outerBoundHits(*(new FTList<FTWire *>(3))),
00145 _sList(NULL),
00146 _zList(NULL),
00147 _track(NULL)
00148 {
00149 StatusCode scmgn = Gaudi::svcLocator()->service("MagneticFieldSvc",m_pmgnIMF);
00150 if(scmgn!=StatusCode::SUCCESS) {
00151 std::cout<< "Unable to open Magnetic field service"<<std::endl;
00152 }
00153 }
00154
00155 inline
00156 FTSegment::~FTSegment()
00157 {
00158 delete &_wireHits;
00159 delete &_innerBoundHits;
00160 delete &_outerBoundHits;
00161 if (_sList){
00162 delete _sList;
00163 delete _zList;
00164 delete _trackList;
00165 }
00166 }
00167
00168 inline
00169 void
00170 FTSegment::connect_outer(const FTList<FTWire *> & outerHits,
00171 const FTList<FTWire *> & outerBound)
00172 {
00173 _wireHits.append(outerHits);
00174 _outerBoundHits.clear();
00175 _outerBoundHits.append(outerBound);
00176 }
00177
00178 inline
00179 void
00180 FTSegment::connect_inner(const FTList<FTWire *> & innerHits,
00181 const FTList<FTWire *> & innerBound)
00182 {
00183 _wireHits.append(innerHits);
00184 _innerBoundHits.clear();
00185 _innerBoundHits.append(innerBound);
00186 }
00187
00188 inline
00189 void
00190 FTSegment::connect_outer(const FTWire * h)
00191 {
00192 _wireHits.append((FTWire *)h);
00193 _outerBoundHits.clear();
00194 _outerBoundHits.append((FTWire *)h);
00195 }
00196
00197 inline
00198 void
00199 FTSegment::connect_inner(const FTWire * h)
00200 {
00201 _wireHits.append((FTWire *)h);
00202 _innerBoundHits.clear();
00203 _innerBoundHits.append((FTWire *)h);
00204 }
00205
00206 inline
00207 FTSuperLayer &
00208 FTSegment::superLayer(void) const
00209 {
00210 return _superLayer;
00211 }
00212
00213 inline
00214 FTList<FTWire *>&
00215 FTSegment::wireHits(void) const
00216 {
00217 return _wireHits;
00218 }
00219
00220 inline
00221 FTList<FTWire *>&
00222 FTSegment::innerBoundHits(void) const
00223 {
00224 return _innerBoundHits;
00225 }
00226
00227 inline
00228 FTList<FTWire *>&
00229 FTSegment::outerBoundHits(void) const
00230 {
00231 return _outerBoundHits;
00232 }
00233
00234 inline
00235 float
00236 FTSegment::outgoingX(void) const
00237 {
00238 return _outgoing_x;
00239 }
00240
00241 inline
00242 float
00243 FTSegment::outgoingY(void) const
00244 {
00245 return _outgoing_y;
00246 }
00247
00248 inline
00249 float
00250 FTSegment::incomingX(void) const
00251 {
00252 return _incoming_x;
00253 }
00254
00255 inline
00256 float
00257 FTSegment::incomingY(void) const
00258 {
00259 return _incoming_y;
00260 }
00261
00262 inline
00263 float
00264 FTSegment::incomingPhi(void) const
00265 {
00266 if (_innerBoundHits.length() ^ 1) {
00267 float phi_1st = _innerBoundHits[0]->phi();
00268 float phi_2nd = _innerBoundHits[1]->phi();
00269 float phi = 0.5 * (phi_1st + phi_2nd);
00270 if (fabs(phi_1st - phi_2nd) > M_PI) {
00271 return (phi>M_PI) ? (phi-M_PI) : (phi+M_PI);
00272 }
00273 return phi;
00274 }
00275 return _innerBoundHits[0]->phi();
00276 }
00277
00278 inline
00279 float
00280 FTSegment::outgoingPhi(void) const
00281 {
00282 if (_outerBoundHits.length() ^ 1) {
00283 float phi_1st = _outerBoundHits[0]->phi();
00284 float phi_2nd = _outerBoundHits[1]->phi();
00285 float phi = 0.5 * (phi_1st + phi_2nd);
00286 if (fabs(phi_1st - phi_2nd) > M_PI) {
00287 return (phi>M_PI) ? (phi-M_PI) : (phi+M_PI);
00288 }
00289 return phi;
00290 }
00291 return _outerBoundHits[0]->phi();
00292 }
00293
00294 inline
00295 float
00296 FTSegment::attr_const(void) const
00297 {
00298 float x_len = _outgoing_x - _incoming_x;
00299 float y_len = _outgoing_y - _incoming_y;
00300 float phi_l = outgoingPhi() - incomingPhi();
00301 return sin(phi_l) / sqrt(x_len*x_len + y_len*y_len);
00302 }
00303
00304 inline
00305 float
00306 FTSegment::r(void) const
00307 {
00308 return _r;
00309 }
00310
00311 inline
00312 float
00313 FTSegment::kappa(void) const
00314 {
00315 return _kappa;
00316 }
00317
00318 inline
00319 float
00320 FTSegment::s(void) const
00321 {
00322 return _sList->first();
00323 }
00324
00325 inline
00326 float
00327 FTSegment::z(void) const
00328 {
00329 return _zList->first();
00330 }
00331
00332 inline
00333 FTTrack *
00334 FTSegment::track(void) const
00335 {
00336 return _track;
00337 }
00338
00339 inline
00340 FTTrack *
00341 FTSegment::track(FTTrack * src)
00342 {
00343 return _track = src;
00344 }
00345
00346
00347 #endif
00348