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="
71void 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);
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);
112 for (
int iPart = 0; iPart < hepevt_.
nhep; ++iPart) {
113 if (hepevt_.
isthep[iPart] > 1) {
135 ROOT::Math::LorentzRotation boost,
bool isVirtual,
bool isInitial)
149 }
else if (isInitial) {
158 part.
setMomentum(ROOT::Math::XYZVector(mom[0], mom[1], mom[2]));
164 ROOT::Math::PxPyPzEVector p4 = part.
get4Vector();
void generateEvent(MCParticleGraph &mcGraph, ROOT::Math::XYZVector vertex, ROOT::Math::LorentzRotation boost)
Generates one single event.
double m_crossSection
The cross section of the generated KoralW events.
double m_cmsEnergy
CMS Energy = 2*Ebeam [GeV].
static constexpr int m_numXPar
Number of parameters for KoralW.
unsigned int m_seed2
Second seed for the random number generator.
unsigned int m_seed3
Third seed for the random number generator.
void term()
Terminates the generator.
void init(const std::string &dataPath, const std::string &userDataFile)
Initializes the generator.
double m_crossSectionError
The error on the cross section of the generated KoralW events.
void storeParticle(MCParticleGraph &mcGraph, const float *mom, const float *vtx, int pdg, ROOT::Math::XYZVector vertex, ROOT::Math::LorentzRotation boost, bool isVirtual=false, bool isInitial=false)
Store a single generated particle into the MonteCarlo graph.
double m_XPar[m_numXPar]
Values of parameters for KoralW.
unsigned int m_seed1
First seed for the random number generator.
Class to represent Particle data in graph.
void setFirstDaughter(int daughter)
Set the 1-based index of the first daughter, 0 means no daughters.
void setLastDaughter(int daughter)
Set the 1-based index of the last daughter, 0 means no daughters.
Class to build, validate and sort a particle decay chain.
@ c_Initial
bit 5: Particle is initial such as e+ or e- and not going to Geant4
@ c_PrimaryParticle
bit 0: Particle is primary particle.
@ c_IsVirtual
bit 4: Particle is virtual and not going to Geant4.
void setMass(float mass)
Set particle mass.
void addStatus(unsigned short int bitmask)
Add bitmask to current status.
void setEnergy(float energy)
Set energy.
ROOT::Math::XYZVector getProductionVertex() const
Return production vertex position.
void setValidVertex(bool valid)
Set indication wether vertex and time information is valid or just default.
void setProductionVertex(const ROOT::Math::XYZVector &vertex)
Set production vertex position.
ROOT::Math::PxPyPzEVector get4Vector() const
Return 4Vector of particle.
void setPDG(int pdg)
Set PDG code of the particle.
void set4Vector(const ROOT::Math::PxPyPzEVector &p4)
Sets the 4Vector of particle.
void setMomentum(const ROOT::Math::XYZVector &momentum)
Set particle momentum.
void setStatus(unsigned short int status)
Set Status code for the particle.
static const double mm
[millimeters]
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.