Belle II Software  release-06-02-00
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 
15 using namespace std;
16 using namespace Belle2;
17 
18 // Register module in the framework
19 REG_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.");
25  setPropertyFlags(c_ParallelProcessingCertified);
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 
34 void V0DaughterMassUpdaterModule::event()
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 
Base class for Modules.
Definition: Module.h:72
Class to store reconstructed particles.
Definition: Particle.h:74
EParticleSourceObject getParticleSource() const
Returns particle source as defined with enum EParticleSourceObject.
Definition: Particle.h:416
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:95
This module replaces the mass of two daughters of the selected V0 particles inside the given particle...
#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.