ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitHzz4l/ElectronStudies/src/ZeeTreeWriterArgs.cc
Revision: 1.4
Committed: Thu Jul 26 22:41:07 2012 UTC (12 years, 9 months ago) by anlevin
Content type: text/plain
Branch: MAIN
Changes since 1.3: +4 -0 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 anlevin 1.3 #include "ZeeTreeWriterArgs.h"
6 anlevin 1.1
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.4 {"rho", 1, 0, 'h'},
24 anlevin 1.1 {0, 0, 0, 0}
25     };
26    
27     c = getopt_long (argc, argv, "a:b:",
28     long_options, &option_index);
29     if (c == -1)
30     break;
31    
32     switch (c) {
33     case 0:
34     printf ("option %s", long_options[option_index].name);
35     if (optarg)
36     printf (" with arg %s", optarg);
37     printf ("\n");
38     break;
39    
40     case 'a':
41     flags.catalogDir = string(optarg);
42     break;
43     case 'b':
44     flags.book = string(optarg);
45     break;
46     case 'c':
47     flags.dataset = string(optarg);
48     break;
49     case 'd':
50     flags.fileset = string(optarg);
51     break;
52     case 'e':
53 anlevin 1.2 flags.output_filename = string(optarg);
54 anlevin 1.1 break;
55 anlevin 1.2 case 'f':
56     flags.is_data = atoi(optarg);
57     break;
58     case 'g':
59     flags.n_events_to_process = atoi(optarg);
60 anlevin 1.1 break;
61 anlevin 1.4 case 'h':
62     flags.rho = string(optarg);
63     break;
64 anlevin 1.1 case '2':
65     if (digit_optind != 0 && digit_optind != this_option_optind)
66     printf ("digits occur in two different argv-elements.\n");
67     digit_optind = this_option_optind;
68     printf ("option %c\n", c);
69     break;
70    
71    
72     case '?':
73     break;
74    
75     default:
76     printf ("?? getopt returned character code 0%o ??\n", c);
77     }
78     }
79    
80     if (optind < argc) {
81     printf ("non-option ARGV-elements: ");
82     while (optind < argc)
83     printf ("%s ", argv[optind++]);
84     printf ("\n");
85     }
86    
87    
88     }