12 #include <analysis/modules/KlongDecayReconstructor/KlongDecayReconstructorExpertModule.h>
15 #include <framework/logging/Logger.h>
18 #include <analysis/dataobjects/Particle.h>
21 #include <analysis/DecayDescriptor/DecayDescriptorParticle.h>
24 #include <analysis/DecayDescriptor/ParticleListName.h>
47 Module(), m_pdgCode(0), m_isSelfConjugatedParticle(false)
51 setDescription(
"This module is used to employ kinematic constraints to determine the momentum of Klongs for two body B decays containing a K_L0 and something else. The module creates a list of K_L0 candidates whose K_L0 momentum is reconstructed by combining the reconstructed direction (from either the ECL or KLM) of the K_L0 and kinematic constraints of the intial state.");
52 setPropertyFlags(c_ParallelProcessingCertified);
55 addParam(
"decayString", m_decayString,
56 "Input DecayDescriptor string.");
57 addParam(
"cut", m_cutParameter,
"Selection criteria to be applied", std::string(
""));
58 addParam(
"maximumNumberOfCandidates", m_maximumNumberOfCandidates,
59 "Don't reconstruct channel if more candidates than given are produced.", -1);
60 addParam(
"decayMode", m_decayModeID,
"User-specified decay mode identifier (saved in 'decayModeID' extra-info for each Particle)",
62 addParam(
"writeOut", m_writeOut,
63 "If true, the output ParticleList will be saved by RootOutput. If false, it will be ignored when writing the file.",
false);
64 addParam(
"recoList", m_recoList,
65 "Suffix attached to the original K_L input list to identify the output list of the FindKlongMomentum module; this is the input for this module, if not defined it is set to '_reco' \n",
66 std::string(
"_reco"));
70 void KlongDecayReconstructorExpertModule::initialize()
74 m_generator =
nullptr;
77 bool valid = m_decaydescriptor.init(m_decayString);
79 B2ERROR(
"Invalid input DecayString: " << m_decayString);
84 m_pdgCode = mother->getPDGCode();
85 m_listName = mother->getFullName();
87 m_antiListName = ParticleListName::antiParticleListName(m_listName);
88 m_isSelfConjugatedParticle = (m_listName == m_antiListName);
90 std::string newDecayString;
91 std::string kListName;
92 newDecayString = m_listName +
" -> ";
97 int nProducts = m_decaydescriptor.getNDaughters();
98 for (
int i = 0; i < nProducts; ++i) {
100 if (daughter->getPDGCode() != Const::Klong.getPDGCode()) {
102 newDecayString = newDecayString + daughter->getFullName() +
" ";
105 kListName = daughter->getFullName() + m_recoList;
111 B2FATAL(
"This module is meant to reconstruct decays with a K_L0 in the final state. There is no K_L0 in this decay!");
112 newDecayString = newDecayString + kListName;
114 m_generator = std::make_unique<ParticleGenerator>(newDecayString, m_cutParameter);
118 particleList.registerInDataStore(flags);
119 if (!m_isSelfConjugatedParticle) {
121 antiParticleList.registerInDataStore(flags);
124 m_cut = Variable::Cut::compile(m_cutParameter);
128 void KlongDecayReconstructorExpertModule::event()
134 outputList->initialize(m_pdgCode, m_listName);
136 if (!m_isSelfConjugatedParticle) {
138 outputAntiList.create();
139 outputAntiList->initialize(-1 * m_pdgCode, m_antiListName);
141 outputList->bindAntiParticleList(*(outputAntiList));
146 int numberOfCandidates = 0;
147 while (m_generator->loadNext()) {
149 Particle particle = m_generator->getCurrentParticle();
151 bool is_physical =
true;
153 const std::vector<Particle*> daughters = particle.getDaughters();
155 if (daughters.size() < 2)
156 B2FATAL(
"Reconstructing particle as a daughter of a decay with less than 2 daughters!");
158 if (daughters.size() > 3)
159 B2FATAL(
"Higher multiplicity (>2) missing momentum decays not implemented yet!");
162 TLorentzVector pDaughters;
163 for (
auto daughter : daughters) {
164 if (daughter->getPDGCode() != Const::Klong.getPDGCode()) {
165 pDaughters += daughter->get4Vector();
166 e_check = daughter->getArrayIndex() + e_check * 100;
171 TLorentzVector klDaughters;
172 for (
auto daughter : daughters) {
173 if (daughter->getPDGCode() == Const::Klong.getPDGCode()) {
174 klDaughters += daughter->get4Vector();
175 if (e_check != daughter->getExtraInfo(
"permID")) {
180 double m_b = particle.getPDGMass();
182 TLorentzVector mom = pDaughters + klDaughters;
183 mom.SetE(TMath::Sqrt(mom.Vect().Mag2() + m_b * m_b));
184 if ((!isnan(mom.Vect().Mag())) && is_physical)
185 particle.set4Vector(mom);
186 if (isnan(mom.Vect().Mag()))
189 if (!m_cut->check(&particle))
195 numberOfCandidates++;
197 if (m_maximumNumberOfCandidates > 0 and numberOfCandidates > m_maximumNumberOfCandidates) {
202 Particle* newParticle = particles.appendNew(particle);
204 outputList->addParticle(newParticle);
205 newParticle->
addExtraInfo(
"decayModeID", m_decayModeID);