GENIEGenerator
Loading...
Searching...
No Matches
genie::DMEKinematicsGenerator Class Reference

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

#include <DMEKinematicsGenerator.h>

Inheritance diagram for genie::DMEKinematicsGenerator:
[legend]
Collaboration diagram for genie::DMEKinematicsGenerator:
[legend]

Public Member Functions

 DMEKinematicsGenerator ()
 DMEKinematicsGenerator (string config)
 ~DMEKinematicsGenerator ()
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.
virtual AlgStatus_t GetStatus (void) const
 Get algorithm status.
virtual bool AllowReconfig (void) const
virtual AlgCmp_t Compare (const Algorithm *alg) const
 Compare with input algorithm.
virtual void SetId (const AlgId &id)
 Set algorithm ID.
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.

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.
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.
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.
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
int AddLowRegistry (Registry *rp, bool owns=true)
 add registry with lowest priority, also update ownership
int MergeTopRegistry (const Registry &r)
int AddTopRegisties (const vector< Registry * > &rs, bool owns=false)
 Add registries with top priority, also udated Ownerships.
Protected Attributes inherited from genie::KineGeneratorWithCache
const XSecAlgorithmIfXSecModel
double fSafetyFactor
 ComputeMaxXSec -> ComputeMaxXSec * fSafetyFactor.
std::vector< double > vSafetyFactors
 MaxXSec -> MaxXSec * fSafetyFactors[nkey].
int fNumOfSafetyFactors
 Number of given safety factors.
std::vector< string > vInterpolatorTypes
 Type of interpolator for each key in a branch.
int fNumOfInterpolatorTypes
 Number of given interpolators types.
double fMaxXSecDiffTolerance
 max{100*(xsec-maxxsec)/.5*(xsec+maxxsec)} if xsec>maxxsec
double fEMin
 min E for which maxxsec is cached - forcing explicit calc.
bool fGenerateUniformly
 uniform over allowed phase space + event weight?
Protected Attributes inherited from genie::Algorithm
bool fAllowReconfig
bool fOwnsSubstruc
 true if it owns its substructure (sub-algs,...)
AlgId fID
 algorithm name and configuration set
vector< Registry * > fConfVect
vector< bool > fOwnerships
 ownership for every registry in fConfVect
AlgStatus_t fStatus
 algorithm execution status
AlgMapfOwnedSubAlgMp
 local pool for owned sub-algs (taken out of the factory pool)

Detailed Description

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

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

Definition at line 28 of file DMEKinematicsGenerator.h.

Constructor & Destructor Documentation

◆ DMEKinematicsGenerator() [1/2]

DMEKinematicsGenerator::DMEKinematicsGenerator ( )

Definition at line 40 of file DMEKinematicsGenerator.cxx.

40 :
41KineGeneratorWithCache("genie::DMEKinematicsGenerator")
42{
43
44}

References genie::KineGeneratorWithCache::KineGeneratorWithCache().

◆ DMEKinematicsGenerator() [2/2]

DMEKinematicsGenerator::DMEKinematicsGenerator ( string config)

Definition at line 46 of file DMEKinematicsGenerator.cxx.

46 :
47KineGeneratorWithCache("genie::DMEKinematicsGenerator", config)
48{
49
50}

References genie::KineGeneratorWithCache::KineGeneratorWithCache().

◆ ~DMEKinematicsGenerator()

DMEKinematicsGenerator::~DMEKinematicsGenerator ( )

Definition at line 52 of file DMEKinematicsGenerator.cxx.

53{
54
55}

Member Function Documentation

◆ ComputeMaxXSec()

double DMEKinematicsGenerator::ComputeMaxXSec ( const Interaction * in) const
virtual

Implements genie::KineGeneratorWithCache.

Definition at line 156 of file DMEKinematicsGenerator.cxx.

158{
159// Computes the maximum differential cross section in the requested phase
160// space. This method overloads KineGeneratorWithCache::ComputeMaxXSec
161// method and the value is cached at a circular cache branch for retrieval
162// during subsequent event generation.
163// The computed max differential cross section does not need to be the exact
164// maximum. The number used in the rejection method will be scaled up by a
165// safety factor. But it needs to be fast - do not use a very small y step.
166
167 const int N = 40;
168//const int Nb = 6;
169
170 const KPhaseSpace & kps = interaction->PhaseSpace();
171 Range1D_t yl = kps.Limits(kKVy);
172 const double ymin = yl.min;
173 const double ymax = yl.max;
174
175 double max_xsec = -1.0;
176
177 double dy = (ymax-ymin)/(N-1);
178//double xseclast = -1;
179//bool increasing;
180
181 for(int i=0; i<N; i++) {
182 double y = ymin + i * dy;
183 interaction->KinePtr()->Sety(y);
184 double xsec = fXSecModel->XSec(interaction, kPSyfE);
185
186 SLOG("DMEKinematics", pDEBUG) << "xsec(y = " << y << ") = " << xsec;
187 max_xsec = TMath::Max(xsec, max_xsec);
188/*
189 increasing = xsec-xseclast>=0;
190 xseclast = xsec;
191
192 // once the cross section stops increasing, I reduce the step size and
193 // step backwards a little bit to handle cases that the max cross section
194 // is grossly underestimated (very peaky distribution & large step)
195 if(!increasing) {
196 dy/=(Nb+1);
197 for(int ib=0; ib<Nb; ib++) {
198 y = y-dy;
199 if(y<ymin) break;
200 interaction->KinePtr()->Sety(y);
201 xsec = fXSecModel->XSec(interaction, kPSyfE);
202 SLOG("DMEKinematics", pDEBUG) << "xsec(y = " << y << ") = " << xsec;
203 max_xsec = TMath::Max(xsec, max_xsec);
204 }
205 break;
206 }
207*/
208 }//y
209
210 // Apply safety factor, since value retrieved from the cache might
211 // correspond to a slightly different energy.
212 max_xsec *= fSafetyFactor;
213
214 SLOG("DMEKinematics", pDEBUG) << interaction->AsString();
215 SLOG("DMEKinematics", pDEBUG) << "Max xsec in phase space = " << max_xsec;
216 SLOG("DMEKinematics", pDEBUG) << "Computed using alg = " << *fXSecModel;
217
218 return max_xsec;
219}
#define pDEBUG
Definition Messenger.h:63
#define SLOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a short string (using the FUNCTION and...
Definition Messenger.h:84
Range1D_t Limits(KineVar_t kvar) const
Return the kinematical variable limits.
double fSafetyFactor
ComputeMaxXSec -> ComputeMaxXSec * fSafetyFactor.
@ kKVy
Definition KineVar.h:32

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(), and SLOG.

◆ Configure() [1/2]

void DMEKinematicsGenerator::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 231 of file DMEKinematicsGenerator.cxx.

232{
233 Algorithm::Configure(config);
234 this->LoadConfig();
235}
virtual void Configure(const Registry &config)
Definition Algorithm.cxx:62

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

◆ Configure() [2/2]

void DMEKinematicsGenerator::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 237 of file DMEKinematicsGenerator.cxx.

238{
239 Algorithm::Configure(config);
240 this->LoadConfig();
241}

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

◆ Energy()

double DMEKinematicsGenerator::Energy ( const Interaction * in) const
virtual

Reimplemented from genie::KineGeneratorWithCache.

Definition at line 221 of file DMEKinematicsGenerator.cxx.

222{
223// Override the base class Energy() method to cache the max xsec for the
224// neutrino energy in the LAB rather than in the hit nucleon rest frame.
225
226 const InitialState & init_state = interaction->InitState();
227 double E = init_state.ProbeE(kRfLab);
228 return E;
229}
double ProbeE(RefFrame_t rf) const
@ kRfLab
Definition RefFrame.h:26

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

◆ LoadConfig()

void DMEKinematicsGenerator::LoadConfig ( void )

Definition at line 243 of file DMEKinematicsGenerator.cxx.

244{
245 GetParamDef( "MaxXSec-SafetyFactor", fSafetyFactor, 2.00 ) ;
246 GetParamDef( "Cache-MinEnergy", fEMin, 1.00 ) ;
247
248 GetParamDef("MaxXSec-DiffTolerance", fMaxXSecDiffTolerance, 0. ) ;
249 assert(fMaxXSecDiffTolerance>=0);
250
251 //-- Generate kinematics uniformly over allowed phase space and compute
252 // an event weight?
253 GetParamDef( "UniformOverPhaseSpace", fGenerateUniformly, false ) ;
254
255}
bool GetParamDef(const RgKey &name, T &p, const T &def) 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.

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

Referenced by Configure(), and Configure().

◆ ProcessEventRecord()

void DMEKinematicsGenerator::ProcessEventRecord ( GHepRecord * event_rec) const
virtual

Implements genie::EventRecordVisitorI.

Definition at line 57 of file DMEKinematicsGenerator.cxx.

58{
60 LOG("DMEKinematics", pNOTICE)
61 << "Generating kinematics uniformly over the allowed phase space";
62 }
63
64 //-- Get the random number generators
65 RandomGen * rnd = RandomGen::Instance();
66
67 //-- Access cross section algorithm for running thread
68 RunningThreadInfo * rtinfo = RunningThreadInfo::Instance();
69 const EventGeneratorI * evg = rtinfo->RunningThread();
71
72 //-- For the subsequent kinematic selection with the rejection method:
73 // Calculate the max differential cross section or retrieve it from the
74 // cache. Throw an exception and quit the evg thread if a non-positive
75 // value is found.
76 // If the kinematics are generated uniformly over the allowed phase
77 // space the max xsec is irrelevant
78 double xsec_max = (fGenerateUniformly) ? -1 : this->MaxXSec(evrec);
79
80 //-- y range
81 const KPhaseSpace & kps = evrec->Summary()->PhaseSpace();
82 Range1D_t yl = kps.Limits(kKVy);
83 double ymin = yl.min;
84 double ymax = yl.max;
85 double dy = ymax-ymin;
86
87 double xsec = -1;
88 Interaction * interaction = evrec->Summary();
89
90 //-- Try to select a valid inelastisity y
91 unsigned int iter = 0;
92 bool accept = false;
93 while(1) {
94 iter++;
95 if(iter > kRjMaxIterations) {
96 LOG("DMEKinematics", pWARN)
97 << "*** Could not select a valid y after "
98 << iter << " iterations";
99 evrec->EventFlags()->SetBitNumber(kKineGenErr, true);
100 genie::exceptions::EVGThreadException exception;
101 exception.SetReason("Couldn't select kinematics");
102 exception.SwitchOnFastForward();
103 throw exception;
104 }
105
106 double y = ymin + dy * rnd->RndKine().Rndm();
107 interaction->KinePtr()->Sety(y);
108
109 LOG("DMEKinematics", pINFO) << "Trying: y = " << y;
110
111 //-- computing cross section for the current kinematics
112 xsec = fXSecModel->XSec(interaction, kPSyfE);
113
114 //-- decide whether to accept the current kinematics
115 if(!fGenerateUniformly) {
116 this->AssertXSecLimits(interaction, xsec, xsec_max);
117
118 double t = xsec_max * rnd->RndKine().Rndm();
119 LOG("DMEKinematics", pDEBUG) << "xsec= "<< xsec<< ", J= 1, Rnd= "<< t;
120
121 accept = (t<xsec);
122 } else {
123 accept = (xsec>0);
124 }
125
126 //-- If the generated kinematics are accepted, finish-up module's job
127 if(accept) {
128 LOG("DMEKinematics", pINFO) << "Selected: y = " << y;
129
130 // set the cross section for the selected kinematics
131 evrec->SetDiffXSec(xsec,kPSyfE);
132
133 // for uniform kinematics, compute an event weight as
134 // wght = (phase space volume)*(differential xsec)/(event total xsec)
136 double vol = kinematics::PhaseSpaceVolume(interaction,kPSyfE);
137 double totxsec = evrec->XSec();
138 double wght = (vol/totxsec)*xsec;
139 LOG("DMEKinematics", pNOTICE) << "Kinematics wght = "<< wght;
140
141 // apply computed weight to the current event weight
142 wght *= evrec->Weight();
143 LOG("DMEKinematics", pNOTICE) << "Current event wght = " << wght;
144 evrec->SetWeight(wght);
145 }
146
147 // lock selected kinematics & clear running values
148 interaction->KinePtr()->Sety(y, true);
149 interaction->KinePtr()->ClearRunningValues();
150
151 return;
152 }
153 }// iterations
154}
#define pNOTICE
Definition Messenger.h:61
#define pINFO
Definition Messenger.h:62
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE,...
Definition Messenger.h:96
#define pWARN
Definition Messenger.h:60
virtual const XSecAlgorithmI * CrossSectionAlg(void) const =0
Kinematics * KinePtr(void) const
Definition Interaction.h:76
virtual void AssertXSecLimits(const Interaction *in, double xsec, double xsec_max) const
virtual double MaxXSec(GHepRecord *evrec, const int nkey=0) const
void ClearRunningValues(void)
void Sety(double y, bool selected=false)
static RandomGen * Instance()
Access instance.
Definition RandomGen.cxx:74
TRandom3 & RndKine(void) const
rnd number generator used by kinematics generators
Definition RandomGen.h:50
static RunningThreadInfo * Instance(void)
const EventGeneratorI * RunningThread(void)
static const unsigned int kRjMaxIterations
Definition Controls.h:26
double PhaseSpaceVolume(const Interaction *const i, KinePhaseSpace_t ps)
Definition KineUtils.cxx:36
@ kKineGenErr
Definition GHepFlags.h:31

References genie::KineGeneratorWithCache::AssertXSecLimits(), genie::Kinematics::ClearRunningValues(), genie::EventGeneratorI::CrossSectionAlg(), genie::GHepRecord::EventFlags(), genie::KineGeneratorWithCache::fGenerateUniformly, genie::KineGeneratorWithCache::fXSecModel, genie::RandomGen::Instance(), genie::RunningThreadInfo::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(), and genie::GHepRecord::XSec().


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