ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitHzz4l/ElectronStudies/src/ZeeTreeWriterArgs.cc
Revision: 1.1
Committed: Tue Jul 17 14:09:14 2012 UTC (12 years, 10 months ago) by anlevin
Content type: text/plain
Branch: MAIN
Log Message:
added electron regression stuff

File Contents

# Content
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <getopt.h>
4
5 #include "ZeeTreeWriterArgs.h"
6
7 void parse_zee_tree_writer_args(int argc, char** argv, ZeeTreeWriterFlags &flags) {
8
9 int c;
10 int digit_optind = 0;
11
12 while (1) {
13 int this_option_optind = optind ? optind : 1;
14 int option_index = 0;
15 static struct option long_options[] = {
16 {"catalogDir", 1, 0, 'a'},
17 {"book", 1, 0, 'b'},
18 {"dataset", 1, 0, 'c'},
19 {"fileset", 1, 0, 'd'},
20 {"outputFilename", 1, 0, 'e'},
21 {"n_events_to_process", 1, 0, 'h'},
22 {0, 0, 0, 0}
23 };
24
25 c = getopt_long (argc, argv, "a:b:",
26 long_options, &option_index);
27 if (c == -1)
28 break;
29
30 switch (c) {
31 case 0:
32 printf ("option %s", long_options[option_index].name);
33 if (optarg)
34 printf (" with arg %s", optarg);
35 printf ("\n");
36 break;
37
38 case 'a':
39 flags.catalogDir = string(optarg);
40 break;
41 case 'b':
42 flags.book = string(optarg);
43 break;
44 case 'c':
45 flags.dataset = string(optarg);
46 break;
47 case 'd':
48 flags.fileset = string(optarg);
49 break;
50 case 'e':
51 flags.outputFilename = string(optarg);
52 break;
53 case 'h':
54 flags.n_events_to_process =atoi(optarg);
55 break;
56 case '2':
57 if (digit_optind != 0 && digit_optind != this_option_optind)
58 printf ("digits occur in two different argv-elements.\n");
59 digit_optind = this_option_optind;
60 printf ("option %c\n", c);
61 break;
62
63
64 case '?':
65 break;
66
67 default:
68 printf ("?? getopt returned character code 0%o ??\n", c);
69 }
70 }
71
72 if (optind < argc) {
73 printf ("non-option ARGV-elements: ");
74 while (optind < argc)
75 printf ("%s ", argv[optind++]);
76 printf ("\n");
77 }
78
79
80 }