Belle II Software  release-08-01-10
InternalParticle Class Reference

another unnecessary layer of abstraction More...

#include <InternalParticle.h>

Inheritance diagram for InternalParticle:
Collaboration diagram for InternalParticle:

Public Types

enum  TFParticleType {
  kInteractionPoint ,
  kOrigin ,
  kComposite ,
  kRecoResonance ,
  kInternalParticle ,
  kRecoTrack ,
  kResonance ,
  kRecoPhoton ,
  kRecoKlong ,
  kMissingParticle
}
 particle types

 
typedef std::vector< Constraintconstraintlist
 alias
 
typedef std::vector< std::pair< const ParticleBase *, int > > indexmap
 alias
 

Public Member Functions

 InternalParticle (Belle2::Particle *particle, const ParticleBase *mother, const ConstraintConfiguration &config, bool forceFitAll)
 constructor
 
virtual ~InternalParticle ()
 destructor
 
virtual ErrCode initCovariance (FitParams &) const override
 init covariance
 
ErrCode projectKineConstraint (const FitParams &, Projection &) const
 project kinematical constraint
 
ErrCode projectBeamConstraint (const FitParams &, Projection &) const
 project beam four momentum constraint
 
virtual void forceP4Sum (FitParams &) const override
 enforce conservation of momentum sum
 
virtual ErrCode initParticleWithMother (FitParams &fitparams) override
 init particle in case it has a mother
 
virtual ErrCode initMotherlessParticle (FitParams &fitparams) override
 init particle in case it has no mother More...
 
ErrCode projectConstraint (const Constraint::Type type, const FitParams &fitparams, Projection &p) const override
 find out which constraint it is and project
 
virtual int dim () const override
 space reserved in fit params, if has mother then it has tau
 
virtual int type () const override
 type
 
virtual int posIndex () const override
 position index in fit params
 
virtual int tauIndex () const override
 tau index in fit params only if it has a mother More...
 
virtual int momIndex () const override
 momentum index in fit params depending on whether it has a mother
More...
 
virtual bool hasEnergy () const override
 has energy in fitparams

 
virtual bool hasPosition () const override
 has position index

 
virtual std::string parname (int index) const override
 name

 
virtual void addToConstraintList (constraintlist &list, int depth) const override
 add to constraint list

 
void setMassConstraint (bool b)
 set mass constraint flag
 
virtual void updateIndex (int &offset)
 this sets the index for momentum, position, etc. More...
 
const ParticleBaselocate (Belle2::Particle *particle) const
 get particle base from basf2 particle
 
Belle2::Particleparticle () const
 get basf2 particle

 
int index () const
 get index

 
const ParticleBasemother () const
 getMother() / hasMother()
 
virtual ErrCode projectGeoConstraint (const FitParams &, Projection &) const
 project geometrical constraint More...
 
virtual ErrCode projectMassConstraintParticle (const FitParams &, Projection &) const
 project mass constraint using the particles parameters More...
 
virtual ErrCode projectMassConstraintDaughters (const FitParams &, Projection &) const
 project mass constraint using the parameters of the daughters More...
 
virtual ErrCode projectMassConstraint (const FitParams &, Projection &) const
 project mass constraint abstract
 
int eneIndex () const
 get energy index

 
virtual double chiSquare (const FitParams &) const
 get chi2
 
int charge () const
 get charge
 
virtual ParticleBaseaddDaughter (Belle2::Particle *, const ConstraintConfiguration &config, bool forceFitAll=false)
 add daughter

 
virtual void removeDaughter (const ParticleBase *pb)
 remove daughter
 
virtual void retrieveIndexMap (indexmap &anindexmap) const
 get index map

 
void setMother (const ParticleBase *m)
 set mother

 
void collectVertexDaughters (std::vector< ParticleBase * > &particles, int posindex)
 get vertex daughters
 
virtual int nFinalChargedCandidates () const
 number of charged candidates
 

Static Public Member Functions

static ParticleBasecreateParticle (Belle2::Particle *particle, const ParticleBase *mother, const ConstraintConfiguration &config, bool forceFitAll=false)
 create the according treeFitter particle obj for a basf2 particle type

 
static ParticleBasecreateOrigin (Belle2::Particle *daughter, const ConstraintConfiguration &config, bool forceFitAll)
 create a custom origin particle or a beamspot
 

Protected Types

typedef std::vector< ParticleBase * > ParticleContainer
 just an alias
 

Protected Member Functions

ErrCode initMomentum (FitParams &fitparams) const
 init momentum of *this and daughters
 
ErrCode initTau (FitParams &par) const
 initialises tau as a length

 
void setIndex (int i)
 set Index (in statevector)
 

Static Protected Member Functions

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. More...
 

Protected Attributes

Belle2::Particlem_particle
 pointer to framework type

 
const ParticleBasem_mother
 motherparticle
 
std::vector< ParticleBase * > m_daughters
 daughter container

 
bool m_isStronglyDecayingResonance
 decay length less than 1 micron

 
const ConstraintConfigurationm_config
 has all the constraint config
 

Static Private Member Functions

static bool compTrkTransverseMomentum (const RecoTrack *lhs, const RecoTrack *rhs)
 compare transverse track momentum
 

Private Attributes

bool m_massconstraint
 has mass constraint
 
bool m_beamconstraint
 has beam constraint
 
bool m_shares_vertex_with_mother
 shares vertex with mother, that means decay vertex = productionvertex
 
bool m_geo_constraint
 use a geo metric constraint
 
bool m_lifetimeconstraint
 has lifetime constraint

 
bool m_isconversion
 is conversion

 
bool m_automatic_vertex_constraining
 automatically figure out if mother and particle vertex should be the same and also add geometric constraints
 
int m_index
 index
 
std::string m_name
 name

 

Detailed Description

another unnecessary layer of abstraction

Definition at line 17 of file InternalParticle.h.

Member Function Documentation

◆ initMotherlessParticle()

ErrCode initMotherlessParticle ( FitParams fitparams)
overridevirtual

init particle in case it has no mother

(0,0,0) is the best guess in any other case

Implements ParticleBase.

Reimplemented in Resonance.

Definition at line 89 of file InternalParticle.cc.

90  {
91  ErrCode status ;
92  for (auto daughter : m_daughters) {
93  status |= daughter->initMotherlessParticle(fitparams);
94  }
95 
96  int posindex = posIndex();
97  // FIXME update this and check if this position is already initialised
98  // lower stream vertices might be better
99  if (hasPosition()) {
100  fitparams.getStateVector().segment(posindex, 3) = Eigen::Matrix<double, 3, 1>::Zero(3);
101 
102  std::vector<ParticleBase*> alldaughters;
103  ParticleBase::collectVertexDaughters(alldaughters, posindex);
104 
105  std::vector<ParticleBase*> vtxdaughters;
106 
107  vector<RecoTrack*> trkdaughters;
108  for (auto daughter : alldaughters) {
109  if (daughter->type() == ParticleBase::TFParticleType::kRecoTrack) {
110  trkdaughters.push_back(static_cast<RecoTrack*>(daughter));
111  } else if (daughter->hasPosition()
112  && fitparams.getStateVector()(daughter->posIndex()) != 0) {
113  vtxdaughters.push_back(daughter);
114  }
115  }
116 
117  if (trkdaughters.size() >= 2) {
118 
119  auto v0 = particle()->getV0();
120  auto dummy_vertex = ROOT::Math::XYZVector(0, 0, 0);
121 
122  bool initWithV0 = false;
123  if (v0 && v0->getFittedVertexPosition() != dummy_vertex) {
124  auto part_dau1 = particle()->getDaughter(0);
125  auto part_dau2 = particle()->getDaughter(1);
126 
127  auto recotrack_dau1 = std::find_if(trkdaughters.begin(), trkdaughters.end(),
128  [&part_dau1](RecoTrack * rt) { return rt->particle()->getMdstArrayIndex() == part_dau1->getMdstArrayIndex(); });
129  auto recotrack_dau2 = std::find_if(trkdaughters.begin(), trkdaughters.end(),
130  [&part_dau2](RecoTrack * rt) { return rt->particle()->getMdstArrayIndex() == part_dau2->getMdstArrayIndex(); });
131 
132  if (recotrack_dau1 == trkdaughters.end() || recotrack_dau2 == trkdaughters.end()) {
133  B2WARNING("V0 daughter particles do not match with RecoTracks.");
134  } else {
135  double X_V0(v0->getFittedVertexX()), Y_V0(v0->getFittedVertexY()), Z_V0(v0->getFittedVertexZ());
136  fitparams.getStateVector()(posindex) = X_V0;
137  fitparams.getStateVector()(posindex + 1) = Y_V0;
138  fitparams.getStateVector()(posindex + 2) = Z_V0;
139 
140  Belle2::Helix helix1 = v0->getTrackFitResults().first->getHelix();
141  Belle2::Helix helix2 = v0->getTrackFitResults().second->getHelix();
142 
143  (*recotrack_dau1)->setFlightLength(helix1.getArcLength2DAtXY(X_V0, Y_V0));
144  (*recotrack_dau2)->setFlightLength(helix2.getArcLength2DAtXY(X_V0, Y_V0));
145 
146  initWithV0 = true;
147  }
148  }
149 
150  if (!initWithV0) {
151  std::sort(trkdaughters.begin(), trkdaughters.end(), compTrkTransverseMomentum);
152 
153  RecoTrack* dau1 = trkdaughters[0];
154  RecoTrack* dau2 = trkdaughters[1];
155 
156  Belle2::Helix helix1 = dau1->particle()->getTrackFitResult()->getHelix();
157  Belle2::Helix helix2 = dau2->particle()->getTrackFitResult()->getHelix();
158 
159  double flt1(0), flt2(0);
161  HelixUtils::helixPoca(helix1, helix2, flt1, flt2, v, m_isconversion);
162 
163  fitparams.getStateVector()(posindex) = v.X();
164  fitparams.getStateVector()(posindex + 1) = v.Y();
165  fitparams.getStateVector()(posindex + 2) = v.Z();
166 
167  dau1->setFlightLength(flt1);
168  dau2->setFlightLength(flt2);
169  }
170 
171  } else if (false && trkdaughters.size() + vtxdaughters.size() >= 2) {
172  // TODO switched off waiting for refactoring of init1 and init2 functions (does not affect performance)
173  } else if (mother() && mother()->posIndex() >= 0) {
174  const int posindexmother = mother()->posIndex();
175  const int dim = m_config->m_originDimension; //TODO access mother
176  fitparams.getStateVector().segment(posindex, dim) = fitparams.getStateVector().segment(posindexmother, dim);
177  } else {
179  fitparams.getStateVector().segment(posindex, 3) = Eigen::Matrix<double, 1, 3>::Zero(3);
180  }
181  }
182 
183  for (auto daughter : m_daughters) {
184  daughter->initParticleWithMother(fitparams);
185  }
186 
187  initMomentum(fitparams);
188  return status;
189  }
DataType Z() const
access variable Z (= .at(2) without boundary check)
Definition: B2Vector3.h:435
DataType X() const
access variable X (= .at(0) without boundary check)
Definition: B2Vector3.h:431
DataType Y() const
access variable Y (= .at(1) without boundary check)
Definition: B2Vector3.h:433
Helix parameter class.
Definition: Helix.h:48
const V0 * getV0() const
Returns the pointer to the V0 object that was used to create this Particle (if ParticleType == c_V0).
Definition: Particle.cc:884
const Particle * getDaughter(unsigned i) const
Returns a pointer to the i-th daughter particle.
Definition: Particle.cc:635
const int m_originDimension
dimension of the origin constraint and ALL geometric gcosntraints
static double helixPoca(const Belle2::Helix &helix1, const Belle2::Helix &helix2, double &flt1, double &flt2, Belle2::B2Vector3D &vertex, bool parallel=false)
POCA between two tracks.
Definition: HelixUtils.cc:214
bool m_isconversion
is conversion
virtual int dim() const override
space reserved in fit params, if has mother then it has tau
virtual bool hasPosition() const override
has position index
ErrCode initMomentum(FitParams &fitparams) const
init momentum of *this and daughters
static bool compTrkTransverseMomentum(const RecoTrack *lhs, const RecoTrack *rhs)
compare transverse track momentum
virtual int posIndex() const override
position index in fit params
Belle2::Particle * particle() const
get basf2 particle
Definition: ParticleBase.h:92
const ConstraintConfiguration * m_config
has all the constraint config
Definition: ParticleBase.h:204
virtual int posIndex() const
get vertex index (in statevector!)
Definition: ParticleBase.h:122
std::vector< ParticleBase * > m_daughters
daughter container
Definition: ParticleBase.h:198
void collectVertexDaughters(std::vector< ParticleBase * > &particles, int posindex)
get vertex daughters
const ParticleBase * mother() const
getMother() / hasMother()
Definition: ParticleBase.h:98

◆ isAResonance()

bool isAResonance ( Belle2::Particle particle)
staticprotectedinherited

controls if a particle is treated as a resonance(lifetime=0) or a particle that has a finite lifetime.

A finite life time means it will register a geo constraint for this particle

Definition at line 134 of file ParticleBase.cc.

◆ momIndex()

int momIndex ( ) const
overridevirtual

momentum index in fit params depending on whether it has a mother

indexing in { x, y, z, tau, px, py, pz, E } but tau is not existing for all InternalParticles

Reimplemented from ParticleBase.

Reimplemented in Resonance.

Definition at line 353 of file InternalParticle.cc.

◆ projectGeoConstraint()

ErrCode projectGeoConstraint ( const FitParams fitparams,
Projection p 
) const
virtualinherited

project geometrical constraint

the direction of the momentum is very well known from the kinematic constraints that is why we do not extract the distance as a vector here

Definition at line 249 of file ParticleBase.cc.

◆ projectMassConstraintDaughters()

ErrCode projectMassConstraintDaughters ( const FitParams fitparams,
Projection p 
) const
virtualinherited

project mass constraint using the parameters of the daughters

be aware that the signs here are important E-|p|-m extracts a negative mass and messes with the momentum !

Definition at line 314 of file ParticleBase.cc.

◆ projectMassConstraintParticle()

ErrCode projectMassConstraintParticle ( const FitParams fitparams,
Projection p 
) const
virtualinherited

project mass constraint using the particles parameters

be aware that the signs here are important E-|p|-m extracts a negative mass and messes with the momentum !

Definition at line 375 of file ParticleBase.cc.

◆ tauIndex()

int tauIndex ( ) const
overridevirtual

tau index in fit params only if it has a mother

only exists if particle is geo constraint and has a mother

Reimplemented from ParticleBase.

Reimplemented in Resonance.

Definition at line 347 of file InternalParticle.cc.

◆ updateIndex()

void updateIndex ( int &  offset)
virtualinherited

this sets the index for momentum, position, etc.

in the statevector

Definition at line 84 of file ParticleBase.cc.


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