Hammer  1.0.0
Helicity Amplitude Module for Matrix Element Reweighting
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FormFactorBase.hh
Go to the documentation of this file.
1 ///
2 /// @file FormFactorBase.hh
3 /// @brief Hammer base form factor 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 #ifndef HAMMER_FORMFACTOR_BASE
13 #define HAMMER_FORMFACTOR_BASE
14 
15 #include <string>
16 #include <utility>
17 #include <vector>
18 #include <memory>
19 
20 
22 #include "Hammer/Math/Tensor.hh"
23 #include "Hammer/Tools/Logging.hh"
26 
27 namespace Hammer {
28 
29  class Log;
30 
31  /// @brief Base class for form factors
32  ///
33  /// Provides the form factor contents as tensor...
34  ///
35  /// @ingroup Base
36  class FormFactorBase : public ParticleData, public SettingsConsumer {
37 
38  public:
40 
41  FormFactorBase(const FormFactorBase& other);
42  FormFactorBase& operator=(const FormFactorBase& other) = delete;
43 
44  FormFactorBase(FormFactorBase&& other) = delete;
45  FormFactorBase& operator=(FormFactorBase&& other) = delete;
46  virtual ~FormFactorBase() noexcept = default;
47 
48  public:
49  /// @brief method to evaluate the object on a specific particle set
50  /// @param[in] parent the parent Particle
51  /// @param[in] daughters the daughters (and grand-daughters, if necessary) Particle list
52  /// @param[in] references the parent Particle siblings (necessary e.g. for helicity amplitude phase conventions)
53  virtual void eval(const Particle& parent, const ParticleList& daughters,
54  const ParticleList& references) = 0;
55 
56  /// @brief
57  /// @param[in] label
58  /// @return
59  virtual std::unique_ptr<FormFactorBase> clone(const std::string& label) = 0;
60 
61  public:
62 
63  std::vector<double> getErrVectorFromDict(const std::map<std::string, double>& errDict) const;
64  std::vector<double> getErrVectorFromSettings(bool useDefault = false) const;
65 
66  void updateFFErrSettings(const std::vector<double>& values);
67  void updateFFErrSettings(const std::map<std::string, double>& values);
68 
69  void updateFFErrTensor(std::vector<double> values, MultiDimensional::SharedTensorData& data) const;
70 
71  /// @brief
72  /// @return
73  const FFPrefixGroup& getFFErrPrefixGroup() const;
74 
75  std::pair<FFPrefixGroup, IndexLabel> getFFErrInfo() const;
76 
77  /// @brief initializes the form factor (defines settings associated to this form factor, etc.)
78  void init();
79 
80  /// @brief returns a reference to itself as a Tensor
81  /// @return itself
82  Tensor& getTensor();
83 
84  /// @brief returns a reference to itself as a Tensor
85  /// @return itself
86  const Tensor& getTensor() const;
87 
88  /// @brief
89  /// @param[in] intPoints
90  /// @return
91  Tensor getFFPSIntegrand(const EvaluationGrid& intPoints);
92 
93  /// @brief
94  /// @return
95  const std::string& group() const;
96 
97  /// @brief compute unit rescaling of this class wrt MC units
98  void calcUnits();
99 
100  protected:
101  /// @brief defines new settings for this class
102  virtual void defineSettings() = 0;
103 
104  /// @brief
105  /// @param[in] point other invariant masses
106  /// @param[in] masses
107  /// @return
108  virtual void evalAtPSPoint(const std::vector<double>& point, const std::vector<double>& masses = {}) = 0;
109 
110  /// @brief Sets the FF parametrization scheme label. Enforced to be same over the set of signatures.
111  /// @param[in] name
112  void setGroup(const std::string& name);
113 
114  /// @brief Sets the XtoY formal process label. May vary over the set of signatures.
115  /// @param[in] name
116  void setPrefix(const std::string& name);
117 
118  /// @brief set units for the FF class parameters
119  /// @param[in] name
120  void setUnits(const std::string& name);
121 
122  /// @brief adds the index labels for the form factor tensor for a specific signature to the
123  /// index labels signature list. It will be selected by calling setSignatureIndex
124  /// @param[in] tensor the tensor indices labels
125  void addTensor(Tensor&& tensor);
126 
127  /// @brief derived from ParticleData::addProcessSignature, also populates _FFInfoList
128  /// @param[in] parent the parent PDG code
129  /// @param[in] daughters the list of daughter PDG codes
130  void addProcessSignature(PdgId parent, const std::vector<PdgId>& daughters);
131 
132  protected:
133  /// @brief logging facility
134  /// @return stream to be used for logging
135  Log& getLog() const;
136 
137  protected:
140  std::vector<std::pair<FFPrefixGroup, IndexLabel>> _FFInfoList; ///< list of {prefix/group struct, uncertainty label} (one for each signature)
141  std::vector<std::string> _FFErrNames;
142  std::vector<Tensor> _tensorList; ///< list of (list of) labels for the tensor indices (one for each signature)
143  double _units;
144  bool _unitsinit = false;
145  };
146 
147 } // namespace Hammer
148 
149 #define MAKE_CLONE(OBJ, LABEL) \
150  do { \
151  unique_ptr<FormFactorBase> result; \
152  OBJ* tmp = new OBJ(*this); \
153  if (tmp != nullptr) { \
154  tmp->setGroup(tmp->group() + "_" + LABEL); \
155  result.reset(tmp); \
156  } \
157  return result; \
158  } while (0)
159 
160 #endif
virtual std::unique_ptr< FormFactorBase > clone(const std::string &label)=0
FFPrefixGroup _errPrefixGroup
Base class for form factors.
FormFactorBase & operator=(const FormFactorBase &other)=delete
Hammer numerical integration forward declarations.
virtual void eval(const Particle &parent, const ParticleList &daughters, const ParticleList &references)=0
method to evaluate the object on a specific particle set
std::vector< std::pair< FFPrefixGroup, IndexLabel > > _FFInfoList
list of {prefix/group struct, uncertainty label} (one for each signature)
Hammer decay PDG code management.
std::vector< Tensor > _tensorList
list of (list of) labels for the tensor indices (one for each signature)
Log & getLog() const
logging facility
Message logging routines.
void setUnits(const std::string &name)
set units for the FF class parameters
void init()
initializes the form factor (defines settings associated to this form factor, etc.)
std::pair< FFPrefixGroup, IndexLabel > getFFErrInfo() const
void updateFFErrSettings(const std::vector< double > &values)
Tensor & getTensor()
returns a reference to itself as a Tensor
Base class to access the settings repository.
std::vector< double > getErrVectorFromSettings(bool useDefault=false) const
std::shared_ptr< IContainer > SharedTensorData
Tensor getFFPSIntegrand(const EvaluationGrid &intPoints)
std::vector< double > getErrVectorFromDict(const std::map< std::string, double > &errDict) const
const std::string & group() const
const std::vector< double > & masses() const
returns the particle masses of the current decay signature
Definition: ParticleData.cc:44
std::vector< Particle > ParticleList
Definition: Particle.fhh:20
Logging class.
Definition: Logging.hh:33
virtual void evalAtPSPoint(const std::vector< double > &point, const std::vector< double > &masses={})=0
Particle class.
Definition: Particle.hh:30
IndexLabel
label identifiers of tensor indices they are used to determine which indices can be contracted togeth...
Definition: IndexLabels.hh:27
Multidimensional tensor class with complex numbers as elements.
Definition: Tensor.hh:33
void calcUnits()
compute unit rescaling of this class wrt MC units
Base class for accessing Hammer settings repository.
std::vector< std::string > _FFErrNames
const FFPrefixGroup & getFFErrPrefixGroup() const
virtual void defineSettings()=0
defines new settings for this class
void setPrefix(const std::string &name)
Sets the XtoY formal process label.
void addProcessSignature(PdgId parent, const std::vector< PdgId > &daughters)
derived from ParticleData::addProcessSignature, also populates _FFInfoList
void addTensor(Tensor &&tensor)
adds the index labels for the form factor tensor for a specific signature to the index labels signatu...
std::vector< std::vector< double >> EvaluationGrid
Definition: Integrator.fhh:26
int PdgId
Definition: Pdg.fhh:17
void updateFFErrTensor(std::vector< double > values, MultiDimensional::SharedTensorData &data) const
Hammer tensor class.
virtual ~FormFactorBase() noexcept=default
void setGroup(const std::string &name)
Sets the FF parametrization scheme label.
PDG code process signature class.
Definition: ParticleData.hh:33