62{
65
66 string detectorFile;
70
71 try {
72
73 JParser<> zap(
"Auxiliary program to compose detector from separate calibrations.");
74
75 zap[
'a'] =
make_field(detectorFile,
"detector file");
76 zap[
'f'] =
make_field(inputFile,
"detector calibration files in JSON format "\
77 "(wild card \'" <<
FILENAME_WILDCARD <<
"\' will be replaced by corresponding calibration set)");
80
81 zap(argc, argv);
82 }
83 catch(const exception &error) {
84 FATAL(error.what() << endl);
85 }
86
87
89
90 try {
92 }
95 }
96
98 FATAL(
"No detector address map for detector identier " <<
detector.getID() << endl);
99 }
100
102
105
107
108
109 enum {
111 DEFINED = 1
112 };
113
114 struct status_type {
115
116 status_type() :
118 {}
119
120 operator int() const { return value; }
121
122 status_type& operator=(const int value)
123 {
124 this->value = value;
125
126 return *this;
127 }
128
129 int value;
130 };
131
133
134 map_type tcal;
135 map_type pcal;
136 map_type rcal;
137 map_type acal;
138 map_type ccal;
139 map_type scal[2];
140
141
142 for (const auto& file_name : inputFile) {
143
145
153 else
154 buffer = { file_name };
155
156 for (const auto& file_name : buffer) {
157
158 const JSon js(file_name);
159
160 json::const_iterator
data;
161
163
165
166 for (
size_t i = 0; i !=
data->size(); ++i) {
167
169
173 }
174 }
175
177
179
180 if (pmtRouter.hasPMT(element.getID())) {
181
182 JPMT& pmt =
detector.getPMT(pmtRouter.getAddress(element.getID()));
183
185
186 tcal[pmt.
getID()] = DEFINED;
187 }
188 }
189 }
190
192
194
195 if (moduleRouter.hasModule(element.getID())) {
196
197 JModule& module =
detector.getModule(moduleRouter.getAddress(element.getID()));
198
199 module.set(element.getPosition());
200
201 pcal[module.
getID()] = DEFINED;
202 }
203 }
204 }
205
207
209
210 if (moduleRouter.hasModule(element.getID())) {
211
212 JModule& module =
detector.getModule(moduleRouter.getAddress(element.getID()));
213
214 module.set(element.getPosition());
215
216 pcal[module.
getID()] = DEFINED;
217 }
218 }
219 }
220
222
224
225 if (moduleRouter.hasModule(element.getID())) {
226
227 JModule& module =
detector.getModule(moduleRouter.getAddress(element.getID()));
228
230
231 if (module.size() != buffer.size()) {
232 FATAL(
"Module size " << module.size() <<
" != " << buffer.size() << endl);
233 }
234
236
237 for (size_t i = 0; i != module.size(); ++i) {
238 module.getPMT(i).setAxis(buffer.getPMT(i).getAxis());
239 }
240
241 module.rotate(element.getQuaternion());
242
243 module.setPosition(module.getCenter());
244 module.set(center);
245
246 rcal[module.
getID()] = DEFINED;
247 }
248 }
249 }
250
252
254
255 if (moduleRouter.hasModule(element.getID())) {
256
257 JModule& module =
detector.getModule(moduleRouter.getAddress(element.getID()));
258
259 module.setCalibration(element.getCalibration());
260
261 acal[module.
getID()] = DEFINED;
262 }
263 }
264 }
265
267
269
270 if (moduleRouter.hasModule(element.getID())) {
271
272 JModule& module =
detector.getModule(moduleRouter.getAddress(element.getID()));
273
274 module.setCalibration(element.getCalibration());
275
276 acal[module.
getID()] = DEFINED;
277 }
278 }
279 }
280
282
284
285 if (moduleRouter.hasModule(element.getID())) {
286
287 JModule& module =
detector.getModule(moduleRouter.getAddress(element.getID()));
288
289 module.setQuaternion(element.getQuaternion());
290
291 ccal[module.
getID()] = DEFINED;
292 }
293 }
294 }
295
297
299
300 if (moduleRouter.hasModule(element.getID())) {
301
302 JModule& module =
detector.getModule(moduleRouter.getAddress(element.getID()));
303
304 module.setQuaternion(element.getQuaternion());
305
306 ccal[module.
getID()] = DEFINED;
307 }
308 }
309 }
310
312
314
315 if (pmtRouter.hasPMT(element.getID())) {
316
317 JPMT& pmt =
detector.getPMT(pmtRouter.getAddress(element.getID()));
318
320
321 scal[0][pmt.
getID()] = DEFINED;
322 }
323 }
324 }
325
327
329
330 if (moduleRouter.hasModule(element.getID())) {
331
332 JModule& module =
detector.getModule(moduleRouter.getAddress(element.getID()));
333
334 module.setStatus(element.getStatus());
335
336 scal[1][module.
getID()] = DEFINED;
337 }
338 }
339 }
340
342
344
345 if (moduleRouter.hasModule(element.getID())) {
346
347 JModule& module =
detector.getModule(moduleRouter.getAddress(element.getID()));
348
349 module.setStatus(element.getStatus());
350
351 scal[1][module.
getID()] = DEFINED;
352 }
353 }
354 }
355 }
356 }
357 }
358 }
359
360 for (JDetector::const_iterator module =
detector.begin(); module !=
detector.end(); ++module) {
361
362 if (pcal [module->
getID()] != DEFINED) {
ERROR(
"Module " << setw(10) << module->
getID() <<
' ' <<
getLabel(module->
getLocation()) <<
" no position calibration." << endl); }
363 if (rcal [module->
getID()] != DEFINED &&
365 if (acal [module->
getID()] != DEFINED) {
ERROR(
"Module " << setw(10) << module->
getID() <<
' ' <<
getLabel(module->
getLocation()) <<
" no acoustics calibration." << endl); }
366 if (ccal [module->
getID()] != DEFINED) {
ERROR(
"Module " << setw(10) << module->
getID() <<
' ' <<
getLabel(module->
getLocation()) <<
" no compass calibration." << endl); }
367 if (scal[1][module->
getID()] != DEFINED) {
ERROR(
"Module " << setw(10) << module->
getID() <<
' ' <<
getLabel(module->
getLocation()) <<
" no status calibration." << endl); }
368
369 for (JModule::const_iterator pmt = module->begin(); pmt != module->end(); ++pmt) {
370 if (tcal [pmt->
getID()] != DEFINED) {
ERROR(
"PMT " << setw(8) << pmt->
getID() <<
" no time calibration." << endl); }
371 if (scal[0][pmt->
getID()] != DEFINED) {
ERROR(
"PMT " << setw(8) << pmt->
getID() <<
" no status calibration." << endl); }
372 }
373 }
374
375
377
378 try {
381 else
383 }
386 }
387
388 return 0;
389}
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
#define MAKE_STRING(A)
Make string.
void setCalibration(const JCalibration &cal)
Set calibration.
const JLocation & getLocation() const
Get location.
int getFloor() const
Get floor number.
Router for direct addressing of module data in detector data structure.
Data structure for a composite optical module.
Router for direct addressing of PMT data in detector data structure.
Data structure for PMT geometry, calibration and status.
Data structure for position in three dimensions.
int getID() const
Get identifier.
Utility class to parse command line options.
void from_json(const json &js, JDBString &object)
Convert JSon to database string.
std::string getLabel(const JLocation &location)
Get module label for monitoring and other applications.
JDetectorBuilder & getDetectorBuilder()
Get detector builder.
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.
bool hasDetectorAddressMap(const int id)
Check if detector address map is available.
std::string setWildCard(const std::string &file_name, const std::string &value)
Get file name by setting wild card to given value.
bool hasWildCard(const std::string &file_name)
Check presence of wild card.
static const char FILENAME_WILDCARD
wild card character for file name substitution
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
std::map< int, buffer_type > map_type
identifier -> hits
static const std::string BasePositions_t
static const std::string BaseStatusInfo_t
static const std::string BaseAcousticT0_t
static const std::string TCAL
PMT time offsets.
bool is_valid(const json &js)
Check validity of JSon data.
static const std::string PMTT0s_t
static const std::string PCAL
(optical|base) module positions
static const std::string DOMPositions_t
static const std::string SCAL
(module|PMT) status
static const std::string DetID_t
static const std::string RCAL
optical module orientations
static const std::string BaseCompassRotations_t
static const std::string Data_t
static const std::string PMTStatusInfo_t
static const std::string DOMRotations_t
static const std::string ACAL
acoustic time offsets (piezo sensor or hydrophone)
static const std::string DOMAcousticT0_t
static const std::string CCAL
compass alignment (a.k.a. quaternion calibration)
static const std::string DOMStatusInfo_t
static const std::string DOMCompassRotations_t
static const std::string Comment_t
Auxiliary interface for building detector.
const JModule & getModule(const int id=-1, const JLocation &location=JLocation()) const
Get module.
void setStatus(const JStatus &status)
Set status.
Auxiliary class to load json data from file.