10 #include <generators/kkmc/KKGenInterface.h>
13 #include <framework/gearbox/Const.h>
14 #include <framework/gearbox/Unit.h>
15 #include <framework/logging/Logger.h>
16 #include <framework/particledb/EvtGenDatabasePDG.h>
17 #include <mdst/dataobjects/MCParticleGraph.h>
20 #include <THashList.h>
21 #include <TLorentzVector.h>
31 const std::string& taudecaytableFileName,
const std::string& KKMCOutputFileName)
33 B2DEBUG(20,
"Begin initialisation of KKGen Interface.");
36 char DatX_d[132], DatX_u[132], DatX_p[132], DatX_o[132];
37 for (
int i = 0; i < 132; ++i) {
43 strcpy(DatX_d, KKdefaultFileName.c_str());
44 int length = strlen(DatX_d);
46 strcpy(DatX_u, tauinputFileName.c_str());
47 length = strlen(DatX_u);
49 strcpy(DatX_p, taudecaytableFileName.c_str());
50 length = strlen(DatX_p);
52 strcpy(DatX_o, KKMCOutputFileName.c_str());
53 length = strlen(DatX_o);
56 kk_init_(DatX_d, DatX_u, DatX_p, &irand, DatX_o);
64 for (TObject*
object : *particlelist) {
67 B2FATAL(
"Something is wrong with the EvtGenDatabasePDG, got object not inheriting from EvtGenParticlePDG");
72 B2DEBUG(20,
"End initialisation of KKGen Interface.");
82 double ph = P4_HER.Vect().Mag();
83 double pl = P4_LER.Vect().Mag();
84 double eh = P4_HER.E();
85 double el = P4_LER.E();
86 if (ph > 0. && pl > 0. && eh > 0. && el > 0.) {
88 double pxh, pyh, pzh, pxl, pyl, pzl;
99 "Set Beam info: (%9.4f, %9.4f, %9.4f, %9.4f), (%9.4f, %9.4f, %9.4f, %9.4f)", pxh, pyh, pzh, eh, pxl, pyl, pzl, el);
102 kk_putbeam_(&pxh, &pyh, &pzh, &eh, &pxl, &pyl, &pzl, &el);
104 B2DEBUG(20,
"Espread_LER=" << Espread_LER);
105 B2DEBUG(20,
"Espread_HER=" << Espread_HER);
106 double Espread_CM = 0.0;
109 "Set Beam Energy spread: %9.4f", Espread_CM);
111 kk_begin_run_(&Espread_CM);
115 "Wrongly Set Beam info: Eh=%9.4f, Ph=%9.4f, El=%9.4f, Pl=%9.4f",
124 B2DEBUG(20,
"Start simulation of KKGen Interface.");
129 B2DEBUG(100,
"HepEVT table:");
131 for (
int i = 0; i < hepevt_.
nhep; ++i) {
134 "IntA: %3d %4d %8d %4d %4d %4d %9.4f %9.4f %9.4f %9.4f %9.4f",
138 hepevt_.
phep[i][1], hepevt_.
phep[i][2],
139 hepevt_.
phep[i][3], hepevt_.
phep[i][4]);
145 B2DEBUG(100,
"GraphParticles:");
148 for (
int i = 0; i < npar; ++i) {
152 sprintf(buf,
"IntB: %3d %4u %8d %4d %4d %4d %9.4f %9.4f %9.4f %9.4f",
153 p->getIndex() , p->getStatus() , p->getPDG() , moID ,
154 p->getFirstDaughter() , p->getLastDaughter() ,
155 p->get4Vector().Px() , p->get4Vector().Py() ,
156 p->get4Vector().Pz() , p->get4Vector().E());
161 B2DEBUG(20,
"End simulation of KKGen Interface.");
171 if (hepevt_.
nhep < 5) {
172 B2ERROR(
"KKMC-generated event has not been produced correctty!");
176 std::vector <MCParticleGraph::GraphParticle*> MCPList;
179 for (
int i = 1; i <= hepevt_.
nhep; ++i) {
180 int position = graph.
size();
184 MCPList.push_back(p);
188 for (
int i = 4; i <= hepevt_.
nhep; ++i) {
190 if (hepevt_.
jmohep[i - 1][0] > 0 && hepevt_.
jmohep[i - 1][0] <= hepevt_.
nhep) {
191 int j = hepevt_.
jmohep[i - 1][0];
202 if (index < 1 || index > hepevt_.
nhep)
209 gParticle->
setPDG(iter->second);
219 if (abs(hepevt_.
idhep[index - 1]) == 11 &&
220 hepevt_.
jmohep[index - 1][0] == 0 &&
221 hepevt_.
jmohep[index - 1][1] == 0 &&
222 hepevt_.
isthep[index - 1] == 3 &&
228 if (hepevt_.
idhep[index - 1] == 23 || std::abs(hepevt_.
idhep[index - 1]) == 24) {
230 }
else if (hepevt_.
isthep[index - 1] == 1) {
236 if (hepevt_.
idhep[index - 1] == 22) {
237 if (hepevt_.
jmohep[index - 1][0] == 1) {
243 TLorentzVector p4(hepevt_.
phep[index - 1][0],
244 hepevt_.
phep[index - 1][1],
245 hepevt_.
phep[index - 1][2],
246 hepevt_.
phep[index - 1][3]);
251 TVector3 pProductionVertex(hepevt_.
vhep[index - 1][0]*
Unit::mm,
255 pProductionVertex = pProductionVertex + vertex;
266 kk_term_(&xsec, &xsecerr);
static const double speedOfLight
[cm/ns]
static EvtGenDatabasePDG * Instance()
Instance method that loads the EvtGen table.
Helper class for setting additional TParticlePDG members and storing the ones it doesn't have yet.
int simulateEvent(MCParticleGraph &graph, TVector3 vertex)
Simulate the events.
std::unordered_map< int, int > m_mapPythiaIDtoPDG
Map between PYTHIA id and PDG codes.
void term()
Terminate the generator.
int addParticles2Graph(MCParticleGraph &graph, TVector3 vertex)
Add particles to the MCParticleGraph.
void set_beam_info(TLorentzVector P4_LER, double Espread_LER, TLorentzVector P4_HER, double Espread_HER)
Setup for beams information.
int setup(const std::string &KKdefaultFileName, const std::string &tauinputFileName, const std::string &taudecaytableFileName, const std::string &KKMCOutputFileName)
Setup for KKMC and TAUOLA.
void updateGraphParticle(int, MCParticleGraph::GraphParticle *gParticle, TVector3 vertex)
Update the MCParticleGraph.
Class to represent Particle data in graph.
Class to build, validate and sort a particle decay chain.
@ c_checkCyclic
Check for cyclic dependencies.
@ c_setDecayInfo
Set decay time and vertex.
size_t size() const
Return the number of particles in the graph.
void generateList(const std::string &name="", int options=c_setNothing)
Generates the MCParticle list and stores it in the StoreArray with the given name.
@ c_IsFSRPhoton
bit 7: Particle is from finial state radiation
@ 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.
@ c_StableInGenerator
bit 1: Particle is stable, i.e., not decaying in the generator.
@ c_IsISRPhoton
bit 6: Particle is from initial state radiation
void set4Vector(const TLorentzVector &p4)
Sets the 4Vector of particle.
void setMass(float mass)
Set particle mass.
void setProductionVertex(const TVector3 &vertex)
Set production vertex position.
void addStatus(unsigned short int bitmask)
Add bitmask to current status.
bool hasStatus(unsigned short int bitmask) const
Return if specific status bit is set.
void setValidVertex(bool valid)
Set indication wether vertex and time information is valid or just default.
void setPDG(int pdg)
Set PDG code of the particle.
void setProductionTime(float time)
Set production time.
static const double mm
[millimeters]
GraphParticle & addParticle()
Add new particle to the graph.
Abstract base class for different kinds of events.
int jmohep[nmxhep][2]
parent particles.
int isthep[nmxhep]
status code.
double vhep[nmxhep][4]
vertex [mm].
int jdahep[nmxhep][2]
childreen particles.
double phep[nmxhep][5]
four-momentum, mass [GeV].
int idhep[nmxhep]
particle ident KF.
int nhep
number of particles.