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
106 &JCalibrationType::nick_name) << endl
110 zap[
'V'] =
make_field(variant,
"detector version") = getDetectorVersions<string>(),
"";
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);
127 FATAL(
"Invalid calibration set \"" <<
i->getKey() <<
"\"" << endl);
132 if (calibration.size() != 0
u &&
133 calibration.size() != 3
u &&
134 calibration.size() != 6
u) {
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 !=
"");
139 const bool tpr = (calibration.count(
TCAL) != 0 &&
140 calibration.count(
PCAL) != 0 &&
141 calibration.count(
RCAL) != 0 &&
142 calibration.count(
ACAL) == 0 &&
143 calibration.count(
CCAL) == 0 &&
144 calibration.count(
SCAL) == 0);
145 const bool tpracs = (calibration.count(
TCAL) != 0 &&
146 calibration.count(
PCAL) != 0 &&
147 calibration.count(
RCAL) != 0 &&
148 calibration.count(
ACAL) != 0 &&
149 calibration.count(
CCAL) != 0 &&
150 calibration.count(
SCAL) != 0);
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.");
177 catch(
const exception& error) {
178 FATAL(error.what() << endl);
188 *(JDB::get()->DetX)(
id.c_str(),
189 calibration[
TCAL] !=
"?" ? calibration[
TCAL].c_str() : NULL,
190 calibration[
PCAL] !=
"?" ? calibration[
PCAL].c_str() : NULL,
193 *(JDB::get()->DetX)(
id.c_str(),
194 calibration[
TCAL] !=
"?" ? calibration[
TCAL].c_str() : NULL,
195 calibration[
PCAL] !=
"?" ? calibration[
PCAL].c_str() : NULL,
196 calibration[
RCAL] !=
"?" ? calibration[
RCAL].c_str() : NULL,
197 calibration[
ACAL] !=
"?" ? calibration[
ACAL].c_str() : NULL,
198 calibration[
CCAL] !=
"?" ? calibration[
CCAL].c_str() : NULL,
199 calibration[
SCAL] !=
"?" ? calibration[
SCAL].c_str() : NULL,
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);
228 selector.
add(&JCLBMap::FLOORID, 0);
230 ResultSet& rs =
getResultSet(getTable<JCLBMap>(), selector);
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();
248 if (
i->FLOORID == 0) {
254 if (zmap[
i->DUID].count(1) != 0) {
259 zmap[
i->DUID][1].getY(),
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);
283 zmap[
i->DUID][1].getY(),
289 FATAL(
"Missing floor in string " << setw(4) <<
i->DUID << endl);
301 ResultSet& rs =
getResultSet(getTable<JDetectorIntegration_t>());
303 if (! (rs >> detector_t)) {
317 const JLocation_t location = router.getLocation(
i->first);
319 JDetector::iterator p = find_if(
detector.begin(),
329 const double t0 =
getAverage(
make_array(p->begin(), p->end(), &JPMT::getT0), 0.0) - getDelayTime(
i->first);
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);
bool isORCADetector(const JDetectorHeader &header)
Check if given detector header is compatible with that of ORCA.
bool hasNickname(const std::string &type) const
Has calibration type.
Utility class to parse command line options.
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 JGetPBSSequences getPBSSequences
Function object to get PBS sequences as a function of PBS.
Data structure for a composite optical module.
static const double ARCA_TBARZ_M
ORCA T-bar position relative to seabed [m].
bool isARCADetector(const JDetectorHeader &header)
Check if given detector header is compatible with tat of ARCA.
then usage $script[< detector identifier >< run range >]< QA/QCfile > nExample script to produce data quality plots nWhen a detector identifier and run range are data are downloaded from the database nand subsequently stored in the given QA QC file
static const std::string ACAL
acoustic time offsets (piezo sensor or hydrophone)
std::string getLabel(const JLocation &location)
Get module label for monitoring and other applications.
static const std::string CCAL
compass alignment (a.k.a. quaternion calibration)
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
std::iterator_traits< T >::value_type getAverage(T __begin, T __end)
Get average.
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Auxiliary data structure for correspondence between nick and full name of calibration types...
Auxiliary data structure for floating point format specification.
Auxiliary class for specifying selection of database data.
JDetectorsHelper & getDetector()
Auxiliary function for helper object initialisation.
static const JPBS_t ACOUSTIC_SENSOR(3, 4, 3, 6, 2)
PBS of piezo sensor
static const double ORCA_TBARZ_M
ORCA T-bar position relative to seabed [m].
static const std::string TCAL
PMT time offsets.
int floor
position in string
map_type::const_iterator range_const_iterator
Logical location of module.
Auxiliary data structure for location of product in detector.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
JSelector & add(const JSelector &selection)
Add selection.
const array_type< JValue_t > & make_array(const JValue_t(&array)[N])
Method to create array of values.
void store(const std::string &file_name, const JDetector &detector)
Store detector to output file.
range_type find(const JUPI_t &upi) const
Find range of products with given UPI.
Auxiliary data structure for streaming of STL containers.
Auxiliary class to map UPI to location in detector.
static const std::string RCAL
optical module orientations
Auxiliary data structure for sequence of same character.
static const JGetDetectorVersion getDetectorVersion
Function object to map detector version to numerical value.
z range($ZMAX-$ZMIN)< $MINIMAL_DZ." fi fi typeset -Z 4 STRING typeset -Z 2 FLOOR JPlot1D -f $
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
static const std::string SCAL
(module|PMT) status
static const JPBS_t HYDROPHONE(4, 5)
PBS of hydrophone
ResultSet & getResultSet(const std::string &query)
Get result set.
std::vector< JServer > getServernames()
Get list of names of available database servers.
void configure(const std::string &detid, const bool option=false)
Configure detector integration for given detector identifier.
Wrapper class for server name.
Product breakdown structure (PBS).
Data structure for position in three dimensions.
do set_variable DETECTOR_TXT $WORKDIR detector
static const std::string PCAL
(optical|base) module positions
Auxiliary data structure for floating point format specification.
int string
position in detector
Template definition for getting table specific selector.