GENIEGenerator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TabulatedLabFrameHadronTensor.h
Go to the documentation of this file.
1 //____________________________________________________________________________
2 /*!
3 
4 \class genie::TabulatedLabFrameHadronTensor
5 
6 \brief Computes the elements and structure functions of the hadron
7  tensor \f$W^{\mu\nu}\f$ (using the conventions of the Valencia model)
8  using precomputed tables.
9  Is a concrete implementation of the HadronTensorI interface.
10 
11 \author Steven Gardiner <gardiner \at fnal.gov>
12  Fermi National Accelerator Laboratory
13 
14 \created August 23, 2018
15 
16 \cpright Copyright (c) 2003-2024, The GENIE Collaboration
17  For the full text of the license visit http://copyright.genie-mc.org
18  or see $GENIE/LICENSE
19 */
20 //____________________________________________________________________________
21 
22 #ifndef TABULATED_VALENCIA_HADRON_TENSOR_H
23 #define TABULATED_VALENCIA_HADRON_TENSOR_H
24 
25 // standard library includes
26 #include <vector>
27 
28 // GENIE includes
31 
32 namespace genie {
33 
35 
36  public:
37 
38  TabulatedLabFrameHadronTensor(const std::string& table_file_name);
40 
41  // \todo Enable override specifiers when GENIE modernizes to C++11
42 
43  virtual std::complex<double> tt(double q0, double q_mag) const /*override*/;
44 
45  virtual std::complex<double> tz(double q0, double q_mag) const /*override*/;
46 
47  virtual std::complex<double> xx(double q0, double q_mag) const /*override*/;
48 
49  virtual std::complex<double> xy(double q0, double q_mag) const /*override*/;
50 
51  virtual std::complex<double> zz(double q0, double q_mag) const /*override*/;
52 
53  virtual double W1(double q0, double q_mag, double Mi) const /*override*/;
54  virtual double W2(double q0, double q_mag, double Mi) const /*override*/;
55  virtual double W3(double q0, double q_mag, double Mi) const /*override*/;
56  virtual double W4(double q0, double q_mag, double Mi) const /*override*/;
57  virtual double W5(double q0, double q_mag, double Mi) const /*override*/;
58  virtual double W6(double q0, double q_mag, double Mi) const /*override*/;
59 
60  //virtual double contraction(const Interaction* interaction) const /*override*/;
61 
62  virtual double dSigma_dT_dCosTheta(const Interaction* interaction,
63  double Q_value) const /*override*/;
64 
65  virtual double dSigma_dT_dCosTheta(int probe_pdg, double E_probe,
66  double m_probe, double Tl, double cos_l, double ml, double Q_value)
67  const /*override*/;
68 
69  virtual double dSigma_dT_dCosTheta_rosenbluth(const Interaction* interaction,
70  double Q_value) const /*override*/;
71 
72  virtual double dSigma_dT_dCosTheta_rosenbluth(int probe_pdg, double E_probe,
73  double m_probe, double Tl, double cos_l, double ml, double Q_value)
74  const /*override*/;
75 
76  inline virtual double q0Min() const /*override*/ { return fGrid.x_min(); }
77  inline virtual double q0Max() const /*override*/ { return fGrid.x_max(); }
78  inline virtual double qMagMin() const /*override*/ { return fGrid.y_min(); }
79  inline virtual double qMagMax() const /*override*/ { return fGrid.y_max(); }
80 
81  protected:
82 
83  /// Helper function that allows this class to handle variations in the
84  /// data file format for the 1D \f$q_0\f$ and
85  /// \f$\left|\overrightarrow{q}\right|\f$ grids
86  /// \param[in] num_points The number of grid points to be read from the file
87  /// \param[in] flag A numerical flag describing the grid data format
88  /// \param[inout] in_file A reference to the file being read
89  /// \param[out] vec_to_fill The vector that will store the grid points
90  void read1DGridValues(int num_points, int flag, std::ifstream& in_file,
91  std::vector<double>& vec_to_fill);
92 
93  class TableEntry {
94 
95  public:
96 
97  double W00;
98  double Wxx;
99  double Wzz;
100  double ImWxy;
101  double ReW0z;
102 
103  // Scalar operations
104  TableEntry operator*(double d) const
105  { return apply_to_elements(d, &TableEntry::multiply); }
106 
107  TableEntry operator/(double d) const
108  { return apply_to_elements(d, &TableEntry::divide); }
109 
110  // TableEntry operations
111  TableEntry operator+(const TableEntry& rhs) const
112  { return apply_to_elements(rhs, &TableEntry::add); }
113 
114  TableEntry operator-(const TableEntry& rhs) const
115  { return apply_to_elements(rhs, &TableEntry::subtract); }
116 
117  TableEntry operator*(const TableEntry& rhs) const
118  { return apply_to_elements(rhs, &TableEntry::multiply); }
119 
120  TableEntry operator/(const TableEntry& rhs) const
121  { return apply_to_elements(rhs, &TableEntry::divide); }
122 
123  bool operator==(const TableEntry& rhs) const {
124  bool are_equal = this->W00 == rhs.W00;
125  if ( are_equal ) are_equal = this->Wxx == rhs.Wxx;
126  if ( are_equal ) are_equal = this->Wzz == rhs.Wzz;
127  if ( are_equal ) are_equal = this->ImWxy == rhs.ImWxy;
128  if ( are_equal ) are_equal = this->ReW0z == rhs.ReW0z;
129  return are_equal;
130  }
131 
132  bool operator!=(const TableEntry& rhs) const {
133  return !operator==(rhs);
134  }
135 
136  protected:
137 
139  double (*my_function)(double, double) ) const
140  {
141  // Create a new TableEntry object by applying the function to
142  // each pair of elements
143  TableEntry result;
144  result.W00 = (*my_function)( this->W00, d );
145  result.Wxx = (*my_function)( this->Wxx, d );
146  result.Wzz = (*my_function)( this->Wzz, d );
147  result.ImWxy = (*my_function)( this->ImWxy, d );
148  result.ReW0z = (*my_function)( this->ReW0z, d );
149 
150  return result;
151  }
152 
154  double (*my_function)(double, double) ) const
155  {
156  // Create a new TableEntry object by applying the function to
157  // each pair of elements
158  TableEntry result;
159  result.W00 = (*my_function)( this->W00, rhs.W00 );
160  result.Wxx = (*my_function)( this->Wxx, rhs.Wxx );
161  result.Wzz = (*my_function)( this->Wzz, rhs.Wzz );
162  result.ImWxy = (*my_function)( this->ImWxy, rhs.ImWxy );
163  result.ReW0z = (*my_function)( this->ReW0z, rhs.ReW0z );
164  return result;
165  }
166 
167  private:
168 
169  // Dummy functions defined so that they can be applied to each class member
170  // by passing a function pointer to apply_to_elements()
171  /// \todo Replace these with lambdas (or something similar) when GENIE
172  /// updates to C++11. This technique is a bit of a hack.
173  inline static double add(double x, double y) { return x + y; }
174  inline static double subtract(double x, double y) { return x - y; }
175  inline static double multiply(double x, double y) { return x * y; }
176  inline static double divide(double x, double y) { return x / y; }
177  };
178 
179  /// \name Structure function helpers
180  /// \brief These helper functions allow multiple structure
181  /// function values (e.g., \f$W_1\f$ and \f$W_2\f$) to be computed
182  /// without having to perform bilinear interpolation every time.
183  /// \details Because the differential cross section
184  /// \f$\frac{ d^2\sigma_{\nu l} }
185  /// { d\cos(\theta^\prime) dE^\prime_l }\f$ does not depend on the
186  /// initial nucleus's mass \f$M_i\f$, the explicit factors of \f$M_i\f$
187  /// have been removed from these internally-used functions.
188  /// \param[in] Hadronic tensor table entry that has been pre-interpolated
189  /// @{
190  virtual double W1(double q0, double q_mag, const TableEntry& entry) const;
191 
192  virtual double W2(double q0, double q_mag, const TableEntry& entry) const;
193 
194  virtual double W3(double q0, double q_mag, const TableEntry& entry) const;
195 
196  virtual double W4(double q0, double q_mag, const TableEntry& entry) const;
197 
198  virtual double W5(double q0, double q_mag, const TableEntry& entry) const;
199 
200  virtual double W6(double q0, double q_mag, const TableEntry& entry) const;
201  ///@}
202 
203  std::vector<double> fq0Points;
204  std::vector<double> fqmagPoints;
205  std::vector<TableEntry> fEntries;
206 
208 
209 }; // class TabulatedLabFrameHadronTensor
210 
211 } // genie namespace
212 #endif
virtual std::complex< double > tz(double q0, double q_mag) const
The tensor element .
BLI2DNonUnifObjectGrid< TableEntry > fGrid
virtual std::complex< double > tt(double q0, double q_mag) const
The tensor element .
Abstract interface for an object that computes the elements ( , , etc.) and structure functions ( ...
TableEntry apply_to_elements(const TableEntry &rhs, double(*my_function)(double, double)) const
Summary information for an interaction.
Definition: Interaction.h:56
virtual std::complex< double > zz(double q0, double q_mag) const
The tensor element .
virtual double dSigma_dT_dCosTheta(const Interaction *interaction, double Q_value) const
virtual double W2(double q0, double q_mag, double Mi) const
virtual double W4(double q0, double q_mag, double Mi) const
virtual double W1(double q0, double q_mag, double Mi) const
The structure function .
Computes the elements and structure functions of the hadron tensor (using the conventions of the Val...
void read1DGridValues(int num_points, int flag, std::ifstream &in_file, std::vector< double > &vec_to_fill)
virtual double W6(double q0, double q_mag, double Mi) const
virtual std::complex< double > xx(double q0, double q_mag) const
The tensor element .
virtual double W5(double q0, double q_mag, double Mi) const
virtual double dSigma_dT_dCosTheta_rosenbluth(const Interaction *interaction, double Q_value) const
A class template that performs bilinear interpolation on a non-uniform grid with an implementation si...
virtual std::complex< double > xy(double q0, double q_mag) const
The tensor element .
TabulatedLabFrameHadronTensor(const std::string &table_file_name)
virtual double W3(double q0, double q_mag, double Mi) const
TableEntry apply_to_elements(double d, double(*my_function)(double, double)) const