Belle II Software  release-06-01-15
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 
21 using namespace Belle2;
22 
23 REG_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  TVector3 shift = m_Initial.updateVertex();
50  if (shift == TVector3{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
This module smears the primary vertex (the interaction point) according to the values stored in BeamP...
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.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
TVector3 updateVertex(bool force=false)
Update the vertex position:
void initialize()
function to be executed on initialize()
Abstract base class for different kinds of events.