GENIEGenerator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
QvalueShifter.cxx
Go to the documentation of this file.
1 //_________________________________________________________________________
2 /*
3  Copyright (c) 2003-2024, 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 
18 using namespace genie;
19 
20 //_________________________________________________________________________
22  Algorithm("genie::QvalueShifter")
23 {
24 
25 }
26 //_________________________________________________________________________
28  Algorithm("genie::QvalueShifter",config)
29 {
30 
31 }
32 //_________________________________________________________________________
34 {
35 
36 }
37 //_________________________________________________________________________
38 void QvalueShifter::Configure(const Registry & config)
39 {
40  Algorithm::Configure(config);
41  this->LoadConfig();
42 }
43 //____________________________________________________________________________
44 void QvalueShifter::Configure(string config)
45 {
46  Algorithm::Configure(config);
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
int Pdg(void) const
Definition: Target.h:71
Algorithm abstract base class.
Definition: Algorithm.h:54
virtual const Registry & GetConfig(void) const
Definition: Algorithm.cxx:246
Summary information for an interaction.
Definition: Interaction.h:56
RgKeyList FindKeys(RgKey key_part) const
create list with all keys containing &#39;key_part&#39;
Definition: Registry.cxx:840
static constexpr double second
Definition: Units.h:37
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
A Neutrino Interaction Target. Is a transparent encapsulation of quite different physical systems suc...
Definition: Target.h:40
virtual void Configure(const Registry &config)
Definition: Algorithm.cxx:62
virtual double Shift(const Target &target) const
static PDGLibrary * Instance(void)
Definition: PDGLibrary.cxx:68
std::map< int, double > fRelShift
Definition: QvalueShifter.h:49
vector< string > Split(string input, string delim)
Definition: StringUtils.cxx:36
bool IsIon(int pdgc)
Definition: PDGUtils.cxx:42
string RgKey
A registry. Provides the container for algorithm configuration parameters.
Definition: Registry.h:65
void Configure(const Registry &config)
const InitialState & InitState(void) const
Definition: Interaction.h:69
bool GetParam(const RgKey &name, T &p, bool is_top_call=true) const
const Target & Tgt(void) const
Definition: InitialState.h:66