Belle II Software development
DecayChain Class Reference

this class does a lot of stuff: Build decaytree structure allowing to index particles and handle the filtering of constraints across the tree More...

#include <DecayChain.h>

Public Member Functions

 DecayChain ()
 empty constructor

 
 DecayChain (Belle2::Particle *bc, const ConstraintConfiguration &config, bool forceFitAll=false)
 constructor

 
 ~DecayChain ()
 destructor

 
ErrCode initialize (FitParams &par)
 initialize the chain
 
ErrCode filter (FitParams &par)
 filter down the chain
 
ErrCode filterWithReference (FitParams &par, const FitParams &ref)
 filter with respect to a previous iteration for better stability
 
int dim () const
 get dimension

 
void initConstraintList ()
 init contraintlist

 
void removeConstraintFromList ()
 remove constraints from list
 
double chiSquare (const FitParams &par) const
 get the chi2 for the head of the chain
 
ParticleBasemother ()
 get mother
 
const ParticleBasecand ()
 get candidate
 
const ParticleBasemother () const
 get mother
 
const ParticleBaselocate (Belle2::Particle *bc) const
 convert Belle2::particle into particle base(fitter base particle)

 
int index (Belle2::Particle *bc) const
 get the particle index
 
int posIndex (Belle2::Particle *bc) const
 get the vertex index of the particle in state vector
 
int momIndex (Belle2::Particle *bc) const
 get momentum index of the particle in the state vector
 
int tauIndex (Belle2::Particle *bc) const
 get tau (i.e.
 
int momIndex () const
 !NOT IMPLEMENTED

 

Private Types

typedef std::map< Belle2::Particle *, const ParticleBase * > ParticleMap
 typedef for a map of a particle to a TreeFitter::ParticleBase
 

Private Attributes

int m_dim
 the dimension of constraint
 
ParticleBasem_headOfChain
 head of decay tree
 
const ParticleBasem_cand
 fit candidate (not same to mother in case of bs/be constraint)
 
ParticleBase::constraintlist m_constraintlist
 list of constraints
 
ParticleMap m_particleMap
 the map from Belle2::Particles to TreeFitter::ParticleBase
 
const bool m_isOwner
 internal class member to check if we own the chain
 
const ConstraintConfiguration m_config
 config container
 

Detailed Description

this class does a lot of stuff: Build decaytree structure allowing to index particles and handle the filtering of constraints across the tree

Definition at line 23 of file DecayChain.h.

Member Typedef Documentation

◆ ParticleMap

typedef std::map<Belle2::Particle*, const ParticleBase*> ParticleMap
private

typedef for a map of a particle to a TreeFitter::ParticleBase

Definition at line 99 of file DecayChain.h.

Constructor & Destructor Documentation

◆ DecayChain() [1/2]

DecayChain ( )
inline

empty constructor

Definition at line 28 of file DecayChain.h.

28: m_dim(0), m_headOfChain(0), m_cand(0), m_isOwner(true) {} //Default constructor (actually never used)
int m_dim
the dimension of constraint
Definition: DecayChain.h:89
ParticleBase * m_headOfChain
head of decay tree
Definition: DecayChain.h:91
const bool m_isOwner
internal class member to check if we own the chain
Definition: DecayChain.h:105
const ParticleBase * m_cand
fit candidate (not same to mother in case of bs/be constraint)
Definition: DecayChain.h:93

◆ DecayChain() [2/2]

DecayChain ( Belle2::Particle bc,
const ConstraintConfiguration config,
bool  forceFitAll = false 
)

constructor

Definition at line 21 of file DecayChain.cc.

24 :
25 m_dim(0),
26 m_headOfChain(nullptr),
27 m_isOwner(true),
28 m_config(config)
29 {
30
31 if (config.m_ipConstraint && config.m_customOrigin) {
32 B2FATAL("Setup error. Can't have both custom origin and ip constraint.");
33 }
34 config.m_headOfTreePDG = std::abs(particle->getPDGCode());
35 if (config.m_ipConstraint || config.m_customOrigin) {
36 m_headOfChain = ParticleBase::createOrigin(particle, config, forceFitAll);
37 } else {
38 m_headOfChain = ParticleBase::createParticle(particle, nullptr, config, forceFitAll);
39 }
40
42
43 m_cand = locate(particle);
44 }
const ConstraintConfiguration m_config
config container
Definition: DecayChain.h:108
const ParticleBase * locate(Belle2::Particle *bc) const
convert Belle2::particle into particle base(fitter base particle)
Definition: DecayChain.cc:111
virtual void updateIndex(int &offset)
this sets the index for momentum, position, etc.
Definition: ParticleBase.cc:84
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

◆ ~DecayChain()

~DecayChain ( )

destructor

Definition at line 46 of file DecayChain.cc.

47 {
48 if (m_headOfChain && m_isOwner) {
49 delete m_headOfChain;
50 }
51 }

Member Function Documentation

◆ cand()

const ParticleBase * cand ( )
inline

get candidate

Definition at line 64 of file DecayChain.h.

64{ return m_cand ; }

◆ chiSquare()

double chiSquare ( const FitParams par) const

get the chi2 for the head of the chain

Definition at line 106 of file DecayChain.cc.

107 {
108 return m_headOfChain->chiSquare(par);
109 }
virtual double chiSquare(const FitParams &) const
get chi2

◆ dim()

int dim ( ) const
inline

get dimension

Definition at line 49 of file DecayChain.h.

49{ return m_dim;}

◆ filter()

ErrCode filter ( FitParams par)

filter down the chain

Definition at line 81 of file DecayChain.cc.

82 {
83 ErrCode status;
84 par.resetCovariance();
85 status |= m_headOfChain->initCovariance(par);
86 par.resetChiSquare();
87 for (auto constraint : m_constraintlist) {
88 status |= constraint.filter(par);
89 }
90 return status;
91 }
ParticleBase::constraintlist m_constraintlist
list of constraints
Definition: DecayChain.h:96
virtual ErrCode initCovariance(FitParams &) const
init covariance matrix

◆ filterWithReference()

ErrCode filterWithReference ( FitParams par,
const FitParams ref 
)

filter with respect to a previous iteration for better stability

Definition at line 93 of file DecayChain.cc.

94 {
95 ErrCode status;
96 par.resetCovariance();
97 status |= m_headOfChain->initCovariance(par);
98 par.resetChiSquare();
99 for (auto constraint : m_constraintlist) {
100 status |= constraint.filterWithReference(par, ref);
101 }
102 return status;
103 }

◆ index()

int index ( Belle2::Particle bc) const

get the particle index

Definition at line 130 of file DecayChain.cc.

131 {
132 const ParticleBase* base = locate(particle);
133 if (base) {
134 return base->index();
135 }
136 return -1;
137 }

◆ initConstraintList()

void initConstraintList ( )

init contraintlist

Definition at line 53 of file DecayChain.cc.

54 {
55 m_constraintlist.clear();
58 std::sort(m_constraintlist.begin(), m_constraintlist.end());
59 }
void removeConstraintFromList()
remove constraints from list
Definition: DecayChain.cc:61
virtual void addToConstraintList(constraintlist &alist, int depth) const =0
add to constraint list

◆ initialize()

ErrCode initialize ( FitParams par)

initialize the chain

Definition at line 70 of file DecayChain.cc.

71 {
72 ErrCode status;
73 par.resetStateVector();
75 par.resetCovariance();
76 status |= m_headOfChain->initCovariance(par);
78 return status;
79 }
void initConstraintList()
init contraintlist
Definition: DecayChain.cc:53
virtual ErrCode initMotherlessParticle(FitParams &)=0
init particle that does not need a mother vertex

◆ locate()

const ParticleBase * locate ( Belle2::Particle bc) const

convert Belle2::particle into particle base(fitter base particle)

Definition at line 111 of file DecayChain.cc.

112 {
113 const ParticleBase* rc(nullptr);
114 const auto mapRow = m_particleMap.find(particle) ;
115
116 if (mapRow == m_particleMap.end()) {
117 //take head of chain and recursively find particle in it
118 rc = m_headOfChain->locate(particle);
119
120 if (rc && rc->particle()) {
121 const_cast<DecayChain*>(this)->m_particleMap[rc->particle()] = rc;
122 }
123 } else {
124 //only used for "head of tree"
125 rc = mapRow->second;// (B2::Particle, Particlebase)
126 }
127 return rc;
128 }
DecayChain()
empty constructor
Definition: DecayChain.h:28
ParticleMap m_particleMap
the map from Belle2::Particles to TreeFitter::ParticleBase
Definition: DecayChain.h:102
const ParticleBase * locate(Belle2::Particle *particle) const
get particle base from basf2 particle

◆ momIndex()

int momIndex ( Belle2::Particle bc) const

get momentum index of the particle in the state vector

Definition at line 148 of file DecayChain.cc.

149 {
150 const ParticleBase* base = locate(particle);
151 if (base) {
152 return base->momIndex();
153 }
154 return -1;
155 }

◆ mother() [1/2]

ParticleBase * mother ( )
inline

get mother

Definition at line 61 of file DecayChain.h.

61{ return m_headOfChain ; }

◆ mother() [2/2]

const ParticleBase * mother ( ) const
inline

get mother

Definition at line 67 of file DecayChain.h.

67{ return m_headOfChain ; }

◆ posIndex()

int posIndex ( Belle2::Particle bc) const

get the vertex index of the particle in state vector

Definition at line 139 of file DecayChain.cc.

140 {
141 const ParticleBase* base = locate(particle);
142 if (base) {
143 return base->posIndex();
144 }
145 return -1;
146 }

◆ removeConstraintFromList()

void removeConstraintFromList ( )

remove constraints from list

Definition at line 61 of file DecayChain.cc.

62 {
63 for (auto removeConstraint : m_config.m_removeConstraintList) {
64 m_constraintlist.erase(std::remove_if(m_constraintlist.begin(), m_constraintlist.end(),
65 [&](const Constraint & constraint) { return constraint.name() == removeConstraint ;}),
66 m_constraintlist.end());
67 }
68 }
const std::vector< std::string > m_removeConstraintList
list of constraints not to apply in tree fit

◆ tauIndex()

int tauIndex ( Belle2::Particle bc) const

get tau (i.e.

decay lifetime) index of the particle in the state vector

Definition at line 157 of file DecayChain.cc.

158 {
159 const ParticleBase* base = locate(particle);
160 if (base) {
161 return base->tauIndex();
162 }
163 return -1;
164 }

Member Data Documentation

◆ m_cand

const ParticleBase* m_cand
private

fit candidate (not same to mother in case of bs/be constraint)

Definition at line 93 of file DecayChain.h.

◆ m_config

const ConstraintConfiguration m_config
private

config container

Definition at line 108 of file DecayChain.h.

◆ m_constraintlist

ParticleBase::constraintlist m_constraintlist
private

list of constraints

Definition at line 96 of file DecayChain.h.

◆ m_dim

int m_dim
mutableprivate

the dimension of constraint

Definition at line 89 of file DecayChain.h.

◆ m_headOfChain

ParticleBase* m_headOfChain
mutableprivate

head of decay tree

Definition at line 91 of file DecayChain.h.

◆ m_isOwner

const bool m_isOwner
private

internal class member to check if we own the chain

Definition at line 105 of file DecayChain.h.

◆ m_particleMap

ParticleMap m_particleMap
private

the map from Belle2::Particles to TreeFitter::ParticleBase

Definition at line 102 of file DecayChain.h.


The documentation for this class was generated from the following files: