ROOTPWA
gamp.cc
Go to the documentation of this file.
1 #include <cstdlib>
2 #include <unistd.h>
3 
4 #include "event.h"
5 #include "keyfile.h"
6 
7 
8 using namespace std;
9 
10 
11 extern int keydebug;
13 
14 
15 void printUsage(char* pname);
16 
17 
18 int main(int argc, char** argv)
19 {
20  char* pdgFile = (char*) NULL;
21  char* pname = argv[0];
22  int io_ver = 1;
23  int printPDG = 0;
24  int dumpPDG = 0;
25 
26  int c;
27  extern char* optarg;
28  extern int optind;
29  while ((c = getopt(argc, argv, "htP:vi:D")) != -1)
30  switch (c) {
31  case 'P':
32  pdgFile = optarg;
33  break;
34  case 'v':
35  printPDG = 1;
36  break;
37  case 'D':
38  dumpPDG = 1;
39  break;
40  case 'i':
41  io_ver = atoi(optarg);
42  break;
43  case 't':
44  keydebug = 1;
45  break;
46  case 'h':
47  case '?':
48  printUsage(pname);
49  }
50 
51  if (pdgFile)
52  PDGtable.initialize(pdgFile);
53  else
55 
56  if (dumpPDG) {
57  PDGtable.dump();
58  cout << flush;
59  }
60  if (printPDG) {
61  PDGtable.print();
62  cout << flush;
63  }
64 
65  if (!argv[optind]) {
66  cerr << pname << ": ERROR: no keyfile specified" << endl;
67  printUsage(pname);
68  }
69  keyfile keyf;
70  keyf.open(argv[optind]);
71 
72  event e;
73  e.setIOVersion(io_ver);
74  while (!(cin >> e).eof()) {
75  keyf.run(e);
76  keyf.rewind();
77  }
78 
79  return 0;
80 }
81 
82 
83 void printUsage(char* pname)
84 {
85  cerr << "usage: " << pname << " [-t] keyfile [-P pdgFile] [-v] [-D] < datafile" << endl
86  << "\t-t:\tparser trace" << endl
87  << "\t-P pdgFile:\tread PDG table from pdgFile" << endl
88  << "\t-v:\tprint pdgTable" << endl
89  << "\t-i io_ver:\tset event io version to io_ver (1 or 2)" << endl
90  << "\t-D:\tdump pdgTable" << endl
91  << "\tkeyfile: decay amplitude specification" << endl;
92  exit(1);
93 }