Belle II Software development
V0DaughterMassUpdaterModule.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#include <analysis/modules/V0DaughterMassUpdater/V0DaughterMassUpdaterModule.h>
10#include <analysis/dataobjects/ParticleList.h>
11
12#include <framework/datastore/StoreObjPtr.h>
13#include <framework/gearbox/Const.h>
14
15using namespace std;
16using namespace Belle2;
17
18// Register module in the framework
19REG_MODULE(V0DaughterMassUpdater);
20
22{
23 //Set module properties
24 setDescription("This module replaces the mass of two daughters of the selected V0 particles inside the given particleLists with masses of given pdgCode. The particle in selected particleList has to have 2 daughters.");
26 //Parameter definition
27 addParam("particleLists", m_strParticleLists, "List of ParticleLists", vector<string>());
28 addParam("pdgCodeOfV0posDaughter", m_pdg_pos_dau, "PDG code of daughter with positive charge", Const::electron.getPDGCode());
29 addParam("pdgCodeOfV0negDaughter", m_pdg_neg_dau, "PDG code of daughter with negative charge", Const::electron.getPDGCode());
30
31}
32
33
35{
36
37
38 for (auto& iList : m_strParticleLists) {
39
40 StoreObjPtr<ParticleList> particlelist(iList);
41 if (!particlelist) {
42 B2ERROR("ParticleList " << iList << " not found");
43 continue;
44 } else {
45 if (particlelist->getListSize() == 0) continue;
46 for (unsigned int i = 0; i < particlelist->getListSize(); ++i) {
47 Particle* iParticle = particlelist->getParticle(i);
48 if (iParticle->getParticleSource() != Particle::EParticleSourceObject::c_Composite)
49 B2FATAL("This V0 particle is not a composite particle!");
50 else {
51 std::vector<Belle2::Particle*> dau = iParticle -> getDaughters();
52 if (dau.size() != 2)
53 B2FATAL("This V0 particle has " << dau.size() << " daughters, the number of daughters has to be 2.");
54 else {
55 // To check daughters order of V0 is correct (first positive, second negative)
56 bool correctOrder = true;
57 if (dau[0]->getCharge() < 0 && dau[1]->getCharge() > 0) correctOrder = false;
58 if (correctOrder) {
59 dau[0]->updateMass(m_pdg_pos_dau);
60 dau[1]->updateMass(m_pdg_neg_dau);
61 } else {
62 dau[0]->updateMass(m_pdg_neg_dau);
63 dau[1]->updateMass(m_pdg_pos_dau);
64 }
65 }
66 }
67 }
68 }
69 }
70}
71
static const ChargedStable electron
electron particle
Definition: Const.h:659
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
EParticleSourceObject getParticleSource() const
Returns particle source as defined with enum EParticleSourceObject.
Definition: Particle.h:478
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:96
int m_pdg_pos_dau
PDG code for V0's positive daughter.
virtual void event() override
Method called for each event.
std::vector< std::string > m_strParticleLists
Name of the lists.
int m_pdg_neg_dau
PDG code for V0's negative daughter.
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
Abstract base class for different kinds of events.
STL namespace.