Belle II Software  release-08-01-10
ParticleMassUpdaterModule.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/ParticleMassUpdater/ParticleMassUpdaterModule.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(ParticleMassUpdater);
20 
21 ParticleMassUpdaterModule::ParticleMassUpdaterModule() : Module()
22 {
23  //Set module properties
24  setDescription("This module replaces the mass of the particles inside the given particleLists with the invariant mass of the particle corresponding to the given pdgCode.");
26  //Parameter definition
27  addParam("particleLists", m_strParticleLists, "List of ParticleLists", vector<string>());
28  addParam("pdgCode", m_pdgCode, "PDG code for mass reference", Const::photon.getPDGCode());
29 }
30 
32 {
33 }
34 
36 {
37 
38 
39  for (auto& iList : m_strParticleLists) {
40 
41  StoreObjPtr<ParticleList> particlelist(iList);
42  if (!particlelist) {
43  B2ERROR("ParticleList " << iList << " not found");
44  continue;
45  } else {
46  if (particlelist->getListSize() == 0) continue;
47  for (unsigned int i = 0; i < particlelist->getListSize(); ++i) {
48  Particle* iParticle = particlelist->getParticle(i);
49  iParticle -> updateMass(m_pdgCode);
50  }
51  }
52  }
53 }
54 
56 {
57 }
58 
static const ParticleType photon
photon particle
Definition: Const.h:664
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
virtual void initialize() override
Initialises the module.
virtual void event() override
Method called for each event.
virtual void terminate() override
Write TTree to file, and close file if necessary.
std::vector< std::string > m_strParticleLists
Name of the lists.
int m_pdgCode
PDG code for mass reference.
Class to store reconstructed particles.
Definition: Particle.h:75
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:96
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.