12 printf(
"\nUsage: %s INPUTS [INPUTS ...] OUTPUT\n\n", first_arg);
13 printf(
"INPUTS Must be valid panda files.\n");
14 printf(
"OUTPUT Is the name of the output file that is used in monojet analysis\n");
15 printf(
" The file must not exist prior to running %s\n\n", first_arg);
31 for (
int i_file = 1; i_file < argc; i_file++) {
32 int stat_code = stat(argv[i_file], &buffer);
34 if (stat_code != 0 && i_file != (argc - 1)) {
36 printf(
"Could not find file located at %s\n", argv[i_file]);
37 printf(
"Please try again.\n");
40 else if (stat_code == 0 && i_file == (argc - 1)) {
42 printf(
"File %s already exists.\n", argv[i_file]);
43 printf(
"Please select a different file to write to.\n");
48 time_t start_time = time(NULL);
49 auto exit_code = desired_main(argc, argv);
50 printf(
"\nFinished %i files in %li seconds.\n\n", argc - 2, time(
nullptr) - start_time);
70 const char* dummyinput =
"inputFiles";
71 const char* dummyoutput =
"outputFile";
75 printf(
"Alternatively, you can use this goofy cmsRun-style syntax:\n\n");
76 printf(
" %s fake.py %s=INPUTS,INPUTS[,INPUTS...] %s=OUTPUT\n\n",
77 argv[0], dummyinput, dummyoutput);
78 printf(
"Be sure to put some fake python file name there,\n");
79 printf(
"if that's what you want. Otherwise I won't parse.\n\n");
83 if (strcmp(argv[1] + strlen(argv[1]) - 3,
".py") == 0) {
84 printf(
"Detected fake python file %s at the beginning.\n", argv[1]);
85 printf(
"Parsing inputs for CMSSW style.\n\n");
89 assert(argv[2][strlen(dummyinput)] ==
'=');
90 assert(argv[3][strlen(dummyoutput)] ==
'=');
93 const int MAX_ARGS = 2048;
94 char* parsed_argv[MAX_ARGS];
95 parsed_argv[0] = argv[0];
98 int num_chars = strlen(argv[2]);
99 bool just_found_sep =
true;
100 for (
int i_char = strlen(dummyinput) + 1; i_char < num_chars; i_char++) {
101 if (just_found_sep) {
102 parsed_argv[parsed_argc++] = argv[2] + i_char;
103 just_found_sep =
false;
104 assert(parsed_argc < MAX_ARGS);
107 if (argv[2][i_char] ==
',') {
108 argv[2][i_char] =
'\0';
109 just_found_sep =
true;
114 parsed_argv[parsed_argc++] = argv[3] + strlen(dummyoutput) + 1;