PandaRoot
Constraint.h
Go to the documentation of this file.
1 //****************************************************************************
2 //* This file is part of PandaRoot. *
3 //* *
4 //* PandaRoot is distributed under the terms of the *
5 //* GNU General Public License (GPL) version 3, *
6 //* copied verbatim in the file "LICENSE". *
7 //* *
8 //* Copyright (C) 2006 - 2024 FAIR GmbH and copyright holders of PandaRoot *
9 //* The copyright holders are listed in the file "COPYRIGHTHOLDERS". *
10 //* The authors are listed in the file "AUTHORS". *
11 //****************************************************************************
12 
13 // ******************************************************
14 // DecayTreeFitter Package
15 // We thank the original author Wouter Hulsbergen
16 // (BaBar, LHCb) for providing the sources.
17 // http://arxiv.org/abs/physics/0503191v1 (2005)
18 // Adaptation & Development for PANDA: Ralf Kliemt (2015)
19 // ******************************************************
20 #ifndef DECAYTREEFITTER_CONSTRAINT_H
21 #define DECAYTREEFITTER_CONSTRAINT_H 1
22 
23 #include <string>
24 #include <iostream>
25 #include "ErrCode.h"
26 #include "Rtypes.h"
27 
28 namespace DecayTreeFitter {
29 class ParticleBase;
30 class Projection;
31 class FitParams;
32 
33 class Constraint {
34  public:
35  // the order of these constraints is important: it is the order in
36  // which they are applied.
37 
39 
40  bool operator<(const Constraint &rhs) const;
41 
42  bool operator==(const Constraint &rhs) const { return m_type == rhs.m_type; }
43 
44  // accessors
45  Type type() const { return m_type; }
46  unsigned int dim() const { return m_dim; }
47  bool isLineair() const { return m_maxNIter <= 1; }
48  unsigned int nIter() const { return m_maxNIter; }
49 
50  Constraint() : m_node(nullptr), m_depth(0), m_type(unknown), m_dim(0) {}
51 
52  Constraint(const ParticleBase *node, Type atype, int depth, unsigned int adim, int maxniter = 1 /*, double precision=1e-5*/)
53  : m_node(node), m_depth(depth), m_type(atype), m_dim(adim), m_weight(1), m_maxNIter(maxniter)
54  {
55  }
56 
57  virtual ~Constraint() {}
58 
59  virtual ErrCode project(const FitParams *fitpar, Projection &p) const;
60  virtual ErrCode filter(FitParams *fitpar) const;
61  virtual ErrCode filter(FitParams *fitpar, const FitParams *reference) const;
62  virtual void print(std::ostream &os = std::cout) const;
63  std::string name() const;
64 
65  // set to minus one if constraints needs to be removed on next filter
66  void setWeight(int w) { m_weight = w < 0 ? -1 : 1; }
67 
68  protected:
69  Constraint(Constraint::Type atype) : m_node(nullptr), m_depth(0), m_type(atype), m_dim(0), m_weight(0), m_maxNIter(0) {}
70  void setDim(unsigned int d) { m_dim = d; }
71  void setNIter(unsigned int d) { m_maxNIter = d; }
72 
73  private:
74  const ParticleBase *m_node;
75  int m_depth;
76  Type m_type;
77  unsigned int m_dim;
78  // the weight: guassian constraint can be 'unfilter'
79  int m_weight;
80  int m_maxNIter; // maximum number of iterations for non-linear constraints
81  ClassDef(Constraint, 1)
82 };
83 
84 } // namespace DecayTreeFitter
85 
86 #endif
Constraint(Constraint::Type atype)
Definition: Constraint.h:69
void setDim(unsigned int d)
Definition: Constraint.h:70
bool operator<(const Constraint &rhs) const
virtual ErrCode project(const FitParams *fitpar, Projection &p) const
unsigned int nIter() const
Definition: Constraint.h:48
bool operator==(const Constraint &rhs) const
Definition: Constraint.h:42
unsigned int dim() const
Definition: Constraint.h:46
Constraint(const ParticleBase *node, Type atype, int depth, unsigned int adim, int maxniter=1)
Definition: Constraint.h:52
virtual void print(std::ostream &os=std::cout) const
std::string name() const
void setNIter(unsigned int d)
Definition: Constraint.h:71
virtual ErrCode filter(FitParams *fitpar) const