Hammer  1.0.0
Helicity Amplitude Module for Matrix Element Reweighting
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AmplitudeBase.cc
Go to the documentation of this file.
1 ///
2 /// @file AmplitudeBase.cc
3 /// @brief Hammer base amplitude class
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 #include "Hammer/AmplitudeBase.hh"
14 #include "Hammer/IndexLabels.hh"
15 #include "Hammer/Math/Utils.hh"
18 
19 using namespace std;
20 
21 namespace Hammer {
22 
23  namespace MD = MultiDimensional;
24 
25  AmplitudeBase::AmplitudeBase() : _WCNames{}, _WCPrefix{""}, _WCLabel{NONE}, _tensorList{}, _multiplicity{1ul} {
26  }
27 
28  vector<complex<double>> AmplitudeBase::getWCVectorFromDict(const map<string, complex<double>>& wcDict) const {
29  vector<complex<double>> result(_WCNames.size());
30  for(size_t pos = 0ul; pos < _WCNames.size(); ++pos) {
31  auto it = wcDict.find(_WCNames[pos]);
32  if(it != wcDict.end()) {
33  result[pos] = it->second;
34  }
35  }
36  return result;
37  }
38 
39  vector<complex<double>> AmplitudeBase::getWCVectorFromSettings(WTerm what) const {
40  WTerm oldwhat = const_cast<AmplitudeBase*>(this)->setWeightTerm(what);
41  vector<complex<double>> result(_WCNames.size());
42  for(size_t pos = 0ul; pos < _WCNames.size(); ++pos) {
43  result[pos] = *getSetting<complex<double>>(_WCPrefix,_WCNames[pos]);
44  }
45  const_cast<AmplitudeBase*>(this)->setWeightTerm(oldwhat);
46  return result;
47  }
48 
49  void AmplitudeBase::updateWCSettings(const vector<complex<double>>& values, WTerm what) {
50  this->updateVectorOfSettings(values, _WCNames, _WCPrefix, what);
51  }
52 
53  void AmplitudeBase::updateWCSettings(const map<string, complex<double>>& values, WTerm what) {
54  this->updateVectorOfSettings(values, _WCPrefix, what);
55  }
56 
57  void AmplitudeBase::updateWCTensor(vector<complex<double>> values, MD::SharedTensorData& data) const {
58  ASSERT(values.size() == _WCNames.size());
59  preProcessWCValues(values);
60  if(!data || data->rank() == 0) {
61  data = MD::SharedTensorData{MD::makeVector({static_cast<uint16_t>(values.size())}, {_WCLabel}, values).release()};
62  }
63  else {
64  for(IndexType i = 0; i<values.size(); ++i) {
65  data->element({i}) = values[i];
66  }
67  }
68  }
69 
70  pair<string, IndexLabel> AmplitudeBase::getWCInfo() const {
71  return make_pair(_WCPrefix, _WCLabel);
72  }
73 
74  void AmplitudeBase::preProcessWCValues(vector<complex<double>>&) const {
75  return;
76  }
77 
79  // initSettings();
80  ///@todo anything else?
81  }
82 
85  }
86 
89  }
90 
92  bool res = ParticleData::setSignatureIndex(idx);
93  if(res) {
95  return true;
96  }
97  MSG_WARNING("Unable to update the signature index");
98  return false;
99  }
100 
102  _WCLabel = NONE;
103  _WCPrefix = "None";
104  }
105 
107  return _multiplicity;
108  }
109 
111  return Log::getLog("Hammer.AmplitudeBase");
112  }
113 
115  _tensorList.push_back(move(tensor));
116  }
117 
118 
119 } // namespace Hammer
#define MSG_WARNING(x)
Definition: Logging.hh:366
PDG codes to UID functions.
Base class for amplitudes.
std::pair< std::string, IndexLabel > getWCInfo() const
std::vector< std::complex< double > > getWCVectorFromDict(const std::map< std::string, std::complex< double >> &wcDict) const
#define ASSERT(x)
Definition: Exceptions.hh:95
Non-sparse tensor data container.
Tensor indices label definitions.
WTerm setWeightTerm(WTerm group)
TensorData makeVector(IndexList dimensions, LabelsList labels, vector< complex< double >> values)
Hammer base amplitude class.
std::vector< Tensor > _tensorList
list of (list of) labels for the tensor indices (one for each signature)
uint16_t IndexType
std::shared_ptr< IContainer > SharedTensorData
static Log & getLog(const std::string &name)
Get a logger with the given name.
Definition: Logging.cc:139
std::vector< std::complex< double > > getWCVectorFromSettings(WTerm what) const
Order-0 tensor data container.
Logging class.
Definition: Logging.hh:33
virtual bool setSignatureIndex(size_t idx=0)
select a specific signature to be the current signature
virtual bool setSignatureIndex(size_t idx=0)
select a specific signature to be the current signature
Multidimensional tensor class with complex numbers as elements.
Definition: Tensor.hh:33
std::vector< std::string > _WCNames
void updateWCTensor(std::vector< std::complex< double >> values, MultiDimensional::SharedTensorData &data) const
virtual void preProcessWCValues(std::vector< std::complex< double >> &data) const
virtual void updateWilsonCeffLabelPrefix()
size_t _signatureIndex
the index of the current signature
void init()
initializes the amplitude (defines settings associated to this amplitude, etc.)
size_t multiplicityFactor() const
void updateWCSettings(const std::vector< std::complex< double >> &values, WTerm what)
void addTensor(Tensor &&tensor)
adds the index labels for the amplitude tensor for a specific signature to the index labels signature...
void updateVectorOfSettings(const std::vector< T > &values, const std::vector< std::string > &names, const std::string &path="", WTerm group=WTerm::COMMON)
Log & getLog() const
logging facility
Tensor & getTensor()
returns a reference to itself as a Tensor