Belle II Software  release-05-02-19
ParticleBase.h
1 /**************************************************************************
2  *
3  * BASF2 (Belle Analysis Framework 2) *
4  * Copyright(C) 2013 - Belle II Collaboration *
5  * *
6  * Author: The Belle II Collaboration *
7  * Contributor: Wouter Hulsbergen, Francesco Tenchini, Jo-Frederik Krohn *
8  * *
9  * This software is provided "as is" without any warranty. *
10  **************************************************************************/
11 #pragma once
12 
13 #include <analysis/VertexFitting/TreeFitter/Constraint.h>
14 #include <analysis/VertexFitting/TreeFitter/Projection.h>
15 #include <analysis/VertexFitting/TreeFitter/ErrCode.h>
16 #include <analysis/VertexFitting/TreeFitter/ConstraintConfiguration.h>
17 #include <Eigen/Core>
18 
19 #include <analysis/dataobjects/Particle.h>
20 
21 namespace TreeFitter {
22 
23  class FitParams;
24  class ConstraintConfiguration;
25 
27  class ParticleBase {
28 
29  public:
30 
32  enum TFParticleType {kInteractionPoint,
33  kOrigin,
34  kRecoComposite,
35  kRecoResonance,
36  kInternalParticle,
37  kRecoTrack,
38  kResonance,
39  kRecoPhoton,
40  kRecoKlong,
41  kMissingParticle,
42  kFeedthroughParticle,
43  kInternalTrack
44  };
45 
48 
51 
52 
54  ParticleBase(const std::string& name);
55 
57  virtual ~ParticleBase();
58 
60  typedef std::vector<Constraint> constraintlist;
61 
63  typedef std::vector< std::pair<const ParticleBase*, int> > indexmap;
64 
67  const ParticleBase* mother,
68  const ConstraintConfiguration& config,
69  bool forceFitAll = false
70  );
71 
73  static ParticleBase* createOrigin(Belle2::Particle* daughter,
74  const ConstraintConfiguration& config,
75  bool forceFitAll
76  );
77 
80 
83 
85  virtual ErrCode initCovariance(FitParams&) const;
86 
88  virtual int dim() const = 0 ;
89 
91  virtual void updateIndex(int& offset);
92 
94  virtual std::string parname(int index) const ;
95 
98 
100  Belle2::Particle* particle() const { return m_particle ; }
101 
103  int index() const { return m_index ; }
104 
106  const ParticleBase* mother() const;
107 
109  const std::string& name() const { return m_name ; }
110 
113 
116 
119 
121  virtual ErrCode projectMassConstraint(const FitParams&, Projection&) const ;
122 
125 
127  virtual void forceP4Sum(FitParams&) const {} ;
128 
130  virtual int type() const = 0 ;
131 
133  virtual int posIndex() const { return -1 ; }
134 
136  virtual int tauIndex() const { return -1 ; }
137 
139  virtual int momIndex() const { return -1 ; }
140 
141  // does the particle have a 3-momentum or a 4-momentum ?
143  virtual bool hasEnergy() const { return false ; }
144 
146  virtual bool hasPosition() const { return false ; }
147 
149  int eneIndex() const { return hasEnergy() ? momIndex() + 3 : -1 ; }
150 
152  virtual double chiSquare(const FitParams&) const;
153 
155  double pdgMass() const { return m_pdgMass ; }
156 
158  double pdgWidth() const { return m_pdgWidth ; }
159 
161  double pdgLifeTime() const { return m_pdgLifeTime ; }
162 
164  double pdgTime() const { return m_pdgMass > 0 ? m_pdgLifeTime : 0; }
165 
167  int charge() const { return m_charge ; }
168 
170  virtual ParticleBase* addDaughter(Belle2::Particle*, const ConstraintConfiguration& config, bool forceFitAll = false);
171 
173  virtual void removeDaughter(const ParticleBase* pb);
174 
176  virtual void retrieveIndexMap(indexmap& anindexmap) const ;
177 
179  void setMother(const ParticleBase* m) { m_mother = m ; }
180 
182  virtual void addToConstraintList(constraintlist& alist, int depth) const = 0 ;
183 
185  void collectVertexDaughters(std::vector<ParticleBase*>& particles, int posindex) ;
186 
188  virtual int nFinalChargedCandidates() const;
189 
192 
193  protected:
194 
196  typedef std::vector<ParticleBase*> ParticleContainer;
197 
199  static double pdgLifeTime(Belle2::Particle* particle) ;
200 
204  static bool isAResonance(Belle2::Particle* particle) ;
205 
207  static double bFieldOverC();
208 
210  ErrCode initTau(FitParams& par) const ;
211 
213  void setIndex(int i) { m_index = i ; }
214 
217 
219  const ParticleBase* m_mother;
220 
222  std::vector<ParticleBase*> m_daughters;
223 
226 
229 
230  private:
232  int m_index;
233 
235  const double m_pdgMass;
236 
238  double m_pdgWidth;
239 
241  const double m_pdgLifeTime;
242 
244  int m_charge;
245 
247  std::string m_name;
248 
249  }; // end class ParticleBase
250 } // end namespace TreeFitter
TreeFitter::ParticleBase::projectConstraint
virtual ErrCode projectConstraint(Constraint::Type, const FitParams &, Projection &) const
project constraint.
Definition: ParticleBase.cc:537
TreeFitter::ParticleBase::projectMassConstraint
virtual ErrCode projectMassConstraint(const FitParams &, Projection &) const
project mass constraint abstract
Definition: ParticleBase.cc:526
TreeFitter::ParticleBase::dim
virtual int dim() const =0
get dimension of constraint
TreeFitter::ParticleBase::name
const std::string & name() const
get name of the particle
Definition: ParticleBase.h:118
TreeFitter::ParticleBase::createParticle
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
Definition: ParticleBase.cc:156
TreeFitter::ParticleBase::setMother
void setMother(const ParticleBase *m)
set mother
Definition: ParticleBase.h:188
TreeFitter::ConstraintConfiguration
constainer
Definition: ConstraintConfiguration.h:25
TreeFitter::ParticleBase::nFinalChargedCandidates
virtual int nFinalChargedCandidates() const
number of charged candidates
Definition: ParticleBase.cc:350
TreeFitter::ParticleBase::locate
const ParticleBase * locate(Belle2::Particle *particle) const
get particle base from basf2 particle
Definition: ParticleBase.cc:321
TreeFitter::ParticleBase::ParticleBase
ParticleBase(Belle2::Particle *particle, const ParticleBase *mother, const ConstraintConfiguration *config)
default constructor
Definition: ParticleBase.cc:41
TreeFitter::ParticleBase::projectMassConstraintDaughters
virtual ErrCode projectMassConstraintDaughters(const FitParams &, Projection &) const
project mass constraint using the parameters of the daughters
Definition: ParticleBase.cc:435
TreeFitter::ErrCode
abstract errorocode be aware that the default is succes
Definition: ErrCode.h:23
TreeFitter::ParticleBase::type
virtual int type() const =0
get particle type
TreeFitter::ParticleBase::pdgMass
double pdgMass() const
get pdg mass
Definition: ParticleBase.h:164
TreeFitter::ParticleBase
base class for all particles
Definition: ParticleBase.h:36
TreeFitter::ParticleBase::chiSquare
virtual double chiSquare(const FitParams &) const
get chi2
Definition: ParticleBase.cc:341
TreeFitter::ParticleBase::initParticleWithMother
virtual ErrCode initParticleWithMother(FitParams &)=0
init particle that does need a mother vertex
TreeFitter::FitParams
Class to store and manage fitparams (statevector)
Definition: FitParams.h:29
TreeFitter::ParticleBase::eneIndex
int eneIndex() const
get energy index
Definition: ParticleBase.h:158
TreeFitter::ParticleBase::~ParticleBase
virtual ~ParticleBase()
destructor, actually does something
Definition: ParticleBase.cc:111
TreeFitter::ParticleBase::setIndex
void setIndex(int i)
set Index (in statevector)
Definition: ParticleBase.h:222
TreeFitter::ParticleBase::initTau
ErrCode initTau(FitParams &par) const
initialises tau as a length
Definition: ParticleBase.cc:553
TreeFitter::ParticleBase::setParticle
void setParticle(Belle2::Particle *particle)
set the relation to basf2 particle type
Definition: ParticleBase.h:200
TreeFitter::ParticleBase::bFieldOverC
static double bFieldOverC()
Bz/c
Definition: ParticleBase.cc:548
TreeFitter::ParticleBase::m_pdgMass
const double m_pdgMass
pdg mass
Definition: ParticleBase.h:244
TreeFitter::ParticleBase::pdgWidth
double pdgWidth() const
get pdg width
Definition: ParticleBase.h:167
TreeFitter::ParticleBase::m_name
std::string m_name
name
Definition: ParticleBase.h:256
TreeFitter::ParticleBase::addToConstraintList
virtual void addToConstraintList(constraintlist &alist, int depth) const =0
add to constraint list
TreeFitter::ParticleBase::isAResonance
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...
Definition: ParticleBase.cc:235
TreeFitter::ParticleBase::createOrigin
static ParticleBase * createOrigin(Belle2::Particle *daughter, const ConstraintConfiguration &config, bool forceFitAll)
create a custom origin particle or a beamspot
Definition: ParticleBase.cc:147
TreeFitter::Constraint::Type
Type
type of constraints the order of these constraints is important: it is the order in which they are ap...
Definition: Constraint.h:36
TreeFitter::ParticleBase::index
int index() const
get index
Definition: ParticleBase.h:112
TreeFitter::ParticleBase::charge
int charge() const
get charge
Definition: ParticleBase.h:176
TreeFitter::ParticleBase::indexmap
std::vector< std::pair< const ParticleBase *, int > > indexmap
alias
Definition: ParticleBase.h:72
TreeFitter::ParticleBase::projectGeoConstraint
virtual ErrCode projectGeoConstraint(const FitParams &, Projection &) const
project geometrical constraint
Definition: ParticleBase.cc:359
TreeFitter::ParticleBase::tauIndex
virtual int tauIndex() const
get tau index
Definition: ParticleBase.h:145
TreeFitter::ParticleBase::hasPosition
virtual bool hasPosition() const
get false
Definition: ParticleBase.h:155
TreeFitter::ParticleBase::m_index
int m_index
index
Definition: ParticleBase.h:241
TreeFitter::ParticleBase::posIndex
virtual int posIndex() const
get vertex index (in statevector!)
Definition: ParticleBase.h:142
TreeFitter::ParticleBase::constraintlist
std::vector< Constraint > constraintlist
alias
Definition: ParticleBase.h:69
TreeFitter::ParticleBase::projectMassConstraintParticle
virtual ErrCode projectMassConstraintParticle(const FitParams &, Projection &) const
project mass constraint using the particles parameters
Definition: ParticleBase.cc:496
TreeFitter::ParticleBase::hasEnergy
virtual bool hasEnergy() const
get momentum dimension
Definition: ParticleBase.h:152
TreeFitter::ParticleBase::m_isStronglyDecayingResonance
bool m_isStronglyDecayingResonance
decay length less than 1 micron
Definition: ParticleBase.h:234
TreeFitter::ParticleBase::initCovariance
virtual ErrCode initCovariance(FitParams &) const
init covariance matrix
Definition: ParticleBase.cc:268
TreeFitter::ParticleBase::parname
virtual std::string parname(int index) const
get name of parameter i
Definition: ParticleBase.cc:304
Belle2::Particle
Class to store reconstructed particles.
Definition: Particle.h:77
TreeFitter::ParticleBase::removeDaughter
virtual void removeDaughter(const ParticleBase *pb)
remove daughter
Definition: ParticleBase.cc:127
TreeFitter::ParticleBase::m_mother
const ParticleBase * m_mother
motherparticle
Definition: ParticleBase.h:228
TreeFitter::ParticleBase::m_particle
Belle2::Particle * m_particle
pointer to framework type
Definition: ParticleBase.h:225
TreeFitter::ParticleBase::mother
const ParticleBase * mother() const
getMother() / hasMother()
Definition: ParticleBase.cc:295
TreeFitter::ParticleBase::momIndex
virtual int momIndex() const
get momentum index
Definition: ParticleBase.h:148
TreeFitter::ParticleBase::retrieveIndexMap
virtual void retrieveIndexMap(indexmap &anindexmap) const
get index map
Definition: ParticleBase.cc:333
TreeFitter::ParticleBase::forceP4Sum
virtual void forceP4Sum(FitParams &) const
force p4 sum conservation all allong the tree
Definition: ParticleBase.h:136
TreeFitter::ParticleBase::collectVertexDaughters
void collectVertexDaughters(std::vector< ParticleBase * > &particles, int posindex)
get vertex daughters
Definition: ParticleBase.cc:257
TreeFitter::ParticleBase::m_pdgWidth
double m_pdgWidth
particle width
Definition: ParticleBase.h:247
TreeFitter::ParticleBase::pdgLifeTime
double pdgLifeTime() const
get pdg lifetime
Definition: ParticleBase.h:170
TreeFitter::ParticleBase::initMotherlessParticle
virtual ErrCode initMotherlessParticle(FitParams &)=0
init particle that does not need a mother vertex
TreeFitter::ParticleBase::updateIndex
virtual void updateIndex(int &offset)
this sets the index for momentum, position, etc.
Definition: ParticleBase.cc:138
TreeFitter::ParticleBase::m_config
const ConstraintConfiguration * m_config
has all the constraint config
Definition: ParticleBase.h:237
TreeFitter::ParticleBase::TFParticleType
TFParticleType
particle types
Definition: ParticleBase.h:41
TreeFitter::ParticleBase::m_charge
int m_charge
charge
Definition: ParticleBase.h:253
TreeFitter::ParticleBase::ParticleContainer
std::vector< ParticleBase * > ParticleContainer
just an alias
Definition: ParticleBase.h:205
TreeFitter::ParticleBase::particle
Belle2::Particle * particle() const
get basf2 particle
Definition: ParticleBase.h:109
TreeFitter::Projection
class to store the projected residuals and the corresponding jacobian as well as the covariance matri...
Definition: Projection.h:27
TreeFitter::ParticleBase::pdgTime
double pdgTime() const
get Tau
Definition: ParticleBase.h:173
TreeFitter::ParticleBase::m_daughters
std::vector< ParticleBase * > m_daughters
daughter container
Definition: ParticleBase.h:231
TreeFitter::ParticleBase::m_pdgLifeTime
const double m_pdgLifeTime
lifetime in cm
Definition: ParticleBase.h:250
TreeFitter::ParticleBase::addDaughter
virtual ParticleBase * addDaughter(Belle2::Particle *, const ConstraintConfiguration &config, bool forceFitAll=false)
add daughter
Definition: ParticleBase.cc:119