MINT2
Permutator.cpp
Go to the documentation of this file.
1 // author: Jonas Rademacker (Jonas.Rademacker@bristol.ac.uk)
2 // status: Mon 9 Feb 2009 19:18:13 GMT
3 #include "Mint/Permutator.h"
4 
5 #include <algorithm>
6 
7 using namespace std;
8 
10  : MINT::PolymorphVector<Permutation>()
11  , _pat(){
12  Permutation p(1);
13  this->push_back(p);
14 }
15 
17  : MINT::PolymorphVector<Permutation>()
18  , _pat(pat)
19 {
21 }
22 
24  _pat = pat;
25  this->clear();
27 }
28 
30 
31  this->clear();
32  Permutation p(_pat.size());
33  p.makeUnity();
34  this->push_back(p);
35 
36  for(unsigned int i=0; i < _pat.size()-1; i++){
37  for(unsigned int j=i+1; j < _pat.size(); j++){
38  if(_pat[i] == _pat[j]){
39  unsigned int n = this->size();
40  for(unsigned int k = 0; k < n; k++){
41  Permutation ptemp( (*this)[k] );
42  ptemp.swap(i,j);
43  this->push_back(ptemp);
44  }
45  }
46  }
47  }
48 
49  sort(this->begin(), this->end());
50 
51  std::vector<Permutation>::iterator
52  lastUnique = unique(this->begin(), this->end());
53 
54  this->erase(lastUnique, this->end());
55 
56  return this->size();
57 }
58 
59 void Permutator::print(std::ostream& os) const{
60  for(unsigned int i=0; i< this->size(); i++){
61  os << " " << i << ")\n" << (*this)[i] << endl;
62  }
63 }
64 
65 ostream& operator<<(ostream& os, const Permutator& p){
66  p.print(os);
67  return os;
68 }
69 
70 //
DalitzEventPattern _pat
Definition: Permutator.h:14
void setPattern(const DalitzEventPattern &pat)
Definition: Permutator.cpp:23
int findAllPermutations()
Definition: Permutator.cpp:29
std::vector< Permutation >::iterator end()
void push_back(const Permutation &c)
void swap(int x1, int x2, int sgn=1)
Definition: Permutation.cpp:54
void makeUnity()
Definition: Permutation.cpp:42
void erase(typename std::vector< Permutation >::iterator pos)
std::vector< Permutation >::iterator begin()
unsigned int size() const
ostream & operator<<(ostream &os, const Permutator &p)
Definition: Permutator.cpp:65
void print(std::ostream &os=std::cout) const
Definition: Permutator.cpp:59