194 typedef JHVTable::JHVTableTypes JHVTableType_t;
207 double minHV = -1500;
208 double maxHV = - 800;
225 JParser<> zap(
"Auxiliary program to treat failed high-voltage tuning results.");
227 zap[
'f'] =
make_field(inputFile,
"input file");
237 }
catch(
const exception &error) {
239 FATAL(error.what() << endl);
242 if (login.empty() || locationID.empty()) {
243 FATAL(
"Missing user information (please specify via -#login and -#locationID).");
247 const JUUID& UUID = JUUID::rndm();
251 timer.sub(elapsedTime);
256 JDBAPIVersion DBAPIVersion;
258 string metaInfoStr =
MAKE_STRING(JMeta(argc, argv));
266 ifstream ifs(inputFile.c_str());
275 if (i0 != js.cend()) {
277 istringstream iss(i0->get<
string>());
284 json::const_iterator i1 = js.find(
Data_t);
286 if ((DBAPIVersion.getMajorVersion() == 2) &&
287 (i1 != js.cend() && i1->size() > 0)) {
289 DBTestType = (*i1)[0].at(
Test_t +
Type_t).get<
string>();
307 if (pmtSet.empty()) {
309 for (JHVCalibration::iterator it = HVcals.begin(); it != HVcals.end(); ++it) {
311 if (it->result !=
OK_t) {
312 toEdit.push_back(*it);
320 JHVCalibration::iterator pmt = find_if(HVcals.begin(), HVcals.end(),
322 if (pmt != HVcals.end()) {
324 if (pmt->result ==
OK_t) {
325 WARNING(
"Editing " <<
OK_t <<
" result for " << pmt->getUPI() << endl);
328 toEdit.push_back(*pmt);
335 ERROR(inputFile <<
" is not a JSON file." << endl);
339 if (!HVtable.second.empty()) {
341 NOTICE(
"Setting " << (HVtable.first == JHVTableType_t::VENDOR_HV ?
"vendor " :
"run-specific ") <<
342 "PMT high-voltages from file " << HVtable.second <<
"..." << endl);
344 JHVTable getHV(HVtable.second.c_str(), HVtable.first);
346 for (JHVCalibration::iterator i = toEdit.begin(); i != toEdit.end(); ++i) {
348 const JUPI_t& upi = i->getUPI();
349 const double HV = getHV(upi.getNumber());
351 if (HV > minHV && HV < maxHV) {
353 i->supplyVoltage = getHV(upi.getNumber());
358 WARNING(
"Invalid high-voltage for PMT " << upi <<
" (" <<
FIXED(7,1) << HV <<
359 " not within [ " <<
FIXED(7,1) << minHV <<
", " <<
FIXED(7,1) << maxHV <<
"]); skip." << endl);
365 NOTICE(
"Setting high-voltages manually..." << endl);
367 for (JHVCalibration::iterator i = toEdit.begin(); i != toEdit.end(); ++i) {
369 NOTICE(
"Please specify high-voltage for " <<
RIGHT(30) << i->getUPI() <<
":" << endl);
374 while (manualHV < minHV || manualHV > maxHV) {
376 WARNING(
"Specified high-voltage is not within range [" <<
377 FIXED(7,1) << minHV <<
", " <<
FIXED(7,1) << maxHV <<
378 "]; Please specify again." << endl);
383 i->supplyVoltage = manualHV;
391 if (DBAPIVersion.getMajorVersion() == 2) {
412 js[
Start_t] = timer.toString();
413 js[
End_t] = timer().toString();
429 ofs << setw(2) << setprecision(8);
static JDBTestTypesTuneHV & getDBVersionTuneHV
Function object for looking up the HV-tuning database version number corresponding to a specific test...
static const std::string Arguments_t
Utility class to parse command line options.
static const std::string Start_t
JPredicate< JResult_t T::*, JComparison::eq > make_predicate(JResult_t T::*member, const JResult_t value)
Helper method to create predicate for data member.
static const std::string Location_t
static const std::string Code_t
static const std::string Encoding_t
#define gmake_property(A)
macro to convert (template) parameter to JPropertiesElement object
static const std::string Error_t
Utility class to parse parameter values.
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Auxiliary data structure for floating point format specification.
#define MAKE_STRING(A)
Make string.
static const std::string Time_t
static const std::string APIVersion_t
static const std::string Configuration_t
static const std::string Test_t
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
std::vector< JHVCalibration_t > JHVCalibration
PMT high voltage calibration.
static const std::string End_t
static const std::string Info_t
static const std::string Message_t
static const std::string Data_t
static const std::string Type_t
static const std::string Provenance_t
static const std::string UUID_t
static const std::string Tests_t
bool isJSONFile(const char *file_name)
Check file format.
static const std::string OK_t
static const std::string User_t