73int main(
int argc,
char **argv)
93 JParser<> zap(
"Auxiliary program to decompose detector to separate calibrations.");
95 zap[
's'] =
make_field(server) = getServernames();
99 zap[
'a'] =
make_field(detectorFile,
"detector file");
101 "\nFile name should contain wild card \'" << FILENAME_WILDCARD <<
"\' or"\
104 &JCalibrationType::nick_name));
105 zap[
'V'] =
make_field(validity,
"validity range UTC [s], e.g. \"<UTC min> <UTC max>\"") = JRange_t(UTC_INVALID_S, UTC_INVALID_S);
106 zap[
'r'] =
make_field(range,
"run range e.g. \"<first run> <last run>\"") = JRange_t(RUN_INVALID, RUN_INVALID);
107 zap[
'p'] =
make_field(precision,
"precision for match with reference module") = 1.0e-5;
112 catch(
const exception &error) {
113 FATAL(error.what() << endl);
127 if (!hasDetectorAddressMap(
detector.getID())) {
128 FATAL(
"No detector address map for detector identier " <<
detector.getID() << endl);
139 JDB::reset(usr, pwd, cookie);
144 for (
JPersons object; rs >> object; ) {
154 locid =
object.LOCATIONID;
161 if (range.getLowerLimit() != RUN_INVALID && validity.getLowerLimit() == UTC_INVALID_S) {
165 for (
JRuns object; rs >> object; ) {
166 validity.setLowerLimit(
object.UNIXJOBSTART / 1000);
172 if (range.getUpperLimit() != RUN_INVALID && validity.getUpperLimit() == UTC_INVALID_S) {
176 for (
JRuns object; rs >> object; ) {
177 validity.setUpperLimit(
object.UNIXJOBEND / 1000);
183 catch(
const exception& error) {
184 FATAL(error.what() << endl);
190 for (JDetector::const_iterator module =
detector.begin(); module !=
detector.end(); ++module) {
192 if (module->getFloor() != 0) {
196 const JRotation3D R = getRotation(buffer, *module);
200 if (!JModule::compare(buffer, *module, precision)) {
202 for (
size_t i = 0; i !=
module->size(); ++i) {
203 DEBUG(
"PMT " << setw(2) << i <<
' '
204 << (*module)[i].getDirection() <<
' '
205 << buffer[i].getDirection() <<
' '
206 <<
FIXED(7,3) << acos(getDot((*module)[i].getDirection(), buffer[i].getDirection())) * 180.0 / PI <<
" [deg]" << endl);
209 FATAL(
"Module " << setw(10) << module->getID() <<
' ' << module->getLocation() <<
" incompatible with reference." << endl);
214 const json header = { { UserId_t, userid },
215 { TypeId_t,
json() },
216 { LocationId_t, locid },
217 { DetOID_t, detoid },
220 getJSon(ValidFrom_t, validity.getLowerLimit()),
221 getJSon(ValidThrough_t, validity.getUpperLimit()) };
223 const json error = { {Message_t,
"" },
225 {Arguments_t, json::array() } };
231 js[Error_t] =
json(error);
237 for (JDetector::const_iterator module =
detector.begin(); module !=
detector.end(); ++module) {
238 for (JModule::const_iterator pmt = module->begin(); pmt != module->end(); ++pmt) {
243 js[Data_t][0] =
json(header);
244 js[Data_t][0][PMTT0s_t] =
json(data);
253 for (JDetector::const_iterator module =
detector.begin(); module !=
detector.end(); ++module) {
255 const JModule& buffer = demo.
getModule(module->getID(), module->getLocation());
258 data[0].push_back(
JModulePosition_t(module->getID(), getPosition(buffer, *module)));
260 data[1].push_back(
JModulePosition_t(module->getID(), getPosition(buffer, *module)));
263 js[Data_t][0] =
json(header);
264 js[Data_t][0][BasePositions_t] =
json(data[0]);
265 js[Data_t][0][DOMPositions_t] =
json(data[1]);
274 for (JDetector::const_iterator module =
detector.begin(); module !=
detector.end(); ++module) {
276 const JModule& buffer = demo.
getModule(module->getID(), module->getLocation());
278 if (module->getFloor() != 0) {
279 data.push_back(
JModuleRotation_t(module->getID(), getRotation(buffer, *module)));
283 js[Data_t][0] =
json(header);
284 js[Data_t][0][DOMRotations_t] =
json(data);
293 for (JDetector::const_iterator module =
detector.begin(); module !=
detector.end(); ++module) {
295 if (module->getFloor() == 0)
301 js[Data_t][0] =
json(header);
302 js[Data_t][0][BaseAcousticT0_t] =
json(data[0]);
303 js[Data_t][0][DOMAcousticT0_t] =
json(data[1]);
312 for (JDetector::const_iterator module =
detector.begin(); module !=
detector.end(); ++module) {
313 if (module->getFloor() == 0)
319 js[Data_t][0] =
json(header);
320 js[Data_t][0][BaseCompassRotations_t] =
json(data[0]);
321 js[Data_t][0][DOMCompassRotations_t] =
json(data[1]);
328 js[Data_t][0] =
json(header);
333 for (JDetector::const_iterator module =
detector.begin(); module !=
detector.end(); ++module) {
334 for (JModule::const_iterator pmt = module->begin(); pmt != module->end(); ++pmt) {
335 data.push_back(
JPMTStatus_t(pmt->getID(), pmt->getStatus()));
339 js[Data_t][0][PMTStatusInfo_t ] =
json(data);
344 for (JDetector::const_iterator module =
detector.begin(); module !=
detector.end(); ++module) {
345 if (module->getFloor() == 0)
346 data[0].push_back(
JModuleStatus_t(module->getID(), module->getStatus()));
348 data[1].push_back(
JModuleStatus_t(module->getID(), module->getStatus()));
351 js[Data_t][0][BaseStatusInfo_t] =
json(data[0]);
352 js[Data_t][0][DOMStatusInfo_t] =
json(data[1]);