Belle II Software  release-06-01-15
EventT0ShifterModule.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 <generators/modules/EventT0ShifterModule.h>
10 
11 #include <framework/datastore/StoreArray.h>
12 #include <framework/datastore/StoreObjPtr.h>
13 
14 using namespace Belle2;
15 
16 REG_MODULE(EventT0Shifter)
17 
19 {
20  // set module description
21  setDescription("Shift the time of all MCParticles so that the collision time is t=0."
22  "It reverts the shift done by the EventT0Generator module and should be used after the simulation."
23  "Note that the collisionTime in the MCInitialParticles is not changed.");
24 
25  setPropertyFlags(c_ParallelProcessingCertified);
26 }
27 
28 
30 {
32  m_initialParticles.isRequired();
33 }
34 
35 
37 {
38  // shift MC particles times
39  double collisionTime = m_initialParticles->getTime();
40  for (auto& particle : m_mcParticles) {
41  particle.setProductionTime(particle.getProductionTime() - collisionTime);
42  particle.setDecayTime(particle.getDecayTime() - collisionTime);
43  }
44 }
Module that shifts the time of all MCParticles so that the collision is at t=0.
virtual void initialize() override
Initialize the Module.
virtual void event() override
Event processor.
StoreArray< MCParticle > m_mcParticles
MC particles.
StoreObjPtr< MCInitialParticles > m_initialParticles
beam particles
Base class for Modules.
Definition: Module.h:72
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
Abstract base class for different kinds of events.