SKHadronicSystemGenerator.cxx
Go to the documentation of this file.
1 //____________________________________________________________________________
2 /*
3  Copyright (c) 2003-2020, The GENIE Collaboration
4  For the full text of the license visit http://copyright.genie-mc.org
5 
6  Chris Marshall <marshall \at pas.rochester.edu>
7  University of Rochester
8 
9  Martti Nirkko
10  University of Berne
11 */
12 //____________________________________________________________________________
13 
14 #include <cstdlib>
15 
16 #include <TVector3.h>
17 
34 
35 using namespace genie;
36 using namespace genie::constants;
37 
38 //___________________________________________________________________________
40 HadronicSystemGenerator("genie::SKHadronicSystemGenerator")
41 {
42 
43 }
44 //___________________________________________________________________________
46 HadronicSystemGenerator("genie::SKHadronicSystemGenerator", config)
47 {
48 
49 }
50 //___________________________________________________________________________
52 {
53 
54 }
55 //___________________________________________________________________________
57 {
58 // Access cross section algorithm for running thread
59  //RunningThreadInfo * rtinfo = RunningThreadInfo::Instance();
60  //const EventGeneratorI * evg = rtinfo->RunningThread();
61  //const XSecAlgorithmI *fXSecModel = evg->CrossSectionAlg();
63 }
64 //___________________________________________________________________________
66 {
67 //
68 // This method generates the final state hadronic system (kaon + nucleus)
69 //
70 
71  Interaction * interaction = evrec->Summary();
72  Kinematics * kinematics = interaction->KinePtr();
73  const XclsTag & xcls_tag = interaction->ExclTag();
74 
75  //-- Access neutrino, initial nucleus and final state prim. lepton entries
76  GHepParticle * nu = evrec->Probe();
77  GHepParticle * Ni = evrec->HitNucleon();
78  GHepParticle * fsl = evrec->FinalStatePrimaryLepton();
79  assert(nu);
80  assert(Ni);
81  assert(fsl);
82 
83  const TLorentzVector vtx = *(nu->X4());
84  const TLorentzVector p4nu_lab = *(nu ->P4());
85  const TLorentzVector p4fsl_lab = *(fsl->P4());
86 
87  // these will get boosted to the nucleon rest frame
88  TLorentzVector p4nu = p4nu_lab;
89  TLorentzVector p4fsl = p4fsl_lab;
90 
91  // Transform the neutrino and final-state lepton to the struck nucleon rest frame
92  const TLorentzVector pnuc4 = interaction->InitState().Tgt().HitNucP4(); // 4-momentum of struck nucleon in lab frame
93  TVector3 beta = pnuc4.BoostVector();
94  p4nu.Boost(-1.*beta);
95  p4fsl.Boost(-1.*beta);
96 
97  LOG( "SKHadron", pDEBUG ) << "\nStruck nucleon p = (" << pnuc4.X() << ", " << pnuc4.Y() << ", " << pnuc4.Z() << ")";
98  LOG( "SKHadron", pDEBUG ) << "\nLab frame neutrino E = " << p4nu_lab.E() << " lepton " << p4fsl_lab.E() << " rest frame " << p4nu.E() << " lepton " << p4fsl.E();
99 
100  //-- Determine the pdg code of the final state nucleon
101  int nuc_pdgc = (xcls_tag.NProtons()) ? kPdgProton : kPdgNeutron; // there's only ever one nucleon
102  int kaon_pdgc = xcls_tag.StrangeHadronPdg();
103 
104  const Target & tgt = interaction->InitState().Tgt();
105  GHepStatus_t ist = (tgt.IsNucleus()) ?
107 
108  //-- basic kinematic inputs
109  double Mf = (xcls_tag.NProtons()) ? kProtonMass : kNeutronMass; // there's only ever one nucleon
110  double M = pnuc4.M(); // Mass of the struck nucleon
111  double mk = PDGLibrary::Instance()->Find(kaon_pdgc)->Mass(); // K+ and K0 mass are slightly different
112  double mk2 = TMath::Power(mk,2);
113 
114  //-- specific kinematic quantities
115  double kaon_T = kinematics->GetKV(kKVSelTk);
116  double kaon_E = kaon_T + mk;
117  double pk = sqrt( kaon_E*kaon_E - mk2 );
118 
119  TLorentzVector q = p4nu - p4fsl; // nucleon rest frame
120 
121  TVector3 qvec = q.Vect(); // nucleon rest frame
122  double q3 = qvec.Mag(); // in q frame (0,0,q3)
123 
124  // Equation 17 of notes from M. Rafi Alam dated 6 November 2013
125  double eN = q.E() + M - kaon_E; // FS nucleon total energy
126  double cos_thetaKq = (q3*q3 + pk*pk + Mf*Mf - eN*eN)/(2*q3*pk);
127 
128  LOG( "SKHadron", pDEBUG ) <<
129  "Cosine theta_kq = " << cos_thetaKq << "\n" <<
130  "q.E = " << q.E() << " M = " << M << " kaon E " << kaon_E << " q3 = " << q3 << " pk = " << pk;
131 
132  if(cos_thetaKq > 1.0) {
133  LOG("SKHadron", pWARN) << "Invalid selected kinematics; Attempt regenerating";
134  evrec->EventFlags()->SetBitNumber(kKineGenErr, true);
136  exception.SetReason("Invalid selected kinematics");
137  exception.SwitchOnStepBack();
138  exception.SetReturnStep(0);
139  throw exception;
140  }
141 
142 // this can be slightly larger than 1 due to numerical precision issues -- don't let it be
143 // if( cos_thetaKq > 1.0 ) {
144 // LOG( "SKHadron", pWARN ) <<
145 // "Cosine theta_kq = " << cos_thetaKq << ", setting to 1.0\n" <<
146 // "q.E = " << q.E() << " M = " << M << " kaon E " << kaon_E << " q3 = " << q3 << " pk = " << pk;
147 // cos_thetaKq = 1.0;
148 // }
149 
150 
151  // Get phi for the k-q plane relative to nu-l plane
152  double phi_kq = kinematics->GetKV(kKVSelphikq);
153 
154  TVector3 kaon;
155  kaon.SetMagThetaPhi( pk, TMath::ACos(cos_thetaKq), phi_kq );
156 
157  TVector3 nucleon( -kaon.X(), -kaon.Y(), q3 - kaon.Z() ); // force 3-momentum conservation in q frame
158 
159  // Transform hadron momenta from z axis along q to lab frame
160  kaon.RotateUz(qvec.Unit());
161  nucleon.RotateUz(qvec.Unit());
162 
163  LOG( "SKHadron", pDEBUG ) <<
164  "\nKaon (x,y,z) in nuc rest frame: (" << kaon.X() << ", " << kaon.Y() << ", " << kaon.Z() << ")" <<
165  "\nNucleon: (" << nucleon.X() << ", " << nucleon.Y() << ", " << nucleon.Z() << ")";
166 
167  // make 4-vectors for the kaon and nucleon
168  TLorentzVector p4kaon( kaon, sqrt(kaon.Mag2()+mk2) );
169  TLorentzVector p4fsnuc( nucleon, sqrt(nucleon.Mag2()+Mf*Mf) );
170  // these are in the struck nucleon rest frame...boost them to the lab frame
171  p4kaon.Boost( beta );
172  p4fsnuc.Boost( beta );
173 
174  LOG( "SKHadron", pDEBUG ) <<
175  "\nKaon (x,y,z) in lab frame: (" << p4kaon.X() << ", " << p4kaon.Y() << ", " << p4kaon.Z() << ")" <<
176  "\nNucleon: (" << p4fsnuc.X() << ", " << p4fsnuc.Y() << ", " << p4fsnuc.Z() << ")";
177 
178  double pxNf = p4fsnuc.Px();
179  double pyNf = p4fsnuc.Py();
180  double pzNf = p4fsnuc.Pz();
181  double ENf = p4fsnuc.E();
182 
183  double pxKf = p4kaon.Px();
184  double pyKf = p4kaon.Py();
185  double pzKf = p4kaon.Pz();
186  double EKf = p4kaon.E();
187 
188  //-- Save the particles at the GHEP record
189 
190  // mom is mother, not momentum
191  int mom = evrec->HitNucleonPosition();
192 
193  // AddParticle (int pdg, GHepStatus_t ist, int mom1, int mom2, int dau1, int dau2, double px, double py, double pz, double E, double x, double y, double z, double t)
194 
195  evrec->AddParticle(
196  nuc_pdgc, ist, mom,-1,-1,-1,
197  pxNf, pyNf, pzNf, ENf, vtx.X(), vtx.Y(), vtx.Z(), vtx.T());
198 
199  evrec->AddParticle(
200  kaon_pdgc,ist, mom,-1,-1,-1,
201  pxKf, pyKf, pzKf, EKf, vtx.X(), vtx.Y(), vtx.Z(), vtx.T());
202 
203 }
Basic constants.
double beta(double KE, const simb::MCParticle *part)
THE MAIN GENIE PROJECT NAMESPACE
Definition: AlgCmp.h:25
virtual Interaction * Summary(void) const
Definition: GHepRecord.cxx:91
const TLorentzVector * P4(void) const
Definition: GHepParticle.h:78
Kinematics * KinePtr(void) const
Definition: Interaction.h:76
bool IsNucleus(void) const
Definition: Target.cxx:272
Generated/set kinematical variables for an event.
Definition: Kinematics.h:39
virtual int HitNucleonPosition(void) const
Definition: GHepRecord.cxx:410
Contains minimal information for tagging exclusive processes.
Definition: XclsTag.h:39
virtual GHepParticle * Probe(void) const
Definition: GHepRecord.cxx:277
Summary information for an interaction.
Definition: Interaction.h:56
const TLorentzVector & HitNucP4(void) const
Definition: Target.h:91
An exception thrown by EventRecordVisitorI when the normal processing sequence has to be disrupted (f...
int StrangeHadronPdg(void) const
Definition: XclsTag.h:55
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
static Config * config
Definition: config.cpp:1054
virtual GHepParticle * FinalStatePrimaryLepton(void) const
Definition: GHepRecord.cxx:326
A Neutrino Interaction Target. Is a transparent encapsulation of quite different physical systems suc...
Definition: Target.h:40
static const double kNeutronMass
Definition: Constants.h:76
double GetKV(KineVar_t kv) const
Definition: Kinematics.cxx:323
#define pWARN
Definition: Messenger.h:60
void ProcessEventRecord(GHepRecord *event_rec) const
static PDGLibrary * Instance(void)
Definition: PDGLibrary.cxx:57
virtual TBits * EventFlags(void) const
Definition: GHepRecord.h:117
const TLorentzVector * X4(void) const
Definition: GHepParticle.h:79
const XclsTag & ExclTag(void) const
Definition: Interaction.h:72
virtual GHepParticle * HitNucleon(void) const
Definition: GHepRecord.cxx:306
virtual void AddParticle(const GHepParticle &p)
Definition: GHepRecord.cxx:491
const InitialState & InitState(void) const
Definition: Interaction.h:69
void CalculateHadronicSystem_AtharSingleKaon(GHepRecord *event_rec) const
Abstract class. Is used to pass some commonly recurring methods to all concrete implementations of th...
const int kPdgProton
Definition: PDGCodes.h:81
TParticlePDG * Find(int pdgc, bool must_exist=true)
Definition: PDGLibrary.cxx:75
const Target & Tgt(void) const
Definition: InitialState.h:66
const int kPdgNeutron
Definition: PDGCodes.h:83
GENIE&#39;s GHEP MC event record.
Definition: GHepRecord.h:45
Most commonly used PDG codes. A set of utility functions to handle PDG codes is provided in PDGUtils...
STDHEP-like event record entry that can fit a particle or a nucleus.
Definition: GHepParticle.h:39
static const double kProtonMass
Definition: Constants.h:75
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
enum genie::EGHepStatus GHepStatus_t
#define pDEBUG
Definition: Messenger.h:63
int NProtons(void) const
Definition: XclsTag.h:56