evtgen is hosted by Hepforge, IPPP Durham
EvtGen  2.0.0
Monte Carlo generator of particle decays, in particular the weak decays of heavy flavour particles such as B mesons.
EvtSpinAmp.hh
Go to the documentation of this file.
1 
2 /***********************************************************************
3 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors *
4 * *
5 * This file is part of EvtGen. *
6 * *
7 * EvtGen is free software: you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation, either version 3 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * EvtGen is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with EvtGen. If not, see <https://www.gnu.org/licenses/>. *
19 ***********************************************************************/
20 
21 #ifndef __EVTSPINAMP_HH__
22 #define __EVTSPINAMP_HH__
23 
24 #include "EvtGenBase/EvtComplex.hh"
26 
27 #include <vector>
28 using std::vector;
29 
30 #include <cstdarg>
31 
32 class EvtSpinAmp;
33 EvtSpinAmp operator*( const EvtComplex&, const EvtSpinAmp& );
34 EvtSpinAmp operator*( const EvtSpinAmp&, const EvtComplex& );
35 EvtSpinAmp operator/( const EvtSpinAmp&, const EvtComplex& );
36 
37 class EvtSpinAmp {
38  friend EvtSpinAmp operator*( const EvtComplex&, const EvtSpinAmp& );
39  friend EvtSpinAmp operator*( const EvtSpinAmp&, const EvtComplex& );
40  friend EvtSpinAmp operator/( const EvtSpinAmp&, const EvtComplex& );
41  friend std::ostream& operator<<( std::ostream&, const EvtSpinAmp& );
42 
43  public:
45  EvtSpinAmp( const vector<EvtSpinType::spintype>& );
46  EvtSpinAmp( const vector<EvtSpinType::spintype>&, const EvtComplex& );
47  EvtSpinAmp( const vector<EvtSpinType::spintype>&, const vector<EvtComplex>& );
48  EvtSpinAmp( const EvtSpinAmp& );
49 
51 
52  // Input to the index functions are twice the magnetic quantum number
53  EvtComplex& operator()( const vector<int>& );
54  const EvtComplex& operator()( const vector<int>& ) const;
55  EvtComplex& operator()( int, ... );
56  const EvtComplex& operator()( int, ... ) const;
57 
58  EvtSpinAmp& operator=( const EvtSpinAmp& );
59 
60  EvtSpinAmp operator+( const EvtSpinAmp& ) const;
61  EvtSpinAmp& operator+=( const EvtSpinAmp& );
62 
63  EvtSpinAmp operator-( const EvtSpinAmp& ) const;
64  EvtSpinAmp& operator-=( const EvtSpinAmp& );
65 
66  // Direct Product
67  EvtSpinAmp operator*(const EvtSpinAmp&)const;
68  EvtSpinAmp& operator*=( const EvtSpinAmp& );
69 
70  EvtSpinAmp& operator*=( const EvtComplex& );
71  EvtSpinAmp& operator/=( const EvtComplex& );
72 
73  // Contraction of amplitudes
74  void intcont( size_t, size_t );
75  void extcont( const EvtSpinAmp&, int, int );
76 
77  // assign this value to every member in the container
78  void assign( const EvtComplex& val ) { _elem.assign( _elem.size(), val ); }
79 
80  // get the order of the container
81  size_t rank() const { return _twospin.size(); }
82 
83  // get the dimension vector of the container
84  const vector<unsigned int>& dims() const { return _twospin; }
85 
86  // set the elements and the dimensions of the vector - useful for something
87  // things eventough it is usually not the cleanest solution
88  void addspin( int twospin ) { _twospin.push_back( twospin ); }
89  void setelem( const vector<EvtComplex>& elem ) { _elem = elem; }
90 
91  bool iterate( vector<int>& index ) const;
92  vector<int> iterinit() const;
93 
94  bool allowed( const vector<int>& index ) const;
95  bool iterateallowed( vector<int>& index ) const;
96  vector<int> iterallowedinit() const;
97 
98  private:
99  void checkindexargs( const vector<int>& index ) const;
100  void checktwospin( const vector<unsigned int>& twospin ) const;
101  int findtrueindex( const vector<int>& index ) const;
102  vector<unsigned int> calctwospin(
103  const vector<EvtSpinType::spintype>& type ) const;
104 
105  vector<EvtSpinType::spintype> _type;
106  vector<unsigned int> _twospin;
107  vector<EvtComplex> _elem;
108 };
109 
110 #endif // __EVTSPINAMP__
size_t rank() const
Definition: EvtSpinAmp.hh:81
EvtSpinAmp operator *(const EvtComplex &, const EvtSpinAmp &)
Definition: EvtSpinAmp.cpp:46
EvtSpinAmp & operator/=(const EvtComplex &)
Definition: EvtSpinAmp.cpp:381
bool iterateallowed(vector< int > &index) const
Definition: EvtSpinAmp.cpp:442
EvtComplex & operator()(const vector< int > &)
Definition: EvtSpinAmp.cpp:196
void extcont(const EvtSpinAmp &, int, int)
Definition: EvtSpinAmp.cpp:522
void checktwospin(const vector< unsigned int > &twospin) const
Definition: EvtSpinAmp.cpp:138
vector< int > iterallowedinit() const
Definition: EvtSpinAmp.cpp:452
void checkindexargs(const vector< int > &index) const
Definition: EvtSpinAmp.cpp:149
EvtSpinAmp & operator+=(const EvtSpinAmp &)
Definition: EvtSpinAmp.cpp:297
int findtrueindex(const vector< int > &index) const
Definition: EvtSpinAmp.cpp:182
const vector< unsigned int > & dims() const
Definition: EvtSpinAmp.hh:84
EvtSpinAmp & operator=(const EvtSpinAmp &)
Definition: EvtSpinAmp.cpp:276
vector< unsigned int > _twospin
Definition: EvtSpinAmp.hh:106
vector< unsigned int > calctwospin(const vector< EvtSpinType::spintype > &type) const
Definition: EvtSpinAmp.cpp:73
void setelem(const vector< EvtComplex > &elem)
Definition: EvtSpinAmp.hh:89
bool allowed(const vector< int > &index) const
Definition: EvtSpinAmp.cpp:416
EvtSpinAmp & operator-=(const EvtSpinAmp &)
Definition: EvtSpinAmp.cpp:318
vector< int > iterinit() const
Definition: EvtSpinAmp.cpp:389
EvtSpinAmp operator/(const EvtSpinAmp &, const EvtComplex &)
Definition: EvtSpinAmp.cpp:62
EvtSpinAmp & operator *=(const EvtSpinAmp &)
Definition: EvtSpinAmp.cpp:366
bool iterate(vector< int > &index) const
Definition: EvtSpinAmp.cpp:399
void assign(const EvtComplex &val)
Definition: EvtSpinAmp.hh:78
friend std::ostream & operator<<(std::ostream &, const EvtSpinAmp &)
Definition: EvtSpinAmp.cpp:30
friend EvtSpinAmp operator/(const EvtSpinAmp &, const EvtComplex &)
Definition: EvtSpinAmp.cpp:62
friend EvtSpinAmp operator *(const EvtComplex &, const EvtSpinAmp &)
Definition: EvtSpinAmp.cpp:46
EvtSpinAmp operator+(const EvtSpinAmp &) const
Definition: EvtSpinAmp.cpp:285
EvtSpinAmp operator-(const EvtSpinAmp &) const
Definition: EvtSpinAmp.cpp:307
void intcont(size_t, size_t)
Definition: EvtSpinAmp.cpp:462
vector< EvtSpinType::spintype > _type
Definition: EvtSpinAmp.hh:105
vector< EvtComplex > _elem
Definition: EvtSpinAmp.hh:107
void addspin(int twospin)
Definition: EvtSpinAmp.hh:88