MINT2
AssociatingDecayTree.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:02 GMT
4 #include "Mint/IDalitzEvent.h"
5 
6 #include <algorithm>
7 
8 using namespace std;
9 using namespace MINT;
10 
12  return associate(evt.eventPattern());
13 }
15  bool success=true;
16  success &= associateFinalStates(pat);
17  if(! success) return false;
18  success &= associateResonances();
19  _prevPattern=pat;
20  return success;
21 }
22 
24  return associateFinalStates(evt.eventPattern());
25 }
27  bool dbThis=false;
28  if(dbThis) cout << "associateFinalStates was called " << endl;
29  if(pat.empty())return false;
30  vector<int> fs_pat= pat.finalStates();
31 
32  if(dbThis) cout << "got pattern of size " << pat.size() << endl;
33  if(fs_pat.empty()) return false;
34  if(dbThis) cout << "pattern not empty" << endl;
35  std::vector<AssociatedDecayTreeItem*> sorted
36  = _theDecay.finalStateInThisOrder(fs_pat);
37  if(dbThis) cout << "sorted" << endl;
38  if(sorted.size() != fs_pat.size()){
39  cout << "Sizes: " << sorted.size() << " " << fs_pat.size() << endl;
40 
41  std::cout << "ERROR in AssociatingDecayTree::associate!"
42  << " fs_pattern : ";
43  for(unsigned int i=0; i<fs_pat.size(); i++){
44  std::cout << "(" << i << ") " << fs_pat[i] << ", ";
45  }
46  std::cout << std::endl;
47 
48  for(unsigned int i=0; i<sorted.size(); i++){
49  std::cout << "(" << i << ") " << *(sorted[i]) << ", ";
50  }
51  std::cout << std::endl;
52  // std::cout << "\n does not match decay:\n" << _theDecay << std::endl;
53  return false;
54  }
55  // cout << "now putting it all in" << endl;
56  for(unsigned int i=0; i<sorted.size(); i++){
57  sorted[i]->_asi.clear();
58  sorted[i]->_asi.push_back(i+1);
59  }
60  if(dbThis){
61  std::cout << "the new sorted thing" << std::endl;
62  for(unsigned int i=0; i<sorted.size(); i++){
63  std::cout << "(" << i << ") " << *(sorted[i]) << ", ";
64  }
65  }
66 
67  // cout << "associateFinalStates returning true" << endl;
68  return true;
69 }
70 
72  return ! (addAssociations(&_theDecay).empty());
73 }
75  return addAssociations(ctree.get());
76 }
77 
79  if(tree->isFinalState()){
80  return tree->getVal()._asi;
81  }
82  std::vector<int> allAsis;
83 
84  for(int i=0; i< tree->nDgtr(); i++){
85  std::vector<int> thisAsi = addAssociations(tree->getDgtrTreePtr(i));
86  for(unsigned int j=0; j<thisAsi.size(); j++){ allAsis.push_back(thisAsi[j]);}
87  }
88  stable_sort(allAsis.begin(), allAsis.end());
89  tree->getVal()._asi=allAsis;
90  return allAsis;
91 }
92 
93 
94 
96  return patternHasChanged(evt.eventPattern());
97 }
99  bool dbThis=false ;
100  if(pat.empty()) return false;
101  if(_prevPattern.size() != pat.size()){
102  if(dbThis){
103  std::cout << "prev pattern size != new pattern size: "
104  << _prevPattern.size() << " != " << pat.size() << endl;
105  std::cout << " returning pattern has changed = true " << std::endl;
106  }
107  return true;
108  }
109  // only compare final state:
110  // (this means for D or Dbar to same final state will be treated
111  // as having the same pattern).
112  for(unsigned int i=1; i< _prevPattern.size(); i++){
113  if (_prevPattern[i] != pat[i]){
114  if(dbThis)
115  std::cout << " returning pattern has changed = true " << std::endl;
116  return true;
117  }
118  }
119  return false;
120 }
121 
123  if(patternHasChanged(evt)) associate(evt);
124  return getTreePtr(evt.eventPattern());
125 }
127  if(patternHasChanged(pat)) associate(pat);
128  return & _theDecay;
129 }
130 
132  if(patternHasChanged(evt)) associate(evt);
133  return getTree(evt.eventPattern());
134 }
136  if(patternHasChanged(pat)) associate(pat);
137  return _theDecay;
138 }
139 
141  return _theTreesPattern;
142 }
143 
144 //
145 
const AssociatedDecayTree * getTreePtr(const DalitzEventPattern &pat) const
std::vector< int > finalStates() const
const DalitzEventPattern & getTreePattern() const
const ValueType & getVal() const
Definition: DDTree.h:102
bool isFinalState() const
Definition: DDTree.h:93
MINT::const_counted_ptr< DDTree< ValueType > > getDgtrTreePtr(int i) const
Definition: DDTree.h:114
bool patternHasChanged(const DalitzEventPattern &pat) const
const AssociatedDecayTree & getTree(const DalitzEventPattern &pat) const
virtual const DalitzEventPattern & eventPattern() const =0
unsigned int size() const
bool associate(const DalitzEventPattern &pat) const
std::vector< int > addAssociations(MINT::counted_ptr< AssociatedDecayTree > ctree) const
int nDgtr() const
Definition: DDTree.h:96
bool associateFinalStates(const DalitzEventPattern &pat) const
X * get() const
Definition: counted_ptr.h:123