GENIEGenerator
Loading...
Searching...
No Matches
GLRESWdecPythia6.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 Alfonso Garcia <aagarciasoto \at km3net.de>
7 IFIC (Valencia)
8*/
9//____________________________________________________________________________
10
12
13#ifdef __GENIE_PYTHIA6_ENABLED__
14#if ROOT_VERSION_CODE >= ROOT_VERSION(5,15,6)
15#include <TMCParticle.h>
16#else
17#include <TMCParticle6.h>
18#endif
19#endif // __GENIE_PYTHIA6_ENABLED__
20
21//___________________________________________________________________________
23EventRecordVisitorI("genie::GLRESWdecPythia6")
24{
25 this->Initialize();
26 born = new Born();
27}
28//___________________________________________________________________________
30EventRecordVisitorI("genie::GLRESWdecPythia6", config)
31{
32 this->Initialize();
33 born = new Born();
34}
35//___________________________________________________________________________
40//____________________________________________________________________________
42{
43
44 if(!this->Wdecay(event)) {
45 LOG("GLRESGenerator", pWARN) << "W decayer failed!";
46 event->EventFlags()->SetBitNumber(kHadroSysGenErr, true);
48 exception.SetReason("Could not simulate the W decay system");
49 exception.SwitchOnFastForward();
50 throw exception;
51 return;
52 }
53
54}
55//___________________________________________________________________________
57#ifdef __GENIE_PYTHIA6_ENABLED__
58 event // avoid unused variable warning if PYTHIA6 is not enabled
59#endif
60) const
61{
62
63#ifdef __GENIE_PYTHIA6_ENABLED__
64 Interaction * interaction = event->Summary();
65 const InitialState & init_state = interaction->InitState();
66
67 //incoming v & struck particle & remnant nucleus
68 GHepParticle * nu = event->Probe();
69 GHepParticle * el = event->HitElectron();
70
71 GHepParticle * target = event -> TargetNucleus();
72 if(target) event->AddParticle(target->Pdg(), kIStFinalStateNuclearRemnant, 1,-1,-1,-1, *(target->P4()), *(target->X4()) );
73
74 TVector3 unit_nu = nu->P4()->Vect().Unit();
75
76 long double mlout = interaction->FSPrimLepton()->Mass(); //mass of charged lepton
77 long double mlin = kElectronMass; //mass of incoming charged lepton
78
79 long double Enuin = init_state.ProbeE(kRfLab);
80 long double s = born->GetS(mlin,Enuin);
81
82 long double n1 = interaction->Kine().GetKV(kKVn1);
83 long double n2 = interaction->Kine().GetKV(kKVn2);
84
85 long double costhCM = n1;
86 long double sinthCM = sqrtl(1-costhCM*costhCM);
87
88 long double t = born->GetT(mlin,mlout,s,n1);
89 long double zeta = born->GetReAlpha()/kPi*(2.0*logl(sqrtl(-t)/kElectronMass)-1.0);
90 long double omx = powl(n2, 1.0/zeta );
91 long double s_r = s*( 1.-omx );
92
93 // Boost velocity CM -> LAB
94 long double EnuinCM = (s_r-mlin*mlin)/sqrtl(s_r)/2.;
95 long double beta = (powl(Enuin,2)-powl(EnuinCM,2))/(powl(Enuin,2)+powl(EnuinCM,2));
96
97 // Final state primary lepton PDG code
98 int pdgl = interaction->FSPrimLeptonPdg();
99 assert(pdgl!=0);
100
101 if ( pdg::IsElectron(TMath::Abs(pdgl)) || pdg::IsMuon(TMath::Abs(pdgl)) || pdg::IsTau(TMath::Abs(pdgl)) ) {
102
103 long double ElpoutCM = (s_r+mlout*mlout)/sqrtl(s_r)/2.;
104 long double EnuoutCM = (s_r-mlout*mlout)/sqrtl(s_r)/2.;
105 LongLorentzVector p4_lpout( 0., EnuoutCM*sinthCM, EnuoutCM*costhCM, ElpoutCM );
106 LongLorentzVector p4_nuout( 0., -EnuoutCM*sinthCM, -EnuoutCM*costhCM, EnuoutCM );
107
108 p4_lpout.BoostZ(beta);
109 p4_nuout.BoostZ(beta);
110
111 TLorentzVector p4lp_o( (double)p4_lpout.Px(), (double)p4_lpout.Py(), (double)p4_lpout.Pz(), (double)p4_lpout.E() );
112 TLorentzVector p4nu_o( (double)p4_nuout.Px(), (double)p4_nuout.Py(), (double)p4_nuout.Pz(), (double)p4_nuout.E() );
113
114 // Randomize transverse components
116 double phi = 2* kPi * rnd->RndLep().Rndm();
117 p4lp_o.RotateZ(phi);
118 p4nu_o.RotateZ(phi);
119
120 //rotate from LAB=[0,0,Ev,Ev]->[px,py,pz,E]
121 p4lp_o.RotateUz(unit_nu);
122 p4nu_o.RotateUz(unit_nu);
123
124 int pdgvout = 0;
125 if ( pdg::IsElectron(pdgl) ) pdgvout = kPdgAntiNuE;
126 else if ( pdg::IsPositron(pdgl) ) pdgvout = kPdgNuE;
127 else if ( pdg::IsMuon(pdgl) ) pdgvout = kPdgAntiNuMu;
128 else if ( pdg::IsAntiMuon(pdgl) ) pdgvout = kPdgNuMu;
129 else if ( pdg::IsTau(pdgl) ) pdgvout = kPdgAntiNuTau;
130 else if ( pdg::IsAntiTau(pdgl) ) pdgvout = kPdgNuTau;
131
132 int pdgboson = pdg::IsNeutrino(init_state.ProbePdg()) ? kPdgWP : kPdgWM;
133
134 // Create a GHepParticle and add it to the event record
135 event->AddParticle( pdgboson, kIStDecayedState, 0, -1, 5, 6, *nu->P4()+*el->P4(), *(nu->X4()) ); //W [mothers: nuebar_in,e_in][daugthers: nulbar_out,lp_out]
136 event->AddParticle( pdgl, kIStStableFinalState, 4, -1, -1, -1, p4lp_o, *(nu->X4()) );
137 event->AddParticle( pdgvout, kIStStableFinalState, 4, -1, -1, -1, p4nu_o, *(nu->X4()) );
138 event->Summary()->KinePtr()->SetFSLeptonP4(p4lp_o);
139
140 }
141 else {
142
143 char p6frame[10],p6nu[10],p6tgt[10];
144 strcpy(p6frame, "CMS" );
145 strcpy(p6nu, "nu_ebar" );
146 strcpy(p6tgt, "e-" );
147
148 int def61 = fPythia->GetMSTP(61);
149 int def71 = fPythia->GetMSTP(71);
150 int def206 = fPythia->GetMDME(206,1);
151 int def207 = fPythia->GetMDME(207,1);
152 int def208 = fPythia->GetMDME(208,1);
153 fPythia->SetMSTP(61,0); // (Default=2) master switch for initial-state QCD and QED radiation.
154 fPythia->SetMSTP(71,0); // (Default=2) master switch for initial-state QCD and QED radiation.
155 fPythia->SetMDME(206,1,0); //swicht off W decay leptonic modes
156 fPythia->SetMDME(207,1,0);
157 fPythia->SetMDME(208,1,0);
158
159 fPythia->Pyinit(p6frame, p6nu, p6tgt, sqrtl(s_r));
160 fPythia->Pyevnt();
161
162 fPythia->SetMSTP(61,def61);
163 fPythia->SetMSTP(71,def71);
164 fPythia->SetMDME(206,1,def206);
165 fPythia->SetMDME(207,1,def207);
166 fPythia->SetMDME(208,1,def208);
167
168 // get LUJETS record
169 fPythia->GetPrimaries();
170 TClonesArray * pythia_particles = (TClonesArray *) fPythia->ImportParticles("All");
171 int np = pythia_particles->GetEntries();
172 assert(np>0);
173
174 TMCParticle * particle = 0;
175 TIter piter(pythia_particles);
176 while( (particle = (TMCParticle *) piter.Next()) ) {
177
178 int pdgc = particle->GetKF();
179 int ks = particle->GetKS();
180
181 if ( ks==21 ) { continue; } //we dont want to save first particles from pythia (init states)
182
183 LongLorentzVector p4longo(particle->GetPx(), particle->GetPy(), particle->GetPz(), particle->GetEnergy());
184 p4longo.BoostZ(beta);
185
186 TLorentzVector p4o( (double)p4longo.Px(), (double)p4longo.Py(), (double)p4longo.Pz(), (double)p4longo.E() );
187 p4o.RotateUz(unit_nu);
188
189 double massPDG = PDGLibrary::Instance()->Find(pdgc)->Mass();
190 if ( (ks==1 || ks==4) && p4o.E()<massPDG ) {
191 LOG("GLRESGenerator", pWARN) << "Putting at rest one stable particle generated by PYTHIA because E < m";
192 LOG("GLRESGenerator", pWARN) << "PDG = " << pdgc << " // State = " << ks;
193 LOG("GLRESGenerator", pWARN) << "E = " << p4o.E() << " // |p| = " << TMath::Sqrt(p4o.P());
194 LOG("GLRESGenerator", pWARN) << "p = [ " << p4o.Px() << " , " << p4o.Py() << " , " << p4o.Pz() << " ]";
195 LOG("GLRESGenerator", pWARN) << "m = " << p4o.M() << " // mpdg = " << massPDG;
196 p4o.SetXYZT(0,0,0,massPDG);
197 }
198
199 // copy final state particles to the event record
201
202 // fix numbering scheme used for mother/daughter assignments
203 int firstmother = -1;
204 int lastmother = -1;
205 int firstchild = -1;
206 int lastchild = -1;
207
208 if ( particle->GetParent() < 10 ) {
209 if ( TMath::Abs(pdgc)<7 ) { //outgoing quarks: mother will be the boson (saved in position 4)
210 firstmother = 4;
211 firstchild = particle->GetFirstChild() - 6;
212 lastchild = particle->GetLastChild() - 6;
213 }
214 else if ( TMath::Abs(pdgc)==24 ) { //produced W boson: mother will be the incoming neutrino
215 firstmother = 0;
216 firstchild = particle->GetFirstChild() - 6;
217 lastchild = particle->GetLastChild() - 6;
218 }
219 else if ( pdgc==22 ) { //radiative photons: mother will be the incoming electron
220 firstmother = 2;
221 }
222 }
223 else { //rest
224 firstmother = particle->GetParent() - 6; //shift to match boson position
225 firstchild = (particle->GetFirstChild()==0) ? particle->GetFirstChild() - 1 : particle->GetFirstChild() - 6;
226 lastchild = (particle->GetLastChild()==0) ? particle->GetLastChild() - 1 : particle->GetLastChild() - 6;
227 }
228
229 double vx = nu->X4()->X() + particle->GetVx()*1e12; //pythia gives position in [mm] while genie uses [fm]
230 double vy = nu->X4()->Y() + particle->GetVy()*1e12;
231 double vz = nu->X4()->Z() + particle->GetVz()*1e12;
232 double vt = nu->X4()->T() + particle->GetTime()*(units::millimeter/units::second);
233 TLorentzVector pos( vx, vy, vz, vt );
234
235 event->AddParticle(pdgc, ist, firstmother, lastmother, firstchild, lastchild, p4o, pos );
236
237 }
238
239 delete particle;
240 pythia_particles->Clear("C");
241
242 }
243
244 return true;
245#else
246 return false;
247#endif
248
249
250}
251//___________________________________________________________________________
257//____________________________________________________________________________
263//____________________________________________________________________________
265{
266
267#ifdef __GENIE_PYTHIA6_ENABLED__
268 GetParam( "SSBarSuppression", fSSBarSuppression );
269 GetParam( "GaussianPt2", fGaussianPt2 );
270 GetParam( "NonGaussianPt2Tail", fNonGaussianPt2Tail );
271 GetParam( "RemainingEnergyCutoff", fRemainingECutoff );
272 GetParam( "DiQuarkSuppression", fDiQuarkSuppression );
273 GetParam( "LightVMesonSuppression", fLightVMesonSuppression );
274 GetParam( "SVMesonSuppression", fSVMesonSuppression );
275 GetParam( "Lunda", fLunda );
276 GetParam( "Lundb", fLundb );
277 GetParam( "LundaDiq", fLundaDiq );
278
279 // PYTHIA parameters only valid for HEDIS
280 double wmin; GetParam( "Xsec-Wmin", wmin ) ;
281 int warnings; GetParam( "Warnings", warnings ) ;
282 int errors; GetParam( "Errors", errors ) ;
283 int qrk_mass; GetParam( "QuarkMass", qrk_mass ) ;
284 fPythia->SetPARP(2, wmin); //(D = 10. GeV) lowest c.m. energy for the event as a whole that the program will accept to simulate. (bellow 2GeV pythia crashes)
285 fPythia->SetMSTU(26, warnings); // (Default=10) maximum number of warnings that are printed
286 fPythia->SetMSTU(22, errors); // (Default=10) maximum number of errors that are printed
287 fPythia->SetMSTJ(93, qrk_mass); // light (d, u, s, c, b) quark masses are taken from PARF(101) - PARF(105) rather than PMAS(1,1) - PMAS(5,1). Diquark masses are given as sum of quark masses, without spin splitting term.
288 fPythia->SetPMAS(24,1,kMw); //mass of the W boson (pythia=80.450 // genie=80.385)
289 fPythia->SetPMAS(24,2,0.); //set to 0 the width of the W boson to avoid problems with energy conservation
290 fPythia->SetPMAS(6,2,0.); //set to 0 the width of the top to avoid problems with energy conservation
291 fPythia->SetMDME(192,1,0); // W->dbar+t decay off
292 fPythia->SetMDME(196,1,0); // W->cbar+t decay off
293 fPythia->SetMDME(200,1,0); // W->cbar+t decay off
294
295 // PYTHIA tuned parameters
296 fPythia->SetPARJ(2, fSSBarSuppression );
297 fPythia->SetPARJ(21, fGaussianPt2 );
298 fPythia->SetPARJ(23, fNonGaussianPt2Tail );
299 fPythia->SetPARJ(33, fRemainingECutoff );
300 fPythia->SetPARJ(1, fDiQuarkSuppression );
301 fPythia->SetPARJ(11, fLightVMesonSuppression );
302 fPythia->SetPARJ(12, fSVMesonSuppression );
303 fPythia->SetPARJ(41, fLunda );
304 fPythia->SetPARJ(42, fLundb );
305 fPythia->SetPARJ(45, fLundaDiq );
306#endif // __GENIE_PYTHIA6_ENABLED__
307
308}
309//____________________________________________________________________________
311{
312
313#ifdef __GENIE_PYTHIA6_ENABLED__
314 fPythia = TPythia6::Instance();
315
316 // sync GENIE/PYTHIA6 seed number
318#endif
319
320}
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE,...
Definition Messenger.h:96
#define pWARN
Definition Messenger.h:60
bool GetParam(const RgKey &name, T &p, bool is_top_call=true) const
virtual void Configure(const Registry &config)
Definition Algorithm.cxx:62
Born level nu-electron cross section.
Definition Born.h:26
STDHEP-like event record entry that can fit a particle or a nucleus.
int Pdg(void) const
const TLorentzVector * P4(void) const
const TLorentzVector * X4(void) const
GENIE's GHEP MC event record.
Definition GHepRecord.h:45
double fLundb
Lund b parameter.
double fSSBarSuppression
ssbar suppression
double fNonGaussianPt2Tail
non gaussian pt2 tail parameterization
double fLightVMesonSuppression
light vector meson suppression
void ProcessEventRecord(GHepRecord *event) const
double fLunda
Lund a parameter.
double fDiQuarkSuppression
di-quark suppression parameter
double fRemainingECutoff
remaining E cutoff stopping fragmentation
double fSVMesonSuppression
strange vector meson suppression
double fLundaDiq
adjustment of Lund a for di-quark
bool Wdecay(GHepRecord *event) const
double fGaussianPt2
gaussian pt2 distribution width
void Configure(const Registry &config)
Initial State information.
int ProbePdg(void) const
double ProbeE(RefFrame_t rf) const
Summary information for an interaction.
Definition Interaction.h:56
const Kinematics & Kine(void) const
Definition Interaction.h:71
int FSPrimLeptonPdg(void) const
final state primary lepton pdg
TParticlePDG * FSPrimLepton(void) const
final state primary lepton
const InitialState & InitState(void) const
Definition Interaction.h:69
double GetKV(KineVar_t kv) const
static PDGLibrary * Instance(void)
TParticlePDG * Find(int pdgc, bool must_exist=true)
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
TRandom3 & RndLep(void) const
rnd number generator used by final state primary lepton generators
Definition RandomGen.h:62
A registry. Provides the container for algorithm configuration parameters.
Definition Registry.h:65
An exception thrown by EventRecordVisitorI when the normal processing sequence has to be disrupted (f...
bool IsTau(int pdgc)
Definition PDGUtils.cxx:208
bool IsNeutrino(int pdgc)
Definition PDGUtils.cxx:110
bool IsPositron(int pdgc)
Definition PDGUtils.cxx:193
bool IsElectron(int pdgc)
Definition PDGUtils.cxx:188
bool IsAntiTau(int pdgc)
Definition PDGUtils.cxx:213
bool IsAntiMuon(int pdgc)
Definition PDGUtils.cxx:203
bool IsMuon(int pdgc)
Definition PDGUtils.cxx:198
static constexpr double millimeter
Definition Units.h:41
static constexpr double second
Definition Units.h:37
Simple functions for loading and reading nucleus dependent keys from config files.
@ kIStFinalStateNuclearRemnant
Definition GHepStatus.h:38
@ kIStDISPreFragmHadronicState
Definition GHepStatus.h:35
@ kIStStableFinalState
Definition GHepStatus.h:30
@ kIStDecayedState
Definition GHepStatus.h:32
const int kPdgWM
Definition PDGCodes.h:192
const int kPdgAntiNuE
Definition PDGCodes.h:29
enum genie::EGHepStatus GHepStatus_t
const int kPdgAntiNuTau
Definition PDGCodes.h:33
@ kKVn2
Definition KineVar.h:62
@ kKVn1
Definition KineVar.h:61
const int kPdgNuE
Definition PDGCodes.h:28
const int kPdgNuTau
Definition PDGCodes.h:32
@ kRfLab
Definition RefFrame.h:26
const int kPdgAntiNuMu
Definition PDGCodes.h:31
const int kPdgWP
Definition PDGCodes.h:191
const int kPdgNuMu
Definition PDGCodes.h:30
@ kHadroSysGenErr
Definition GHepFlags.h:32