Documentation of MARTY
A Modern ARtificial Theoretical phYsicist
fermionFlow.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 
24 #ifndef FERMIONFLOW_H_INCLUDED
25 #define FERMIONFLOW_H_INCLUDED
26 
27 #include <vector>
28 #include <csl.h>
29 
30 namespace mty {
31 
32  class QuantumField;
33  class ConjugationList;
34  struct FermionLine;
35 
41 
42  public:
43 
47  enum Type {
48 
53 
58 
63  };
64 
69  using FieldList = std::vector<mty::QuantumField const*>;
70 
85  constexpr static size_t maxFermionLines = 3;
86 
107  FieldList init,
108  FieldList const &ruleOrder,
109  bool ruleMode
110  );
111 
125  FieldList const &init,
126  std::vector<QuantumField> const &ruleOrder,
127  bool ruleMode
128  );
129 
144  static void simplify(
145  ConjugationList &infoList,
146  bool ruleMode
147  );
148 
149  static void applyConjugation(
150  ConjugationList infoList,
151  csl::Expr &expr,
152  bool ruleMode
153  );
154 
155  public:
156 
162  ConjugationInfo();
163 
171  explicit
173  csl::Index const &t_A,
174  bool t_conjugated
175  );
176 
184  csl::Index const &t_A,
185  csl::Index const &t_B,
186  csl::Index const &t_preA,
187  csl::Index const &t_postB
188  );
189 
193  ~ConjugationInfo() = default;
194 
200  ConjugationInfo(ConjugationInfo const &) = default;
206  ConjugationInfo(ConjugationInfo &&) = default;
214  ConjugationInfo &operator=(ConjugationInfo const &) = default;
223 
227  Type getType() const { return type; }
228 
232  csl::Index getA() const { return A; }
233 
238  csl::Index getB() const { return B; }
239 
244  csl::Index getPreA() const { return preA; }
245 
250  csl::Index getPostB() const { return postB; }
251 
256  bool getConjugated() const { return conjugated; }
257 
265  void setInfo(
266  csl::Index const &t_A,
267  bool t_conjugated
268  );
269 
277  void setInfo(
278  csl::Index const &t_A,
279  csl::Index const &t_B,
280  csl::Index const &t_preA,
281  csl::Index const &t_postB
282  );
283 
296  void apply(
297  csl::Expr &expr,
298  bool ruleMode,
299  std::vector<FermionLine> const &lines
300  ) const;
301 
302  protected:
303 
304  void insertInChain(
305  csl::Expr &expr
306  ) const;
307 
308  void insertInChainForRule(
309  csl::Expr &expr,
310  std::vector<FermionLine> const &lines
311  ) const;
312 
313  void insertExternal(
314  csl::Expr &expr
315  ) const;
316 
317  protected:
318 
324 
329 
335 
341 
347 
353  };
354 
355  struct FermionLine {
356 
358  std::vector<csl::Index> indices;
359  };
360 
361  class ConjugationList: public std::vector<ConjugationInfo> {
362 
363  public:
364 
366  std::vector<ConjugationInfo> const &info,
367  int &t_sign,
368  std::vector<FermionLine> const &t_lines,
369  std::vector<QuantumField const*> const &t_bosons
370  )
371  :std::vector<ConjugationInfo>(info),
372  sign(t_sign),
373  lines(t_lines),
374  bosons(t_bosons)
375  {}
376 
377  std::vector<QuantumField const *> getFinalOrder(
378  size_t sizeHint = 10
379  ) const {
380  std::vector<QuantumField const *> finalOrder;
381  finalOrder.reserve(sizeHint);
382  for (const auto &b : bosons)
383  finalOrder.push_back(b);
384  for (const auto &line : lines)
385  for (const auto &f : line.fields)
386  finalOrder.push_back(f);
387 
388  return finalOrder;
389  }
390 
391  int sign = 1;
392  std::vector<FermionLine> lines;
393  std::vector<QuantumField const*> bosons;
394  };
395 
396  std::ostream &operator<<(
397  std::ostream &out,
399  );
400 
401  std::ostream &operator<<(
402  std::ostream &out,
403  ConjugationInfo const &info
404  );
405 
406  ConjugationInfo::FieldList::iterator getExternalBegin(
408  );
409  ConjugationInfo::FieldList::iterator getInternalBegin(
411  );
412  ConjugationInfo::FieldList::iterator getBegin(
414  );
415 
416 } // End of namespace mty
417 
418 #endif
bool conjugated
Boolean for External ConjugationInfo, tells if the external leg is complex conjugated.
Definition: fermionFlow.h:352
Class encapsulating necesarry data to place conjugation matrices in amplitudes when treating Majorana...
Definition: fermionFlow.h:40
std::vector< mty::QuantumField const * > FieldList
Quick definition of the data structure for a field list in this file.
Definition: fermionFlow.h:69
Definition: fermionFlow.h:355
csl::Index preA
Index before A in the chain, not valued for External ConjugationInfo.
Definition: fermionFlow.h:340
Type type
Type of ConjugationInfo. Can be external (external leg) or internal (part of gamma-matrices chain)...
Definition: fermionFlow.h:323
std::ostream & operator<<(std::ostream &fout, csl::Type type)
Namespace of MARTY.
Definition: 2HDM.h:31
ConjugationInfo & operator=(ConjugationInfo const &)=default
Default copy assignement operator.
void setInfo(csl::Index const &t_A, bool t_conjugated)
Sets info for an external ConjugationInfo. See the corresponding constructor for more info...
Definition: fermionFlow.cpp:589
Type getType() const
Returns the type.
Definition: fermionFlow.h:227
static ConjugationList resolveFermionLines(FieldList init, FieldList const &ruleOrder, bool ruleMode)
Resolves all fermion lines in a set of fields.
Definition: fermionFlow.cpp:351
csl::Index B
Second index of the chain, not valued for External ConjugationInfo.
Definition: fermionFlow.h:334
csl::Index getA() const
Returns the first index of the ConjugationInfo.
Definition: fermionFlow.h:232
Conjugation of a part of a gamma-matrices chain.
Definition: fermionFlow.h:62
csl::Index postB
Index after B in the chain, not valued for External ConjugationInfo.
Definition: fermionFlow.h:346
Undefined ConjugationInfo.
Definition: fermionFlow.h:52
bool getConjugated() const
Returns the conjugation of the ConjugationInfo, has a meaning only for External ConjugationInfo.
Definition: fermionFlow.h:256
static constexpr size_t maxFermionLines
Maximum number of fermion lines in a diagram.
Definition: fermionFlow.h:85
void apply(csl::Expr &expr, bool ruleMode, std::vector< FermionLine > const &lines) const
Applies the conjugation on the underlying expression.
Definition: fermionFlow.cpp:613
Definition: fermionFlow.h:361
ConjugationInfo()
Constructs an empty ConjugationInfo. Will do nothing.
Definition: fermionFlow.cpp:565
Type
Type of ConjugationInfo.
Definition: fermionFlow.h:47
~ConjugationInfo()=default
Default constructor.
csl::Index A
First (or only for External type) index of the chain.
Definition: fermionFlow.h:328
static void simplify(ConjugationList &infoList, bool ruleMode)
Simplifies a set of ConjugationInfo, merging the consecutive ones.
Definition: fermionFlow.cpp:467
Conjugation of an external leg.
Definition: fermionFlow.h:57
csl::Index getPreA() const
Returns the index before A in the chain, has a meaning only for Internal ConjugationInfo.
Definition: fermionFlow.h:244
csl::Index getB() const
Returns the second index of the ConjugationInfo, has a meaning only for Internal ConjugationInfo.
Definition: fermionFlow.h:238
csl::Index getPostB() const
Returns the index after B in the chain, has a meaning only for Internal ConjugationInfo.
Definition: fermionFlow.h:250