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

This class is responsible to compute a scaling factor for the XSec. More...

#include <XSecScaleMap.h>

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

Public Member Functions

 XSecScaleMap ()
 XSecScaleMap (string config)
virtual ~XSecScaleMap ()
virtual double GetScaling (const Interaction &) const override
Public Member Functions inherited from genie::XSecScaleI
virtual ~XSecScaleI ()
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.

Protected Member Functions

virtual void LoadConfig (void) override
Protected Member Functions inherited from genie::XSecScaleI
 XSecScaleI (string name, string config="Default")
void Configure (const Registry &config) override
virtual void Configure (string config) override
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.

Private Attributes

const XSecScaleIfXSecScaleDefault
std::map< int, const XSecScaleI * > fXSecScaleMap

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

This class is responsible to compute a scaling factor for the XSec.

Author
Code contributed by J.Tena Vidal and M.Roda
Created:\n June, 2020
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 25 of file XSecScaleMap.h.

Constructor & Destructor Documentation

◆ XSecScaleMap() [1/2]

XSecScaleMap::XSecScaleMap ( )

Definition at line 20 of file XSecScaleMap.cxx.

20 :
21 XSecScaleI("genie::XSecScaleMap")
22{
23
24}
XSecScaleI(string name, string config="Default")

References genie::XSecScaleI::XSecScaleI().

◆ XSecScaleMap() [2/2]

XSecScaleMap::XSecScaleMap ( string config)

Definition at line 26 of file XSecScaleMap.cxx.

26 :
27 XSecScaleI("genie::XSecScaleMap",config)
28{
29
30}

References genie::XSecScaleI::XSecScaleI().

◆ ~XSecScaleMap()

XSecScaleMap::~XSecScaleMap ( )
virtual

Definition at line 32 of file XSecScaleMap.cxx.

33{
34
35}

Member Function Documentation

◆ GetScaling()

double XSecScaleMap::GetScaling ( const Interaction & interaction) const
overridevirtual

Implements genie::XSecScaleI.

Definition at line 37 of file XSecScaleMap.cxx.

37 {
38 // This function accesses the requested Algoritm given the Pdg code and
39 // it retrieves the appropiate scaling.
40 // Get Target pdg
41 int pdg_target = interaction.InitState().Tgt().Pdg() ;
42
43 const auto it = fXSecScaleMap.find(pdg_target) ;
44 if ( it != fXSecScaleMap.end() ) {
45 return (it -> second)->GetScaling( interaction ) ;
46 }
47 if ( fXSecScaleDefault ) {
48 // return default
49 return fXSecScaleDefault->GetScaling( interaction ) ;
50 }
51 return 1. ;
52
53}
const Target & Tgt(void) const
const InitialState & InitState(void) const
Definition Interaction.h:69
int Pdg(void) const
Definition Target.h:71
std::map< int, const XSecScaleI * > fXSecScaleMap
const XSecScaleI * fXSecScaleDefault

References fXSecScaleDefault, fXSecScaleMap, genie::Interaction::InitState(), genie::Target::Pdg(), and genie::InitialState::Tgt().

◆ LoadConfig()

void XSecScaleMap::LoadConfig ( void )
overrideprotectedvirtual

Implements genie::XSecScaleI.

Definition at line 57 of file XSecScaleMap.cxx.

58{
59 bool good_config = true ;
60 fXSecScaleDefault = nullptr ;
61 fXSecScaleMap.clear() ;
62
63 // Store default value
64 static RgKey default_algo_name = "XSecScaleDefaultAlg" ;
65 if( GetConfig().Exists(default_algo_name) ) {
66 fXSecScaleDefault = dynamic_cast<const XSecScaleI *> ( this->SubAlg(default_algo_name) );
67 if( !fXSecScaleDefault ) {
68 good_config = false ;
69 LOG("XSecScaleMap", pERROR) << "The subalgorithm with ID couldn't be casted " ;
70 // << SubAlg(default_algo_name)->Id() << " couldn't be casted " ;
71 }
72
73 }
74
75 // Get possible entries to pdg - shift map
76 auto kpdg_list = GetConfig().FindKeys("XSecScaleAlg@Pdg=") ;
77
78 for( auto kiter = kpdg_list.begin(); kiter != kpdg_list.end(); ++kiter ) {
79 const RgKey & key = *kiter ;
80 vector<string> kv = genie::utils::str::Split(key,"=");
81 assert(kv.size()==2);
82 int pdg_target = stoi( kv[1] );
83 if( ! PDGLibrary::Instance()->Find(pdg_target) ) {
84 good_config = false ;
85 LOG("XSecScaleMap", pERROR) << "The target Pdg code associated is not valid : " << pdg_target ;
86 continue ;
87 }
88
89 if( ! pdg::IsIon(pdg_target) ) {
90 good_config = false ;
91 LOG("XSecScaleMap", pERROR) << "The target Pdg code does not correspond to a Ion : " << pdg_target ;
92 continue ;
93 }
94
95 const auto algo = fXSecScaleMap[pdg_target] = dynamic_cast<const XSecScaleI*> ( this->SubAlg( key ) );
96 if( ! algo ) {
97 good_config = false ;
98 LOG("XSecScaleMap", pERROR) << "The subalgorithm " << GetConfig().GetAlg(key).name
99 << " and target pdg " << pdg_target << " do not exist" ;
100 continue ;
101 }
102
103 }
104
105 if( ! good_config ) {
106 LOG("XSecScaleMap", pERROR) << "Configuration has failed.";
107 exit(78) ;
108 }
109
110}
#define pERROR
Definition Messenger.h:59
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE,...
Definition Messenger.h:96
string RgKey
virtual const Registry & GetConfig(void) const
const Algorithm * SubAlg(const RgKey &registry_key) const
static PDGLibrary * Instance(void)
RgAlg GetAlg(RgKey key) const
Definition Registry.cxx:488
RgKeyList FindKeys(RgKey key_part) const
create list with all keys containing 'key_part'
Definition Registry.cxx:840
bool IsIon(int pdgc)
Definition PDGUtils.cxx:42
vector< string > Split(string input, string delim)

References genie::Registry::FindKeys(), fXSecScaleDefault, fXSecScaleMap, genie::Registry::GetAlg(), genie::Algorithm::GetConfig(), genie::PDGLibrary::Instance(), genie::pdg::IsIon(), LOG, RgAlg::name, pERROR, genie::utils::str::Split(), genie::Algorithm::SubAlg(), and genie::XSecScaleI::XSecScaleI().

Member Data Documentation

◆ fXSecScaleDefault

const XSecScaleI* genie::XSecScaleMap::fXSecScaleDefault
private

Definition at line 41 of file XSecScaleMap.h.

Referenced by GetScaling(), and LoadConfig().

◆ fXSecScaleMap

std::map<int,const XSecScaleI *> genie::XSecScaleMap::fXSecScaleMap
private

Definition at line 42 of file XSecScaleMap.h.

Referenced by GetScaling(), and LoadConfig().


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