Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JDB.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <iomanip>
3 
4 #include "JDB/JDB.hh"
5 #include "JDetector/JDetector.hh"
6 
7 #include "Jeep/JParser.hh"
8 #include "Jeep/JMessage.hh"
9 
10 
11 /**
12  * \file
13  *
14  * Example program to test detector reading using KM3NETDB::JDB.
15  * \author mdejong
16  */
17 int main(int argc, char **argv)
18 {
19  using namespace std;
20 
21  string usr;
22  string pwd;
23  string cookie;
24  string id;
25  string t0set;
26  string calibset;
27  int run;
28  int debug;
29 
30  try {
31 
32  JParser<> zap("Example program to test detector reading from data base.");
33 
34  zap['u'] = make_field(usr) = "";
35  zap['!'] = make_field(pwd) = "";
36  zap['C'] = make_field(cookie) = "";
37  zap['D'] = make_field(id) = "14";
38  zap['r'] = make_field(run);
39  zap['t'] = make_field(t0set) = "";
40  zap['c'] = make_field(calibset) = "";
41  zap['d'] = make_field(debug) = 1, 0, 2, 3;
42 
43  zap(argc, argv);
44  }
45  catch(const exception &error) {
46  FATAL(error.what() << endl);
47  }
48 
49  using namespace JPP;
50  using namespace KM3NETDB;
51 
52  if (usr != "" && pwd != "")
53  JDB::reset(usr, pwd);
54  else if (cookie != "")
55  JDB::reset(cookie);
56  else
57  FATAL("Must provide either username (with password) or cookie." << endl);
58 
59  JDetector detector;
60  if (!t0set.empty() && !calibset.empty())
61  *JDB::get()->DetX(id.c_str(), run, t0set.c_str(), calibset.c_str()) >> detector;
62  else
63  *JDB::get()->DetX(id.c_str(), run) >> detector;
64 
65  cout << detector << endl;
66 
67 }
Utility class to parse command line options.
Definition: JParser.hh:1410
void reset(JCLBInput &data, size_t size)
Reset CLB buffers.
Data structure for detector geometry and calibration.
T get(const JHead &head)
Get object from header.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1836
int debug
debug level
Definition: JSirene.cc:59
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:65
Utility class to parse command line options.
int main(int argc, char *argv[])
Definition: Main.cpp:15