65#ifdef __GENIE_PYTHIA6_ENABLED__
71#ifdef __GENIE_PYTHIA6_ENABLED__
78 LOG(
"LeptoHad",
pDEBUG) <<
"v [LAB']: " << p4v.
E() <<
" // " << p4v.
M2() <<
" // [ " << p4v.
Dx() <<
" , " << p4v.
Dy() <<
" , " << p4v.
Dz() <<
" ]";
79 LOG(
"LeptoHad",
pDEBUG) <<
"N [LAB']: " << p4N.
E() <<
" // " << p4N.
M2() <<
" // [ " << p4N.
Dx() <<
" , " << p4N.
Dy() <<
" , " << p4N.
Dz() <<
" ]";
80 LOG(
"LeptoHad",
pDEBUG) <<
"l [LAB']: " << p4l.
E() <<
" // " << p4l.
M2() <<
" // [ " << p4l.
Dx() <<
" , " << p4l.
Dy() <<
" , " << p4l.
Dz() <<
" ]";
81 LOG(
"LeptoHad",
pDEBUG) <<
"H [LAB']: " << p4Hadlong.
E() <<
" // " << p4Hadlong.
M2() <<
" // [ " << p4Hadlong.
Dx() <<
" , " << p4Hadlong.
Dy() <<
" , " << p4Hadlong.
Dz() <<
" ]";
84 const TLorentzVector & vtx = *(
event->Probe()->X4());
85 TLorentzVector p4Had( (
double)p4Hadlong.
Px(), (
double)p4Hadlong.
Py(), (
double)p4Hadlong.
Pz(), (
double)p4Hadlong.
E() );
92 double W = interaction->
Kine().
W();
94 LOG(
"LeptoHad",
pWARN) <<
"Low invariant mass, W = " << W <<
" GeV!!";
107 LOG(
"LeptoHad",
pDEBUG) <<
"Hit nucleon pdgc = " << target.
HitNucPdg() <<
", W = " << W;
108 LOG(
"LeptoHad",
pDEBUG) <<
"Selected hit quark pdgc = " << hit_quark <<
" // Fragmentation quark = " << frag_quark;
130 LOG(
"LeptoHad",
pWARN) <<
"Low invariant mass, W = " << W <<
" GeV! Returning a null list";
131 LOG(
"LeptoHad",
pWARN) <<
"frag_quark = " << frag_quark <<
" -> m = " << m_frag;
132 LOG(
"LeptoHad",
pWARN) <<
"diquark = " << diquark <<
" -> m = " << m_diquark;
136 double e_frag = (W*W - m_diquark*m_diquark + m_frag*m_frag)/2./W;
137 double e_diquark = (W*W + m_diquark*m_diquark - m_frag*m_frag)/2./W;
138 fPythia->Py1ent( -1, frag_quark, e_frag, 0., 0. );
144 fPythia->Py1ent( fPythia->GetN()+1, diquark, e_diquark, fPythia->GetPARU(1), 0. );
161 LOG(
"LeptoHad",
pWARN) <<
"Low invariant mass, W = " << W <<
" GeV! Returning a null list";
162 LOG(
"LeptoHad",
pWARN) <<
"frag_quark = " << frag_quark <<
" -> m = " << m_frag;
163 LOG(
"LeptoHad",
pWARN) <<
"diquark = " << diquark <<
" -> m = " << m_diquark;
167 double e_frag = (W*W - m_diquark*m_diquark + m_frag*m_frag)/2./W;
168 double e_diquark = (W*W + m_diquark*m_diquark - m_frag*m_frag)/2./W;
169 fPythia->Py1ent( -1, frag_quark, e_frag, 0., 0. );
170 fPythia->Py1ent( fPythia->GetN()+1, diquark, e_diquark, fPythia->GetPARU(1), 0. );
183 int rema_hit_quark = -hit_quark;
189 LOG(
"LeptoHad",
pWARN) <<
"Low invariant mass, W = " << W <<
" GeV! Returning a null list";
190 LOG(
"LeptoHad",
pWARN) <<
" frag_quark = " << frag_quark <<
" -> m = " << m_frag;
191 LOG(
"LeptoHad",
pWARN) <<
" rema_hit_quark = " << rema_hit_quark <<
" -> m = " << m_rema_hit;
199 int ntwoq = isp ? 2 : 1;
212 int valquark = int(1.+ntwoq/3.+rnd->
RndHadro().Rndm());
215 else diquark = 1000*ntwoq+100*ntwoq+3;
219 if ( rema_hit_quark>0 ) {
220 pykfdi_(&diquark,&rema_hit_quark,&idum,&hadron);
224 pykfdi_(&valquark,&rema_hit_quark,&idum,&hadron);
234 double pT2 = TMath::Power(pT,2);
235 double pr = TMath::Power(m_hadron,2)+pT2;
243 pyzdis_(&kfl1,&kfl3,&pr,&z);
246 double tm_hadron = pr / z / W;
247 double E_hadron = 0.5 * ( z*W + tm_hadron );
248 double E_pz = W - tm_hadron;
249 double WT = (1-z) * W * E_pz - pT2;
252 if ( WT > TMath::Power(m_frag+m_rema+
fMinESinglet,2) ) {
256 WT = TMath::Sqrt( WT + pT2 );
257 double tm_rema = TMath::Power(m_rema,2) + pT2;
258 double E_frag = 0.5 * ( WT + ( TMath::Power(m_frag,2) - tm_rema)/WT );
259 double E_rema = 0.5 * ( WT + (-TMath::Power(m_frag,2) + tm_rema)/WT );
260 double x_rema = -1 * TMath::Sqrt( TMath::Power(E_rema,2) - tm_rema );
262 theta_rema = pyangl_(&x_rema,&pT);
267 double dbez = (E_pz-(1-z)*W)/(E_pz+(1-z)*W);
268 double pz_hadron = -0.5 * ( z*W - tm_hadron );
273 fPythia->Py1ent( -1, frag_quark, E_frag, 0., 0. );
274 if (TMath::Abs(frag_quark) > 5 ) {
278 fPythia->Py1ent( fPythia->GetN()+1, rema, E_rema, theta_rema, phi );
282 double the = 0.;
double ph = 0.;
283 double dbex = 0.;
double dbey = 0.;
284 pyrobo_( &imin , &imax, &the, &ph, &dbex, &dbey , &dbez );
285 double theta_hadron = pyangl_(&pz_hadron,&pT);
287 fPythia->SetMSTU( 10, 1 );
288 fPythia->SetP( fPythia->GetN()+1, 5, m_hadron );
289 fPythia->Py1ent( fPythia->GetN()+1, hadron, E_hadron, theta_hadron, phi +
kPi );
290 fPythia->SetMSTU( 10, 2 );
293 if ( fPythia->GetP(fPythia->GetN()-1,3)<0 && fPythia->GetP(fPythia->GetN(),3)<0 )
break;
295 LOG(
"LeptoHad",
pINFO) <<
"Not backward hadron or rema";
296 LOG(
"LeptoHad",
pINFO) <<
"hadron = " << hadron <<
" -> Pz = " << fPythia->GetP(fPythia->GetN(),3) ;
297 LOG(
"LeptoHad",
pINFO) <<
"rema = " << rema <<
" -> Pz = " << fPythia->GetP(fPythia->GetN()-1,3) ;
301 LOG(
"LeptoHad",
pINFO) <<
"Low WT value ... ";
302 LOG(
"LeptoHad",
pINFO) <<
"WT = " << TMath::Sqrt(WT) <<
" // m_frag = " << m_frag <<
" // m_rema = " << m_rema;
305 LOG(
"LeptoHad",
pINFO) <<
"Hadronization paricles not suitable. Trying again... " << counter;
308 LOG(
"LeptoHad",
pWARN) <<
"Hadronization particles failed after " << counter <<
" iterations! Returning a null list";
323 double dbex = 0.;
double dbey = 0.;
double dbez = 0;
324 pyrobo_( &imin , &imax, &theta, &phi, &dbex, &dbey , &dbez );
326 theta = TMath::ATan(2.*pT/W);
327 pyrobo_( &imin , &imax, &theta, &phi, &dbex, &dbey , &dbez );
333 fPythia->GetPrimaries();
334 TClonesArray * pythia_particles = (TClonesArray *) fPythia->ImportParticles(
"All");
337 int np = pythia_particles->GetEntries();
339 TClonesArray * particle_list =
new TClonesArray(
"genie::GHepParticle", np);
340 particle_list->SetOwner(
true);
343 long double beta = p4Hadlong.
P()/p4Hadlong.
E();
350 int mom =
event->FinalStateHadronicSystemPosition();
354 TIter particle_iter(pythia_particles);
355 while( (p = (TMCParticle *) particle_iter.Next()) ) {
357 int pdgc = p->GetKF();
363 LOG(
"LeptoHad",
pERROR) <<
"Hadronization failed! Bare quark/di-quarks appear in final state!";
372 if (
pdg::IsTQuark( TMath::Abs(pdgc) ) ) { isTop=
true;
continue; }
376 (p->GetParent()==0) ? p->SetParent(p->GetParent() - 1) : p->SetParent(p->GetParent() - 2);
377 p->SetFirstChild (p->GetFirstChild() - 2);
378 p->SetLastChild (p->GetLastChild() - 2);
381 p->SetParent(p->GetParent() - 1);
382 p->SetFirstChild (p->GetFirstChild() - 1);
383 p->SetLastChild (p->GetLastChild() - 1);
391 TLorentzVector p4( (
double)p4long.
Px(), (
double)p4long.
Py(), (
double)p4long.
Pz(), (
double)p4long.
E() );
396 if ( (ks==1 || ks==4) && p4.E()<massPDG ) {
397 LOG(
"LeptoHad",
pINFO) <<
"Putting at rest one stable particle generated by PYTHIA because E < m";
398 LOG(
"LeptoHad",
pINFO) <<
"PDG = " << pdgc <<
" // State = " << ks;
399 LOG(
"LeptoHad",
pINFO) <<
"E = " << p4.E() <<
" // |p| = " << p4.P();
400 LOG(
"LeptoHad",
pINFO) <<
"p = [ " << p4.Px() <<
" , " << p4.Py() <<
" , " << p4.Pz() <<
" ]";
401 LOG(
"LeptoHad",
pINFO) <<
"m = " << p4.M() <<
" // mpdg = " << massPDG;
402 p4.SetXYZT(0,0,0,massPDG);
408 int im = mom + 1 + p->GetParent();
409 int ifc = (p->GetFirstChild() <= -1) ? -1 : mom + 1 + p->GetFirstChild();
410 int ilc = (p->GetLastChild() <= -1) ? -1 : mom + 1 + p->GetLastChild();
412 double vx = vtx.X() + p->GetVx()*1e12;
413 double vy = vtx.Y() + p->GetVy()*1e12;
414 double vz = vtx.Z() + p->GetVz()*1e12;
416 TLorentzVector pos( vx, vy, vz, vt );
418 event->AddParticle( pdgc, ist, im,-1, ifc, ilc, p4, pos );