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);
70 if (
is >> entry.DETID >> entry.DUID >> entry.FLOORID >> entry.CABLEPOS >> entry.PMTSERIAL >> entry.PMT_SUPPLY_VOLTAGE) {
72 if (entry.PMTSERIAL > 0 &&
73 entry.PMT_SUPPLY_VOLTAGE < 0) {
75 HVmap[entry.PMTSERIAL] = entry.PMT_SUPPLY_VOLTAGE;
85 for (
string buffer;
getline(
in, buffer); ) {
87 istringstream
is(buffer);
89 JPMTHVRunSettings entry;
91 if (
is >> entry.DETOID >> entry.DETID >>
92 entry.RUN >> entry.RUNSETUPID >>
93 entry.DUID >> entry.FLOORID >> entry.PMTINTID >> entry.CABLEPOS >> entry.PMTSERIAL >>
94 entry.CG_OID >> entry.HV_INDEX >> entry.HV_VALUE) {
96 if (entry.PMTSERIAL > 0 &&
99 HVmap[entry.PMTSERIAL] = entry.HV_VALUE;
108 THROW(JValueOutOfRange,
"JHVTable::JHVTable(): Invalid HV-table type: " << type);
121 double operator()(
const int serialID)
128 if (p != HVmap.end()) {
131 THROW(JValueOutOfRange,
"Serial number " << serialID <<
" not found.");
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;
164 THROW(JValueOutOfRange,
"operator>>(): Invalid HV-table type: " << type);
176 inline std::ostream&
operator<<(std::ostream& out,
177 JHVTable::JHVTableTypes
object) {
178 return out << int(
object);
190 int main(
int argc,
char **argv)
195 typedef JHVTable::JHVTableTypes JHVTableType_t;
208 double minHV = -1500;
209 double maxHV = - 800;
226 JParser<> zap(
"Auxiliary program to treat failed high-voltage tuning results.");
228 zap[
'f'] =
make_field(inputFile,
"input file");
238 }
catch(
const exception &error) {
240 FATAL(error.what() << endl);
243 if (login.empty() || locationID.empty()) {
244 FATAL(
"Missing user information (please specify via -#login and -#locationID).");
248 const JUUID& UUID = JUUID::rndm();
253 timer->tm_sec -= elapsedTime;
258 JDBAPIVersion DBAPIVersion;
260 string metaInfoStr =
MAKE_STRING(JMeta(argc, argv));
268 ifstream ifs(inputFile.c_str());
277 if (i0 != js.cend()) {
279 istringstream iss(i0->get<
string>());
286 json::const_iterator i1 = js.find(
Data_t);
288 if ((DBAPIVersion.getMajorVersion() == 2) &&
289 (i1 != js.cend() && i1->size() > 0)) {
291 DBTestType = (*i1)[0].at(
Test_t +
Type_t).get<
string>();
309 if (pmtSet.empty()) {
311 for (JHVCalibration::iterator it = HVcals.begin(); it != HVcals.end(); ++it) {
313 if (it->result !=
OK_t) {
314 toEdit.push_back(*it);
322 JHVCalibration::iterator pmt = find_if(HVcals.begin(), HVcals.end(),
324 if (pmt != HVcals.end()) {
326 if (pmt->result ==
OK_t) {
327 WARNING(
"Editing " <<
OK_t <<
" result for " << pmt->getUPI() << endl);
330 toEdit.push_back(*pmt);
337 ERROR(inputFile <<
" is not a JSON file." << endl);
341 if (!HVtable.second.empty()) {
343 NOTICE(
"Setting " << (HVtable.first == JHVTableType_t::VENDOR_HV ?
"vendor " :
"run-specific ") <<
344 "PMT high-voltages from file " << HVtable.second <<
"..." << endl);
346 JHVTable getHV(HVtable.second.c_str(), HVtable.first);
348 for (JHVCalibration::iterator i = toEdit.begin(); i != toEdit.end(); ++i) {
350 const JUPI_t& upi = i->getUPI();
351 const double HV = getHV(upi.getNumber());
353 if (HV > minHV && HV < maxHV) {
355 i->supplyVoltage = getHV(upi.getNumber());
360 WARNING(
"Invalid high-voltage for PMT " << upi <<
" (" <<
FIXED(7,1) << HV <<
361 " not within [ " <<
FIXED(7,1) << minHV <<
", " <<
FIXED(7,1) << maxHV <<
"]); skip." << endl);
367 NOTICE(
"Setting high-voltages manually..." << endl);
369 for (JHVCalibration::iterator i = toEdit.begin(); i != toEdit.end(); ++i) {
371 NOTICE(
"Please specify high-voltage for " <<
RIGHT(30) << i->getUPI() <<
":" << endl);
376 while (manualHV < minHV || manualHV > maxHV) {
378 WARNING(
"Specified high-voltage is not within range [" <<
379 FIXED(7,1) << minHV <<
", " <<
FIXED(7,1) << maxHV <<
380 "]; Please specify again." << endl);
385 i->supplyVoltage = manualHV;
393 if (DBAPIVersion.getMajorVersion() == 2) {
414 js[
Start_t] = timer.toString(format);
415 js[
End_t] = timer().toString(format);
431 ofs << setw(2) << setprecision(8);
static JDBTestTypesTuneHV & getDBVersionTuneHV
Function object for looking up the HV-tuning database version number corresponding to a specific test...
Utility class to parse command line options.
static const std::string UUID_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.
int main(int argc, char *argv[])
static const std::string Time_t
#define gmake_property(A)
macro to convert (template) parameter to JPropertiesElement object
static const std::string Tests_t
static const std::string OK_t
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Utility class to parse parameter values.
static const std::string Location_t
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
JDateAndTimeFormat
Date and time formats.
Auxiliary data structure for floating point format specification.
static const std::string Encoding_t
Utility class to parse parameter values.
#define MAKE_STRING(A)
Make string.
static const std::string Provenance_t
static const std::string Arguments_t
static const std::string Configuration_t
I/O formatting auxiliaries.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
std::vector< JHVCalibration_t > JHVCalibration
PMT high voltage calibration.
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
static const std::string Code_t
static const std::string Test_t
static const std::string Info_t
static const std::string Message_t
General purpose messaging.
std::istream & operator>>(std::istream &in, JAANET::JHead &header)
Read header from input.
Utility class to parse command line options.
static const std::string Type_t
static const std::string APIVersion_t
static const std::string User_t
Detector calibration key words for JSON I/O.
Exception for accessing a value in a collection that is outside of its range.
static const std::string Error_t
KM3NeT DAQ constants, bit handling, etc.
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
static const std::string Data_t
static const std::string End_t
static const std::string Start_t
Specifications of file name extensions.
bool isJSONFile(const char *file_name)
Check file format.