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#include <analysis/VertexFitting/TreeFitter/Projection.h>
13#include <analysis/VertexFitting/TreeFitter/ErrCode.h>
14#include <analysis/VertexFitting/TreeFitter/ConstraintConfiguration.h>
15#include <Eigen/Core>
16
17#include <analysis/dataobjects/Particle.h>
18
19namespace TreeFitter {
20
21 class FitParams;
22 class ConstraintConfiguration;
23
26
27 public:
28
30 enum TFParticleType {kInteractionPoint,
31 kOrigin,
32 kComposite,
33 kRecoResonance,
34 kInternalParticle,
35 kRecoTrack,
36 kResonance,
37 kRecoPhoton,
38 kRecoKlong,
39 kMissingParticle
40 };
41
44
46 ParticleBase(const std::string& name);
47
49 virtual ~ParticleBase();
50
52 typedef std::vector<Constraint> constraintlist;
53
55 typedef std::vector< std::pair<const ParticleBase*, int> > indexmap;
56
59 const ParticleBase* mother,
60 const ConstraintConfiguration& config,
61 bool forceFitAll = false
62 );
63
66 const ConstraintConfiguration& config,
67 bool forceFitAll
68 );
69
72
75
77 virtual ErrCode initCovariance(FitParams&) const;
78
80 virtual int dim() const = 0 ;
81
83 virtual void updateIndex(int& offset);
84
86 virtual std::string parname(int index) const ;
87
90
92 Belle2::Particle* particle() const { return m_particle ; }
93
95 int index() const { return m_index ; }
96
98 const ParticleBase* mother() const { return m_mother; };
99
101 virtual ErrCode projectGeoConstraint(const FitParams&, Projection&) const ;
102
105
108
110 virtual ErrCode projectMassConstraint(const FitParams&, Projection&) const ;
111
114
116 virtual void forceP4Sum(FitParams&) const {} ;
117
119 virtual int type() const = 0 ;
120
122 virtual int posIndex() const { return -1 ; }
123
125 virtual int tauIndex() const { return -1 ; }
126
128 virtual int momIndex() const { return -1 ; }
129
130 // does the particle have a 3-momentum or a 4-momentum ?
132 virtual bool hasEnergy() const { return false ; }
133
135 virtual bool hasPosition() const { return false ; }
136
138 int eneIndex() const { return hasEnergy() ? momIndex() + 3 : -1 ; }
139
141 virtual double chiSquare(const FitParams&) const;
142
144 int charge() const
145 {
146 if (m_particle->getPDGCode()) {
147 double fltcharge = m_particle->getCharge();
148 return fltcharge < 0 ? int(fltcharge - 0.5) : int(fltcharge + 0.5);
149 } else {
150 return m_particle->getCharge() > 0 ? 1 : (m_particle->getCharge() < 0 ? -1 : 0);
151 }
152 }
153
155 virtual ParticleBase* addDaughter(Belle2::Particle*, const ConstraintConfiguration& config, bool forceFitAll = false);
156
158 virtual void removeDaughter(const ParticleBase* pb);
159
161 virtual void retrieveIndexMap(indexmap& anindexmap) const ;
162
164 void setMother(const ParticleBase* m) { m_mother = m ; }
165
167 virtual void addToConstraintList(constraintlist& alist, int depth) const = 0 ;
168
170 void collectVertexDaughters(std::vector<ParticleBase*>& particles, int posindex) ;
171
173 virtual int nFinalChargedCandidates() const;
174
175 protected:
176
178 typedef std::vector<ParticleBase*> ParticleContainer;
179
184
186 ErrCode initTau(FitParams& par) const ;
187
189 void setIndex(int i) { m_index = i ; }
190
193
196
198 std::vector<ParticleBase*> m_daughters;
199
202
205
206 private:
209
211 std::string m_name;
212
213 }; // end class ParticleBase
214} // end namespace TreeFitter
Class to store reconstructed particles.
Definition: Particle.h:75
int getPDGCode(void) const
Returns PDG code.
Definition: Particle.h:454
double getCharge(void) const
Returns particle charge.
Definition: Particle.cc:622
constraint configuration class
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
Definition: ParticleBase.h:25
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.
Definition: ParticleBase.cc:84
virtual ErrCode projectMassConstraintParticle(const FitParams &, Projection &) const
project mass constraint using the particles parameters
Belle2::Particle * particle() const
get basf2 particle
Definition: ParticleBase.h:92
ErrCode initTau(FitParams &par) const
initialises tau as a length
virtual ParticleBase * addDaughter(Belle2::Particle *, const ConstraintConfiguration &config, bool forceFitAll=false)
add daughter
Definition: ParticleBase.cc:65
static ParticleBase * createOrigin(Belle2::Particle *daughter, const ConstraintConfiguration &config, bool forceFitAll)
create a custom origin particle or a beamspot
Definition: ParticleBase.cc:93
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
Definition: ParticleBase.h:164
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
Definition: ParticleBase.h:116
virtual ErrCode projectMassConstraint(const FitParams &, Projection &) const
project mass constraint abstract
const ConstraintConfiguration * m_config
has all the constraint config
Definition: ParticleBase.h:204
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
Definition: ParticleBase.h:138
const ParticleBase * locate(Belle2::Particle *particle) const
get particle base from basf2 particle
void setIndex(int i)
set Index (in statevector)
Definition: ParticleBase.h:189
std::vector< ParticleBase * > ParticleContainer
just an alias
Definition: ParticleBase.h:178
virtual void removeDaughter(const ParticleBase *pb)
remove daughter
Definition: ParticleBase.cc:73
const ParticleBase * m_mother
motherparticle
Definition: ParticleBase.h:195
bool m_isStronglyDecayingResonance
decay length less than 1 micron
Definition: ParticleBase.h:201
virtual ErrCode initCovariance(FitParams &) const
init covariance matrix
virtual int type() const =0
get particle type
Belle2::Particle * m_particle
pointer to framework type
Definition: ParticleBase.h:192
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!)
Definition: ParticleBase.h:122
std::vector< std::pair< const ParticleBase *, int > > indexmap
alias
Definition: ParticleBase.h:55
virtual int momIndex() const
get momentum index
Definition: ParticleBase.h:128
int index() const
get index
Definition: ParticleBase.h:95
virtual bool hasEnergy() const
get momentum dimension
Definition: ParticleBase.h:132
std::vector< ParticleBase * > m_daughters
daughter container
Definition: ParticleBase.h:198
TFParticleType
particle types
Definition: ParticleBase.h:30
std::string m_name
name
Definition: ParticleBase.h:211
virtual ~ParticleBase()
destructor, actually does something
Definition: ParticleBase.cc:57
void collectVertexDaughters(std::vector< ParticleBase * > &particles, int posindex)
get vertex daughters
virtual int tauIndex() const
get tau index
Definition: ParticleBase.h:125
int charge() const
get charge
Definition: ParticleBase.h:144
const ParticleBase * mother() const
getMother() / hasMother()
Definition: ParticleBase.h:98
virtual bool hasPosition() const
get false
Definition: ParticleBase.h:135
std::vector< Constraint > constraintlist
alias
Definition: ParticleBase.h:52
class to store the projected residuals and the corresponding jacobian as well as the covariance matri...
Definition: Projection.h:18