ROOTPWA
testParticle.cc
Go to the documentation of this file.
1 
2 //
3 // Copyright 2010
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 // $Rev:: $: revision of last commit
24 // $Author:: $: author of last commit
25 // $Date:: $: date of last commit
26 //
27 // Description:
28 // basic test program for particle and related classes
29 //
30 //
31 // Author List:
32 // Boris Grube TUM (original author)
33 //
34 //
35 //-------------------------------------------------------------------------
36 
37 
38 #include "TVector3.h"
39 #include "TLorentzRotation.h"
40 
41 #ifdef USE_PWA2000
42 #include "Vec.h"
43 #include "lorentz.h"
44 #endif
45 
46 #include "spinUtils.hpp"
47 #include "reportingUtilsRoot.hpp"
48 #include "conversionUtils.hpp"
49 #include "../particleDataTable.h"
50 #include "../particle.h"
51 
52 
53 using namespace std;
54 using namespace rpwa;
55 
56 
57 int
58 main(int argc, char** argv)
59 {
60 
61  if (1) {
62  // switch on debug output
63  particleProperties::setDebug(true);
64  particleDataTable::setDebug(true);
65  particle::setDebug(true);
66  }
67 
68  // test loading of particle data table
69  particleDataTable& pdt = particleDataTable::instance();
70  pdt.readFile("./particleDataTable.txt");
71  pdt.readDecayModeFile("./testParticleDecays.txt");
72 
73  if (1)
74  printInfo << "particle data table:" << endl
75  << pdt;
76 
77  // test filling of particle properties
78  if (0) {
79  particleProperties partProp;
80  const string partName = "pi+";
81  partProp.fillFromDataTable(partName);
82  printInfo << "particle properties for '" << partName << "':" << endl
83  << partProp << endl;
84  pdt.addEntry(partProp);
85  printInfo << "antiparticle properties for '" << partName << "':" << endl
86  << partProp.antiPartProperties() << endl;
87  }
88 
89  // test construction of particles
90  if (0) {
91  TVector3 mom;
92  mom = TVector3(1, 2, 3);
93  const particle p1("pi+", true, 0, 0, 0, mom);
94  mom = TVector3(2, 3, 4);
95  const particle p2("pi-", true, 1, -1, 0, mom);
96  particle p3 = p2;
97  p3.setName("X+");
98  p3.setSpinProj(+1);
99  printInfo << "created particles: " << endl
100  << p1 << endl
101  << p2 << endl
102  << p3 << endl;
103  }
104 
105  // checking charge name handling
106  if (0) {
107  for (int i = -2; i < 3; ++i) {
108  stringstream c;
109  c << "pi";
110  if (abs(i) > 1)
111  c << abs(i);
112  c << sign(i);
113  //const particle p(c.str(), i);
114  int q;
115  const string n = particle::chargeFromName(c.str(), q);
116  printInfo << c.str() << ": charge = " << q << ", bare name = " << n << endl;
117  const particle p(c.str());
118  cout << "name = " << p.name() << endl
119  << endl;
120  }
121  }
122 
123  // check decay modes
124  if (1) {
125  cout << endl;
126  // particleProperties::decayMode decay1 = particleProperties::decayMode();
127  // printInfo << "decay mode: " << decay1 << endl;
128  particleProperties partProp;
129 
130  // printDebug << "testing anti-particle decay modes" << endl;
131  // partProp.fillFromDataTable("rho(770)-");
132  // printInfo << "particle properties: " << partProp << endl;
133  // particleProperties antiPartProp = partProp.antiPartProperties(true);
134  // printInfo << "anti-particle properties: " << antiPartProp << endl;
135 
136  printDebug << "testing equality operator for decay modes" << endl;
137  partProp.fillFromDataTable("sigma");
138  printInfo << "particle properties: " << partProp << endl;
139  for (unsigned int i = 0; i < partProp.nmbDecays(); ++i)
140  for (unsigned int j = i; j < partProp.nmbDecays(); ++j) {
141  cout << " {decay mode[" << i << "]: " << partProp.decayModes()[i]
142  << " vs. decay mode[" << j << "]: " << partProp.decayModes()[j]
143  << "}: " << trueFalse(partProp.decayModes()[i] == partProp.decayModes()[j]) << endl;
144  }
145  }
146 
147  // checking spin-exotic
148  if (0) {
149  printInfo << "testing spin-exotic tag" << endl;
150  for (particleDataTable::iterator i = pdt.begin(); i != pdt.end(); ++i) {
151  const particleProperties& prop = i->second;
152  const bool jpc = jpcIsExotic(prop.J(), prop.P(), prop.C());
153  const bool igjp = igjpIsExotic(prop.isospin(), prop.G(), prop.J(), prop.P());
154  cout << prop.name() << ": " << yesNo(jpc) << " vs. " << yesNo(igjp)
155  << ((jpc != igjp) ? " <<<" : "") << endl;
156  }
157  for (int J = 0; J < 4; ++J)
158  for (int P = -1; P <= 1; P += 2)
159  for (int C = -1; C <= 1; C += 2) {
160  const bool jpc = jpcIsExotic(2 * J, P, C);
161  const bool igjp1 = igjpIsExotic(0, C, 2 * J, P);
162  const bool igjp2 = igjpIsExotic(2, -C, 2 * J, P);
163  cout << J << sign(P) << sign(C) << ": " << yesNo(jpc) << " vs. " << yesNo(igjp1)
164  << ", " << yesNo(igjp2) << endl;
165  }
166  }
167 
168  if (0) {
169 #ifdef USE_PWA2000
170  {
171  fourVec p(2, threeVec(0.5, 0.75, 1));
172  threeVec n = threeVec(0, 0, 1) / p.V();
173  cout << "before = " << n << " " << p << endl;
174  rotation R;
175  lorentzTransform L1;
176  L1.set(R.set(n.phi(), n.theta() - M_PI / 2, -M_PI / 2));
177  n *= R;
178  p *= L1;
179  cout << "L1 -> " << n << " " << p << endl;
180  lorentzTransform L2;
181  L2.set(R.set(0, signof(p.x()) * p.theta(), 0));
182  p *= L2;
183  cout << "L2 -> " << p << endl;
184  lorentzTransform L3;
185  L3.set(p);
186  p *= L3;
187  cout << "L3 -> " << p << endl;
188 
189  matrix<double> X(4, 4);
190  X = L3 * (L2 * L1);
191  lorentzTransform L(X);
192  p = fourVec(2, threeVec(0.5, 0.75, 1));
193  p *= L;
194  cout << "L -> " << p << endl;
195  }
196 #else
197  printWarn << "code disabled, because compilation of PWA2000 is disabled" << endl;
198 #endif
199 
200  {
201  TLorentzVector p(0.5, 0.75, 1, 2);
202  TVector3 n = TVector3(0, 0, 1).Cross(p.Vect());
203  TRotation R1;
204  R1.RotateZ(-n.Phi());
205  R1.RotateY(piHalf - n.Theta());
206  R1.RotateZ(piHalf);
207  n *= R1;
208  p *= R1;
209  cout << "R1 -> " << n << " " << p << endl;
210  // rotate about yHfAxis so that daughter momentum is along z-axis
211  TRotation R2;
212  R2.RotateY(-signum(p.X()) * p.Theta());
213  p *= R2;
214  cout << "R2 -> " << p << endl;
215  // boost into daughter RF
216  TLorentzRotation L3(-p.BoostVector());
217  cout << "L3 -> " << L3 * p << endl;
218 
219  R1.Transform(R2);
220  TLorentzRotation L(R1);
221  L.Boost(-p.BoostVector());
222  p = TLorentzVector(0.5, 0.75, 1, 2);
223  p *= L;
224  cout << "L -> " << p << endl;
225  }
226  }
227 
228 }