FairRoot/PandaRoot
Constraint.h
Go to the documentation of this file.
1 // ******************************************************
2 // DecayTreeFitter Package
3 // We thank the original author Wouter Hulsbergen
4 // (BaBar, LHCb) for providing the sources.
5 // http://arxiv.org/abs/physics/0503191v1 (2005)
6 // Adaptation & Development for PANDA: Ralf Kliemt (2015)
7 // ******************************************************
8 #ifndef DECAYTREEFITTER_CONSTRAINT_H
9 #define DECAYTREEFITTER_CONSTRAINT_H 1
10 
11 #include <string>
12 #include <iostream>
13 #include "ErrCode.h"
14 #include "Rtypes.h"
15 
16 namespace DecayTreeFitter
17 {
18  class ParticleBase ;
19  class Projection ;
20  class FitParams ;
21 
22  class Constraint
23  {
24  public:
25  // the order of these constraints is important: it is the order in
26  // which they are applied.
27 
28  enum Type { unknown=0,
42  ntypes} ;
43 
44  bool operator<(const Constraint& rhs) const ;
45 
46  bool operator==(const Constraint& rhs) const {
47  return m_type == rhs.m_type ; }
48 
49  // accessors
50  Type type() const { return m_type ; }
51  unsigned int dim() const { return m_dim ; }
52  bool isLineair() const { return m_maxNIter <=1 ; }
53  unsigned int nIter() const { return m_maxNIter ; }
54 
56 
57  Constraint( const ParticleBase* node, Type atype, int depth,
58  unsigned int adim,
59  int maxniter=1 /*, double precision=1e-5*/)
60  : m_node(node), m_depth(depth), m_type(atype), m_dim(adim),
61  m_weight(1), m_maxNIter(maxniter) {}
62 
63  virtual ~Constraint() {}
64 
65  virtual ErrCode project(const FitParams* fitpar, Projection& p) const ;
66  virtual ErrCode filter(FitParams* fitpar) const ;
67  virtual ErrCode filter(FitParams* fitpar,
68  const FitParams* reference) const ;
69  virtual void print(std::ostream& os=std::cout) const ;
70  std::string name() const ;
71 
72  // set to minus one if constraints needs to be removed on next filter
73  void setWeight(int w) { m_weight = w<0 ? -1 : 1 ; }
74 
75 
76  protected:
78  m_node(0),m_depth(0),m_type(atype),m_dim(0),
79  m_weight(0),m_maxNIter(0) {}
80  void setDim(unsigned int d) { m_dim = d ; }
81  void setNIter(unsigned int d) { m_maxNIter = d ; }
82  private:
84  int m_depth ;
86  unsigned int m_dim ;
87  // the weight: guassian constraint can be 'unfilter'
88  int m_weight ;
89  int m_maxNIter ; // maximum number of iterations for non-linear constraints
90  ClassDef ( Constraint,1 )
91  } ;
92 
93 }
94 
95 #endif
TObjArray * d
virtual ErrCode filter(FitParams *fitpar) const
Definition: Constraint.cxx:59
std::string name() const
Definition: Constraint.cxx:179
Constraint(Constraint::Type atype)
Definition: Constraint.h:77
unsigned int nIter() const
Definition: Constraint.h:53
bool operator==(const Constraint &rhs) const
Definition: Constraint.h:46
void setDim(unsigned int d)
Definition: Constraint.h:80
virtual void print(std::ostream &os=std::cout) const
Definition: Constraint.cxx:171
Double_t p
Definition: anasim.C:58
virtual ErrCode project(const FitParams *fitpar, Projection &p) const
Definition: Constraint.cxx:51
unsigned int dim() const
Definition: Constraint.h:51
Constraint(const ParticleBase *node, Type atype, int depth, unsigned int adim, int maxniter=1)
Definition: Constraint.h:57
void setNIter(unsigned int d)
Definition: Constraint.h:81
const ParticleBase * m_node
Definition: Constraint.h:83
bool operator<(const Constraint &rhs) const
Definition: Constraint.cxx:20