]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TEvtGen/EvtGenBase/EvtAmpIndex.cxx
Compilation of TEvtGen
[u/mrichter/AliRoot.git] / TEvtGen / EvtGenBase / EvtAmpIndex.cxx
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) 2002      Caltech
10 //
11 // Module: EvtAmp.cc
12 //
13 // Description: Class to manipulate the amplitudes in the decays.
14 //
15 // Modification history:
16 //
17 //    RYD     Nov 22, 2002         Module created
18 //
19 //------------------------------------------------------------------------
20 // 
21 #include "EvtGenBase/EvtPatches.hh"
22 #include "EvtGenBase/EvtAmpIndex.hh"
23 #include <vector>
24 using std::vector;
25
26
27 EvtAmpIndex::EvtAmpIndex(std::vector<int> ind):
28   _ind(ind),
29   _size(ind.size()),
30   _state(ind.size()),
31   _nstate(ind.size())
32 {
33   int i;
34   
35   for(i=0;i<_size;i++) {
36     _state[i]=0;
37     if (i==0){
38       _nstate[i]=1;
39     }
40     else{
41       _nstate[i]=_nstate[i-1]*_ind[i];
42     }
43   }
44 }
45
46
47 void EvtAmpIndex::reset(){
48   int i;
49   for(i=0;i<_size;i++) {
50     _state[i]=0;
51   }
52 }
53
54 bool EvtAmpIndex::next(){
55   int i;
56   for(i=0;i<_size;i++) {
57     _state[i]++;
58     if (_state[i]<_ind[i]){
59       return true;
60     }
61     else{
62       _state[i]=0;
63     }
64   }
65   return false;
66 }
67
68 int EvtAmpIndex::index(){
69
70   int i;
71   int ind=0;
72
73   for(i=0;i<_size;i++) {
74     ind+=_state[i]*_nstate[i];
75   }
76
77   return ind;
78
79 }
80
81
82
83
84
85
86
87
88
89
90