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);
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);
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
int main(int argc, char *argv[])
static const std::string Code_t
static const std::string Encoding_t
#define gmake_property(A)
macros to convert (template) parameter to JPropertiesElement object
JEEP::JVersion JDBAPIVersion
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
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.
Utility class to parse parameter values.
#define MAKE_STRING(A)
Make string.
static const std::string Time_t
static const std::string APIVersion_t
I/O formatting auxiliaries.
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.
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
static const std::string End_t
static const std::string Info_t
General purpose messaging.
static const std::string Message_t
std::istream & operator>>(std::istream &in, JAANET::JHead &header)
Read header from input.
static const std::string Data_t
Utility class to parse command line options.
static const std::string Type_t
Exception for accessing a value in a collection that is outside of its range.
static const std::string Provenance_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 UUID_t
Specifications of file name extensions.
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