70int main(
int argc, 
char **argv)
 
   82    JParser<> zap(
"Auxiliary program to print detector file in human friendly format.");
 
  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 == default_t) {
 
  132  } 
else if (option == modules_t) {
 
  136    for (JDetector::const_iterator module = 
detector.begin(); module != 
detector.end(); ++module) {
 
  139      cout << 
' ' << noshowpos << setw(8) << right << module->getID();
 
  140      cout << 
' ' << noshowpos << setw(3) << right << module->getString();
 
  141      cout << 
' ' << noshowpos << setw(2) << right << module->getFloor();
 
  142      cout << 
' ' << 
FIXED(7,2) << module->getX();
 
  143      cout << 
' ' << 
FIXED(7,2) << module->getY();
 
  144      cout << 
' ' << 
FIXED(7,2) << module->getZ();
 
  145      cout << 
' ' << 
FIXED(8,2) << module->getT0();
 
  147      if (module->getFloor() != 0) {
 
  154          const double phi = (JVector3Z_t.getDot(q1.
twist) >= 0.0 ? +1.0 : -1.0) * q1.
twist.
getAngle();
 
  156          cout << 
' ' << 
FIXED(7,2) << phi;
 
  162          const double phi = (JVector3Z_t.getDot(q1.
twist) >= 0.0 ? +1.0 : -1.0) * q1.
twist.
getAngle();
 
  164          cout << 
' ' << 
FIXED(7,2) << phi;         
 
  169          const JRotation3D R = getRotation(buffer, *module);
 
  173          cout << 
' ' << (JModule::compare(buffer, *module, precision) ? 
"==" : 
"!=") 
 
  181  } 
else if (option == pmts_t) {
 
  185    for (JDetector::const_iterator module = 
detector.begin(); module != 
detector.end(); ++module) {
 
  189      for (
size_t i = 0; i != 
module->size(); ++i) {
 
  191        const JPMT&                pmt     = 
module->getPMT(i);
 
  194        cout << 
"PMT[" << 
FILL(2,
'0')  << i << 
FILL() << 
"]";
 
  195        cout << 
' ' << address;
 
  196        cout << 
' ' << noshowpos << setw(8) << right << pmt.
getID();
 
  204        cout << 
' ' << noshowpos << setw(8) << right << pmt.
getStatus();
 
  209  } 
else if (option == geometry_t ||
 
  210             option == GEOMETRY_t) {
 
  212    if (option == geometry_t) {
 
  214      cout << 
"Maximal distance [m] = " << 
FIXED(6,1) << getMaximalDistance(
detector) << endl;
 
  215      cout << 
"Minimal distance [m] = " << 
FIXED(6,1) << getMinimalDistance(
detector) << endl;
 
  216      cout << 
"Maximal time [ns]    = " << 
FIXED(6,1) << getMaximalTime    (
detector) << endl;
 
  220      cout << 
"set_variable MAXIMAL_DISTANCE_M " << 
FIXED(6,1) << getMaximalDistance(
detector)  << 
";" << endl;
 
  221      cout << 
"set_variable MINIMAL_DISTANCE_M " << 
FIXED(6,1) << getMinimalDistance(
detector)  << 
";" << endl;
 
  224  } 
else if (option == comment_t) {
 
  228  } 
else if (option == header_t ||
 
  229             option == HEADER_t) {
 
  231    if (option == header_t) {
 
  233      cout << 
detector.getProperties() << endl;
 
  234      cout << 
"name = " << (isARCADetector(
detector) ? 
"ARCA" : 
 
  237      cout << 
"validity = "  
  243      cout << 
"set_variable UTM_EAST         " << 
FIXED(12,2) << 
detector.getUTMEast()  << 
";" << endl;
 
  244      cout << 
"set_variable UTM_NORTH        " << 
FIXED(12,2) << 
detector.getUTMNorth() << 
";" << endl;
 
  245      cout << 
"set_variable UTM_Z            " << 
FIXED(12,2) << 
detector.getUTMZ()     << 
";" << endl;
 
  246      cout << 
"set_variable UTM_ZONE         " << 
FIXED(12,2) << 
detector.getUTMZone()  << 
";" << endl;
 
  247      cout << 
"set_variable UTM_WGS          " << 
FIXED(12,2) << 
detector.getWGS()      << 
";" << endl;
 
  250  } 
else if (option == version_t || 
 
  251             option == VERSION_t) {
 
  253    if (option == version_t) {
 
  255      cout << 
detector.getVersion() << endl;
 
  259      cout << 
"set_variable DETECTOR_VERSION " << 
detector.getVersion() << 
";" << endl;
 
  262  } 
else if (option == identifier_t ||
 
  263             option == IDENTIFIER_t) {
 
  265    if (option == identifier_t) {
 
  267      cout << 
"Detector " << 
detector.getID() << endl;
 
  271      cout << 
"set_variable DETECTOR_ID      " << 
detector.getID() << 
";" << endl;
 
  274  } 
else if (option == can_t ||
 
  280    const double      D = getMaximalDistance(
detector);
 
  282    if (option == can_t) {
 
  284      cout << 
"X        = " << 
FIXED(7,1)       << cylinder.
getX()      << endl;
 
  285      cout << 
"Y        = " << 
FIXED(7,1)       << cylinder.
getY()      << endl;
 
  286      cout << 
"Zmin     = " << 
FIXED(7,1)       << cylinder.
getZmin()   << endl;
 
  287      cout << 
"Zmax     = " << 
FIXED(7,1)       << cylinder.
getZmax()   << endl;
 
  288      cout << 
"Radius   = " << 
FIXED(7,1)       << cylinder.
getRadius() << endl;
 
  289      cout << 
"Depth    = " << 
FIXED(7,1)       << 
detector.getUTMZ()   << endl;
 
  290      cout << 
"Volume   = " << 
SCIENTIFIC(12,3) << V                    << endl;
 
  291      cout << 
"Distance = " << 
FIXED(9,3)       << D                    << endl;
 
  295      cout << 
"set_variable CAN_X_M        " << 
FIXED(7,1)       << cylinder.
getX()           << 
";" << endl;
 
  296      cout << 
"set_variable CAN_Y_M        " << 
FIXED(7,1)       << cylinder.
getY()           << 
";" << endl;
 
  297      cout << 
"set_variable CAN_ZMIN_M     " << 
FIXED(7,1)       << cylinder.
getZmin()        << 
";" << endl;
 
  298      cout << 
"set_variable CAN_ZMAX_M     " << 
FIXED(7,1)       << cylinder.
getZmax()        << 
";" << endl;
 
  299      cout << 
"set_variable CAN_RADIUS_M   " << 
FIXED(7,1)       << cylinder.
getRadius()      << 
";" << endl;
 
  300      cout << 
"set_variable CAN_DEPTH_M    " << 
FIXED(7,1)       << 
detector.getUTMZ()        << 
";" << endl;
 
  301      cout << 
"set_variable CAN_VOLUME_M3  " << 
SCIENTIFIC(12,3) << V                         << 
";" << endl;
 
  302      cout << 
"set_variable CAN_DISTANCE_M " << 
FIXED(9,3)       << D                         << 
";" << endl;
 
  305  } 
else if (option == center_t || 
 
  306             option == CENTER_t) {
 
  310    if (option == center_t) {
 
  313      cout << showpos << 
FIXED(8,3) << center.
getX() << 
' ';
 
  314      cout << showpos << 
FIXED(8,3) << center.
getY() << 
' ';
 
  315      cout << showpos << 
FIXED(8,3) << center.
getZ() << endl;
 
  319      cout << 
"set_variable CENTER_X_M " << 
FIXED(7,1) << center.
getX() << 
";" << endl;
 
  320      cout << 
"set_variable CENTER_Y_M " << 
FIXED(7,1) << center.
getY() << 
";" << endl;
 
  321      cout << 
"set_variable CENTER_Z_M " << 
FIXED(7,1) << center.
getZ() << 
";" << endl;
 
  324  } 
else if (option == summary_t ||
 
  325             option == SUMMARY_t) {
 
  327    const int numberOfStrings    = getNumberOfStrings(
detector);
 
  328    const int numberOfFloors     = getNumberOfFloors (
detector);
 
  329    const int numberOfModules    = getNumberOfModules(
detector);
 
  330    const int numberOfPMTs       = getNumberOfPMTs   (
detector);
 
  334    const JRange_t string_t(make_array(
detector.begin(), 
detector.end(), &JModule::getString));
 
  335    const JRange_t floor_t (make_array(
detector.begin(), 
detector.end(), &JModule::getFloor));
 
  340    for (JDetector::const_iterator module = 
detector.begin(); module != 
detector.end(); ++module) {
 
  341      strings.insert(module->getString());
 
  342      modules.insert(module->getID());
 
  345    if (option == summary_t) {
 
  347      cout << 
"Number of strings = " << setw(4) << numberOfStrings << endl;
 
  348      cout << 
"Number of floors  = " << setw(4) << numberOfFloors  << endl;
 
  349      cout << 
"Number of modules = " << setw(4) << numberOfModules << endl;
 
  350      cout << 
"Number of PMTs    = " << setw(4) << numberOfPMTs    << endl;
 
  351      cout << 
"First string      = " << setw(4) << string_t.first  << endl;
 
  352      cout << 
"Last  string      = " << setw(4) << string_t.second << endl;
 
  353      cout << 
"First floor       = " << setw(4) << floor_t .first  << endl;
 
  354      cout << 
"Last  floor       = " << setw(4) << floor_t .second << endl;
 
  358      cout << 
"let \"NUMBER_OF_STRINGS = " << setw(5) << numberOfStrings << 
"\";" << endl;
 
  359      cout << 
"let \"NUMBER_OF_FLOORS  = " << setw(5) << numberOfFloors  << 
"\";" << endl;
 
  360      cout << 
"let \"NUMBER_OF_MODULES = " << setw(5) << numberOfModules << 
"\";" << endl;
 
  361      cout << 
"let \"NUMBER_OF_PMTS    = " << setw(5) << numberOfPMTs    << 
"\";" << endl;
 
  362      cout << 
"let \"FIRST_STRING      = " << setw(5) << string_t.first  << 
"\";" << endl;
 
  363      cout << 
"let \"LAST_STRING       = " << setw(5) << string_t.second << 
"\";" << endl;
 
  364      cout << 
"let \"FIRST_FLOOR       = " << setw(5) << floor_t .first  << 
"\";" << endl;
 
  365      cout << 
"let \"LAST_FLOOR        = " << setw(5) << floor_t .second << 
"\";" << endl;
 
  367      copy(strings.begin(), strings.end(), ostream_iterator<int>(cout, 
" "));
 
  368      cout << 
");" << endl;
 
  370      copy(modules.begin(), modules.end(), ostream_iterator<int>(cout, 
" "));
 
  371      cout << 
");" << endl;
 
  375      for (
const auto i : strings) {
 
  376        cout << 
"typeset -A " << getString(i) << 
";"                                         << endl;
 
  379        cout << getString(i.getString()) << 
"[" << i.getFloor() << 
"]=" << i.getID() << 
";"  << endl;