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
18/* ROOT headers. */
19#include <TVector3.h>
20
21using namespace Belle2;
22
23REG_MODULE(SmearPrimaryVertex);
24
26 m_Initial(BeamParameters::c_smearVertex)
27{
28 /* Module description. */
29 setDescription("Smears primary vertex and all subsequent vertices of all the MCParticles using the informations stored in BeamParameters.");
30 /* Parameters definition. */
31 addParam("MCParticlesStoreArrayName", m_MCParticlesName, "Name of the MCParticles StoreArray.", std::string(""));
32}
33
35{
36}
37
39{
41 mcParticles.isRequired(m_MCParticlesName);
43}
44
46{
48 // smear the primary vertex if not already done
49 ROOT::Math::XYZVector shift = m_Initial.updateVertex();
50 if (shift == ROOT::Math::XYZVector(0, 0, 0)) return;
51 for (MCParticle& mcParticle : mcParticles) {
52 /* Shift the production vertex. */
53 mcParticle.setProductionVertex(mcParticle.getProductionVertex() + shift);
54 /* Shift also the decay vertex only if the MCParticle has a daughter. */
55 if (mcParticle.getNDaughters() > 0)
56 mcParticle.setDecayVertex(mcParticle.getDecayVertex() + shift);
57 }
58}
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
Base class for Modules.
Definition: Module.h:72
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
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:560
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
void initialize()
function to be executed on initialize()
ROOT::Math::XYZVector updateVertex(bool force=false)
Update the vertex position:
Abstract base class for different kinds of events.