ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitHzz4l/ElectronStudies/src/ZeeTreeWriterArgs.cc
Revision: 1.2
Committed: Wed Jul 18 09:31:12 2012 UTC (12 years, 10 months ago) by anlevin
Content type: text/plain
Branch: MAIN
Changes since 1.1: +9 -5 lines
Log Message:
updated electron studies stuff

File Contents

# User Rev Content
1 anlevin 1.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 anlevin 1.2 {"output_filename", 1, 0, 'e'},
21     {"is_data", 1, 0, 'f'},
22     {"n_events_to_process", 1, 0, 'g'},
23 anlevin 1.1 {0, 0, 0, 0}
24     };
25    
26     c = getopt_long (argc, argv, "a:b:",
27     long_options, &option_index);
28     if (c == -1)
29     break;
30    
31     switch (c) {
32     case 0:
33     printf ("option %s", long_options[option_index].name);
34     if (optarg)
35     printf (" with arg %s", optarg);
36     printf ("\n");
37     break;
38    
39     case 'a':
40     flags.catalogDir = string(optarg);
41     break;
42     case 'b':
43     flags.book = string(optarg);
44     break;
45     case 'c':
46     flags.dataset = string(optarg);
47     break;
48     case 'd':
49     flags.fileset = string(optarg);
50     break;
51     case 'e':
52 anlevin 1.2 flags.output_filename = string(optarg);
53 anlevin 1.1 break;
54 anlevin 1.2 case 'f':
55     flags.is_data = atoi(optarg);
56     break;
57     case 'g':
58     flags.n_events_to_process = atoi(optarg);
59 anlevin 1.1 break;
60     case '2':
61     if (digit_optind != 0 && digit_optind != this_option_optind)
62     printf ("digits occur in two different argv-elements.\n");
63     digit_optind = this_option_optind;
64     printf ("option %c\n", c);
65     break;
66    
67    
68     case '?':
69     break;
70    
71     default:
72     printf ("?? getopt returned character code 0%o ??\n", c);
73     }
74     }
75    
76     if (optind < argc) {
77     printf ("non-option ARGV-elements: ");
78     while (optind < argc)
79     printf ("%s ", argv[optind++]);
80     printf ("\n");
81     }
82    
83    
84     }