MINT2
DalitzEventPattern.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:00 GMT
4 #include "Mint/DecayTree.h"
5 #include "Mint/counted_ptr.h"
6 
7 #include "Mint/AmpInitialiser.h"
8 
9 #include <algorithm>
10 
12 
13 using namespace std;
14 using namespace MINT;
15 
16 DalitzEventPattern::DalitzEventPattern(int pdg_ids[], int arrayDimension)
17  : PolymorphVector<DecayTreeItem>(arrayDimension)
18 {
19  for(int i=0; i<arrayDimension; i++){
20  DecayTreeItem dti(pdg_ids[i]);
21  (*this)[i]=dti;
22  }
23 }
24 
25 DalitzEventPattern::DalitzEventPattern(const std::vector<int>& pdg_ids)
26  : PolymorphVector<DecayTreeItem>(pdg_ids.size())
27 {
28  for(unsigned int i=0; i<pdg_ids.size(); i++){
29  DecayTreeItem dti(pdg_ids[i]);
30  (*this)[i]=dti;
31  }
32 }
33 
34 DalitzEventPattern::DalitzEventPattern(const vector<DecayTreeItem>& other)
35  : PolymorphVector<DecayTreeItem>(other.size())
36 {
37  for(unsigned int i=0; i < this->size(); i++){
38  (*this)[i] = other[i];
39  }
40 }
41 
44 {}
47 {}
48 
49 
52 {
53  (*this)[0] = DecayTreeItem(mum);
54  (*this)[1] = DecayTreeItem(d1);
55  (*this)[2] = DecayTreeItem(d2);
56 }
57 
58 DalitzEventPattern::DalitzEventPattern(int mum, int d1, int d2, int d3)
60 {
61  (*this)[0] = DecayTreeItem(mum);
62  (*this)[1] = DecayTreeItem(d1);
63  (*this)[2] = DecayTreeItem(d2);
64  (*this)[3] = DecayTreeItem(d3);
65 }
66 
67 DalitzEventPattern::DalitzEventPattern(int mum,int d1,int d2,int d3,int d4)
69 {
70  (*this)[0] = DecayTreeItem(mum);
71  (*this)[1] = DecayTreeItem(d1);
72  (*this)[2] = DecayTreeItem(d2);
73  (*this)[3] = DecayTreeItem(d3);
74  (*this)[4] = DecayTreeItem(d4);
75 }
76 
77 
79  bool dbThis=false;
81  fsTree_pointers( dt_in.finalStatePtr() );
82 
83  std::vector<int> finalState( fsTree_pointers->size() );
84 
85  for(unsigned int i=0; i< fsTree_pointers->size(); i++){
86  finalState[i] = (*fsTree_pointers)[i]->pdg();
87  }
88  sort(finalState.begin(), finalState.end());
89 
90  this->resize(finalState.size() + 1);
91  (*this)[0] = dt_in.getVal();
92  for(unsigned int i=0; i< finalState.size(); i++){ // offspring
93  (*this)[i+1] = finalState[i];
94  }
95 
96  if(dbThis){
97  cout << "made this pattern: " << *this
98  << "out of this tree " << dt_in << endl;
99  }
100 }
101 
102 
104  DalitzEventPattern pat(*this);
105  for(unsigned int i=0; i < pat.size(); i++) pat[i].antiThis();
106  return pat;
107 }
108 
110  if(size() != other.size()) return false;
111  for(unsigned int i=0; i<size(); i++){
112  if((*this)[i] != other[i]) return false;
113  }
114  return true;
115 }
116 
118  if(equal(other)) return false;
119  if(size() < other.size()) return true;
120  if(size() > other.size()) return false;
121  for(unsigned int i=0; i<size(); i++){
122  if((*this)[i] < other[i]) return true;
123  if((*this)[i] > other[i]) return false;
124  }
125  return false;
126 }
128  return equal(rhs);
129 }
131  return ! ((*this) == rhs);
132 }
133 
135  return lt(rhs);
136 }
138  return (*this < rhs || *this == rhs);
139 }
141  return ! ((*this) < rhs);
142 }
144  return ! ((*this) <= rhs);
145 }
146 
147 void DalitzEventPattern::print(std::ostream& os)const{
148  os << "(";
149  for(unsigned int i=0; i< this->size(); i++){
150  os << (*this)[i];
151  if(i + 1< this->size()) os << ", ";
152  }
153  os << ")";
154 }
155 
156 std::vector<int> DalitzEventPattern::finalStates() const{
157  std::vector<int> fs;
158  for(unsigned int i=1; i<this->size(); i++){
159  fs.push_back((*this)[i]);
160  }
161  return fs;
162 }
163 
165  if(this->empty()) return false;
166 
167  if(tree.getVal().pdg() != (*this)[0]) return false; // check mother
168 
169  return compatibleWithFinalState(tree); // check daughters
170 }
171 
172 bool DalitzEventPattern::compatibleWithFinalState(const AmpInitialiser& ampInitContainsTree)const{
173  return compatibleWithFinalState(ampInitContainsTree.tree());
174 }
175 
176 
178  if(this->empty()) return false;
179 
180  std::vector<const DecayTreeItem*> fsTree_pointers = tree.finalState();
181 
182  std::vector<int> fsTree;
183  for(unsigned int i=0; i< fsTree_pointers.size(); i++){
184  fsTree.push_back(fsTree_pointers[i]->pdg());
185  }
186 
187  return compatibleWithFinalState(fsTree);
188 }
189 
191  pat) const{
192  if(this->empty()) return false;
193  std::vector<int> otherFs = pat.finalStates();
194  return compatibleWithFinalState(otherFs);
195 }
196 
197 bool DalitzEventPattern::compatibleWithFinalState(const std::vector<int>&
198  otherFs_in) const{
199 
200  std::vector<int> fs = finalStates(); // my own;
201  if(otherFs_in.size() != fs.size()) return false;
202 
203  std::vector<int> otherFs(otherFs_in);
204  sort(fs.begin() , fs.end());
205  sort(otherFs.begin(), otherFs.end());
206 
207  for(unsigned int i=0; i<fs.size(); i++){
208  if(fs[i] != otherFs[i]) return false;
209  }
210 
211  return true;
212 
213 }
214 
216  return this->compatibleWithFinalState(this->makeCPConjugate());
217 }
218 
219 double DalitzEventPattern::sijMin(int i, int j) const{
220  std::vector<int> indices(2);
221  indices[0] = i; indices[1] = j;
222  return sijMin(indices);
223 }
224 double DalitzEventPattern::sijMax(int i, int j) const{
225  std::vector<int> indices(2);
226  indices[0] = i; indices[1] = j;
227  return sijMax(indices);
228 }
229 
230 double DalitzEventPattern::sijMin(int i, int j, int k) const{
231  std::vector<int> indices(3);
232  indices[0] = i; indices[1] = j; indices[2] = k;
233  return sijMin(indices);
234 }
235 
236 double DalitzEventPattern::sijMax(int i, int j, int k) const{
237  std::vector<int> indices(3);
238  indices[0] = i; indices[1] = j; indices[2]=k;
239  return sijMax(indices);
240 }
241 
243  double sum=0;
244  for(unsigned int i=0; i< indices.size(); i++){
245  if(indices[i] < 1 || indices[i] >= (int) this->size()){
246  // indices should be dgtr indices, i.e. from 1 to num-daughters.
247  return -9999.0;
248  }
249  sum += (*this)[indices[i]].mass();
250  }
251  return sum*sum;
252 }
253 
255  if(this->empty()) return -9999;
256 
257  double sum=(*this)[0].mass();
258  for(unsigned int i=1; i<this->size(); i++){
259  sum -= (*this)[i].mass();
260  }
261  // at this stage, sum = mother mass - (all daugher masses).
262 
263  for(unsigned int i=0; i< indices.size(); i++){
264  if(indices[i] < 1 || indices[i] >= (int) this->size()){
265  // indices should be dgtr indices, i.e. from 1 to num-daughters.
266  return -9999.0;
267  }
268  sum += (*this)[indices[i]].mass();
269  }
270 
271  // now sum = mother mass - (missing daughter masses)
272  return sum*sum;
273 }
274 
275 std::vector<int> DalitzEventPattern::getVectorOfInts() const{
276  std::vector<int> v(this->size());
277  for(unsigned int i=0; i<this->size(); i++){
278  v[i] = (int) (*this)[i];
279  }
280  return v;
281 }
282 
283 std::string DalitzEventPattern::name() const{
284  std::string s("");
285  if(this->size() < 1) return "";
286  s = (*this)[0].name() + "->";
287  for(unsigned int i=1; i < this->size(); i++){
288  s += (*this)[i].name();
289  }
290  return s;
291 }
292 
293 std::ostream& operator<<(std::ostream& os, const DalitzEventPattern& p){
294  p.print(os);
295  return os;
296 }
297 //
double sijMax(const MINT::PolymorphVector< int > &indices) const
bool lt(const DalitzEventPattern &other) const
bool compatibleWithFinalState(const AmpInitialiser &ampInitContainsTree) const
MINT::counted_ptr< std::vector< const ValueType * > > finalStatePtr() const
Definition: DDTree.h:304
std::string name() const
std::vector< int > finalStates() const
bool operator==(const DalitzEventPattern &rhs) const
const DecayTree & tree() const
bool compatibleWith(const DecayTree &tree) const
static const double s
bool operator<(const DalitzEventPattern &rhs) const
const ValueType & getVal() const
Definition: DDTree.h:102
bool operator>=(const DalitzEventPattern &rhs) const
bool operator<=(const DalitzEventPattern &rhs) const
std::vector< int > getVectorOfInts() const
double sijMin(const MINT::PolymorphVector< int > &indices) const
static const DalitzEventPattern NoPattern
std::ostream & operator<<(std::ostream &os, const DalitzEventPattern &p)
bool equal(const DalitzEventPattern &other) const
bool operator!=(const DalitzEventPattern &rhs) const
DalitzEventPattern makeCPConjugate() const
std::vector< const ValueType * > finalState() const
Definition: DDTree.h:293
int pdg() const
void print(std::ostream &os=std::cout) const
bool operator>(const DalitzEventPattern &rhs) const