Belle II Software  release-06-01-15
Constraint.h
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * External Contributor: Wouter Hulsbergen *
5  * *
6  * See git log for contributors and copyright holders. *
7  * This file is licensed under LGPL-3.0, see LICENSE.md. *
8  **************************************************************************/
9 #pragma once
10 
11 #include <string>
12 #include <analysis/VertexFitting/TreeFitter/ErrCode.h>
13 
14 namespace TreeFitter {
15  class ParticleBase ;
16  class Projection ;
17  class FitParams ;
18 
20  class Constraint {
21  public:
27  enum Type { unknown = 0,
28  beamenergy,
29  beamspot,
30  origin,
31  lifetime,
32  resonance,
33  composite,
34  track,
35  photon,
36  klong,
37  conversion,
38  kinematic,
39  geometric,
40  mass,
41  massEnergy,
42  merged,
43  ntypes,
44  helix
45  };
46 
48  bool operator<(const Constraint& rhs) const;
49 
51  bool operator==(const Constraint& rhs) const
52  {
53  return m_type == rhs.m_type;
54  }
55 
57  Type type() const { return m_type; }
58 
60  unsigned int dim() const { return m_dim; }
61 
63  bool isLinear() const { return m_maxNIter <= 1; }
64 
66  unsigned int nIter() const { return m_maxNIter; }
67 
70  m_node(0),
71  m_depth(0),
72  m_type(unknown),
73  m_dim(0),
74  m_weight(0),
75  m_maxNIter(0) {}
76 
78  Constraint(const ParticleBase* node,
79  Type type,
80  int depth,
81  unsigned int dim,
82  int maxniter = 1) :
83  m_node(node),
84  m_depth(depth),
85  m_type(type),
86  m_dim(dim),
87  m_weight(1),
88  m_maxNIter(maxniter) {}
89 
91  virtual ~Constraint() {}
92 
94  virtual ErrCode project(const FitParams& fitpar, Projection& p) const;
95 
97  virtual ErrCode filter(FitParams& fitpar);
98 
100  virtual ErrCode filterWithReference(FitParams& fitpar, const FitParams& oldState);
101 
103  std::string name() const;
104 
108  [[gnu::unused]] void setWeight(int w) { m_weight = w < 0 ? -1 : 1; }
109 
110  protected:
111 
114  m_node(0),
115  m_depth(0),
116  m_type(type),
117  m_dim(0),
118  m_weight(0),
119  m_maxNIter(0) {}
120 
122  void setDim(unsigned int d) { m_dim = d; }
123 
125  void setNIter(unsigned int d) { m_maxNIter = d; }
126 
127  private:
128 
131 
136  int m_depth;
137 
140 
142  unsigned int m_dim;
143 
145  int m_weight;
146 
149  };
150 
151 }
class to manage the order of constraints and their filtering
Definition: Constraint.h:20
Type m_type
type of constraint
Definition: Constraint.h:139
bool isLinear() const
is this a linear constraint
Definition: Constraint.h:63
Type
type of constraints the order of these constraints is important: it is the order in which they are ap...
Definition: Constraint.h:27
std::string name() const
get name of constraint
Definition: Constraint.cc:124
unsigned int dim() const
get dimension of constraint
Definition: Constraint.h:60
void setNIter(unsigned int d)
set max number of iterations for non lin constraint
Definition: Constraint.h:125
bool operator==(const Constraint &rhs) const
operator
Definition: Constraint.h:51
virtual ~Constraint()
destructor
Definition: Constraint.h:91
Constraint()
constructor
Definition: Constraint.h:69
int m_weight
weight of this constraint currently we set them all to unity
Definition: Constraint.h:145
int m_depth
chi2 coming from the constraint
Definition: Constraint.h:136
Constraint(Constraint::Type type)
constructor
Definition: Constraint.h:113
unsigned int m_dim
dimension of constraint
Definition: Constraint.h:142
int m_maxNIter
maximum number of iterations for non-linear constraints
Definition: Constraint.h:148
virtual ErrCode filterWithReference(FitParams &fitpar, const FitParams &oldState)
filter this constraint
Definition: Constraint.cc:83
void setDim(unsigned int d)
set dimension of constraint
Definition: Constraint.h:122
Constraint(const ParticleBase *node, Type type, int depth, unsigned int dim, int maxniter=1)
constructor
Definition: Constraint.h:78
bool operator<(const Constraint &rhs) const
operator used to sort the constraints
Definition: Constraint.cc:17
unsigned int nIter() const
get maximum number of iterations for non in constraint
Definition: Constraint.h:66
void setWeight(int w)
used to be able to weight the constraints
Definition: Constraint.h:108
const ParticleBase * m_node
particle behind the constraint
Definition: Constraint.h:130
virtual ErrCode filter(FitParams &fitpar)
filter this constraint
Definition: Constraint.cc:28
Type type() const
get type of constraint
Definition: Constraint.h:57
virtual ErrCode project(const FitParams &fitpar, Projection &p) const
call the constraints projection function
Definition: Constraint.cc:23
abstract errorocode be aware that the default is success
Definition: ErrCode.h:14
Class to store and manage fitparams (statevector)
Definition: FitParams.h:20
base class for all particles
Definition: ParticleBase.h:25
class to store the projected residuals and the corresponding jacobian as well as the covariance matri...
Definition: Projection.h:18