BOSS 7.0.2
BESIII Offline Software System
Loading...
Searching...
No Matches
Reconstruction/MdcPatRec/TrkBase/TrkBase-00-01-12/TrkBase/TrkPredicates.h
Go to the documentation of this file.
1//--------------------------------------------------------------------------
2// File and Version Information:
3// $Id: TrkPredicates.h,v 1.2 2007/11/13 07:27:23 codeman Exp $
4//
5// Description:
6// general, simple tracking predicates
7//
8// All classes (or structs) here should inherit from either
9// unary_function< X, bool> or binary_function<X,Y,bool> and
10// provide bool operator()(const X&,const Y&) const. In addition,
11// this operator should be a 'pure' function, i.e. _no_ side effects...
12//
13// Environment:
14// Software developed for the BaBar Detector at the SLAC B-Factory.
15//
16// Author List:
17// Gerhard Raven
18//------------------------------------------------------------------------
19#include <functional>
20
21#include "TrkBase/TrkRecoTrk.h"
22#include "TrkBase/TrkHitOnTrk.h"
23#include "TrkBase/TrkFitStatus.h"
24
25namespace TrkBase { namespace Predicates {
26
27 struct isHotActive : TrkHitOnTrk::predicate_type {
28 bool operator()(const TrkHitOnTrk& h) const
29 { return h.isActive(); }
30 };
31
32 class isLayer : TrkHitOnTrk::predicate_type {
33 public:
34 isLayer(int layer) : _layer(layer) {}
35 bool operator()(const TrkHitOnTrk& h) const
36 { return h.layerNumber() == _layer; }
37 private:
38 int _layer;
39 };
40
41 struct hasResidual : TrkHitOnTrk::predicate_type {
42 bool operator()(const TrkHitOnTrk& h) const
43 { return h.hasResidual(); }
44 };
45
46 class isSvtHitOnTrack : public TrkHitOnTrk::predicate_type {
47 public:
48 isSvtHitOnTrack(bool activeOnly=false) : _activeOnly(activeOnly) { }
49 bool operator()(const TrkHitOnTrk& h) const
50 { return h.svtHitOnTrack()!=0 && ( !_activeOnly || h.isActive() ); }
51 private:
52 bool _activeOnly;
53 };
54
55 class isMdcHitOnTrack : public TrkHitOnTrk::predicate_type {
56 public:
57 isMdcHitOnTrack(bool activeOnly=false) : _activeOnly(activeOnly) { }
58 bool operator()(const TrkHitOnTrk& h) const
59 { return h.mdcHitOnTrack()!=0 && ( !_activeOnly || h.isActive() ); }
60 private:
61 bool _activeOnly;
62 };
63
64 class hasView : public TrkHitOnTrk::predicate_type {
65 public:
67 bool operator()(const TrkHitOnTrk& h) const
68 {
69 if (_view==TrkEnums::bothView) return true;
70 TrkEnums::TrkViewInfo hotview = h.whatView();
71 if (h.svtHitOnTrack() != 0) {
72 return _view == hotview;
73 } else if (h.mdcHitOnTrack() != 0) {
74// unfortunately the Mdc calls stereo hits 'both view': I'm re-interpreting it here
75 return _view == TrkEnums::xyView && hotview == _view ||
76 _view == TrkEnums::zView && hotview == TrkEnums::bothView;
77 }
78 return false;
79 }
80 private:
82 };
83
84
85 class hotMatchesFundHit : public TrkHitOnTrk::predicate_type {
86 public:
87 hotMatchesFundHit(const TrkFundHit *h) : _h(h) { }
88 bool operator()(const TrkHitOnTrk& h) const
89 { return h.hit()==_h; }
90 private:
91 const TrkFundHit *_h;
92 };
93
94
95 struct isHotOnTrack : std::binary_function<TrkHitOnTrk,const TrkRecoTrk*, bool>
96 {
97 bool operator()(const TrkHitOnTrk& h, const TrkRecoTrk* const & t) const
98 { return h.parentTrack() == t; }
99 };
100
101 struct isFitValid : TrkFitStatus::predicate_type {
102 bool operator()( const TrkFitStatus& t) const
103 { return (t.fitValid()); }
104 };
105
106 struct isFitCurrent : TrkFitStatus::predicate_type {
107 bool operator()( const TrkFitStatus& t) const
108 { return (t.fitCurrent()); }
109 };
110
111 // note that we use 'has' in here, not 'is' as above.... subtly distinction ;-)
112
113 struct hasFitValid : TrkRecoTrk::predicate_type {
114 bool operator()( const TrkRecoTrk& t) const
115 { const TrkFitStatus *x = t.status(); return x!=0 && isFitValid()(*x); }
116 };
117
118 struct hasFitCurrent : TrkRecoTrk::predicate_type {
119 bool operator()( const TrkRecoTrk& t) const
120 { const TrkFitStatus *x = t.status(); return x!=0 && isFitCurrent()(*x); }
121 };
122
123
124} }
Double_t x[10]
std::unary_function< TrkFitStatus, bool > predicate_type
virtual const SvtHitOnTrack * svtHitOnTrack() const
Definition: TrkHitOnTrk.cxx:31
virtual const MdcHitOnTrack * mdcHitOnTrack() const
Definition: TrkHitOnTrk.cxx:30
virtual TrkEnums::TrkViewInfo whatView() const =0
std::unary_function< TrkHitOnTrk, bool > predicate_type
TrkRecoTrk * parentTrack() const
virtual unsigned layerNumber() const =0
std::unary_function< TrkRecoTrk, bool > predicate_type
bool operator()(const TrkHitOnTrk &h, const TrkRecoTrk *const &t) const
int t()
Definition: t.c:1