59 const int errCode = 0)
61 cerr <<
"creates graphical representation of decay graph(s) specified in given key file(s)" << endl
62 <<
"output files will have the same name as the corresponding key files" << endl
66 <<
" [-p PDG file -f output format -v -h] key file(s)" << endl
68 <<
" -p file path to particle data table file (default: ./particleDataTable.txt)" << endl
69 <<
" -f format output format: dot, ps, eps (default), svg, fig, dia, png, gif" << endl
70 <<
" -v verbose; print debug output (default: false)" << endl
71 <<
" -h print help" << endl
87 const string progName = argv[0];
88 string pdgFileName =
"./particleDataTable.txt";
89 string outFormat =
"eps";
94 while ((c = getopt(argc, argv,
"p:f:vh")) != -1)
111 if (optind >= argc) {
112 printErr <<
"you need to specify at least one key file to process. aborting." << endl;;
115 vector<string> keyFileNames;
116 while (optind < argc) {
117 const string fileName = argv[optind++];
118 if (fileName.substr(fileName.length() - 4) ==
".key")
119 keyFileNames.push_back(fileName);
121 printWarn <<
"input file '" << fileName <<
"' is not a .key file. "
122 <<
"skipping." << endl;
124 if (keyFileNames.size() == 0) {
125 printErr <<
"none of the specified input files is a .key file. aborting.";
130 transform(outFormat.begin(), outFormat.end(), outFormat.begin(), (
int(*)(
int))tolower);
131 const string validFormats[] = {
"dot",
"ps",
"eps",
"svg",
"fig",
"dia",
"png",
"gif"};
132 bool isValidFormat =
false;
133 for (
unsigned int i = 0;
i <
sizeof(validFormats) /
sizeof(validFormats[0]); ++
i)
134 if (outFormat == validFormats[
i]) {
135 isValidFormat =
true;
138 if (not isValidFormat) {
139 printErr <<
"requested format '" << outFormat <<
"' is not supported." << endl;
148 unsigned int countSuccess = 0;
149 for (
unsigned int i = 0; i < keyFileNames.size(); ++
i) {
156 printErr <<
"problems constructing decay topology from key file '" << keyFileNames[
i] <<
"'. "
157 <<
"skipping." << endl;
160 const string dotFileName = keyFileNames[
i].substr(0, keyFileNames[i].length() - 4) +
".dot";
162 printDebug <<
"writing graph to file '" << dotFileName <<
"'" << endl;
163 if (not decayTopo->writeGraphViz(dotFileName)) {
164 printWarn <<
"there were problems writing graph to file '" << dotFileName <<
"'. "
165 <<
"skipping." << endl;
170 const string outFileName = keyFileNames[
i].substr(0, keyFileNames[i].length() - 4)
173 printDebug <<
"converting graph to file '" << outFileName <<
"'" << endl;
175 if ( (outFormat ==
"ps" ) or (outFormat ==
"eps")
176 or (outFormat ==
"fig") or (outFormat ==
"dia")
177 or (outFormat ==
"png") or (outFormat ==
"gif")
178 or (outFormat ==
"svg")) {
179 cmd <<
"dot -T" << outFormat <<
" -o " << outFileName <<
" " << dotFileName;
181 printDebug <<
"executing command '" << cmd.str() <<
"'" << endl;
182 if (gSystem->Exec(cmd.str().c_str()) != 0)
183 printWarn <<
"command '" << cmd.str() <<
"' was not successful." << endl;
188 cmd <<
"rm " << (debug ?
"--verbose " :
"") << dotFileName;
189 if (gSystem->Exec(cmd.str().c_str()) != 0)
190 printWarn <<
"command '" << cmd.str() <<
"' was not successful." << endl;
194 printSucc <<
"created " << countSuccess <<
" out of " << keyFileNames.size()
195 <<
" diagram files" << endl;