Belle II Software development
KlongMomentumUpdaterExpertModule.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9// Own header.
10#include <analysis/modules/KlongDecayReconstructor/KlongMomentumUpdaterExpertModule.h>
11
12// framework aux
13#include <framework/logging/Logger.h>
14
15// dataobjects
16#include <analysis/dataobjects/Particle.h>
17
18// utilities
19#include <analysis/utility/ParticleCopy.h>
20#include <analysis/utility/KlongCalculatorUtils.h>
21
22using namespace Belle2;
23
24//-----------------------------------------------------------------
25// Register module
26//-----------------------------------------------------------------
27
28REG_MODULE(KlongMomentumUpdaterExpert);
29
30//-----------------------------------------------------------------
31// Implementation
32//-----------------------------------------------------------------
33
35{
36 // set module description (e.g. insert text)
37 setDescription("This module calculates and updates the kinematics of two body B decays including one Klong");
39
40 // Add parameters
41 addParam("listName", m_listName, "name of particle list", std::string(""));
42 addParam("writeOut", m_writeOut,
43 "If true, the output ParticleList will be saved by RootOutput. If false, it will be ignored when writing the file.",
44 false);
45}
46
48{
49 // Particle list with name m_listName has to exist
50 m_plist.isRequired(m_listName);
51}
52
54{
55
56 unsigned int n = m_plist->getListSize();
57 for (unsigned i = 0; i < n; i++) {
58 Particle* particle = m_plist->getParticle(i);
59 const double m_b = particle->getPDGMass();
60 const std::vector<Particle*> daughters = particle->getDaughters();
61
62 if (daughters.size() < 2)
63 B2FATAL("Reconstructing particle as a daughter of a decay with less than 2 daughters!");
64
65 if (daughters.size() > 3)
66 B2FATAL("Higher multiplicity (>2) missing momentum decays not implemented yet!");
67
68 ROOT::Math::PxPyPzEVector BMomentum;
69 ROOT::Math::PxPyPzEVector KMomentum;
70 int idx = 0;
71 bool is_physical = KlongCalculatorUtils::calculateBtoKlongX(BMomentum, KMomentum, daughters, m_b, idx);
72
73 if (!is_physical) {
74 B2ERROR("Recalculation of two body B-decay with Klong gives unphysical results. "
75 "Update of kinematics is skipped!");
76 continue;
77 }
78
79 // Set 4-vector to B-meson
80 particle->set4Vector(BMomentum);
81
82 // Set 4-vector of Klong
83 for (auto daughter : daughters) {
84 if (daughter->getPDGCode() == Const::Klong.getPDGCode()) {
85 auto copyKlong = ParticleCopy::copyParticle(daughter);
86 copyKlong->set4Vector(KMomentum);
87 copyKlong->writeExtraInfo("permID", idx);
88 particle->replaceDaughter(daughter, copyKlong);
89 break;
90 }
91 }
92
93 }
94
95}
int getPDGCode() const
PDG code.
Definition: Const.h:473
static const ParticleType Klong
K^0_L particle.
Definition: Const.h:678
virtual void initialize() override
Initialize the Module.
virtual void event() override
Event processor.
std::string m_listName
name of the input ParticleList
StoreObjPtr< ParticleList > m_plist
the input ParticleList.
Base class for Modules.
Definition: Module.h:72
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition: Module.cc:208
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Definition: Module.h:80
Class to store reconstructed particles.
Definition: Particle.h:75
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition: Module.h:560
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
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
Abstract base class for different kinds of events.
static bool calculateBtoKlongX(ROOT::Math::PxPyPzEVector &BMomentum, ROOT::Math::PxPyPzEVector &KMomentum, const std::vector< Particle * > daughters, const double m_b, int &idx)
Calculate kinematics of two body B decays containing a K_L0.