BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
EvtOrthogVector.cc
Go to the documentation of this file.
1//--------------------------------------------------------------------------
2//
3// Environment:
4// This software is part of the EvtGen package developed jointly
5// for the BaBar and CLEO collaborations. If you use all or part
6// of it, please give an appropriate acknowledgement.
7//
8// Copyright Information: See EvtGen/COPYRIGHT
9// Copyright (C) 2000 Caltech, LLNL
10//
11// Module: EvtGen/EvtOrthogVector.hh
12//
13// Description:
14//
15// Modification history:
16//
17// Lange August 11, 2000 Created
18//
19//------------------------------------------------------------------------
20#include "EvtPatches.hh"
21
22#include "EvtOrthogVector.hh"
23#include <ctype.h>
24#include <fstream>
25#include <iostream>
26#include <stdlib.h>
27#include <string.h>
28using std::fstream;
29
30EvtOrthogVector::EvtOrthogVector( int n, std::vector<double>* vectors ) {
31
32 _dimen = n;
33 _holder.resize( n );
34
35 std::vector<int> temp;
36
37 int i;
38 for ( i = 0; i < n; i++ )
39 {
40 _orthogVector.push_back( 0. );
41 temp.push_back( i );
42 }
43
44 findOrthog( _dimen, temp, vectors );
45}
46
48
49void EvtOrthogVector::findOrthog( int dim, std::vector<int> invect,
50 std::vector<double>* vectors ) {
51
52 if ( dim == 2 )
53 {
54 _holder[0] = invect[0];
55 _holder[1] = invect[1];
56 int sign = findEvenOddSwaps();
57 {
58 double addition = 1;
59 int i;
60 for ( i = 1; i < _dimen; i++ ) { addition *= vectors[i - 1][_holder[i]]; }
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++ ) { addition *= vectors[i - 1][_holder[i]]; }
72 addition *= sign;
73 _orthogVector[_holder[0]] -= addition;
74 }
75
76 return;
77 }
78 else
79 {
80 std::vector<int> temp( ( 2 * dim ) );
81
82 int i;
83 for ( i = 0; i < dim; i++ ) temp[i] = invect[i];
84 for ( i = 0; i < dim; i++ ) temp[i + dim] = invect[i];
85
86 for ( i = 0; i < dim; i++ )
87 {
88 _holder[dim - 1] = temp[dim - 1 + i];
89 std::vector<int> tempDim( ( dim - 1 ) );
90
91 int j;
92 for ( j = 0; j < ( dim - 1 ); j++ ) tempDim[j] = temp[j + i];
93 findOrthog( dim - 1, tempDim, vectors );
94 }
95 }
96
97 return;
98}
99
100int EvtOrthogVector::findEvenOddSwaps() {
101
102 std::vector<int> temp( _dimen );
103
104 int i, j, nSwap;
105 for ( i = 0; i < _dimen; i++ ) temp[i] = _holder[i];
106
107 nSwap = 0;
108 for ( i = 0; i < ( _dimen - 1 ); i++ )
109 {
110 for ( j = i + 1; j < _dimen; j++ )
111 {
112
113 if ( temp[i] > temp[j] )
114 {
115 int duh = temp[j];
116 temp[j] = temp[i];
117 temp[i] = duh;
118 nSwap += 1;
119 }
120 }
121 }
122 nSwap -= ( nSwap / 2 ) * 2;
123
124 if ( nSwap ) return -1;
125
126 return 1;
127}
const Int_t n
EvtOrthogVector(int n, std::vector< double > *vectors)