Hammer  1.0.0
Helicity Amplitude Module for Matrix Element Reweighting
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ExternalData.hh
Go to the documentation of this file.
1 ///
2 /// @file ExternalData.hh
3 /// @brief Container class for values of WC and FF vectors
4 ///
5 
6 //**** This file is a part of the HAMMER library
7 //**** Copyright (C) 2016 - 2020 The HAMMER Collaboration
8 //**** HAMMER is licensed under version 3 of the GPL; see COPYING for details
9 //**** Please note the MCnet academic guidelines; see GUIDELINES for details
10 
11 // -*- C++ -*-
12 #ifndef HAMMER_EXTERNALDATA
13 #define HAMMER_EXTERNALDATA
14 
15 #include <map>
16 #include <set>
17 #include <string>
18 #include <vector>
19 #include <memory>
20 #include <unordered_map>
21 
22 #include <boost/thread/tss.hpp>
23 
24 #include "Hammer/IndexTypes.hh"
26 #include "Hammer/Tools/Pdg.fhh"
29 #include "Hammer/Tools/Utils.hh"
30 
31 namespace Hammer {
32 
33  class AmplitudeBase;
34  class FormFactorBase;
35  class Tensor;
36  class RunDefinitions;
37  class ProvidersRepo;
38 
39  /// @brief Main class
40  ///
41  /// Contains ...
42  ///
43  /// @ingroup Core
44  class ExternalData : public SettingsConsumer {
45 
46  public:
47 
48  ExternalData(const ProvidersRepo* provs);
49 
50  ExternalData(const ExternalData& other) = delete;
51  ExternalData& operator=(const ExternalData& other) = delete;
52  ExternalData(ExternalData&& other) = delete;
53  ExternalData& operator=(ExternalData&& other) = delete;
54 
55  virtual ~ExternalData() noexcept;
56 
57  public:
58 
59  /// @brief
60  /// @param[in] schemeName
61  /// @param[in] labels
62  /// @return
63  virtual const Tensor& getExternalVectors(std::string schemeName, LabelsList labels) const;
64 
65  /// @brief
66  /// @param[in] parent
67  /// @param[in] daughters
68  /// @param[in] granddaughters
69  /// @param[in] what
70  /// @return
71  virtual MultiDimensional::SharedTensorData getWilsonCoefficients(PdgId parent, const std::vector<PdgId>& daughters,
72  const std::vector<PdgId>& granddaughters = {}, WTerm what = WTerm::NUMERATOR) const;
73 
74  /// @brief
75  /// @param[in] amp
76  /// @param[in] what
77  /// @return
79 
80  /// @brief
81  /// @param[in] amp
82  /// @return
84 
85  /// @brief
86  /// @param[in] prefixName
87  /// @param[in] settings
88  void specializeWCInWeights(const std::string& prefixName, const std::map<std::string, std::complex<double>>& settings);
89 
90  /// @brief
91  /// @param[in] prefixName
92  /// @param[in] values
93  void specializeWCInWeights(const std::string& prefixName, const std::vector<std::complex<double>>& values);
94 
95  /// @brief
96  /// @param[in] prefixName
97  void resetSpecializeWCInWeights(const std::string& prefixName);
98 
99  /// @brief
100  /// @param[in] ampl
101  /// @return bool
102  bool isWCSpecialized(AmplitudeBase* ampl) const;
103 
104  /// @brief
105  /// @param[in] prefixName
106  /// @param[in] values
107  /// @param[in] what
108  void setWilsonCoefficients(const std::string& prefixName, const std::vector<std::complex<double>>& values, WTerm what = WTerm::NUMERATOR);
109 
110  void setWilsonCoefficients(const std::string& prefixName,
111  const std::map<std::string, std::complex<double>>& values, WTerm what = WTerm::NUMERATOR);
112 
113  /// @brief
114  /// @param[in] prefixName
115  /// @param[in] values
116  void setWilsonCoefficientsLocal(const std::string& prefixName, const std::vector<std::complex<double>>& values);
117 
118  void setWilsonCoefficientsLocal(const std::string& prefixName,
119  const std::map<std::string, std::complex<double>>& values);
120 
121  void resetWilsonCoefficients(const std::string& prefixName, WTerm what = WTerm::NUMERATOR);
122 
124  const std::vector<std::complex<double>>& values) const;
126  const std::map<std::string, std::complex<double>>& values) const;
127 
128 
129  /// @brief
130  /// @param[in] ff
131  /// @param[in] schemeName
132  /// @return
133  virtual MultiDimensional::SharedTensorData getFFEigenVectors(FormFactorBase* ff, const std::string& schemeName) const;
134 
135 
136  // /// @brief
137  // /// @param[in] amp
138  // /// @param[in] numerator
139  // /// @param[in] hConj
140  // /// @return
141  // virtual const Tensor* getFFEigenVectors(FormFactorBase* ff, WTerm what = WTerm::NUMERATOR) const;
142 
143  /// @brief
144  /// @param[in] process
145  /// @param[in] values
146  void setFFEigenVectors(const FFPrefixGroup& process,
147  const std::vector<double>& values);
148 
149  /// @brief
150  /// @param[in] process
151  /// @param[in] values
152  void setFFEigenVectors(const FFPrefixGroup& process, const std::map<std::string, double>& values);
153 
154  /// @brief
155  /// @param[in] process
156  /// @param[in] values
157  void setFFEigenVectorsLocal(const FFPrefixGroup& process, const std::vector<double>& values);
158 
159  /// @brief
160  /// @param[in] process
161  /// @param[in] values
162  void setFFEigenVectorsLocal(const FFPrefixGroup& process, const std::map<std::string, double>& values);
163 
164  void resetFFEigenVectors(const FFPrefixGroup& process);
165 
167  const std::vector<double>& values) const;
169  const std::map<std::string, double>& values) const;
170 
171 
172  void init(std::vector<std::string> schemeNames);
173 
174  private:
175 
176  void initWilsonCoefficients();
177  void initFormFactorErrors();
178  void initExternalVectors();
179 
180  virtual void defineSettings();
181 
182  Log& getLog() const;
183 
184  private:
185 
186  using externalVectorsType = std::unordered_map<std::string, UMap<LabelsList, Tensor>>;
187  using processWilsonCoefficientsType = std::map<IndexLabel, std::array<MultiDimensional::SharedTensorData, 2>>;
188  using processFFEigenVectorsType = std::map<IndexLabel, SchemeDict<MultiDimensional::SharedTensorData>>;
189 
190 
191  mutable boost::thread_specific_ptr<processWilsonCoefficientsType> _processWilsonCoefficients;
192  mutable boost::thread_specific_ptr<processFFEigenVectorsType> _processFFEigenVectors;
193  mutable boost::thread_specific_ptr<externalVectorsType> _externalVectors;
194 
195  std::vector<std::string> _schemes;
196  std::map<IndexLabel, MultiDimensional::SharedTensorData> _processSpecializedWilsonCoefficients;
197  std::map<std::string, bool> _isWCSpecializedDict{};
199 
200  };
201 
202 } // namespace Hammer
203 
204 #endif
virtual MultiDimensional::SharedTensorData getWilsonCoefficients(PdgId parent, const std::vector< PdgId > &daughters, const std::vector< PdgId > &granddaughters={}, WTerm what=WTerm::NUMERATOR) const
Definition: ExternalData.cc:99
virtual void defineSettings()
purely virtual function for a class to define new settings
Definition: ExternalData.cc:54
MultiDimensional::SharedTensorData getTempFFEigenVectors(const FFPrefixGroup &process, const std::vector< double > &values) const
void setWilsonCoefficients(const std::string &prefixName, const std::vector< std::complex< double >> &values, WTerm what=WTerm::NUMERATOR)
Forward declaration of serialization related typedefs and includes.
void setWilsonCoefficientsLocal(const std::string &prefixName, const std::vector< std::complex< double >> &values)
Base class for form factors.
Base class for amplitudes.
Hammer data types declarations.
virtual MultiDimensional::SharedTensorData getFFEigenVectors(FormFactorBase *ff, const std::string &schemeName) const
void init(std::vector< std::string > schemeNames)
void resetFFEigenVectors(const FFPrefixGroup &process)
boost::thread_specific_ptr< processWilsonCoefficientsType > _processWilsonCoefficients
virtual MultiDimensional::SharedTensorData getSpecializedWilsonCoefficients(AmplitudeBase *amp) const
void resetWilsonCoefficients(const std::string &prefixName, WTerm what=WTerm::NUMERATOR)
std::map< IndexLabel, std::array< MultiDimensional::SharedTensorData, 2 >> processWilsonCoefficientsType
virtual ~ExternalData() noexcept
Definition: ExternalData.cc:40
std::map< IndexLabel, MultiDimensional::SharedTensorData > _processSpecializedWilsonCoefficients
void setFFEigenVectorsLocal(const FFPrefixGroup &process, const std::vector< double > &values)
std::map< std::string, bool > _isWCSpecializedDict
ExternalData & operator=(const ExternalData &other)=delete
ExternalData(const ProvidersRepo *provs)
Definition: ExternalData.cc:35
Base class to access the settings repository.
Forward declarations of types used in the tensor classes.
std::shared_ptr< IContainer > SharedTensorData
boost::thread_specific_ptr< externalVectorsType > _externalVectors
std::map< IndexLabel, SchemeDict< MultiDimensional::SharedTensorData >> processFFEigenVectorsType
Pdg forward declarations.
Logging class.
Definition: Logging.hh:33
void setFFEigenVectors(const FFPrefixGroup &process, const std::vector< double > &values)
Log & getLog() const
std::unordered_map< std::string, UMap< LabelsList, Tensor >> externalVectorsType
virtual const Tensor & getExternalVectors(std::string schemeName, LabelsList labels) const
Definition: ExternalData.cc:57
Multidimensional tensor class with complex numbers as elements.
Definition: Tensor.hh:33
Base class for accessing Hammer settings repository.
MultiDimensional::SharedTensorData getTempWilsonCoefficients(const std::string &prefixName, const std::vector< std::complex< double >> &values) const
std::vector< std::string > _schemes
std::vector< IndexLabel > LabelsList
void specializeWCInWeights(const std::string &prefixName, const std::map< std::string, std::complex< double >> &settings)
const ProvidersRepo * _providers
boost::thread_specific_ptr< processFFEigenVectorsType > _processFFEigenVectors
void resetSpecializeWCInWeights(const std::string &prefixName)
bool isWCSpecialized(AmplitudeBase *ampl) const
int PdgId
Definition: Pdg.fhh:17