11#include <analysis/modules/ParticleMomentumUpdater/ParticleMomentumUpdaterModule.h>
12#include <analysis/dataobjects/ParticleList.h>
14#include <framework/datastore/StoreArray.h>
15#include <framework/logging/Logger.h>
17#include <analysis/utility/PCmsLabTransform.h>
18#include <analysis/utility/ParticleCopy.h>
32 setDescription(
"This module replaces the momentum of the particles in the selected target particle list by p(beam) - p(selected daughters). The momentum of the mother particle will not be changed.");
37 "DecayString specifying the target particle whose momentum will be updated",
40 "DecayString specifying the daughter particles used to replace the momentum of the target particle by p(beam)-p(daughters)",
48 particles.isRequired();
56 B2ERROR(
"ParticleMomentumUpdaterModule::initialize invalid Decay Descriptor: " <<
m_decayStringTarget);
58 B2ERROR(
"ParticleMomentumUpdaterModule::initialize please select exactly one target: " <<
m_decayStringTarget);
74 ROOT::Math::PxPyPzEVector daughters4Vector;
76 const unsigned int numParticles = plist->getListSize();
77 for (
unsigned int i = 0; i < numParticles; i++) {
78 Particle* iParticle = plist->getParticle(i);
83 daughters4Vector = {0., 0., 0., 0.};
84 for (
auto& selParticle : selParticlesDaughters) {
85 daughters4Vector += selParticle->get4Vector();
88 Particle* targetP = particles[selParticlesTarget[0]->getArrayIndex()];
89 if (targetP == iParticle) {
90 iParticle->
set4Vector(boost4Vector - daughters4Vector);
93 daughterCopy->
set4Vector(boost4Vector - daughters4Vector);
96 B2ERROR(
"ParticleMomentumUpdaterModule::event No target particle found for " <<
m_decayStringTarget);
bool init(const std::string &str)
Initialise the DecayDescriptor from given string.
std::vector< int > getSelectionPDGCodes()
Return list of PDG codes of selected particles.
std::vector< const Particle * > getSelectionParticles(const Particle *particle)
Get a vector of pointers with selected daughters in the decay tree.
void setDescription(const std::string &description)
Sets the description of the module.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
std::string m_decayStringDaughters
DecayString specifying the daughters used to update the momentum of the target particle.
virtual void initialize() override
Initialises the module.
virtual void event() override
Method called for each event.
ParticleMomentumUpdaterModule()
Constructor.
virtual void terminate() override
Write TTree to file, and close file if necessary.
DecayDescriptor m_pDDescriptorTarget
Decay descriptor of the target particles.
std::string m_particleList
name of input particle list.
DecayDescriptor m_pDDescriptorDaughters
Decay descriptor of the daughter particles.
std::string m_decayStringTarget
DecayString specifying the target Particle whose momentum will be updated.
Class to store reconstructed particles.
void set4Vector(const ROOT::Math::PxPyPzEVector &p4)
Sets Lorentz vector.
bool replaceDaughterRecursively(const Particle *oldDaughter, Particle *newDaughter)
Apply replaceDaughter to all Particles in the decay tree by looping recursively through it,...
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
Accessor to arrays stored in the data store.
Type-safe access to single objects in the data store.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Particle * copyParticle(const Particle *original)
Function takes argument Particle and creates a copy of it and copies of all its (grand-)^n-daughters.
Abstract base class for different kinds of events.