BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
Reconstruction/MdcPatRec/TrkBase/include/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/TrkFitStatus.h"
22#include "TrkBase/TrkHitOnTrk.h"
23#include "TrkBase/TrkRecoTrk.h"
24
25namespace TrkBase {
26 namespace Predicates {
27
29 bool operator()( const TrkHitOnTrk& h ) const { 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 { return h.layerNumber() == _layer; }
36
37 private:
38 int _layer;
39 };
40
41 struct hasResidual : TrkHitOnTrk::predicate_type {
42 bool operator()( const TrkHitOnTrk& h ) const { return h.hasResidual(); }
43 };
44
45 class isSvtHitOnTrack : public TrkHitOnTrk::predicate_type {
46 public:
47 isSvtHitOnTrack( bool activeOnly = false ) : _activeOnly( activeOnly ) {}
48 bool operator()( const TrkHitOnTrk& h ) const {
49 return h.svtHitOnTrack() != 0 && ( !_activeOnly || h.isActive() );
50 }
51
52 private:
53 bool _activeOnly;
54 };
55
56 class isMdcHitOnTrack : public TrkHitOnTrk::predicate_type {
57 public:
58 isMdcHitOnTrack( bool activeOnly = false ) : _activeOnly( activeOnly ) {}
59 bool operator()( const TrkHitOnTrk& h ) const {
60 return h.mdcHitOnTrack() != 0 && ( !_activeOnly || h.isActive() );
61 }
62
63 private:
64 bool _activeOnly;
65 };
66
67 class hasView : public TrkHitOnTrk::predicate_type {
68 public:
70 bool operator()( const TrkHitOnTrk& h ) const {
71 if ( _view == TrkEnums::bothView ) return true;
72 TrkEnums::TrkViewInfo hotview = h.whatView();
73 if ( h.svtHitOnTrack() != 0 ) { return _view == hotview; }
74 else if ( h.mdcHitOnTrack() != 0 )
75 {
76 // unfortunately the Mdc calls stereo hits 'both view': I'm re-interpreting it here
77 return _view == TrkEnums::xyView && hotview == _view ||
78 _view == TrkEnums::zView && hotview == TrkEnums::bothView;
79 }
80 return false;
81 }
82
83 private:
85 };
86
87 class hotMatchesFundHit : public TrkHitOnTrk::predicate_type {
88 public:
89 hotMatchesFundHit( const TrkFundHit* h ) : _h( h ) {}
90 bool operator()( const TrkHitOnTrk& h ) const { return h.hit() == _h; }
91
92 private:
93 const TrkFundHit* _h;
94 };
95
96 struct isHotOnTrack : std::binary_function<TrkHitOnTrk, const TrkRecoTrk*, bool> {
97 bool operator()( const TrkHitOnTrk& h, const TrkRecoTrk* const& t ) const {
98 return h.parentTrack() == t;
99 }
100 };
101
102 struct isFitValid : TrkFitStatus::predicate_type {
103 bool operator()( const TrkFitStatus& t ) const { return ( t.fitValid() ); }
104 };
105
106 struct isFitCurrent : TrkFitStatus::predicate_type {
107 bool operator()( const TrkFitStatus& t ) const { return ( t.fitCurrent() ); }
108 };
109
110 // note that we use 'has' in here, not 'is' as above.... subtly distinction ;-)
111
112 struct hasFitValid : TrkRecoTrk::predicate_type {
113 bool operator()( const TrkRecoTrk& t ) const {
114 const TrkFitStatus* x = t.status();
115 return x != 0 && isFitValid()( *x );
116 }
117 };
118
119 struct hasFitCurrent : TrkRecoTrk::predicate_type {
120 bool operator()( const TrkRecoTrk& t ) const {
121 const TrkFitStatus* x = t.status();
122 return x != 0 && isFitCurrent()( *x );
123 }
124 };
125
126 } // namespace Predicates
127} // namespace TrkBase
std::unary_function< TrkFitStatus, bool > predicate_type
virtual const SvtHitOnTrack * svtHitOnTrack() const
virtual const MdcHitOnTrack * mdcHitOnTrack() const
std::unary_function< TrkHitOnTrk, bool > predicate_type
virtual TrkEnums::TrkViewInfo whatView() const =0
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