MINT2
AmpInitialiser.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
3 
4 #include <iostream>
5 #include <algorithm>
6 #include "Mint/AmpInitialiser.h"
8 #include "Mint/Utils.h"
10 
11 using namespace std;
12 using namespace MINT;
13 
15  : _SPD('?')
16  , _valid(false)
17  , _lopt("")
18  , _numOpts()
19  , _autoSwap(true)
20  , _index(-1)
21 {}
22 AmpInitialiser::AmpInitialiser(const std::string& StandardisedDecayTreeName
23  , const std::string& lopt_in
24  , const std::string& namePrefix
25  , const std::string& lineshapePrefix
26  , const std::vector<double>& numOpts_in
27  , bool autoSwap_in
28  , int index_in
29  )
30  : _valid(false)
31  , _prefix(namePrefix)
32  , _lsPrefix(lineshapePrefix)
33  , _lopt(lopt_in)
34  , _numOpts(numOpts_in)
35  , _autoSwap(autoSwap_in)
36  , _index(index_in)
37 {
38  setSPD('?');
40  if(! ndl){
41  cout << "ERROR in constructor of AmpInitialiser from string: "
42  << StandardisedDecayTreeName << endl;
43  cout << "Can't find NamedDecayTreeList!" << endl;
44  }else{
45  bool success=false;
46  (*this) = ndl->find(StandardisedDecayTreeName, success);
47  if(! success){
48  cout << "ERROR in constructor of AmpInitialiser from string: "
49  << StandardisedDecayTreeName << endl;
50  cout << "Can't find this decay in List" << endl;
51  }
52  }
53 }
55  , char SPD_in
56  , const std::string& lopt_in
57  , const std::string& namePrefix
58  , const std::string& lineshapePrefix
59  , const std::vector<double>& numOpts_in
60  , bool autoSwap_in
61  , int index_in
62  )
63  : _prefix(namePrefix)
64  , _lsPrefix(lineshapePrefix)
65  , _lopt(lopt_in)
66  , _numOpts(numOpts_in)
67  , _autoSwap(autoSwap_in)
68  , _index(index_in)
69 {
70  setTree(dt_in);
71  setSPD(SPD_in);
72 }
74  , const std::string& lopt_in
75  , const std::string& namePrefix
76  , const std::string& lineshapePrefix
77  , const std::vector<double>& numOpts_in
78  , bool autoSwap_in
79  , int index_in
80  )
81  : _prefix(namePrefix)
82  , _lsPrefix(lineshapePrefix)
83  , _lopt(lopt_in)
84  , _numOpts(numOpts_in)
85  , _autoSwap(autoSwap_in)
86  , _index(index_in)
87 {
88  setTree(dt_in);
89  setSPD('?');
90 }
91 
92 AmpInitialiser::AmpInitialiser(const AmpInitialiser& other, const std::string& addedPrefix, const std::string& addedLineshapePrefix)
93  : _SPD(other._SPD)
94  , _valid(other._valid)
95  , _prefix(addedPrefix + other._prefix)
96  , _lsPrefix(addedLineshapePrefix + other._lsPrefix)
97  , _lopt(other._lopt)
98  , _numOpts(other._numOpts)
99  , _autoSwap(other._autoSwap)
100  , _index(other._index)
101 {
102  setTree(other._dt);
103 }
105  setTree(rhs._dt);
106  _SPD = rhs._SPD;
107  _valid = rhs._valid;
108  _prefix = rhs._prefix;
109  _lsPrefix = rhs._lsPrefix;
110  _lopt = rhs._lopt;
111  _numOpts = rhs._numOpts;
112  _autoSwap = rhs._autoSwap;
113  _index = rhs._index;
114  return *this;
115 }
116 
118  return _dt;
119 }
120 
122  std::vector<const DecayTreeItem*> fs = tree().finalState();
123 
124  std::vector<int> fs_int;
125  fs_int.push_back(tree().getVal().pdg()); // mum;
126  for(unsigned int i=0; i< fs.size(); i++){
127  fs_int.push_back(fs[i]->pdg());
128  }
129  return DalitzEventPattern(fs_int);
130 }
131 
133  _dt = dt_in;
134  standardSort(_dt);
135  // sorting makes the name derived
136  // from tree unique.
137  _valid=true;
138 }
139 char AmpInitialiser::SPD() const{
140  return _SPD;
141 }
142 void AmpInitialiser::setSPD(char SPD_in){
143  _SPD = SPD_in;
144 }
145 
146 const std::string& AmpInitialiser::lopt() const{
147  return _lopt;
148 }
149 void AmpInitialiser::setLopt(const std::string& lopt_in){
150  _lopt = lopt_in;
151 }
152 void AmpInitialiser::addLopt(const std::string& lopt_in){
153  if(! A_is_in_B(lopt_in, _lopt)){
154  _lopt += lopt_in;
155  }
156 }
157 
158 void AmpInitialiser::setNumOpts(const std::vector<double>& numOpts_in){
159  _numOpts = numOpts_in;
160 }
161 
163  _numOpts.push_back(n1);
164 }
165 void AmpInitialiser::setNumOpts(double n1, double n2){
166  _numOpts.push_back(n1); _numOpts.push_back(n2);
167 }
168 
169 void AmpInitialiser::setNumOpts(double n1, double n2, double n3){
170  _numOpts.push_back(n1); _numOpts.push_back(n2); _numOpts.push_back(n3);
171 }
172 
173 
174 const std::vector<double>& AmpInitialiser::numOpts() const{
175  return _numOpts;
176 }
177 
179  return _autoSwap;
180 }
181 bool AmpInitialiser::setAutoSwap(bool autoSwap_in) {
182  return _autoSwap=autoSwap_in;
183 }
184 
186  return _index;
187 }
188 
189 void AmpInitialiser::setIndex(int index_in){
190  _index = index_in;
191 }
192 
193 std::string AmpInitialiser::indexString()const{
194  if(index() < 0){
195  return "";
196  }else{
197  return "_" + anythingToString(index());
198  }
199 }
200 
201 const std::string& AmpInitialiser::prefix() const{
202  return _prefix;
203 }
204 void AmpInitialiser::addPrefix(const std::string& namePrefix){
205  _prefix = namePrefix + _prefix;
206 }
207 
208 const std::string& AmpInitialiser::lsPrefix() const{
209  return _lsPrefix;
210 }
211 void AmpInitialiser::addLsPrefix(const std::string& lineshapePrefix){
212  _lsPrefix = lineshapePrefix + _lsPrefix;
213 }
214 
215 std::string AmpInitialiser::uniqueName() const{
216  if(_valid){
217  std::string s = prefix() + _lopt + _dt.oneLiner() + indexString();
218  // if(_SPD != '?') s = s + "_" + _SPD;
219  return s;
220  }else{
221  return "Tree not set - so no name";
222  }
223 }
224 std::string AmpInitialiser::name() const{
225  return uniqueName();
226 }
227 
const AmpInitialiser & find(const std::string &name, bool &successFlag) const
const std::string & lopt() const
void setIndex(int index)
std::string uniqueName() const
const DecayTree & tree() const
static const double s
std::string name() const
std::string _lsPrefix
bool standardSort(DecayTree &A)
bool A_is_in_B(const std::string &a, const std::string &b)
Definition: Utils.cpp:34
std::string indexString() const
int index() const
void setSPD(char SPD_in)
char SPD() const
static NamedDecayTreeList * getMe(const std::string &printopt="printNever")
void setTree(const DecayTree &dt_in)
const std::string & lsPrefix() const
std::string _lopt
bool setAutoSwap(bool autoSwap_in=true)
void setLopt(const std::string &lopt_in)
std::string anythingToString(const T &anything)
Definition: Utils.h:62
const std::string & prefix() const
std::vector< const ValueType * > finalState() const
Definition: DDTree.h:293
void oneLiner(std::stringstream &seam, int generation=0) const
Definition: DDTree.h:375
std::string _prefix
const std::vector< double > & numOpts() const
AmpInitialiser & operator=(const AmpInitialiser &rhs)
bool autoSwap() const
void addLopt(const std::string &lopt_in)
DalitzEventPattern getEventPattern() const
void addPrefix(const std::string &namePrefix)
void addLsPrefix(const std::string &linshapePrefix)
void setNumOpts(const std::vector< double > &numOpts_in=std::vector< double >())
std::vector< double > _numOpts