11 #include <generators/teegg/Teegg.h>
12 #include <framework/gearbox/Unit.h>
13 #include <framework/logging/Logger.h>
14 #include <framework/dataobjects/EventMetaData.h>
15 #include <analysis/dataobjects/EventExtraInfo.h>
17 #include <framework/datastore/StoreObjPtr.h>
19 #include <TDatabasePDG.h>
20 #include <TLorentzVector.h>
58 void teegg_rndmarr_(
double* drvec,
int* lengt)
60 for (
int i = 0; i < *lengt; ++i) {
61 double rr = gRandom->Rndm();
66 double teegg_rndm_(
int*)
68 double r = gRandom->Rndm();
73 void teeggm_(
int* mode,
double* xpar,
int* npar);
76 void teegg_warning_generic_(
double* weight,
double* max)
78 B2WARNING(
"TEEGG: Maximum weight " << *max <<
" to small, increase fmax to at least " << *weight);
82 void report_() { B2FATAL(
"Teegg: report_() is not implemented"); }
84 void golife_() { B2FATAL(
"Teegg: golife_() is not implemented"); }
86 void golint_() { B2FATAL(
"Teegg: golint_() is not implemented"); }
91 for (
int i = 0; i < 100; ++i) {
104 void Teegg::setDefaultSettings()
106 m_cmsEnergy = 5.28695 * 2.0 * Unit::GeV;
108 m_pi = 3.1415926535897932384626433832795029;
109 m_conversionFactor = 0.389379660e6;
110 m_alphaQED0 = 1.0 / 137.0359895;
111 m_massElectron = 0.51099906 * Unit::MeV;
115 m_sCONFIG =
"EGAMMA";
125 m_PEGMIN = m_pi / 4.00;
128 m_PHVETO = m_pi / 4.00;
148 void Teegg::initExtraInfo()
151 eventextrainfo.registerInDataStore();
160 void Teegg::generateEvent(
MCParticleGraph& mcGraph, TVector3 vertex, TLorentzRotation boost)
164 teeggm_(&mode, m_xpar, m_npar);
167 storeParticle(mcGraph, momset_.tq2, 11, vertex, boost,
false,
false);
168 storeParticle(mcGraph, momset_.tp2, -11, vertex, boost,
false,
false);
171 for (
int iPhot = 0; iPhot < momset_.tnphot; ++iPhot) {
172 double photMom[4] = {momset_.tphot[0][iPhot], momset_.tphot[1][iPhot], momset_.tphot[2][iPhot], momset_.tphot[3][iPhot]};
173 storeParticle(mcGraph, photMom, 22, vertex, boost,
false,
false);
177 m_t = teeggextra_.tt;
178 m_w2 = teeggextra_.tw2;
179 m_weight = teeggextra_.tweight;
180 m_vp2 = teeggextra_.tvp2;
184 eventMetaDataPtr->setGeneratedWeight(m_weight);
188 if (not eventExtraInfo.isValid())
189 eventExtraInfo.create();
190 if (eventExtraInfo->hasExtraInfo(
"GeneratorVP2")) {
191 B2WARNING(
"EventExtraInfo with given name is already set! I won't set it again!");
193 eventExtraInfo->addExtraInfo(
"GeneratorVP2", m_vp2);
201 teeggm_(&mode, m_xpar, m_npar);
203 B2RESULT(
"Cross-section (nb) = " << teeggresults_.rescross / 1.e3 <<
" +/- " << teeggresults_.rescrosserr / 1.e3 <<
"");
204 B2RESULT(
"Events (unweighted) = " << teeggresults_.resngen);
205 B2RESULT(
"Trials = " << teeggresults_.resntrials);
206 B2RESULT(
"Efficiency = " << 100.*teeggresults_.reseff <<
" %");
207 B2RESULT(
"Average Q2 = " << teeggresults_.avgq2);
215 void Teegg::applySettings()
220 m_npar[0] = m_UNWGHT;
222 if (m_sRADCOR ==
"NONE") m_RADCOR = 3;
223 else if (m_sRADCOR ==
"SOFT") m_RADCOR = 2;
224 else if (m_sRADCOR ==
"HARD") m_RADCOR = 1;
226 m_npar[1] = m_RADCOR;
228 if (m_sCONFIG ==
"EGAMMA") m_CONFIG = 11;
229 else if (m_sCONFIG ==
"ETRON") m_CONFIG = 12;
230 else if (m_sCONFIG ==
"GAMMA") m_CONFIG = 13;
231 else if (m_sCONFIG ==
"GAMMAE") m_CONFIG = 14;
233 m_npar[2] = m_CONFIG;
235 if (m_sMATRIX ==
"BK") m_MATRIX = 21;
236 else if (m_sMATRIX ==
"BKM2") m_MATRIX = 22;
237 else if (m_sMATRIX ==
"TCHAN") m_MATRIX = 23;
238 else if (m_sMATRIX ==
"EPA") m_MATRIX = 24;
240 m_npar[3] = m_MATRIX;
242 if (m_sMTRXGG ==
"EPADC") m_MTRXGG = 31;
243 else if (m_sMTRXGG ==
"BEEGG") m_MTRXGG = 32;
244 else if (m_sMTRXGG ==
"MEEGG") m_MTRXGG = 33;
245 else if (m_sMTRXGG ==
"HEEGG") m_MTRXGG = 34;
247 m_npar[4] = m_MTRXGG;
249 if (m_sVACPOL ==
"OFF") m_VACPOL = 41;
250 else if (m_sVACPOL ==
"HLMNT") m_VACPOL = 42;
251 else if (m_sVACPOL ==
"NSK") m_VACPOL = 43;
253 m_npar[5] = m_VACPOL;
258 double toRad = TMath::DegToRad();
259 m_xpar[0] = m_TEVETO * toRad;
260 m_xpar[1] = m_TEMIN * toRad;
261 m_xpar[2] = m_TGMIN * toRad;
262 m_xpar[3] = m_TGVETO * toRad;
265 m_xpar[6] = m_PEGMIN * toRad;
266 m_xpar[7] = m_EEVETO;
267 m_xpar[8] = m_EGVETO;
268 m_xpar[9] = m_PHVETO * toRad;
269 m_xpar[10] = m_CUTOFF;
271 m_xpar[12] = m_FRAPHI;
272 m_xpar[13] = m_EPSPHI;
273 m_xpar[14] = m_WGHT1M;
274 m_xpar[15] = m_WGHTMX;
275 m_xpar[30] = m_cmsEnergy;
278 teeggm_(&mode, m_xpar, m_npar);
282 void Teegg::storeParticle(
MCParticleGraph& mcGraph,
const double* mom,
int pdg, TVector3 vertex, TLorentzRotation boost,
283 bool isVirtual,
bool isInitial)
288 part.addStatus(MCParticle::c_IsVirtual);
289 }
else if (isInitial) {
290 part.addStatus(MCParticle::c_Initial);
294 part.addStatus(MCParticle::c_PrimaryParticle);
297 part.addStatus(MCParticle::c_StableInGenerator);
301 part.addStatus(MCParticleGraph::GraphParticle::c_IsISRPhoton);
302 part.addStatus(MCParticleGraph::GraphParticle::c_IsFSRPhoton);
306 part.setFirstDaughter(0);
307 part.setLastDaughter(0);
308 part.setMomentum(TVector3(mom[0], mom[1], mom[2]));
309 part.setMass(TDatabasePDG::Instance()->GetParticle(pdg)->Mass());
310 part.setEnergy(mom[3]);
313 TLorentzVector p4 = part.get4Vector();
314 p4.SetPz(-1.0 * p4.Pz());
320 TVector3 v3 = part.getProductionVertex();
322 part.setProductionVertex(v3);
323 part.setValidVertex(
true);