Belle II Software development
BHWide.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include <generators/bhwide/BHWide.h>
10#include <framework/gearbox/Unit.h>
11
12#include <TDatabasePDG.h>
13#include <Math/Vector4D.h>
14#include <TRandom.h>
15
16using namespace std;
17using namespace Belle2;
18
19//Declaration of the BHWide FORTRAN methods and common blocks.
20extern "C" {
21
22 extern struct {
23 double p1[4];
24 double q1[4];
25 double p2[4];
26 double q2[4];
27 double phit[4][100];
28 int nphot;
29 } momset_;
30
31 void bhwide_(int* mode, double* xpar, int* npar);
32 void glimit_(int* number);
33
39 void varran_(double* drvec, const int* lengt)
40 {
41 for (int i = 0; i < *lengt; ++i) {
42 do {
43 //BHWide does not want 1 for some reason, at least they are rejected in
44 //the original VARRAN subroutine so we do it here as well
45 drvec[i] = gRandom->Rndm();
46 } while (drvec[i] >= 1.0);
47 }
48 }
53 void ranmar_(double* rvec)
54 {
55 *rvec = gRandom->Rndm();
56 }
57}
58
59
61{
62 for (int i = 0; i < 100; ++i) {
63 m_npar[i] = 0;
64 m_xpar[i] = 0.0;
65 }
66
67 m_crossSection = 0.;
69
71}
72
73
75{
76
77}
78
79
81{
82
83 m_zContribution = true;
85 m_weighted = false;
87 m_weakCorrections = true;
91
92 m_cmsEnergy = 10.58 * Unit::GeV;
93 m_ScatteringAngleRangePositron = make_pair(17.0, 150.0); //in [deg]
94 m_ScatteringAngleRangeElectron = make_pair(17.0, 150.0); //in [deg]
97 m_maxAcollinearity = 10.0;
98 m_infCutCMSEnergy = 1e-5;
100 m_massZ = 91.1882 * Unit::GeV;
101 m_widthZ = 2.4952;
102 m_sinW2 = 0.22225;
103 m_massTop = 174.3 * Unit::GeV;
104 m_massHiggs = 115.0 * Unit::GeV;
105}
106
107
109{
110 int number = 50000;
111 glimit_(&number);
113}
114
115
116void BHWide::generateEvent(MCParticleGraph& mcGraph, ROOT::Math::XYZVector vertex, ROOT::Math::LorentzRotation boost)
117{
118 //Generate event
119 int mode = 0;
120 bhwide_(&mode, m_xpar, m_npar);
121
122 //Store the initial particles as virtual particles into the MCParticleGraph
123 storeParticle(mcGraph, momset_.q1, 11, vertex, boost, true);
124 storeParticle(mcGraph, momset_.p1, -11, vertex, boost, true);
125
126 //Store the final state positron and electron into the MCParticleGraph
127 storeParticle(mcGraph, momset_.q2, 11, vertex, boost);
128 storeParticle(mcGraph, momset_.p2, -11, vertex, boost);
129
130 //Store the real photons into the MCParticleGraph
131 for (int iPhot = 0; iPhot < momset_.nphot; ++iPhot) {
132 double photMom[4] = {momset_.phit[0][iPhot], momset_.phit[1][iPhot], momset_.phit[2][iPhot], momset_.phit[3][iPhot]};
133 storeParticle(mcGraph, photMom, 22, vertex, boost);
134 }
135}
136
137
139{
140 int mode = 2;
141 bhwide_(&mode, m_xpar, m_npar);
142
143 //Get the cross section
146}
147
148//=========================================================================
149// Protected methods
150//=========================================================================
151
153{
154 //--------------------
155 // Integer parameters
156 //--------------------
157 int keyZof;
158 if (m_zContribution) keyZof = 0;
159 else keyZof = 1;
160 m_npar[0] = (1000 * keyZof) + (100 * m_channel) + (10 * m_weighted) + m_randomGenerator;
162
163 //--------------------
164 // Double parameters
165 //--------------------
166 m_xpar[0] = m_cmsEnergy;
176 m_xpar[10] = m_massZ;
177 m_xpar[11] = m_widthZ;
178 m_xpar[12] = m_sinW2;
179 m_xpar[13] = m_massTop;
180 m_xpar[14] = m_massHiggs;
181
182 int mode = -1;
183 bhwide_(&mode, m_xpar, m_npar);
184}
185
186
187void BHWide::storeParticle(MCParticleGraph& mcGraph, const double* mom, int pdg, ROOT::Math::XYZVector vertex,
188 ROOT::Math::LorentzRotation boost,
189 bool isVirtual, bool isInitial)
190{
191 // //Create particle
192 //MCParticleGraph::GraphParticle& part = mcGraph.addParticle();
193 //if (!isVirtual) {
194 // part.setStatus(MCParticle::c_PrimaryParticle);
195 //} else {
196 // part.setStatus(MCParticle::c_IsVirtual);
197 //}
198 //Create particle
199 // RG 6/25/14 Add new flag for ISR "c_Initial"
201 if (isVirtual) {
203 } else if (isInitial) {
205 }
206
207 // every particle from a generator is primary
209
210 // all particles produced by BHWIDE are stable
212
213 // all photons from BHWIDE are ISR or FSR
214 if (pdg == 22 && !isVirtual) {
217 }
218
219 part.setPDG(pdg);
220 part.setFirstDaughter(0);
221 part.setLastDaughter(0);
222 part.setMomentum(ROOT::Math::XYZVector(mom[0], mom[1], mom[2]));
223 part.setMass(TDatabasePDG::Instance()->GetParticle(pdg)->Mass());
224 part.setEnergy(mom[3]);
225
226 //boost
227 ROOT::Math::PxPyPzEVector p4 = part.get4Vector();
228 p4.SetPz(-1.0 * p4.Pz()); //BHWIDE uses other direction convention
229 p4 = boost * p4;
230 part.set4Vector(p4);
231
232 //set vertex
233 if (!isInitial) {
234 ROOT::Math::XYZVector v3 = part.getProductionVertex();
235 v3 = v3 + vertex;
236 part.setProductionVertex(v3);
237 part.setValidVertex(true);
238 }
239}
@ EC_ALIBABA
ElectroWeak Corr.
Definition: BHWide.h:51
void init()
Initializes the generator.
Definition: BHWide.cc:108
void generateEvent(MCParticleGraph &mcGraph, ROOT::Math::XYZVector vertex, ROOT::Math::LorentzRotation boost)
Generates one single event.
Definition: BHWide.cc:116
@ HM_CALKUL
from CALKUL, Nucl.
Definition: BHWide.h:57
double m_maxAcollinearity
Maximum acollinearity [deg] of final state e+e-.
Definition: BHWide.h:230
std::pair< double, double > m_ScatteringAngleRangePositron
Min and Max value for the scattering angle [deg] of the positron.
Definition: BHWide.h:225
@ CH_BOTH
both s and t-channels + interferences.
Definition: BHWide.h:37
int m_npar[100]
Integer parameters for BHWide.
Definition: BHWide.h:261
double m_minEnergyFinalStateElc
Minimum energy [GeV] for final state electron.
Definition: BHWide.h:229
BHWide()
Constructor.
Definition: BHWide.cc:60
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.
Definition: BHWide.cc:187
void setDefaultSettings()
Sets the default settings for the BhWide Fortran generator.
Definition: BHWide.cc:80
double m_sinW2
sin^2(theta_W) (may be recalculated by EW library).
Definition: BHWide.h:236
Channel m_channel
Channel choice.
Definition: BHWide.h:216
double m_crossSection
The cross section of the generated bhabha scattering events.
Definition: BHWide.h:240
PhotonVacPolarization m_photonVacPol
Photon vacuum polarization switch.
Definition: BHWide.h:222
@ PP_BURKHARDT
Burkhardt and Pietrzyk 1995 (Moriond).
Definition: BHWide.h:65
double m_cmsEnergy
CMS Energy = 2*Ebeam [GeV].
Definition: BHWide.h:224
RandomGenerator m_randomGenerator
Type of random number generator.
Definition: BHWide.h:218
std::pair< double, double > m_ScatteringAngleRangeElectron
Min and Max value for the scattering angle [deg] of the electron.
Definition: BHWide.h:226
EWCorrectionLib m_ewCorrectionLib
Option for ElectroWeak Corrections Library.
Definition: BHWide.h:220
bool m_weighted
Switch for constant, variable weight.
Definition: BHWide.h:217
double m_widthZ
Z width [GeV] (may be recalculated by EW library).
Definition: BHWide.h:235
void term()
Terminates the generator.
Definition: BHWide.cc:138
bool m_weakCorrections
Switching ON/OFF weak corrections.
Definition: BHWide.h:219
double m_maxRejectionWeight
Maximum Weight for rejection (if <= 0, it is reset inside the program).
Definition: BHWide.h:232
bool m_zContribution
Z-contribution ON/OFF.
Definition: BHWide.h:215
double m_infCutCMSEnergy
Dimensionless infrared cut on CMS energy of soft photons, ( E_phot > CMSENE*EPSCMS/2 ).
Definition: BHWide.h:231
double m_massTop
top quark mass [GeV].
Definition: BHWide.h:237
double m_massHiggs
Higgs mass [GeV].
Definition: BHWide.h:238
double m_xpar[100]
Double parameters for BHWide.
Definition: BHWide.h:262
double m_crossSectionError
The error on the cross section of the generated bhabha scattering events.
Definition: BHWide.h:241
double m_massZ
Z mass [GeV].
Definition: BHWide.h:234
double m_minEnergyFinalStatePos
Minimum energy [GeV] for final state positron.
Definition: BHWide.h:228
~BHWide()
Destrucotr.
Definition: BHWide.cc:74
void applySettings()
Apply the settings to the internal Fortran generator.
Definition: BHWide.cc:152
HardBremsModel m_hardBremsModel
type of MODEL subprogram and QED matrix element for hard bremsstrahlung.
Definition: BHWide.h:221
@ RG_RANMAR
Ranmar generator.
Definition: BHWide.h:44
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_IsFSRPhoton
bit 7: Particle is from finial state radiation
Definition: MCParticle.h:61
@ 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
@ c_StableInGenerator
bit 1: Particle is stable, i.e., not decaying in the generator.
Definition: MCParticle.h:49
@ c_IsISRPhoton
bit 6: Particle is from initial state radiation
Definition: MCParticle.h:59
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 GeV
Standard of [energy, momentum, mass].
Definition: Unit.h:51
GraphParticle & addParticle()
Add new particle to the graph.
Abstract base class for different kinds of events.
STL namespace.