73 JParser<> zap(
"Auxiliary program to compose detector from separate calibrations.");
75 zap[
'a'] =
make_field(detectorFile,
"detector file");
76 zap[
'f'] =
make_field(inputFile,
"detector calibration files in JSON format "\
77 "(wild card \'" <<
FILENAME_WILD_CARD <<
"\' will be replaced by corresponding calibration set)");
83 catch(
const exception &error) {
84 FATAL(error.what() << endl);
98 FATAL(
"No detector address map for detector identier " <<
detector.getID() << endl);
120 operator int()
const {
return value; }
122 status_type& operator=(
const int value)
142 for (
const auto& file_name : inputFile) {
154 buffer = { file_name };
156 for (
const auto& file_name : buffer) {
158 const JSon js(file_name);
160 json::const_iterator
data;
166 for (
size_t i = 0; i != data->size(); ++i) {
170 if (data->at(i).contains(
DetID_t)) {
172 FATAL(
"Detector identifier mismatch " << data->at(i)[
DetID_t].get<
int>() <<
" != " <<
detector.getID() << endl);
176 if (data->at(i).contains(
PMTT0s_t)) {
180 if (pmtRouter.hasPMT(element.getID())) {
182 JPMT& pmt =
detector.getPMT(pmtRouter.getAddress(element.getID()));
186 tcal[pmt.
getID()] = DEFINED;
195 if (moduleRouter.hasModule(element.getID())) {
197 JModule& module =
detector.getModule(moduleRouter.getAddress(element.getID()));
199 module.
set(element.getPosition());
201 pcal[module.
getID()] = DEFINED;
210 if (moduleRouter.hasModule(element.getID())) {
212 JModule& module =
detector.getModule(moduleRouter.getAddress(element.getID()));
214 module.
set(element.getPosition());
216 pcal[module.
getID()] = DEFINED;
225 if (moduleRouter.hasModule(element.getID())) {
227 JModule& module =
detector.getModule(moduleRouter.getAddress(element.getID()));
231 if (module.size() != buffer.size()) {
232 FATAL(
"Module size " << module.size() <<
" != " << buffer.size() << endl);
237 for (
size_t i = 0; i != module.size(); ++i) {
241 module.
rotate(element.getQuaternion());
246 rcal[module.
getID()] = DEFINED;
255 if (moduleRouter.hasModule(element.getID())) {
257 JModule& module =
detector.getModule(moduleRouter.getAddress(element.getID()));
261 acal[module.
getID()] = DEFINED;
270 if (moduleRouter.hasModule(element.getID())) {
272 JModule& module =
detector.getModule(moduleRouter.getAddress(element.getID()));
276 acal[module.
getID()] = DEFINED;
285 if (moduleRouter.hasModule(element.getID())) {
287 JModule& module =
detector.getModule(moduleRouter.getAddress(element.getID()));
291 ccal[module.
getID()] = DEFINED;
300 if (moduleRouter.hasModule(element.getID())) {
302 JModule& module =
detector.getModule(moduleRouter.getAddress(element.getID()));
306 ccal[module.
getID()] = DEFINED;
315 if (pmtRouter.hasPMT(element.getID())) {
317 JPMT& pmt =
detector.getPMT(pmtRouter.getAddress(element.getID()));
321 scal[0][pmt.
getID()] = DEFINED;
330 if (moduleRouter.hasModule(element.getID())) {
332 JModule& module =
detector.getModule(moduleRouter.getAddress(element.getID()));
336 scal[1][module.
getID()] = DEFINED;
345 if (moduleRouter.hasModule(element.getID())) {
347 JModule& module =
detector.getModule(moduleRouter.getAddress(element.getID()));
351 scal[1][module.
getID()] = DEFINED;
360 for (JDetector::const_iterator module =
detector.begin(); module !=
detector.end(); ++module) {
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); }
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); }
Router for direct addressing of PMT data in detector data structure.
Utility class to parse command line options.
static const std::string DOMStatusInfo_t
int getFloor() const
Get floor number.
Data structure for a composite optical module.
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)
bool is_valid(const json &js)
Check validity of JSon data.
static const std::string PMTT0s_t
Router for direct addressing of module data in detector data structure.
bool hasDetectorAddressMap(const int id)
Check if detector address map is available.
void from_json(const json &js, JDBString &object)
Convert JSon to database string.
void setAxis(const JAxis3D &axis)
Set axis.
Lookup table for PMT addresses in detector.
static const std::string BaseStatusInfo_t
#define MAKE_STRING(A)
Make string.
static const std::string TCAL
PMT time offsets.
static const std::string Comment_t
void setQuaternion(const JQuaternion3D &quaternion)
Set quaternion.
const JLocation & getLocation() const
Get location.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
int getID() const
Get identifier.
Data structure for PMT geometry, calibration and status.
void store(const std::string &file_name, const JDetector &detector)
Store detector to output file.
static const std::string DOMPositions_t
JVector3D getCenter() const
Get center of module based on crossing point of PMT axes.
JDetectorAddressMap & getDetectorAddressMap()
Get detector address map.
static const std::string RCAL
optical module orientations
const JPMT & getPMT(const int index) const
Get PMT.
void rotate(const JRotation3D &R)
Rotate module.
static const std::string DOMCompassRotations_t
void setStatus(const JStatus &status)
Set status.
std::string setWildCard(const std::string &file_name, const std::string &value)
Get file name by setting wild card to given value.
static const std::string Data_t
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
static const std::string SCAL
(module|PMT) status
void setCalibration(const JCalibration &cal)
Set calibration.
static const std::string BasePositions_t
static const std::string DOMRotations_t
const JAxis3D & getAxis() const
Get axis.
static const char FILENAME_WILD_CARD
wild card character for file name substitution
Data structure for position in three dimensions.
static const std::string BaseCompassRotations_t
Auxiliary class to load json data from file.
do set_variable DETECTOR_TXT $WORKDIR detector
static const std::string PMTStatusInfo_t
static const std::string PCAL
(optical|base) module positions
static const std::string DetID_t
JModule & set(const JVector3D &pos)
Set position.
static const std::string DOMAcousticT0_t
const JModule & getModule(const JDetector &detector, const JModuleLocation &location)
find module with a given string and floor number
static const std::string BaseAcousticT0_t
void setPosition(const JVector3D &pos)
Set position.
bool hasWildCard(const std::string &file_name)
Check presence of wild card.