75{
78
80 string usr;
83 string id;
87 int run;
88 string variant;
90 double precision;
92
93 try {
94
95 JParser<> zap(
"Auxiliary program to download or update detector from database.");
96
111 zap[
'W'] =
make_field(
wizzard,
"-W add base modules; -WW set time offsets of acoustic sensors");
114
116 }
117 catch(const exception &error) {
119 }
120
121
123
125
127 FATAL(
"Invalid calibration set \"" << i->getKey() <<
"\"" <<
endl);
128 else
130 }
131
135 FATAL(
"Inconsistent specificaton of calibration sets, either {}, {t,p,r}cal or {t,p,r,a,c,s}cal.");
136 }
137
151 const bool daq = (run != -1);
152
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."); }
157
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."); }
161
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."); }
165
166 if (daq &&
id ==
"") {
FATAL(
"Inconsistent specificaton of run number and no detector identifier."); }
167
169 variant != "" &&
171 FATAL(
"Inconsistent detector variant and option -W.");
172 }
173
174 try {
176 }
177 catch(const exception& error) {
179 }
180
182
183 try {
184
185 if (file)
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 != "")
205 else
206 FATAL(
"Invalid options.");
207 }
208 catch(const exception& error) {
210 }
211
212
214
215 if (
detector.setToLatestVersion()) {
217 }
218
219
221
223
224 try {
225
227
229
231
233
234 rs.Close();
235 }
236 catch(const exception& error) {
238 }
239
241
243 zmap[module->getString()][module->getFloor()] = module->getPosition();
244 }
245
247
248 if (i->FLOORID == 0) {
249
251
253
254 if (zmap[i->DUID].count(1) != 0) {
255
257
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 :
262 0.0));
263
265
267
268 } else {
269
271 }
272
273 } else if (zmap[i->DUID].count(1) != 0) {
274
275 if (fabs(p->getX() - zmap[i->DUID][1].getX()) > precision ||
276 fabs(p->getY() - zmap[i->DUID][1].getY()) > precision) {
277
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);
281
282 p->setPosition(
JPosition3D(zmap[i->DUID][1].getX(),
283 zmap[i->DUID][1].getY(),
284 p->getZ()));
285 }
286
287 } else {
288
289 ERROR(
"Missing floor in string " <<
setw(4) << i->DUID <<
endl);
290 }
291 }
292 }
293 }
294
296
297 try {
298
300
302
305 }
306
308
310
312
314
316
317 const JLocation_t location = router.getLocation(i->first);
318
324
326
327 try {
328
330
331 if (t0 != p->getT0()) {
332
333 NOTICE(
"Set module time calibration " <<
getLabel(p->getLocation()) <<
' ' <<
setw(10) << p->getID() <<
' ' <<
setw(28) << left << i->first << right <<
' ' <<
FIXED(12,3) << t0 <<
endl);
334
335 p->setCalibration(t0);
336 }
337 }
338 catch(const exception& error) {
339 if (i->first.getVariant() !=
NOPIEZO) {
340 ERROR(location <<
' ' << error.what() <<
endl);
341 }
342 }
343
344 } else {
345
346 ERROR(
"No module for UPI " << i->first <<
" at " << location <<
endl);
347 }
348 }
349 }
350 }
351 catch(const exception& error) {
353 }
354 }
355
358 else
360}
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
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.
Template definition of a multi-dimensional oscillation probability interpolation table.
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.
JDetectorsHelper & getDetector()
Auxiliary function for helper object initialisation.
std::vector< JServer > getServernames()
Get list of names of available database servers.
std::string getLabel(const JLocation &location)
Get module label for monitoring and other applications.
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.
void store(const std::string &file_name, const JDetector &detector)
Store detector to output file.
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
Auxiliary data structure for location of product in detector.
int string
position in detector
int floor
position in string
Product breakdown structure (PBS).
Auxiliary class to map UPI to location in detector.
Wrapper class for server name.
@ V4
Version with quaternion and time offset per module.
Auxiliary data structure for streaming of STL containers.
Functional implementations of comparison operators.
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.