20#include "Framework/Conventions/GBuild.h"
69 LOG(
"QELEvent",
pDEBUG) <<
"Generating QE event kinematics...";
85 LOG(
"QELEvent",
pFATAL) <<
"No hit nucleon was set";
98 bool have_nucleus = (nucleus != 0);
103 double hitNucPos = nucleon->
X4()->Vect().Mag();
116 if ( have_nucleus ) {
118 int nucleon_pdgc = nucleon->
Pdg();
120 int Z = (is_p) ? nucleus->
Z()-1 : nucleus->
Z();
121 int A = nucleus->
A() - 1;
122 TParticlePDG * fnucleus = 0;
127 <<
"No particle with [A = " << A <<
", Z = " << Z
128 <<
", pdgc = " << ipdgc <<
"] in PDGLibrary!";
138 unsigned int iter = 0;
143 LOG(
"QELEvent",
pINFO) <<
"Attempt #: " << iter;
146 <<
"Couldn't select a valid (pNi, Eb, cos_theta_0, phi_0) tuple after "
147 << iter <<
" iterations";
150 exception.
SetReason(
"Couldn't select kinematics");
164 fNuclModel->SetMomentum3( TVector3(0., 0., 0.) );
173 double cos_theta0_max = std::min(1.,
CosTheta0Max(*interaction));
177 if ( cos_theta0_max <= -1. )
continue;
185 double costheta = rnd->
RndKine().Uniform(-1., cos_theta0_max);
186 double phi = rnd->
RndKine().Uniform( 2.*
kPi );
190 LOG(
"QELEvent",
pDEBUG) <<
"cth0 = " << costheta <<
", phi0 = " << phi;
197 double t = xsec_max * rnd->
RndKine().Rndm();
199#ifdef __GENIE_LOW_LEVEL_MESG_ENABLED__
201 <<
"xsec= " << xsec <<
", Rnd= " << t;
208 LOG(
"QELEvent",
pINFO) <<
"*Selected* Q^2 = " <<
gQ2 <<
" GeV^2";
220 LOG(
"QELKinematics",
pNOTICE) <<
"E = " << E <<
", M = "<< M;
238 LOG(
"QELEvent",
pNOTICE) <<
"Selected: W = "<< gW;
256 TLorentzVector x4l(*(evrec->
Probe())->X4());
272 LOG(
"QELEvent",
pNOTICE) <<
"pn: " << p4ptr.X() <<
", "
273 << p4ptr.Y() <<
", " << p4ptr.Z() <<
", " << p4ptr.E();
282 LOG(
"QELEvent",
pDEBUG) <<
"Reject current throw...";
286 LOG(
"QELEvent",
pINFO) <<
"Done generating QE event kinematics!";
293 LOG(
"QELEvent",
pINFO) <<
"Adding final state nucleus";
301 bool have_nucleus = nucleus != 0;
302 if (!have_nucleus)
return;
304 int A = nucleus->
A();
305 int Z = nucleus->
Z();
310 for(
int id = fd;
id <= ld;
id++) {
315 int pdgc = particle->
Pdg();
320 if (is_p || is_n) A--;
322 Px += particle->
Px();
323 Py += particle->
Py();
324 Pz += particle->
Pz();
329 TParticlePDG * remn = 0;
334 <<
"No particle with [A = " << A <<
", Z = " << Z
335 <<
", pdgc = " << ipdgc <<
"] in PDGLibrary!";
339 double Mi = nucleus->
Mass();
347 <<
"Adding nucleus [A = " << A <<
", Z = " << Z
348 <<
", pdgc = " << ipdgc <<
"]";
352 ipdgc,
kIStStableFinalState, imom,-1,-1,-1, Px,Py,Pz,E, 0,0,0,0);
376 RgKey nuclkey =
"NuclearModel";
401 std::string binding_mode;
402 GetParamDef(
"HitNucleonBindingMode", binding_mode, std::string(
"UseNuclearModel") );
418 LOG(
"QELEvent",
pINFO) <<
"Computing maximum cross section to throw against";
420 double xsec_max = -1;
421 double dummy_Eb = 0.;
434 double max_momentum = 0.010;
435 double search_step = 0.1;
436 const double STEP_STOP = 1
e-6;
437 while ( search_step > STEP_STOP ) {
438 double pNi_next = max_momentum + search_step;
441 fNuclModel->SetMomentum3( TVector3(0., 0., -pNi_next) );
449 double dummy_w = -1.;
450 double prob =
fNuclModel->Prob(pNi_next, dummy_w, tgt,
455 if ( prob > 0. && costh0_max > -1. ) max_momentum = pNi_next;
456 else search_step /= 2.;
461 fNuclModel->SetMomentum3( TVector3(0., 0., -max_momentum) );
473 const double acceptable_fraction_of_safety_factor = 0.2;
474 const int max_n_layers = 100;
475 const int N_theta = 10;
476 const int N_phi = 10;
477 double phi_at_xsec_max = -1;
478 double costh_at_xsec_max = 0;
479 double this_nuc_xsec_max = -1;
481 double costh_range_min = -1.;
483 double phi_range_min = 0.;
484 double phi_range_max = 2*TMath::Pi();
485 for (
int ilayer = 0 ; ilayer < max_n_layers ; ilayer++) {
486 double last_layer_xsec_max = this_nuc_xsec_max;
487 double costh_increment = (costh_range_max-costh_range_min) / N_theta;
488 double phi_increment = (phi_range_max-phi_range_min) / N_phi;
490 for (
int itheta = 0; itheta < N_theta; itheta++){
491 double costh = costh_range_min + itheta * costh_increment;
492 for (
int iphi = 0; iphi < N_phi; iphi++) {
493 double phi = phi_range_min + iphi * phi_increment;
501 if (xs > this_nuc_xsec_max){
502 phi_at_xsec_max = phi;
503 costh_at_xsec_max = costh;
504 this_nuc_xsec_max = xs;
511 costh_range_min = costh_at_xsec_max - costh_increment;
512 costh_range_max = costh_at_xsec_max + costh_increment;
513 phi_range_min = phi_at_xsec_max - phi_increment;
514 phi_range_max = phi_at_xsec_max + phi_increment;
516 double improvement_factor = this_nuc_xsec_max/last_layer_xsec_max;
517 if (ilayer && (improvement_factor-1) < acceptable_fraction_of_safety_factor * (
fSafetyFactor-1)) {
521 if (this_nuc_xsec_max > xsec_max) {
522 xsec_max = this_nuc_xsec_max;
523 LOG(
"QELEvent",
pINFO) <<
"best estimate for xsec_max = " << xsec_max;
532#ifdef __GENIE_LOW_LEVEL_MESG_ENABLED__
534 SLOG(
"QELEvent",
pDEBUG) <<
"Max xsec in phase space = " << max_xsec;
538 LOG(
"QELEvent",
pINFO) <<
"Computed maximum cross section to throw against - value is " << xsec_max;
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE,...
#define SLOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a short string (using the FUNCTION and...
Most commonly used PDG codes. A set of utility functions to handle PDG codes is provided in PDGUtils.
virtual void Configure(const Registry &config)
bool GetParamDef(const RgKey &name, T &p, const T &def) const
const Algorithm * SubAlg(const RgKey ®istry_key) const
Defines the EventGeneratorI interface.
virtual const XSecAlgorithmI * CrossSectionAlg(void) const =0
STDHEP-like event record entry that can fit a particle or a nucleus.
void SetMomentum(const TLorentzVector &p4)
void SetRemovalEnergy(double Erm)
double Mass(void) const
Mass that corresponds to the PDG code.
const TLorentzVector * X4(void) const
int LastDaughter(void) const
double Px(void) const
Get Px.
double E(void) const
Get energy.
double Pz(void) const
Get Pz.
double Py(void) const
Get Py.
int FirstDaughter(void) const
GENIE's GHEP MC event record.
virtual int ProbePosition(void) const
virtual GHepParticle * Probe(void) const
virtual void SetDiffXSec(double xsec, KinePhaseSpace_t ps)
virtual GHepParticle * TargetNucleus(void) const
virtual Interaction * Summary(void) const
virtual TBits * EventFlags(void) const
virtual void AddParticle(const GHepParticle &p)
virtual int TargetNucleusPosition(void) const
virtual GHepParticle * Particle(int position) const
virtual int HitNucleonPosition(void) const
virtual GHepParticle * HitNucleon(void) const
Initial State information.
const Target & Tgt(void) const
double ProbeE(RefFrame_t rf) const
Target * TgtPtr(void) const
Summary information for an interaction.
string AsString(void) const
const XclsTag & ExclTag(void) const
InitialState * InitStatePtr(void) const
int RecoilNucleonPdg(void) const
recoil nucleon pdg
int FSPrimLeptonPdg(void) const
final state primary lepton pdg
const InitialState & InitState(void) const
Kinematics * KinePtr(void) const
virtual void AssertXSecLimits(const Interaction *in, double xsec, double xsec_max) const
bool fGenerateUniformly
uniform over allowed phase space + event weight?
double fMaxXSecDiffTolerance
max{100*(xsec-maxxsec)/.5*(xsec+maxxsec)} if xsec>maxxsec
double fEMin
min E for which maxxsec is cached - forcing explicit calc.
double fSafetyFactor
ComputeMaxXSec -> ComputeMaxXSec * fSafetyFactor.
virtual double MaxXSec(GHepRecord *evrec, const int nkey=0) const
const XSecAlgorithmI * fXSecModel
void Setx(double x, bool selected=false)
void SetQ2(double Q2, bool selected=false)
double Q2(bool selected=false) const
const TLorentzVector & HadSystP4(void) const
const TLorentzVector & FSLeptonP4(void) const
void ClearRunningValues(void)
void Sety(double y, bool selected=false)
void SetW(double W, bool selected=false)
Pure abstract base class. Defines the NuclearModelI interface to be implemented by any physics model ...
static PDGLibrary * Instance(void)
TParticlePDG * Find(int pdgc, bool must_exist=true)
void AddTargetNucleusRemnant(GHepRecord *evrec) const
add a recoiled nucleus remnant
void Configure(const Registry &config)
void ProcessEventRecord(GHepRecord *event_rec) const
QELEvGen_BindingMode_t fHitNucleonBindingMode
const NuclearModelI * fNuclModel
nuclear model
double ComputeMaxXSec(const Interaction *in) const
int fMaxXSecNucleonThrows
A singleton holding random number generator classes. All random number generation in GENIE should tak...
static RandomGen * Instance()
Access instance.
TRandom3 & RndKine(void) const
rnd number generator used by kinematics generators
A registry. Provides the container for algorithm configuration parameters.
Keep info on the event generation thread currently on charge. This is used so that event generation m...
static RunningThreadInfo * Instance(void)
const EventGeneratorI * RunningThread(void)
A Neutrino Interaction Target. Is a transparent encapsulation of quite different physical systems suc...
void SetHitNucPosition(double r)
const TLorentzVector & HitNucP4(void) const
double HitNucPosition(void) const
bool IsNucleus(void) const
Contains minimal information for tagging exclusive processes.
bool IsStrangeEvent(void) const
bool IsCharmEvent(void) const
int StrangeHadronPdg(void) const
int CharmHadronPdg(void) const
An exception thrown by EventRecordVisitorI when the normal processing sequence has to be disrupted (f...
void SwitchOnFastForward(void)
void SetReason(string reason)
Misc GENIE control constants.
static const unsigned int kRjMaxIterations
int IonPdgCode(int A, int Z)
Simple functions for loading and reading nucleus dependent keys from config files.
void WQ2toXY(double Ev, double M, double W, double Q2, double &x, double &y)
Root of GENIE utility namespaces.
QELEvGen_BindingMode_t StringToQELBindingMode(const std::string &mode_str)
double CosTheta0Max(const genie::Interaction &interaction)
double ComputeFullQELPXSec(Interaction *interaction, const NuclearModelI *nucl_model, const XSecAlgorithmI *xsec_model, double cos_theta_0, double phi_0, double &Eb, QELEvGen_BindingMode_t hitNucleonBindingMode, double min_angle_EM=0., bool bind_nucleon=true)
void SetPrimaryLeptonPolarization(GHepRecord *ev)
void BindHitNucleon(Interaction &interaction, const NuclearModelI &nucl_model, double &Eb, DMELEvGen_BindingMode_t hitNucleonBindingMode)
THE MAIN GENIE PROJECT NAMESPACE
enum genie::EGHepStatus GHepStatus_t
const UInt_t kISkipKinematicChk
if set, skip kinematic validity checks
const UInt_t kISkipProcessChk
if set, skip process validity checks
const UInt_t kIAssumeFreeNucleon