Belle II Software development
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
14namespace 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 beam,
31 origin,
32 lifetime,
33 resonance,
34 composite,
35 track,
36 photon,
37 klong,
38 conversion,
39 kinematic,
40 geometric,
41 mass,
42 massEnergy,
43 merged,
44 ntypes,
45 helix
46 };
47
49 bool operator<(const Constraint& rhs) const;
50
52 bool operator==(const Constraint& rhs) const
53 {
54 return m_type == rhs.m_type;
55 }
56
58 Type type() const { return m_type; }
59
61 unsigned int dim() const { return m_dim; }
62
64 bool isLinear() const { return m_maxNIter <= 1; }
65
67 unsigned int nIter() const { return m_maxNIter; }
68
71 m_node(0),
72 m_depth(0),
73 m_type(unknown),
74 m_dim(0),
75 m_weight(0),
76 m_maxNIter(0) {}
77
80 Type type,
81 int depth,
82 unsigned int dim,
83 int maxniter = 1) :
84 m_node(node),
85 m_depth(depth),
86 m_type(type),
87 m_dim(dim),
88 m_weight(1),
89 m_maxNIter(maxniter) {}
90
92 virtual ~Constraint() {}
93
95 virtual ErrCode project(const FitParams& fitpar, Projection& p) const;
96
98 virtual ErrCode filter(FitParams& fitpar);
99
101 virtual ErrCode filterWithReference(FitParams& fitpar, const FitParams& oldState);
102
104 std::string name() const;
105
109 [[gnu::unused]] void setWeight(int w) { m_weight = w < 0 ? -1 : 1; }
110
111 protected:
112
115 m_node(0),
116 m_depth(0),
117 m_type(type),
118 m_dim(0),
119 m_weight(0),
120 m_maxNIter(0) {}
121
123 void setDim(unsigned int d) { m_dim = d; }
124
126 void setNIter(unsigned int d) { m_maxNIter = d; }
127
128 private:
129
132
138
141
143 unsigned int m_dim;
144
147
150 };
151
152}
class to manage the order of constraints and their filtering
Definition: Constraint.h:20
Type m_type
type of constraint
Definition: Constraint.h:140
bool isLinear() const
is this a linear constraint
Definition: Constraint.h:64
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:61
void setNIter(unsigned int d)
set max number of iterations for non lin constraint
Definition: Constraint.h:126
bool operator==(const Constraint &rhs) const
operator
Definition: Constraint.h:52
virtual ~Constraint()
destructor
Definition: Constraint.h:92
Constraint()
constructor
Definition: Constraint.h:70
int m_weight
weight of this constraint currently we set them all to unity
Definition: Constraint.h:146
int m_depth
chi2 coming from the constraint
Definition: Constraint.h:137
Constraint(Constraint::Type type)
constructor
Definition: Constraint.h:114
unsigned int m_dim
dimension of constraint
Definition: Constraint.h:143
int m_maxNIter
maximum number of iterations for non-linear constraints
Definition: Constraint.h:149
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:123
Constraint(const ParticleBase *node, Type type, int depth, unsigned int dim, int maxniter=1)
constructor
Definition: Constraint.h:79
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:67
void setWeight(int w)
used to be able to weight the constraints
Definition: Constraint.h:109
const ParticleBase * m_node
particle behind the constraint
Definition: Constraint.h:131
virtual ErrCode filter(FitParams &fitpar)
filter this constraint
Definition: Constraint.cc:28
Type type() const
get type of constraint
Definition: Constraint.h:58
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