Belle II Software  release-05-01-25
EvtGenDecayModule.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2017 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Kirill Chilikin *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 /* External headers. */
12 #include <EvtGenBase/EvtPDL.hh>
13 #include <EvtGenBase/EvtDecayTable.hh>
14 
15 /* Belle 2 headers. */
16 #include <framework/datastore/StoreArray.h>
17 #include <framework/utilities/FileSystem.h>
18 #include <generators/modules/evtgendecay/EvtGenDecayModule.h>
19 
20 using namespace Belle2;
21 
22 REG_MODULE(EvtGenDecay)
23 
25 {
26  setDescription("This module decays unstable particles using EvtGen. The "
27  "event should be already generated by another generator. "
28  "If you need to generate full event with EvtGen, then use "
29  "the module 'EvtGenInput'.");
30  addParam("DecFile", m_DecFile, "EvtGen decay file (DECAY.DEC)",
32  "decfiles/dec/DECAY_BELLE2.DEC", true));
33  addParam("UserDecFile", m_UserDecFile, "User EvtGen decay file",
34  std::string(""));
35  addParam("MCParticleColName", m_MCParticleColName,
36  "MCParticle collection name.", std::string(""));
37  m_Initialized = false;
38 }
39 
41 {
42 }
43 
45 {
47  mcParticles.isRequired();
48  const std::string defaultDecFile =
49  FileSystem::findFile("decfiles/dec/DECAY_BELLE2.DEC", true);
50  if (m_DecFile.empty()) {
51  B2ERROR("No global decay file defined, please make sure "
52  "the parameter 'DecFile' is set correctly.");
53  return;
54  }
55  if (defaultDecFile.empty()) {
56  B2WARNING("Cannot find default decay file");
57  } else if (defaultDecFile != m_DecFile) {
58  B2INFO("Using non-standard DECAY file \"" << m_DecFile << "\"");
59  }
60 }
61 
63 {
64 }
65 
67 {
68  int i, n;
69  if (m_BeamParameters.hasChanged()) {
70  if (!m_Initialized) {
72  } else {
73  B2FATAL("EvtGenDecayModule::event(): BeamParameters have changed within "
74  "a job, this is not supported for EvtGen!");
75  }
76  }
77  m_Graph.clear();
79  n = m_Graph.size();
80  for (i = 0; i < n; i++) {
81  bool decay = true;
82  MCParticleGraph::GraphParticle* graphParticle = &m_Graph[i];
83 
84  if (graphParticle->isInitial())
85  decay = false;
86  else if (graphParticle->getNDaughters() > 0)
87  decay = false;
88  else if (m_DecayableParticles.find(graphParticle->getPDG()) ==
90  decay = false;
91  if (decay)
92  m_EvtGenInterface.simulateDecay(m_Graph, *graphParticle);
93  }
98 }
99 
101 {
102 }
103 
105 {
106 }
107 
109 {
110  int i, n;
111  EvtId id;
112  EvtDecayTable* decayTable;
114  decayTable = EvtDecayTable::getInstance();
115  n = EvtPDL::entries();
116  for (i = 0; i < n; i++) {
117  id = EvtPDL::getEntry(i);
118  if (decayTable->getNModes(id) > 0)
119  m_DecayableParticles.insert(EvtPDL::getStdHep(id));
120  }
121 }
122 
Belle2::EvtGenDecayModule::~EvtGenDecayModule
virtual ~EvtGenDecayModule()
Destructor.
Definition: EvtGenDecayModule.cc:40
Belle2::MCParticleGraph::generateList
void generateList(const std::string &name="", int options=c_setNothing)
Generates the MCParticle list and stores it in the StoreArray with the given name.
Definition: MCParticleGraph.cc:211
Belle2::EvtGenDecayModule::m_Graph
MCParticleGraph m_Graph
MCParticle graph.
Definition: EvtGenDecayModule.h:98
Belle2::EvtGenDecayModule::initializeGenerator
void initializeGenerator()
Generator initialization.
Definition: EvtGenDecayModule.cc:108
Belle2::MCParticleGraph::size
size_t size() const
Return the number of particles in the graph.
Definition: MCParticleGraph.h:253
Belle2::EvtGenInterface::simulateDecay
int simulateDecay(MCParticleGraph &graph, MCParticleGraph::GraphParticle &parent)
Simulate a particle decay.
Definition: EvtGenInterface.cc:174
Belle2::EvtGenDecayModule::m_DecayableParticles
std::set< int > m_DecayableParticles
Monte-Carlo codes of particles that can be decayed by EvtGen.
Definition: EvtGenDecayModule.h:107
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:652
Belle2::EvtGenInterface::setup
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
Definition: EvtGenInterface.cc:83
Belle2::MCParticleGraph::c_checkCyclic
@ c_checkCyclic
Check for cyclic dependencies.
Definition: MCParticleGraph.h:75
Belle2::EvtGenDecayModule::m_DecFile
std::string m_DecFile
Decay file.
Definition: EvtGenDecayModule.h:89
Belle2::MCParticleGraph::loadList
void loadList(const std::string &name="")
Load the MCParticle list given by name into the Graph.
Definition: MCParticleGraph.cc:241
Belle2::EvtGenDecayModule::m_UserDecFile
std::string m_UserDecFile
User decay file.
Definition: EvtGenDecayModule.h:92
Belle2::MCParticle::isInitial
bool isInitial() const
Check if particle is an initial particle such as ISR.
Definition: MCParticle.h:583
Belle2::MCParticleGraph::c_setDecayInfo
@ c_setDecayInfo
Set decay time and vertex.
Definition: MCParticleGraph.h:74
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2::EvtGenDecayModule::beginRun
virtual void beginRun() override
This method is called when entering a new run.
Definition: EvtGenDecayModule.cc:62
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::MCParticle::getPDG
int getPDG() const
Return PDG code of particle.
Definition: MCParticle.h:123
Belle2::EvtGenDecayModule::endRun
virtual void endRun() override
This method is called if the current run ends.
Definition: EvtGenDecayModule.cc:100
Belle2::MCParticleGraph::c_clearParticles
@ c_clearParticles
Clear the particle list before adding the graph.
Definition: MCParticleGraph.h:76
Belle2::EvtGenDecayModule::m_Initialized
bool m_Initialized
Whether the generator is initialized or not.
Definition: EvtGenDecayModule.h:104
Belle2::EvtGenDecayModule::initialize
virtual void initialize() override
Initialization.
Definition: EvtGenDecayModule.cc:44
Belle2::StoreArray< MCParticle >
Belle2::EvtGenDecayModule::m_BeamParameters
DBObjPtr< BeamParameters > m_BeamParameters
Beam parameters.
Definition: EvtGenDecayModule.h:110
Belle2::EvtGenDecayModule::terminate
virtual void terminate() override
This method is called at the end of the event processing.
Definition: EvtGenDecayModule.cc:104
Belle2::FileSystem::findFile
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:147
Belle2::MCParticle::getNDaughters
int getNDaughters() const
Return number of daughter MCParticles.
Definition: MCParticle.cc:66
Belle2::MCParticleGraph::clear
void clear()
Reset particles and decay information to make the class reusable.
Definition: MCParticleGraph.h:298
Belle2::EvtGenDecayModule::m_MCParticleColName
std::string m_MCParticleColName
MCParticle collection name.
Definition: EvtGenDecayModule.h:95
Belle2::EvtGenDecayModule
This module decays unstable particles using EvtGen.
Definition: EvtGenDecayModule.h:42
Belle2::MCParticleGraph::GraphParticle
Class to represent Particle data in graph.
Definition: MCParticleGraph.h:86
Belle2::EvtGenDecayModule::event
virtual void event() override
This method is called for each event.
Definition: EvtGenDecayModule.cc:66
Belle2::EvtGenDecayModule::m_EvtGenInterface
EvtGenInterface m_EvtGenInterface
Evtgen interface.
Definition: EvtGenDecayModule.h:101