ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitHzz4l/NonMCBackground/src/ElectronFakeRateArgs.cc
Revision: 1.1
Committed: Thu Jul 5 13:38:30 2012 UTC (12 years, 10 months ago) by anlevin
Content type: text/plain
Branch: MAIN
CVS Tags: compiled, HEAD
Log Message:
added arguments for fake rates

File Contents

# Content
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <getopt.h>
4
5 #include "ElectronFakeRateArgs.h"
6
7 void parse_electron_fake_rate_args( int argc, char** argv, ElectronFakeRateFlags &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 {"dielectron_or_dimuon_data", 1, 0, 'f'},
22 {"isData", 1, 0, 'g'},
23 {"n_events_to_process", 1, 0, 'h'},
24 {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 flags.outputFilename = string(optarg);
54 break;
55 case 'f':
56 flags.dielectron_or_dimuon_data = string(optarg);
57 break;
58 case 'g':
59 flags.isData = atoi(optarg);
60 break;
61 case 'h':
62 flags.n_events_to_process =atoi(optarg);
63 break;
64 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 }