42 JParser<> zap(
"Auxiliary program to compose detector from separate calibrations.");
44 zap[
'a'] =
make_field(detectorFile,
"detector file");
45 zap[
'f'] =
make_field(inputFile,
"detector calibration files in JSON format "\
46 "(wild card \'" <<
FILENAME_WILD_CARD <<
"\' will be replaced by corresponding calibration set)");
52 catch(
const exception &error) {
53 FATAL(error.what() << endl);
67 FATAL(
"No detector address map for detector identier " <<
detector.getID() << endl);
87 operator int()
const {
return value; }
89 status_type& operator=(
const int value)
109 for (
const auto& file_name : inputFile) {
121 buffer = { file_name };
123 for (
const auto& file_name : buffer) {
125 const JSon js(file_name);
127 json::const_iterator data;
133 for (
size_t i = 0; i != data->size(); ++i) {
135 if (data->at(i).contains(
DetID_t)) {
137 FATAL(
"Detector identifier mismatch " << data->at(i)[
DetID_t].get<
int>() <<
" != " <<
detector.getID() << endl);
141 if (data->at(i).contains(
PMTT0s_t)) {
145 if (pmtRouter.hasPMT(element.getID())) {
147 JPMT& pmt =
detector.getPMT(pmtRouter.getAddress(element.getID()));
151 tcal[pmt.
getID()] = DEFINED;
160 if (moduleRouter.hasModule(element.getID())) {
162 JModule& module =
detector.getModule(moduleRouter.getAddress(element.getID()));
164 module.
add(element.getPosition());
166 pcal[module.
getID()] = DEFINED;
175 if (moduleRouter.hasModule(element.getID())) {
177 JModule& module =
detector.getModule(moduleRouter.getAddress(element.getID()));
179 module.
add(element.getPosition());
181 pcal[module.
getID()] = DEFINED;
190 if (moduleRouter.hasModule(element.getID())) {
192 JModule& module =
detector.getModule(moduleRouter.getAddress(element.getID()));
196 if (module.size() != buffer.size()) {
197 FATAL(
"Module size " << module.size() <<
" != " << buffer.size() << endl);
202 for (
size_t i = 0; i != module.size(); ++i) {
206 module.
rotate(element.getQuaternion());
211 rcal[module.
getID()] = DEFINED;
220 if (moduleRouter.hasModule(element.getID())) {
222 JModule& module =
detector.getModule(moduleRouter.getAddress(element.getID()));
226 acal[module.
getID()] = DEFINED;
235 if (moduleRouter.hasModule(element.getID())) {
237 JModule& module =
detector.getModule(moduleRouter.getAddress(element.getID()));
241 acal[module.
getID()] = DEFINED;
250 if (moduleRouter.hasModule(element.getID())) {
252 JModule& module =
detector.getModule(moduleRouter.getAddress(element.getID()));
256 ccal[module.
getID()] = DEFINED;
265 if (moduleRouter.hasModule(element.getID())) {
267 JModule& module =
detector.getModule(moduleRouter.getAddress(element.getID()));
271 ccal[module.
getID()] = DEFINED;
280 if (pmtRouter.hasPMT(element.getID())) {
282 JPMT& pmt =
detector.getPMT(pmtRouter.getAddress(element.getID()));
286 scal[0][pmt.
getID()] = DEFINED;
295 if (moduleRouter.hasModule(element.getID())) {
297 JModule& module =
detector.getModule(moduleRouter.getAddress(element.getID()));
301 scal[1][module.
getID()] = DEFINED;
310 if (moduleRouter.hasModule(element.getID())) {
312 JModule& module =
detector.getModule(moduleRouter.getAddress(element.getID()));
316 scal[1][module.
getID()] = DEFINED;
325 for (JDetector::const_iterator module =
detector.begin(); module !=
detector.end(); ++module) {
327 if (pcal [module->
getID()] != DEFINED) {
ERROR(
"Module " << setw(10) << module->
getID() <<
' ' <<
getLabel(module->
getLocation()) <<
" no position calibration." << endl); }
328 if (rcal [module->
getID()] != DEFINED &&
330 if (acal [module->
getID()] != DEFINED) {
ERROR(
"Module " << setw(10) << module->
getID() <<
' ' <<
getLabel(module->
getLocation()) <<
" no acoustics calibration." << endl); }
331 if (ccal [module->
getID()] != DEFINED) {
ERROR(
"Module " << setw(10) << module->
getID() <<
' ' <<
getLabel(module->
getLocation()) <<
" no compass calibration." << endl); }
332 if (scal[1][module->
getID()] != DEFINED) {
ERROR(
"Module " << setw(10) << module->
getID() <<
' ' <<
getLabel(module->
getLocation()) <<
" no status calibration." << endl); }
334 for (JModule::const_iterator pmt = module->begin(); pmt != module->end(); ++pmt) {
335 if (tcal [pmt->
getID()] != DEFINED) {
ERROR(
"PMT " << setw(8) << pmt->
getID() <<
" no time calibration." << endl); }
336 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 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|base) 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
JModule & add(const JVector3D &pos)
Add position.
void setPosition(const JVector3D &pos)
Set position.
bool hasWildCard(const std::string &file_name)
Check presence of wild card.