75int main(
int argc,
char **argv)
95 JParser<> zap(
"Auxiliary program to decompose detector to separate calibrations.");
97 zap[
's'] =
make_field(server) = getServernames();
101 zap[
'a'] =
make_field(detectorFile,
"detector file");
103 "\nFile name should contain wild card \'" << FILENAME_WILDCARD <<
"\' or"\
106 &JCalibrationType::nick_name));
107 zap[
'V'] =
make_field(validity,
"validity range UTC [s], e.g. \"<UTC min> <UTC max>\"") = JRange_t(UTC_INVALID_S, UTC_INVALID_S);
108 zap[
'r'] =
make_field(range,
"run range e.g. \"<first run> <last run>\"") = JRange_t(RUN_INVALID, RUN_INVALID);
109 zap[
'p'] =
make_field(precision,
"precision for match with reference module") = 1.0e-5;
114 catch(
const exception &error) {
115 FATAL(error.what() << endl);
129 if (!hasDetectorAddressMap(
detector.getID())) {
130 FATAL(
"No detector address map for detector identier " <<
detector.getID() << endl);
141 JDB::reset(usr, pwd, cookie);
146 for (
JPersons object; rs >> object; ) {
156 locid =
object.LOCATIONID;
163 if (range.getLowerLimit() != RUN_INVALID && validity.getLowerLimit() == UTC_INVALID_S) {
167 for (
JRuns object; rs >> object; ) {
168 validity.setLowerLimit(
object.UNIXJOBSTART / 1000);
174 if (range.getUpperLimit() != RUN_INVALID && validity.getUpperLimit() == UTC_INVALID_S) {
178 for (
JRuns object; rs >> object; ) {
179 validity.setUpperLimit(
object.UNIXJOBEND / 1000);
185 catch(
const exception& error) {
186 FATAL(error.what() << endl);
192 for (JDetector::const_iterator module =
detector.begin(); module !=
detector.end(); ++module) {
194 if (module->getFloor() != 0) {
198 const JRotation3D R = getRotation(buffer, *module);
202 if (!JModule::compare(buffer, *module, precision)) {
204 for (
size_t i = 0; i !=
module->size(); ++i) {
205 DEBUG(
"PMT " << setw(2) << i <<
' '
206 << (*module)[i].getDirection() <<
' '
207 << buffer[i].getDirection() <<
' '
208 <<
FIXED(7,3) << acos(getDot((*module)[i].getDirection(), buffer[i].getDirection())) * 180.0 / PI <<
" [deg]" << endl);
211 FATAL(
"Module " << setw(10) << module->getID() <<
' ' << module->getLocation() <<
" incompatible with reference." << endl);
216 const json header = { { UserId_t, userid },
217 { TypeId_t,
json() },
218 { LocationId_t, locid },
219 { DetOID_t, detoid },
222 getJSon(ValidFrom_t, validity.getLowerLimit()),
223 getJSon(ValidThrough_t, validity.getUpperLimit()) };
225 const json error = { {Message_t,
"" },
227 {Arguments_t, json::array() } };
233 js[Error_t] =
json(error);
239 for (JDetector::const_iterator module =
detector.begin(); module !=
detector.end(); ++module) {
240 for (JModule::const_iterator pmt = module->begin(); pmt != module->end(); ++pmt) {
245 js[Data_t][0] =
json(header);
246 js[Data_t][0][PMTT0s_t] =
json(data);
255 for (JDetector::const_iterator module =
detector.begin(); module !=
detector.end(); ++module) {
257 const JModule& buffer = demo.
getModule(module->getID(), module->getLocation());
260 data[0].push_back(
JModulePosition_t(module->getID(), getPosition(buffer, *module)));
262 data[1].push_back(
JModulePosition_t(module->getID(), getPosition(buffer, *module)));
265 js[Data_t][0] =
json(header);
266 js[Data_t][0][BasePositions_t] =
json(data[0]);
267 js[Data_t][0][DOMPositions_t] =
json(data[1]);
276 for (JDetector::const_iterator module =
detector.begin(); module !=
detector.end(); ++module) {
278 const JModule& buffer = demo.
getModule(module->getID(), module->getLocation());
280 if (module->getFloor() != 0) {
281 data.push_back(
JModuleRotation_t(module->getID(), getRotation(buffer, *module)));
285 js[Data_t][0] =
json(header);
286 js[Data_t][0][DOMRotations_t] =
json(data);
295 for (JDetector::const_iterator module =
detector.begin(); module !=
detector.end(); ++module) {
297 if (module->getFloor() == 0)
303 js[Data_t][0] =
json(header);
304 js[Data_t][0][BaseAcousticT0_t] =
json(data[0]);
305 js[Data_t][0][DOMAcousticT0_t] =
json(data[1]);
314 for (JDetector::const_iterator module =
detector.begin(); module !=
detector.end(); ++module) {
315 if (module->getFloor() == 0)
321 js[Data_t][0] =
json(header);
322 js[Data_t][0][BaseCompassRotations_t] =
json(data[0]);
323 js[Data_t][0][DOMCompassRotations_t] =
json(data[1]);
330 js[Data_t][0] =
json(header);
335 for (JDetector::const_iterator module =
detector.begin(); module !=
detector.end(); ++module) {
336 for (JModule::const_iterator pmt = module->begin(); pmt != module->end(); ++pmt) {
337 data.push_back(
JPMTStatus_t(pmt->getID(), pmt->getStatus()));
341 js[Data_t][0][PMTStatusInfo_t ] =
json(data);
346 for (JDetector::const_iterator module =
detector.begin(); module !=
detector.end(); ++module) {
347 if (module->getFloor() == 0)
348 data[0].push_back(
JModuleStatus_t(module->getID(), module->getStatus()));
350 data[1].push_back(
JModuleStatus_t(module->getID(), module->getStatus()));
353 js[Data_t][0][BaseStatusInfo_t] =
json(data[0]);
354 js[Data_t][0][DOMStatusInfo_t] =
json(data[1]);