76{
79
81
83 string usr;
84 string pwd;
85 string cookie;
86 string detectorFile;
88 JRange_t validity;
89 JRange_t range;
90 double precision;
92
93 try {
94
95 JParser<> zap(
"Auxiliary program to decompose detector to separate calibrations.");
96
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;
111
112 zap(argc, argv);
113 }
114 catch(const exception &error) {
115 FATAL(error.what() << endl);
116 }
117
118
119
121
122 try {
124 }
127 }
128
130 FATAL(
"No detector address map for detector identier " <<
detector.getID() << endl);
131 }
132
134
135 string userid = "";
136 string detoid = "";
137 string locid = "";
138
139 try {
140
141 JDB::reset(usr, pwd, cookie);
142
143 {
145
146 for (
JPersons object; rs >> object; ) {
147 userid = object.OID;
148 }
149
150 rs.Close();
151 }
152 {
154
156 locid = object.LOCATIONID;
157 detoid = object.OID;
158 }
159
160 rs.Close();
161 }
162
163 if (range.getLowerLimit() != RUN_INVALID && validity.getLowerLimit() == UTC_INVALID_S) {
164
166
167 for (
JRuns object; rs >> object; ) {
168 validity.setLowerLimit(object.UNIXJOBSTART / 1000);
169 }
170
171 rs.Close();
172 }
173
174 if (range.getUpperLimit() != RUN_INVALID && validity.getUpperLimit() == UTC_INVALID_S) {
175
177
178 for (
JRuns object; rs >> object; ) {
179 validity.setUpperLimit(object.UNIXJOBEND / 1000);
180 }
181
182 rs.Close();
183 }
184 }
185 catch(const exception& error) {
186 FATAL(error.what() << endl);
187 }
188
189
190
191
192 for (JDetector::const_iterator module =
detector.begin(); module !=
detector.end(); ++module) {
193
194 if (module->getFloor() != 0) {
195
197
198 const JRotation3D R = getRotation(buffer, *module);
199
201
202 if (!JModule::compare(buffer, *module, precision)) {
203
204 for (size_t i = 0; i != module->size(); ++i) {
205 DEBUG(
"PMT " << setw(2) << i <<
' '
209 }
210
211 FATAL(
"Module " << setw(10) << module->getID() <<
' ' << module->getLocation() <<
" incompatible with reference." << endl);
212 }
213 }
214 }
215
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()) };
224
225 const json error = { {Message_t,
"" },
226 {Code_t, OK_t },
227 {Arguments_t, json::array() } };
228
229
231
233 js[Error_t] =
json(error);
234
236
238
239 for (JDetector::const_iterator module =
detector.begin(); module !=
detector.end(); ++module) {
240 for (JModule::const_iterator pmt = module->begin(); pmt != module->end(); ++pmt) {
242 }
243 }
244
245 js[Data_t][0] =
json(header);
246 js[Data_t][0][PMTT0s_t] =
json(data);
247
249 }
250
252
254
255 for (JDetector::const_iterator module =
detector.begin(); module !=
detector.end(); ++module) {
256
257 const JModule& buffer = demo.
getModule(module->getID(), module->getLocation());
258
261 else
263 }
264
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]);
268
270 }
271
273
275
276 for (JDetector::const_iterator module =
detector.begin(); module !=
detector.end(); ++module) {
277
278 const JModule& buffer = demo.
getModule(module->getID(), module->getLocation());
279
280 if (module->getFloor() != 0) {
282 }
283 }
284
285 js[Data_t][0] =
json(header);
286 js[Data_t][0][DOMRotations_t] =
json(data);
287
289 }
290
292
294
295 for (JDetector::const_iterator module =
detector.begin(); module !=
detector.end(); ++module) {
296
297 if (module->getFloor() == 0)
299 else
301 }
302
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]);
306
308 }
309
311
313
314 for (JDetector::const_iterator module =
detector.begin(); module !=
detector.end(); ++module) {
315 if (module->getFloor() == 0)
317 else
319 }
320
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]);
324
326 }
327
329
330 js[Data_t][0] =
json(header);
331
332 {
334
335 for (JDetector::const_iterator module =
detector.begin(); module !=
detector.end(); ++module) {
336 for (JModule::const_iterator pmt = module->begin(); pmt != module->end(); ++pmt) {
338 }
339 }
340
341 js[Data_t][0][PMTStatusInfo_t ] =
json(data);
342 }
343 {
345
346 for (JDetector::const_iterator module =
detector.begin(); module !=
detector.end(); ++module) {
347 if (module->getFloor() == 0)
349 else
351 }
352
353 js[Data_t][0][BaseStatusInfo_t] =
json(data[0]);
354 js[Data_t][0][DOMStatusInfo_t] =
json(data[1]);
355 }
356
358 }
359
360 return 0;
361}
#define DEBUG(A)
Message macros.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Data structure for time calibration.
int getFloor() const
Get floor number.
Data structure for a composite optical module.
void rotate(const JRotation3D &R)
Rotate module.
Utility class to parse command line options.
JDirection3D getDirection(const Vec &dir)
Get direction.
JPosition3D getPosition(const Vec &pos)
Get position.
ResultSet & getResultSet(const std::string &query)
Get result set.
std::vector< JServer > getServernames()
Get list of names of available database servers.
JDetectorBuilder & getDetectorBuilder()
Get detector builder.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
JCalibration getCalibration(const JCalibration &first, const JCalibration &second)
Get calibration to go from first to second calibration.
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.
double getDot(const JFirst_t &first, const JSecond_t &second)
Get dot product of objects.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary data structure for floating point format specification.
Wrapper class for server name.
Template definition for getting table specific selector.
Auxiliary data structure for compass rotation.
Auxiliary interface for building detector.
const JModule & getModule(const int id=-1, const JLocation &location=JLocation()) const
Get module.
Auxiliary data structure for module time calibration.
Auxiliary data structure for module position.
Auxiliary data structure for module rotation.
Auxiliary data structure for module status.
Auxiliary data structure for PMT time calibration.
Auxiliary data structure for PMT status.
Auxiliary data structure for streaming of STL containers.
Auxiliary data structure for correspondence between nick and full name of calibration types.
Auxiliary class for date and time.
std::string toString() const
Get ASCII formatted date and time.