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

Defines an XSecAlgorithmI that delegates the actual calculation to one or more sub-algorithms (each of which is itself an XSecAlgorithmI) based on the input interaction. The choice of sub-algorithms is configurable via XML. More...

#include <HybridXSecAlgorithm.h>

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

Public Member Functions

 HybridXSecAlgorithm ()
 
 HybridXSecAlgorithm (string config)
 
virtual ~HybridXSecAlgorithm ()
 
double XSec (const Interaction *i, KinePhaseSpace_t k) const
 Compute the cross section for the input interaction. More...
 
double Integral (const Interaction *i) const
 
bool ValidProcess (const Interaction *i) const
 Can this cross section algorithm handle the input process? More...
 
void Configure (const Registry &config)
 
void Configure (string config)
 
- Public Member Functions inherited from genie::XSecAlgorithmI
virtual ~XSecAlgorithmI ()
 
virtual bool ValidKinematics (const Interaction *i) const
 Is the input kinematical point a physically allowed one? More...
 
- 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)
 Load algorithm configuration. More...
 
const XSecAlgorithmIChooseXSecAlg (const Interaction &interaction) const
 

Private Attributes

std::map< string, const
XSecAlgorithmI * > 
fXSecAlgMap
 
const XSecAlgorithmIfDefaultXSecAlg
 Optional XSecAlgorithmI to use by default. 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::XSecAlgorithmI
 XSecAlgorithmI ()
 
 XSecAlgorithmI (string name)
 
 XSecAlgorithmI (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::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

Defines an XSecAlgorithmI that delegates the actual calculation to one or more sub-algorithms (each of which is itself an XSecAlgorithmI) based on the input interaction. The choice of sub-algorithms is configurable via XML.

      The current use case is to allow GENIE to simultaneously use the
      SuSAv2 quasielastic cross section model for complex targets and the
      Llewellyn-Smith model for free nucleons.

      Is a concrete implementation of the XSecAlgorithmI interface.
Author
Steven Gardiner <gardiner fnal.gov> Fermi National Acclerator Laboratory
Created:
November 4, 2019
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 35 of file HybridXSecAlgorithm.h.

Constructor & Destructor Documentation

HybridXSecAlgorithm::HybridXSecAlgorithm ( )

Definition at line 17 of file HybridXSecAlgorithm.cxx.

17  : XSecAlgorithmI("genie::HybridXSecAlgorithm")
18 {
19 }
HybridXSecAlgorithm::HybridXSecAlgorithm ( string  config)

Definition at line 21 of file HybridXSecAlgorithm.cxx.

22  : XSecAlgorithmI("genie::HybridXSecAlgorithm", config)
23 {
24 }
HybridXSecAlgorithm::~HybridXSecAlgorithm ( )
virtual

Definition at line 26 of file HybridXSecAlgorithm.cxx.

27 {
28 }

Member Function Documentation

const XSecAlgorithmI * HybridXSecAlgorithm::ChooseXSecAlg ( const Interaction interaction) const
private

Retrieve a pointer to the appropriate cross section algorithm using the map. If no suitable algorithm was found, return a null pointer.

Definition at line 30 of file HybridXSecAlgorithm.cxx.

References genie::Interaction::AsString(), genie::Registry::Exists(), fDefaultXSecAlg, fXSecAlgMap, genie::Algorithm::GetConfig(), and genie::Algorithm::SubAlg().

Referenced by Integral(), ValidProcess(), and XSec().

32 {
33  std::string inter_str = interaction.AsString();
34  RgKey key = "XSecAlg@Interaction=" + inter_str;
35 
36  std::map<std::string, const XSecAlgorithmI*>::const_iterator
37  cend = fXSecAlgMap.cend();
38 
39  std::map<std::string, const XSecAlgorithmI*>::const_iterator
40  citer = fXSecAlgMap.find( key );
41 
42  // If the algorithm doesn't appear in the map, try to load it.
43  if ( citer == cend ) {
44 
45  // If a key exists for the algorithm in the registry, load it
46  // and store it for rapid retrieval later
47  const Registry& temp_reg = this->GetConfig();
48  if ( temp_reg.Exists(key) ) {
49  const XSecAlgorithmI* temp_alg = dynamic_cast< const XSecAlgorithmI* >(
50  this->SubAlg(key) );
51  assert( temp_alg );
52 
53  fXSecAlgMap[ inter_str ] = temp_alg;
54  return temp_alg;
55  }
56 
57  // Otherwise, if the user has specified a default algorithm, then store a
58  // new entry for that one in the map
59  else if ( fDefaultXSecAlg ) {
60  fXSecAlgMap[ inter_str ] = fDefaultXSecAlg;
61  return fDefaultXSecAlg;
62  }
63 
64  // Otherwise, store and return a null pointer. No suitable algorithm could
65  // be found for the requested interaction.
66  else {
67  fXSecAlgMap[ inter_str ] = NULL;
68  return NULL;
69  }
70 
71  }
72 
73  // If an entry was found in the map, then just use that
74  else return citer->second;
75 }
Cross Section Calculation Interface.
string AsString(void) const
virtual const Registry & GetConfig(void) const
Definition: Algorithm.cxx:246
string RgKey
A registry. Provides the container for algorithm configuration parameters.
Definition: Registry.h:65
std::map< string, const XSecAlgorithmI * > fXSecAlgMap
bool Exists(RgKey key) const
item with input key exists?
Definition: Registry.cxx:563
const XSecAlgorithmI * fDefaultXSecAlg
Optional XSecAlgorithmI to use by default.
const Algorithm * SubAlg(const RgKey &registry_key) const
Definition: Algorithm.cxx:345
void HybridXSecAlgorithm::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 113 of file HybridXSecAlgorithm.cxx.

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

114 {
115  Algorithm::Configure(config);
116  this->LoadConfig();
117 }
virtual void Configure(const Registry &config)
Definition: Algorithm.cxx:62
void LoadConfig(void)
Load algorithm configuration.
void genie::HybridXSecAlgorithm::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.

double HybridXSecAlgorithm::Integral ( const Interaction i) const
virtual

Integrate the model over the kinematic phase space available to the input interaction (kinematical cuts can be included)

Implements genie::XSecAlgorithmI.

Definition at line 96 of file HybridXSecAlgorithm.cxx.

References ChooseXSecAlg(), and genie::XSecAlgorithmI::Integral().

97 {
98  const XSecAlgorithmI* alg_to_use = this->ChooseXSecAlg( *interaction );
99 
100  if ( !alg_to_use ) return 0.;
101  else return alg_to_use->Integral( interaction );
102 }
Cross Section Calculation Interface.
const XSecAlgorithmI * ChooseXSecAlg(const Interaction &interaction) const
virtual double Integral(const Interaction *i) const =0
void HybridXSecAlgorithm::LoadConfig ( void  )
private

Load algorithm configuration.

Definition at line 125 of file HybridXSecAlgorithm.cxx.

References genie::Registry::Exists(), fDefaultXSecAlg, genie::Algorithm::GetConfig(), and genie::Algorithm::SubAlg().

Referenced by Configure().

126 {
127  fDefaultXSecAlg = NULL;
128 
129  // The user can optionally configure a cross section algorithm
130  // to use by default (i.e., whenever one wasn't explicitly specified
131  // for an input interaction). If one was given, then configure it.
132  // Handling of the interaction-specific algorithms is done via
133  // lazy initialization in ChooseXSecAlg().
134  const Registry& temp_reg = this->GetConfig();
135  if ( temp_reg.Exists("DefaultXSecAlg") ) {
136  fDefaultXSecAlg = dynamic_cast< const XSecAlgorithmI* >(
137  this->SubAlg("DefaultXSecAlg") );
138  assert( fDefaultXSecAlg );
139  }
140 }
Cross Section Calculation Interface.
virtual const Registry & GetConfig(void) const
Definition: Algorithm.cxx:246
A registry. Provides the container for algorithm configuration parameters.
Definition: Registry.h:65
bool Exists(RgKey key) const
item with input key exists?
Definition: Registry.cxx:563
const XSecAlgorithmI * fDefaultXSecAlg
Optional XSecAlgorithmI to use by default.
const Algorithm * SubAlg(const RgKey &registry_key) const
Definition: Algorithm.cxx:345
bool HybridXSecAlgorithm::ValidProcess ( const Interaction i) const
virtual

Can this cross section algorithm handle the input process?

Implements genie::XSecAlgorithmI.

Definition at line 104 of file HybridXSecAlgorithm.cxx.

References ChooseXSecAlg(), genie::kISkipProcessChk, and genie::XSecAlgorithmI::ValidProcess().

105 {
106  if ( interaction->TestBit(kISkipProcessChk) ) return true;
107 
108  const XSecAlgorithmI* alg_to_use = this->ChooseXSecAlg( *interaction );
109  if ( !alg_to_use ) return false;
110  else return alg_to_use->ValidProcess( interaction );
111 }
Cross Section Calculation Interface.
const XSecAlgorithmI * ChooseXSecAlg(const Interaction &interaction) const
virtual bool ValidProcess(const Interaction *i) const =0
Can this cross section algorithm handle the input process?
const UInt_t kISkipProcessChk
if set, skip process validity checks
Definition: Interaction.h:47
double HybridXSecAlgorithm::XSec ( const Interaction i,
KinePhaseSpace_t  k 
) const
virtual

Compute the cross section for the input interaction.

Implements genie::XSecAlgorithmI.

Definition at line 77 of file HybridXSecAlgorithm.cxx.

References ChooseXSecAlg(), fDefaultXSecAlg, genie::kPSQ2fE, and genie::XSecAlgorithmI::XSec().

79 {
80  const XSecAlgorithmI* alg_to_use = this->ChooseXSecAlg( *interaction );
81 
82  if ( !alg_to_use ) return 0.;
83  // Ad hoc solution of problem with inappropriate kinematic phase space
84  // reported by Julia so she can continue working.
85  // (The reason of problem: it is intended for LlewelynSmith,
86  // BUT also used by Rosenbluth)
87  // A more thoughtful solutions could be
88  // 1. Specify in the configuration file the phase space appropriate
89  // for each algorithm
90  // 2. Implement in RosenbluthPXSec the analog of method
91  // LwlynSmithQELCCPXSec::FullDifferentialXSec - Igor Kakorin
92  if (alg_to_use == fDefaultXSecAlg) return alg_to_use->XSec( interaction, kps );
93  return alg_to_use->XSec( interaction, kPSQ2fE );
94 }
Cross Section Calculation Interface.
const XSecAlgorithmI * ChooseXSecAlg(const Interaction &interaction) const
virtual double XSec(const Interaction *i, KinePhaseSpace_t k=kPSfE) const =0
Compute the cross section for the input interaction.
const XSecAlgorithmI * fDefaultXSecAlg
Optional XSecAlgorithmI to use by default.

Member Data Documentation

const XSecAlgorithmI* genie::HybridXSecAlgorithm::fDefaultXSecAlg
private

Optional XSecAlgorithmI to use by default.

Definition at line 70 of file HybridXSecAlgorithm.h.

Referenced by ChooseXSecAlg(), LoadConfig(), and XSec().

std::map<string, const XSecAlgorithmI*> genie::HybridXSecAlgorithm::fXSecAlgMap
mutableprivate

Map specifying the managed cross section algorithms. Keys are strings generated with Interaction::AsString() (identical to those used for splines). Values are pointers to the corresponding cross section algorithms.

Definition at line 67 of file HybridXSecAlgorithm.h.

Referenced by ChooseXSecAlg().


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