LCOV - code coverage report
Current view: top level - TEvtGen/EvtGen/EvtGenBase - EvtOrthogVector.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 52 0.0 %
Date: 2016-06-14 17:26:59 Functions: 0 6 0.0 %

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

Generated by: LCOV version 1.11