47  inline double getDelayTime(
const JUPI_t& upi)
 
   64  static const char* 
const NOPIEZO = 
"NOPIEZO";  
 
   74int main(
int argc, 
char **argv)
 
   95    JParser<> zap(
"Auxiliary program to download or update detector from database.");
 
  101    zap[
'D'] = 
make_field(
id,            
"detector identifier")                                        = 
"";
 
  102    zap[
'r'] = 
make_field(run,           
"run number")                                                 = -1;
 
  103    zap[
'@'] = 
make_field(calset,        
"calibration sets \"<key> = <value>[; <key> = <value>]\""    << endl
 
  111    zap[
'W'] = 
make_field(wizzard,       
"-W add base modules; -WW set time offsets of acoustic sensors");
 
  117  catch(
const exception &error) {
 
  118    FATAL(error.what() << endl);
 
  124  for (vector<JEquation_t>::const_iterator i = calset.begin(); i != calset.end(); ++i) {
 
  127      FATAL(
"Invalid calibration set \"" << i->getKey() << 
"\"" << endl);
 
  135    FATAL(
"Inconsistent specificaton of calibration sets, either {}, {t,p,r}cal or {t,p,r,a,c,s}cal.");
 
  138  const bool file   = (detectorFile != 
"");
 
  151  const bool daq    = (run != -1);
 
  153  if (file   && 
id      != 
"") { 
FATAL(
"Inconsistent specificaton of detector file and detector identifier."); }
 
  154  if (file   && tpr)           { 
FATAL(
"Inconsistent specificaton of detector file and {t,p,r}cal calibration sets."); }
 
  155  if (file   && tpracs)        { 
FATAL(
"Inconsistent specificaton of detector file and {t,p,r,a,c,s}cal calibration sets."); }
 
  156  if (file   && daq)           { 
FATAL(
"Inconsistent specificaton of detector file and run number."); }
 
  158  if (tpr    && 
id      == 
"") { 
FATAL(
"Inconsistent specificaton of {t,p,r}cal calibration sets and no detector identifier."); }
 
  159  if (tpr    && variant != 
"") { 
FATAL(
"Inconsistent specificaton of {t,p,r}cal calibration sets and variant."); }
 
  160  if (tpr    && daq)           { 
FATAL(
"Inconsistent specificaton of {t,p,r}cal calibration sets and run number."); }
 
  162  if (tpracs && 
id      == 
"") { 
FATAL(
"Inconsistent specificaton of {t,p,r,a,c,s}cal calibration sets and no detector identifier."); }
 
  163  if (tpracs && variant == 
"") { 
FATAL(
"Inconsistent specificaton of {t,p,r,a,c,s}cal calibration sets and no variant."); }
 
  164  if (tpracs && daq)           { 
FATAL(
"Inconsistent specificaton of {t,p,r,a,c,s}cal calibration sets and run number."); }
 
  166  if (daq    && 
id      == 
"") { 
FATAL(
"Inconsistent specificaton of run number and no detector identifier."); }
 
  171    FATAL(
"Inconsistent detector variant and option -W.");
 
  175    JDB::reset(usr, pwd, cookie);
 
  177  catch(
const exception& error) {
 
  178    FATAL(error.what() << endl);
 
  188      *(JDB::get()->DetX)(
id.c_str(), 
 
  193      *(JDB::get()->DetX)(
id.c_str(),
 
  201    else if (daq && variant == 
"")
 
  202      *(JDB::get()->DetX)(
id.c_str(), run)                              >>  
detector;
 
  203    else if (daq && variant != 
"")
 
  206      FATAL(
"Invalid options.");
 
  208  catch(
const exception& error) {
 
  209    FATAL(error.what() << endl);
 
  215  if (
detector.setToLatestVersion()) {
 
  216    NOTICE(
"Set detector version to " << 
detector.getVersion() << endl);
 
  236    catch(
const exception& error) {
 
  237      FATAL(error.what() << endl);
 
  242    for (JDetector::const_iterator module = 
detector.begin(); module != 
detector.end(); ++module) {
 
  243      zmap[module->getString()][module->getFloor()] = 
module->getPosition();
 
  246    for (vector<JCLBMap>::const_iterator i = clbmap.begin(); i != clbmap.end(); ++i) {
 
  248      if (i->FLOORID == 0) {
 
  254          if (zmap[i->DUID].count(1) != 0) {
 
  258            module.setPosition(JPosition3D(zmap[i->DUID][1].getX(),
 
  259                                           zmap[i->DUID][1].getY(),
 
  260                                           isARCADetector(detector) ? ARCA_TBARZ_M :
 
  261                                           isORCADetector(detector) ? ORCA_TBARZ_M :
 
  264            NOTICE(
"Adding module " << module << endl);
 
  270            ERROR(
"Missing floor in string " << 
FILL(4,
'0') << i->DUID << 
FILL() << endl);
 
  273        } 
else if (zmap[i->DUID].count(1) != 0) {
 
  275          if (fabs(p->getX() - zmap[i->DUID][1].getX()) > precision ||
 
  276              fabs(p->getY() - zmap[i->DUID][1].getY()) > precision) {
 
  278            NOTICE(
"Offset module " << 
getLabel(p->getLocation()) << 
" (x,y) position "  
  279                   << 
SCIENTIFIC(12,3) << (p->getX() - zmap[i->DUID][1].getX()) << 
' '  
  280                   << 
SCIENTIFIC(12,3) << (p->getY() - zmap[i->DUID][1].getY()) << endl);
 
  282            p->setPosition(
JPosition3D(zmap[i->DUID][1].getX(),
 
  283                                       zmap[i->DUID][1].getY(),
 
  289          FATAL(
"Missing floor in string " << setw(4) << i->DUID << endl);
 
  303      if (! (rs >> detector_t)) {
 
  319          JDetector::iterator p = find_if(
detector.begin(), 
 
  331              if (t0 != p->getT0()) {
 
  333                NOTICE(
"Set module time calibration " << 
getLabel(p->getLocation()) << 
' ' << setw(10)  << p->getID() << 
' ' << setw(28) << left << i->first << right << 
' ' << 
FIXED(12,3) << t0 << endl);
 
  335                p->setCalibration(t0);
 
  338            catch(
const exception& error) {
 
  339              if (i->first.getVariant() != NOPIEZO) {
 
  340                ERROR(location << 
' ' << error.what() << endl);
 
  346            ERROR(
"No module for UPI " << i->first << 
" at " << location << endl);
 
  351    catch(
const exception& error) {
 
  352      FATAL(error.what() << endl);
 
 
int main(int argc, char **argv)
 
Data structure for detector geometry and calibration.
 
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
 
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.
 
JSon definitions and auxiliaries.
 
Auxiliary methods to convert data members or return values of member methods of a set of objects to a...
 
Auxiliary class for specifying selection of database data.
 
JSelector & add(const JSelector &selection)
Add selection.
 
double getT0() const
Get time offset.
 
Logical location of module.
 
const JLocation & getLocation() const
Get location.
 
Data structure for a composite optical module.
 
Data structure for position in three dimensions.
 
int getID() const
Get identifier.
 
Exception for accessing a value in a collection that is outside of its range.
 
Utility class to parse command line options.
 
static const JPBS_t HYDROPHONE(4, 5)
PBS of hydrophone
 
static const JPBS_t ACOUSTIC_SENSOR(3, 4, 3, 6, 2)
PBS of piezo sensor
 
ResultSet & getResultSet(const std::string &query)
Get result set.
 
static JGetPBSSequences getPBSSequences
Function object to get PBS sequences as a function of PBS.
 
const char * getTable()
Get table name.
 
JDetectorsHelper & getDetector()
Auxiliary function for helper object initialisation.
 
std::vector< JServer > getServernames()
Get list of names of available database servers.
 
static const double PIEZO_V2_DELAYTIME_US
Piezo delay time [us].
 
std::string getLabel(const JLocation &location)
Get module label for monitoring and other applications.
 
static const double PIEZO_V1_DELAYTIME_US
Piezo delay time [us].
 
static const JGetDetectorVersion getDetectorVersion
Function object to map detector version to numerical value.
 
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
 
static const double HYDROPHONE_DELAYTIME_US
Hydrophone delay time [us].
 
void store(const std::string &file_name, const JDetector &detector)
Store detector to output file.
 
static const double PIEZO_V3_DELAYTIME_US
Piezo delay time [us].
 
std::vector< T > getDetectorVersions()
Get detector versions.
 
const array_type< JValue_t > & make_array(const JValue_t(&array)[N])
Method to create array of values.
 
std::iterator_traits< T >::value_type getAverage(T __begin, T __end)
Get average.
 
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
 
static const std::string TCAL
PMT time offsets.
 
static const std::string PCAL
(optical|base) module positions
 
static const std::string SCAL
(module|PMT) status
 
static const std::string RCAL
optical module orientations
 
static const std::string ACAL
acoustic time offsets (piezo sensor or hydrophone)
 
static const std::string CCAL
compass alignment (a.k.a. quaternion calibration)
 
Auxiliary data structure for sequence of same character.
 
Auxiliary data structure for floating point format specification.
 
map_type::const_iterator range_const_iterator
 
void configure(const std::string &detid, const bool option=false)
Configure detector integration for given detector identifier.
 
range_type find(const JUPI_t &upi) const
Find range of products with given UPI.
 
Auxiliary data structure for location of product in detector.
 
int string
position in detector
 
int floor
position in string
 
Product breakdown structure (PBS).
 
const JPBS_t & getPBS() const
Get PBS.
 
Auxiliary class to map UPI to location in detector.
 
JLocation_t getLocation(const JUPI_t &upi) const
Get location of product with given UPI.
 
Wrapper class for server name.
 
Universal product identifier (UPI).
 
const std::string & getVariant() const
Get variant.
 
Template definition for getting table specific selector.
 
@ V4
Version with quaternion and time offset per module.
 
Auxiliary data structure for streaming of STL containers.
 
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
 
std::string nick_name
nick name (e.g. "xcal")
 
Auxiliary data structure for correspondence between nick and full name of calibration types.
 
bool hasNickname(const std::string &type) const
Has calibration type.
 
Auxiliary data structure for floating point format specification.