GENIEGenerator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TabulatedHadronTensorModelI.h
Go to the documentation of this file.
1 //____________________________________________________________________________
2 /*!
3 
4 \class genie::TabulatedHadronTensorModelI
5 
6 \brief Creates hadron tensor objects for cross section calculations
7  using precomputed data tables
8 
9 \author Steven Gardiner <gardiner \at fnal.gov>
10  Liang Liu <liangliu \at fnal.gov>
11  Fermi National Accelerator Laboratory
12 
13 \created April 26, 2019
14 
15 \cpright Copyright (c) 2003-2024, The GENIE Collaboration
16  For the full text of the license visit http://copyright.genie-mc.org
17  or see $GENIE/LICENSE
18 
19 */
20 //____________________________________________________________________________
21 
22 #ifndef _TABULATED_HADRON_TENSOR_MODEL_H_
23 #define _TABULATED_HADRON_TENSOR_MODEL_H_
24 
25 // standard library includes
26 #include <map>
27 #include <string>
28 #include <vector>
29 
30 // GENIE includes
34 
35 namespace genie {
36 
38 
39 public:
41 
42  // Implementation of Algorithm interface
43  virtual void Configure(const Registry& config);
44  virtual void Configure(std::string config);
45 
46  // Implementation of HadronTensorModelI interface
47  virtual const HadronTensorI* GetTensor(int tensor_pdg, HadronTensorType_t type) const;
48 
49 protected:
50 
52  TabulatedHadronTensorModelI(std::string name);
53  TabulatedHadronTensorModelI(std::string name, std::string config);
54 
55  /// Saves some basic XML config parameters to data members
56  void LoadConfig();
57 
58  /// Looks up the full path when constructing hadron tensor objects that are
59  /// based on a data file
60  std::string FindTensorTableFile(const std::string& basename,
61  bool& ok) const;
62 
63  /// Struct used to provide a unique ID for each tensor object
64  struct HadronTensorID {
66  : target_pdg( pdg ), type( typ ) {}
69 
70  // Less than operator needed for sorting a map of these IDs
71  bool operator<(const HadronTensorID& other) const {
72  return (target_pdg < other.target_pdg)
73  || (target_pdg == other.target_pdg && type < other.type);
74  }
75  };
76 
77  /// If true, logging messages will be issued when a requested hadron tensor
78  /// file cannot be found
80 
81  /// Cache of hadron tensor objects that have been fully loaded into memory
82  ///
83  /// Keys are tensor IDs, values are pointers to hadron tensor objects
84  mutable std::map< HadronTensorID, HadronTensorI* > fTensors;
85 
86  /// Paths to check when searching for hadron tensor data files
87  std::vector<std::string> fDataPaths;
88 
89  /// Create a HadronTensorI object given a particular HadronTensorID
90  const HadronTensorI* BuildTensor( const HadronTensorID& ht_id ) const;
91 
92  /// Loads the basename for a particular hadron tensor file from
93  /// the configuration Registry
94  std::string GetTensorFileBasename( const HadronTensorID& ht_id ) const;
95 
96  /// Parses the hadron tensor file (specified by its full file name,
97  /// including the path) and returns a HadronTensorI* to it
98  virtual HadronTensorI* ParseTensorFile( const std::string& full_file_name ) const = 0;
99 };
100 
101 } // namespace genie
102 
103 #endif // _TABULATED_HADRON_TENSOR_MODEL_H_
std::string GetTensorFileBasename(const HadronTensorID &ht_id) const
std::string FindTensorTableFile(const std::string &basename, bool &ok) const
HadronTensorID(int pdg=0, HadronTensorType_t typ=kHT_Undefined)
virtual void Configure(const Registry &config)
enum genie::HadronTensorType HadronTensorType_t
bool operator<(const HadronTensorID &other) const
virtual const HadronTensorI * GetTensor(int tensor_pdg, HadronTensorType_t type) const
Abstract interface for an object that computes the elements a hadron tensor . Also computes the contr...
Definition: HadronTensorI.h:95
std::vector< std::string > fDataPaths
Paths to check when searching for hadron tensor data files.
Struct used to provide a unique ID for each tensor object.
void LoadConfig()
Saves some basic XML config parameters to data members.
Creates hadron tensor objects for cross section calculations using precomputed data tables...
A registry. Provides the container for algorithm configuration parameters.
Definition: Registry.h:65
virtual HadronTensorI * ParseTensorFile(const std::string &full_file_name) const =0
Creates hadron tensor objects for use in cross section calculations.
const HadronTensorI * BuildTensor(const HadronTensorID &ht_id) const
Create a HadronTensorI object given a particular HadronTensorID.
std::map< HadronTensorID, HadronTensorI * > fTensors