70int main(
int argc,
char **argv)
82 JParser<> zap(
"Auxiliary program to print detector file in human friendly format.");
85 zap[
'O'] =
make_field(option,
"possible options "
96 << identifier_t <<
' '
104 << IDENTIFIER_t <<
' '
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);
128 if (option.count(default_t)) {
134 if (option.count(modules_t)) {
138 for (JDetector::const_iterator module =
detector.begin(); module !=
detector.end(); ++module) {
141 cout <<
' ' << noshowpos << setw(8) << right << module->getID();
142 cout <<
' ' << noshowpos << setw(3) << right << module->getString();
143 cout <<
' ' << noshowpos << setw(2) << right << module->getFloor();
144 cout <<
' ' <<
FIXED(7,2) << module->getX();
145 cout <<
' ' <<
FIXED(7,2) << module->getY();
146 cout <<
' ' <<
FIXED(7,2) << module->getZ();
147 cout <<
' ' <<
FIXED(8,2) << module->getT0();
149 if (module->getFloor() != 0) {
156 const double phi = (JVector3Z_t.getDot(q1.
twist) >= 0.0 ? +1.0 : -1.0) * q1.
twist.
getAngle();
158 cout <<
' ' <<
FIXED(7,2) << phi;
164 const double phi = (JVector3Z_t.getDot(q1.
twist) >= 0.0 ? +1.0 : -1.0) * q1.
twist.
getAngle();
166 cout <<
' ' <<
FIXED(7,2) << phi;
171 const JRotation3D R = getRotation(buffer, *module);
175 cout <<
' ' << (JModule::compare(buffer, *module, precision) ?
"==" :
"!=")
185 if (option.count(pmts_t)) {
189 for (JDetector::const_iterator module =
detector.begin(); module !=
detector.end(); ++module) {
193 for (
size_t i = 0; i !=
module->size(); ++i) {
195 const JPMT& pmt =
module->getPMT(i);
198 cout <<
"PMT[" <<
FILL(2,
'0') << i <<
FILL() <<
"]";
199 cout <<
' ' << address;
200 cout <<
' ' << noshowpos << setw(8) << right << pmt.
getID();
208 cout <<
' ' << noshowpos << setw(8) << right << pmt.
getStatus();
215 if (option.count(geometry_t) ||
216 option.count(GEOMETRY_t)) {
218 if (option.count(geometry_t)) {
220 cout <<
"Maximal distance [m] = " <<
FIXED(6,1) << getMaximalDistance(
detector) << endl;
221 cout <<
"Minimal distance [m] = " <<
FIXED(6,1) << getMinimalDistance(
detector) << endl;
222 cout <<
"Maximal time [ns] = " <<
FIXED(6,1) << getMaximalTime (
detector) << endl;
226 cout <<
"set_variable MAXIMAL_DISTANCE_M " <<
FIXED(6,1) << getMaximalDistance(
detector) <<
";" << endl;
227 cout <<
"set_variable MINIMAL_DISTANCE_M " <<
FIXED(6,1) << getMinimalDistance(
detector) <<
";" << endl;
232 if (option.count(comment_t)) {
238 if (option.count(header_t) ||
239 option.count(HEADER_t)) {
241 if (option.count(header_t)) {
243 cout <<
detector.getProperties() << endl;
244 cout <<
"name = " << (isARCADetector(
detector) ?
"ARCA" :
247 cout <<
"validity = "
253 cout <<
"set_variable UTM_EAST " <<
FIXED(12,2) <<
detector.getUTMEast() <<
";" << endl;
254 cout <<
"set_variable UTM_NORTH " <<
FIXED(12,2) <<
detector.getUTMNorth() <<
";" << endl;
255 cout <<
"set_variable UTM_Z " <<
FIXED(12,2) <<
detector.getUTMZ() <<
";" << endl;
256 cout <<
"set_variable UTM_ZONE " <<
FIXED(12,2) <<
detector.getUTMZone() <<
";" << endl;
257 cout <<
"set_variable UTM_WGS " <<
FIXED(12,2) <<
detector.getWGS() <<
";" << endl;
262 if (option.count(version_t) ||
263 option.count(VERSION_t)) {
265 if (option.count(version_t)) {
267 cout <<
detector.getVersion() << endl;
271 cout <<
"set_variable DETECTOR_VERSION " <<
detector.getVersion() <<
";" << endl;
276 if (option.count(identifier_t) ||
277 option.count(IDENTIFIER_t)) {
279 if (option.count(identifier_t)) {
281 cout <<
"Detector " <<
detector.getID() << endl;
285 cout <<
"set_variable DETECTOR_ID " <<
detector.getID() <<
";" << endl;
290 if (option.count(can_t) ||
291 option.count(CAN_t)) {
296 const double D = getMaximalDistance(
detector);
298 if (option.count(can_t)) {
300 cout <<
"X = " <<
FIXED(7,1) << cylinder.
getX() << endl;
301 cout <<
"Y = " <<
FIXED(7,1) << cylinder.
getY() << endl;
302 cout <<
"Zmin = " <<
FIXED(7,1) << cylinder.
getZmin() << endl;
303 cout <<
"Zmax = " <<
FIXED(7,1) << cylinder.
getZmax() << endl;
304 cout <<
"Radius = " <<
FIXED(7,1) << cylinder.
getRadius() << endl;
305 cout <<
"Depth = " <<
FIXED(7,1) <<
detector.getUTMZ() << endl;
306 cout <<
"Volume = " <<
SCIENTIFIC(12,3) << V << endl;
307 cout <<
"Distance = " <<
FIXED(9,3) << D << endl;
311 cout <<
"set_variable CAN_X_M " <<
FIXED(7,1) << cylinder.
getX() <<
";" << endl;
312 cout <<
"set_variable CAN_Y_M " <<
FIXED(7,1) << cylinder.
getY() <<
";" << endl;
313 cout <<
"set_variable CAN_ZMIN_M " <<
FIXED(7,1) << cylinder.
getZmin() <<
";" << endl;
314 cout <<
"set_variable CAN_ZMAX_M " <<
FIXED(7,1) << cylinder.
getZmax() <<
";" << endl;
315 cout <<
"set_variable CAN_RADIUS_M " <<
FIXED(7,1) << cylinder.
getRadius() <<
";" << endl;
316 cout <<
"set_variable CAN_DEPTH_M " <<
FIXED(7,1) <<
detector.getUTMZ() <<
";" << endl;
317 cout <<
"set_variable CAN_VOLUME_M3 " <<
SCIENTIFIC(12,3) << V <<
";" << endl;
318 cout <<
"set_variable CAN_DISTANCE_M " <<
FIXED(9,3) << D <<
";" << endl;
323 if (option.count(center_t) ||
324 option.count(CENTER_t)) {
328 if (option.count(center_t)) {
331 cout << showpos <<
FIXED(8,3) << center.
getX() <<
' ';
332 cout << showpos <<
FIXED(8,3) << center.
getY() <<
' ';
333 cout << showpos <<
FIXED(8,3) << center.
getZ() << endl;
337 cout <<
"set_variable CENTER_X_M " <<
FIXED(7,1) << center.
getX() <<
";" << endl;
338 cout <<
"set_variable CENTER_Y_M " <<
FIXED(7,1) << center.
getY() <<
";" << endl;
339 cout <<
"set_variable CENTER_Z_M " <<
FIXED(7,1) << center.
getZ() <<
";" << endl;
344 if (option.count(summary_t) ||
345 option.count(SUMMARY_t)) {
347 const int numberOfStrings = getNumberOfStrings(
detector);
348 const int numberOfFloors = getNumberOfFloors (
detector);
349 const int numberOfModules = getNumberOfModules(
detector);
350 const int numberOfPMTs = getNumberOfPMTs (
detector);
354 const JRange_t string_t(make_array(
detector.begin(),
detector.end(), &JModule::getString));
355 const JRange_t floor_t (make_array(
detector.begin(),
detector.end(), &JModule::getFloor));
360 for (JDetector::const_iterator module =
detector.begin(); module !=
detector.end(); ++module) {
361 strings.insert(module->getString());
362 modules.insert(module->getID());
365 if (option.count(summary_t)) {
367 cout <<
"Number of strings = " << setw(4) << numberOfStrings << endl;
368 cout <<
"Number of floors = " << setw(4) << numberOfFloors << endl;
369 cout <<
"Number of modules = " << setw(4) << numberOfModules << endl;
370 cout <<
"Number of PMTs = " << setw(4) << numberOfPMTs << endl;
371 cout <<
"First string = " << setw(4) << string_t.first << endl;
372 cout <<
"Last string = " << setw(4) << string_t.second << endl;
373 cout <<
"First floor = " << setw(4) << floor_t .first << endl;
374 cout <<
"Last floor = " << setw(4) << floor_t .second << endl;
378 cout <<
"let \"NUMBER_OF_STRINGS = " << setw(5) << numberOfStrings <<
"\";" << endl;
379 cout <<
"let \"NUMBER_OF_FLOORS = " << setw(5) << numberOfFloors <<
"\";" << endl;
380 cout <<
"let \"NUMBER_OF_MODULES = " << setw(5) << numberOfModules <<
"\";" << endl;
381 cout <<
"let \"NUMBER_OF_PMTS = " << setw(5) << numberOfPMTs <<
"\";" << endl;
382 cout <<
"let \"FIRST_STRING = " << setw(5) << string_t.first <<
"\";" << endl;
383 cout <<
"let \"LAST_STRING = " << setw(5) << string_t.second <<
"\";" << endl;
384 cout <<
"let \"FIRST_FLOOR = " << setw(5) << floor_t .first <<
"\";" << endl;
385 cout <<
"let \"LAST_FLOOR = " << setw(5) << floor_t .second <<
"\";" << endl;
387 copy(strings.begin(), strings.end(), ostream_iterator<int>(cout,
" "));
388 cout <<
");" << endl;
390 copy(modules.begin(), modules.end(), ostream_iterator<int>(cout,
" "));
391 cout <<
");" << endl;
395 for (
const auto i : strings) {
396 cout <<
"typeset -A " << getString(i) <<
";" << endl;
399 cout << getString(i.getString()) <<
"[" << i.getFloor() <<
"]=" << i.getID() <<
";" << endl;