Belle II Software  release-06-02-00
Belle2::ParticleCopy Namespace Reference

Functions that create copies of Particles. More...

Functions

ParticlecopyParticle (const Particle *original)
 Function takes argument Particle and creates a copy of it and copies of all its (grand-)^n-daughters. More...
 
void copyDaughters (Particle *mother)
 Function copies all (grand-)^n-daughter particles of the argument mother Particle. More...
 

Detailed Description

Functions that create copies of Particles.

Functions take existing Particle and create its copy ((grand)^n-daughter particles are copied as well).

Function Documentation

◆ copyDaughters()

void copyDaughters ( Belle2::Particle mother)

Function copies all (grand-)^n-daughter particles of the argument mother Particle.

The copied particles are stored in the same StoreArray as the mother Particle and its original daughters. The indices of daughter particles in the mother Particle are replaced with the indices of copied daughter particles. The existing relations of the original daughter Particles are copied as well. Note that only the relation is copied and that the related object is not. Copy is related to the same object as the original one.

Parameters
motherpointer to the mother Particle whose daughters are to be copied

Definition at line 51 of file ParticleCopy.cc.

52 {
53  unsigned nDaughters = mother->getNDaughters();
54  for (unsigned iOld = 0; iOld < nDaughters; iOld++) {
55  const Particle* originalDaughter = mother->getDaughter(0);
56  Particle* daughterCopy = copyParticle(originalDaughter);
57 
58  // remove original daughter
59  mother->removeDaughter(originalDaughter);
60  // append copied daughter instead
61  mother->appendDaughter(daughterCopy);
62  }
63 }
Class to store reconstructed particles.
Definition: Particle.h:74
Particle * copyParticle(const Particle *original)
Function takes argument Particle and creates a copy of it and copies of all its (grand-)^n-daughters.
Definition: ParticleCopy.cc:18

◆ copyParticle()

Particle * copyParticle ( const Particle original)

Function takes argument Particle and creates a copy of it and copies of all its (grand-)^n-daughters.

The existing relations of the original Particle are copied as well. Note that only the relation is copied and that the related object is not. Copy is related to the same object as the original one.

Created copies are stored in the same StoreArray as the original Particle.

Parameters
originalpointer to the original Particle to be copied
Returns
returns pointer to the copied Particle

Definition at line 18 of file ParticleCopy.cc.