20 #include "Framework/Conventions/GBuild.h" 44 using namespace genie;
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");
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";
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;
449 double dummy_w = -1.;
455 if ( prob > 0. && costh0_max > -1. ) max_momentum = pNi_next;
456 else search_step /= 2.;
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;
void ProcessEventRecord(GHepRecord *event_rec) const
virtual double MaxXSec(GHepRecord *evrec) const
virtual GHepParticle * Particle(int position) const
bool fGenerateUniformly
uniform over allowed phase space + event weight?
THE MAIN GENIE PROJECT NAMESPACE
double E(void) const
Get energy.
virtual Interaction * Summary(void) const
const NuclearModelI * fNuclModel
nuclear model
static RandomGen * Instance()
Access instance.
void SetQ2(double Q2, bool selected=false)
Kinematics * KinePtr(void) const
double fSafetyFactor
maxxsec -> maxxsec * safety_factor
int FirstDaughter(void) const
int RecoilNucleonPdg(void) const
recoil nucleon pdg
virtual void AssertXSecLimits(const Interaction *in, double xsec, double xsec_max) const
int CharmHadronPdg(void) const
bool IsStrangeEvent(void) const
bool IsNucleus(void) const
double fMaxXSecDiffTolerance
max{100*(xsec-maxxsec)/.5*(xsec+maxxsec)} if xsec>maxxsec
Defines the EventGeneratorI interface.
virtual int HitNucleonPosition(void) const
double ComputeMaxXSec(const Interaction *in) const
const TLorentzVector & HadSystP4(void) const
Pure abstract base class. Defines the NuclearModelI interface to be implemented by any physics model ...
void SetHitNucPosition(double r)
void SetMomentum(const TLorentzVector &p4)
double Mass(void) const
Mass that corresponds to the PDG code.
void BindHitNucleon(Interaction &interaction, const NuclearModelI &nucl_model, double &Eb, DMELEvGen_BindingMode_t hitNucleonBindingMode)
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)
Abstract class. Provides a data caching mechanism for for concrete implementations of the EventRecord...
A singleton holding random number generator classes. All random number generation in GENIE should tak...
double Pz(void) const
Get Pz.
string AsString(void) const
const XSecAlgorithmI * fXSecModel
Contains minimal information for tagging exclusive processes.
int FSPrimLeptonPdg(void) const
final state primary lepton pdg
double Px(void) const
Get Px.
virtual GHepParticle * Probe(void) const
bool IsCharmEvent(void) const
Summary information for an interaction.
const TLorentzVector & HitNucP4(void) const
int LastDaughter(void) const
An exception thrown by EventRecordVisitorI when the normal processing sequence has to be disrupted (f...
const TLorentzVector & FSLeptonP4(void) const
int StrangeHadronPdg(void) const
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
void AddTargetNucleusRemnant(GHepRecord *evrec) const
add a recoiled nucleus remnant
void WQ2toXY(double Ev, double M, double W, double Q2, double &x, double &y)
A Neutrino Interaction Target. Is a transparent encapsulation of quite different physical systems suc...
virtual void Configure(const Registry &config)
virtual GHepParticle * TargetNucleus(void) const
TRandom3 & RndKine(void) const
rnd number generator used by kinematics generators
Misc GENIE control constants.
const UInt_t kISkipKinematicChk
if set, skip kinematic validity checks
virtual const XSecAlgorithmI * CrossSectionAlg(void) const =0
void Setx(double x, bool selected=false)
void SetRemovalEnergy(double Erm)
static RunningThreadInfo * Instance(void)
void SetRemovalEnergy(double E) const
void SetW(double W, bool selected=false)
void SwitchOnFastForward(void)
static PDGLibrary * Instance(void)
void SetReason(string reason)
virtual TBits * EventFlags(void) const
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
void SetMomentum3(const TVector3 &mom) const
const TLorentzVector * X4(void) const
A registry. Provides the container for algorithm configuration parameters.
int fMaxXSecNucleonThrows
void Sety(double y, bool selected=false)
double CosTheta0Max(const genie::Interaction &interaction)
const UInt_t kIAssumeFreeNucleon
const XclsTag & ExclTag(void) const
double HitNucPosition(void) const
virtual GHepParticle * HitNucleon(void) const
QELEvGen_BindingMode_t StringToQELBindingMode(const std::string &mode_str)
Target * TgtPtr(void) const
double fEMin
min E for which maxxsec is cached - forcing explicit calc.
int IonPdgCode(int A, int Z)
InitialState * InitStatePtr(void) const
virtual bool GenerateNucleon(const Target &) const =0
virtual void AddParticle(const GHepParticle &p)
const InitialState & InitState(void) const
TParticlePDG * Find(int pdgc, bool must_exist=true)
double Q2(bool selected=false) const
void ClearRunningValues(void)
bool GetParamDef(const RgKey &name, T &p, const T &def) const
const Target & Tgt(void) const
virtual int ProbePosition(void) const
static const unsigned int kRjMaxIterations
const EventGeneratorI * RunningThread(void)
#define SLOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a short string (using the FUNCTION and...
void SetPrimaryLeptonPolarization(GHepRecord *ev)
void Configure(const Registry &config)
virtual double Prob(double p, double w, const Target &) const =0
double ProbeE(RefFrame_t rf) const
GENIE's GHEP MC event record.
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.
Keep info on the event generation thread currently on charge. This is used so that event generation m...
virtual int TargetNucleusPosition(void) const
Root of GENIE utility namespaces.
cet::coded_exception< error, detail::translate > exception
const UInt_t kISkipProcessChk
if set, skip process validity checks
virtual void SetDiffXSec(double xsec, KinePhaseSpace_t ps)
enum genie::EGHepStatus GHepStatus_t
Initial State information.
QELEvGen_BindingMode_t fHitNucleonBindingMode
double Py(void) const
Get Py.
const Algorithm * SubAlg(const RgKey ®istry_key) const