11 #include <generators/modules/evtgeninput/EvtGenInputModule.h>
12 #include <generators/evtgen/EvtGenInterface.h>
13 #include <mdst/dataobjects/MCParticleGraph.h>
14 #include <framework/utilities/FileSystem.h>
16 #include <framework/datastore/StoreArray.h>
34 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.");
38 addParam(
"userDECFile", m_userDECFileName,
"user DECfile name",
string(
""));
39 addParam(
"DECFile", m_DECFileName,
"global DECfile to be used",
40 FileSystem::findFile(
"decfiles/dec/DECAY_BELLE2.DEC",
true));
41 addParam(
"ParentParticle", m_parentParticle,
"Parent Particle Name",
string(
"Upsilon(4S)"));
42 addParam(
"InclusiveType", m_inclusiveType,
"inclusive decay type (0: generic, 1: inclusive, 2: inclusive (charge conjugate)", 0);
43 addParam(
"CoherentMixing", m_coherentMixing,
"decay the neutral B meson pairs coherently or non-coherently",
true);
44 addParam(
"InclusiveParticle", m_inclusiveParticle,
"Inclusive Particle Name",
string(
""));
45 addParam(
"maxTries", m_maxTries,
"Number of tries to generate a parent "
46 "particle from the beam energies which fits inside the mass window "
47 "before giving up", 100000);
49 m_PrimaryVertex = TVector3(0., 0., 0.);
54 void EvtGenInputModule::initialize()
56 const std::string defaultDecFile = FileSystem::findFile(
"decfiles/dec/DECAY_BELLE2.DEC",
true);
57 if (m_DECFileName.empty()) {
58 B2ERROR(
"No global decay file defined, please make sure the parameter 'DECFile' is set correctly");
61 if (defaultDecFile.empty()) {
62 B2WARNING(
"Cannot find default decay file");
63 }
else if (defaultDecFile != m_DECFileName) {
64 B2INFO(
"Using non-standard DECAY file \"" << m_DECFileName <<
"\"");
68 mcparticle.registerInDataStore();
71 m_initial.initialize();
76 void EvtGenInputModule::beginRun()
81 TLorentzVector EvtGenInputModule::createBeamParticle(
double minMass,
double maxMass)
84 for (
int i = 0; i < m_maxTries; ++i) {
90 TLorentzVector beam = initial.
getLER() + initial.
getHER();
97 B2FATAL(
"Could not create parent particle within mass window: "
98 <<
"minMass=" << minMass <<
" GeV, "
99 <<
"maxMass=" << maxMass <<
" GeV");
102 return TLorentzVector(0, 0, 0, 0);
105 void EvtGenInputModule::event()
107 B2DEBUG(10,
"Starting event generation");
110 if (m_beamParams.hasChanged()) {
111 if (!m_initialized) {
112 initializeGenerator();
114 B2FATAL(
"EvtGenInputModule::event(): BeamParameters have changed within a job, this is not supported for EvtGen!");
118 TLorentzVector pParentParticle;
121 if (EvtPDL::getStdHep(m_parentId) == 10022) {
123 pParentParticle = createBeamParticle();
126 pParentParticle = createBeamParticle(EvtPDL::getMinMass(m_parentId),
127 EvtPDL::getMaxMass(m_parentId));
135 int nPart = m_Ievtgen.simulateEvent(mpg, pParentParticle, m_PrimaryVertex,
136 m_inclusiveType, m_inclusiveParticle);
138 B2DEBUG(10,
"EvtGen: generated event with " << nPart <<
" particles.");
141 void EvtGenInputModule::initializeGenerator()
145 m_Ievtgen.setup(m_DECFileName, m_parentParticle, m_userDECFileName, m_coherentMixing);
147 if (m_inclusiveType == 0) m_inclusiveParticle =
"";
148 if (m_inclusiveType != 0 && EvtPDL::getId(m_inclusiveParticle).getId() == -1) {
149 B2ERROR(
"User Specified Inclusive Particle '" << m_inclusiveParticle
150 <<
"' does not exist");
152 m_parentId = EvtPDL::getId(m_parentParticle);
153 if (m_parentId.getId() == -1) {
154 B2ERROR(
"User specified parent particle '" << m_parentParticle
155 <<
"' does not exist");
158 m_initialized =
true;