Documentation of MARTY
A Modern ARtificial Theoretical phYsicist
amplitude.h
Go to the documentation of this file.
1 // This file is part of MARTY.
2 //
3 // MARTY is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, either version 3 of the License, or
6 // (at your option) any later version.
7 //
8 // MARTY is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with MARTY. If not, see <https://www.gnu.org/licenses/>.
15 
26 #pragma once
27 
28 #include "feynmanDiagram.h"
29 #include "kinematics.h"
30 
31 namespace mty {
32 
41  class Amplitude {
42 
43  public:
44 
45  friend class AmplitudeInitializer;
46 
55  Amplitude(
56  FeynOptions const &t_options,
57  Kinematics const &t_kinematics
58  );
59 
67  Amplitude(
68  FeynOptions const &t_options,
69  std::vector<mty::FeynmanDiagram> const &t_diagrams,
70  mty::Kinematics const &t_kinematics
71  );
72 
81  Amplitude(
82  FeynOptions const &t_options,
83  std::vector<mty::FeynmanDiagram> &&t_diagrams,
84  mty::Kinematics const &t_kinematics
85  );
86 
91  bool empty() const {
92  return diagrams.empty();
93  }
94 
99  size_t size() const {
100  return diagrams.size();
101  }
102 
121  csl::Expr &expression(size_t pos);
122 
130  csl::Expr const &expression(size_t pos) const;
131 
140  FeynmanDiagram::diagram_t &diagram(size_t pos);
141 
150  FeynmanDiagram::diagram_t const &diagram(size_t pos) const;
151 
158  std::vector<csl::Expr> obtainExpressions() const;
159 
166  std::vector<std::shared_ptr<mty::wick::Graph>> obtainGraphs() const;
167 
173  void add(std::vector<mty::FeynmanDiagram> const &t_diagrams);
174 
181  void add(std::vector<mty::FeynmanDiagram> &&t_diagrams);
182 
212  std::function<bool(mty::FeynmanDiagram const&)> filter
213  ) const;
214 
227  template<class First, class ...Next,
228  typename = std::enable_if_t<(sizeof...(Next) > 1)>
229  >
231  First &&first,
232  Next &&...next
233  ) const
234  {
235  return filterOut(std::forward<First>(first)).filterOut(
236  std::forward<Next>(next)...
237  );
238  }
239 
245  FeynOptions const &getOptions() const {
246  return options;
247  }
248 
255  std::vector<mty::FeynmanDiagram> const &getDiagrams() const {
256  return diagrams;
257  }
258 
265  std::vector<mty::FeynmanDiagram> &getDiagrams() {
266  return diagrams;
267  }
268 
275  return kinematics;
276  }
277 
284  return kinematics;
285  }
286 
293  csl::Expr getSum() const;
294 
305  Amplitude copy() const;
306 
313  void setKinematics(
314  Kinematics const &t_kinematics,
315  bool replace = true);
316 
317  private:
318 
327  template<class Iterator>
328  void add(Iterator first, Iterator last)
329  {
330  diagrams.insert(end(diagrams), first, last);
331  }
332 
333  private:
334 
339 
345  std::vector<mty::FeynmanDiagram> diagrams;
346 
351  };
352 
353 } // namespace mty
std::vector< mty::FeynmanDiagram > & getDiagrams()
Returns all the mty::FeynmanDiagram objects as a reference to a range.
Definition: amplitude.h:265
csl::Expr & expression(size_t pos)
Returns a reference to expression of the diagram at a given position.
Definition: amplitude.cpp:54
Amplitude filterOut(First &&first, Next &&...next) const
Applies an arbitrary number of filters on an amplitude.
Definition: amplitude.h:230
void add(std::vector< mty::FeynmanDiagram > const &t_diagrams)
Adds diagrams to the amplitude.
Definition: amplitude.cpp:110
bool empty() const
Definition: amplitude.h:91
FeynOptions options
Set of options that have been used for the calculation.
Definition: amplitude.h:338
FeynmanDiagram::diagram_t & diagram(size_t pos)
Returns a reference to the graph layout of the diagram at a given position.
Definition: amplitude.cpp:72
Namespace of MARTY.
Definition: 2HDM.h:31
Interface class containing the result of an amplitude calculation.
Definition: amplitude.h:41
Instances of this class can be given to mty::Model when launching a calculation to customize the outp...
Definition: feynOptions.h:44
Amplitude(FeynOptions const &t_options, Kinematics const &t_kinematics)
Initializes an amplitude with no diagram (to be added later using Amplitude::add()).
Definition: amplitude.cpp:20
mty::Kinematics kinematics
Kinematics of the process.
Definition: amplitude.h:350
Amplitude copy() const
Returns a copy of the amplitude.
Definition: amplitude.cpp:146
std::vector< mty::FeynmanDiagram > diagrams
Range of mty::FeynmanDiagram of the process. Each diagram contains a mathematical expression and the ...
Definition: amplitude.h:345
size_t size() const
Definition: amplitude.h:99
Contains the mty::Kinematics class.
Class containing a Feynman diagram, symbolic expression and graph included.
Definition: feynmanDiagram.h:50
Stores insertion and momenta data and provides a simple interface to manipulate it.
Definition: kinematics.h:39
Amplitude filterOut(std::function< bool(mty::FeynmanDiagram const &)> filter) const
Applies a diagram filter (mty::FeynOptions::DiagramFilter requirement) to the amplitude and returns t...
Definition: amplitude.cpp:123
csl::Expr getSum() const
Computes and returns the sum of all diagrams i.e. the total amplitude.
Definition: amplitude.cpp:138
std::vector< mty::FeynmanDiagram > const & getDiagrams() const
Returns all the mty::FeynmanDiagram objects as a const reference to a range.
Definition: amplitude.h:255
FeynOptions const & getOptions() const
Returns the options used to calculate the amplitude;.
Definition: amplitude.h:245
mty::Kinematics & getKinematics()
Returns the kinematics of the process.
Definition: amplitude.h:283
Definition: amplitudeInitializer.h:36
mty::Kinematics const & getKinematics() const
Returns the kinematics of the process.
Definition: amplitude.h:274
void add(Iterator first, Iterator last)
Template utility to add multiple diagrams at once.
Definition: amplitude.h:328
std::vector< std::shared_ptr< mty::wick::Graph > > obtainGraphs() const
Creates and return a range containing the graph layouts of all diagrams.
Definition: amplitude.cpp:100
std::vector< csl::Expr > obtainExpressions() const
Creates and return a range containing the expressions of all diagrams.
Definition: amplitude.cpp:90
void setKinematics(Kinematics const &t_kinematics, bool replace=true)
Replaces one kinematic context by another, replacing the relevant momenta in expressions.
Definition: amplitude.cpp:156
Contains the mty::FeynmanDiagram class.