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:
genie::XSecAlgorithmI genie::Algorithm

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)
 
- 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
 
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< 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

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

November 4, 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 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 }
static Config * config
Definition: config.cpp:1054
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.

32 {
33  std::string inter_str = interaction.AsString();
34  RgKey key = "XSecAlg@Interaction=" + inter_str;
35 
37  cend = fXSecAlgMap.cend();
38 
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.
decltype(auto) constexpr cend(T &&obj)
ADL-aware version of std::cend.
Definition: StdUtils.h:87
std::string string
Definition: nybbler.cc:12
intermediate_table::const_iterator const_iterator
string AsString(void) const
virtual const Registry & GetConfig(void) const
Definition: Algorithm.cxx:246
def key(type, name=None)
Definition: graph.py:13
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 103 of file HybridXSecAlgorithm.cxx.

104 {
105  Algorithm::Configure(config);
106  this->LoadConfig();
107 }
virtual void Configure(const Registry &config)
Definition: Algorithm.cxx:62
void LoadConfig(void)
Load algorithm configuration.
void HybridXSecAlgorithm::Configure ( std::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 109 of file HybridXSecAlgorithm.cxx.

110 {
112  this->LoadConfig();
113 }
static Config * config
Definition: config.cpp:1054
virtual void Configure(const Registry &config)
Definition: Algorithm.cxx:62
void LoadConfig(void)
Load algorithm configuration.
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 86 of file HybridXSecAlgorithm.cxx.

87 {
88  const XSecAlgorithmI* alg_to_use = this->ChooseXSecAlg( *interaction );
89 
90  if ( !alg_to_use ) return 0.;
91  else return alg_to_use->Integral( interaction );
92 }
Cross Section Calculation Interface.
virtual double Integral(const Interaction *i) const =0
const XSecAlgorithmI * ChooseXSecAlg(const Interaction &interaction) const
void HybridXSecAlgorithm::LoadConfig ( void  )
private

Load algorithm configuration.

Definition at line 115 of file HybridXSecAlgorithm.cxx.

116 {
117  fDefaultXSecAlg = NULL;
118 
119  // The user can optionally configure a cross section algorithm
120  // to use by default (i.e., whenever one wasn't explicitly specified
121  // for an input interaction). If one was given, then configure it.
122  // Handling of the interaction-specific algorithms is done via
123  // lazy initialization in ChooseXSecAlg().
124  const Registry& temp_reg = this->GetConfig();
125  if ( temp_reg.Exists("DefaultXSecAlg") ) {
126  fDefaultXSecAlg = dynamic_cast< const XSecAlgorithmI* >(
127  this->SubAlg("DefaultXSecAlg") );
128  assert( fDefaultXSecAlg );
129  }
130 }
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 94 of file HybridXSecAlgorithm.cxx.

95 {
96  if ( interaction->TestBit(kISkipProcessChk) ) return true;
97 
98  const XSecAlgorithmI* alg_to_use = this->ChooseXSecAlg( *interaction );
99  if ( !alg_to_use ) return false;
100  else return alg_to_use->ValidProcess( interaction );
101 }
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.

79 {
80  const XSecAlgorithmI* alg_to_use = this->ChooseXSecAlg( *interaction );
81 
82  if ( !alg_to_use ) return 0.;
83  else return alg_to_use->XSec( interaction, kps );
84 }
Cross Section Calculation Interface.
virtual double XSec(const Interaction *i, KinePhaseSpace_t k=kPSfE) const =0
Compute the cross section for the input interaction.
const XSecAlgorithmI * ChooseXSecAlg(const Interaction &interaction) const

Member Data Documentation

const XSecAlgorithmI* genie::HybridXSecAlgorithm::fDefaultXSecAlg
private

Optional XSecAlgorithmI to use by default.

Definition at line 70 of file HybridXSecAlgorithm.h.

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.


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