]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TEvtGen/EvtGen/EvtGenBase/EvtSpinAmp.hh
Fix for definitions for CINT
[u/mrichter/AliRoot.git] / TEvtGen / EvtGen / EvtGenBase / EvtSpinAmp.hh
1 #ifndef __EVTSPINAMP_HH__
2 #define __EVTSPINAMP_HH__
3
4 #include "EvtGenBase/EvtSpinType.hh"
5 #include "EvtGenBase/EvtComplex.hh"
6
7 #include <vector>
8 using std::vector;
9
10 #include <cstdarg>
11
12 class EvtSpinAmp;
13 EvtSpinAmp operator*( const EvtComplex&, const EvtSpinAmp& );
14 EvtSpinAmp operator*( const EvtSpinAmp&, const EvtComplex& );
15 EvtSpinAmp operator/( const EvtSpinAmp&, const EvtComplex& );
16
17 class EvtSpinAmp
18 {
19
20     friend EvtSpinAmp operator*( const EvtComplex&, const EvtSpinAmp& );
21     friend EvtSpinAmp operator*( const EvtSpinAmp&, const EvtComplex& );
22     friend EvtSpinAmp operator/( const EvtSpinAmp&, const EvtComplex& );
23     friend std::ostream& operator<< ( std::ostream&, const EvtSpinAmp& );
24     
25 public:
26
27     EvtSpinAmp( ) {};
28     EvtSpinAmp( const vector<EvtSpinType::spintype>& );
29     EvtSpinAmp( const vector<EvtSpinType::spintype>& , const EvtComplex& );
30     EvtSpinAmp( const vector<EvtSpinType::spintype>& , const vector<EvtComplex>& );
31     EvtSpinAmp( const EvtSpinAmp & );
32
33     ~EvtSpinAmp( ) {};
34     
35     // Input to the index functions are twice the magnetic quantum number
36     EvtComplex& operator()( const vector<int>& ); 
37     const EvtComplex& operator()( const vector<int>& ) const; 
38     EvtComplex& operator()( int, ... );
39     const EvtComplex& operator()( int, ... ) const;
40
41     EvtSpinAmp& operator=( const EvtSpinAmp& );
42
43     EvtSpinAmp operator+( const EvtSpinAmp& ) const;
44     EvtSpinAmp& operator+=( const EvtSpinAmp& );
45
46     EvtSpinAmp operator-( const EvtSpinAmp& ) const;
47     EvtSpinAmp& operator-=( const EvtSpinAmp& );
48
49     // Direct Product
50     EvtSpinAmp operator*( const EvtSpinAmp& ) const;
51     EvtSpinAmp& operator*=( const EvtSpinAmp& );
52     
53     EvtSpinAmp& operator*=( const EvtComplex& );
54     EvtSpinAmp& operator/=( const EvtComplex& );
55
56     // Contraction of amplitudes
57     void intcont( size_t, size_t );
58     void extcont( const EvtSpinAmp &, int, int );
59     
60     // assign this value to every member in the container
61     void assign( const EvtComplex & val ) { _elem.assign( _elem.size(), val ); }
62     
63     // get the order of the container
64     size_t rank( ) const { return _twospin.size(); }
65
66     // get the dimension vector of the container
67     const vector<unsigned int> & dims( ) const { return _twospin; } 
68     
69     // set the elements and the dimensions of the vector - useful for something
70     // things eventough it is usually not the cleanest solution
71     void addspin( int twospin ) { _twospin.push_back( twospin ); }
72     void setelem( const vector<EvtComplex> &elem ) { _elem = elem; }
73
74     bool iterate( vector<int>& index ) const;
75     vector<int> iterinit() const;
76
77     bool allowed( const vector<int>& index ) const;
78     bool iterateallowed( vector<int>& index) const;
79     vector<int> iterallowedinit() const;
80
81 private:
82
83     void checkindexargs( const vector<int>& index ) const;
84     void checktwospin( const vector<unsigned int>& twospin ) const;
85     int findtrueindex( const vector<int>& index ) const;
86     vector<unsigned int> calctwospin( const vector<EvtSpinType::spintype>& type ) const;
87
88     vector<EvtSpinType::spintype> _type;
89     vector<unsigned int> _twospin;
90     vector<EvtComplex> _elem;
91 };
92
93 #endif // __EVTSPINAMP__