61int main(
int argc,
char **argv)
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_WILDCARD <<
"\' 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())) {
186 tcal[pmt.
getID()] = DEFINED;
195 if (moduleRouter.
hasModule(element.getID())) {
199 module.set(element.getPosition());
201 pcal[module.
getID()] = DEFINED;
210 if (moduleRouter.
hasModule(element.getID())) {
214 module.set(element.getPosition());
216 pcal[module.
getID()] = DEFINED;
225 if (moduleRouter.
hasModule(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) {
238 module.getPMT(i).setAxis(buffer.getPMT(i).getAxis());
241 module.rotate(element.getQuaternion());
243 module.setPosition(module.getCenter());
246 rcal[module.
getID()] = DEFINED;
255 if (moduleRouter.
hasModule(element.getID())) {
259 module.setCalibration(element.getCalibration());
261 acal[module.
getID()] = DEFINED;
270 if (moduleRouter.
hasModule(element.getID())) {
274 module.setCalibration(element.getCalibration());
276 acal[module.
getID()] = DEFINED;
285 if (moduleRouter.
hasModule(element.getID())) {
289 module.setQuaternion(element.getQuaternion());
291 ccal[module.
getID()] = DEFINED;
300 if (moduleRouter.
hasModule(element.getID())) {
304 module.setQuaternion(element.getQuaternion());
306 ccal[module.
getID()] = DEFINED;
315 if (pmtRouter.
hasPMT(element.getID())) {
321 scal[0][pmt.
getID()] = DEFINED;
330 if (moduleRouter.
hasModule(element.getID())) {
334 module.setStatus(element.getStatus());
336 scal[1][module.
getID()] = DEFINED;
345 if (moduleRouter.
hasModule(element.getID())) {
349 module.setStatus(element.getStatus());
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 &&
364 module->getFloor() != 0) {
ERROR(
"Module " << setw(10) << module->getID() <<
' ' <<
getLabel(module->getLocation()) <<
" no rotation calibration." << endl); }
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); }
int main(int argc, char **argv)
Data structure for detector geometry and calibration.
General purpose messaging.
Direct access to module in detector data structure.
Direct access to PMT in detector data structure.
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
I/O formatting auxiliaries.
#define MAKE_STRING(A)
Make string.
void setCalibration(const JCalibration &cal)
Set calibration.
const JLocation & getLocation() const
Get location.
Router for direct addressing of module data in detector data structure.
bool hasModule(const JObjectID &id) const
Has module.
const JModuleAddress & getAddress(const JObjectID &id) const
Get address of module.
Data structure for a composite optical module.
Router for direct addressing of PMT data in detector data structure.
bool hasPMT(const JObjectID &id) const
Has PMT.
const JPMTAddress & getAddress(const JObjectID &id) const
Get address of PMT.
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 ValidThrough_t
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
static const std::string ValidFrom_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.
Auxiliary class for date and time.
time_t getTime() const
time