GENIEGenerator
Loading...
Searching...
No Matches
PhotonCOHWdecPythia8.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//___________________________________________________________________________
15EventRecordVisitorI("genie::PhotonCOHWdecPythia8")
16{
17 this->Initialize();
18}
19//___________________________________________________________________________
21EventRecordVisitorI("genie::PhotonCOHWdecPythia8", config)
22{
23 this->Initialize();
24}
25//___________________________________________________________________________
30//____________________________________________________________________________
32{
33
34 if(!this->Wdecay(event)) {
35 LOG("PhotonCOHGenerator", pWARN) << "W decayer failed!";
36 event->EventFlags()->SetBitNumber(kHadroSysGenErr, true);
38 exception.SetReason("Could not simulate the W decay system");
39 exception.SwitchOnFastForward();
40 throw exception;
41 return;
42 }
43
44}
45//___________________________________________________________________________
47#ifdef __GENIE_PYTHIA8_ENABLED__
48 event // avoid unused variable warning if PYTHIA8 is not enabled
49#endif
50) const
51{
52
53#ifdef __GENIE_PYTHIA8_ENABLED__
54 Interaction * interaction = event->Summary();
55 const InitialState & init_state = interaction->InitState();
56
57 //incoming v & struck particle & remnant nucleus
58 GHepParticle * nu = event->Probe();
59
60 GHepParticle * target = event -> TargetNucleus();
61 if(target) event->AddParticle(target->Pdg(), kIStFinalStateNuclearRemnant, 1,-1,-1,-1, *(target->P4()), *(target->X4()) );
62
63 TVector3 unit_nu = nu->P4()->Vect().Unit();
64
65 long double Ev = init_state.ProbeE(kRfLab);
66
67 long double Mtgt = init_state.Tgt().Z()*kProtonMass + init_state.Tgt().N()*kNeutronMass;
68
69 long double n1 = interaction->Kine().GetKV(kKVn1);
70 long double n2 = interaction->Kine().GetKV(kKVn2);
71 long double n3 = interaction->Kine().GetKV(kKVn3);
72
73 long double costh = n1;
74 long double sinth = sqrtl(1-costh*costh);
75
76 long double mlout = 0;
77 if (pdg::IsNuE (TMath::Abs(nu->Pdg()))) mlout = kElectronMass;
78 else if (pdg::IsNuMu (TMath::Abs(nu->Pdg()))) mlout = kMuonMass;
79 else if (pdg::IsNuTau(TMath::Abs(nu->Pdg()))) mlout = kTauMass;
80 long double mlout2 = mlout*mlout;
81
82 long double mL = mlout+kMw;
83 long double Delta = sqrtl( powl(2.*Ev*Mtgt-mL*mL,2)-4.*powl(Mtgt*mL,2) );
84 long double s12_min = Ev/(2.*Ev+Mtgt)*(mL*mL+2.*Ev*Mtgt-Delta);
85 long double s12_max = Ev/(2.*Ev+Mtgt)*(mL*mL+2.*Ev*Mtgt+Delta);
86 long double s12 = expl( logl(s12_min)+(logl(s12_max)-logl(s12_min))*n2);
87 long double Q2_min = powl(s12,2)*Mtgt/(2.*Ev*(2.*Ev*Mtgt-s12));
88 long double Q2_max = s12 - mL*mL;
89 double Q2 = expl( logl(Q2_min) + (logl(Q2_max)-logl(Q2_min))*n3 );
90 double s_r = s12 - Q2;
91
92 long double EW = (s_r+kMw2-mlout2)/sqrtl(s_r)/2.;
93 long double El = (s_r-kMw2+mlout2)/sqrtl(s_r)/2.;
94 long double p = sqrtl( EW*EW - kMw2 );
95 LongLorentzVector p4_lout( 0., -p*sinth, -p*costh, El );
96
97 long double bz = 4.*Ev*Mtgt*Q2/(Q2+s_r)/(2.*Ev*Mtgt-Q2) - (2.*Ev*Mtgt+Q2)/(2.*Ev*Mtgt-Q2);
98 long double by = sqrtl(Mtgt*powl(Q2+s_r,2)/(2.*Ev*Q2*(s_r+Q2-2.*Ev*Mtgt))+1.);
99
100 p4_lout.BoostZ(-bz);
101 p4_lout.BoostY(-by);
102
103 TLorentzVector p4l_o(p4_lout.Px(),p4_lout.Py(),p4_lout.Pz(),p4_lout.E());
104 p4l_o.RotateX((double)acosl(by)-kPi/2.);
105
106
107 // Randomize transverse components
109 double phi = 2 * kPi * rnd->RndLep().Rndm();
110
111 p4l_o.RotateZ(phi);
112
113 //rotate from LAB=[0,0,Ev,Ev]->[px,py,pz,E]
114 p4l_o.RotateUz(unit_nu);
115
116 int pdglout = 0;
117 if (pdg::IsAntiNuE (nu->Pdg())) pdglout = kPdgPositron;
118 else if (pdg::IsNuE (nu->Pdg())) pdglout = kPdgElectron;
119 else if (pdg::IsAntiNuMu (nu->Pdg())) pdglout = kPdgAntiMuon;
120 else if (pdg::IsNuMu (nu->Pdg())) pdglout = kPdgMuon;
121 else if (pdg::IsAntiNuTau(nu->Pdg())) pdglout = kPdgAntiTau;
122 else if (pdg::IsNuTau (nu->Pdg())) pdglout = kPdgTau;
123
124 // Create a GHepParticle and add it to the event record
125 event->AddParticle( pdglout, kIStStableFinalState, 0, -1, -1, -1, p4l_o, *(nu->X4()) );
126
127 int pdgboson = pdg::IsNeutrino(init_state.ProbePdg()) ? kPdgWP : kPdgWM;
128
129 fPythia->event.reset();
130 fPythia->event.append(pdgboson, 23, 0, 0, 0., p*sinth, p*costh, EW, kMw);
131
132 fPythia->next();
133
134 // fPythia->event.list();
135 // fPythia->stat();
136
137 Pythia8::Event &fEvent = fPythia->event;
138 int np = fEvent.size();
139 assert(np>0);
140
141 for (int i = 1; i < np; i++) {
142
143 int pdgc = fEvent[i].id();
144 if (!PDGLibrary::Instance()->Find(pdgc)) continue; // some intermediate particles not part of genie tables
145
146 int ks = fEvent[i].status();
147
148 LongLorentzVector p4longo(fEvent[i].px(), fEvent[i].py(), fEvent[i].pz(), fEvent[i].e());
149 p4longo.BoostZ(-bz);
150 p4longo.BoostY(-by);
151
152 TLorentzVector p4o(p4longo.Px(),p4longo.Py(),p4longo.Pz(),p4longo.E());
153 p4o.RotateX((double)acosl(by)-kPi/2.);
154 p4o.RotateZ(phi);
155 p4o.RotateUz(unit_nu);
156
157 double massPDG = PDGLibrary::Instance()->Find(pdgc)->Mass();
158 if ( ks>0 && p4o.E()<massPDG ) {
159 LOG("PhotonCOHGenerator", pWARN) << "Putting at rest one stable particle generated by PYTHIA because E < m";
160 LOG("PhotonCOHGenerator", pWARN) << "PDG = " << pdgc << " // State = " << ks;
161 LOG("PhotonCOHGenerator", pWARN) << "E = " << p4o.E() << " // |p| = " << TMath::Sqrt(p4o.P());
162 LOG("PhotonCOHGenerator", pWARN) << "p = [ " << p4o.Px() << " , " << p4o.Py() << " , " << p4o.Pz() << " ]";
163 LOG("PhotonCOHGenerator", pWARN) << "m = " << p4o.M() << " // mpdg = " << massPDG;
164 p4o.SetXYZT(0,0,0,massPDG);
165 }
166
167 // copy final state particles to the event record
169
170 // fix numbering scheme used for mother/daughter assignments
171 int firstmother = -1;
172 int lastmother = -1;
173 int firstchild = -1;
174 int lastchild = -1;
175
176 if (fEvent[i].mother1()==0) {
177 firstmother = 0;
178 }
179 else {
180 firstmother = fEvent[i].mother1() + 3;
181 if (fEvent[i].daughter1()!=0) firstchild = fEvent[i].daughter1() + 3;
182 if (fEvent[i].daughter2()!=0) lastchild = fEvent[i].daughter2() + 3;
183
184 }
185
186 double vx = nu->X4()->X() + fEvent[i].xProd()*1e12; //pythia gives position in [mm] while genie uses [fm]
187 double vy = nu->X4()->Y() + fEvent[i].yProd()*1e12;
188 double vz = nu->X4()->Z() + fEvent[i].zProd()*1e12;
189 double vt = nu->X4()->T() + fEvent[i].tProd()*(units::millimeter/units::second);
190 TLorentzVector pos( vx, vy, vz, vt );
191
192 event->AddParticle(pdgc, ist, firstmother, lastmother, firstchild, lastchild, p4o, pos );
193
194 }
195
196 return true;
197#else
198 return false;
199#endif
200
201}
202//___________________________________________________________________________
208//____________________________________________________________________________
214//____________________________________________________________________________
216{
217
218#ifdef __GENIE_PYTHIA8_ENABLED__
219 GetParam( "SSBarSuppression", fSSBarSuppression );
220 GetParam( "GaussianPt2", fGaussianPt2 );
221 GetParam( "NonGaussianPt2Tail", fNonGaussianPt2Tail );
222 GetParam( "RemainingEnergyCutoff", fRemainingECutoff );
223 GetParam( "DiQuarkSuppression", fDiQuarkSuppression );
224 GetParam( "LightVMesonSuppression", fLightVMesonSuppression );
225 GetParam( "SVMesonSuppression", fSVMesonSuppression );
226 GetParam( "Lunda", fLunda );
227 GetParam( "Lundb", fLundb );
228 GetParam( "LundaDiq", fLundaDiq );
229
230 fPythia->settings.parm("StringFlav:probStoUD", fSSBarSuppression);
231 fPythia->settings.parm("Diffraction:primKTwidth", fGaussianPt2);
232 fPythia->settings.parm("StringPT:enhancedFraction", fNonGaussianPt2Tail);
233 fPythia->settings.parm("StringFragmentation:stopMass", fRemainingECutoff);
234 fPythia->settings.parm("StringFlav:probQQtoQ", fDiQuarkSuppression);
235 fPythia->settings.parm("StringFlav:mesonUDvector", fLightVMesonSuppression);
236 fPythia->settings.parm("StringFlav:mesonSvector", fSVMesonSuppression);
237 fPythia->settings.parm("StringZ:aLund", fLunda);
238 fPythia->settings.parm("StringZ:bLund", fLundb);
239 fPythia->settings.parm("StringZ:aExtraDiquark", fLundaDiq);
240
241 // Same default mass of the W boson in pythia8 and genie, so no need to change in pythia8
242 // No problem with energy conservation W and top decays, so no need to set the width to 0
243
244 LOG("PhotonCOHGenerator", pINFO) << "Initialising PYTHIA..." ;
245 fPythia->init();
246#endif
247
248}
249//____________________________________________________________________________
251{
252
253#ifdef __GENIE_PYTHIA8_ENABLED__
254 fPythia = Pythia8Singleton::Instance()->Pythia8();
255
256 fPythia->readString("Print:quiet = on");
257
258 // sync GENIE and PYTHIA8 seeds
260 long int seed = rnd->GetSeed();
261 fPythia->readString("Random:setSeed = on");
262 fPythia->settings.mode("Random:seed", seed);
263 LOG("LeptoHad", pINFO) << "PYTHIA8 seed = " << fPythia->settings.mode("Random:seed");
264
265 //needed to only do hadronization
266 fPythia->readString("ProcessLevel:all = off");
267#endif
268
269}
#define pINFO
Definition Messenger.h:62
#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
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
Initial State information.
const Target & Tgt(void) const
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
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)
bool Wdecay(GHepRecord *event) const
double fLightVMesonSuppression
light vector meson suppression
double fLundb
Lund b parameter.
void Configure(const Registry &config)
double fDiQuarkSuppression
di-quark suppression parameter
double fRemainingECutoff
remaining E cutoff stopping fragmentation
double fSSBarSuppression
ssbar suppression
void ProcessEventRecord(GHepRecord *event) const
double fSVMesonSuppression
strange vector meson suppression
double fGaussianPt2
gaussian pt2 distribution width
double fNonGaussianPt2Tail
non gaussian pt2 tail parameterization
double fLundaDiq
adjustment of Lund a for di-quark
double fLunda
Lund a parameter.
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
TRandom3 & RndLep(void) const
rnd number generator used by final state primary lepton generators
Definition RandomGen.h:62
long int GetSeed(void) const
Definition RandomGen.h:82
A registry. Provides the container for algorithm configuration parameters.
Definition Registry.h:65
int N(void) const
Definition Target.h:69
int Z(void) const
Definition Target.h:68
An exception thrown by EventRecordVisitorI when the normal processing sequence has to be disrupted (f...
const double e
bool IsAntiNuTau(int pdgc)
Definition PDGUtils.cxx:183
bool IsNuE(int pdgc)
Definition PDGUtils.cxx:158
bool IsAntiNuE(int pdgc)
Definition PDGUtils.cxx:173
bool IsAntiNuMu(int pdgc)
Definition PDGUtils.cxx:178
bool IsNeutrino(int pdgc)
Definition PDGUtils.cxx:110
bool IsNuMu(int pdgc)
Definition PDGUtils.cxx:163
bool IsNuTau(int pdgc)
Definition PDGUtils.cxx:168
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
const int kPdgAntiMuon
Definition PDGCodes.h:38
const int kPdgWM
Definition PDGCodes.h:192
const int kPdgTau
Definition PDGCodes.h:39
enum genie::EGHepStatus GHepStatus_t
@ kKVn2
Definition KineVar.h:62
@ kKVn1
Definition KineVar.h:61
@ kKVn3
Definition KineVar.h:63
@ kRfLab
Definition RefFrame.h:26
const int kPdgWP
Definition PDGCodes.h:191
const int kPdgMuon
Definition PDGCodes.h:37
const int kPdgPositron
Definition PDGCodes.h:36
@ kHadroSysGenErr
Definition GHepFlags.h:32
const int kPdgAntiTau
Definition PDGCodes.h:40
const int kPdgElectron
Definition PDGCodes.h:35