40{
   44  
   45  string inputFile;
   46  string detectorFile;
   48 
   49  string login;
   50  string locationID;
   51  int    elapsedTime = 0;  
   52  
   54 
   55  try {
   56 
   58 
   62 
   63    JParser<> zap(
"Auxiliary program to print high-voltage tuning results.");
 
   64    
   65    zap[
'f'] = 
make_field(inputFile,    
"input file (JSON output of JTuneHV)");
 
   66    zap[
'a'] = 
make_field(detectorFile, 
"detector file");    
 
   67    zap[
'o'] = 
make_field(
outputFile,   
"output file (for writing failed evaluations to separate JSON output)") = 
"";
 
   70 
   71    zap(argc, argv);
   72    
   73  } catch(const exception &error) {
   74    
   75    FATAL(error.what() << endl);
 
   76  }
   77 
   78  if (!
outputFile.empty() && (login.empty() || locationID.empty())) {
 
   79    
   80    FATAL(
"Missing user information (please specify via -#login and -#locationID).");
 
   81  }
   82 
   83  
   84  const JUUID& UUID = JUUID::rndm();
 
   85  
   87 
   88  timer.
sub(elapsedTime);
 
   89  
   91 
   92  try {
   94  }
   95  catch (const exception& error) {
   96    FATAL(error.what() << endl);
 
   97  }
   98 
  100  
  101 
  103  string        DBTestType;
  105  
  106  size_t        Ntotal = 0;
  107  
  109  
  111    
  113    
  114    ifstream ifs(inputFile.c_str());
  115    
  116    ifs >> js;
  117    ifs.close();
  118 
  119    
  120    
  121    json::const_iterator i0 = js.find(APIVersion_t);
  122 
  123    if (i0 != js.cend()) {
  124      
  125      istringstream iss(i0->get<string>());
  126      
  127      iss >> DBAPIVersion;
  128    }
  129 
  131    
  132    json::const_iterator i1 = js.find(Data_t);
  133    
  135        (i1 != js.cend() && i1->size() > 0)) {
  136 
  137      DBTestType   = (*i1)[0].at(Test_t + Type_t).get<string>();
  138 
  139      JHVCalibration_t::setVersion(getDBVersionTuneHV(DBTestType));
  140      
  142      metaInfoStr += (*i1)[0].at(Provenance_t + Info_t).at(Configuration_t).get<string>();
  143      
  144    } else {
  145 
  146      DBTestType   = js.at(Test_t + Type_t).get<string>();
  147 
  148      JHVCalibration_t::setVersion(getDBVersionTuneHV(DBTestType));      
  149      
  151    }
  152    
  153    
  155           RIGHT(20) << 
"HV"   << 
RIGHT (10)  << 
"gain" << 
RIGHT(10) << 
"status" << endl);
 
  156    
  157    for (JHVCalibration::const_iterator it = HVcals.cbegin(); it != HVcals.cend(); ++it) {
  158 
  162 
  164 
  165      if (it->result != OK_t) {
  167      }
  168 
  169      NOTICE(
LEFT (30) << pmtUPI << 
"(a.k.a. " << pmtID << 
" / " << location << 
"):" <<
 
  170             FIXED(20,1) << it->supplyVoltage << 
RIGHT(10) << it->result << endl);
 
  171 
  172      ++Ntotal;
  173    }
  174 
  175  } else {
  176 
  177    ERROR(inputFile << 
" is not a JSON file." << endl);
 
  178  }
  179 
  180 
  181  size_t Nfailed  = 0;
  182  size_t Nmissing = 0;
  183 
  185  
  186  NOTICE(endl << 
FILL(105, 
'-') << 
" List of failures" << setfill(
' ') << endl);
 
  187  
  189 
  190    Nfailed += i->second.size();
  191    
  192    if (i->second.size() == NUMBER_OF_PMTS) {
  193      
  194      Nmissing += NUMBER_OF_PMTS;
  195      WARNING(
"No successful calibrations found for module " << i->first << 
" (dead module?)" << endl);
 
  196      
  197    } else {
  198 
  199      for (JHVCalibration::const_iterator j = i->second.cbegin(); j != i->second.cend(); ++j) {
  200        
  201        const JUPI_t&         pmtUPI = 
j->getUPI();
 
  204        
  206        
  207        NOTICE(
LEFT(30) << pmtUPI << 
"(a.k.a. " << pmtID << 
" / " << location << 
"):" <<
 
  208               right << 
FIXED(20,1) << 
j->supplyVoltage << 
RIGHT(10) << 
j->result << endl);
 
  209        
  210        failures.push_back(*j);
  211      }
  212    }
  213  }
  214  
  215  NOTICE(endl << 
FILL(105, 
'-') << 
" SUMMARY" << setfill(
' ') << endl);
 
  216  NOTICE(
LEFT(40)  << 
"Number of evaluated PMTs:" << 
RIGHT(20) << Ntotal << endl);
 
  217  NOTICE(
LEFT(40)  << 
"Number of successful evaluations:" << 
RIGHT(20) << Ntotal - Nfailed << endl);
 
  218  NOTICE(
LEFT(40)  << 
"Number of failed evaluations:" << 
RIGHT(20) << Nfailed << endl);
 
  219  NOTICE(
RIGHT(20) << 
'-' << 
LEFT(20) << 
" in missing modules:" << 
RIGHT(20) << Nmissing << endl);
 
  220  NOTICE(
RIGHT(20) << 
'-' << 
LEFT(20) << 
" other:" << 
RIGHT(20) << Nfailed - Nmissing << endl << endl);
 
  221 
  222  
  224 
  226 
  228    
  229      json error           = { {Message_t,              
""                      },
 
  230                               {Code_t,                 OK_t                    },
  231                               {Arguments_t,            json::array()           } };
  232    
  233      json metaData        = { {Configuration_t,        metaInfoStr             },
 
  235    
  237                               {User_t,                 login                   },
  238                               {Location_t,             locationID              },
  239                               {Start_t + Time_t,       timer.
toString()        },
 
  240                               {End_t   + Time_t,       timer().
toString()      },
 
  241                               {Test_t  + Type_t,       DBTestType              },
  242                               {Tests_t,                
json(failures)          } };
 
  243      
  245      js[Data_t + Type_t]  = 
MAKE_STRING(
"ProductTestSession");
 
  247      js[Error_t]          = 
json(error);
 
  250      js[Data_t][0]        = 
json(data);
 
  251    
  252    } else {
  253 
  254      js[User_t]           = login;
  255      js[Location_t]       = locationID;
  256      js[Test_t + Type_t]  = DBTestType;
  257      js[Start_t + Time_t] = timer.
toString();
 
  258      js[End_t + Time_t]   = timer().
toString();
 
  259      js[Tests_t]          = 
json(failures);
 
  260    }
  261    
  263 
  264    ofs << setw(2) << setprecision(8);
  265    ofs << js;
  266 
  267    ofs.close();
  268  }
  269 
  270  return 0;
  271}
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
 
#define MAKE_STRING(A)
Make string.
 
#define gmake_property(A)
macros to convert (template) parameter to JPropertiesElement object
 
int getFloor() const
Get floor number.
 
int getString() const
Get string number.
 
Data structure for a composite optical module.
 
int getModuleID() const
Get module identifier.
 
int getTDC() const
Get TDC.
 
Router for direct addressing of PMT data in detector data structure.
 
Utility class to parse parameter values.
 
Utility class to parse command line options.
 
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
 
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
 
bool isJSONFile(const char *file_name)
Check file format.
 
KM3NeT DAQ data structures and auxiliaries.
 
Auxiliary data structure for alignment of data.
 
Auxiliary data structure for sequence of same character.
 
Auxiliary data structure for floating point format specification.
 
Auxiliary data structure for location of product in detector.
 
Universal product identifier (UPI).
 
const JUPI_t & getUPI() const
Get UPI.
 
int getNumber() const
Get serial number.
 
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.
 
Auxiliary data structure for alignment of data.
 
Auxiliary data structure for alignment of data.