ROOTPWA
TPWAAmp.cc
Go to the documentation of this file.
1 
2 //
3 // Copyright 2009 Sebastian Neubert
4 //
5 // This file is part of rootpwa
6 //
7 // rootpwa is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // rootpwa is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with rootpwa. If not, see <http://www.gnu.org/licenses/>.
19 //
21 
22 //-----------------------------------------------------------
23 // File and Version Information:
24 // $Id$
25 //
26 // Description:
27 // Implementation of class TPWAAmp
28 // see TPWAAmp.h for details
29 //
30 //
31 // Author List:
32 // Sebastian Neubert TUM (original author)
33 //
34 //
35 //-----------------------------------------------------------
36 
37 
38 // This Class' Header ------------------
39 #include "TPWAAmp.h"
40 
41 // C/C++ Headers ----------------------
42 #include<iostream>
43 #include<sstream>
44 
45 // Collaborating Class Headers --------
46 
47 
48 // Class Member definitions -----------
49 
50 
51 TPWAAmp::TPWAAmp(string name, int rank, double threshold,
52  unsigned int normindex,
53  unsigned int accindex)
54  : _name(name), _rank(rank), _threshold(threshold),
55  _integralindex(normindex), _acceptanceindex(accindex),
56  _constr(NULL)
57 {
58  // set reflectivity
59  // Relevant format of wave-names: IGJPCM\eps... \eps=reflectivity
60  if(name[6] == '-') _reflectivity= -1;
61  else if(name[6] == '+') _reflectivity= 1;
62  else {
63  std::cout<<"Wrong wavename format. "
64  <<"Could not determine reflectivity! Aborting!"<<std::endl;
65  throw;
66  }
67 }
68 
69 
71  : _name(amp._name),_reflectivity(amp._reflectivity), _rank(amp._rank),_threshold(amp._threshold), _integralindex(amp._integralindex), _acceptanceindex(amp._acceptanceindex),_constr(NULL){
72  if(amp._constr!=NULL)setConstraint(amp._constr->clone());
73 }
74 
76  if(_constr!=0)delete _constr;
77  _constr=0;
78 }
79 
80 void
82  _name=amp._name;
84  _rank=amp._rank;
88  setConstraint(amp._constr->clone());
89 }
90 
91 
92 complex<double> operator*(TPWAAmp& lhs, TPWAAmp& rhs){
93  return lhs.amp() * rhs.amp();
94 }
95 
96 complex<double> operator*(TPWAAmp& lhs, const complex<double>& rhs){
97  return lhs.amp() * rhs;
98 }
99 
100 complex<double> operator*(const complex<double>& lhs,TPWAAmp& rhs){
101  return lhs * rhs.amp();
102 }
103 
104 std::ostream& operator<< (std::ostream& s, const TPWAAmp& me){
105  s << me.name() << " " << me.amp();
106  return s;
107 }
108 
109 const complex<double>&
110 TPWAAmp::amp() const {
111  return _cached;
112 }
113 
114 complex<double>
116  if(_constr!=NULL)_cached=_constr->cAmp(_amp);
117  else _cached=_amp;
118  return _cached;
119 }
120 
121 
122 complex<double>
123 TPWAAmp::setPar(double* par){
124  _amp.real()=par[0];
125  _amp.imag()=par[1];
126  updateAmp();
127  return amp();
128 }
129 
130 int
131 TPWAAmp::npar() const {
132  if(_constr==NULL)return 2;
133  else return _constr->npar();
134 }
135 
136 string
137 TPWAAmp::type() const {
138  if(_constr==NULL)return "UnConstraint";
139  else return _constr->type();
140 }
141 
142 string
143 TPWAAmp::parname(unsigned int i) const {
144  std::stringstream name;
145  name << "V" << _rank << "_" << _name;
146  if(_constr==NULL){
147  if(i==0)name << "_RE";
148  else if(i==1)name << "_IM";
149  }
150  else name << _constr->parname(i);
151  return name.str();
152 }
153 
154 
155 double
156 TPWAAmp::par(unsigned int i) const {
157  return i==0 ? _amp.real() : _amp.imag();
158 }
159 
160 
161 
162 
163 void
165  if(_constr!=NULL){
166  std::cerr << "*** " << this->name() << std::endl;
167  std::cerr << "*** OVERRIDING PREVIOUSLY INSTALLED CONSTRAINT! "
168  << std::endl;
169  delete _constr;
170  }
171  _constr=c;
172  updateAmp();
173 }
174 
175 complex<double>
176 TPWAAmp::dampdpar(unsigned int i) const {
177  if(_constr==NULL){
178  if(i==0)return complex<double>(1,0);
179  else if(i==1)return complex<double>(0,1);
180  else return complex<double>(0,0);
181  }
182  else {
183  return _constr->dampdpar(i);
184  }
185 }