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

Generates kinematics for neutrino-electron events. Is a concrete implementation of the EventRecordVisitorI interface. More...

#include <NuEKinematicsGenerator.h>

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

Public Member Functions

 NuEKinematicsGenerator ()
 
 NuEKinematicsGenerator (string config)
 
 ~NuEKinematicsGenerator ()
 
void ProcessEventRecord (GHepRecord *event_rec) const
 
void Configure (const Registry &config)
 
void Configure (string config)
 
void LoadConfig (void)
 
double ComputeMaxXSec (const Interaction *in) const
 
double Energy (const Interaction *in) const
 
- 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...
 

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 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 kinematics for neutrino-electron events. Is a concrete implementation of the EventRecordVisitorI interface.

Author
Costas Andreopoulos <c.andreopoulos cern.ch> University of Liverpool
Created:
July 13, 2005
License:
Copyright (c) 2003-2024, The GENIE Collaboration For the full text of the license visit http://copyright.genie-mc.org

Definition at line 27 of file NuEKinematicsGenerator.h.

Constructor & Destructor Documentation

NuEKinematicsGenerator::NuEKinematicsGenerator ( )

Definition at line 29 of file NuEKinematicsGenerator.cxx.

29  :
30 KineGeneratorWithCache("genie::NuEKinematicsGenerator")
31 {
32 
33 }
NuEKinematicsGenerator::NuEKinematicsGenerator ( string  config)

Definition at line 35 of file NuEKinematicsGenerator.cxx.

35  :
36 KineGeneratorWithCache("genie::NuEKinematicsGenerator", config)
37 {
38 
39 }
NuEKinematicsGenerator::~NuEKinematicsGenerator ( )

Definition at line 41 of file NuEKinematicsGenerator.cxx.

42 {
43 
44 }

Member Function Documentation

double NuEKinematicsGenerator::ComputeMaxXSec ( const Interaction in) const
virtual

Implements genie::KineGeneratorWithCache.

Definition at line 145 of file NuEKinematicsGenerator.cxx.

References genie::Interaction::AsString(), genie::KineGeneratorWithCache::fSafetyFactor, genie::KineGeneratorWithCache::fXSecModel, genie::Interaction::KinePtr(), genie::kKVy, genie::kPSyfE, genie::KPhaseSpace::Limits(), genie::Range1D_t::max, genie::Range1D_t::min, pDEBUG, genie::Interaction::PhaseSpace(), genie::Kinematics::Sety(), SLOG, and genie::XSecAlgorithmI::XSec().

147 {
148 // Computes the maximum differential cross section in the requested phase
149 // space. This method overloads KineGeneratorWithCache::ComputeMaxXSec
150 // method and the value is cached at a circular cache branch for retrieval
151 // during subsequent event generation.
152 // The computed max differential cross section does not need to be the exact
153 // maximum. The number used in the rejection method will be scaled up by a
154 // safety factor. But it needs to be fast - do not use a very small y step.
155 
156  const int N = 40;
157 //const int Nb = 6;
158 
159  const KPhaseSpace & kps = interaction->PhaseSpace();
160  Range1D_t yl = kps.Limits(kKVy);
161  const double ymin = yl.min;
162  const double ymax = yl.max;
163 
164  double max_xsec = -1.0;
165 
166  double dy = (ymax-ymin)/(N-1);
167 //double xseclast = -1;
168 //bool increasing;
169 
170  for(int i=0; i<N; i++) {
171  double y = ymin + i * dy;
172  interaction->KinePtr()->Sety(y);
173  double xsec = fXSecModel->XSec(interaction, kPSyfE);
174 
175  SLOG("NuEKinematics", pDEBUG) << "xsec(y = " << y << ") = " << xsec;
176  max_xsec = TMath::Max(xsec, max_xsec);
177 /*
178  increasing = xsec-xseclast>=0;
179  xseclast = xsec;
180 
181  // once the cross section stops increasing, I reduce the step size and
182  // step backwards a little bit to handle cases that the max cross section
183  // is grossly underestimated (very peaky distribution & large step)
184  if(!increasing) {
185  dy/=(Nb+1);
186  for(int ib=0; ib<Nb; ib++) {
187  y = y-dy;
188  if(y<ymin) break;
189  interaction->KinePtr()->Sety(y);
190  xsec = fXSecModel->XSec(interaction, kPSyfE);
191  SLOG("NuEKinematics", pDEBUG) << "xsec(y = " << y << ") = " << xsec;
192  max_xsec = TMath::Max(xsec, max_xsec);
193  }
194  break;
195  }
196 */
197  }//y
198 
199  // Apply safety factor, since value retrieved from the cache might
200  // correspond to a slightly different energy.
201  max_xsec *= fSafetyFactor;
202 
203  SLOG("NuEKinematics", pDEBUG) << interaction->AsString();
204  SLOG("NuEKinematics", pDEBUG) << "Max xsec in phase space = " << max_xsec;
205  SLOG("NuEKinematics", pDEBUG) << "Computed using alg = " << *fXSecModel;
206 
207  return max_xsec;
208 }
double fSafetyFactor
ComputeMaxXSec -&gt; ComputeMaxXSec * fSafetyFactor.
A simple [min,max] interval for doubles.
Definition: Range1.h:42
Range1D_t Limits(KineVar_t kvar) const
Return the kinematical variable limits.
Kinematical phase space.
Definition: KPhaseSpace.h:33
virtual double XSec(const Interaction *i, KinePhaseSpace_t k=kPSfE) const =0
Compute the cross section for the input interaction.
double max
Definition: Range1.h:53
double min
Definition: Range1.h:52
#define SLOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a short string (using the FUNCTION and...
Definition: Messenger.h:84
#define pDEBUG
Definition: Messenger.h:63
void NuEKinematicsGenerator::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 220 of file NuEKinematicsGenerator.cxx.

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

221 {
222  Algorithm::Configure(config);
223  this->LoadConfig();
224 }
virtual void Configure(const Registry &config)
Definition: Algorithm.cxx:62
void NuEKinematicsGenerator::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 226 of file NuEKinematicsGenerator.cxx.

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

227 {
228  Algorithm::Configure(config);
229  this->LoadConfig();
230 }
virtual void Configure(const Registry &config)
Definition: Algorithm.cxx:62
double NuEKinematicsGenerator::Energy ( const Interaction in) const
virtual

Reimplemented from genie::KineGeneratorWithCache.

Definition at line 210 of file NuEKinematicsGenerator.cxx.

References genie::Interaction::InitState(), genie::kRfLab, and genie::InitialState::ProbeE().

211 {
212 // Override the base class Energy() method to cache the max xsec for the
213 // neutrino energy in the LAB rather than in the hit nucleon rest frame.
214 
215  const InitialState & init_state = interaction->InitState();
216  double E = init_state.ProbeE(kRfLab);
217  return E;
218 }
double ProbeE(RefFrame_t rf) const
Initial State information.
Definition: InitialState.h:48
void NuEKinematicsGenerator::LoadConfig ( void  )

Definition at line 232 of file NuEKinematicsGenerator.cxx.

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

Referenced by Configure().

233 {
234  GetParamDef( "MaxXSec-SafetyFactor", fSafetyFactor, 2.00 ) ;
235  GetParamDef( "Cache-MinEnergy", fEMin, 1.00 ) ;
236 
237  GetParamDef("MaxXSec-DiffTolerance", fMaxXSecDiffTolerance, 0. ) ;
238  assert(fMaxXSecDiffTolerance>=0);
239 
240  //-- Generate kinematics uniformly over allowed phase space and compute
241  // an event weight?
242  GetParamDef( "UniformOverPhaseSpace", fGenerateUniformly, false ) ;
243 
244 }
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
void NuEKinematicsGenerator::ProcessEventRecord ( GHepRecord event_rec) const
virtual

Implements genie::EventRecordVisitorI.

Definition at line 46 of file NuEKinematicsGenerator.cxx.

References genie::KineGeneratorWithCache::AssertXSecLimits(), genie::Kinematics::ClearRunningValues(), genie::EventGeneratorI::CrossSectionAlg(), genie::GHepRecord::EventFlags(), genie::KineGeneratorWithCache::fGenerateUniformly, genie::KineGeneratorWithCache::fXSecModel, genie::RunningThreadInfo::Instance(), genie::RandomGen::Instance(), genie::Interaction::KinePtr(), genie::kKineGenErr, genie::kKVy, genie::kPSyfE, genie::controls::kRjMaxIterations, genie::KPhaseSpace::Limits(), LOG, genie::Range1D_t::max, genie::KineGeneratorWithCache::MaxXSec(), genie::Range1D_t::min, pDEBUG, genie::Interaction::PhaseSpace(), genie::utils::kinematics::PhaseSpaceVolume(), pINFO, pNOTICE, pWARN, genie::RandomGen::RndKine(), genie::RunningThreadInfo::RunningThread(), genie::GHepRecord::SetDiffXSec(), genie::exceptions::EVGThreadException::SetReason(), genie::GHepRecord::SetWeight(), genie::Kinematics::Sety(), genie::GHepRecord::Summary(), genie::exceptions::EVGThreadException::SwitchOnFastForward(), genie::GHepRecord::Weight(), genie::XSecAlgorithmI::XSec(), and genie::GHepRecord::XSec().

47 {
48  if(fGenerateUniformly) {
49  LOG("NuEKinematics", pNOTICE)
50  << "Generating kinematics uniformly over the allowed phase space";
51  }
52 
53  //-- Get the random number generators
55 
56  //-- Access cross section algorithm for running thread
58  const EventGeneratorI * evg = rtinfo->RunningThread();
59  fXSecModel = evg->CrossSectionAlg();
60 
61  //-- For the subsequent kinematic selection with the rejection method:
62  // Calculate the max differential cross section or retrieve it from the
63  // cache. Throw an exception and quit the evg thread if a non-positive
64  // value is found.
65  // If the kinematics are generated uniformly over the allowed phase
66  // space the max xsec is irrelevant
67  double xsec_max = (fGenerateUniformly) ? -1 : this->MaxXSec(evrec);
68 
69  //-- y range
70  const KPhaseSpace & kps = evrec->Summary()->PhaseSpace();
71  Range1D_t yl = kps.Limits(kKVy);
72  double ymin = yl.min;
73  double ymax = yl.max;
74  double dy = ymax-ymin;
75 
76  double xsec = -1;
77  Interaction * interaction = evrec->Summary();
78 
79  //-- Try to select a valid inelastisity y
80  unsigned int iter = 0;
81  bool accept = false;
82  while(1) {
83  iter++;
84  if(iter > kRjMaxIterations) {
85  LOG("NuEKinematics", pWARN)
86  << "*** Could not select a valid y after "
87  << iter << " iterations";
88  evrec->EventFlags()->SetBitNumber(kKineGenErr, true);
90  exception.SetReason("Couldn't select kinematics");
91  exception.SwitchOnFastForward();
92  throw exception;
93  }
94 
95  double y = ymin + dy * rnd->RndKine().Rndm();
96  interaction->KinePtr()->Sety(y);
97 
98  LOG("NuEKinematics", pINFO) << "Trying: y = " << y;
99 
100  //-- computing cross section for the current kinematics
101  xsec = fXSecModel->XSec(interaction, kPSyfE);
102 
103  //-- decide whether to accept the current kinematics
104  if(!fGenerateUniformly) {
105  this->AssertXSecLimits(interaction, xsec, xsec_max);
106 
107  double t = xsec_max * rnd->RndKine().Rndm();
108  LOG("NuEKinematics", pDEBUG) << "xsec= "<< xsec<< ", J= 1, Rnd= "<< t;
109 
110  accept = (t<xsec);
111  } else {
112  accept = (xsec>0);
113  }
114 
115  //-- If the generated kinematics are accepted, finish-up module's job
116  if(accept) {
117  LOG("NuEKinematics", pINFO) << "Selected: y = " << y;
118 
119  // set the cross section for the selected kinematics
120  evrec->SetDiffXSec(xsec,kPSyfE);
121 
122  // for uniform kinematics, compute an event weight as
123  // wght = (phase space volume)*(differential xsec)/(event total xsec)
124  if(fGenerateUniformly) {
125  double vol = kinematics::PhaseSpaceVolume(interaction,kPSyfE);
126  double totxsec = evrec->XSec();
127  double wght = (vol/totxsec)*xsec;
128  LOG("NuEKinematics", pNOTICE) << "Kinematics wght = "<< wght;
129 
130  // apply computed weight to the current event weight
131  wght *= evrec->Weight();
132  LOG("NuEKinematics", pNOTICE) << "Current event wght = " << wght;
133  evrec->SetWeight(wght);
134  }
135 
136  // lock selected kinematics & clear running values
137  interaction->KinePtr()->Sety(y, true);
138  interaction->KinePtr()->ClearRunningValues();
139 
140  return;
141  }
142  }// iterations
143 }
bool fGenerateUniformly
uniform over allowed phase space + event weight?
static RandomGen * Instance()
Access instance.
Definition: RandomGen.cxx:71
Kinematics * KinePtr(void) const
Definition: Interaction.h:76
A simple [min,max] interval for doubles.
Definition: Range1.h:42
virtual void AssertXSecLimits(const Interaction *in, double xsec, double xsec_max) const
Defines the EventGeneratorI interface.
virtual double MaxXSec(GHepRecord *evrec, const int nkey=0) const
A singleton holding random number generator classes. All random number generation in GENIE should tak...
Definition: RandomGen.h:29
Range1D_t Limits(KineVar_t kvar) const
Return the kinematical variable limits.
double PhaseSpaceVolume(const Interaction *const i, KinePhaseSpace_t ps)
Definition: KineUtils.cxx:36
Summary information for an interaction.
Definition: Interaction.h:56
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
Kinematical phase space.
Definition: KPhaseSpace.h:33
#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
virtual double XSec(const Interaction *i, KinePhaseSpace_t k=kPSfE) const =0
Compute the cross section for the input interaction.
static RunningThreadInfo * Instance(void)
double max
Definition: Range1.h:53
void Sety(double y, bool selected=false)
Definition: Kinematics.cxx:243
virtual const XSecAlgorithmI * CrossSectionAlg(void) const =0
double min
Definition: Range1.h:52
#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)
Keep info on the event generation thread currently on charge. This is used so that event generation m...
#define pDEBUG
Definition: Messenger.h:63

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