GENIEGenerator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
genie::XSecLinearCombinations Class Reference

Computes the xsec as a linear combination of different XSecSlgorithmI See GENIE docdb 252. More...

#include <XSecLinearCombinations.h>

Inheritance diagram for genie::XSecLinearCombinations:
Inheritance graph
[legend]
Collaboration diagram for genie::XSecLinearCombinations:
Collaboration graph
[legend]

Public Member Functions

 XSecLinearCombinations ()
 
 XSecLinearCombinations (string config)
 
virtual ~XSecLinearCombinations ()
 
double XSec (const Interaction *i, KinePhaseSpace_t k) const
 Compute the cross section for the input interaction. More...
 
double Integral (const Interaction *i) const
 
bool ValidProcess (const Interaction *i) const
 Can this cross section algorithm handle the input process? More...
 
void Configure (const Registry &config)
 
void Configure (string config)
 
- Public Member Functions inherited from genie::XSecAlgorithmI
virtual ~XSecAlgorithmI ()
 
virtual bool ValidKinematics (const Interaction *i) const
 Is the input kinematical point a physically allowed one? More...
 
- 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

void LoadConfig (void)
 
- Protected Member Functions inherited from genie::XSecAlgorithmI
 XSecAlgorithmI ()
 
 XSecAlgorithmI (string name)
 
 XSecAlgorithmI (string name, string config)
 
- 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
 
template<class T >
int GetParamMat (const std::string &comm_name, TMatrixT< T > &mat, bool is_top_call=true) const
 Handle to load matrix of parameters. More...
 
template<class T >
int GetParamMatSym (const std::string &comm_name, TMatrixTSym< T > &mat, bool is_top_call=true) const
 
int GetParamMatKeys (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

std::vector< const
XSecAlgorithmI * > 
fXSections
 
std::vector< double > fLinearCoefficients
 

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)
 
static string BuildParamMatKey (const std::string &comm_name, unsigned int i, unsigned int j)
 
static string BuildParamMatRowSizeKey (const std::string &comm_name)
 
static string BuildParamMatColSizeKey (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< bool > fOwnerships
 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

Computes the xsec as a linear combination of different XSecSlgorithmI See GENIE docdb 252.

Author
Code contributed by J.Tena Vidal and M.Roda
Created:
Mar 12, 2020
License:
Copyright (c) 2003-2024, The GENIE Collaboration For the full text of the license visit http://copyright.genie-mc.org

Definition at line 27 of file XSecLinearCombinations.h.

Constructor & Destructor Documentation

XSecLinearCombinations::XSecLinearCombinations ( )

Definition at line 18 of file XSecLinearCombinations.cxx.

18  :
19  XSecAlgorithmI("genie::XSecLinearCombinations")
20 {
21 
22 }
XSecLinearCombinations::XSecLinearCombinations ( string  config)

Definition at line 24 of file XSecLinearCombinations.cxx.

24  :
25  XSecAlgorithmI("genie::XSecLinearCombinations", config)
26 {
27 
28 }
XSecLinearCombinations::~XSecLinearCombinations ( )
virtual

Definition at line 30 of file XSecLinearCombinations.cxx.

31 {
32 
33 }

Member Function Documentation

void XSecLinearCombinations::Configure ( const Registry config)
virtual

Configure the algorithm with an external registry The registry is merged with the top level registry if it is owned, Otherwise a copy of it is added with the highest priority

Reimplemented from genie::Algorithm.

Definition at line 84 of file XSecLinearCombinations.cxx.

References genie::Algorithm::Configure(), and LoadConfig().

85 {
86  Algorithm::Configure(config);
87  this->LoadConfig();
88 }
virtual void Configure(const Registry &config)
Definition: Algorithm.cxx:62
void XSecLinearCombinations::Configure ( string  config)
virtual

Configure the algorithm from the AlgoConfigPool based on param_set string given in input An algorithm contains a vector of registries coming from different xml configuration files, which are loaded according a very precise prioriy This methods will load a number registries in order of priority: 1) "Tunable" parameter set from CommonParametes. This is loaded with the highest prioriry and it is designed to be used for tuning procedure Usage not expected from the user. 2) For every string defined in "CommonParame" the corresponding parameter set will be loaded from CommonParameter.xml 3) parameter set specified by the config string and defined in the xml file of the algorithm 4) if config is not "Default" also the Default parameter set from the same xml file will be loaded Effectively this avoids the repetion of a parameter when it is not changed in the requested configuration

Reimplemented from genie::Algorithm.

Definition at line 92 of file XSecLinearCombinations.cxx.

References genie::Algorithm::Configure(), and LoadConfig().

93 {
94  Algorithm::Configure(config);
95  this->LoadConfig();
96 }
virtual void Configure(const Registry &config)
Definition: Algorithm.cxx:62
double XSecLinearCombinations::Integral ( const Interaction i) const
virtual

Integrate the model over the kinematic phase space available to the input interaction (kinematical cuts can be included)

Implements genie::XSecAlgorithmI.

Definition at line 53 of file XSecLinearCombinations.cxx.

References fLinearCoefficients, and fXSections.

54 {
55 
56  double xsec = 0 ;
57  // Store xsec prediction for each entry :
58  for( unsigned int i = 0 ; i < fXSections.size() ; ++ i ) {
59  xsec += ( fXSections[i] -> Integral( interaction ) ) * fLinearCoefficients[i] ;
60  }
61 
62  return xsec;
63 }
double Integral(const Interaction *i) const
std::vector< double > fLinearCoefficients
std::vector< const XSecAlgorithmI * > fXSections
void XSecLinearCombinations::LoadConfig ( void  )
protected

Definition at line 100 of file XSecLinearCombinations.cxx.

References fLinearCoefficients, fXSections, genie::Algorithm::GetParam(), genie::Algorithm::GetParamVect(), genie::Algorithm::GetParamVectKeys(), LOG, pERROR, and genie::Algorithm::SubAlg().

Referenced by Configure().

101 {
102  bool good_config = true ;
103  GetParamVect( "LinearCoefficients", fLinearCoefficients ) ;
104 
105  bool Normalise = false ;
106  GetParam( "Normalise", Normalise ) ;
107 
108  if( Normalise ) {
109  double sum = 0 ;
110  for( unsigned int i = 0 ; i < fLinearCoefficients.size() ; ++i ) {
111  sum += fLinearCoefficients[i] ;
112  }
113 
114  if( sum == 0 ) {
115  good_config = false ;
116  LOG("XSecLinearCombinations", pERROR) << "Sum of linear coefficients is zero. Cannot normalize " ;
117  }
118 
119  for( unsigned int j = 0 ; j < fLinearCoefficients.size() ; ++j ) {
120  fLinearCoefficients[j] /= sum ;
121  }
122  }
123 
124  std::vector<RgKey> XSectionsKeys ;
125  GetParamVectKeys( "CrossSection", XSectionsKeys ) ;
126 
127  if( XSectionsKeys.size() != fLinearCoefficients.size() ) {
128  good_config = false ;
129  LOG("XSecLinearCombinations", pERROR) << "Entries don't match" ;
130  LOG("XSecLinearCombinations", pERROR) << "Cross Sections size: " << XSectionsKeys.size() ;
131  LOG("XSecLinearCombinations", pERROR) << "Linear Coefficients size: " << fLinearCoefficients.size() ;
132  }
133 
134  for( unsigned int i = 0 ; i < XSectionsKeys.size() ; ++i ) {
135  fXSections.push_back( dynamic_cast<const XSecAlgorithmI *> ( this->SubAlg( XSectionsKeys[i] ) ) );
136  if ( ! fXSections[i] ) {
137  good_config = false ;
138  LOG("XSecLinearCombinations", pERROR) << "The SubAlg is not a XSecAlgorithmI";
139  }
140  }
141 
142  if( ! good_config ) {
143  LOG("XSecLinearCombinations", pERROR) << "XSecLinearCombilation Configuration has failed.";
144  exit(78) ;
145  }
146 
147 }
#define pERROR
Definition: Messenger.h:59
int GetParamVect(const std::string &comm_name, std::vector< T > &v, bool is_top_call=true) const
Handle to load vectors of parameters.
std::vector< double > fLinearCoefficients
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
std::vector< const XSecAlgorithmI * > fXSections
int GetParamVectKeys(const std::string &comm_name, std::vector< RgKey > &k, bool is_top_call=true) const
Definition: Algorithm.cxx:555
bool GetParam(const RgKey &name, T &p, bool is_top_call=true) const
const Algorithm * SubAlg(const RgKey &registry_key) const
Definition: Algorithm.cxx:345
bool XSecLinearCombinations::ValidProcess ( const Interaction i) const
virtual

Can this cross section algorithm handle the input process?

Implements genie::XSecAlgorithmI.

Definition at line 67 of file XSecLinearCombinations.cxx.

References fXSections.

68 {
69  bool is_valid = true ;
70 
71  // CHECK THAT THE XSEC USED CONSIDER A VALID PROCESS
72  for( unsigned int i = 0 ; i < fXSections.size() ; ++ i ) {
73  if( ! fXSections[i] -> ValidProcess( interaction ) ) {
74  is_valid = false ;
75  break ;
76  }
77  }
78 
79  return is_valid ;
80 }
bool ValidProcess(const Interaction *i) const
Can this cross section algorithm handle the input process?
std::vector< const XSecAlgorithmI * > fXSections
double XSecLinearCombinations::XSec ( const Interaction i,
KinePhaseSpace_t  k 
) const
virtual

Compute the cross section for the input interaction.

Implements genie::XSecAlgorithmI.

Definition at line 37 of file XSecLinearCombinations.cxx.

References fLinearCoefficients, fXSections, and genie::XSecAlgorithmI::ValidKinematics().

39 {
40  double xsec = 0 ;
41  // Store xsec prediction for each entry :
42  for( unsigned int i = 0 ; i < fXSections.size() ; ++ i ) {
43  if( fXSections[i] -> ValidKinematics( interaction ) ) {
44  xsec += ( fXSections[i] -> XSec( interaction, kps ) ) * fLinearCoefficients[i] ;
45  }
46  }
47 
48  return xsec;
49 }
double XSec(const Interaction *i, KinePhaseSpace_t k) const
Compute the cross section for the input interaction.
std::vector< double > fLinearCoefficients
virtual bool ValidKinematics(const Interaction *i) const
Is the input kinematical point a physically allowed one?
std::vector< const XSecAlgorithmI * > fXSections

Member Data Documentation

std::vector<double> genie::XSecLinearCombinations::fLinearCoefficients
private

Definition at line 52 of file XSecLinearCombinations.h.

Referenced by Integral(), LoadConfig(), and XSec().

std::vector<const XSecAlgorithmI*> genie::XSecLinearCombinations::fXSections
private

Definition at line 51 of file XSecLinearCombinations.h.

Referenced by Integral(), LoadConfig(), ValidProcess(), and XSec().


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