BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
Reconstruction/MdcPatRec/TrkBase/include/TrkBase/TrkFunctors.h
Go to the documentation of this file.
1//--------------------------------------------------------------------------
2// File and Version Information:
3// $Id: TrkFunctors.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, Z> or binary_function<X,Y,Z> and
10// provide Z operator()(const X&,const Y&) const.
11//
12// Environment:
13// Software developed for the BaBar Detector at the SLAC B-Factory.
14//
15// Author List:
16// Gerhard Raven
17//------------------------------------------------------------------------
18#ifndef TRKFUNCTORS_H
19#define TRKFUNCTORS_H
20#include <functional>
21
22#include "TrkBase/TrkErrCode.h"
23#include "TrkBase/TrkHitOnTrk.h"
25class TrkRep;
26
27namespace TrkBase {
28 namespace Functors {
29
30 class cloneHot : public std::unary_function<TrkHitOnTrk, TrkHitOnTrk*> {
31 public:
32 cloneHot( TrkRep* parentRep, const TrkDifTraj* trkTraj = 0 )
33 : _r( parentRep ), _t( trkTraj ) {}
34
35 TrkHitOnTrk* operator()( const TrkHitOnTrk& h ) const { return h.clone( _r, _t ); }
36
37 private:
38 TrkRep* _r;
39 const TrkDifTraj* _t;
40 };
41
42 template <class T> struct takeAddress : std::unary_function<T, T*> {
43 T* operator()( T& t ) { return &t; }
44 };
45
46 // Functors which are only accessible by inheriting from TrkHitOnTrkUpdater
47 // FIXME: maybe these should live in the TrkHitOnTrkUpdater namespace instead???
48
49 class updateMeasurement : public std::unary_function<TrkHitOnTrk, TrkErrCode> {
50 public:
51 TrkErrCode operator()( TrkHitOnTrk& h ) const { return h.updateMeasurement( _t, _m ); }
52
53 private:
54 // Only TrkHitOnTrkUpdater can create one of these...
55 friend class ::TrkHitOnTrkUpdater;
56 updateMeasurement( const TrkDifTraj* traj = 0, bool maintainAmbiguity = false )
57 : _t( traj ), _m( maintainAmbiguity ) {}
58 const TrkDifTraj* _t;
59 bool _m;
60 };
61
62 class setActive : public std::unary_function<TrkHitOnTrk, void> {
63 public:
64 TrkHitOnTrk* operator()( TrkHitOnTrk& h ) const { return h.setActive( _a ); }
65 TrkHitOnTrk* operator()( TrkHitOnTrk*& h ) const { return h->setActive( _a ); }
66
67 private:
68 // Only TrkHitOnTrkUpdater can create one of these...
69 friend class ::TrkHitOnTrkUpdater;
70 setActive( bool active ) : _a( active ) {}
71 bool _a;
72 };
73
74 class setParent : public std::unary_function<TrkHitOnTrk, void> {
75 public:
76 TrkHitOnTrk* operator()( TrkHitOnTrk& h ) const { return h.setParent( _p ); }
77
78 private:
79 // Only TrkHitOnTrkUpdater can create one of these...
80 friend class ::TrkHitOnTrkUpdater;
81 setParent( TrkRep* parent ) : _p( parent ) {}
82 TrkRep* _p;
83 };
84 } // namespace Functors
85} // namespace TrkBase
86#endif
virtual TrkErrCode updateMeasurement(const TrkDifTraj *traj, bool maintainAmbiguity)=0
virtual TrkHitOnTrk * clone(TrkRep *parentRep, const TrkDifTraj *trkTraj=0) const =0
int t()
Definition t.c:1