GENIEGenerator
Loading...
Searching...
No Matches
Pythia6Hadro2019.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 <c.andreopoulos \at cern.ch>
7 University of Liverpool
8*/
9//____________________________________________________________________________
10
11#include <RVersion.h>
12#include <TClonesArray.h>
13
27
28#ifdef __GENIE_PYTHIA6_ENABLED__
29#if ROOT_VERSION_CODE >= ROOT_VERSION(5,15,6)
30#include <TMCParticle.h>
31#else
32#include <TMCParticle6.h>
33#endif
34#endif // __GENIE_PYTHIA6_ENABLED__
35
36using namespace genie;
37using namespace genie::constants;
38
39// the actual PYTHIA call
40extern "C" void py2ent_(int *, int *, int *, double *);
41
42//____________________________________________________________________________
44PythiaBaseHadro2019("genie::Pythia6Hadro2019")
45{
46 this->Initialize();
47}
48//____________________________________________________________________________
50PythiaBaseHadro2019("genie::Pythia6Hadro2019", config)
51{
52 this->Initialize();
53}
54//____________________________________________________________________________
59//____________________________________________________________________________
61 #ifdef __GENIE_PYTHIA6_ENABLED__
62 event // avoid unused variable warning if PYTHIA6 is not enabled
63 #endif
64) const
65{
66#ifdef __GENIE_PYTHIA6_ENABLED__
68#else
69 LOG("Pythia6Had", pFATAL)
70 << "Calling GENIE/PYTHIA6 hadronization modules without enabling PYTHIA6";
71 gAbortingInErr = true;
72 std::exit(1);
73#endif
74}
75//____________________________________________________________________________
77#ifdef __GENIE_PYTHIA6_ENABLED__
78 event // avoid unused variable warning if PYTHIA6 is not enabled
79#endif
80) const
81{
82#ifdef __GENIE_PYTHIA6_ENABLED__
83
84 LOG("Pythia6Had", pNOTICE) << "Running PYTHIA6 hadronizer";
85
86 const Interaction * interaction = event->Summary();
87 const Kinematics & kinematics = interaction->Kine();
88 double W = kinematics.W();
89
90 LOG("Pythia6Had", pNOTICE)
91 << "Fragmentation: "
92 << "q = " << fLeadingQuark << ", qq = " << fRemnantDiquark
93 << ", W = " << W;
94
95 // Hadronize
96 int ip = 0;
97 py2ent_(&ip, &fLeadingQuark, &fRemnantDiquark, &W); // hadronizer
98
99 // Get LUJETS record
100 fPythia->GetPrimaries();
101 TClonesArray * pythia_particles =
102 (TClonesArray *) fPythia->ImportParticles("All");
103
104 // Copy PYTHIA container to a new TClonesArray so as to transfer ownership
105 // of the container and of its elements to the calling method
106
107 int np = pythia_particles->GetEntries();
108 assert(np>0);
109
110 // Hadronic 4vec
111 TLorentzVector p4Had = kinematics.HadSystP4();
112
113 // Vector defining rotation from LAB to LAB' (z:= \vec{phad})
114 TVector3 unitvq = p4Had.Vect().Unit();
115
116 // Boost velocity LAB' -> HCM
117 TVector3 beta(0,0,p4Had.P()/p4Had.Energy());
118
119 // Check target and decide appropriate status code for f/s particles
120 bool is_nucleus = interaction->InitState().Tgt().IsNucleus();
122
123 // Get the index of the mother of the hadronic system
124 int mom = event->FinalStateHadronicSystemPosition();
125 assert(mom!=-1);
126
127 // Get the neutrino vertex position (all hadrons positions set to this point)
128 GHepParticle * neutrino = event->Probe();
129 const TLorentzVector & vtx = *(neutrino->X4());
130
131 // Loop over PYTHIA6 event particles and copy relevant entries
132 unsigned int i = 0;
133 TMCParticle * p = 0;
134 TIter particle_iter(pythia_particles);
135 while( (p = (TMCParticle *) particle_iter.Next()) ) {
136
137 int particle_pdg_code = p->GetKF();
138 int pythia_particle_status = p->GetKS();
139
140 // Sanity check
141 if(pythia_particle_status == 1) {
142 if( pdg::IsQuark (particle_pdg_code) ||
143 pdg::IsDiQuark(particle_pdg_code) )
144 {
145 LOG("Pythia6Had", pERROR)
146 << "Hadronization failed! Bare quarks appear in final state!";
147 return false;
148 }
149 }
150
151 // The fragmentation products are generated in the hadronic CM frame
152 // where the z>0 axis is the \vec{phad} direction. For each particle
153 // returned by the hadronizer:
154 // - boost it back to LAB' frame {z:=\vec{phad}} / doesn't affect pT
155 // - rotate its 3-momentum from LAB' to LAB
156 TLorentzVector p4o(p->GetPx(), p->GetPy(), p->GetPz(), p->GetEnergy());
157 p4o.Boost(beta);
158 TVector3 p3 = p4o.Vect();
159 p3.RotateUz(unitvq);
160 TLorentzVector p4(p3,p4o.Energy());
161
162 // Set the proper GENIE status according to a number of things:
163 // interaction on a nucleus or nucleon, particle type
164 GHepStatus_t ist = (pythia_particle_status == 1) ?
166 // Handle gammas, and leptons that might come from internal pythia decays
167 // mark them as final state particles
168 bool is_gamma = (particle_pdg_code == kPdgGamma);
169 bool is_nu = pdg::IsNeutralLepton(particle_pdg_code);
170 bool is_lchg = pdg::IsChargedLepton(particle_pdg_code);
171 bool not_hadr = is_gamma || is_nu || is_lchg;
172 if(not_hadr) { ist = kIStStableFinalState; }
173
174 // Set mother/daugher indices
175 int mother1 = mom + p->GetParent();
176 int mother2 = -1;
177 int daughter1 = (p->GetFirstChild() <= 0 ) ? -1 : mom + p->GetFirstChild();
178 int daughter2 = (p->GetLastChild() <= 0 ) ? -1 : mom + p->GetLastChild();
179
180 // Create GHepParticle
181 GHepParticle particle = GHepParticle(
182 particle_pdg_code, // pdg
183 ist, // status
184 mother1, // first parent
185 mother2, // second parent
186 daughter1, // first daughter
187 daughter2, // second daughter
188 p4.Px(), // px
189 p4.Py(), // py
190 p4.Pz(), // pz
191 p4.Energy(), // e
192 vtx.X(), // x
193 vtx.Y(), // y
194 vtx.Z(), // z
195 vtx.T() // t
196 );
197
198 LOG("Pythia6Had", pDEBUG)
199 << "Adding final state particle pdgc = " << particle.Pdg()
200 << " with status = " << particle.Status();
201
202 // Insert the particle in the list
203 event->AddParticle(particle);
204 }
205 return true;
206
207#else
208 return false;
209#endif // __GENIE_PYTHIA6_ENABLED__
210}
211//____________________________________________________________________________
213{
214#ifdef __GENIE_PYTHIA6_ENABLED__
215 fOriDecayFlag_pi0 = (fPythia->GetMDCY(fPythia->Pycomp(kPdgPi0), 1) == 1);
216 fOriDecayFlag_K0 = (fPythia->GetMDCY(fPythia->Pycomp(kPdgK0), 1) == 1);
217 fOriDecayFlag_K0b = (fPythia->GetMDCY(fPythia->Pycomp(kPdgAntiK0), 1) == 1);
218 fOriDecayFlag_L0 = (fPythia->GetMDCY(fPythia->Pycomp(kPdgLambda), 1) == 1);
219 fOriDecayFlag_L0b = (fPythia->GetMDCY(fPythia->Pycomp(kPdgAntiLambda), 1) == 1);
220 fOriDecayFlag_Dm = (fPythia->GetMDCY(fPythia->Pycomp(kPdgP33m1232_DeltaM), 1) == 1);
221 fOriDecayFlag_D0 = (fPythia->GetMDCY(fPythia->Pycomp(kPdgP33m1232_Delta0), 1) == 1);
222 fOriDecayFlag_Dp = (fPythia->GetMDCY(fPythia->Pycomp(kPdgP33m1232_DeltaP), 1) == 1);
223 fOriDecayFlag_Dpp = (fPythia->GetMDCY(fPythia->Pycomp(kPdgP33m1232_DeltaPP), 1) == 1);
224
225#ifdef __GENIE_LOW_LEVEL_MESG_ENABLED__
226 LOG("Pythia6Had", pDEBUG)
227 << "Original PYTHIA6 decay flags:"
228 << "\n pi0 = " << fOriDecayFlag_pi0
229 << "\n K0 = " << fOriDecayFlag_K0
230 << "\n \bar{K0} = " << fOriDecayFlag_K0b
231 << "\n Lambda = " << fOriDecayFlag_L0
232 << "\n \bar{Lambda0} = " << fOriDecayFlag_L0b
233 << "\n D- = " << fOriDecayFlag_Dm
234 << "\n D0 = " << fOriDecayFlag_D0
235 << "\n D+ = " << fOriDecayFlag_Dp
236 << "\n D++ = " << fOriDecayFlag_Dpp;
237#endif
238
239#endif // __GENIE_PYTHIA6_ENABLED__
240}
241//____________________________________________________________________________
243{
244#ifdef __GENIE_PYTHIA6_ENABLED__
245
246 fPythia->SetMDCY(fPythia->Pycomp(kPdgPi0),
247 1, (fReqDecayFlag_pi0) ? 1 : 0);
248 fPythia->SetMDCY(fPythia->Pycomp(kPdgK0),
249 1, (fReqDecayFlag_K0) ? 1 : 0);
250 fPythia->SetMDCY(fPythia->Pycomp(kPdgAntiK0),
251 1, (fReqDecayFlag_K0b) ? 1 : 0);
252 fPythia->SetMDCY(fPythia->Pycomp(kPdgLambda),
253 1, (fReqDecayFlag_L0) ? 1 : 0);
254 fPythia->SetMDCY(fPythia->Pycomp(kPdgAntiLambda),
255 1, (fReqDecayFlag_L0b) ? 1 : 0);
256 fPythia->SetMDCY(fPythia->Pycomp(kPdgP33m1232_DeltaM),
257 1, (fReqDecayFlag_Dm) ? 1 : 0);
258 fPythia->SetMDCY(fPythia->Pycomp(kPdgP33m1232_Delta0),
259 1, (fReqDecayFlag_D0) ? 1 : 0);
260 fPythia->SetMDCY(fPythia->Pycomp(kPdgP33m1232_DeltaP),
261 1, (fReqDecayFlag_Dp) ? 1 : 0);
262 fPythia->SetMDCY(fPythia->Pycomp(kPdgP33m1232_DeltaPP),
263 1, (fReqDecayFlag_Dpp) ? 1 : 0);
264
265#endif // __GENIE_PYTHIA6_ENABLED__
266}
267//____________________________________________________________________________
269{
270#ifdef __GENIE_PYTHIA6_ENABLED__
271
272fPythia->SetMDCY(fPythia->Pycomp(kPdgPi0),
273 1, (fOriDecayFlag_pi0) ? 1 : 0);
274fPythia->SetMDCY(fPythia->Pycomp(kPdgK0),
275 1, (fOriDecayFlag_K0) ? 1 : 0);
276fPythia->SetMDCY(fPythia->Pycomp(kPdgAntiK0),
277 1, (fOriDecayFlag_K0b) ? 1 : 0);
278fPythia->SetMDCY(fPythia->Pycomp(kPdgLambda),
279 1, (fOriDecayFlag_L0) ? 1 : 0);
280fPythia->SetMDCY(fPythia->Pycomp(kPdgAntiLambda),
281 1, (fOriDecayFlag_L0b) ? 1 : 0);
282fPythia->SetMDCY(fPythia->Pycomp(kPdgP33m1232_DeltaM),
283 1, (fOriDecayFlag_Dm) ? 1 : 0);
284fPythia->SetMDCY(fPythia->Pycomp(kPdgP33m1232_Delta0),
285 1, (fOriDecayFlag_D0) ? 1 : 0);
286fPythia->SetMDCY(fPythia->Pycomp(kPdgP33m1232_DeltaP),
287 1, (fOriDecayFlag_Dp) ? 1 : 0);
288fPythia->SetMDCY(fPythia->Pycomp(kPdgP33m1232_DeltaPP),
289 1, (fOriDecayFlag_Dpp) ? 1 : 0);
290
291#endif // __GENIE_PYTHIA6_ENABLED__
292}
293//____________________________________________________________________________
295{
296 Algorithm::Configure(config);
297 this->LoadConfig();
298}
299//____________________________________________________________________________
301{
302 Algorithm::Configure(config);
303 this->LoadConfig();
304}
305//____________________________________________________________________________
307{
309
310#ifdef __GENIE_PYTHIA6_ENABLED__
311 fPythia->SetPARJ(2, fSSBarSuppression );
312 fPythia->SetPARJ(21, fGaussianPt2 );
313 fPythia->SetPARJ(23, fNonGaussianPt2Tail );
314 fPythia->SetPARJ(33, fRemainingECutoff );
315 fPythia->SetPARJ(1, fDiQuarkSuppression );
316 fPythia->SetPARJ(11, fLightVMesonSuppression );
317 fPythia->SetPARJ(12, fSVMesonSuppression );
318 fPythia->SetPARJ(41, fLunda );
319 fPythia->SetPARJ(42, fLundb );
320 fPythia->SetPARJ(45, fLundaDiq );
321#endif
322
323 LOG("Pythia6Had", pDEBUG) << this->GetConfig() ;
324}
325//____________________________________________________________________________
327{
329#ifdef __GENIE_PYTHIA6_ENABLED__
330 fPythia = TPythia6::Instance();
331 // sync GENIE/PYTHIA6 seed number
332 // PYTHIA6 is a singleton, so do this from RandomGen for all
333 // GENIE algorithms that use PYTHIA6
335#endif
336}
337//____________________________________________________________________________
#define pNOTICE
Definition Messenger.h:61
#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.
void py2ent_(int *, int *, int *, double *)
virtual const Registry & GetConfig(void) const
virtual void Configure(const Registry &config)
Definition Algorithm.cxx:62
STDHEP-like event record entry that can fit a particle or a nucleus.
int Pdg(void) const
const TLorentzVector * X4(void) const
GHepStatus_t Status(void) const
GENIE's GHEP MC event record.
Definition GHepRecord.h:45
const Target & Tgt(void) const
Summary information for an interaction.
Definition Interaction.h:56
const Kinematics & Kine(void) const
Definition Interaction.h:71
const InitialState & InitState(void) const
Definition Interaction.h:69
Generated/set kinematical variables for an event.
Definition Kinematics.h:39
const TLorentzVector & HadSystP4(void) const
Definition Kinematics.h:66
double W(bool selected=false) const
void Configure(const Registry &config)
void SetDesiredDecayFlags(void) const
void RestoreOriginalDecayFlags(void) const
bool Hadronize(GHepRecord *event) const
void ProcessEventRecord(GHepRecord *event) const
void CopyOriginalDecayFlags(void) const
double fLundb
Lund b parameter.
double fSSBarSuppression
ssbar suppression
double fNonGaussianPt2Tail
non gaussian pt2 tail parameterization
double fDiQuarkSuppression
di-quark suppression parameter
double fLundaDiq
adjustment of Lund a for di-quark
double fGaussianPt2
gaussian pt2 distribution width
double fRemainingECutoff
remaining E cutoff stopping fragmentation
double fLunda
Lund a parameter.
double fSVMesonSuppression
strange vector meson suppression
virtual void ProcessEventRecord(GHepRecord *event) const
double fLightVMesonSuppression
light vector meson suppression
static RandomGen * Instance()
Access instance.
Definition RandomGen.cxx:74
A registry. Provides the container for algorithm configuration parameters.
Definition Registry.h:65
bool IsNucleus(void) const
Definition Target.cxx:272
Basic 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
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