GENIEGenerator
Loading...
Searching...
No Matches
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:
[legend]
Collaboration diagram for genie::HybridXSecAlgorithm:
[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.
double Integral (const Interaction *i) const
bool ValidProcess (const Interaction *i) const
 Can this cross section algorithm handle the input process?
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?
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.

Private Member Functions

void LoadConfig (void)
 Load algorithm configuration.
const XSecAlgorithmIChooseXSecAlg (const Interaction &interaction) const

Private Attributes

std::map< string, const XSecAlgorithmI * > fXSecAlgMap
const XSecAlgorithmIfDefaultXSecAlg
 Optional XSecAlgorithmI to use by default.

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.
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::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

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 \at fnal.gov> Fermi National Acclerator Laboratory
Created:\n November 4, 2019
License:\n Copyright (c) 2003-2025, 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() [1/2]

HybridXSecAlgorithm::HybridXSecAlgorithm ( )

Definition at line 17 of file HybridXSecAlgorithm.cxx.

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

References genie::XSecAlgorithmI::XSecAlgorithmI().

◆ HybridXSecAlgorithm() [2/2]

HybridXSecAlgorithm::HybridXSecAlgorithm ( string config)

Definition at line 21 of file HybridXSecAlgorithm.cxx.

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

References genie::XSecAlgorithmI::XSecAlgorithmI().

◆ ~HybridXSecAlgorithm()

HybridXSecAlgorithm::~HybridXSecAlgorithm ( )
virtual

Definition at line 26 of file HybridXSecAlgorithm.cxx.

27{
28}

Member Function Documentation

◆ ChooseXSecAlg()

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
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}
string RgKey
virtual const Registry & GetConfig(void) const
const Algorithm * SubAlg(const RgKey &registry_key) const
const XSecAlgorithmI * fDefaultXSecAlg
Optional XSecAlgorithmI to use by default.
std::map< string, const XSecAlgorithmI * > fXSecAlgMap
string AsString(void) const
bool Exists(RgKey key) const
item with input key exists?
Definition Registry.cxx:563

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

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

◆ Configure() [1/2]

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.

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.

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

◆ Configure() [2/2]

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.

References genie::XSecAlgorithmI::XSecAlgorithmI().

◆ Integral()

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.

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}
const XSecAlgorithmI * ChooseXSecAlg(const Interaction &interaction) const
virtual double Integral(const Interaction *i) const =0

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

◆ LoadConfig()

void HybridXSecAlgorithm::LoadConfig ( void )
private

Load algorithm configuration.

Definition at line 125 of file HybridXSecAlgorithm.cxx.

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}

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

Referenced by Configure().

◆ ValidProcess()

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.

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

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

◆ XSec()

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 // 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}
virtual double XSec(const Interaction *i, KinePhaseSpace_t k=kPSfE) const =0
Compute the cross section for the input interaction.

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

Member Data Documentation

◆ fDefaultXSecAlg

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

◆ fXSecAlgMap

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: