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;
33 double phokhara_rndm()
35 double r = gRandom->Rndm();
44 void phokhara_rndmarray(
double* drvec,
const int* lengt)
46 for (
int i = 0; i < *lengt; ++i) {
47 drvec[i] = gRandom->Rndm();
52 void phokhara(
int* mode,
double* xpar,
int* npar);
56 void phokhara_set_parameter_file(
const char* paramfilename);
59 void phokhara_error_trials_(
const double* trials)
61 B2ERROR(
"PHOKHARA: Event rejected! Number of maximal trials (" << *trials <<
" << exceeded");
65 void phokhara_warning_weight_(
const int* photmult,
const double* weight,
const double* max)
67 B2WARNING(
"PHOKHARA: Event weight (" << *weight <<
") exceeds limit (" << *max <<
"), photon multiplicity: " << *photmult);
71 void phokhara_warning_negweight_(
const int* photmult,
const double* weight)
73 B2WARNING(
"PHOKHARA: Event weight (" << *weight <<
") is negative, photon multiplicity: " << *photmult);
80 for (
int i = 0; i < 100; ++i) {
93 void Phokhara::setDefaultSettings()
123 m_replaceMuonsByVirtualPhoton =
false;
135 m_pionstructure = -1;
139 m_ScatteringAngleRangePhoton = make_pair(0.0, 180.0);
140 m_ScatteringAngleRangeFinalStates = make_pair(0.0, 180.0);
141 m_MinInvMassHadronsGamma = -1;
142 m_MinInvMassHadrons = 0.;
143 m_ForceMinInvMassHadronsCut =
false;
144 m_MaxInvMassHadrons = 0.;
145 m_MinEnergyGamma = 0.;
151 m_conversionFactor = 0.;
161 void Phokhara::init(
const std::string& paramFile)
163 B2INFO(
"Phokhara::init, using paramater file: " << paramFile);
165 if (paramFile.empty()) B2FATAL(
"Phokhara: The specified param file is empty!");
166 phokhara_set_parameter_file(paramFile.c_str());
176 double Phokhara::generateEvent(
MCParticleGraph& mcGraph, ROOT::Math::XYZVector vertex, ROOT::Math::LorentzRotation boost)
181 if (m_ForceMinInvMassHadronsCut) {
183 phokhara(&mode, m_xpar, m_npar);
184 double partMom[4] = {0, 0, 0, 0};
185 for (
int iPart = 0; iPart < belle2_phokhara_particles.bnhad; ++iPart) {
186 for (
int j = 0; j < 4; ++j)
187 partMom[j] += belle2_phokhara_particles.bp2[j][iPart];
189 double m2 = partMom[0] * partMom[0] - partMom[1] * partMom[1]
190 - partMom[2] * partMom[2] - partMom[3] * partMom[3];
191 if (m2 > m_MinInvMassHadrons)
195 phokhara(&mode, m_xpar, m_npar);
198 double eMom[4] = {belle2_phokhara_particles.bp1[1], belle2_phokhara_particles.bp1[2], belle2_phokhara_particles.bp1[3], belle2_phokhara_particles.bp1[0]};
199 double pMom[4] = {belle2_phokhara_particles.bq1[1], belle2_phokhara_particles.bq1[2], belle2_phokhara_particles.bq1[3], belle2_phokhara_particles.bq1[0]};
201 storeParticle(mcGraph, eMom, 11, vertex, boost,
false,
true);
202 storeParticle(mcGraph, pMom, -11, vertex, boost,
false,
true);
205 for (
int iPhot = 0; iPhot < belle2_phokhara_particles.bnphot; ++iPhot) {
206 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]};
207 storeParticle(mcGraph, photMom, 22, vertex, boost,
false,
false);
211 if ((m_finalState == 0) && m_replaceMuonsByVirtualPhoton) {
212 if (belle2_phokhara_particles.bnhad != 2)
213 B2FATAL(
"Number of particles generated by PHOKHARA does not match the "
214 "requested final state (mu+ mu-).");
215 double partMom[4] = {belle2_phokhara_particles.bp2[1][0] + belle2_phokhara_particles.bp2[1][1],
216 belle2_phokhara_particles.bp2[2][0] + belle2_phokhara_particles.bp2[2][1],
217 belle2_phokhara_particles.bp2[3][0] + belle2_phokhara_particles.bp2[3][1],
218 belle2_phokhara_particles.bp2[0][0] + belle2_phokhara_particles.bp2[0][1]
220 storeParticle(mcGraph, partMom, 10022, vertex, boost,
false,
false);
222 for (
int iPart = 0; iPart < belle2_phokhara_particles.bnhad; ++iPart) {
223 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]};
225 storeParticle(mcGraph, partMom, belle2_phokhara_particles.bp2[4][iPart], vertex, boost,
false,
false);
230 if (m_finalState == 9) {
231 int id = 2 + belle2_phokhara_particles.bnphot;
241 daughter1 = &mcGraph[
id + 4];
243 daughter2 = &mcGraph[
id + 5];
246 lambdabar->
removeStatus(MCParticle::c_StableInGenerator);
251 return belle2_phokhara_particles.wgt;
257 void Phokhara::term()
261 phokhara(&mode, m_xpar, m_npar);
284 void Phokhara::applySettings()
290 m_npar[1] = m_nMaxTrials;
291 m_npar[2] = m_nSearchMax;
292 m_npar[3] = m_weighted;
293 m_npar[20] = m_finalState;
297 m_npar[33] = m_IFSNLO;
298 m_npar[34] = m_alpha;
299 m_npar[35] = m_pionff;
300 m_npar[36] = m_pionstructure;
301 m_npar[37] = m_kaonff;
302 m_npar[38] = m_narres;
303 m_npar[39] = m_protonff;
304 m_npar[40] = m_fullNLO;
305 m_npar[50] = m_chi_sw;
307 m_npar[60] = m_weighted;
312 m_xpar[0] = m_cmsEnergy;
313 m_xpar[11] = m_epsilon;
315 m_xpar[15] = m_MinInvMassHadronsGamma;
316 m_xpar[16] = m_MinInvMassHadrons;
317 m_xpar[17] = m_MaxInvMassHadrons;
318 m_xpar[18] = m_MinEnergyGamma;
320 m_xpar[20] = m_ScatteringAngleRangePhoton.first;
321 m_xpar[21] = m_ScatteringAngleRangePhoton.second;
322 m_xpar[22] = m_ScatteringAngleRangeFinalStates.first;
323 m_xpar[23] = m_ScatteringAngleRangeFinalStates.second;
325 m_xpar[30] = m_beamres;
328 phokhara(&mode, m_xpar, m_npar);
332 void Phokhara::storeParticle(
MCParticleGraph& mcGraph,
const double* mom,
int pdg, ROOT::Math::XYZVector vertex,
333 ROOT::Math::LorentzRotation boost,
bool isVirtual,
bool isInitial)
340 part.addStatus(MCParticle::c_PrimaryParticle);
343 part.addStatus(MCParticle::c_StableInGenerator);
346 part.addStatus(MCParticle::c_IsVirtual);
347 }
else if (isInitial) {
348 part.addStatus(MCParticle::c_Initial);
353 part.addStatus(MCParticle::c_IsISRPhoton);
354 part.addStatus(MCParticle::c_IsFSRPhoton);
358 part.setFirstDaughter(0);
359 part.setLastDaughter(0);
360 part.setMomentum(ROOT::Math::XYZVector(mom[0], mom[1], mom[2]));
362 if ((m_finalState == 0) && m_replaceMuonsByVirtualPhoton && (pdg == 10022))
363 part.setMass(
sqrt(mom[3] * mom[3] - mom[0] * mom[0] - mom[1] * mom[1] -
366 part.setMass(TDatabasePDG::Instance()->GetParticle(pdg)->Mass());
367 part.setEnergy(mom[3]);
370 ROOT::Math::PxPyPzEVector p4 = part.get4Vector();
376 ROOT::Math::XYZVector v3 = part.getProductionVertex();
378 part.setProductionVertex(v3);
379 part.setValidVertex(
true);
Class to represent Particle data in graph.
void comesFrom(GraphParticle &mother)
Tells the graph that this particle is a decay product of mother.
Class to build, validate and sort a particle decay chain.
void removeStatus(unsigned short int bitmask)
Remove bitmask from current status.
double sqrt(double a)
sqrt for double
GraphParticle & addParticle()
Add new particle to the graph.
Abstract base class for different kinds of events.