GENIEGenerator
Loading...
Searching...
No Matches
AGCharmPythia8Hadro2023.cxx
Go to the documentation of this file.
1//____________________________________________________________________________
2/*
3 Copyright (c) 2003-2025, The GENIE Collaboration
4 For the full text of the license visit http://copyright.genie-mc.org
5
6 Costas Andreopoulos <constantinos.andreopoulos \at cern.ch>
7 University of Liverpool & STFC Rutherford Appleton Laboratory
8
9 Changes required to implement the GENIE Boosted Dark Matter module
10 were installed by Josh Berger (Univ. of Wisconsin)
11*/
12//____________________________________________________________________________
13
14#include <RVersion.h>
15#include <TVector3.h>
16#include <TF1.h>
17#include <TROOT.h>
18
39
40using namespace genie;
41using namespace genie::constants;
42using namespace genie::controls;
43
44//____________________________________________________________________________
46AGCharmPythiaBaseHadro2023("genie::AGCharmPythia8Hadro2023")
47{
48 this->Initialize();
49}
50//____________________________________________________________________________
52AGCharmPythiaBaseHadro2023("genie::AGCharmPythia8Hadro2023", config)
53{
54 this->Initialize();
55}
56//____________________________________________________________________________
58{
59#ifdef __GENIE_PYTHIA8_ENABLED__
60
61#endif
62}
63//____________________________________________________________________________
65{
67#ifdef __GENIE_PYTHIA8_ENABLED__
68 Pythia8::Pythia* gPythia = Pythia8Singleton::Instance()->Pythia8();
69
70 gPythia->readString("ProcessLevel:all = off");
71 gPythia->readString("Print:quiet = on");
72
73 // sync GENIE and PYTHIA8 seeds
75 long int seed = rnd->GetSeed();
76 gPythia->readString("Random:setSeed = on");
77 gPythia->settings.mode("Random:seed", seed);
78 LOG("AGCharmPythia8Hadro2023", pINFO)
79 << "PYTHIA8 seed = " << gPythia->settings.mode("Random:seed");
80 gPythia->init();
81
82 fOriDecayFlag_pi0 = false;
83 fOriDecayFlag_K0 = false;
84 fOriDecayFlag_K0b = false;
85 fOriDecayFlag_L0 = false;
86 fOriDecayFlag_L0b = false;
87 fOriDecayFlag_Dm = false;
88 fOriDecayFlag_D0 = false;
89 fOriDecayFlag_Dp = false;
90 fOriDecayFlag_Dpp = false;
91 fReqDecayFlag_pi0 = false;
92 fReqDecayFlag_K0 = false;
93 fReqDecayFlag_K0b = false;
94 fReqDecayFlag_L0 = false;
95 fReqDecayFlag_L0b = false;
96 fReqDecayFlag_Dm = false;
97 fReqDecayFlag_D0 = false;
98 fReqDecayFlag_Dp = false;
99 fReqDecayFlag_Dpp = false;
100
101#else
102 LOG("AGCharmPythia8Hadro2023", pFATAL)
103 << "calling GENIE/PYTHIA8 charm hadronization without enabling PYTHIA8";
104 gAbortingInErr = true;
105 std::exit(1);
106#endif
107
108}
109//____________________________________________________________________________
111{
113 // Set required PYTHIA decay flags
114 fReqDecayFlag_pi0 = false; // don't decay pi0
115 fReqDecayFlag_K0 = false; // don't decay K0
116 fReqDecayFlag_K0b = false; // don't decay \bar{K0}
117 fReqDecayFlag_L0 = false; // don't decay Lambda0
118 fReqDecayFlag_L0b = false; // don't decay \bar{Lambda0}
119 fReqDecayFlag_Dm = true; // decay Delta-
120 fReqDecayFlag_D0 = true; // decay Delta0
121 fReqDecayFlag_Dp = true; // decay Delta+
122 fReqDecayFlag_Dpp = true; // decay Delta++
123}
124//____________________________________________________________________________
125
126bool AGCharmPythia8Hadro2023::HadronizeRemnant (int qrkSyst1, int qrkSyst2,
127 double WR, TLorentzVector p4R,
128 unsigned int& rpos, TClonesArray * particle_list) const
129{
130#ifdef __GENIE_PYTHIA8_ENABLED__
131 Pythia8::Pythia* gPythia = Pythia8Singleton::Instance()->Pythia8();
132
135
136 gPythia->event.reset();
137
138 double m1 = gPythia->particleData.m0(qrkSyst1);
139 double m2 = gPythia->particleData.m0(qrkSyst2);
140
141 LOG("AGCharmPythia8Hadro2023", pINFO) // debug
142 << " qrkSyst1 " << qrkSyst1 << " m1 " << m1
143 << " qrkSyst2 " << qrkSyst2 << " m2 " << m2
144 << " WR " << WR << " p4R " << genie::utils::print::P4AsString(&p4R);
145
146 double pz1cm = 0.5 * Pythia8::sqrtpos(
147 (WR + m1 + m2)*(WR - m1 -m2)*(WR - m1 + m2)*(WR + m1 - m2) ) / WR;
148
149 double pz2cm = - pz1cm;
150 double e1 = sqrt(m1*m1 + pz1cm*pz1cm);
151 double e2 = sqrt(m2*m2 + pz2cm*pz2cm);
152
153 LOG("AGCharmPythia8Hadro2023", pINFO) // debug
154 << " qrkSyst1 pz=" << pz1cm << ", E=" << e1
155 << " qrkSyst2 pz=" << pz2cm << ", E=" << e2;
156
157 // status codes and anti/collor tags must complement each other
158 // id, status, int col, int acol, px,py,pz,E,m,scale=0,pol=9
159 gPythia->event.append(qrkSyst1,23,101, 0,0.,0.,pz1cm,e1,m1);
160 gPythia->event.append(qrkSyst2,23, 0,101,0.,0.,pz2cm,e2,m2);
161 //gPythia->event.list();
162
163 LOG("AGCharmPythia8Hadro2023", pDEBUG)
164 << "Generating next PYTHIA8 event";
165 // Generating next pythia8 event
166 gPythia->next();
167
168 //gPythia->event.list();
169 //gPythia->stat();
170
171 // get the LUJETss record
172 Pythia8::Event &fEvent = gPythia->event;
173 int np = fEvent.size();
174 assert(np>0);
175
176 // Vector defining rotation from LAB to LAB' (z:= \vec{p4R}J)
177 TVector3 unitvq = p4R.Vect().Unit();
178
179 // Boost velocity LAB' -> HCM
180 TVector3 beta(0,0,p4R.P()/p4R.Energy());
181
182 GHepStatus_t istfin = kIStHadronInTheNucleus; /// should be testing on is_nucleus
183 // from interaction->InitState().Tgt().IsNucleus();
184
185 int mom = -1; // event->FinalStateHadronicSystemPosition();
186 const TLorentzVector vtx(0,0,0,0);
187
188 for (int i=0; i<np; ++i) {
189 if (fEvent[i].id() == 90) continue; // ignore (system) pseudoparticle
190
191 int particle_pdg_code = fEvent[i].id();
192 int pythia_particle_status = fEvent[i].status();
193
194 GHepParticle* bremn = 0; // boosted remnant
195
196 // sanity check
197 if (pythia_particle_status > 0 ) {
198 if ( pdg::IsQuark (particle_pdg_code ) ||
199 pdg::IsDiQuark(particle_pdg_code ) )
200 {
201 LOG("AGCharmPythia8Hadro2023", pERROR)
202 << "Hadronization failed! Bare quarks appear in final state!";
203 return false;
204 }
205 }
206 // copy the initial quark systemcs (satus = -23) and all undecayed particles
207 // ignore particle we asked PYTHIA to decay but record their decay products
208 bool copy = (pythia_particle_status==-23) ||
209 (pythia_particle_status > 0);
210 if (copy) {
211 // the fragmenation products are generated in the remnant hadronic CM frame
212 // where the z>0 asix is the \vec{p4R} direction.
213 // for each particle returned by the hadronizer:
214 // -- boost it back to LAB' frame {z:\vec{p4T}} / doesn't affect pT
215 // -- rotate its 3-momentum from LAB' to LAB
216 TLorentzVector p4o(fEvent[i].px(),fEvent[i].py(),fEvent[i].pz(),fEvent[i].e());
217 p4o.Boost(beta);
218 TVector3 p3 = p4o.Vect();
219 p3.RotateUz(unitvq);
220 TLorentzVector p4(p3,p4o.Energy());
221
222 //!!!!
223 istfin = GHepStatus_t(1);
224
225 // set the proper GENIE status according to a number of things:
226 GHepStatus_t ist = (pythia_particle_status > 0) ?
228
229 // handle gammas, and leptons that might come from internal pythia decay
230 // mark them as final state particles
231 bool is_gamma = (particle_pdg_code == kPdgGamma);
232 bool is_nu = pdg::IsNeutralLepton(particle_pdg_code);
233 bool is_lchg = pdg::IsChargedLepton(particle_pdg_code);
234 bool not_hadr = is_gamma || is_nu || is_lchg;
235 if (not_hadr) { ist = kIStStableFinalState; }
236
237 int mother1 = mom;
238 int mother2 = -1;
239
240 int daughter1 = -1;
241 int daughter2 = -1;
242
243 // create GHepParticle
244
245 bremn = new ((*particle_list)[rpos++]) GHepParticle(
246 particle_pdg_code, // pdg
247 ist, // status
248 mother1, // first parent
249 mother2, // second parent
250 daughter1, // first daughter
251 daughter2, // second daughter
252 p4.Px(), // px
253 p4.Py(), // py
254 p4.Pz(), // pz
255 p4.Energy(), // e
256 vtx.X(), // x
257 vtx.Y(), // y
258 vtx.Z(), // z
259 vtx.T() // t
260 );
261
262 //std::cout << "bremn " << rpos-1 << "||" << *bremn << std::endl;
263
264 } // if (copy)
265 } // loop over particles in pythia event record
266
268
269 return true;
270
271#else
272 LOG("AGCharmPythia8Hadro2023", pFATAL)
273 << "calling GENIE/PYTHIA8 charm hadronization without enabling PYTHIA8"
274 << " qrkSyst " << qrkSyst1 << "," << qrkSyst2 << " WR " << WR;
275 gAbortingInErr = true;
276 std::exit(1);
277#endif
278
279
280}
281
282//____________________________________________________________________________
284{
285#ifdef __GENIE_PYTHIA8_ENABLED__
286 Pythia8::Pythia* gPythia = Pythia8Singleton::Instance()->Pythia8();
287
288 fOriDecayFlag_pi0 = gPythia->particleData.canDecay(kPdgPi0);
289 fOriDecayFlag_K0 = gPythia->particleData.canDecay(kPdgK0);
290 fOriDecayFlag_K0b = gPythia->particleData.canDecay(kPdgAntiK0);
291 fOriDecayFlag_L0 = gPythia->particleData.canDecay(kPdgLambda);
292 fOriDecayFlag_L0b = gPythia->particleData.canDecay(kPdgAntiLambda);
293 fOriDecayFlag_Dm = gPythia->particleData.canDecay(kPdgP33m1232_DeltaM);
294 fOriDecayFlag_D0 = gPythia->particleData.canDecay(kPdgP33m1232_Delta0);
295 fOriDecayFlag_Dp = gPythia->particleData.canDecay(kPdgP33m1232_DeltaP);
296 fOriDecayFlag_Dpp = gPythia->particleData.canDecay(kPdgP33m1232_DeltaPP);
297
298#ifdef __GENIE_LOW_LEVEL_MESG_ENABLED__
299 LOG("Pythia8Had", pDEBUG)
300 << "Original PYTHIA6 decay flags:"
301 << "\n pi0 = " << fOriDecayFlag_pi0
302 << "\n K0 = " << fOriDecayFlag_K0
303 << "\n \bar{K0} = " << fOriDecayFlag_K0b
304 << "\n Lambda = " << fOriDecayFlag_L0
305 << "\n \bar{Lambda0} = " << fOriDecayFlag_L0b
306 << "\n D- = " << fOriDecayFlag_Dm
307 << "\n D0 = " << fOriDecayFlag_D0
308 << "\n D+ = " << fOriDecayFlag_Dp
309 << "\n D++ = " << fOriDecayFlag_Dpp;
310#endif
311
312#endif
313}
314//____________________________________________________________________________
316{
317#ifdef __GENIE_PYTHIA8_ENABLED__
318 Pythia8::Pythia* gPythia = Pythia8Singleton::Instance()->Pythia8();
319
320 gPythia->particleData.mayDecay(kPdgPi0, fReqDecayFlag_pi0 );
321 gPythia->particleData.mayDecay(kPdgK0, fReqDecayFlag_K0 );
322 gPythia->particleData.mayDecay(kPdgAntiK0, fReqDecayFlag_K0b );
323 gPythia->particleData.mayDecay(kPdgLambda, fReqDecayFlag_L0 );
324 gPythia->particleData.mayDecay(kPdgAntiLambda, fReqDecayFlag_L0b );
325 gPythia->particleData.mayDecay(kPdgP33m1232_DeltaM, fReqDecayFlag_Dm );
326 gPythia->particleData.mayDecay(kPdgP33m1232_Delta0, fReqDecayFlag_D0 );
327 gPythia->particleData.mayDecay(kPdgP33m1232_DeltaP, fReqDecayFlag_Dp );
328 gPythia->particleData.mayDecay(kPdgP33m1232_DeltaPP, fReqDecayFlag_Dpp );
329#endif
330}
331//____________________________________________________________________________
333{
334#ifdef __GENIE_PYTHIA8_ENABLED__
335 Pythia8::Pythia* gPythia = Pythia8Singleton::Instance()->Pythia8();
336
337 gPythia->particleData.mayDecay(kPdgPi0, fOriDecayFlag_pi0 );
338 gPythia->particleData.mayDecay(kPdgK0, fOriDecayFlag_K0 );
339 gPythia->particleData.mayDecay(kPdgAntiK0, fOriDecayFlag_K0b );
340 gPythia->particleData.mayDecay(kPdgLambda, fOriDecayFlag_L0 );
341 gPythia->particleData.mayDecay(kPdgAntiLambda, fOriDecayFlag_L0b );
342 gPythia->particleData.mayDecay(kPdgP33m1232_DeltaM, fOriDecayFlag_Dm );
343 gPythia->particleData.mayDecay(kPdgP33m1232_Delta0, fOriDecayFlag_D0 );
344 gPythia->particleData.mayDecay(kPdgP33m1232_DeltaP, fOriDecayFlag_Dp );
345 gPythia->particleData.mayDecay(kPdgP33m1232_DeltaPP, fOriDecayFlag_Dpp );
346#endif
347}
348
349//____________________________________________________________________________
#define pINFO
Definition Messenger.h:62
#define pERROR
Definition Messenger.h:59
#define pFATAL
Definition Messenger.h:56
#define pDEBUG
Definition Messenger.h:63
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE,...
Definition Messenger.h:96
Most commonly used PDG codes. A set of utility functions to handle PDG codes is provided in PDGUtils.
bool HadronizeRemnant(int qrkSyst1, int qrkSyst2, double WR, TLorentzVector p4R, unsigned int &rpos, TClonesArray *particle_list) const
STDHEP-like event record entry that can fit a particle or a nucleus.
static Pythia8Singleton * Instance(void)
A singleton holding random number generator classes. All random number generation in GENIE should tak...
Definition RandomGen.h:29
static RandomGen * Instance()
Access instance.
Definition RandomGen.cxx:74
long int GetSeed(void) const
Definition RandomGen.h:82
const double e
Basic constants.
Misc GENIE control constants.
bool IsQuark(int pdgc)
Definition PDGUtils.cxx:250
bool IsChargedLepton(int pdgc)
Definition PDGUtils.cxx:101
bool IsNeutralLepton(int pdgc)
Definition PDGUtils.cxx:95
bool IsDiQuark(int pdgc)
Definition PDGUtils.cxx:231
string P4AsString(const TLorentzVector *p)
THE MAIN GENIE PROJECT NAMESPACE
Definition AlgCmp.h:25
@ kIStHadronInTheNucleus
Definition GHepStatus.h:37
@ kIStDISPreFragmHadronicState
Definition GHepStatus.h:35
@ kIStStableFinalState
Definition GHepStatus.h:30
bool gAbortingInErr
Definition Messenger.cxx:34
const int kPdgP33m1232_Delta0
Definition PDGCodes.h:105
const int kPdgPi0
Definition PDGCodes.h:160
const int kPdgP33m1232_DeltaPP
Definition PDGCodes.h:107
enum genie::EGHepStatus GHepStatus_t
const int kPdgAntiLambda
Definition PDGCodes.h:86
const int kPdgP33m1232_DeltaM
Definition PDGCodes.h:104
const int kPdgLambda
Definition PDGCodes.h:85
const int kPdgP33m1232_DeltaP
Definition PDGCodes.h:106
const int kPdgGamma
Definition PDGCodes.h:189
const int kPdgAntiK0
Definition PDGCodes.h:175
const int kPdgK0
Definition PDGCodes.h:174