GENIEGenerator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
genie::SPPEventGenerator Class Reference

Generates resonance single pion production event for the following channels: More...

#include <SPPEventGenerator.h>

Inheritance diagram for genie::SPPEventGenerator:
Inheritance graph
[legend]
Collaboration diagram for genie::SPPEventGenerator:
Collaboration graph
[legend]

Classes

struct  Cell
 
struct  Vertex
 

Public Member Functions

 SPPEventGenerator ()
 
 SPPEventGenerator (string config)
 
 ~SPPEventGenerator ()
 
void ProcessEventRecord (GHepRecord *event_rec) const
 
void Configure (const Registry &config)
 
void Configure (string config)
 
- Public Member Functions inherited from genie::EventRecordVisitorI
virtual ~EventRecordVisitorI ()
 
- Public Member Functions inherited from genie::Algorithm
virtual ~Algorithm ()
 
virtual void FindConfig (void)
 
virtual const RegistryGetConfig (void) const
 
RegistryGetOwnedConfig (void)
 
virtual const AlgIdId (void) const
 Get algorithm ID. More...
 
virtual AlgStatus_t GetStatus (void) const
 Get algorithm status. More...
 
virtual bool AllowReconfig (void) const
 
virtual AlgCmp_t Compare (const Algorithm *alg) const
 Compare with input algorithm. More...
 
virtual void SetId (const AlgId &id)
 Set algorithm ID. More...
 
virtual void SetId (string name, string config)
 
const AlgorithmSubAlg (const RgKey &registry_key) const
 
void AdoptConfig (void)
 
void AdoptSubstructure (void)
 
virtual void Print (ostream &stream) const
 Print algorithm info. More...
 

Private Member Functions

void LoadConfig (void)
 
double ComputeMaxXSec (const Interaction *interaction) const
 
int GetRecoilNucleonPdgCode (Interaction *interaction) const
 
int GetFinalPionPdgCode (Interaction *interaction) const
 

Private Attributes

double fWcut
 
int fMaxDepth
 Maximum depth of dividing parent cell. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from genie::Algorithm
static string BuildParamVectKey (const std::string &comm_name, unsigned int i)
 
static string BuildParamVectSizeKey (const std::string &comm_name)
 
static string BuildParamMatKey (const std::string &comm_name, unsigned int i, unsigned int j)
 
static string BuildParamMatRowSizeKey (const std::string &comm_name)
 
static string BuildParamMatColSizeKey (const std::string &comm_name)
 
- Protected Member Functions inherited from genie::KineGeneratorWithCache
 KineGeneratorWithCache ()
 
 KineGeneratorWithCache (string name)
 
 KineGeneratorWithCache (string name, string config)
 
 ~KineGeneratorWithCache ()
 
virtual double ComputeMaxXSec (const Interaction *in, const int nkey) const
 
virtual double MaxXSec (GHepRecord *evrec, const int nkey=0) const
 
virtual double FindMaxXSec (const Interaction *in, const int nkey=0) const
 
virtual void CacheMaxXSec (const Interaction *in, double xsec, const int nkey=0) const
 
virtual double Energy (const Interaction *in) const
 
virtual CacheBranchFxAccessCacheBranch (const Interaction *in, const int nkey=0) const
 
virtual void AssertXSecLimits (const Interaction *in, double xsec, double xsec_max) const
 
- Protected Member Functions inherited from genie::EventRecordVisitorI
 EventRecordVisitorI ()
 
 EventRecordVisitorI (string name)
 
 EventRecordVisitorI (string name, string config)
 
- Protected Member Functions inherited from genie::Algorithm
 Algorithm ()
 
 Algorithm (string name)
 
 Algorithm (string name, string config)
 
void Initialize (void)
 
void DeleteConfig (void)
 
void DeleteSubstructure (void)
 
RegistryExtractLocalConfig (const Registry &in) const
 
RegistryExtractLowerConfig (const Registry &in, const string &alg_key) const
 Split an incoming configuration Registry into a block valid for the sub-algo identified by alg_key. More...
 
template<class T >
bool GetParam (const RgKey &name, T &p, bool is_top_call=true) const
 
template<class T >
bool GetParamDef (const RgKey &name, T &p, const T &def) const
 
template<class T >
int GetParamVect (const std::string &comm_name, std::vector< T > &v, bool is_top_call=true) const
 Handle to load vectors of parameters. More...
 
int GetParamVectKeys (const std::string &comm_name, std::vector< RgKey > &k, bool is_top_call=true) const
 
template<class T >
int GetParamMat (const std::string &comm_name, TMatrixT< T > &mat, bool is_top_call=true) const
 Handle to load matrix of parameters. More...
 
template<class T >
int GetParamMatSym (const std::string &comm_name, TMatrixTSym< T > &mat, bool is_top_call=true) const
 
int GetParamMatKeys (const std::string &comm_name, std::vector< RgKey > &k, bool is_top_call=true) const
 
int AddTopRegistry (Registry *rp, bool owns=true)
 add registry with top priority, also update ownership More...
 
int AddLowRegistry (Registry *rp, bool owns=true)
 add registry with lowest priority, also update ownership More...
 
int MergeTopRegistry (const Registry &r)
 
int AddTopRegisties (const vector< Registry * > &rs, bool owns=false)
 Add registries with top priority, also udated Ownerships. More...
 
- Protected Attributes inherited from genie::KineGeneratorWithCache
const XSecAlgorithmIfXSecModel
 
double fSafetyFactor
 ComputeMaxXSec -> ComputeMaxXSec * fSafetyFactor. More...
 
std::vector< double > vSafetyFactors
 MaxXSec -> MaxXSec * fSafetyFactors[nkey]. More...
 
int fNumOfSafetyFactors
 Number of given safety factors. More...
 
std::vector< string > vInterpolatorTypes
 Type of interpolator for each key in a branch. More...
 
int fNumOfInterpolatorTypes
 Number of given interpolators types. More...
 
double fMaxXSecDiffTolerance
 max{100*(xsec-maxxsec)/.5*(xsec+maxxsec)} if xsec>maxxsec More...
 
double fEMin
 min E for which maxxsec is cached - forcing explicit calc. More...
 
bool fGenerateUniformly
 uniform over allowed phase space + event weight? More...
 
- Protected Attributes inherited from genie::Algorithm
bool fAllowReconfig
 
bool fOwnsSubstruc
 true if it owns its substructure (sub-algs,...) More...
 
AlgId fID
 algorithm name and configuration set More...
 
vector< Registry * > fConfVect
 
vector< bool > fOwnerships
 ownership for every registry in fConfVect More...
 
AlgStatus_t fStatus
 algorithm execution status More...
 
AlgMapfOwnedSubAlgMp
 local pool for owned sub-algs (taken out of the factory pool) More...
 

Detailed Description

Generates resonance single pion production event for the following channels:

for the following channels:

      1       nu + p -> l      + p + pi+
      2       nu + n -> l      + p + pi0
      3       nu + n -> l      + n + pi+
      4   antinu + n -> l+     + n + pi-
      5   antinu + p -> l+     + n + pi0
      6   antinu + p -> l+     + p + pi-
      7       nu + p -> nu     + p + pi0
      8       nu + p -> nu     + n + pi+
      9       nu + n -> nu     + n + pi0
      10      nu + n -> nu     + p + pi-
      11  antinu + p -> antinu + p + pi0
      12  antinu + p -> antinu + n + pi+
      13  antinu + n -> antinu + n + pi0
      14  antinu + n -> antinu + p + pi-

Is a concrete implementation of the EventRecordVisitorI interface.

Authors
Igor Kakorin kakor.nosp@m.in@j.nosp@m.inr.r.nosp@m.u, Joint Institute for Nuclear Research
Vadim Naumov vnaum.nosp@m.ov@t.nosp@m.heor..nosp@m.jinr.nosp@m..ru, Joint Institute for Nuclear Research
Created:
May 9, 2020
License:
Copyright (c) 2003-2024, The GENIE Collaboration For the full text of the license visit http://copyright.genie-mc.org or see $GENIE/LICENSE

Definition at line 50 of file SPPEventGenerator.h.

Constructor & Destructor Documentation

SPPEventGenerator::SPPEventGenerator ( )

Definition at line 47 of file SPPEventGenerator.cxx.

47  :
48 KineGeneratorWithCache("genie::SPPEventGenerator")
49 {
50 
51 }
SPPEventGenerator::SPPEventGenerator ( string  config)

Definition at line 53 of file SPPEventGenerator.cxx.

53  :
54 KineGeneratorWithCache("genie::SPPEventGenerator", config)
55 {
56 
57 }
SPPEventGenerator::~SPPEventGenerator ( )

Definition at line 59 of file SPPEventGenerator.cxx.

60 {
61 
62 }

Member Function Documentation

double SPPEventGenerator::ComputeMaxXSec ( const Interaction interaction) const
privatevirtual

Implements genie::KineGeneratorWithCache.

Definition at line 342 of file SPPEventGenerator.cxx.

References e, fMaxDepth, genie::utils::res::FromString(), genie::KineGeneratorWithCache::fSafetyFactor, fWcut, genie::KineGeneratorWithCache::fXSecModel, genie::kRfHitNucRest, genie::utils::res::Mass(), genie::Range1D_t::max, genie::Range1D_t::min, genie::Interaction::PhaseSpacePtr(), genie::InitialState::ProbeE(), genie::utils::res::Width(), and genie::KPhaseSpace::WLim_SPP_iso().

343 {
344  KPhaseSpace * kps = interaction->PhaseSpacePtr();
345  Range1D_t Wl = kps->WLim_SPP_iso();
346  ROOT::Math::Minimizer * min = ROOT::Math::Factory::CreateMinimizer("Minuit", "Minimize");
347  ROOT::Math::IBaseFunctionMultiDim * f = new genie::utils::gsl::d4XSecMK_dWQ2CosThetaPhi_E(fXSecModel, interaction, fWcut);
348  min->SetFunction( *f );
349  min->SetMaxFunctionCalls(10000); // for Minuit/Minuit2
350  min->SetMaxIterations(10000); // for GSL
351  min->SetTolerance(1e-3);
352  min->SetPrintLevel(0);
353  double min_xsec = 0.;
354  double xsec;
355  double step = 1e-7;
356  // a heuristic algorithm for maximum search
357  int total_cells = (TMath::Power(16, fMaxDepth) - 1)/15;
358  vector<Cell> cells(total_cells);
359 
360  for (int dep = 0; dep < fMaxDepth; dep++)
361  {
362  int aux = TMath::Power(16, dep) - 1;
363  for (int cell = aux/15; cell <= 16*aux/15 ; cell++)
364  {
365  if (cell == 0)
366  {
367  cells[cell].Vertex1 = Vertex(0., 0., 0., 0.);
368  cells[cell].Vertex2 = Vertex(1., 1., 1., 1.);
369  }
370  double x1m = (cells[cell].Vertex1.x1 + cells[cell].Vertex2.x1)/2;
371  double x2m = (cells[cell].Vertex1.x2 + cells[cell].Vertex2.x2)/2;
372  double x3m = (cells[cell].Vertex1.x3 + cells[cell].Vertex2.x3)/2;
373  double x4m = (cells[cell].Vertex1.x4 + cells[cell].Vertex2.x4)/2;
374  min->SetVariable(0, "x1", x1m, step);
375  min->SetVariable(1, "x2", x2m, step);
376  min->SetVariable(2, "x3", x3m, step);
377  min->SetVariable(3, "x4", x4m, step);
378  min->SetVariableLimits(0, cells[cell].Vertex1.x1, cells[cell].Vertex2.x1);
379  min->SetVariableLimits(1, cells[cell].Vertex1.x2, cells[cell].Vertex2.x2);
380  min->SetVariableLimits(2, cells[cell].Vertex1.x3, cells[cell].Vertex2.x3);
381  min->SetVariableLimits(3, cells[cell].Vertex1.x4, cells[cell].Vertex2.x4);
382  min->Minimize();
383  xsec = min->MinValue();
384  if (xsec < min_xsec)
385  min_xsec = xsec;
386  const double *xs = min->X();
387  Vertex minv(xs[0], xs[1], xs[2], xs[3]);
388  if (minv == cells[cell].Vertex1 || minv == cells[cell].Vertex2)
389  minv = Vertex (x1m, x2m, x3m, x4m);
390  if (dep < fMaxDepth - 1)
391  for (int i = 0; i < 16; i++)
392  {
393  int child = 16*cell + i + 1;
394  cells[child].Vertex1 = minv;
395  cells[child].Vertex2 = Vertex ((i>>0)%2?cells[cell].Vertex1.x1:cells[cell].Vertex2.x1,
396  (i>>1)%2?cells[cell].Vertex1.x2:cells[cell].Vertex2.x2,
397  (i>>2)%2?cells[cell].Vertex1.x3:cells[cell].Vertex2.x3,
398  (i>>3)%2?cells[cell].Vertex1.x4:cells[cell].Vertex2.x4);
399  }
400  }
401  }
402  Resonance_t res = genie::utils::res::FromString("P33(1232)");
403  const InitialState & init_state = interaction -> InitState();
404  double Enu = init_state.ProbeE(kRfHitNucRest);
405  // other heuristic algorithm for maximum search to fix flaws of the first
406  int N3 = 2;
407  int N4 = 4;
408  double x2max;
409  if (Enu < 1.)
410  x2max = 1.;
411  else
412  x2max = 1./3;
413  double dW = Wl.max - Wl.min;
414  double MR = utils::res::Mass(res);
415  double WR = utils::res::Width(res);
416  double x1 = (MR - Wl.min)/dW;
417  double x1min = (MR - WR - Wl.min)/dW;
418  if (x1min > 1)
419  {
420  delete f;
421  return -min_xsec;
422  }
423  x1min = x1min<0?0:x1min;
424  double x1max = (MR + WR - Wl.min)/dW;
425  if (x1max < 0)
426  {
427  delete f;
428  return -min_xsec;
429  }
430  x1max = x1max>1?1:x1max;
431  if (x1 < x1min || x1 > x1max) x1=0.5*(x1min + x1max);
432  for (int i3 = 0; i3 < N3; i3++)
433  {
434  double x3 = 1.*i3;
435  double x3min = .5*i3;
436  double x3max = .5*(i3 + 1);
437  for (int i4 = 0; i4 <= N4; i4++)
438  {
439  double x4 = 1.*i4/N4;
440  double x4min = 1.*i4/N4;
441  double x4max = 1.*(i4 + 1)/N4;
442  if (i4 == N4)
443  {
444  x4min = 3./N4;
445  x4max = 1;
446  }
447  min->SetVariable(0, "x1", x1, step);
448  min->SetVariable(1, "x2", 1./6, step);
449  min->SetVariable(2, "x3", x3, step);
450  min->SetVariable(3, "x4", x4, step);
451  min->SetVariableLimits(0, x1min, x1max);
452  min->SetVariableLimits(1, 0, x2max);
453  min->SetVariableLimits(2, x3min, x3max);
454  min->SetVariableLimits(3, x4min, x4max);
455  min->Minimize();
456  xsec = min->MinValue();
457  if (xsec < min_xsec)
458  min_xsec = xsec;
459  }
460  }
461 
462  delete f;
463 
464  return -fSafetyFactor*min_xsec;
465 }
Resonance_t FromString(const char *res)
string -&gt; resonance id
double fSafetyFactor
ComputeMaxXSec -&gt; ComputeMaxXSec * fSafetyFactor.
A simple [min,max] interval for doubles.
Definition: Range1.h:42
double Mass(Resonance_t res)
resonance mass (GeV)
double Width(Resonance_t res)
resonance width (GeV)
enum genie::EResonance Resonance_t
KPhaseSpace * PhaseSpacePtr(void) const
Definition: Interaction.h:78
const double e
Kinematical phase space.
Definition: KPhaseSpace.h:33
double max
Definition: Range1.h:53
Range1D_t WLim_SPP_iso(void) const
W limits for resonance single pion production on isoscalar nucleon.
double min
Definition: Range1.h:52
int fMaxDepth
Maximum depth of dividing parent cell.
double ProbeE(RefFrame_t rf) const
Initial State information.
Definition: InitialState.h:48
void SPPEventGenerator::Configure ( const Registry config)
virtual

Configure the algorithm with an external registry The registry is merged with the top level registry if it is owned, Otherwise a copy of it is added with the highest priority

Reimplemented from genie::Algorithm.

Definition at line 304 of file SPPEventGenerator.cxx.

References genie::Algorithm::Configure(), and LoadConfig().

305 {
306  Algorithm::Configure(config);
307  this->LoadConfig();
308 }
virtual void Configure(const Registry &config)
Definition: Algorithm.cxx:62
void SPPEventGenerator::Configure ( string  config)
virtual

Configure the algorithm from the AlgoConfigPool based on param_set string given in input An algorithm contains a vector of registries coming from different xml configuration files, which are loaded according a very precise prioriy This methods will load a number registries in order of priority: 1) "Tunable" parameter set from CommonParametes. This is loaded with the highest prioriry and it is designed to be used for tuning procedure Usage not expected from the user. 2) For every string defined in "CommonParame" the corresponding parameter set will be loaded from CommonParameter.xml 3) parameter set specified by the config string and defined in the xml file of the algorithm 4) if config is not "Default" also the Default parameter set from the same xml file will be loaded Effectively this avoids the repetion of a parameter when it is not changed in the requested configuration

Reimplemented from genie::Algorithm.

Definition at line 310 of file SPPEventGenerator.cxx.

References genie::Algorithm::Configure(), and LoadConfig().

311 {
312  Algorithm::Configure(config);
313  this->LoadConfig();
314 }
virtual void Configure(const Registry &config)
Definition: Algorithm.cxx:62
int SPPEventGenerator::GetFinalPionPdgCode ( Interaction interaction) const
private

Definition at line 293 of file SPPEventGenerator.cxx.

References genie::Interaction::ExclTag(), genie::kPdgPi0, genie::kPdgPiM, genie::kPdgPiP, genie::XclsTag::NPiMinus(), and genie::XclsTag::NPiPlus().

Referenced by ProcessEventRecord().

294 {
295  const XclsTag & xcls = interaction->ExclTag();
296  if (xcls.NPiPlus() == 1)
297  return kPdgPiP;
298  else if (xcls.NPiMinus() == 1)
299  return kPdgPiM;
300  return kPdgPi0;
301 
302 }
int NPiMinus(void) const
Definition: XclsTag.h:60
Contains minimal information for tagging exclusive processes.
Definition: XclsTag.h:39
int NPiPlus(void) const
Definition: XclsTag.h:59
const int kPdgPiP
Definition: PDGCodes.h:158
const int kPdgPi0
Definition: PDGCodes.h:160
const XclsTag & ExclTag(void) const
Definition: Interaction.h:72
const int kPdgPiM
Definition: PDGCodes.h:159
int SPPEventGenerator::GetRecoilNucleonPdgCode ( Interaction interaction) const
private

Definition at line 283 of file SPPEventGenerator.cxx.

References genie::Interaction::ExclTag(), genie::kPdgNeutron, genie::kPdgProton, and genie::XclsTag::NProtons().

Referenced by ProcessEventRecord().

284 {
285  const XclsTag & xcls = interaction->ExclTag();
286  if (xcls.NProtons() == 1)
287  return kPdgProton;
288  else
289  return kPdgNeutron;
290 
291 }
Contains minimal information for tagging exclusive processes.
Definition: XclsTag.h:39
const XclsTag & ExclTag(void) const
Definition: Interaction.h:72
const int kPdgProton
Definition: PDGCodes.h:81
const int kPdgNeutron
Definition: PDGCodes.h:83
int NProtons(void) const
Definition: XclsTag.h:56
void SPPEventGenerator::LoadConfig ( void  )
private

Definition at line 316 of file SPPEventGenerator.cxx.

References genie::KineGeneratorWithCache::fEMin, genie::KineGeneratorWithCache::fGenerateUniformly, fMaxDepth, genie::KineGeneratorWithCache::fMaxXSecDiffTolerance, genie::KineGeneratorWithCache::fSafetyFactor, fWcut, and genie::Algorithm::GetParamDef().

Referenced by Configure().

317 {
318 
319  // Safety factor for the maximum differential cross section
320  this->GetParamDef("MaxXSec-SafetyFactor", fSafetyFactor, 1.03);
321  this->GetParamDef("Maximum-Depth", fMaxDepth, 3);
322 
323  // Minimum energy for which max xsec would be cached, forcing explicit
324  // calculation for lower eneries
325  this->GetParamDef("Cache-MinEnergy", fEMin, 0.5);
326 
327 
328  // Maximum allowed fractional cross section deviation from maxim cross
329  // section used in rejection method
330  this->GetParamDef("MaxXSec-DiffTolerance", fMaxXSecDiffTolerance, 999999.);
331  assert(fMaxXSecDiffTolerance>=0);
332 
333  // Generate kinematics uniformly over allowed phase space and compute
334  // an event weight?
335  this->GetParamDef("UniformOverPhaseSpace", fGenerateUniformly, false);
336 
337  this->GetParamDef("Wcut", fWcut, -1.);
338 
339 
340 }
bool fGenerateUniformly
uniform over allowed phase space + event weight?
double fSafetyFactor
ComputeMaxXSec -&gt; ComputeMaxXSec * fSafetyFactor.
double fMaxXSecDiffTolerance
max{100*(xsec-maxxsec)/.5*(xsec+maxxsec)} if xsec&gt;maxxsec
double fEMin
min E for which maxxsec is cached - forcing explicit calc.
bool GetParamDef(const RgKey &name, T &p, const T &def) const
int fMaxDepth
Maximum depth of dividing parent cell.
void SPPEventGenerator::ProcessEventRecord ( GHepRecord event_rec) const
virtual

Implements genie::EventRecordVisitorI.

Definition at line 64 of file SPPEventGenerator.cxx.

References genie::GHepRecord::AddParticle(), genie::KineGeneratorWithCache::AssertXSecLimits(), genie::Kinematics::ClearRunningValues(), genie::EventGeneratorI::CrossSectionAlg(), genie::GHepRecord::EventFlags(), genie::KineGeneratorWithCache::fGenerateUniformly, genie::PDGLibrary::Find(), genie::Interaction::FSPrimLepton(), genie::Interaction::FSPrimLeptonPdg(), fWcut, genie::KineGeneratorWithCache::fXSecModel, GetFinalPionPdgCode(), genie::InitialState::GetProbeP4(), GetRecoilNucleonPdgCode(), genie::GHepRecord::HitNucleon(), genie::GHepRecord::HitNucleonPosition(), genie::RunningThreadInfo::Instance(), genie::RandomGen::Instance(), genie::PDGLibrary::Instance(), genie::Target::IsNucleus(), genie::Interaction::KinePtr(), genie::kISkipKinematicChk, genie::kISkipProcessChk, genie::kIStHadronInTheNucleus, genie::kIStStableFinalState, genie::kKineGenErr, genie::kPdgNeutron, genie::kPdgPi0, genie::kPdgPiM, genie::kPdgPiP, genie::kPdgProton, genie::constants::kPi, genie::kPSWQ2ctpphipfE, genie::kRfLab, genie::controls::kRjMaxIterations, LOG, genie::Range1D_t::max, genie::KineGeneratorWithCache::MaxXSec(), genie::Range1D_t::min, genie::Interaction::PhaseSpace(), pINFO, pNOTICE, genie::GHepRecord::Probe(), genie::GHepRecord::ProbePosition(), pWARN, genie::utils::kinematics::Q2(), genie::KPhaseSpace::Q2Lim_W_SPP_iso(), genie::RandomGen::RndKine(), genie::RunningThreadInfo::RunningThread(), genie::GHepRecord::SetDiffXSec(), genie::Target::SetHitNucP4(), genie::Kinematics::SetQ2(), genie::exceptions::EVGThreadException::SetReason(), genie::Kinematics::SetW(), genie::GHepRecord::SetWeight(), genie::Kinematics::Setx(), genie::Kinematics::Sety(), genie::GHepRecord::Summary(), genie::exceptions::EVGThreadException::SwitchOnFastForward(), genie::utils::kinematics::W(), genie::GHepRecord::Weight(), genie::KPhaseSpace::WLim_SPP_iso(), genie::utils::kinematics::WQ2toXY(), and genie::GHepRecord::XSec().

65 {
66 
67 
68  LOG("SPPEventGen", pINFO) << "Generating resonance single pion production event kinematics...";
69 
70  if(fGenerateUniformly) {
71  LOG("SPPEventGen", pNOTICE)
72  << "Generating kinematics uniformly over the allowed phase space";
73  }
74 
75  //-- Get the interaction from the GHEP record
76  Interaction * interaction = evrec->Summary();
77  const InitialState & init_state = interaction -> InitState();
78  const KPhaseSpace& kps = interaction->PhaseSpace();
79 
80  // Access the target from the interaction summary
81  //const Target & tgt = init_state.Tgt();
82  Target * tgt = interaction -> InitStatePtr()->TgtPtr();
83 
84  // get masses of nucleon and pion
85  PDGLibrary * pdglib = PDGLibrary::Instance();
86  // imply isospin symmetry
87  double mpi = (pdglib->Find(kPdgPiP)->Mass() + pdglib->Find(kPdgPi0)->Mass() + pdglib->Find(kPdgPiM)->Mass())/3;
88  double mpi2 = mpi*mpi;
89  double M = (pdglib->Find(kPdgProton)->Mass() + pdglib->Find(kPdgNeutron)->Mass())/2;
90  double M2 = M*M;
91  // mass of final lepton
92  double ml = interaction->FSPrimLepton()->Mass();
93  double ml2 = ml*ml;
94 
95  // 4-momentum of neutrino in lab frame
96  TLorentzVector k1(*(init_state.GetProbeP4(kRfLab)));
97  // 4-momentum of hit nucleon in lab frame
98  TLorentzVector p1(*(evrec->HitNucleon())->P4());
99  TLorentzVector p1_copy(p1);
100  // set temporarily initial nucleon on shell
101  p1.SetE(TMath::Sqrt(p1.P()*p1.P() + M*M));
102  tgt->SetHitNucP4(p1);
103 
104  // neutrino 4-momentun in nucleon rest frame
105  TLorentzVector k1_HNRF = k1;
106  k1_HNRF.Boost(-p1.BoostVector());
107  // neutrino energy in nucleon rest frame
108  double Ev = k1_HNRF.E();
109  // initial nucleon 4-momentun in nucleon rest frame
110  TLorentzVector p1_HNRF(0,0,0,M);
111 
112  //-- Access cross section algorithm for running thread
114  const EventGeneratorI * evg = rtinfo->RunningThread();
115  fXSecModel = evg->CrossSectionAlg();
116 
117  // function gives differential cross section and depends on reduced variables W,Q2,cos(theta) and phi -> 1
119 
120  //-- Get the random number generators
121  RandomGen * rnd = RandomGen::Instance();
122 
123  double xsec = -1;
124  double xin[4];
125 
126  //-- For the subsequent kinematic selection with the rejection method:
127  // Calculate the max differential cross section or retrieve it from the
128  // cache. Throw an exception and quit the evg thread if a non-positive
129  // value is found.
130  // If the kinematics are generated uniformly over the allowed phase
131  // space the max xsec is irrelevant
132  double xsec_max = (fGenerateUniformly) ? -1 : this->MaxXSec(evrec);
133  // generate W, Q2, cos(theta) and phi by accept-reject method
134  unsigned int iter = 0;
135  bool accept = false;
136  while(1)
137  {
138  iter++;
139  if(iter > 100*kRjMaxIterations) {
140  LOG("SPPEventGen", pWARN)
141  << "*** Could not select a valid kinematics variable after "
142  << iter << " iterations";
143  evrec->EventFlags()->SetBitNumber(kKineGenErr, true);
145  exception.SetReason("Couldn't select kinematics");
146  exception.SwitchOnFastForward();
147  throw exception;
148  }
149 
150  xin[0] = rnd->RndKine().Rndm();
151  xin[1] = rnd->RndKine().Rndm();
152  xin[2] = rnd->RndKine().Rndm();
153  xin[3] = rnd->RndKine().Rndm();
154 
155 
156  //-- Computing cross section for the current kinematics
157  xsec = -(*f)(xin);
158 
159  //-- Decide whether to accept the current kinematics
160  if(!fGenerateUniformly)
161  {
162  this->AssertXSecLimits(interaction, xsec, xsec_max);
163  double t = xsec_max * rnd->RndKine().Rndm();
164  accept = (t < xsec);
165  }
166  else
167  {
168  accept = (xsec>0);
169  }
170 
171  // If the generated kinematics are accepted, finish-up module's job
172  if(accept)
173  {
174  // reset 'trust' bits
175  interaction->ResetBit(kISkipProcessChk);
176  interaction->ResetBit(kISkipKinematicChk);
177  break;
178  }
179  iter++;
180  }
181 
182  // W,Q2,cos(theta) and phi from reduced variables
183  Range1D_t Wl = kps.WLim_SPP_iso();
184  if (fWcut >= Wl.min)
185  Wl.max = TMath::Min(fWcut,Wl.max);
186  Range1D_t Q2l = kps.Q2Lim_W_SPP_iso();
187  double W = Wl.min + (Wl.max - Wl.min)*xin[0];
188  interaction->KinePtr()->SetW(W);
189  double Q2 = Q2l.min + (Q2l.max - Q2l.min)*xin[1];
190  double CosTheta_isb = -1. + 2.*xin[2];
191  double SinTheta_isb = (1 - CosTheta_isb*CosTheta_isb)<0?0:TMath::Sqrt(1 - CosTheta_isb*CosTheta_isb);
192  double Phi_isb = 2*kPi*xin[3];
193 
194 
195  // compute x,y for selected W,Q2
196  double x=-1, y=-1;
197  kinematics::WQ2toXY(Ev,M,W,Q2,x,y);
198 
200  {
201  double vol = (Wl.max-Wl.min)*(Q2l.max-Q2l.min)*4*kPi;
202  double totxsec = evrec->XSec();
203  double wght = (vol/totxsec)*xsec;
204  wght *= evrec->Weight();
205  evrec->SetWeight(wght);
206  }
207 
208 
209  // set the cross section for the selected kinematics
210  evrec->SetDiffXSec(xsec,kPSWQ2ctpphipfE);
211 
212  // lock selected kinematics & clear running values
213  interaction->KinePtr()->SetQ2(Q2, true);
214  interaction->KinePtr()->SetW (W, true);
215  interaction->KinePtr()->Setx (x, true);
216  interaction->KinePtr()->Sety (y, true);
217  interaction->KinePtr()->ClearRunningValues();
218 
219 
220  double W2 = W*W;
221  // Kinematical values of all participating particles in the isobaric frame
222  double Enu_isb = (Ev*M - (ml2 + Q2)/2)/W;
223  double El_isb = (Ev*M - (ml2 + W2 - M2)/2)/W;
224  double v_isb = (W2 - M2 - Q2)/2/W;
225  double q_isb = TMath::Sqrt(v_isb*v_isb + Q2);
226  double kz1_isb = 0.5*(q_isb+(Enu_isb*Enu_isb - El_isb*El_isb + ml2)/q_isb);
227  double kz2_isb = kz1_isb - q_isb;
228  double kx1_isb = (Enu_isb*Enu_isb - kz1_isb*kz1_isb)<0?0:TMath::Sqrt(Enu_isb*Enu_isb - kz1_isb*kz1_isb);
229  double Epi_isb = (W2 + mpi2 - M2)/W/2;
230  double ppi_isb = (Epi_isb - mpi)<0?0:TMath::Sqrt(Epi_isb*Epi_isb - mpi2);
231  double E1_isb = (W2 + Q2 + M2)/2/W;
232  double E2_isb = W - Epi_isb;
233 
234  // 4-momentum of all particles in the isobaric frame
235  TLorentzVector k1_isb(kx1_isb, 0, kz1_isb, Enu_isb);
236  TLorentzVector k2_isb(kx1_isb, 0, kz2_isb, El_isb);
237  TLorentzVector p1_isb(0, 0, -q_isb, E1_isb);
238  TLorentzVector p2_isb(-ppi_isb*SinTheta_isb*TMath::Cos(Phi_isb), -ppi_isb*SinTheta_isb*TMath::Sin(Phi_isb), -ppi_isb*CosTheta_isb, E2_isb);
239  TLorentzVector pi_isb( ppi_isb*SinTheta_isb*TMath::Cos(Phi_isb), ppi_isb*SinTheta_isb*TMath::Sin(Phi_isb), ppi_isb*CosTheta_isb, Epi_isb);
240 
241 
242  // boost from isobaric frame to hit nucleon rest frame
243  TVector3 boost = -p1_isb.BoostVector();
244  k1_isb.Boost(boost);
245  k2_isb.Boost(boost);
246  p2_isb.Boost(boost);
247  pi_isb.Boost(boost);
248 
249 
250  // rotation to align 3-momentum of all particles
251  TVector3 rot_vect = k1_isb.Vect().Cross(k1_HNRF.Vect());
252  double rot_angle = k1_isb.Vect().Angle(k1_HNRF.Vect());
253  k2_isb.Rotate(rot_angle, rot_vect);
254  p2_isb.Rotate(rot_angle, rot_vect);
255  pi_isb.Rotate(rot_angle, rot_vect);
256 
257  // boost to laboratory frame
258  boost = p1.BoostVector();
259  k2_isb.Boost(boost);
260  p2_isb.Boost(boost);
261  pi_isb.Boost(boost);
262 
263 
264  tgt->SetHitNucP4(p1_copy);
265 
266  TLorentzVector x4l(*(evrec->Probe())->X4());
267  // add final lepton
268  evrec->AddParticle(interaction->FSPrimLeptonPdg(), kIStStableFinalState, evrec->ProbePosition(), -1, -1, -1, k2_isb, x4l);
269 
271  // add final nucleon
272  evrec->AddParticle(this->GetRecoilNucleonPdgCode(interaction), ist, evrec->HitNucleonPosition(), -1, -1, -1, p2_isb, x4l);
273  // add final pion
274  evrec->AddParticle(this->GetFinalPionPdgCode(interaction), ist, evrec->HitNucleonPosition(), -1, -1, -1, pi_isb, x4l);
275 
276  delete f;
277 
278 
279  return;
280 
281 }
const KPhaseSpace & PhaseSpace(void) const
Definition: Interaction.h:73
bool fGenerateUniformly
uniform over allowed phase space + event weight?
double Q2(const Interaction *const i)
Definition: KineUtils.cxx:1077
static RandomGen * Instance()
Access instance.
Definition: RandomGen.cxx:71
void SetQ2(double Q2, bool selected=false)
Definition: Kinematics.cxx:255
Kinematics * KinePtr(void) const
Definition: Interaction.h:76
int GetRecoilNucleonPdgCode(Interaction *interaction) const
A simple [min,max] interval for doubles.
Definition: Range1.h:42
virtual void AssertXSecLimits(const Interaction *in, double xsec, double xsec_max) const
bool IsNucleus(void) const
Definition: Target.cxx:272
Defines the EventGeneratorI interface.
virtual double MaxXSec(GHepRecord *evrec, const int nkey=0) const
void SetHitNucP4(const TLorentzVector &p4)
Definition: Target.cxx:189
A singleton holding random number generator classes. All random number generation in GENIE should tak...
Definition: RandomGen.h:29
int FSPrimLeptonPdg(void) const
final state primary lepton pdg
double W(const Interaction *const i)
Definition: KineUtils.cxx:1101
Summary information for an interaction.
Definition: Interaction.h:56
Range1D_t Q2Lim_W_SPP_iso(void) const
Q2 limits @ fixed W for resonance single pion production on isoscalar nucleon.
An exception thrown by EventRecordVisitorI when the normal processing sequence has to be disrupted (f...
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
void WQ2toXY(double Ev, double M, double W, double Q2, double &x, double &y)
Definition: KineUtils.cxx:1132
A Neutrino Interaction Target. Is a transparent encapsulation of quite different physical systems suc...
Definition: Target.h:40
Kinematical phase space.
Definition: KPhaseSpace.h:33
const int kPdgPiP
Definition: PDGCodes.h:158
const int kPdgPi0
Definition: PDGCodes.h:160
#define pINFO
Definition: Messenger.h:62
TRandom3 & RndKine(void) const
rnd number generator used by kinematics generators
Definition: RandomGen.h:50
#define pWARN
Definition: Messenger.h:60
const UInt_t kISkipKinematicChk
if set, skip kinematic validity checks
Definition: Interaction.h:48
TParticlePDG * FSPrimLepton(void) const
final state primary lepton
void Setx(double x, bool selected=false)
Definition: Kinematics.cxx:231
static RunningThreadInfo * Instance(void)
double max
Definition: Range1.h:53
void SetW(double W, bool selected=false)
Definition: Kinematics.cxx:279
static PDGLibrary * Instance(void)
Definition: PDGLibrary.cxx:68
Singleton class to load &amp; serve a TDatabasePDG.
Definition: PDGLibrary.h:35
void Sety(double y, bool selected=false)
Definition: Kinematics.cxx:243
virtual const XSecAlgorithmI * CrossSectionAlg(void) const =0
Range1D_t WLim_SPP_iso(void) const
W limits for resonance single pion production on isoscalar nucleon.
const int kPdgPiM
Definition: PDGCodes.h:159
double min
Definition: Range1.h:52
const int kPdgProton
Definition: PDGCodes.h:81
TParticlePDG * Find(int pdgc, bool must_exist=true)
Definition: PDGLibrary.cxx:86
#define pNOTICE
Definition: Messenger.h:61
void ClearRunningValues(void)
Definition: Kinematics.cxx:347
static const unsigned int kRjMaxIterations
Definition: Controls.h:26
const EventGeneratorI * RunningThread(void)
int GetFinalPionPdgCode(Interaction *interaction) const
const int kPdgNeutron
Definition: PDGCodes.h:83
Keep info on the event generation thread currently on charge. This is used so that event generation m...
TLorentzVector * GetProbeP4(RefFrame_t rf=kRfHitNucRest) const
const UInt_t kISkipProcessChk
if set, skip process validity checks
Definition: Interaction.h:47
enum genie::EGHepStatus GHepStatus_t
Initial State information.
Definition: InitialState.h:48

Member Data Documentation

int genie::SPPEventGenerator::fMaxDepth
private

Maximum depth of dividing parent cell.

Definition at line 109 of file SPPEventGenerator.h.

Referenced by ComputeMaxXSec(), and LoadConfig().

double genie::SPPEventGenerator::fWcut
private

Definition at line 70 of file SPPEventGenerator.h.

Referenced by ComputeMaxXSec(), LoadConfig(), and ProcessEventRecord().


The documentation for this class was generated from the following files: