GENIEGenerator
Loading...
Searching...
No Matches
XSecScaleMap.cxx
Go to the documentation of this file.
1//_________________________________________________________________________
2/*
3 Copyright (c) 2003-2025, The GENIE Collaboration
4 For the full text of the license visit http://copyright.genie-mc.org
5
6 Original code contributed by J.Tena and M.Roda
7 Substantial code refactorizations by the core GENIE group.
8*/
9//_________________________________________________________________________
10
16
17using namespace genie;
18
19//_________________________________________________________________________
21 XSecScaleI("genie::XSecScaleMap")
22{
23
24}
25//_________________________________________________________________________
27 XSecScaleI("genie::XSecScaleMap",config)
28{
29
30}
31//_________________________________________________________________________
36//_________________________________________________________________________
37double XSecScaleMap::GetScaling( const Interaction & interaction ) const {
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}
54
55//_________________________________________________________________________
56
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}
111
112//_________________________________________________________________________
#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
Most commonly used PDG codes. A set of utility functions to handle PDG codes is provided in PDGUtils.
string RgKey
virtual const Registry & GetConfig(void) const
const Algorithm * SubAlg(const RgKey &registry_key) const
const Target & Tgt(void) const
Summary information for an interaction.
Definition Interaction.h:56
const InitialState & InitState(void) const
Definition Interaction.h:69
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
int Pdg(void) const
Definition Target.h:71
XSecScaleI(string name, string config="Default")
std::map< int, const XSecScaleI * > fXSecScaleMap
virtual void LoadConfig(void) override
const XSecScaleI * fXSecScaleDefault
virtual double GetScaling(const Interaction &) const override
bool IsIon(int pdgc)
Definition PDGUtils.cxx:42
vector< string > Split(string input, string delim)
THE MAIN GENIE PROJECT NAMESPACE
Definition AlgCmp.h:25