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 class ParticleBase;
18 class Projection;
19 class FitParams;
20 
21 class Constraint {
22  public:
23  // the order of these constraints is important: it is the order in
24  // which they are applied.
25 
27 
28  bool operator<(const Constraint &rhs) const;
29 
30  bool operator==(const Constraint &rhs) const { return m_type == rhs.m_type; }
31 
32  // accessors
33  Type type() const { return m_type; }
34  unsigned int dim() const { return m_dim; }
35  bool isLineair() const { return m_maxNIter <= 1; }
36  unsigned int nIter() const { return m_maxNIter; }
37 
38  Constraint() : m_node(nullptr), m_depth(0), m_type(unknown), m_dim(0) {}
39 
40  Constraint(const ParticleBase *node, Type atype, int depth, unsigned int adim, int maxniter = 1 /*, double precision=1e-5*/)
41  : m_node(node), m_depth(depth), m_type(atype), m_dim(adim), m_weight(1), m_maxNIter(maxniter)
42  {
43  }
44 
45  virtual ~Constraint() {}
46 
47  virtual ErrCode project(const FitParams *fitpar, Projection &p) const;
48  virtual ErrCode filter(FitParams *fitpar) const;
49  virtual ErrCode filter(FitParams *fitpar, const FitParams *reference) const;
50  virtual void print(std::ostream &os = std::cout) const;
51  std::string name() const;
52 
53  // set to minus one if constraints needs to be removed on next filter
54  void setWeight(int w) { m_weight = w < 0 ? -1 : 1; }
55 
56  protected:
57  Constraint(Constraint::Type atype) : m_node(nullptr), m_depth(0), m_type(atype), m_dim(0), m_weight(0), m_maxNIter(0) {}
58  void setDim(unsigned int d) { m_dim = d; }
59  void setNIter(unsigned int d) { m_maxNIter = d; }
60 
61  private:
62  const ParticleBase *m_node;
63  int m_depth;
64  Type m_type;
65  unsigned int m_dim;
66  // the weight: guassian constraint can be 'unfilter'
67  int m_weight;
68  int m_maxNIter; // maximum number of iterations for non-linear constraints
69  ClassDef(Constraint, 1)
70 };
71 
72 } // namespace DecayTreeFitter
73 
74 #endif
Constraint(Constraint::Type atype)
Definition: Constraint.h:57
void setDim(unsigned int d)
Definition: Constraint.h:58
bool operator<(const Constraint &rhs) const
virtual ErrCode project(const FitParams *fitpar, Projection &p) const
unsigned int nIter() const
Definition: Constraint.h:36
bool operator==(const Constraint &rhs) const
Definition: Constraint.h:30
unsigned int dim() const
Definition: Constraint.h:34
Constraint(const ParticleBase *node, Type atype, int depth, unsigned int adim, int maxniter=1)
Definition: Constraint.h:40
virtual void print(std::ostream &os=std::cout) const
std::string name() const
void setNIter(unsigned int d)
Definition: Constraint.h:59
virtual ErrCode filter(FitParams *fitpar) const