Belle II Software development
EvtGenDecayModule.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/evtgendecay/EvtGenDecayModule.h>
11
12/* Generators headers. */
13#include <generators/evtgen/EvtGenUtilities.h>
14
15/* Basf2 headers. */
16#include <framework/datastore/StoreArray.h>
17#include <framework/utilities/FileSystem.h>
18
19/* External headers. */
20#include <EvtGenBase/EvtPDL.hh>
21#include <EvtGenBase/EvtDecayTable.hh>
22
23using namespace Belle2;
24
25REG_MODULE(EvtGenDecay);
26
28{
29 setDescription("This module decays unstable particles using EvtGen. The "
30 "event should be already generated by another generator. "
31 "If you need to generate full event with EvtGen, then use "
32 "the module 'EvtGenInput'.");
33 addParam("DecFile", m_DecFile, "EvtGen decay file (DECAY.DEC).",
35 "decfiles/dec/DECAY_BELLE2.DEC", true));
36 addParam("UserDecFile", m_UserDecFile, "User EvtGen decay file.",
37 std::string(""));
38 addParam("MCParticleColName", m_MCParticleColName,
39 "MCParticle collection name.", std::string(""));
40 m_Initialized = false;
41}
42
44{
45}
46
48{
50 mcParticles.isRequired();
51 generators::checkEvtGenDecayFile(m_DecFile);
52}
53
55{
56}
57
59{
60 int i, n;
61 if (m_BeamParameters.hasChanged()) {
62 if (!m_Initialized) {
64 } else {
65 B2FATAL("EvtGenDecayModule::event(): BeamParameters have changed within "
66 "a job, this is not supported for EvtGen!");
67 }
68 }
69 m_Graph.clear();
71 n = m_Graph.size();
72 for (i = 0; i < n; i++) {
73 bool decay = true;
74 MCParticleGraph::GraphParticle* graphParticle = &m_Graph[i];
75
76 if (graphParticle->isInitial())
77 decay = false;
78 else if (graphParticle->getNDaughters() > 0)
79 decay = false;
80 else if (m_DecayableParticles.find(graphParticle->getPDG()) ==
82 decay = false;
83 if (decay)
85 }
90}
91
93{
94}
95
97{
98}
99
101{
102 int i, n;
103 EvtId id;
104 EvtDecayTable* decayTable;
106 decayTable = EvtDecayTable::getInstance();
107 n = EvtPDL::entries();
108 for (i = 0; i < n; i++) {
109 id = EvtPDL::getEntry(i);
110 if (decayTable->getNModes(id) > 0)
111 m_DecayableParticles.insert(EvtPDL::getStdHep(id));
112 }
113}
114
virtual void initialize() override
Initialization.
virtual void event() override
This method is called for each event.
virtual void endRun() override
This method is called if the current run ends.
virtual void terminate() override
This method is called at the end of the event processing.
bool m_Initialized
Whether the generator is initialized or not.
std::string m_DecFile
Decay file.
virtual void beginRun() override
This method is called when entering a new run.
DBObjPtr< BeamParameters > m_BeamParameters
Beam parameters.
std::string m_UserDecFile
User decay file.
MCParticleGraph m_Graph
MCParticle graph.
std::string m_MCParticleColName
MCParticle collection name.
EvtGenInterface m_EvtGenInterface
Evtgen interface.
std::set< int > m_DecayableParticles
Monte-Carlo codes of particles that can be decayed by EvtGen.
virtual ~EvtGenDecayModule()
Destructor.
void initializeGenerator()
Generator initialization.
int simulateDecay(MCParticleGraph &graph, MCParticleGraph::GraphParticle &parent)
Simulate a particle decay.
int setup(const std::string &decayFileName, const std::string &parentParticle, const std::string &userFileName=std::string(""), bool coherentMixing=true)
Setup evtgen with the given decay files
static std::string findFile(const std::string &path, bool silent=false)
Search for given file or directory in local or central release directory, and return absolute path if...
Definition: FileSystem.cc:151
Class to represent Particle data in graph.
@ c_checkCyclic
Check for cyclic dependencies.
@ c_clearParticles
Clear the particle list before adding the graph.
@ c_setDecayInfo
Set decay time and vertex.
size_t size() const
Return the number of particles in the graph.
void loadList(const std::string &name="")
Load the MCParticle list given by name into the Graph.
void generateList(const std::string &name="", int options=c_setNothing)
Generates the MCParticle list and stores it in the StoreArray with the given name.
int getNDaughters() const
Return number of daughter MCParticles.
Definition: MCParticle.cc:75
int getPDG() const
Return PDG code of particle.
Definition: MCParticle.h:112
Base class for Modules.
Definition: Module.h:72
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
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
bool isInitial() const
Check if particle is an initial particle such as ISR.
Definition: MCParticle.h:590
void clear()
Reset particles and decay information to make the class reusable.
Abstract base class for different kinds of events.