Documentation of MARTY
A Modern ARtificial Theoretical phYsicist
feynmanDiagram.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/>.
23 #pragma once
24 
25 #include <csl.h>
26 #include "model.h"
27 #include "topology.h"
28 
29 namespace mty {
30 
31  namespace wick {
32  class Graph;
33  }
34 
35  class Model;
36  class Particle;
37 
51 
52  public:
53 
58 
65  template<typename T>
66  using isNotParticle_t = typename std::enable_if_t<
67  !std::is_same_v<mty::Particle, std::decay_t<T>>
68  >;
69 
74 
77  Loop,
78  Any
79  };
80 
82  mty::Model const &t_model
83  );
84 
86  mty::Model const &t_model,
87  csl::Expr const &t_expression,
88  diagram_t const &t_diagram
89  );
90 
100  bool isZero() const {
101  return CSL_0 == expression;
102  }
103 
109  csl::Expr const &getExpression() const { return expression; }
110 
116  csl::Expr &getExpression() { return expression; }
117 
123  diagram_t &getDiagram() { return diagram; }
124 
130  diagram_t const &getDiagram() const { return diagram; }
131 
143  std::vector<mty::Particle> const &getParticles(
144  DiagramParticleType type = Any
145  ) const;
146 
176  bool contains(
177  mty::Particle const &part,
178  DiagramParticleType type = Any
179  ) const;
180 
191  bool isExternal(mty::Particle const &particle) const {
192  return contains(particle, External);
193  }
204  bool isMediator(mty::Particle const &particle) const {
205  return contains(particle, Mediator);
206  }
217  bool isInLoop(mty::Particle const &particle) const {
218  return contains(particle, Loop);
219  }
231  bool isInternal(mty::Particle const &particle) const {
232  return isMediator(particle) || isInLoop(particle);
233  }
234 
239  bool isTreeLevel() const {
240  return getNLoops() == 0;
241  }
242 
247  bool isLoop() const {
248  return !isTreeLevel();
249  }
250 
254  int getNLoops() const;
255 
276  bool isTopology(int topology) const;
277 
296  template<typename T, typename = isNotParticle_t<T>>
297  bool contains(
298  T &&part,
299  DiagramParticleType type = Any
300  ) const {
301  return contains(
302  model->getParticle(std::forward<T>(part)),
303  type
304  );
305  }
306 
329  template<typename T, typename = isNotParticle_t<T>>
330  bool isExternal(T &&particle) const {
331  return isExternal(model->getParticle(std::forward<T>(particle)));
332  }
355  template<typename T, typename = isNotParticle_t<T>>
356  bool isMediator(T &&particle) const {
357  return isMediator(model->getParticle(std::forward<T>(particle)));
358  }
381  template<typename T, typename = isNotParticle_t<T>>
382  bool isInLoop(T &&particle) const {
383  return isInLoop(model->getParticle(std::forward<T>(particle)));
384  }
407  template<typename T, typename = isNotParticle_t<T>>
408  bool isInternal(T &&particle) const {
409  return isInternal(model->getParticle(std::forward<T>(particle)));
410  }
411 
420  FeynmanDiagram copy() const;
421 
433  static FeynmanDiagram combine(
434  FeynmanDiagram const &A,
435  FeynmanDiagram const &B,
436  Particle const &mediator
437  );
438 
439  private:
440 
449  std::vector<mty::Particle> &getParticles(
450  DiagramParticleType type = Any
451  );
452 
460  void addParticle(
461  mty::Particle const &part,
463  );
464 
482  template<typename T, typename = isNotParticle_t<T>>
484  T &&part,
486  )
487  {
488  addParticle(
489  model->getParticle(std::forward<T>(part)),
490  type
491  );
492  }
493 
494  void loadParticlesFromVertices(
495  std::vector<mty::wick::Vertex> const &vertices
496  );
497 
501  void updateParticleData();
502 
506  void updateParticleData(std::vector<mty::wick::Vertex> const &vertices);
507 
512  void mergeParticles();
513 
514  private:
515 
519  Model const *model;
520 
525 
530 
536 
540  int nLoops;
541 
545  std::vector<mty::Particle> allParticles;
546 
550  std::vector<mty::Particle> externalParticles;
551 
561  std::vector<mty::Particle> mediatorParticles;
562 
568  std::vector<mty::Particle> loopParticles;
569  };
570 
571 }
bool isMediator(T &&particle) const
Tells if a particle is a mediator particle in the diagram.
Definition: feynmanDiagram.h:356
std::vector< mty::Particle > allParticles
List of all particles in the process.
Definition: feynmanDiagram.h:545
bool contains(T &&part, DiagramParticleType type=Any) const
Tells if one particle is contained in the diagram for a given type.
Definition: feynmanDiagram.h:297
Contains utilities to handle topologies for Feynman diagrams.
This class inherits from std::shared_ptr<QuantumFieldParent> and should be used instead of direct Qua...
Definition: quantumField.h:1409
Namespace of MARTY.
Definition: 2HDM.h:31
Contains the mty::Model class. It contains all objects in the theory. In particular QuantumField obje...
std::vector< mty::Particle > mediatorParticles
List of mediator particles in the process.
Definition: feynmanDiagram.h:561
std::vector< mty::Particle > externalParticles
List of external particles in the process.
Definition: feynmanDiagram.h:550
int cycleLength
Length of the cycle (momentum integral) if the calculation is at one-loop.
Definition: feynmanDiagram.h:535
bool isInLoop(T &&particle) const
Tells if a particle is a looped particle in the diagram.
Definition: feynmanDiagram.h:382
csl::Expr expression
Expression result of the calculation.
Definition: feynmanDiagram.h:524
void addParticle(T &&part, DiagramParticleType type)
Template overload for non-mty::Particle objects.
Definition: feynmanDiagram.h:483
bool isExternal(mty::Particle const &particle) const
Tells if a particle is an external particle in the diagram.
Definition: feynmanDiagram.h:191
int nLoops
Number of loops in the diagram.
Definition: feynmanDiagram.h:540
bool isInternal(mty::Particle const &particle) const
Tells if a particle is an internal particle in the diagram.
Definition: feynmanDiagram.h:231
Model const * model
Pointer to the model in which the calculation has been done.
Definition: feynmanDiagram.h:519
bool isExternal(T &&particle) const
Tells if a particle is an external particle in the diagram.
Definition: feynmanDiagram.h:330
csl::Expr const & getExpression() const
Returns the diagrams&#39;s expression as a const reference.
Definition: feynmanDiagram.h:109
bool isInternal(T &&particle) const
Tells if a particle is an internal particle in the diagram.
Definition: feynmanDiagram.h:408
bool isMediator(mty::Particle const &particle) const
Tells if a particle is a mediator particle in the diagram.
Definition: feynmanDiagram.h:204
Class containing a Feynman diagram, symbolic expression and graph included.
Definition: feynmanDiagram.h:50
bool isInLoop(mty::Particle const &particle) const
Tells if a particle is a looped particle in the diagram.
Definition: feynmanDiagram.h:217
bool isZero() const
Tells if the diagram vanishes.
Definition: feynmanDiagram.h:100
diagram_t const & getDiagram() const
Returns the diagram&#39;s graph as a const reference.
Definition: feynmanDiagram.h:130
diagram_t diagram
Graph to forward to GRAFED to display it on screen.
Definition: feynmanDiagram.h:529
diagram_t & getDiagram()
Returns the diagram&#39;s graph as a reference.
Definition: feynmanDiagram.h:123
Contains all objects in the theory. In particular QuantumField objects, Gauge, Flavor, Particle...
Definition: model.h:68
Any topologies i.e. combination of all 5 possible topologies.
Definition: topology.h:59
bool isTreeLevel() const
Definition: feynmanDiagram.h:239
Definition: feynmanDiagram.h:75
typename std::enable_if_t< !std::is_same_v< mty::Particle, std::decay_t< T > > > isNotParticle_t
Helper type definition ensuring that the type T is not a mty::Particle.
Definition: feynmanDiagram.h:68
bool isLoop() const
Definition: feynmanDiagram.h:247
std::vector< mty::Particle > loopParticles
List of particles in loops in the process.
Definition: feynmanDiagram.h:568
csl::Expr & getExpression()
Returns the diagrams&#39;s expression as a reference.
Definition: feynmanDiagram.h:116
Definition: feynmanDiagram.h:77
DiagramParticleType
Possible types of particles in a diagram.
Definition: feynmanDiagram.h:73
Definition: feynmanDiagram.h:76