9 #include <generators/modules/evtgeninput/EvtGenInputModule.h>
10 #include <generators/evtgen/EvtGenInterface.h>
11 #include <mdst/dataobjects/MCParticleGraph.h>
12 #include <framework/utilities/FileSystem.h>
14 #include <framework/datastore/StoreArray.h>
32 setDescription(
"EvtGenInput module. The module is served as an interface for EvtGen Event Generator so that the EvtGen generator can store the generated particles into MCParticles. The users need to provide their own decay mode based on the standard DECAY.DEC.");
36 addParam(
"userDECFile", m_userDECFileName,
"user DECfile name",
string(
""));
37 addParam(
"DECFile", m_DECFileName,
"global DECfile to be used",
38 FileSystem::findFile(
"decfiles/dec/DECAY_BELLE2.DEC",
true));
39 addParam(
"ParentParticle", m_parentParticle,
"Parent Particle Name",
string(
"Upsilon(4S)"));
40 addParam(
"InclusiveType", m_inclusiveType,
"inclusive decay type (0: generic, 1: inclusive, 2: inclusive (charge conjugate)", 0);
41 addParam(
"CoherentMixing", m_coherentMixing,
"decay the neutral B meson pairs coherently or non-coherently",
true);
42 addParam(
"InclusiveParticle", m_inclusiveParticle,
"Inclusive Particle Name",
string(
""));
43 addParam(
"maxTries", m_maxTries,
"Number of tries to generate a parent "
44 "particle from the beam energies which fits inside the mass window "
45 "before giving up", 100000);
47 m_PrimaryVertex = TVector3(0., 0., 0.);
52 void EvtGenInputModule::initialize()
54 const std::string defaultDecFile = FileSystem::findFile(
"decfiles/dec/DECAY_BELLE2.DEC",
true);
55 if (m_DECFileName.empty()) {
56 B2ERROR(
"No global decay file defined, please make sure the parameter 'DECFile' is set correctly");
59 if (defaultDecFile.empty()) {
60 B2WARNING(
"Cannot find default decay file");
61 }
else if (defaultDecFile != m_DECFileName) {
62 B2INFO(
"Using non-standard DECAY file \"" << m_DECFileName <<
"\"");
69 m_initial.initialize();
74 void EvtGenInputModule::beginRun()
79 TLorentzVector EvtGenInputModule::createBeamParticle(
double minMass,
double maxMass)
82 for (
int i = 0; i < m_maxTries; ++i) {
88 TLorentzVector beam = initial.
getLER() + initial.
getHER();
95 B2FATAL(
"Could not create parent particle within mass window: "
96 <<
"minMass=" << minMass <<
" GeV, "
97 <<
"maxMass=" << maxMass <<
" GeV");
100 return TLorentzVector(0, 0, 0, 0);
103 void EvtGenInputModule::event()
105 B2DEBUG(10,
"Starting event generation");
108 if (m_beamParams.hasChanged()) {
109 if (!m_initialized) {
110 initializeGenerator();
112 B2FATAL(
"EvtGenInputModule::event(): BeamParameters have changed within a job, this is not supported for EvtGen!");
116 TLorentzVector pParentParticle;
119 if (EvtPDL::getStdHep(m_parentId) == 10022) {
121 pParentParticle = createBeamParticle();
124 pParentParticle = createBeamParticle(EvtPDL::getMinMass(m_parentId),
125 EvtPDL::getMaxMass(m_parentId));
133 int nPart = m_Ievtgen.simulateEvent(mpg, pParentParticle, m_PrimaryVertex,
134 m_inclusiveType, m_inclusiveParticle);
136 B2DEBUG(10,
"EvtGen: generated event with " << nPart <<
" particles.");
139 void EvtGenInputModule::initializeGenerator()
143 m_Ievtgen.setup(m_DECFileName, m_parentParticle, m_userDECFileName, m_coherentMixing);
145 if (m_inclusiveType == 0) m_inclusiveParticle =
"";
146 if (m_inclusiveType != 0 && EvtPDL::getId(m_inclusiveParticle).getId() == -1) {
147 B2ERROR(
"User Specified Inclusive Particle '" << m_inclusiveParticle
148 <<
"' does not exist");
150 m_parentId = EvtPDL::getId(m_parentParticle);
151 if (m_parentId.getId() == -1) {
152 B2ERROR(
"User specified parent particle '" << m_parentParticle
153 <<
"' does not exist");
156 m_initialized =
true;
This class contains the nominal beam parameters and the parameters used for smearing of the primary v...
This class contains the initial state for the given event.
const TLorentzVector & getLER() const
Get 4vector of the low energy beam.
const TVector3 & getVertex() const
Get the position of the collision.
const TLorentzVector & getHER() const
Get 4vector of the high energy beam.
double getMass() const
Get the invariant mass of the collision (= energy in CMS)
bool registerInDataStore(DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
Register the object/array in the DataStore.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.