GENIEGenerator
Loading...
Searching...
No Matches
QvalueShifter.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
17
18using namespace genie;
19
20//_________________________________________________________________________
22 Algorithm("genie::QvalueShifter")
23{
24
25}
26//_________________________________________________________________________
28 Algorithm("genie::QvalueShifter",config)
29{
30
31}
32//_________________________________________________________________________
37//_________________________________________________________________________
39{
41 this->LoadConfig();
42}
43//____________________________________________________________________________
44void QvalueShifter::Configure(string config)
45{
47 this->LoadConfig();
48}
49//_________________________________________________________________________
50
51 double QvalueShifter::Shift( const Target & target ) const {
52 // Get Target pdg
53 int pdg_target = target.Pdg() ;
54
55 const auto it = fRelShift.find(pdg_target) ;
56 if ( it != fRelShift.end() ) {
57 return it -> second ;
58 } else {
59 // return default
60 return fRelShiftDefault ;
61 }
62
63 }
64
65//_________________________________________________________________________
66
67 double QvalueShifter::Shift( const Interaction & interaction ) const {
68 // This function allows the flexibility to add shift as a function of
69 // the interaction type.
70 // Right now, we just call the default :
71 return Shift( interaction.InitState().Tgt() ) ;
72 }
73
74//_________________________________________________________________________
75
77{
78 bool good_config = true ;
79 // Store default value
80 GetParam( "QvalueShiftDefault", fRelShiftDefault ) ;
81
82 // Clear map
83 fRelShift.clear() ;
84
85 // Get possible entries to pdg - shift map
86 auto kpdg_list = GetConfig().FindKeys("QvalueShift@Pdg=") ;
87
88 for( auto kiter = kpdg_list.begin(); kiter != kpdg_list.end(); ++kiter ) {
89 const RgKey & key = *kiter ;
90 vector<string> kv = genie::utils::str::Split(key,"=");
91 assert(kv.size()==2);
92 int pdg_target = stoi( kv[1] );
93 if( ! PDGLibrary::Instance()->Find(pdg_target) ) {
94 LOG("QvalueShifter", pERROR) << "The target Pdg code associated to the QvalueShift is not valid : " << pdg_target ;
95 good_config = false ;
96 continue ;
97 }
98
99 if( ! pdg::IsIon(pdg_target) ) {
100 LOG("QvalueShifter", pERROR) << "The target Pdg code does not correspond to a Ion : " << pdg_target ;
101 good_config = false ;
102 continue ;
103 }
104 GetParam( key, fRelShift[pdg_target] ) ;
105 }
106
107 if( ! good_config ) {
108 LOG("QvalueShifter", pERROR) << "Configuration has failed.";
109 exit(78) ;
110 }
111
112}
113
114//_________________________________________________________________________
#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
bool GetParam(const RgKey &name, T &p, bool is_top_call=true) const
virtual void Configure(const Registry &config)
Definition Algorithm.cxx:62
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)
virtual double Shift(const Target &target) const
void Configure(const Registry &config)
std::map< int, double > fRelShift
A registry. Provides the container for algorithm configuration parameters.
Definition Registry.h:65
RgKeyList FindKeys(RgKey key_part) const
create list with all keys containing 'key_part'
Definition Registry.cxx:840
A Neutrino Interaction Target. Is a transparent encapsulation of quite different physical systems suc...
Definition Target.h:40
int Pdg(void) const
Definition Target.h:71
bool IsIon(int pdgc)
Definition PDGUtils.cxx:42
vector< string > Split(string input, string delim)
THE MAIN GENIE PROJECT NAMESPACE
Definition AlgCmp.h:25