ROOTPWA
testWaveSetGenerator.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 wave set generator
29 //
30 //
31 // Author List:
32 // Boris Grube TUM (original author)
33 //
34 //
35 //-------------------------------------------------------------------------
36 
37 
38 #include <boost/assign/list_of.hpp>
39 
40 #include "TSystem.h"
41 
42 #include "particleDataTable.h"
43 #include "waveDescription.h"
44 #include "waveSetGenerator.h"
45 
46 
47 using namespace std;
48 using namespace boost;
49 using namespace boost::assign;
50 using namespace rpwa;
51 
52 
53 int
54 main(int argc, char** argv)
55 {
56  // switch on debug output
57  //particleProperties::setDebug(true);
58  //particleDataTable::setDebug(true);
59  //particle::setDebug(true);
60  //decayTopologyGraphType::setDebug(true);
61  //isobarDecayVertex::setDebug(true);
62  //decayTopology::setDebug(true);
63  //isobarDecayTopology::setDebug(true);
64  waveSetGenerator::setDebug(true);
65 
66  particleDataTable& pdt = particleDataTable::instance();
67  pdt.readFile("./particleDataTable.txt");
68  pdt.readDecayModeFile("./testParticleDecays.txt");
69 
70  // test selective comparision of particle properties
71  if (0) {
72  particleProperties prop1("bla", 2, -1, 0, +1, +1);
73  particleProperties prop2("blub", 2, +1, 2, -1, -1);
74 
75  string opt="IGJPC";
76 
77  printDebug << "Comparison result: " << (prop1 == prop2) << endl;
78  printDebug << "Comparison with opt = " << opt << " result: "
79  << (prop1 == pair<particleProperties, string>(prop2, opt)) << endl;
80 
81  vector<const particleProperties*> selection = pdt.entriesMatching(prop2, opt);
82  printDebug << "Matching entries in pdt with prototype: " << endl
83  << prop2 << endl
84  << " with option " << opt << endl;
85 
86  for(unsigned int i = 0; i < selection.size(); ++i)
87  cout << *selection[i] << endl;
88  }
89 
90 
91  // test particle and vertex comparison
92  if (0) {
93  particleProperties partProp1;
94  partProp1.fillFromDataTable("pi+");
95  particleProperties partProp2 = partProp1;
96  printDebug << "particle properties" << endl
97  << partProp1 << endl
98  << partProp2 << endl;
99  printInfo << "comparing particle properties" << endl;
100  partProp1 == partProp2;
101 
102  particlePtr part1 = createParticle(partProp1);
103  particlePtr part2 = createParticle(partProp2, 1, 2, +1);
104  printDebug << "particles" << endl
105  << *part1 << endl
106  << *part2 << endl;
107  printInfo << "comparing particles" << endl;
108  *part1 == *part2;
109 
110  // const string keyFileName = "../../keyfiles/key3pi/SET1_new/1-0-+0+rho770_11_pi-.key";
111  const string keyFileName = "testWaveDescription.key";
112  waveDescription waveDesc;
113  isobarAmplitudePtr amp;
114  if (waveDesc.parseKeyFile(keyFileName) and waveDesc.constructAmplitude(amp)) {
115  isobarDecayTopologyPtr isoTopo = amp->decayTopology();
116  decayTopologyPtr topo = static_pointer_cast<decayTopology>(isoTopo);
117  // printInfo << *isoTopo << endl;
118  // printInfo << *topo << endl;
119  isobarDecayVertexPtr isoVert = isoTopo->XIsobarDecayVertex();
120  interactionVertexPtr vert = topo->XDecayVertex();
121  printInfo << "isobar decay vertex: " << *isoVert << endl;
122  printInfo << "interaction vertex: " << *vert << endl;
123 
124  printInfo << "comparing isobar decay vertices" << endl;
125  *isoVert == *isoVert;
126  printInfo << "comparing interaction vertices" << endl;
127  *vert == *vert;
128  }
129 
130  }
131 
132 
133  if (1) {
134  waveSetGenerator waveSetGen;
135  if (not waveSetGen.setWaveSetParameters("testWaveSetGenerator.key")) {
136  cout << "could not initialize wave set generator. aborting." << endl;
137  exit(1);
138  }
139  const vector<string> isobarWhiteList = list_of("rho(770)")("a1(1260)");
140  waveSetGen.setIsobarWhiteList(isobarWhiteList);
141  waveSetGen.setForceDecayCheck(true);
142  printDebug << waveSetGen;
143  waveSetGen.generateWaveSet();
144  vector<isobarDecayTopology>& decays = waveSetGen.waveSet();
145  unsigned int consistentDecays = 0;
146  unsigned int inconsistentDecays = 0;
147  for (unsigned int i = 0; i < decays.size(); ++i) {
148  // cout << decays[i];
149  // decays[i].printPointers(cout);
150  // for (decayTopologyGraphType::nodeIterator j = decays[i].nodes().first;
151  // j != decays[i].nodes().second; ++j)
152  // decays[i].vertex(*j)->printPointers(cout);
153  //isobarDecayVertex::setDebug(true);
154  bool isConsistent = decays[i].checkTopology() and decays[i].checkConsistency();
155  //isobarDecayVertex::setDebug(false);
156  if (isConsistent) {
157  // cout << "isobar decay topology is consistent" << endl;
158  ++consistentDecays;
159  } else {
160  printErr << "isobar decay topology is NOT consistent" << endl;
161  cout << decays[i];
162  ++inconsistentDecays;
163  }
164  }
165 
166  for (unsigned int i = 0; i < decays.size(); ++i)
167  cout << setw(4) << i << ": " << waveDescription::waveNameFromTopology(decays[i], true) << endl;
168 
169  gSystem->Exec("mkdir testWaveSetGenerator");
170  waveSetGen.writeKeyFiles("testWaveSetGenerator");
171 
172  cout << "got " << inconsistentDecays << " inconsistent" << endl
173  << "and " << consistentDecays << " valid decays" << endl
174  << "out of " << decays.size() << " constructed decays" << endl;
175 
176  // decays.back().writeGraphViz("foo.dot");
177  // gSystem->Exec("dot -Tps -o foo.ps foo.dot");
178  }
179 }