GENIEGenerator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ELFormFactors.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  Costas Andreopoulos <c.andreopoulos \at cern.ch>
7  University of Liverpool
8 */
9 //____________________________________________________________________________
10 
11 #include <string>
12 
17 
18 using std::endl;
19 using std::string;
20 
21 using namespace genie;
22 using namespace genie::utils;
23 
24 //____________________________________________________________________________
25 namespace genie
26 {
27  ostream & operator << (ostream & stream, const ELFormFactors & ff)
28  {
29  ff.Print(stream);
30  return stream;
31  }
32 }
33 //____________________________________________________________________________
35 {
36  this->Reset();
37 }
38 //____________________________________________________________________________
40 {
41  this->Copy(ff);
42 }
43 //____________________________________________________________________________
45 {
46  this->Reset();
47  this->fModel = model;
48 }
49 //____________________________________________________________________________
50 void ELFormFactors::Calculate(const Interaction * interaction)
51 {
52  if(!this->fModel)
53  {
54  LOG("ELFormFactors", pERROR)
55  << "No ELFormFactorModelI algorithm was defined!";
56  this->Reset("D");
57  }
58  else {
59  this->fGep = this->fModel->Gep(interaction);
60  this->fGmp = this->fModel->Gmp(interaction);
61  this->fGen = this->fModel->Gen(interaction);
62  this->fGmn = this->fModel->Gmn(interaction);
63  }
64 }
65 //____________________________________________________________________________
66 void ELFormFactors::Reset(Option_t * opt)
67 {
68 // Reset the ELFormFactors object (data & attached model). If the input
69 // option = D it resets the data only and not the attached model.
70 
71  this->fGep = 0.;
72  this->fGmp = 0.;
73  this->fGen = 0.;
74  this->fGmn = 0.;
75 
76  string option(opt);
77  if(option.find("D") == string::npos) {this->fModel = 0;}
78 }
79 //____________________________________________________________________________
81 {
82  this->fModel = ff.fModel;
83  this->fGep = ff.fGep;
84  this->fGmp = ff.fGmp;
85  this->fGen = ff.fGen;
86  this->fGmn = ff.fGmn;
87 }
88 //____________________________________________________________________________
89 bool ELFormFactors::Compare(const ELFormFactors & ff) const
90 {
91  bool equal =
92  math::AreEqual(this->fGep, ff.fGep) &&
93  math::AreEqual(this->fGmp, ff.fGmp) &&
94  math::AreEqual(this->fGen, ff.fGen) &&
95  math::AreEqual(this->fGmn, ff.fGmn);
96  return equal;
97 }
98 //____________________________________________________________________________
99 void ELFormFactors::Print(ostream & stream) const
100 {
101  stream<< endl;
102  stream<< "(Gep = " << this->fGep << ", Gmp = " << this->fGmp << ")" << endl;
103  stream<< "(Gen = " << this->fGen << ", Gmn = " << this->fGmn << ")" << endl;
104 }
105 //____________________________________________________________________________
107 {
108  return this->Compare(ff);
109 }
110 //___________________________________________________________________________
112 {
113  this->Copy(ff);
114  return (*this);
115 }
116 //___________________________________________________________________________
void Copy(const ELFormFactors &ff)
#define pERROR
Definition: Messenger.h:59
bool operator==(const ELFormFactors &ff) const
bool AreEqual(double x1, double x2)
Definition: MathUtils.cxx:236
bool Compare(const ELFormFactors &ff) const
Summary information for an interaction.
Definition: Interaction.h:56
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
Pure abstract base class. Defines the ELFormFactorsModelI interface to be implemented by any algorith...
void Calculate(const Interaction *interaction)
Calculate the form factors for the input interaction using the attached algorithm.
ELFormFactors & operator=(const ELFormFactors &ff)
A class holding the Elastic Form Factors Ge,Gm.
Definition: ELFormFactors.h:36
void Reset(Option_t *opt="")
ostream & operator<<(ostream &stream, const AlgConfigPool &config_pool)
const ELFormFactorsModelI * fModel
Definition: ELFormFactors.h:80
void Print(ostream &stream) const
void SetModel(const ELFormFactorsModelI *model)
Attach an algorithm.