53 JHVTable(
const char*
const filename,
54 const JHVTableTypes type)
59 ifstream in(filename);
64 for (
string buffer;
getline(in, buffer); ) {
66 istringstream is(buffer);
85 for (
string buffer;
getline(in, buffer); ) {
87 istringstream is(buffer);
121 double operator()(
const int serialID)
128 if (p != HVmap.end()) {
147 inline std::istream&
operator>>(std::istream& in,
148 JHVTable::JHVTableTypes&
object) {
157 case int(JHVTable::VENDOR_HV):
158 object = JHVTable::VENDOR_HV;
160 case int(JHVTable::RUN_HV):
161 object = JHVTable::RUN_HV;
176 inline std::ostream&
operator<<(std::ostream& out,
177 JHVTable::JHVTableTypes
object) {
178 return out << int(
object);
189 int main(
int argc,
char **argv)
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);
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);
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) {
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;
429 ofs << setw(2) << setprecision(8);
KM3NeT DAQ constants, bit handling, etc.
int main(int argc, char **argv)
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Specifications of file name extensions.
std::istream & operator>>(std::istream &in, JAANET::JHead &header)
Read header from input.
General purpose messaging.
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
I/O formatting auxiliaries.
#define MAKE_STRING(A)
Make string.
Utility class to parse parameter values.
#define gmake_property(A)
macros to convert (template) parameter to JPropertiesElement object
Utility class to parse parameter values.
Exception for accessing a value in a collection that is outside of its range.
Utility class to parse command line options.
static JDBTestTypesTuneHV & getDBVersionTuneHV
Function object for looking up the HV-tuning database version number corresponding to a specific test...
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
JPredicate< JResult_t T::*, JComparison::eq > make_predicate(JResult_t T::*member, const JResult_t value)
Helper method to create predicate for data member.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
static const std::string Tests_t
static const std::string APIVersion_t
static const std::string User_t
static const std::string Encoding_t
static const std::string Message_t
static const std::string UUID_t
static const std::string Code_t
static const std::string Location_t
static const std::string Time_t
static const std::string Data_t
static const std::string Test_t
static const std::string OK_t
static const std::string Arguments_t
static const std::string Configuration_t
static const std::string End_t
static const std::string Provenance_t
static const std::string Info_t
static const std::string Error_t
static const std::string Type_t
static const std::string Start_t
bool isJSONFile(const char *file_name)
Check file format.
Auxiliary data structure for floating point format specification.
Universal product identifier (UPI).
const JUPI_t & getUPI() const
Get UPI.
int getNumber() const
Get serial number.
double PMT_SUPPLY_VOLTAGE
Auxiliary data structure for general purpose version number.
version_type getMajorVersion() const
Get major version.
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Auxiliary class for date and time.
std::string toString() const
Get ASCII formatted date and time.
void sub(const time_t t1)
Subtract given time.