// Author: David Lawrence June 25, 2004 // // // hd_ana.cc // #include #include #include #include #include #include "MyProcessor.h" #include "DANA/DApplication.h" using namespace std; void usage() { cout << "Usage: tstart" << " [opts] inputFile.hddm [inputFile2.hddm [...]] " << endl; cout << left << setw(20) << "\t-b" << setw(50) << "Run in batch mode (no counter)" << endl; cout << left << setw(20) << "\t-o output.root" << setw(50) << "Write output to output.root" << endl; cout << left << setw(20) << "\t-n nEvents" << setw(50) << "Process only nEvents events" << endl; } //----------- // main //----------- int main(int argc, char *argv[]) { int max_events = 0; string output_file = "tstart.out"; bool batch_mode = false; vector args; int c; while ((c = getopt(argc, argv, "n:o:bh")) != -1) { switch(c) { case 'n': max_events = atoi(optarg); break; case 'o': output_file = optarg; break; case 'b': batch_mode = true; break; case 'h': usage(); return 1; case '?': if ((optopt == 'n') || (optopt = 'o')) { cout << "Option -" << optopt << " requires an argument." << endl; cout << "See `tstart -h' for more information." << endl; } else if (isprint(optopt)) { cout << "Unknown option -" << optopt << endl; cout << "See `tstart -h' for more information." << endl; } else { cout << "Unrecognized option character " << optopt << endl; cout << "See `tstart -h' for more information." << endl; } return 2; default: abort(); } } if (optind == argc) { cout << "Please supply one or more HDDM files for input." << endl; cout << "See `tstart -h' for more information." << endl; return 3; } for (int i=optind; i < argc; i++) args.push_back(argv[i]); // Instantiate our event processor MyProcessor myproc(args, max_events, output_file, batch_mode); // Instantiate an event loop object DApplication app(argc, argv); // Run though all events, calling our event processor's methods app.Run(&myproc, 1); return 0; }