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.
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 
22 
23 #include "EvtGenBase/EvtPatches.hh"
24 
25 #include <ctype.h>
26 #include <fstream>
27 #include <iostream>
28 #include <stdlib.h>
29 #include <string.h>
30 using std::fstream;
31 
32 EvtOrthogVector::EvtOrthogVector( int n, std::vector<double>* vectors )
33 {
34  _dimen = n;
35  _holder.resize( n );
36 
37  std::vector<int> temp;
38 
39  int i;
40  for ( i = 0; i < n; i++ ) {
41  _orthogVector.push_back( 0. );
42  temp.push_back( i );
43  }
44 
45  findOrthog( _dimen, temp, vectors );
46 }
47 
48 void EvtOrthogVector::findOrthog( int dim, std::vector<int> invect,
49  std::vector<double>* vectors )
50 {
51  if ( dim == 2 ) {
52  _holder[0] = invect[0];
53  _holder[1] = invect[1];
54  int sign = findEvenOddSwaps();
55  {
56  double addition = 1;
57  int i;
58  for ( i = 1; i < _dimen; i++ ) {
59  addition *= vectors[i - 1][_holder[i]];
60  }
61  addition *= sign;
62  _orthogVector[_holder[0]] += addition;
63  }
64 
65  _holder[0] = invect[1];
66  _holder[1] = invect[0];
67 
68  {
69  double addition = 1;
70  int i;
71  for ( i = 1; i < _dimen; i++ ) {
72  addition *= vectors[i - 1][_holder[i]];
73  }
74  addition *= sign;
75  _orthogVector[_holder[0]] -= addition;
76  }
77 
78  return;
79  } else {
80  std::vector<int> temp( ( 2 * dim ) );
81 
82  int i;
83  for ( i = 0; i < dim; i++ )
84  temp[i] = invect[i];
85  for ( i = 0; i < dim; i++ )
86  temp[i + dim] = invect[i];
87 
88  for ( i = 0; i < dim; i++ ) {
89  _holder[dim - 1] = temp[dim - 1 + i];
90  std::vector<int> tempDim( ( dim - 1 ) );
91 
92  int j;
93  for ( j = 0; j < ( dim - 1 ); j++ )
94  tempDim[j] = temp[j + i];
95  findOrthog( dim - 1, tempDim, vectors );
96  }
97  }
98 
99  return;
100 }
101 
103 {
104  std::vector<int> temp( _dimen );
105 
106  int i, j, nSwap;
107  for ( i = 0; i < _dimen; i++ )
108  temp[i] = _holder[i];
109 
110  nSwap = 0;
111  for ( i = 0; i < ( _dimen - 1 ); i++ ) {
112  for ( j = i + 1; j < _dimen; j++ ) {
113  if ( temp[i] > temp[j] ) {
114  int duh = temp[j];
115  temp[j] = temp[i];
116  temp[i] = duh;
117  nSwap += 1;
118  }
119  }
120  }
121  nSwap -= ( nSwap / 2 ) * 2;
122 
123  if ( nSwap )
124  return -1;
125 
126  return 1;
127 }
std::vector< int > _holder
void findOrthog(int dim, std::vector< int > invect, std::vector< double > *vectors)
std::vector< double > _orthogVector
EvtOrthogVector(int n, std::vector< double > *vectors)