Jpp - the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JAHRSCalibration.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <iomanip>
3 
4 #include "JDB/JDB.hh"
5 #include "JDB/JDBToolkit.hh"
6 #include "JDB/JSelector.hh"
9 
10 #include "Jeep/JParser.hh"
11 #include "Jeep/JMessage.hh"
12 
13 
14 /**
15  * \file
16  *
17  * Auxiliary program to store AHRS calibration data on local disk.
18  * \author mdejong
19  */
20 int main(int argc, char **argv)
21 {
22  using namespace std;
23  using namespace JPP;
24 
25  string usr;
26  string pwd;
27  string cookie;
28  int option;
29  string detid;
30  string outputFile;
31  int debug;
32 
33  try {
34 
35  JParser<> zap("Auxiliary program to store AHRS calibration data on local disk.");
36 
37  zap['u'] = make_field(usr) = "";
38  zap['!'] = make_field(pwd) = "";
39  zap['C'] = make_field(cookie) = "";
40  zap['O'] = make_field(option) = 0;
41  zap['D'] = make_field(detid);
42  zap['o'] = make_field(outputFile) = "ahrs_calibration.txt";
43  zap['d'] = make_field(debug) = 2;
44 
45  zap(argc, argv);
46  }
47  catch(const exception &error) {
48  FATAL(error.what() << endl);
49  }
50 
51 
52  try {
53  JDB::reset(usr, pwd, cookie);
54  }
55  catch(const exception& error) {
56  FATAL(error.what() << endl);
57  }
58 
59  STATUS("Reading AHRS calibration data... " << flush);
60 
61  const JAHRSCalibration_t calibration(is_integer(detid) ? to_value<int>(detid) : getDetector(detid), option);
62 
63  STATUS("OK" << endl);
64 
65  if (outputFile != "") {
66 
67  STATUS("Storing AHRS calibration data to " << outputFile << "... " << flush);
68 
69  calibration.store(outputFile.c_str());
70 
71  STATUS("OK" << endl);
72 
73  } else {
74 
75  cout << calibration << endl;
76  }
77 }
Utility class to parse command line options.
Definition: JParser.hh:1500
int main(int argc, char *argv[])
Definition: Main.cc:15
#define STATUS(A)
Definition: JMessage.hh:63
string outputFile
JDetectorsHelper getDetector
Function object for mapping serial number to object identifier of detector and vice versa...
Definition: JDBToolkit.cc:5
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
bool is_integer(const std::string &buffer)
Check if string is an integer.
Definition: JLangToolkit.hh:58
int debug
debug level
Definition: JSirene.cc:63
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
void reset(T &value)
Reset value.
Utility class to parse command line options.