22 #include "JDB/JDBincludes.hh"
46 int main(
int argc,
char **argv)
50 using namespace KM3NETDAQ;
76 JParser<> zap(
"Auxiliary program to treat failed high-voltage tuning results.");
81 zap[
'f'] =
make_field(inputFile,
"input file");
83 zap[
'D'] =
make_field(detID,
"detector identifier") = -1;
84 zap[
'r'] =
make_field(runNr,
"run number") = -1;
91 }
catch(
const exception &error) {
93 FATAL(error.what() << endl);
105 ifstream ifs(inputFile.c_str());
112 json::const_iterator data = js.find(
Tests_t);
114 if (data != js.end()) {
120 ERROR(
"HV calibration data could not be found!");
125 if (DBtype != js.end()) {
127 testType = DBtype->get<
string>();
131 WARNING(
"No database test type specified.");
134 if (pmtSet.empty()) {
136 for (JHVCalibration::iterator it = HVcals.begin(); it != HVcals.end(); ++it) {
138 if (it->result !=
OK_t) {
139 toEdit.push_back(*it);
147 JHVCalibration::iterator pmt = find_if(HVcals.begin(), HVcals.end(),
149 if (pmt != HVcals.end()) {
151 if (pmt->result ==
OK_t) {
152 WARNING(
"Editing result for " << pmt->getUPI() <<
", which is already labeled " <<
OK_t << endl);
155 toEdit.push_back(*pmt);
162 ERROR(inputFile <<
" is not a JSON file." << endl);
173 JSelector selector = getSelector<JPersons>(
JDB::get()->User());
174 ResultSet& rs =
getResultSet(getTable<JPersons>(), selector);
179 if (detID > 0 && runNr > 0) {
181 NOTICE(
"Setting high-voltages corresponding to run " << runNr <<
"..." << endl);
183 JSelector selector = getSelector<JPMTHVRunSettings>(
getDetector(detID), runNr);
184 ResultSet& rs =
getResultSet(getTable<JPMTHVRunSettings>(), selector);
186 for (JPMTHVRunSettings table; rs >> table; ) {
188 JHVCalibration::iterator cal = find_if(toEdit.begin(), toEdit.end(),
190 if (cal != toEdit.end()) {
192 cal->supplyVoltage = table.HV_VALUE;
199 }
else if (detID > 0) {
201 NOTICE(
"Setting vendor high-voltages..." << endl);
203 JSelector selector = getSelector<JVendorHV>(detID);
204 ResultSet& rs =
getResultSet(getTable<JVendorHV>(), selector);
206 for (JVendorHV table; rs >> table; ) {
208 JHVCalibration::iterator cal = find_if(toEdit.begin(), toEdit.end(),
210 if (cal != toEdit.end()) {
212 cal->supplyVoltage = table.PMT_SUPPLY_VOLTAGE;
221 NOTICE(
"Setting high-voltages manually..." << endl);
223 for (JHVCalibration::iterator cal = toEdit.begin(); cal != toEdit.end(); ++cal) {
225 NOTICE(
"Please specify high-voltage for " <<
RIGHT(30) << cal->getUPI() <<
":" << endl);
230 if (manualHV > minHV && manualHV < maxHV) {
232 cal->supplyVoltage = manualHV;
237 WARNING(
"Specified high-voltage is not within range [" << minHV <<
", " << maxHV <<
"]; skip.");
244 }
catch (
const exception& error) {
246 FATAL(error.what() << endl);
251 js[
User_t] = person.LOGIN;
260 ofs << setw(2) << setprecision(8);
Utility class to parse command line options.
JPredicate< JResult_t T::*, JComparison::eq > make_predicate(JResult_t T::*member, const JResult_t value)
Helper method to create predicate for data member.
#define gmake_property(A)
macro to convert (template) parameter to JPropertiesElement object
static const std::string Tests_t
static const std::string OK_t
Utility class to parse parameter values.
T get(const JHead &header)
Get object from header.
static const std::string Location_t
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Utility class to parse parameter values.
JDetectorsHelper getDetector
Function object for mapping serial number to object identifier of detector and vice versa...
I/O formatting auxiliaries.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
std::vector< JHVCalibration_t > JHVCalibration
PMT high voltage calibration.
static const std::string Test_t
General purpose messaging.
static const std::string EndTime_t
Utility class to parse command line options.
static const std::string Type_t
ResultSet & getResultSet(const std::string &query)
Get result set.
static const std::string StartTime_t
static const std::string User_t
Detector calibration key words for JSON I/O.
KM3NeT DAQ constants, bit handling, etc.
Specifications of file name extensions.
bool isJSONFile(const char *file_name)
Check file format.
int main(int argc, char *argv[])