ROOTPWA
testWaveDescription.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 description class
29 //
30 //
31 // Author List:
32 // Boris Grube TUM (original author)
33 //
34 //
35 //-------------------------------------------------------------------------
36 
37 
38 #include "TFile.h"
39 #include "TSystem.h"
40 
41 #include "particleDataTable.h"
42 #include "waveDescription.h"
43 
44 
45 using namespace std;
46 using namespace rpwa;
47 
48 
49 int
50 main(int argc, char** argv)
51 {
52  waveDescription::setDebug(true);
53 
54  printCompilerInfo();
55  printSvnVersion();
56  particleDataTable::readFile();
57 
58  if (1) {
59  const string keyFileName = "testWaveDescription.key";
60  waveDescription waveDesc;
62  if (waveDesc.parseKeyFile(keyFileName) and waveDesc.constructAmplitude(amp)) {
63  isobarDecayTopologyPtr topo = amp->decayTopology();
64  printInfo << *amp;
65  topo->writeGraphViz("testWaveDescription.dot");
66  gSystem->Exec("dot -Tps -o testWaveDescription.ps testWaveDescription.dot");
67  waveDesc.writeKeyFile("testWaveDescriptionWrite.key", *amp); // test key file creation
68  //waveDesc.writeKeyFile("testWaveDescriptionWrite.key", *(amp->decayTopology())); // test key file creation
69  // test file I/O of waveDescription
70  const string waveName = waveDesc.waveNameFromTopology(*topo);
71  {
72  TFile* outFile = TFile::Open("testWaveDescription.root", "RECREATE");
73  waveDesc.Write(waveName.c_str());
74  outFile->Close();
75  }
76  amp.reset();
77  cout << endl
78  << "--------------------------------------------------------------------------------"
79  << endl << endl;
80  {
81  TFile* inFile = TFile::Open("testWaveDescription.root", "READ");
82  waveDescription* waveDesc2 = 0;
83  inFile->GetObject(waveName.c_str(), waveDesc2);
84  if (not waveDesc2)
85  printErr << "cannot find wave description '" << waveName << "'" << endl;
86  else
87  printInfo << "key file:" << endl;
88  waveDesc2->printKeyFileContents(cout);
89  waveDesc2->constructAmplitude(amp);
90  waveDesc2->writeKeyFile("testWaveDescriptionWrite2.key", *amp); // test key file creation
91  //waveDesc2->writeKeyFile("testWaveDescriptionWrite2.key", *(amp->decayTopology())); // test key file creation
92  printInfo << *amp;
93  inFile->Close();
94  }
95  }
96  }
97 
98 }