Public Member Functions | Protected Member Functions | Private Attributes | List of all members
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:
genie::XSecScaleI genie::Algorithm

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. More...
 
virtual AlgStatus_t GetStatus (void) const
 Get algorithm status. More...
 
virtual bool AllowReconfig (void) const
 
virtual AlgCmp_t Compare (const Algorithm *alg) const
 Compare with input algorithm. More...
 
virtual void SetId (const AlgId &id)
 Set algorithm ID. More...
 
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. More...
 

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. More...
 
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. More...
 
int GetParamVectKeys (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 More...
 
int AddLowRegistry (Registry *rp, bool owns=true)
 add registry with lowest priority, also update ownership More...
 
int MergeTopRegistry (const Registry &r)
 
int AddTopRegisties (const vector< Registry * > &rs, bool owns=false)
 Add registries with top priority, also udated Ownerships. More...
 

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)
 
- Protected Attributes inherited from genie::Algorithm
bool fAllowReconfig
 
bool fOwnsSubstruc
 true if it owns its substructure (sub-algs,...) More...
 
AlgId fID
 algorithm name and configuration set More...
 
vector< Registry * > fConfVect
 
vector< boolfOwnerships
 ownership for every registry in fConfVect More...
 
AlgStatus_t fStatus
 algorithm execution status More...
 
AlgMapfOwnedSubAlgMp
 local pool for owned sub-algs (taken out of the factory pool) More...
 

Detailed Description

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

Author
Code contributed by J.Tena Vidal and M.Roda

June, 2020

Copyright (c) 2003-2020, 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::XSecScaleMap ( )

Definition at line 20 of file XSecScaleMap.cxx.

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

Definition at line 26 of file XSecScaleMap.cxx.

26  :
27  XSecScaleI("genie::XSecScaleMap",config)
28 {
29 
30 }
XSecScaleI(string name, string config="Default")
Definition: XSecScaleI.cxx:16
static Config * config
Definition: config.cpp:1054
XSecScaleMap::~XSecScaleMap ( )
virtual

Definition at line 32 of file XSecScaleMap.cxx.

33 {
34 
35 }

Member Function Documentation

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 }
int Pdg(void) const
Definition: Target.h:71
std::map< int, const XSecScaleI * > fXSecScaleMap
Definition: XSecScaleMap.h:42
virtual double GetScaling(const Interaction &) const =0
const InitialState & InitState(void) const
Definition: Interaction.h:69
const Target & Tgt(void) const
Definition: InitialState.h:66
const XSecScaleI * fXSecScaleDefault
Definition: XSecScaleMap.h:41
second_as<> second
Type of time stored in seconds, in double precision.
Definition: spacetime.h:85
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
This class is responsible to compute a scaling factor for the XSec.
Definition: XSecScaleI.h:25
virtual const Registry & GetConfig(void) const
Definition: Algorithm.cxx:246
std::map< int, const XSecScaleI * > fXSecScaleMap
Definition: XSecScaleMap.h:42
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 PDGLibrary * Instance(void)
Definition: PDGLibrary.cxx:57
vector< string > Split(string input, string delim)
Definition: StringUtils.cxx:36
bool IsIon(int pdgc)
Definition: PDGUtils.cxx:39
string RgKey
const XSecScaleI * fXSecScaleDefault
Definition: XSecScaleMap.h:41
RgAlg GetAlg(RgKey key) const
Definition: Registry.cxx:488
const Algorithm * SubAlg(const RgKey &registry_key) const
Definition: Algorithm.cxx:345

Member Data Documentation

const XSecScaleI* genie::XSecScaleMap::fXSecScaleDefault
private

Definition at line 41 of file XSecScaleMap.h.

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

Definition at line 42 of file XSecScaleMap.h.


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