10 #include <analysis/modules/ParticleCopier/ParticleCopierModule.h>
14 #include <framework/datastore/StoreObjPtr.h>
17 #include <framework/logging/Logger.h>
20 #include <analysis/dataobjects/Particle.h>
21 #include <analysis/dataobjects/ParticleList.h>
24 #include <analysis/utility/ParticleCopy.h>
46 setDescription(
"Replaces each Particle in the ParticleList with its copy.\n"
47 "Particle's (grand)^n-daughter Particles are copied as well.\n"
48 "The existing relations of the original Particle (or it's (grand-)^n-daughters)\n"
49 "are copied as well.");
50 setPropertyFlags(c_ParallelProcessingCertified);
53 vector<string> defaultList;
54 addParam(
"inputListNames", m_inputListNames,
55 "list of input ParticleList names", defaultList);
58 void ParticleCopierModule::initialize()
61 for (
const std::string& listName : m_inputListNames) {
66 void ParticleCopierModule::event()
69 for (
const auto& inputListName : m_inputListNames) {
72 const unsigned int origSize = plist->getListSize();
73 std::vector<Particle*> copies(origSize);
75 for (
unsigned i = 0; i < origSize; i++) {
76 const Particle* origP = plist->getParticle(i);
79 Particle* copyP = ParticleCopy::copyParticle(origP);
85 for (
unsigned i = 0; i < origSize; i++)
86 plist->addParticle(copies[i]);
88 unsigned int copySize = plist->getListSize();
90 if (copySize != origSize)
91 B2FATAL(
"Size of the ParticleList " << inputListName
92 <<
" has changed while copying the Particles! original size = "
93 << origSize <<
" vs. new size = " << copySize);
Module for creating copies of Particles.
Class to store reconstructed particles.
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
virtual void clear()
Clear contents of this object.
Type-safe access to single objects in the data store.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.