Belle II Software development
SmearPrimaryVertexModule.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 <generators/modules/SmearPrimaryVertexModule.h>
11
12/* Belle II headers. */
13#include <framework/dataobjects/MCInitialParticles.h>
14#include <framework/datastore/StoreArray.h>
15#include <framework/logging/Logger.h>
16#include <mdst/dataobjects/MCParticle.h>
17
18using namespace Belle2;
19
20REG_MODULE(SmearPrimaryVertex);
21
23 m_Initial(BeamParameters::c_smearVertex)
24{
25 /* Module description. */
26 setDescription("Smears primary vertex and all subsequent vertices of all the MCParticles using the information stored in BeamParameters.");
27 /* Parameters definition. */
28 addParam("MCParticlesStoreArrayName", m_MCParticlesName, "Name of the MCParticles StoreArray.", std::string(""));
29}
30
34
41
43{
45 // smear the primary vertex if not already done
46 ROOT::Math::XYZVector shift = m_Initial.updateVertex();
47 if (shift == ROOT::Math::XYZVector(0, 0, 0)) return;
48 for (MCParticle& mcParticle : mcParticles) {
49 /* Shift the production vertex. */
50 mcParticle.setProductionVertex(mcParticle.getProductionVertex() + shift);
51 /* Shift also the decay vertex only if the MCParticle has a daughter. */
52 if (mcParticle.getNDaughters() > 0)
53 mcParticle.setDecayVertex(mcParticle.getDecayVertex() + shift);
54 }
55}
This class contains the nominal beam parameters and the parameters used for smearing of the primary v...
A Class to store the Monte Carlo particle information.
Definition MCParticle.h:32
void setDescription(const std::string &description)
Sets the description of the module.
Definition Module.cc:214
Module()
Constructor.
Definition Module.cc:30
virtual void initialize() override
Initialize the module.
virtual void event() override
This method is called for each event.
InitialParticleGeneration m_Initial
Initial particle generation.
std::string m_MCParticlesName
Name of the MCParticles StoreArray.
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
Accessor to arrays stored in the data store.
Definition StoreArray.h:113
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:559
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition Module.h:649
Abstract base class for different kinds of events.