EvtGen
2.2.0
Monte Carlo generator of particle decays, in particular the weak decays of heavy flavour particles such as B mesons.
Toggle main menu visibility
Loading...
Searching...
No Matches
src
EvtGenBase
EvtOrthogVector.cpp
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
#include "
EvtGenBase/EvtOrthogVector.hh
"
22
23
#include <ctype.h>
24
#include <fstream>
25
#include <iostream>
26
#include <stdlib.h>
27
#include <string.h>
28
using
std::fstream;
29
30
EvtOrthogVector::EvtOrthogVector
(
int
n, std::vector<double>* vectors )
31
{
32
m_dimen
= n;
33
m_holder
.resize( n );
34
35
std::vector<int> temp;
36
37
int
i;
38
for
( i = 0; i < n; i++ ) {
39
m_orthogVector
.push_back( 0. );
40
temp.push_back( i );
41
}
42
43
findOrthog
(
m_dimen
, temp, vectors );
44
}
45
46
void
EvtOrthogVector::findOrthog
(
int
dim, std::vector<int> invect,
47
std::vector<double>* vectors )
48
{
49
if
( dim == 2 ) {
50
m_holder
[0] = invect[0];
51
m_holder
[1] = invect[1];
52
int
sign =
findEvenOddSwaps
();
53
{
54
double
addition = 1;
55
int
i;
56
for
( i = 1; i <
m_dimen
; i++ ) {
57
addition *= vectors[i - 1][
m_holder
[i]];
58
}
59
addition *= sign;
60
m_orthogVector
[
m_holder
[0]] += addition;
61
}
62
63
m_holder
[0] = invect[1];
64
m_holder
[1] = invect[0];
65
66
{
67
double
addition = 1;
68
int
i;
69
for
( i = 1; i <
m_dimen
; i++ ) {
70
addition *= vectors[i - 1][
m_holder
[i]];
71
}
72
addition *= sign;
73
m_orthogVector
[
m_holder
[0]] -= addition;
74
}
75
76
return
;
77
}
else
{
78
std::vector<int> temp( ( 2 * dim ) );
79
80
int
i;
81
for
( i = 0; i < dim; i++ )
82
temp[i] = invect[i];
83
for
( i = 0; i < dim; i++ )
84
temp[i + dim] = invect[i];
85
86
for
( i = 0; i < dim; i++ ) {
87
m_holder
[dim - 1] = temp[dim - 1 + i];
88
std::vector<int> tempDim( ( dim - 1 ) );
89
90
int
j;
91
for
( j = 0; j < ( dim - 1 ); j++ )
92
tempDim[j] = temp[j + i];
93
findOrthog
( dim - 1, tempDim, vectors );
94
}
95
}
96
97
return
;
98
}
99
100
int
EvtOrthogVector::findEvenOddSwaps
()
101
{
102
std::vector<int> temp(
m_dimen
);
103
104
int
i, j, nSwap;
105
for
( i = 0; i <
m_dimen
; i++ )
106
temp[i] =
m_holder
[i];
107
108
nSwap = 0;
109
for
( i = 0; i < (
m_dimen
- 1 ); i++ ) {
110
for
( j = i + 1; j <
m_dimen
; j++ ) {
111
if
( temp[i] > temp[j] ) {
112
int
duh = temp[j];
113
temp[j] = temp[i];
114
temp[i] = duh;
115
nSwap += 1;
116
}
117
}
118
}
119
nSwap -= ( nSwap / 2 ) * 2;
120
121
if
( nSwap )
122
return
-1;
123
124
return
1;
125
}
EvtOrthogVector.hh
EvtOrthogVector::m_orthogVector
std::vector< double > m_orthogVector
Definition
EvtOrthogVector.hh:38
EvtOrthogVector::m_holder
std::vector< int > m_holder
Definition
EvtOrthogVector.hh:34
EvtOrthogVector::EvtOrthogVector
EvtOrthogVector(int n, std::vector< double > *vectors)
Definition
EvtOrthogVector.cpp:30
EvtOrthogVector::findEvenOddSwaps
int findEvenOddSwaps()
Definition
EvtOrthogVector.cpp:100
EvtOrthogVector::findOrthog
void findOrthog(int dim, std::vector< int > invect, std::vector< double > *vectors)
Definition
EvtOrthogVector.cpp:46
EvtOrthogVector::m_dimen
int m_dimen
Definition
EvtOrthogVector.hh:33
Generated by
1.17.0