10 #include <generators/koralw/KoralW.h>
13 #include <framework/gearbox/Unit.h>
14 #include <framework/logging/Logger.h>
53 void kw_setdatapath_(
const char* filename,
size_t* length);
54 void kw_readatax_(
const char* filename,
size_t* length,
int* reset,
const int* max,
double* xpar);
55 void kw_initialize_(
double* ecm,
double* xpar);
56 void marini_(
unsigned int* mar1,
unsigned int* mar2,
unsigned int* mar3);
57 void rmarin_(
unsigned int* mar1,
unsigned int* mar2,
unsigned int* mar3);
60 void kw_getmomdec_(
double* p1,
double* p2,
double* p3,
double* p4);
61 void kw_getxsecmc_(
double* xSecMC,
double* xErrMC);
63 void koralw_warning_ecm_(
const double* ecmconfig,
const double* ecm)
65 B2WARNING(
"KORALW: Different center of mass energy in config file (obsolete), E=" << *ecmconfig <<
", and from beam parameters, E="
71 void KoralW::init(
const std::string& dataPath,
const std::string& userDataFile)
73 if (dataPath.empty()) B2FATAL(
"KoralW: The specified data path is empty !");
74 if (userDataFile.empty()) B2FATAL(
"KoralW: The specified user data file is empty !");
77 string dataPathNew = dataPath;
78 if (dataPath[dataPath.length() - 1] !=
'/') dataPathNew +=
"/";
81 size_t pathLength = dataPathNew.size();
82 kw_setdatapath_(dataPathNew.c_str(), &pathLength);
86 const string defaultDataFile = dataPathNew +
"KoralW_Default.data";
87 pathLength = defaultDataFile.size();
88 kw_readatax_(defaultDataFile.c_str(), &pathLength, &reset, &m_numXPar, m_XPar);
92 pathLength = userDataFile.size();
93 kw_readatax_(userDataFile.c_str(), &pathLength, &reset, &m_numXPar, m_XPar);
96 kw_initialize_(&m_cmsEnergy, m_XPar);
99 unsigned int mar1 = gRandom->Integer(m_seed1);
100 unsigned int mar2 = gRandom->Integer(m_seed2);
101 unsigned int mar3 = gRandom->Integer(m_seed3);
102 marini_(&mar1, &mar2, &mar3);
103 rmarin_(&mar1, &mar2, &mar3);
107 void KoralW::generateEvent(
MCParticleGraph& mcGraph, ROOT::Math::XYZVector vertex, ROOT::Math::LorentzRotation boost)
112 for (
int iPart = 0; iPart < hepevt_.
nhep; ++iPart) {
113 if (hepevt_.
isthep[iPart] > 1) {
114 storeParticle(mcGraph, hepevt_.
phep[iPart], hepevt_.
vhep[iPart], hepevt_.
idhep[iPart], vertex, boost,
true);
116 storeParticle(mcGraph, hepevt_.
phep[iPart], hepevt_.
vhep[iPart], hepevt_.
idhep[iPart], vertex, boost);
127 kw_getxsecmc_(&m_crossSection, &m_crossSectionError);
134 void KoralW::storeParticle(
MCParticleGraph& mcGraph,
const float* mom,
const float* vtx,
int pdg, ROOT::Math::XYZVector vertex,
135 ROOT::Math::LorentzRotation boost,
bool isVirtual,
bool isInitial)
148 part.setStatus(MCParticle::c_IsVirtual);
149 }
else if (isInitial) {
150 part.setStatus(MCParticle::c_Initial);
154 part.addStatus(MCParticle::c_PrimaryParticle);
156 part.setFirstDaughter(0);
157 part.setLastDaughter(0);
158 part.setMomentum(ROOT::Math::XYZVector(mom[0], mom[1], mom[2]));
159 part.setEnergy(mom[3]);
160 part.setMass(mom[4]);
161 part.setProductionVertex(vtx[0]*Unit::mm, vtx[1]*Unit::mm, vtx[2]*Unit::mm);
164 ROOT::Math::PxPyPzEVector p4 = part.get4Vector();
170 ROOT::Math::XYZVector v3 = part.getProductionVertex();
172 part.setProductionVertex(v3);
173 part.setValidVertex(
true);
Class to represent Particle data in graph.
Class to build, validate and sort a particle decay chain.
GraphParticle & addParticle()
Add new particle to the graph.
Abstract base class for different kinds of events.
int isthep[nmxhep]
status code.
double vhep[nmxhep][4]
vertex [mm].
double phep[nmxhep][5]
four-momentum, mass [GeV].
int idhep[nmxhep]
particle ident KF.
int nhep
number of particles.