QvalueShifter.cxx
Go to the documentation of this file.
1 //_________________________________________________________________________
2 /*
3  Copyright (c) 2003-2020, 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 //_________________________________________________________________________
39 {
40  Algorithm::Configure(config);
41  this->LoadConfig();
42 }
43 //____________________________________________________________________________
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 //_________________________________________________________________________
THE MAIN GENIE PROJECT NAMESPACE
Definition: AlgCmp.h:25
#define pERROR
Definition: Messenger.h:59
int Pdg(void) const
Definition: Target.h:71
Algorithm abstract base class.
Definition: Algorithm.h:53
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
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
def key(type, name=None)
Definition: graph.py:13
static Config * config
Definition: config.cpp:1054
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:57
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:39
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
second_as<> second
Type of time stored in seconds, in double precision.
Definition: spacetime.h:85