MINT2
DalitzCoordinate.cpp
Go to the documentation of this file.
1 // author: Jonas Rademacker (Jonas.Rademacker@bristol.ac.uk)
2 // status: Mon 9 Feb 2009 19:17:58 GMT
4 #include <sstream>
5 
6 #include <algorithm>
7 
8 using namespace std;
9 
11  if(this->size() <=1) return true;
12  for(unsigned int i=1; i< this->size(); i++){
13  if( (*this)[i] != (*this)[i-1] + 1) return false;
14  }
15  return true;
16 }
17 
19  : MINT::PolymorphVector<int>(1)
20  , _mi(-9999)
21  , _ma(-9999)
22  , _val(-9999)
23 {
24  (*this)[0] = -9999;
25  makeName();
26 }
27 
29  : MINT::PolymorphVector<int>(2)
30  , _mi(-9999)
31  , _ma(-9999)
32  , _val(-9999)
33 {
34  (*this)[0] = i;
35  (*this)[1] = j;
36  sort(this->begin(), this->end());
37  makeName();
38 }
40  : MINT::PolymorphVector<int>(3)
41  , _mi(-9999)
42  , _ma(-9999)
43  , _val(-9999)
44 {
45  (*this)[0] = i;
46  (*this)[1] = j;
47  (*this)[2] = k;
48  sort(this->begin(), this->end());
49  makeName();
50 }
51 
53  : MINT::PolymorphVector<int>(other)
54  , _mi(-9999)
55  , _ma(-9999)
56  , _val(-9999)
57 {
58  sort(this->begin(), this->end());
59  makeName();
60 }
62  : MINT::PolymorphVector<int>( (MINT::PolymorphVector<int>) other)
63  , _mi(other._mi)
64  , _ma(other._ma)
65  , _val(other._val)
66  , _name(other._name)
67 {
68 }
69 
71 {
72  this->resize(other.size());
73  for(unsigned int i=0; i< other.size(); i++) (*this)[i] = other[i];
74  _mi = other._mi;
75  _ma = other._ma;
76  _val = other._val;
77  _name = other._name;
78  return *this;
79 }
80 
82  /*
83  cout << "DalitzCoordinate::mapMe of " << (*this)
84  << " called with\n " << perm << endl;
85  */
86  DalitzCoordinate mapped(*this);
87 
88  for(unsigned int i=0; i< this->size(); i++){
89  // cout << "mapping : " << (*this)[i] << endl;
90  mapped[i] = perm[ (*this)[i] ];
91  // cout << "mapped it to " << mapped[i] << endl;
92  }
93  sort(mapped.begin(), mapped.end());
94  return mapped;
95 }
96 
97 
98 std::vector<DalitzCoordinate> DalitzCoordinate::split(int n) const{
99 
100  bool dbThis=false;
101 
102  std::vector<DalitzCoordinate> cList;
103  cList.clear();
104 
105  double newWidth = (this->max() - this->min()) /((double) n);
106  if(dbThis){
107  cout << " DalitzCoordinate::split " << *this << endl;
108  cout << "\t Currently: mi = " << min()
109  << " ma = " << max() << "\n\t";
110  }
111  for(int l=0; l < n; l++){
112  DalitzCoordinate c(*this);
113  double mi = this->min() + l*newWidth;
114  double ma = this->min() + (l+1.0)*newWidth;
115  if(dbThis) cout << ", ( " << mi << ", " << ma << " )";
116  c.setMinMax(mi, ma);
117  cList.push_back(c);
118  }
119  if(dbThis) cout << endl;
120  return cList;
121 }
122 
123 
124 const std::string& DalitzCoordinate::name() const{
125  return _name;
126 }
127 
129  std::stringstream strm;
130  strm << "sij(";
131  for(unsigned int i=0; i < this->size(); i++){
132  if(i > 0) strm << ",";
133  strm << (*this)[i];
134  }
135  strm << ")";
136  std::string ing;
137  strm >> ing;
138  _name = ing;
139  return _name;
140 }
141 std::string DalitzCoordinate::nameFileSave() const{
142  std::stringstream strm;
143  strm << "s";
144  for(unsigned int i=0; i < this->size(); i++){
145  strm << (*this)[i];
146  }
147  std::string ing;
148  strm >> ing;
149  return ing;
150 }
151 
152 void DalitzCoordinate::print(std::ostream& os) const{
153  os << this->name();
154  os << ": val = " << this->val()
155  << ", mi = " << this->min()
156  << ", ma = " << this->max();
157  return;
158 }
160  if(this->size() != rhs.size()) return false;
161  for(unsigned int i=0; i< size(); i++){
162  if((*this)[i] != rhs[i]) return false;
163  }
164 
165  return true;
166 }
167 
169 
170  if(this->size() != rhs.size()) return false;
171  for(unsigned int i=0; i< size(); i++){
172  if((*this)[i] != rhs[i]) return false;
173  }
174  if(this->min() != rhs.min()) return false;
175  if(this->max() != rhs.max()) return false;
176  if(this->val() != rhs.val()) return false;
177 
178  return true;
179 }
180 
182  return ! ((*this) == rhs);
183 }
184 
185 // non-members:
186 std::ostream& operator<<(std::ostream& os, const DalitzCoordinate& c){
187  c.print(os);
188  return os;
189 }
190 //
double min() const
bool I_am_Consecutive() const
bool operator==(const DalitzCoordinate &rhs) const
std::vector< int >::iterator end()
void resize(unsigned int N)
double max() const
std::vector< DalitzCoordinate > split(int n) const
void print(std::ostream &os=std::cout) const
bool operator!=(const DalitzCoordinate &rhs) const
DalitzCoordinate mapMe(const Permutation &perm) const
std::vector< int >::iterator begin()
std::string & makeName()
unsigned int size() const
double val() const
bool sameIndices(const DalitzCoordinate &rhs) const
std::ostream & operator<<(std::ostream &os, const DalitzCoordinate &c)
DalitzCoordinate & operator=(const DalitzCoordinate &other)
void setMinMax(double min, double max)
const std::string & name() const
std::string nameFileSave() const