00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef TConformalFinder_FLAG_
00014 #define TConformalFinder_FLAG_
00015
00016 #ifdef TRKRECO_DEBUG_DETAIL
00017 #ifndef TRKRECO_DEBUG
00018 #define TRKRECO_DEBUG
00019 #endif
00020 #endif
00021 #define HEP_SHORT_NAMES
00022 #include "CLHEP/Alist/ConstAList.h"
00023 #include "TrkReco/TFinderBase.h"
00024 #include "TrkReco/TMLink.h"
00025 #include "TrkReco/TSegment.h"
00026 #include "TrkReco/TBuilder.h"
00027
00028 #ifdef TRKRECO_DEBUG
00029 #define ConformalInitialization 0
00030 #define ConformalFast2DLevel0 10
00031 #define ConformalFast2DLevel1 11
00032 #define ConformalFast3DLevel0 20
00033 #define ConformalFast3DLevel1 21
00034 #define ConformalSlow2D 40
00035 #define ConformalSlow3D 41
00036 #define ConformalOutside 99
00037 #endif
00038 #ifdef TRKRECO_WINDOW
00039 #include "TrkReco/TWindow.h"
00040 #endif
00041
00042 class TMDC;
00043 class TPoint2D;
00044
00046 class TConformalFinder : public TFinderBase {
00047
00048 public:
00050 TConformalFinder(unsigned fastFinder,
00051 unsigned slowFinder,
00052 unsigned perfectSegmentFinding,
00053 float maxSigma,
00054 float maxSigmaStereo,
00055 float salvageLevel,
00056 unsigned minNLinksForSegment,
00057 unsigned minNCoreLinks,
00058 unsigned minNSegments,
00059 unsigned salvageLoadWidth,
00060 unsigned stereoMode,
00061 unsigned stereoLoadWidth,
00062 float szSegmentDistance,
00063 float szLinkDistance,
00064 unsigned fittingFlag);
00065
00067 virtual ~TConformalFinder();
00068
00069 public:
00071 std::string name(void) const;
00072
00074 std::string version(void) const;
00075
00077 void dump(const std::string & message = std::string(""),
00078 const std::string & prefix = std::string("")) const;
00079
00081 bool T0ResetDone(void) const;
00082
00083 public:
00085 void clear(void);
00086
00088 int doit(const AList<TMDCWireHit> & axialHits,
00089 const AList<TMDCWireHit> & stereoHits,
00090 AList<TTrack> & tracks,
00091 AList<TTrack> & tracks2D);
00092
00094 bool doT0Reset(bool);
00095
00096 private:
00098 void selectGoodHits(void);
00099
00101 void findSegments(void);
00102 void findSegmentsPerfect(void);
00104 void findSegmentsTsf(void);
00105
00107 void linkSegments(unsigned level);
00108 void linkSegmentsTsf(void);
00109
00111 void fastFinding2D(unsigned level);
00112 void fastFinding3D(unsigned level);
00113
00115 void slowFinding2D(unsigned level);
00116 TTrack * expand(AList<TSegment> &) const;
00117 TTrack * expand(TTrack &) const;
00118 void targetSuperLayer(unsigned ptn, unsigned & in, unsigned & out) const;
00119 AList<TSegment> targetSegments(const TTrack &, unsigned sl) const;
00120 AList<TMLink> targetLinks(const TTrack &, unsigned sl) const;
00121 bool trackQuality(const TTrack &) const;
00122
00124 AList<TSegment> stereoSegments(const TTrack & t) const;
00125 AList<TSegment> stereoSegmentsFromBadHits(const TTrack & t) const;
00126
00128 void salvage(TTrack & track,
00129 unsigned axialStereoSwitch,
00130 const AList<TSegment> & bads) const;
00131
00133 AList<TSegment> removeBadSegments(TTrack &) const;
00134 AList<TSegment> refineSegments(const TTrack &) const;
00135 void refineLinks(TTrack &, unsigned minNHits) const;
00136
00138 void resolveSegments(AList<TTrack> & tracks) const;
00139 void resolveHits(AList<TTrack> & tracks) const;
00140
00142 void removeUsedSegments(const AList<TTrack> & tracks);
00143
00145 void deleteTrack(TTrack &) const;
00146
00148 void updateTLinks(AList<TTrack> & tracks);
00149
00151 int crossPoints(const TTrack &, TPoint2D points[12]) const;
00152 int crossPointsInConformal(const AList<TSegment> &,
00153 HepPoint3D points[12]) const;
00154 AList<TSegment> pickUpSegments(const TPoint2D p[12],
00155 float loadWidth,
00156 unsigned axialStereo) const;
00157 AList<TSegment> pickUpSegmentsInConformal(float phi[12],
00158 float loadWidth,
00159 unsigned axialStereo) const;
00160 AList<TMLink> pickUpLinks(const TPoint2D p[12],
00161 float loadWidth,
00162 unsigned axialStereo) const;
00163 AList<TMLink> pickUpLinksInConformal(float phi[12],
00164 float loadWidth,
00165 unsigned axialStereo) const;
00166 AList<TMLink> trackSide(const TTrack &, const AList<TMLink> &) const;
00167 AList<TSegment> trackSide(const TTrack &, const AList<TSegment> &) const;
00168 bool quality2D(TTrack & t, unsigned level) const;
00169 TSegment * link(const TSegment & seed,
00170 const HepPoint3D & p,
00171 const HepVector3D & v,
00172 const AList<TSegment> & candidates,
00173 AList<TSegment> & alternatives,
00174 unsigned level) const;
00175 HepVector3D direction(const TSegment &) const;
00176
00177 public:
00178 static const TMDCWire * conformal2Wire(const HepPoint3D & conformalPoint);
00179
00180 private:
00181 bool _doT0Reset;
00182 const unsigned _perfectSegmentFinding;
00183 const unsigned _segmentSeparation;
00184 const unsigned _minNLinksForSegment;
00185 const unsigned _minNLinksForSegmentInRefine;
00186 const unsigned _maxNLinksForSegment;
00187 const unsigned _maxWidthForSegment;
00188 const unsigned _minNCoreLinks;
00189 const unsigned _minNSegments;
00190 const float _minUsedFractionSlow2D;
00191 const unsigned _appendLoad;
00192 const unsigned _salvageLoadWidth;
00193 const unsigned _stereoMode;
00194 const unsigned _stereoLoadWidth;
00195 float _linkMaxDistance[3];
00196 float _linkMinDirAngle[3];
00197
00198 private:
00199 IMagneticFieldSvc* m_pmgnIMF;
00200 const bool _fastFinder;
00201 const bool _slowFinder;
00202 const TBuilder _builder;
00203 const float _maxSigma2;
00204
00205 AList<TMLink> _allHits[3];
00206 AList<TMLink> _hits[3];
00207 AList<TMLink> _unused[3];
00208
00209 AList<TSegment> _allSegments[2][6];
00210 AList<TSegment> _allUnused[2][6];
00211 AList<TSegment> _stereoBadSegments;
00212
00213 AList<TTrack> _2DTracks;
00214 AList<TTrack> _3DTracks;
00215
00216 bool _T0ResetDone;
00217
00218 struct summary {
00219 unsigned _nEvents;
00220 unsigned _nTracksFast3D;
00221 unsigned _nTracksSlow3D;
00222 unsigned _nTracksFast2D;
00223 unsigned _nTracksSlow2D;
00224 unsigned _nTracksFast2DBadQuality;
00225 unsigned _nTracksSlow2DBadQuality;
00226 unsigned _dummy;
00227 };
00228 struct summary * _s;
00229
00230 #ifdef TRKRECO_DEBUG
00231 public:
00232 static unsigned _stage;
00233 #endif
00234
00235 #ifdef TRKRECO_WINDOW
00236 private:
00237 mutable TWindow _rphiWindow;
00238
00239 public:
00240 void displayStatus(const std::string & message) const;
00241 void displayAppendSegments(const AList<TSegment> a[2][6],
00242 leda_color =leda_black) const;
00243 void displayTracks(const AList<TTrack> &,
00244 const AList<TSegment> seg[2][6],
00245 const std::string & text) const;
00246 #endif
00247 };
00248
00249
00250
00251 #ifdef TConformalFinder_NO_INLINE
00252 #define inline
00253 #else
00254 #undef inline
00255 #define TConformalFinder_INLINE_DEFINE_HERE
00256 #endif
00257
00258 #ifdef TConformalFinder_INLINE_DEFINE_HERE
00259
00260 inline
00261 std::string
00262 TConformalFinder::name(void) const {
00263 return "Conformal Finder";
00264 }
00265
00266 inline
00267 bool
00268 TConformalFinder::doT0Reset(bool a) {
00269 return _doT0Reset = a;
00270 }
00271
00272 inline
00273 bool
00274 TConformalFinder::T0ResetDone(void) const {
00275 return _T0ResetDone;
00276 }
00277
00278 #endif
00279
00280 #undef inline
00281
00282 #endif