Public Member Functions | List of all members
genie::GLRESKinematicsGenerator Class Reference

Generates values for the kinematic variables describing Glashow resonance. Is a concrete implementation of the EventRecordVisitorI interface. Part of its implementation, related with the caching and retrieval of previously computed values, is inherited from the KineGeneratorWithCache abstract class. More...

#include <GLRESKinematicsGenerator.h>

Inheritance diagram for genie::GLRESKinematicsGenerator:
genie::KineGeneratorWithCache genie::EventRecordVisitorI genie::Algorithm

Public Member Functions

 GLRESKinematicsGenerator ()
 
 GLRESKinematicsGenerator (string config)
 
 ~GLRESKinematicsGenerator ()
 
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)
 
- Protected Member Functions inherited from genie::KineGeneratorWithCache
 KineGeneratorWithCache ()
 
 KineGeneratorWithCache (string name)
 
 KineGeneratorWithCache (string name, string config)
 
 ~KineGeneratorWithCache ()
 
virtual double MaxXSec (GHepRecord *evrec) const
 
virtual double FindMaxXSec (const Interaction *in) const
 
virtual void CacheMaxXSec (const Interaction *in, double xsec) const
 
virtual CacheBranchFxAccessCacheBranch (const Interaction *in) 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
 
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
 maxxsec -> maxxsec * safety_factor 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< boolfOwnerships
 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 values for the kinematic variables describing Glashow resonance. Is a concrete implementation of the EventRecordVisitorI interface. Part of its implementation, related with the caching and retrieval of previously computed values, is inherited from the KineGeneratorWithCache abstract class.

Author
Alfonso Garcia <alfonsog nikhef.nl> NIKHEF (Amsterdam)

November 8, 2019

Copyright (c) 2003-2019, The GENIE Collaboration For the full text of the license visit http://copyright.genie-mc.org or see $GENIE/LICENSE

Definition at line 29 of file GLRESKinematicsGenerator.h.

Constructor & Destructor Documentation

GLRESKinematicsGenerator::GLRESKinematicsGenerator ( )

Definition at line 35 of file GLRESKinematicsGenerator.cxx.

35  :
36 KineGeneratorWithCache("genie::GLRESKinematicsGenerator")
37 {
38 
39 }
GLRESKinematicsGenerator::GLRESKinematicsGenerator ( string  config)

Definition at line 41 of file GLRESKinematicsGenerator.cxx.

41  :
42 KineGeneratorWithCache("genie::GLRESKinematicsGenerator", config)
43 {
44 
45 }
static Config * config
Definition: config.cpp:1054
GLRESKinematicsGenerator::~GLRESKinematicsGenerator ( )

Definition at line 47 of file GLRESKinematicsGenerator.cxx.

48 {
49 
50 }

Member Function Documentation

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

Implements genie::KineGeneratorWithCache.

Definition at line 132 of file GLRESKinematicsGenerator.cxx.

134 {
135 // Computes the maximum differential cross section in the requested phase
136 // space. This method overloads KineGeneratorWithCache::ComputeMaxXSec
137 // method and the value is cached at a circular cache branch for retrieval
138 // during subsequent event generation.
139 // The computed max differential cross section does not need to be the exact
140 // maximum. The number used in the rejection method will be scaled up by a
141 // safety factor. But it needs to be fast - do not use a very small y step.
142 
143  const int N = 100;
144 
145  const KPhaseSpace & kps = interaction->PhaseSpace();
146  Range1D_t yl = kps.Limits(kKVy);
147  const double ymin = yl.min;
148  const double ymax = yl.max;
149 
150  double max_xsec = -1.0;
151 
152  double dy = (ymax-ymin)/(N-1);
153 
154  for(int i=0; i<N; i++) {
155  double y = ymin + i * dy;
156  interaction->KinePtr()->Sety(y);
157  double xsec = fXSecModel->XSec(interaction, kPSyfE);
158 
159  SLOG("GLRESKinematics", pDEBUG) << "xsec(y = " << y << ") = " << xsec;
160  max_xsec = TMath::Max(xsec, max_xsec);
161 
162  }//y
163 
164  // Apply safety factor, since value retrieved from the cache might
165  // correspond to a slightly different energy.
166  max_xsec *= fSafetyFactor;
167 
168  SLOG("GLRESKinematics", pDEBUG) << interaction->AsString();
169  SLOG("GLRESKinematics", pDEBUG) << "Max xsec in phase space = " << max_xsec;
170  SLOG("GLRESKinematics", pDEBUG) << "Computed using alg = " << *fXSecModel;
171 
172  return max_xsec;
173 }
double fSafetyFactor
maxxsec -> maxxsec * safety_factor
virtual double XSec(const Interaction *i, KinePhaseSpace_t k=kPSfE) const =0
Compute the cross section for the input interaction.
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
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 GLRESKinematicsGenerator::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 185 of file GLRESKinematicsGenerator.cxx.

186 {
187  Algorithm::Configure(config);
188  this->LoadConfig();
189 }
virtual void Configure(const Registry &config)
Definition: Algorithm.cxx:62
void GLRESKinematicsGenerator::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 191 of file GLRESKinematicsGenerator.cxx.

192 {
194  this->LoadConfig();
195 }
static Config * config
Definition: config.cpp:1054
virtual void Configure(const Registry &config)
Definition: Algorithm.cxx:62
double GLRESKinematicsGenerator::Energy ( const Interaction in) const
virtual

Reimplemented from genie::KineGeneratorWithCache.

Definition at line 175 of file GLRESKinematicsGenerator.cxx.

176 {
177 // Override the base class Energy() method to cache the max xsec for the
178 // neutrino energy in the LAB rather than in the hit nucleon rest frame.
179 
180  const InitialState & init_state = interaction->InitState();
181  double E = init_state.ProbeE(kRfLab);
182  return E;
183 }
E
Definition: 018_def.c:13
double ProbeE(RefFrame_t rf) const
Initial State information.
Definition: InitialState.h:48
void GLRESKinematicsGenerator::LoadConfig ( void  )

Definition at line 197 of file GLRESKinematicsGenerator.cxx.

198 {
199 // Reads its configuration data from its configuration Registry and loads them
200 // in private data members to avoid looking up at the Registry all the time.
201 
202  //-- Safety factor for the maximum differential cross section
203  GetParamDef( "MaxXSec-SafetyFactor", fSafetyFactor, 2. ) ;
204 
205  //-- Maximum allowed fractional cross section deviation from maxim cross
206  // section used in rejection method
207  GetParamDef( "MaxXSec-DiffTolerance", fMaxXSecDiffTolerance, 999999. ) ;
208  assert(fMaxXSecDiffTolerance>=0);
209 
210 }
double fSafetyFactor
maxxsec -> maxxsec * safety_factor
double fMaxXSecDiffTolerance
max{100*(xsec-maxxsec)/.5*(xsec+maxxsec)} if xsec>maxxsec
bool GetParamDef(const RgKey &name, T &p, const T &def) const
void GLRESKinematicsGenerator::ProcessEventRecord ( GHepRecord event_rec) const
virtual

Implements genie::EventRecordVisitorI.

Definition at line 52 of file GLRESKinematicsGenerator.cxx.

53 {
54  if(fGenerateUniformly) {
55  LOG("GLRESKinematics", pNOTICE)
56  << "Generating kinematics uniformly over the allowed phase space";
57  }
58 
59  //-- Get the random number generators
61 
62  //-- Access cross section algorithm for running thread
64  const EventGeneratorI * evg = rtinfo->RunningThread();
65  fXSecModel = evg->CrossSectionAlg();
66 
67  //-- For the subsequent kinematic selection with the rejection method:
68  // Calculate the max differential cross section or retrieve it from the
69  // cache. Throw an exception and quit the evg thread if a non-positive
70  // value is found.
71  // If the kinematics are generated uniformly over the allowed phase
72  // space the max xsec is irrelevant
73  double xsec_max = this->MaxXSec(evrec);
74 
75  //-- y range
76  const KPhaseSpace & kps = evrec->Summary()->PhaseSpace();
77  Range1D_t yl = kps.Limits(kKVy);
78  double ymin = yl.min;
79  double ymax = yl.max;
80  double dy = ymax-ymin;
81 
82  double xsec = -1;
83  Interaction * interaction = evrec->Summary();
84 
85  //-- Try to select a valid inelastisity y
86  unsigned int iter = 0;
87  bool accept = false;
88  while(1) {
89  iter++;
90  if(iter > kRjMaxIterations) {
91  LOG("GLRESKinematics", pWARN)
92  << "*** Could not select a valid y after "
93  << iter << " iterations";
94  evrec->EventFlags()->SetBitNumber(kKineGenErr, true);
96  exception.SetReason("Couldn't select kinematics");
97  exception.SwitchOnFastForward();
98  throw exception;
99  }
100 
101  double y = ymin + dy * rnd->RndKine().Rndm();
102  interaction->KinePtr()->Sety(y);
103 
104  LOG("GLRESKinematics", pINFO) << "Trying: y = " << y;
105 
106  //-- computing cross section for the current kinematics
107  xsec = fXSecModel->XSec(interaction, kPSyfE);
108 
109  this->AssertXSecLimits(interaction, xsec, xsec_max);
110 
111  double t = xsec_max * rnd->RndKine().Rndm();
112  LOG("GLRESKinematics", pDEBUG) << "xsec= "<< xsec<< ", J= 1, Rnd= "<< t;
113 
114  accept = (t<xsec);
115 
116  //-- If the generated kinematics are accepted, finish-up module's job
117  if(accept) {
118  LOG("GLRESKinematics", pINFO) << "Selected: y = " << y;
119 
120  // set the cross section for the selected kinematics
121  evrec->SetDiffXSec(xsec,kPSyfE);
122 
123  // lock selected kinematics & clear running values
124  interaction->KinePtr()->Sety(y, true);
125  interaction->KinePtr()->ClearRunningValues();
126 
127  return;
128  }
129  }// iterations
130 }
virtual double MaxXSec(GHepRecord *evrec) const
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
virtual double XSec(const Interaction *i, KinePhaseSpace_t k=kPSfE) const =0
Compute the cross section for the input interaction.
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.
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.
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 const XSecAlgorithmI * CrossSectionAlg(void) const =0
static RunningThreadInfo * Instance(void)
double max
Definition: Range1.h:53
void Sety(double y, bool selected=false)
Definition: Kinematics.cxx:243
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...
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
#define pDEBUG
Definition: Messenger.h:63

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