ROOTPWA
Tgamp.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 // File and Version Information:
23 // $Id$
24 //
25 // Description:
26 //
27 //
28 //
29 // Author List:
30 // Sebastian Neubert TUM (original author)
31 //
32 //
33 //-----------------------------------------------------------
34 
35 
36 #include "keyfile.h"
37 #include "particle.h"
38 #include "lorentz.h"
39 #include "Vec.h"
40 #include "event.h"
41 #include "wave.h"
42 
43 #include "Tgamp.h"
44 
45 
46 using namespace std;
47 
48 
49 //extern int keydebug;
51 extern wave gWave;
52 
53 
54 Tgamp::Tgamp(const string& pdgTableFileName)
55  : _reflect (false), _mirror (false),
56  _suppressOutput(true)
57 {
58  if (pdgTableFileName != "")
59  PDGtable.initialize(pdgTableFileName.c_str());
60  else
62 }
63 
64 
66 {
67 }
68 
69 
70 complex<double>
71 Tgamp::Amp(const string& keyFileName,
72  event& ev) const
73 {
74  keyfile key;
75  key.open(keyFileName);
76 
77  complex<double> amplitude;
78  if (_reflect)
79  ev = reflectEvent(ev);
80  if(_mirror)
81  ev = mirrorEvent(ev);
82  key.run(ev, amplitude, _suppressOutput);
83  key.rewind();
84  key.close();
85  return amplitude;
86 }
87 
88 
89 complex<double>
90 Tgamp::Amp(const unsigned int iKey,
91  event& ev) const
92 {
93  if (iKey >= _keyFileNames.size()) {
94  cerr << "invalid index " << iKey << "! returning (0,0)" << endl;
95  return complex<double>(0,0);
96  }
97 
98  return Amp(_keyFileNames[iKey], ev);
99 }
100 
101 
102 vector<complex<double> >
103 Tgamp::Amp(const string& keyFileName,
104  istream& eventData,
105  const bool testMode) const // enables test mode
106 {
107  if (!testMode) {
108  vector<complex<double> > amplitudes;
109  event ev;
110  ev.setIOVersion(1);
111  while (!(eventData >> ev).eof())
112  amplitudes.push_back(Amp(keyFileName, ev));
113  return amplitudes;
114  } else {
115  cout << "!!! test mode!" << endl;
116  const int debug = 0;
117  vector<complex<double> > amplitudes;
118  event ev;
119  ev.setIOVersion(1);
120  bool first = true;
121  while (!(eventData >> ev).eof())
122  if (first) {
123  amplitudes.push_back(Amp(keyFileName, ev));
124  first = false;
125  } else {
126  if (debug) {
127  cout << "@@Found a wave" << endl;
128  gWave.print();
129  cout << "@@Filling wave" << endl;
130  }
131  gWave.fill(ev, debug);
132  if (debug) {
133  cout << "@@Wave before boosts" << endl;
134  gWave.print();
135  }
136  gWave.setupFrames(debug);
137  if (debug) {
138  cout << "@@Wave after boosts" << endl;
139  gWave.print();
140  }
141  amplitudes.push_back(gWave.decayAmp(debug));
142  }
143  return amplitudes;
144  }
145 }
146 
147 
148 vector<complex<double> >
149 Tgamp::Amp(const unsigned int iKey,
150  istream& eventData) const
151 {
152  if (iKey >= _keyFileNames.size()) {
153  cerr << "invalid index " << iKey << "!" << endl;
154  return vector<complex<double> >();
155  }
156 
157  return Amp(_keyFileNames[iKey], eventData);
158 }
159 
160 
161 // performs reflection through production plane
162 event
164 {
165  // // get X Lorentz-vector in lab frame
166 // const list<particle> daughtersLab = evIn.f_mesons();
167 // fourVec XLab;
168 // for (list<particle>::const_iterator i = daughtersLab.begin(); i != daughtersLab.end(); ++i)
169 // XLab += i->get4P();
170 
171 // // rotation into scattering plane
172 // const fourVec beamLab = evIn.beam().get4P();
173 // const threeVec prodPlaneNormal = beamLab.V() / XLab.V();
174 // static const double piHalf = acos(-1.0) / 2.0;
175 // rotation R(prodPlaneNormal.phi(),
176 // prodPlaneNormal.theta() - piHalf,
177 // -piHalf);
178 // const lorentzTransform rotScatPlane(R);
179 // fourVec X = XLab;
180 // fourVec beam = beamLab;
181 // X *= rotScatPlane;
182 // beam *= rotScatPlane;
183 
184 // // boost into X-RF
185 // const lorentzTransform boostRf(X);
186 // X *= boostRf;
187 // beam *= boostRf;
188 
189 // // rotation so that beam is along z-axis
190 // R.set(0, signof(beam.x()) * beam.V().theta(), 0);
191 // const lorentzTransform rotBeam(R);
192 
193 // // total transformation
194 // matrix<double> transMatrix = rotBeam * (boostRf * rotScatPlane);
195 // const lorentzTransform L = lorentzTransform(transMatrix);
196 // const lorentzTransform Linv(transMatrix.inv());
197 
198  // transform event into Gottfried-Jackson frame
200  lorentzTransform Linv(L.inv());
201  event evOut = L * evIn;
202 
203  // reflect final state through production plane
204  list<particle> daughtersRefl = evOut.f_mesons();
205  for (list<particle>::iterator i = daughtersRefl.begin(); i != daughtersRefl.end(); ++i) {
206  fourVec daughter = i->get4P();
207  daughter.set(daughter.t(), daughter.x(), -daughter.y(), daughter.z());
208  i->set4P(daughter);
209  }
210  evOut.set_f_mesons(daughtersRefl);
211 
212  // transform event back to lab frame
213  evOut = Linv * evOut;
214 
215  return evOut;
216 }
217 
218 // performs parity reflection
219 event
221 {
222 
224  lorentzTransform Linv(L.inv());
225  event evOut = L * evIn;
226 
227  list<particle> daughtersLab = evOut.f_mesons();
228  for (list<particle>::iterator i = daughtersLab.begin(); i != daughtersLab.end(); ++i){
229  fourVec daughter = i->get4P();
230  daughter.set(daughter.t(), -daughter.x(), -daughter.y(), -daughter.z());
231  i->set4P(daughter);
232  }
233  evOut.set_f_mesons(daughtersLab);
234 
235  // transform event back to lab frame
236  evOut = Linv * evOut;
237  return evOut;
238 }
239 
240 
243 // get X Lorentz-vector in lab frame
244  const list<particle> daughtersLab = evIn.f_mesons();
245  fourVec XLab;
246  for (list<particle>::const_iterator i = daughtersLab.begin(); i != daughtersLab.end(); ++i)
247  XLab += i->get4P();
248 
249  // rotation into scattering plane
250  const fourVec beamLab = evIn.beam().get4P();
251  const threeVec prodPlaneNormal = beamLab.V() / XLab.V();
252  static const double piHalf = acos(-1.0) / 2.0;
253  rotation R(prodPlaneNormal.phi(),
254  prodPlaneNormal.theta() - piHalf,
255  -piHalf);
256  const lorentzTransform rotScatPlane(R);
257  fourVec X = XLab;
258  fourVec beam = beamLab;
259  X *= rotScatPlane;
260  beam *= rotScatPlane;
261 
262  // boost into X-RF
263  const lorentzTransform boostRf(X);
264  X *= boostRf;
265  beam *= boostRf;
266 
267  // rotation so that beam is along z-axis
268  R.set(0, signof(beam.x()) * beam.V().theta(), 0);
269  const lorentzTransform rotBeam(R);
270 
271  // total transformation
272  matrix<double> transMatrix = rotBeam * (boostRf * rotScatPlane);
273  return lorentzTransform(transMatrix);
274 
275 }