Jpp  master_rocky-43-ge265d140c
the software that should make you happy
Functions
JDetCalibrations.cc File Reference

Auxiliary program to download default detector from database. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include "JDB/JDB.hh"
#include "JDB/JSelector.hh"
#include "JDB/JSelectorSupportkit.hh"
#include "JDB/JDetCalibrations.hh"
#include "JDB/JDBToolkit.hh"
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JSon/JSupport.hh"
#include "JSupport/JMeta.hh"
#include "Jeep/JPrint.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Auxiliary program to download default detector from database.

Author
mdejong

Definition in file JDetCalibrations.cc.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 30 of file JDetCalibrations.cc.

31 {
32  using namespace std;
33  using namespace JPP;
34 
35  JServer server;
36  string usr;
37  string pwd;
38  string cookie;
39  string id;
40  string outputFile;
41  string variant;
42  int debug;
43 
44  try {
45 
46  JParser<> zap("Auxiliary program to download default detector from database.");
47 
48  zap['s'] = make_field(server) = getServernames();
49  zap['u'] = make_field(usr) = "";
50  zap['!'] = make_field(pwd) = "";
51  zap['C'] = make_field(cookie) = "";
52  zap['D'] = make_field(id, "detector identifier");
53  zap['o'] = make_field(outputFile);
54  zap['V'] = make_field(variant, "detector version") = getDetectorVersions<string>();
55  zap['d'] = make_field(debug) = 2;
56 
57  zap(argc, argv);
58  }
59  catch(const exception &error) {
60  FATAL(error.what() << endl);
61  }
62 
63 
64  try {
65 
66  JDB::reset(usr, pwd, cookie);
67 
68  id = getDetector<string>(id);
69 
70  ResultSet& rs = getResultSet(getTable<JDetCalibrations>(), getSelector<JDetCalibrations>(id));
71 
73 
74  for (JDetCalibrations buffer; rs >> buffer; ) {
75 
76  const string type = getCalibrationType.getNickname(buffer.OPTYPE);
77 
78  if (calibration.count(type) == 0 || calibration[type].STARTTIME < buffer.STARTTIME) {
79  calibration[type] = buffer;
80  }
81  }
82 
83  rs.Close();
84 
86 
87  detector.comment.add(JMeta(argc,argv));
88 
89  for (const auto& key : { TCAL, PCAL, RCAL, ACAL, CCAL, SCAL }) {
90 
91  if (calibration.count(key) == 0) {
92  FATAL("Missing " << key << " calibration." << endl);
93  }
94 
95  detector.comment.add(MAKE_STRING(key << " = " << calibration[key].OPERATIONID));
96  }
97 
98  *(JDB::get()->DetX)(id.c_str(),
99  calibration[TCAL].OPERATIONID.c_str(),
100  calibration[PCAL].OPERATIONID.c_str(),
101  calibration[RCAL].OPERATIONID.c_str(),
102  calibration[ACAL].OPERATIONID.c_str(),
103  calibration[CCAL].OPERATIONID.c_str(),
104  calibration[SCAL].OPERATIONID.c_str(),
105  getDetectorVersion(variant)) >> detector;
106 
107  store(outputFile.c_str(), detector);
108  }
109  catch(const exception& error) {
110  FATAL(error.what() << endl);
111  }
112 }
string outputFile
#define FATAL(A)
Definition: JMessage.hh:67
int debug
debug level
Definition: JSirene.cc:69
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2142
#define MAKE_STRING(A)
Make string.
Definition: JPrint.hh:63
Detector data structure.
Definition: JDetector.hh:96
Utility class to parse command line options.
Definition: JParser.hh:1698
ResultSet & getResultSet(const std::string &query)
Get result set.
Definition: JDB.hh:437
std::vector< JServer > getServernames()
Get list of names of available database servers.
Definition: JDB.hh:107
static const JGetDetectorVersion getDetectorVersion
Function object to map detector version to numerical value.
void store(const std::string &file_name, const JDetector &detector)
Store detector to output file.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
static const std::string TCAL
PMT time offsets.
static const std::string PCAL
(optical|base) module positions
static const std::string SCAL
(module|PMT) status
static const std::string RCAL
optical module orientations
static const std::string ACAL
acoustic time offsets (piezo sensor or hydrophone)
static const std::string CCAL
compass alignment (a.k.a. quaternion calibration)
void reset(T &value)
Reset value.
Definition: JSTDTypes.hh:14
Calibration.
Definition: JHead.hh:330
Detector file.
Definition: JHead.hh:227
Wrapper class for server name.
Definition: JDB.hh:53
Template definition for getting table specific selector.
Auxiliary data structure for correspondence between nick and full name of calibration types.
const std::string & getNickname(const std::string &type) const
Get calibration type.
Auxiliary class for ROOT I/O of application specific meta data.
Definition: JMeta.hh:72