9#include <generators/phokhara/Phokhara.h>
10#include <framework/logging/Logger.h>
12#include <TDatabasePDG.h>
13#include <Math/Vector4D.h>
30 } belle2_phokhara_particles;
38 double phokhara_rndm()
40 double r = gRandom->Rndm();
49 void phokhara_rndmarray(
double* drvec,
const int* lengt)
51 for (
int i = 0; i < *lengt; ++i) {
52 drvec[i] = gRandom->Rndm();
57 void phokhara(
int* mode,
double* xpar,
int* npar);
61 void phokhara_set_parameter_file(
const char* paramfilename);
64 void phokhara_error_trials_(
const double* trials)
66 B2ERROR(
"PHOKHARA: Event rejected! Number of maximal trials (" << *trials <<
" << exceeded");
70 void phokhara_warning_weight_(
const int* photmult,
const double* weight,
const double* max)
72 B2WARNING(
"PHOKHARA: Event weight (" << *weight <<
") exceeds limit (" << *max <<
"), photon multiplicity: " << *photmult);
76 void phokhara_warning_negweight_(
const int* photmult,
const double* weight)
78 B2WARNING(
"PHOKHARA: Event weight (" << *weight <<
") is negative, photon multiplicity: " << *photmult);
85 for (
int i = 0; i < 100; ++i) {
168 B2INFO(
"Phokhara::init, using paramater file: " << paramFile);
170 if (paramFile.empty()) B2FATAL(
"Phokhara: The specified param file is empty!");
171 phokhara_set_parameter_file(paramFile.c_str());
189 double partMom[4] = {0, 0, 0, 0};
190 for (
int iPart = 0; iPart < belle2_phokhara_particles.bnhad; ++iPart) {
191 for (
int j = 0; j < 4; ++j)
192 partMom[j] += belle2_phokhara_particles.bp2[j][iPart];
194 double m2 = partMom[0] * partMom[0] - partMom[1] * partMom[1]
195 - partMom[2] * partMom[2] - partMom[3] * partMom[3];
203 if (belle2_error_flag_.error_flag != 0) {
204 B2FATAL(
"Phokhara returned a non-zero exit code. Check the output of phokara.");
207 double eMom[4] = {belle2_phokhara_particles.bp1[1], belle2_phokhara_particles.bp1[2], belle2_phokhara_particles.bp1[3], belle2_phokhara_particles.bp1[0]};
208 double pMom[4] = {belle2_phokhara_particles.bq1[1], belle2_phokhara_particles.bq1[2], belle2_phokhara_particles.bq1[3], belle2_phokhara_particles.bq1[0]};
210 storeParticle(mcGraph, eMom, 11, vertex, boost,
false,
true);
211 storeParticle(mcGraph, pMom, -11, vertex, boost,
false,
true);
214 for (
int iPhot = 0; iPhot < belle2_phokhara_particles.bnphot; ++iPhot) {
215 double photMom[4] = {belle2_phokhara_particles.bphot[1][iPhot], belle2_phokhara_particles.bphot[2][iPhot], belle2_phokhara_particles.bphot[3][iPhot], belle2_phokhara_particles.bphot[0][iPhot]};
216 storeParticle(mcGraph, photMom, 22, vertex, boost,
false,
false);
221 if (belle2_phokhara_particles.bnhad != 2)
222 B2FATAL(
"Number of particles generated by PHOKHARA does not match the "
223 "requested final state (mu+ mu-).");
224 double partMom[4] = {belle2_phokhara_particles.bp2[1][0] + belle2_phokhara_particles.bp2[1][1],
225 belle2_phokhara_particles.bp2[2][0] + belle2_phokhara_particles.bp2[2][1],
226 belle2_phokhara_particles.bp2[3][0] + belle2_phokhara_particles.bp2[3][1],
227 belle2_phokhara_particles.bp2[0][0] + belle2_phokhara_particles.bp2[0][1]
229 storeParticle(mcGraph, partMom, 10022, vertex, boost,
false,
false);
231 for (
int iPart = 0; iPart < belle2_phokhara_particles.bnhad; ++iPart) {
232 double partMom[4] = {belle2_phokhara_particles.bp2[1][iPart], belle2_phokhara_particles.bp2[2][iPart], belle2_phokhara_particles.bp2[3][iPart], belle2_phokhara_particles.bp2[0][iPart]};
234 storeParticle(mcGraph, partMom, belle2_phokhara_particles.bp2[4][iPart], vertex, boost,
false,
false);
240 int id = 2 + belle2_phokhara_particles.bnphot;
250 daughter1 = &mcGraph[
id + 4];
252 daughter2 = &mcGraph[
id + 5];
260 return belle2_phokhara_particles.wgt;
338 if (belle2_error_flag_.error_flag != 0) {
339 B2FATAL(
"Phokhara returned a non-zero exit code. Check the output of phokara.");
345 ROOT::Math::LorentzRotation boost,
bool isVirtual,
bool isInitial)
359 }
else if (isInitial) {
372 part.
setMomentum(ROOT::Math::XYZVector(mom[0], mom[1], mom[2]));
375 part.
setMass(
sqrt(mom[3] * mom[3] - mom[0] * mom[0] - mom[1] * mom[1] -
378 part.
setMass(TDatabasePDG::Instance()->GetParticle(pdg)->Mass());
382 ROOT::Math::PxPyPzEVector p4 = part.
get4Vector();
Class to represent Particle data in graph.
void comesFrom(GraphParticle &mother)
Tells the graph that this particle is a decay product of mother.
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_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 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.
void removeStatus(unsigned short int bitmask)
Remove bitmask from current status.
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.
double m_beamres
beam resolution for chi2 studies
int m_pionstructure
for pi+pi- only: f0+f0(600): K+K- model(0), "no structure" model(1), no f0+f0(600)(2),...
int m_LO
LO: 1ph(0, default), Born: 0ph(1), only Born: 0ph(-1)
void init(const std::string ¶mFile)
Initializes the generator.
double m_alphaQED0
QED coupling constant at Q=0.
bool m_ForceMinInvMassHadronsCut
Force application of the above cut.
int m_finalState
final state, called 'pion' in Phokhara, dont get confused.
int m_npar[100]
Integer parameters for PHOKHARA.
double m_conversionFactor
Conversion factor for hbarc to nb.
std::pair< double, double > m_ScatteringAngleRangeFinalStates
Minimal/Maximal pions(muons,nucleons,kaons) momentum angle.
int m_QED
ISR only(0), ISR+FSR(1), ISR+INT+FSR(2)
void storeParticle(MCParticleGraph &mcGraph, const double *mom, 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.
void setDefaultSettings()
Sets the default settings for the PHOKHARA generator.
int m_narres
narr_res: no narrow resonances (0), J/psi (1) and psi(2S) (2) only for m_finalState = 0,...
double m_cmsEnergy
CMS Energy = 2*Ebeam [GeV].
int m_alpha
vacuum polarization switch: off (0), on (1,[by Fred Jegerlehner]), on (2,[by Thomas Teubner])
int m_chi_sw
chi_sw: Radiative return(0), Chi production(1), Radiative return + Chi production (2)
double m_epsilon
Soft/hard photon separator in units of CMS/2., called 'w' in Phokhara.
double m_massMuon
electron mass.
int m_pionff
FF_pion: KS PionFormFactor(0),GS old (1),GS new (2)
double m_massW
W mass [GeV] for on shell sin2theta and GF.
int m_protonff
ProtonFormFactor old(0), ProtonFormFactor new(1)
std::pair< double, double > m_ScatteringAngleRangePhoton
Minimal/Maximal photon angle/missing momentum angle.
double m_widthZ
Z width [GeV] (may be recalculated by EW library).
void term()
Terminates the generator.
int m_IFSNLO
IFSNLO: no(0), yes(1)
int m_nSearchMax
Events used to search maximum of differential cross section.
int m_nMaxTrials
Events before loop is aborted.
double generateEvent(MCParticleGraph &mcGraph, ROOT::Math::XYZVector vertex, ROOT::Math::LorentzRotation boost)
Generates one single event.
int m_be_r
be_r: without beam resolution(0), with beam resolution(1)
double m_MinInvMassHadronsGamma
minimum mass of the hadron-gamma system [GeV^2]
double m_xpar[100]
Double parameters for PHOKHARA.
double m_massZ
Z mass [GeV].
int m_kaonff
FF_kaon: KaonFormFactor constrained(0), KaonFormFactor unconstrained(1) KaonFormFactor old(2)
double m_massElectron
muon mass.
int m_weighted
generate weighted events
int m_NLO
NLO, for 1ph only: off (0, default), on (1)
double m_MaxInvMassHadrons
maximum mass of the hadron system [GeV^2]
int m_fullNLO
NLO, full NLO : No(0), Yes(1)
double m_MinEnergyGamma
minimum gamma energy [GeV]
double m_MinInvMassHadrons
minimum mass of the hadron system [GeV^2]
void applySettings()
Apply the settings to the internal Fortran generator.
bool m_replaceMuonsByVirtualPhoton
Replace muons by a virtual photon.
double sqrt(double a)
sqrt for double
GraphParticle & addParticle()
Add new particle to the graph.
Abstract base class for different kinds of events.