Belle II Software development
ParticleBase.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 <analysis/VertexFitting/TreeFitter/Constraint.h>
12
13#include <analysis/dataobjects/Particle.h>
14
15namespace TreeFitter {
16
17 class FitParams;
19 class Projection;
20
23
24 public:
25
27 enum TFParticleType {kInteractionPoint,
28 kOrigin,
29 kComposite,
30 kRecoResonance,
31 kInternalParticle,
32 kRecoTrack,
33 kResonance,
34 kRecoNeutral,
35 kMissingParticle
36 };
37
40
42 ParticleBase(const std::string& name);
43
45 virtual ~ParticleBase();
46
48 typedef std::vector<Constraint> constraintlist;
49
51 typedef std::vector< std::pair<const ParticleBase*, int> > indexmap;
52
55 const ParticleBase* mother,
56 const ConstraintConfiguration& config,
57 bool forceFitAll = false
58 );
59
62 const ConstraintConfiguration& config,
63 bool forceFitAll
64 );
65
68
71
73 virtual ErrCode initCovariance(FitParams&) const;
74
76 virtual int dim() const = 0 ;
77
79 virtual void updateIndex(int& offset);
80
82 virtual std::string parname(int index) const ;
83
86
88 Belle2::Particle* particle() const { return m_particle ; }
89
91 int index() const { return m_index ; }
92
94 const ParticleBase* mother() const { return m_mother; };
95
97 virtual ErrCode projectGeoConstraint(const FitParams&, Projection&) const ;
98
101
104
106 virtual ErrCode projectMassConstraint(const FitParams&, Projection&) const ;
107
110
112 virtual void forceP4Sum(FitParams&) const {} ;
113
115 virtual int type() const = 0 ;
116
118 virtual int posIndex() const { return -1 ; }
119
121 virtual int tauIndex() const { return -1 ; }
122
124 virtual int momIndex() const { return -1 ; }
125
126 // does the particle have a 3-momentum or a 4-momentum ?
128 virtual bool hasEnergy() const { return false ; }
129
131 virtual bool hasPosition() const { return false ; }
132
134 int eneIndex() const { return hasEnergy() ? momIndex() + 3 : -1 ; }
135
137 virtual double chiSquare(const FitParams&) const;
138
140 int charge() const
141 {
142 if (m_particle->getPDGCode()) {
143 double fltcharge = m_particle->getCharge();
144 return fltcharge < 0 ? int(fltcharge - 0.5) : int(fltcharge + 0.5);
145 } else {
146 return m_particle->getCharge() > 0 ? 1 : (m_particle->getCharge() < 0 ? -1 : 0);
147 }
148 }
149
151 virtual ParticleBase* addDaughter(Belle2::Particle*, const ConstraintConfiguration& config, bool forceFitAll = false);
152
154 virtual void removeDaughter(const ParticleBase* pb);
155
157 virtual void retrieveIndexMap(indexmap& anindexmap) const ;
158
160 void setMother(const ParticleBase* m) { m_mother = m ; }
161
163 virtual void addToConstraintList(constraintlist& alist, int depth) const = 0 ;
164
166 void collectVertexDaughters(std::vector<ParticleBase*>& particles, int posindex) ;
167
169 virtual int nFinalChargedCandidates() const;
170
171 protected:
172
174 typedef std::vector<ParticleBase*> ParticleContainer;
175
180
182 ErrCode initTau(FitParams& par) const ;
183
185 void setIndex(int i) { m_index = i ; }
186
189
192
194 std::vector<ParticleBase*> m_daughters;
195
198
201
202 private:
205
207 std::string m_name;
208
209 }; // end class ParticleBase
210} // end namespace TreeFitter
Class to store reconstructed particles.
Definition Particle.h:76
Type
type of constraints the order of these constraints is important: it is the order in which they are ap...
Definition Constraint.h:27
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
virtual void addToConstraintList(constraintlist &alist, int depth) const =0
add to constraint list
virtual void updateIndex(int &offset)
this sets the index for momentum, position, etc.
virtual ErrCode projectMassConstraintParticle(const FitParams &, Projection &) const
project mass constraint using the particles parameters
Belle2::Particle * particle() const
get basf2 particle
ErrCode initTau(FitParams &par) const
initialises tau as a length
virtual ParticleBase * addDaughter(Belle2::Particle *, const ConstraintConfiguration &config, bool forceFitAll=false)
add daughter
static ParticleBase * createOrigin(Belle2::Particle *daughter, const ConstraintConfiguration &config, bool forceFitAll)
create a custom origin particle or a beamspot
static ParticleBase * createParticle(Belle2::Particle *particle, const ParticleBase *mother, const ConstraintConfiguration &config, bool forceFitAll=false)
create the according treeFitter particle obj for a basf2 particle type
virtual int dim() const =0
get dimension of constraint
void setMother(const ParticleBase *m)
set mother
virtual int nFinalChargedCandidates() const
number of charged candidates
virtual void retrieveIndexMap(indexmap &anindexmap) const
get index map
virtual void forceP4Sum(FitParams &) const
force p4 sum conservation all along the tree
virtual ErrCode projectMassConstraint(const FitParams &, Projection &) const
project mass constraint abstract
const ConstraintConfiguration * m_config
has all the constraint config
virtual ErrCode initParticleWithMother(FitParams &)=0
init particle that does need a mother vertex
virtual std::string parname(int index) const
get name of parameter i
static bool isAResonance(Belle2::Particle *particle)
controls if a particle is treated as a resonance(lifetime=0) or a particle that has a finite lifetime...
virtual ErrCode projectConstraint(Constraint::Type, const FitParams &, Projection &) const
project constraint.
virtual ErrCode projectMassConstraintDaughters(const FitParams &, Projection &) const
project mass constraint using the parameters of the daughters
int eneIndex() const
get energy index
const ParticleBase * locate(Belle2::Particle *particle) const
get particle base from basf2 particle
void setIndex(int i)
set Index (in statevector)
std::vector< ParticleBase * > ParticleContainer
just an alias
virtual void removeDaughter(const ParticleBase *pb)
remove daughter
const ParticleBase * m_mother
motherparticle
bool m_isStronglyDecayingResonance
decay length less than 1 micron
virtual ErrCode initCovariance(FitParams &) const
init covariance matrix
virtual int type() const =0
get particle type
Belle2::Particle * m_particle
pointer to framework type
ParticleBase(Belle2::Particle *particle, const ParticleBase *mother, const ConstraintConfiguration *config=nullptr)
default constructor
virtual ErrCode initMotherlessParticle(FitParams &)=0
init particle that does not need a mother vertex
virtual ErrCode projectGeoConstraint(const FitParams &, Projection &) const
project geometrical constraint
virtual double chiSquare(const FitParams &) const
get chi2
virtual int posIndex() const
get vertex index (in statevector!)
std::vector< std::pair< const ParticleBase *, int > > indexmap
alias
virtual int momIndex() const
get momentum index
int index() const
get index
virtual bool hasEnergy() const
get momentum dimension
std::vector< ParticleBase * > m_daughters
daughter container
TFParticleType
particle types
virtual ~ParticleBase()
destructor, actually does something
void collectVertexDaughters(std::vector< ParticleBase * > &particles, int posindex)
get vertex daughters
virtual int tauIndex() const
get tau index
int charge() const
get charge
const ParticleBase * mother() const
getMother() / hasMother()
virtual bool hasPosition() const
get false
std::vector< Constraint > constraintlist
alias
class to store the projected residuals and the corresponding jacobian as well as the covariance matri...
Definition Projection.h:18