14 #include <boost/algorithm/string.hpp>
33 namespace MD = MultiDimensional;
35 ExternalData::ExternalData(
const ProvidersRepo* provs) : _providers{provs} {
36 _processWilsonCoefficients.reset(
new processWilsonCoefficientsType{});
37 _processFFEigenVectors.reset(
new processFFEigenVectorsType{});
62 auto& ext = (*_externalVectors)[schemeName];
63 auto ite = ext.find(labels);
64 if (ite != ext.end()) {
67 if(labels.size() == 0) {
69 return res.first->second;
71 vector<pair<MD::SharedTensorData, bool>> elements;
72 elements.reserve(labels.size());
73 size_t index = (schemeName ==
"Denominator") ? 1 : 0;
74 for (
auto elem : labels) {
76 IndexLabel lab = (elem > 0) ? elem : static_cast<IndexLabel>(-elem);
80 elements.push_back({it->second[index], hc});
87 auto it3 = it2->second.find(schemeName);
88 if (it3 != it2->second.end()) {
89 elements.push_back({it3->second, hc});
95 auto res = ext.emplace(labels,
Tensor{
"External", move(elements)});
96 return res.first->second;
100 const std::vector<PdgId>& granddaughters,
WTerm what)
const {
111 return it->second[0];
113 return it->second[1];
115 throw Error(
"Invalid option");
132 if (ampl !=
nullptr) {
137 MSG_ERROR(
"Wilson coefficients " + prefixName +
" not found.");
143 if (ampl !=
nullptr) {
149 ampl->updateWCTensor(values, itSWC->second);
150 MSG_INFO(prefixName +
" Wilson coefficients will be specialized in weights. Histogram specialization will be superceded!");
152 MSG_ERROR(
"Wilson coefficients " + prefixName +
" not found.");
159 if (ampl !=
nullptr) {
162 MSG_ERROR(
"Wilson coefficients " + prefixName +
" not found.");
177 if (ampl !=
nullptr) {
182 ampl->updateWCSettings(values, what);
185 ampl->updateWCTensor(values, itWC->second[0]);
188 ampl->updateWCTensor(values, itWC->second[1]);
191 ampl->updateWCTensor(values, itWC->second[0]);
192 ampl->updateWCTensor(values, itWC->second[1]);
200 if (ampl !=
nullptr) {
205 ampl->updateWCSettings(values, what);
206 auto vec = ampl->getWCVectorFromSettings(what);
209 ampl->updateWCTensor(vec, itWC->second[0]);
212 ampl->updateWCTensor(vec, itWC->second[1]);
215 ampl->updateWCTensor(vec, itWC->second[0]);
216 ampl->updateWCTensor(vec, itWC->second[1]);
223 const std::vector<std::complex<double>>& values) {
228 if (ampl !=
nullptr) {
233 ampl->updateWCTensor(values, itWC->second[0]);
238 const std::map<std::string, std::complex<double>>& values) {
243 if (ampl !=
nullptr) {
248 auto vec = ampl->getWCVectorFromDict(values);
250 ampl->updateWCTensor(vec, itWC->second[0]);
256 if (ampl !=
nullptr) {
261 auto vec = ampl->getWCVectorFromSettings(what);
266 ampl->updateWCSettings(vec, what);
269 ampl->updateWCTensor(vec, itWC->second[0]);
272 ampl->updateWCTensor(vec, itWC->second[1]);
275 ampl->updateWCTensor(vec, itWC->second[0]);
276 ampl->updateWCTensor(vec, itWC->second[1]);
283 const vector<complex<double>>& values)
const {
286 if (ampl !=
nullptr) {
287 ampl->updateWCTensor(values, t);
293 const map<
string, complex<double>>& values)
const {
296 if (ampl !=
nullptr) {
297 auto vec = ampl->getWCVectorFromDict(values);
298 ampl->updateWCTensor(vec, t);
307 auto it2 = it->second.find(schemeName);
308 if(it2 != it->second.end()) {
317 const vector<double>& values) {
324 ff->updateFFErrSettings(values);
326 vector<double> tmpvalues;
327 tmpvalues.reserve(values.size() + 1);
328 tmpvalues.push_back(1.);
329 tmpvalues.insert(tmpvalues.end(), values.begin(),values.end());
330 for(
auto& elem: schemes) {
331 auto itFFE2 = itFFE1->second.find(elem);
332 if(itFFE2 != itFFE1->second.end()) {
333 ff->updateFFErrTensor(tmpvalues, itFFE2->second);
346 ff->updateFFErrSettings(values);
347 auto vec = ff->getErrVectorFromSettings();
349 for (
auto& elem : schemes) {
350 auto itFFE2 = itFFE1->second.find(elem);
351 if (itFFE2 != itFFE1->second.end()) {
352 ff->updateFFErrTensor(vec, itFFE2->second);
369 vector<double> tmpvalues;
370 tmpvalues.reserve(values.size() + 1);
371 tmpvalues.push_back(1.);
372 tmpvalues.insert(tmpvalues.end(), values.begin(), values.end());
373 for (
auto& elem : schemes) {
374 auto itFFE2 = itFFE1->second.find(elem);
375 if (itFFE2 != itFFE1->second.end()) {
376 ff->updateFFErrTensor(tmpvalues, itFFE2->second);
392 auto vec = ff->getErrVectorFromDict(values);
394 for (
auto& elem : schemes) {
395 auto itFFE2 = itFFE1->second.find(elem);
396 if (itFFE2 != itFFE1->second.end()) {
397 ff->updateFFErrTensor(vec, itFFE2->second);
411 auto n = ff->getErrVectorFromSettings().size();
412 vector<double> tmpvalues(n-1);
413 tmpvalues.reserve(n);
414 ff->updateFFErrSettings(tmpvalues);
415 tmpvalues.insert(tmpvalues.begin(),1.);
417 for(
auto& elem: schemes) {
418 auto itFFE2 = itFFE1->second.find(elem);
419 if(itFFE2 != itFFE1->second.end()) {
420 ff->updateFFErrTensor(tmpvalues, itFFE2->second);
427 const vector<double>& values)
const {
431 ff->updateFFErrTensor(values, t);
437 const map<string, double>& values)
const {
441 auto vec = ff->getErrVectorFromDict(values);
442 ff->updateFFErrTensor(vec, t);
455 elem.second->updateWCTensor(vecN, res.first->second[0]);
457 elem.second->updateWCTensor(vecD, res.first->second[1]);
460 for (
auto& elem: *_processWilsonCoefficients){
461 _processSpecializedWilsonCoefficients.insert({elem.first, elem.second[0]});
465 void ExternalData::initFormFactorErrors() {
467 for (
auto& elem : _providers->getAllFFErrProviders()) {
470 for (
auto& elem2 : elem.second) {
473 bool useDefault = (elem2.first ==
"Denominator");
474 auto vecN = elem2.second->getErrVectorFromSettings(useDefault);
475 elem2.second->updateFFErrTensor(vecN, res2.first->second);
482 void ExternalData::initExternalVectors() {
484 _externalVectors->reserve(_schemes.size() + 1);
485 for (
auto& elem : _schemes) {
491 void ExternalData::init(vector<string> schemeNames) {
493 _schemes = schemeNames;
494 initExternalVectors();
495 if (settings !=
nullptr) {
496 initWilsonCoefficients();
497 initFormFactorErrors();
502 Log& ExternalData::getLog()
const {
503 return Log::getLog(
"Hammer.ExternalData");
PDG codes to UID functions.
std::map< IndexLabel, AmplitudeBase * > getAllWCProviders() const
virtual MultiDimensional::SharedTensorData getWilsonCoefficients(PdgId parent, const std::vector< PdgId > &daughters, const std::vector< PdgId > &granddaughters={}, WTerm what=WTerm::NUMERATOR) const
virtual void defineSettings()
purely virtual function for a class to define new settings
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)
void setWilsonCoefficientsLocal(const std::string &prefixName, const std::vector< std::complex< double >> &values)
std::unordered_map< K, V, boost::hash< K >> UMap
Base class for amplitudes.
std::pair< std::string, IndexLabel > getWCInfo() const
virtual MultiDimensional::SharedTensorData getFFEigenVectors(FormFactorBase *ff, const std::string &schemeName) const
void resetFFEigenVectors(const FFPrefixGroup &process)
boost::thread_specific_ptr< processWilsonCoefficientsType > _processWilsonCoefficients
Container class for values of WC and FF vectors.
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
std::map< IndexLabel, MultiDimensional::SharedTensorData > _processSpecializedWilsonCoefficients
Interface class for amplitudes, rates, FFs dictionary container.
void initFormFactorErrors()
Message logging routines.
Hammer base amplitude class.
IndexLabel getWCLabel(const std::string &wcPrefix) const
void setFFEigenVectorsLocal(const FFPrefixGroup &process, const std::vector< double > &values)
std::map< std::string, bool > _isWCSpecializedDict
void initWilsonCoefficients()
virtual AmplitudeBase * getAmplitude(PdgId parent, const std::vector< PdgId > &daughters, const std::vector< PdgId > &granddaughters={}) const
std::shared_ptr< IContainer > SharedTensorData
boost::thread_specific_ptr< externalVectorsType > _externalVectors
std::map< IndexLabel, SchemeDict< MultiDimensional::SharedTensorData >> processFFEigenVectorsType
IndexLabel getFFErrLabel(const FFPrefixGroup &process) const
Order-0 tensor data container.
void setFFEigenVectors(const FFPrefixGroup &process, const std::vector< double > &values)
std::unordered_map< std::string, UMap< LabelsList, Tensor >> externalVectorsType
virtual const Tensor & getExternalVectors(std::string schemeName, LabelsList labels) const
IndexLabel
label identifiers of tensor indices they are used to determine which indices can be contracted togeth...
Multidimensional tensor class with complex numbers as elements.
TensorData makeScalar(complex< double > value)
MultiDimensional::SharedTensorData getTempWilsonCoefficients(const std::string &prefixName, const std::vector< std::complex< double >> &values) const
std::vector< std::string > _schemes
Hammer settings manager class.
std::vector< IndexLabel > LabelsList
void specializeWCInWeights(const std::string &prefixName, const std::map< std::string, std::complex< double >> &settings)
const ProvidersRepo * _providers
std::map< SchemeName, T > SchemeDict
FormFactorBase * getFFErrProvider(const FFPrefixGroup &process) const
AmplitudeBase * getWCProvider(const std::string &wcPrefix) const
void updateWCSettings(const std::vector< std::complex< double >> &values, WTerm what)
boost::thread_specific_ptr< processFFEigenVectorsType > _processFFEigenVectors
Hammer available modules header.
void resetSpecializeWCInWeights(const std::string &prefixName)
bool isWCSpecialized(AmplitudeBase *ampl) const
Serialization related typedefs and includes.
const std::set< std::string > schemeNamesFromPrefixAndGroup(const FFPrefixGroup &value) const