Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
pulse_classification_IO.hh
Go to the documentation of this file.
1 #ifndef __READOPTIONS__
2 #define __READOPTIONS__
3 
4 //c++ standard library
5 #include <iostream>
6 
7 // Jpp
8 #include "Jeep/JParser.hh"
9 #include "Jeep/JMessage.hh"
10 
11 //root
12 
13 // namespaces
14 using namespace std;
15 
16 /**
17  * \author rgruiz
18  */
19 
20 
21 
22 /**
23  * Structure to store the different command line arguments for pulse_classification.cc .
24  */
25 struct IO{
26 
27  string ifname ;
28 
29  string ofname ;
30 
31  string detector_file ;
32 
33  int string_number ;
34 
35  int analysis_level ;
36 
37  int up_pmts ;
38 
39  int down_pmts ;
40 
41  int number_neighbors ;
42 
43 };
44 
45 /**
46  * Parses the command line options and fills an IO structure with them.
47  *
48  * \param options an option structure
49  * \param argc the number of command line arguments
50  * \param argv the command line arguments
51  *
52  * \return 1 if works 2 if it doesn't work
53  */
54 inline int read_user_options(IO &options, int argc, char **argv){
55 
56  int a = 0;
57 
58  try {
59 
60  JParser<string> zap;
61 
62  zap["o"] = make_field(options.ofname) = "out.root" ;
63 
64  zap["f"] = make_field(options.ifname) ;
65 
66  zap["a"] = make_field(options.detector_file) ;
67 
68  zap["s"] = make_field(options.string_number) ;
69 
70  zap["l"] = make_field(options.analysis_level) = 0 ;
71 
72  zap["u"] = make_field(options.up_pmts) = 1 ;
73 
74  zap["d"] = make_field(options.down_pmts) = 4 ;
75 
76  zap["n"] = make_field(options.number_neighbors) = 2 ;
77 
78  if (zap.read(argc, argv) != 0)
79 
80  a = 1;
81 
82  }
83 
84  catch(const exception &error) {
85 
86  ERROR(error.what() << endl);
87 
88  a = 2;
89 
90  }
91 
92  return a;
93 
94 }
95 
96 
97 #endif
int up_pmts
Utility class to parse command line options.
Definition: JParser.hh:1410
int string_number
int down_pmts
Structure to store the different command line arguments for JRunAnalyzer.
Definition: JRunAnalyzer.cc:40
string ofname
Definition: JRunAnalyzer.cc:44
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1836
#define ERROR(A)
Definition: JMessage.hh:64
string ifname
Definition: JRunAnalyzer.cc:42
General purpose messaging.
int read(const int argc, const char *const argv[])
Parse the program&#39;s command line options.
Definition: JParser.hh:1673
int number_neighbors
Utility class to parse command line options.
string detector_file
Definition: JRunAnalyzer.cc:46
int read_user_options(IO &options, int argc, char **argv)
Parses the command line options and fills an IO structure with them.
Definition: JRunAnalyzer.cc:59
int analysis_level