Belle II Software development
KoralW Class Reference

C++ interface for the FORTRAN 4-fermion final state generator KoralW. More...

#include <KoralW.h>

Public Member Functions

 KoralW ()
 Constructor.
 
 ~KoralW ()
 Destructor.
 
void setCMSEnergy (double cmsEnergy)
 Sets the CMS energy.
 
void init (const std::string &dataPath, const std::string &userDataFile)
 Initializes the generator.
 
void generateEvent (MCParticleGraph &mcGraph, ROOT::Math::XYZVector vertex, ROOT::Math::LorentzRotation boost)
 Generates one single event.
 
void term ()
 Terminates the generator.
 
double getCrossSection ()
 Returns the total cross section of the generated process.
 
double getCrossSectionError ()
 Returns the error on the total cross section of the generated process.
 

Protected Member Functions

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.
 

Protected Attributes

double m_crossSection
 The cross section of the generated KoralW events.
 
double m_crossSectionError
 The error on the cross section of the generated KoralW events.
 
double m_cmsEnergy
 CMS Energy = 2*Ebeam [GeV].
 

Private Attributes

double m_XPar [m_numXPar]
 Values of parameters for KoralW.
 
unsigned int m_seed1
 First seed for the random number generator.
 
unsigned int m_seed2
 Second seed for the random number generator.
 
unsigned int m_seed3
 Third seed for the random number generator.
 

Static Private Attributes

static constexpr int m_numXPar = 10000
 Number of parameters for KoralW.
 

Detailed Description

C++ interface for the FORTRAN 4-fermion final state generator KoralW.

Definition at line 30 of file KoralW.h.

Constructor & Destructor Documentation

◆ KoralW()

KoralW ( )
inline

Constructor.

Definition at line 35 of file KoralW.h.

35 :
36 m_crossSection(0.0),
38 m_cmsEnergy(0.0),
39 m_seed1(900000000),
40 m_seed2(10000),
41 m_seed3(1000)
42 {for (int i = 0; i < m_numXPar; i++) m_XPar[i] = 0.0;}
double m_crossSection
The cross section of the generated KoralW events.
Definition: KoralW.h:85
double m_cmsEnergy
CMS Energy = 2*Ebeam [GeV].
Definition: KoralW.h:89
static constexpr int m_numXPar
Number of parameters for KoralW.
Definition: KoralW.h:107
unsigned int m_seed2
Second seed for the random number generator.
Definition: KoralW.h:113
unsigned int m_seed3
Third seed for the random number generator.
Definition: KoralW.h:115
double m_crossSectionError
The error on the cross section of the generated KoralW events.
Definition: KoralW.h:87
double m_XPar[m_numXPar]
Values of parameters for KoralW.
Definition: KoralW.h:109
unsigned int m_seed1
First seed for the random number generator.
Definition: KoralW.h:111

◆ ~KoralW()

~KoralW ( )
inline

Destructor.

Definition at line 46 of file KoralW.h.

46{};

Member Function Documentation

◆ generateEvent()

void generateEvent ( MCParticleGraph mcGraph,
ROOT::Math::XYZVector  vertex,
ROOT::Math::LorentzRotation  boost 
)

Generates one single event.

Parameters
mcGraphReference to the MonteCarlo graph into which the generated particles will be stored.
vertexgenerated vertex.
boostgenerated boost.

Definition at line 107 of file KoralW.cc.

108{
109 kw_make_();
110
111 //Store the particles with status id 3 and 2 as virtual particles, the particles with status id 1 as real particles
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);
115 } else {
116 storeParticle(mcGraph, hepevt_.phep[iPart], hepevt_.vhep[iPart], hepevt_.idhep[iPart], vertex, boost);
117 }
118 }
119}
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.
Definition: KoralW.cc:134
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.

◆ getCrossSection()

double getCrossSection ( )
inline

Returns the total cross section of the generated process.

Returns
The total cross section.

Definition at line 75 of file KoralW.h.

75{ return m_crossSection; }

◆ getCrossSectionError()

double getCrossSectionError ( )
inline

Returns the error on the total cross section of the generated process.

Returns
The error on the total cross section.

Definition at line 80 of file KoralW.h.

80{ return m_crossSectionError; }

◆ init()

void init ( const std::string &  dataPath,
const std::string &  userDataFile 
)

Initializes the generator.

Parameters
dataPathThe path to the default input data file for KoralW.
userDataFileThe path and filename of the user input data file, which defines the user settings for the generator.

Definition at line 71 of file KoralW.cc.

72{
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 !");
75
76 //Make sure the dataPath ends with an "/"
77 string dataPathNew = dataPath;
78 if (dataPath[dataPath.length() - 1] != '/') dataPathNew += "/";
79
80 //Set the path to the data files
81 size_t pathLength = dataPathNew.size();
82 kw_setdatapath_(dataPathNew.c_str(), &pathLength);
83
84 //Load the default KoralW input data
85 int reset = 1;
86 const string defaultDataFile = dataPathNew + "KoralW_Default.data";
87 pathLength = defaultDataFile.size();
88 kw_readatax_(defaultDataFile.c_str(), &pathLength, &reset, &m_numXPar, m_XPar);
89
90 //Load the user KoralW input data
91 reset = 0;
92 pathLength = userDataFile.size();
93 kw_readatax_(userDataFile.c_str(), &pathLength, &reset, &m_numXPar, m_XPar);
94
95 //Initialize KoralW
96 kw_initialize_(&m_cmsEnergy, m_XPar);
97
98 //Initialize random number generator
99 unsigned int mar1 = gRandom->Integer(m_seed1); //The range for this seed seems to be [0, 900000000]
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);
104}

◆ setCMSEnergy()

void setCMSEnergy ( double  cmsEnergy)
inline

Sets the CMS energy.

Parameters
cmsEnergyThe CMS energy in [GeV].

Definition at line 51 of file KoralW.h.

51{ m_cmsEnergy = cmsEnergy; }

◆ storeParticle()

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 
)
protected

Store a single generated particle into the MonteCarlo graph.

Parameters
mcGraphReference to the MonteCarlo graph into which the particle should be stored.
momThe 3-momentum of the particle in [GeV].
vtxThe vertex of the particle in [mm].
pdgThe PDG code of the particle.
vertexThe vertex of the particle in [mm].
boostLorentz boost vector.
isVirtualIf the particle is a virtual particle, such as the incoming particles, set this to true.
isInitialIf the particle is a initial particle for ISR, set this to true.

Definition at line 134 of file KoralW.cc.

136{
137 // //Create particle
138 //MCParticleGraph::GraphParticle& part = mcGraph.addParticle();
139 //if (!isVirtual) {
140 // part.setStatus(MCParticle::c_PrimaryParticle);
141 //} else {
142 // part.setStatus(MCParticle::c_IsVirtual);
143 //}
144
145 // RG 6/25/14 Add new flag for ISR "c_Initial"
147 if (isVirtual) {
149 } else if (isInitial) {
151 }
152
153 //every particle from a generator is primary, TF
155 part.setPDG(pdg);
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);
162
163 //boost, TF
164 ROOT::Math::PxPyPzEVector p4 = part.get4Vector();
165 p4 = boost * p4;
166 part.set4Vector(p4);
167
168 //set vertex, TF
169 if (!isInitial) {
170 ROOT::Math::XYZVector v3 = part.getProductionVertex();
171 v3 = v3 + vertex;
172 part.setProductionVertex(v3);
173 part.setValidVertex(true);
174 }
175}
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.
@ c_Initial
bit 5: Particle is initial such as e+ or e- and not going to Geant4
Definition: MCParticle.h:57
@ c_PrimaryParticle
bit 0: Particle is primary particle.
Definition: MCParticle.h:47
@ c_IsVirtual
bit 4: Particle is virtual and not going to Geant4.
Definition: MCParticle.h:55
void setMass(float mass)
Set particle mass.
Definition: MCParticle.h:366
void addStatus(unsigned short int bitmask)
Add bitmask to current status.
Definition: MCParticle.h:353
void setEnergy(float energy)
Set energy.
Definition: MCParticle.h:372
ROOT::Math::XYZVector getProductionVertex() const
Return production vertex position.
Definition: MCParticle.h:189
void setValidVertex(bool valid)
Set indication wether vertex and time information is valid or just default.
Definition: MCParticle.h:378
void setProductionVertex(const ROOT::Math::XYZVector &vertex)
Set production vertex position.
Definition: MCParticle.h:396
ROOT::Math::PxPyPzEVector get4Vector() const
Return 4Vector of particle.
Definition: MCParticle.h:207
void setPDG(int pdg)
Set PDG code of the particle.
Definition: MCParticle.h:335
void set4Vector(const ROOT::Math::PxPyPzEVector &p4)
Sets the 4Vector of particle.
Definition: MCParticle.h:438
void setMomentum(const ROOT::Math::XYZVector &momentum)
Set particle momentum.
Definition: MCParticle.h:417
void setStatus(unsigned short int status)
Set Status code for the particle.
Definition: MCParticle.h:346
static const double mm
[millimeters]
Definition: Unit.h:70
GraphParticle & addParticle()
Add new particle to the graph.
const std::vector< double > v3
MATLAB generated random vector.

◆ term()

void term ( )

Terminates the generator.

Closes the internal Fortran generator and retrieves the total cross section.

Definition at line 122 of file KoralW.cc.

123{
124 kw_finalize_();
125
126 //Get the cross section
127 kw_getxsecmc_(&m_crossSection, &m_crossSectionError);
128}

Member Data Documentation

◆ m_cmsEnergy

double m_cmsEnergy
protected

CMS Energy = 2*Ebeam [GeV].

Definition at line 89 of file KoralW.h.

◆ m_crossSection

double m_crossSection
protected

The cross section of the generated KoralW events.

Definition at line 85 of file KoralW.h.

◆ m_crossSectionError

double m_crossSectionError
protected

The error on the cross section of the generated KoralW events.

Definition at line 87 of file KoralW.h.

◆ m_numXPar

constexpr int m_numXPar = 10000
staticconstexprprivate

Number of parameters for KoralW.

Definition at line 107 of file KoralW.h.

◆ m_seed1

unsigned int m_seed1
private

First seed for the random number generator.

Definition at line 111 of file KoralW.h.

◆ m_seed2

unsigned int m_seed2
private

Second seed for the random number generator.

Definition at line 113 of file KoralW.h.

◆ m_seed3

unsigned int m_seed3
private

Third seed for the random number generator.

Definition at line 115 of file KoralW.h.

◆ m_XPar

double m_XPar[m_numXPar]
private

Values of parameters for KoralW.

Definition at line 109 of file KoralW.h.


The documentation for this class was generated from the following files: