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

This class is responsible to compute the MEC scaling factor given Q0, Q3. The scaling is done as a function of the hadronic invariant mass. More...

#include <MECScaleVsW.h>

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

Public Member Functions

 MECScaleVsW ()
 
 MECScaleVsW (string config)
 
virtual ~MECScaleVsW ()
 
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
 
virtual double GetScaling (const double Q0, const double Q3) const
 
weight_type_map GetMapWithLimits (const double Q0, const double Q3) const
 
virtual double ScaleFunction (const double W, const weight_type_pair min, const weight_type_pair max) const
 
- 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
 
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 Types

using weight_type_map = std::map< double, double >
 
using weight_type_pair = std::pair< double, double >
 

Private Attributes

double fDefaultWeight
 
weight_type_map fWeightsMap
 
TSpline3 fW1_Q0Q3_limits
 
double fLowLimitWeight
 
double fUpperLimitWeight
 

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

This class is responsible to compute the MEC scaling factor given Q0, Q3. The scaling is done as a function of the hadronic invariant mass.

Author
Code contributed by J.Tena Vidal and M.Roda
Created:
June, 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 MECScaleVsW.h.

Member Typedef Documentation

using genie::MECScaleVsW::weight_type_map = std::map<double,double>
private

Definition at line 29 of file MECScaleVsW.h.

using genie::MECScaleVsW::weight_type_pair = std::pair<double,double>
private

Definition at line 30 of file MECScaleVsW.h.

Constructor & Destructor Documentation

MECScaleVsW::MECScaleVsW ( )

Definition at line 19 of file MECScaleVsW.cxx.

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

Definition at line 25 of file MECScaleVsW.cxx.

25  :
26  XSecScaleI("genie::MECScaleVsW",config)
27 {
28 
29 }
XSecScaleI(string name, string config="Default")
Definition: XSecScaleI.cxx:16
MECScaleVsW::~MECScaleVsW ( )
virtual

Definition at line 31 of file MECScaleVsW.cxx.

32 {
33 
34 }

Member Function Documentation

MECScaleVsW::weight_type_map MECScaleVsW::GetMapWithLimits ( const double  Q0,
const double  Q3 
) const
protected

Definition at line 77 of file MECScaleVsW.cxx.

References genie::PDGLibrary::Find(), fLowLimitWeight, fUpperLimitWeight, fW1_Q0Q3_limits, fWeightsMap, genie::PDGLibrary::Instance(), genie::kPdgNeutron, and genie::kPdgProton.

Referenced by GetScaling().

77  {
78  // This function is responsible to add the phase space limits in the WValues vector in case they are not included
79  // in the configuration setup.
80 
81  static double Mn = ( PDGLibrary::Instance()->Find(kPdgProton)->Mass() + PDGLibrary::Instance()->Find(kPdgNeutron)->Mass() ) * 0.5 ; // Nucleon mass
82  double W_min = sqrt( pow(Mn,2) + 2*Mn*fW1_Q0Q3_limits.Eval(Q3) - pow(Q3,2) + pow(fW1_Q0Q3_limits.Eval(Q3),2) ) ;
83  double W_max = sqrt( pow(Mn,2) + 2*Mn*Q0 ) ; // Imposing Q2 = 0
84 
85  // Insert phase space limits:
87  w_map.insert( weight_type_pair( W_max, fUpperLimitWeight ) ) ;
88  w_map.insert( weight_type_pair( W_min, fLowLimitWeight ) ) ;
89 
90  return w_map ;
91 }
std::pair< double, double > weight_type_pair
Definition: MECScaleVsW.h:30
std::map< double, double > weight_type_map
Definition: MECScaleVsW.h:29
double fLowLimitWeight
Definition: MECScaleVsW.h:61
weight_type_map fWeightsMap
Definition: MECScaleVsW.h:57
static PDGLibrary * Instance(void)
Definition: PDGLibrary.cxx:68
const int kPdgProton
Definition: PDGCodes.h:81
double fUpperLimitWeight
Definition: MECScaleVsW.h:62
TParticlePDG * Find(int pdgc, bool must_exist=true)
Definition: PDGLibrary.cxx:86
const int kPdgNeutron
Definition: PDGCodes.h:83
TSpline3 fW1_Q0Q3_limits
Definition: MECScaleVsW.h:59
double MECScaleVsW::GetScaling ( const Interaction interaction) const
overridevirtual

Implements genie::XSecScaleI.

Definition at line 36 of file MECScaleVsW.cxx.

References genie::Kinematics::GetKV(), genie::Interaction::Kine(), genie::kKVQ0, and genie::kKVQ3.

37 {
38  double Q0 = interaction.Kine().GetKV(kKVQ0) ;
39  double Q3 = interaction.Kine().GetKV(kKVQ3) ;
40 
41  return GetScaling( Q0, Q3 ) ;
42 }
virtual double GetScaling(const Interaction &) const override
Definition: MECScaleVsW.cxx:36
const Kinematics & Kine(void) const
Definition: Interaction.h:71
double GetKV(KineVar_t kv) const
Definition: Kinematics.cxx:323
double MECScaleVsW::GetScaling ( const double  Q0,
const double  Q3 
) const
protectedvirtual

Definition at line 44 of file MECScaleVsW.cxx.

References fDefaultWeight, genie::PDGLibrary::Find(), GetMapWithLimits(), genie::PDGLibrary::Instance(), genie::kPdgNeutron, genie::kPdgProton, ScaleFunction(), and genie::utils::kinematics::W().

45 {
46  // Get the vectors that include the kinematic limits of W for a given event:
47  MECScaleVsW::weight_type_map weight_map = GetMapWithLimits( Q0, Q3 ) ;
48 
49  // The Scaling is done using the "experimenter's W", which assumes a single nucleon
50  // See motivation in : https://arxiv.org/pdf/1601.02038.pdf
51  // Calculate event W:
52  static double Mn = ( PDGLibrary::Instance()->Find(kPdgProton)->Mass() + PDGLibrary::Instance()->Find(kPdgNeutron)->Mass() ) * 0.5 ; // Nucleon mass
53  double W = pow(Mn,2) + 2*Mn*Q0 - pow(Q3,2) + pow(Q0,2) ;
54  // Do not scale if W<0. This can happen while we try to get the correct kinematics.
55  // If the kinematics is not correct, W can be negative, and we scale with a nan.
56  // To avoid this we do this check.
57  if ( W < 0 ) return 1. ;
58  W = sqrt( W ) ;
59 
60  // Calculate scaling:
61  MECScaleVsW::weight_type_map::iterator it_min = weight_map.begin() ;
62  MECScaleVsW::weight_type_map::iterator it_max = std::next( weight_map.begin(), weight_map.size() -1 ) ;
63 
64  if ( W < it_min->first || W > it_max->first ) return fDefaultWeight ;
65 
66  while ( std::distance( it_min, it_max ) > 1 ) {
67  unsigned int step = std::distance( weight_map.begin(), it_min ) + std::distance( it_min, it_max ) / 2 ;
68  MECScaleVsW::weight_type_map::iterator it_middle = std::next( weight_map.begin(), step ) ;
69  if ( W < it_middle->first ) it_max = it_middle ;
70  else it_min = it_middle ;
71  }
72 
73  return ScaleFunction( W, *it_min, *it_max ) ;
74 }
double W(const Interaction *const i)
Definition: KineUtils.cxx:1101
weight_type_map GetMapWithLimits(const double Q0, const double Q3) const
Definition: MECScaleVsW.cxx:77
std::map< double, double > weight_type_map
Definition: MECScaleVsW.h:29
virtual double ScaleFunction(const double W, const weight_type_pair min, const weight_type_pair max) const
Definition: MECScaleVsW.cxx:94
static PDGLibrary * Instance(void)
Definition: PDGLibrary.cxx:68
const int kPdgProton
Definition: PDGCodes.h:81
TParticlePDG * Find(int pdgc, bool must_exist=true)
Definition: PDGLibrary.cxx:86
const int kPdgNeutron
Definition: PDGCodes.h:83
void MECScaleVsW::LoadConfig ( void  )
overrideprotectedvirtual

Implements genie::XSecScaleI.

Definition at line 103 of file MECScaleVsW.cxx.

References fDefaultWeight, fLowLimitWeight, fUpperLimitWeight, fW1_Q0Q3_limits, fWeightsMap, genie::Algorithm::GetConfig(), genie::Algorithm::GetParam(), genie::Algorithm::GetParamDef(), genie::Algorithm::GetParamVect(), LOG, and pERROR.

104 {
105  bool good_config = true ;
106  // Reset members
107  fWeightsMap.clear();
108 
109  if( GetConfig().Exists("MECScaleVsW-Default-Weight") ) {
110  GetParam( "MECScaleVsW-Default-Weight", fDefaultWeight ) ;
111  } else {
112  good_config = false ;
113  LOG("MECScaleVsW", pERROR) << "Default weight is not specified." ;
114  }
115 
116  std::vector<double> Weights, WValues ;
117  GetParamVect( "MECScaleVsW-Weights", Weights, false ) ;
118  GetParamVect( "MECScaleVsW-WValues", WValues, false ) ;
119 
120  if( Weights.size() != WValues.size() ) {
121  good_config = false ;
122  LOG("MECScaleVsW", pERROR) << "Entries don't match" ;
123  LOG("MECScaleVsW", pERROR) << "Weights size: " << Weights.size() ;
124  LOG("MECScaleVsW", pERROR) << "WValues size: " << WValues.size() ;
125  }
126 
127  // Store weights and WValues in map:
128  for( unsigned int i = 0 ; i<Weights.size() ; ++i ) {
129  fWeightsMap.insert( weight_type_pair( WValues[i], Weights[i] ) ) ;
130  }
131 
132  std::vector<double> limit_Q0, limit_Q3 ;
133  if( GetParamVect( "MECScaleVsW-LowerLimitQ0", limit_Q0 ) == 0 ) {
134  good_config = false ;
135  LOG("MECScaleVsW", pERROR) << "MECScaleVsW-LowerLimitQ0 is empty" ;
136  }
137 
138  if( GetParamVect( "MECScaleVsW-LowerLimitQ3", limit_Q3 ) == 0 ) {
139  good_config = false ;
140  LOG("MECScaleVsW", pERROR) << "MECScaleVsW-LowerLimitQ3 is empty" ;
141  }
142 
143  if( limit_Q0.size() != limit_Q3.size() ) {
144  good_config = false ;
145  LOG("MECScaleVsW", pERROR) << "Entries don't match" ;
146  LOG("MECScaleVsW", pERROR) << "Lower limit for Q0 size: " << limit_Q0.size() ;
147  LOG("MECScaleVsW", pERROR) << "Lower limit for Q3 size: " << limit_Q3.size() ;
148  }
149 
150  GetParamDef("MECScleVsW-LowerLimit-Weight", fLowLimitWeight, fDefaultWeight ) ;
151  GetParamDef("MECScleVsW-UpperLimit-Weight", fUpperLimitWeight, fDefaultWeight ) ;
152 
153  if( ! good_config ) {
154  LOG("MECScaleVsW", pERROR) << "Configuration has failed.";
155  exit(78) ;
156  }
157 
158  fW1_Q0Q3_limits = TSpline3("fW1_Q0Q3_limits",limit_Q3.data(),limit_Q0.data(),limit_Q3.size());
159 
160 }
#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.
virtual const Registry & GetConfig(void) const
Definition: Algorithm.cxx:246
std::pair< double, double > weight_type_pair
Definition: MECScaleVsW.h:30
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
double fLowLimitWeight
Definition: MECScaleVsW.h:61
weight_type_map fWeightsMap
Definition: MECScaleVsW.h:57
double fUpperLimitWeight
Definition: MECScaleVsW.h:62
bool GetParamDef(const RgKey &name, T &p, const T &def) const
bool GetParam(const RgKey &name, T &p, bool is_top_call=true) const
TSpline3 fW1_Q0Q3_limits
Definition: MECScaleVsW.h:59
double MECScaleVsW::ScaleFunction ( const double  W,
const weight_type_pair  min,
const weight_type_pair  max 
) const
protectedvirtual

Definition at line 94 of file MECScaleVsW.cxx.

Referenced by GetScaling().

95 {
96  // This function is responsible to calculate the scale at a given W
97  // It interpolates the value between scale_min (W_min) and scale_max (W_max) linearly
98  return ( max.second - min.second ) * ( W - min.first ) / ( max.first - min.first ) + min.second ;
99 }
double W(const Interaction *const i)
Definition: KineUtils.cxx:1101

Member Data Documentation

double genie::MECScaleVsW::fDefaultWeight
private

Definition at line 56 of file MECScaleVsW.h.

Referenced by GetScaling(), and LoadConfig().

double genie::MECScaleVsW::fLowLimitWeight
private

Definition at line 61 of file MECScaleVsW.h.

Referenced by GetMapWithLimits(), and LoadConfig().

double genie::MECScaleVsW::fUpperLimitWeight
private

Definition at line 62 of file MECScaleVsW.h.

Referenced by GetMapWithLimits(), and LoadConfig().

TSpline3 genie::MECScaleVsW::fW1_Q0Q3_limits
private

Definition at line 59 of file MECScaleVsW.h.

Referenced by GetMapWithLimits(), and LoadConfig().

weight_type_map genie::MECScaleVsW::fWeightsMap
private

Definition at line 57 of file MECScaleVsW.h.

Referenced by GetMapWithLimits(), and LoadConfig().


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