CGEM BOSS 6.6.5.h
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//------------------------------------------------------------------------
21
22#include <iostream>
23#include <fstream>
24#include <stdlib.h>
25#include <ctype.h>
26#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 _orthogVector.push_back(0.);
40 temp.push_back(i);
41 }
42
43 findOrthog(_dimen,temp, vectors);
44
45}
46
49
50void EvtOrthogVector::findOrthog(int dim, std::vector<int> invect,
51 std::vector<double> *vectors) {
52
53
54 if ( dim==2 ) {
55 _holder[0]=invect[0];
56 _holder[1]=invect[1];
57 int sign=findEvenOddSwaps();
58 {
59 double addition=1;
60 int i;
61 for (i=1; i<_dimen; i++){
62 addition*=vectors[i-1][_holder[i]];
63 }
64 addition*=sign;
65 _orthogVector[_holder[0]]+=addition;
66 }
67
68 _holder[0]=invect[1];
69 _holder[1]=invect[0];
70
71 {
72 double addition=1;
73 int i;
74 for (i=1; i<_dimen; i++){
75 addition*=vectors[i-1][_holder[i]];
76 }
77 addition*=sign;
78 _orthogVector[_holder[0]]-=addition;
79 }
80
81 return;
82 }
83 else{
84 std::vector<int> temp((2*dim));
85
86 int i;
87 for (i=0; i<dim; i++) temp[i]=invect[i];
88 for (i=0; i<dim; i++) temp[i+dim]=invect[i];
89
90 for (i=0; i<dim; i++) {
91 _holder[dim-1]=temp[dim-1+i];
92 std::vector<int> tempDim((dim-1));
93
94 int j;
95 for (j=0; j<(dim-1); j++) tempDim[j]=temp[j+i];
96 findOrthog(dim-1, tempDim, vectors);
97 }
98 }
99
100 return;
101}
102
103int EvtOrthogVector::findEvenOddSwaps() {
104
105 std::vector<int> temp(_dimen);
106
107 int i,j,nSwap;
108 for (i=0; i<_dimen; i++) 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
114 if ( temp[i]>temp[j] ) {
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
128}
const Int_t n
EvtOrthogVector(int n, std::vector< double > *vectors)