70{
   73 
   74  string         detectorFile;
   75  string         option;
   76  double         precision;
   78 
   79  try {
   80 
   81    JParser<> zap(
"Auxiliary program to print detector file in human friendly format.");
 
   82 
   85 
   86      default_t,
   87 
   88      pmts_t,
   89      modules_t,
   90      geometry_t,
   91 
   92      comment_t,
   93      header_t,
   94      version_t,
   95      identifier_t,
   96      can_t,
   97      center_t,
   98      summary_t,
   99 
  100      HEADER_t,
  101      VERSION_t,
  102      IDENTIFIER_t,
  103      CAN_t,
  104      CENTER_t,
  105      SUMMARY_t;
  106 
  107    zap[
'p'] = 
make_field(precision,    
"precision for match with reference module") = 1.0e-5;
 
  109 
  110    zap(argc, argv);
  111  }
  112  catch(const exception &error) {
  113    FATAL(error.what() << endl);
 
  114  }
  115 
  116  
  118 
  119  try {
  121  }
  124  }
  125 
  126  if        (option == default_t) {
  127 
  129 
  130  } else if (option == modules_t) {
  131      
  133 
  134    for (JDetector::const_iterator module = 
detector.begin(); module != 
detector.end(); ++module) {
 
  135 
  136      cout << "Module";
  137      cout << ' ' << noshowpos << setw(8) << right << module->getID();
  138      cout << ' ' << noshowpos << setw(3) << right << module->getString();
  139      cout << ' ' << noshowpos << setw(2) << right << module->getFloor();
  140      cout << 
' ' << 
FIXED(7,2) << module->getX();
 
  141      cout << 
' ' << 
FIXED(7,2) << module->getY();
 
  142      cout << 
' ' << 
FIXED(7,2) << module->getZ();
 
  143      cout << 
' ' << 
FIXED(8,2) << module->getT0();
 
  144      
  145      if (module->getFloor() != 0) {
  146        {
  148 
  151 
  152          const double phi = (JVector3Z_t.getDot(q1.twist) >= 0.0 ? +1.0 : -1.0) * q1.twist.getAngle();
  153 
  154          cout << 
' ' << 
FIXED(7,2) << phi;
 
  155        }
  156        {
  159 
  160          const double phi = (JVector3Z_t.getDot(q1.twist) >= 0.0 ? +1.0 : -1.0) * q1.twist.getAngle();
  161       
  162          cout << 
' ' << 
FIXED(7,2) << phi;         
 
  163        }
  164        {
  166 
  167          const JRotation3D R = getRotation(buffer, *module);
 
  168 
  170 
  171          cout << ' ' << (JModule::compare(buffer, *module, precision) ? "==" : "!=") 
  173        }
  174      }
  175 
  176      cout << endl;
  177    }
  178    
  179  } else if (option == pmts_t) {
  180          
  181    for (JDetector::const_iterator module = 
detector.begin(); module != 
detector.end(); ++module) {
 
  182      for (JModule::const_iterator pmt = module->begin(); pmt != module->end(); ++pmt) {
  183        cout << "PMT";
  184        cout << ' ' << noshowpos << setw(8) << right << pmt->getID();
  185        cout << 
' ' << 
FIXED(7,2) << pmt->getX();
 
  186        cout << 
' ' << 
FIXED(7,2) << pmt->getY();
 
  187        cout << 
' ' << 
FIXED(7,2) << pmt->getZ();
 
  188        cout << 
' ' << 
FIXED(6,3) << pmt->getDX();
 
  189        cout << 
' ' << 
FIXED(6,3) << pmt->getDY();
 
  190        cout << 
' ' << 
FIXED(6,3) << pmt->getDZ();
 
  191        cout << 
' ' << 
FIXED(8,2) << pmt->getT0();
 
  192        cout << ' ' << noshowpos << setw(8) << right << pmt->getStatus();
  193        cout << endl;
  194      }
  195    }
  196 
  197  } else if (option == geometry_t) {
  198 
  201  
  202  } else if (option == comment_t) {
  203 
  205  
  206  } else if (option == header_t ||
  207             option == HEADER_t) {
  208 
  209    if (option == header_t) {
  210 
  211      cout << 
detector.getProperties() << endl;
 
  214                            "unknown") << endl;
  215      cout << "validity = " 
  218 
  219    } else {
  220 
  221      cout << 
"set_variable UTM_EAST         " << 
FIXED(12,2) << 
detector.getUTMEast()  << 
";" << endl;
 
  222      cout << 
"set_variable UTM_NORTH        " << 
FIXED(12,2) << 
detector.getUTMNorth() << 
";" << endl;
 
  223      cout << 
"set_variable UTM_Z            " << 
FIXED(12,2) << 
detector.getUTMZ()     << 
";" << endl;
 
  224      cout << 
"set_variable UTM_ZONE         " << 
FIXED(12,2) << 
detector.getUTMZone()  << 
";" << endl;
 
  225      cout << 
"set_variable UTM_WGS          " << 
FIXED(12,2) << 
detector.getWGS()      << 
";" << endl;
 
  226    }
  227 
  228  } else if (option == version_t || 
  229             option == VERSION_t) {
  230 
  231    if (option == version_t) {
  232 
  233      cout << 
detector.getVersion() << endl;
 
  234 
  235    } else {
  236 
  237      cout << 
"set_variable DETECTOR_VERSION " << 
detector.getVersion() << 
";" << endl;
 
  238    }
  239 
  240  } else if (option == identifier_t ||
  241             option == IDENTIFIER_t) {
  242 
  243    if (option == identifier_t) {
  244 
  245      cout << 
"Detector " << 
detector.getID() << endl;
 
  246 
  247    } else {
  248 
  249      cout << 
"set_variable DETECTOR_ID      " << 
detector.getID() << 
";" << endl;
 
  250    }
  251 
  252  } else if (option == can_t ||
  253             option == CAN_t) {
  254 
  256 
  257    const double      V = (cylinder.getZmax() - cylinder.getZmin()) * PI * cylinder.getRadius() * cylinder.getRadius(); 
  259 
  260    if (option == can_t) {
  261      
  262      cout << 
"X        = " << 
FIXED(7,1)       << cylinder.getX()      << endl;
 
  263      cout << 
"Y        = " << 
FIXED(7,1)       << cylinder.getY()      << endl;
 
  264      cout << 
"Zmin     = " << 
FIXED(7,1)       << cylinder.getZmin()   << endl;
 
  265      cout << 
"Zmax     = " << 
FIXED(7,1)       << cylinder.getZmax()   << endl;
 
  266      cout << 
"Radius   = " << 
FIXED(7,1)       << cylinder.getRadius() << endl;
 
  267      cout << 
"Depth    = " << 
FIXED(7,1)       << 
detector.getUTMZ()   << endl;
 
  268      cout << 
"Volume   = " << 
SCIENTIFIC(12,3) << V                    << endl;
 
  269      cout << 
"Distance = " << 
FIXED(9,3)       << D                    << endl;
 
  270 
  271    } else {
  272 
  273      cout << 
"set_variable CAN_X_M        " << 
FIXED(7,1)       << cylinder.getX()           << 
";" << endl;
 
  274      cout << 
"set_variable CAN_Y_M        " << 
FIXED(7,1)       << cylinder.getY()           << 
";" << endl;
 
  275      cout << 
"set_variable CAN_ZMIN_M     " << 
FIXED(7,1)       << cylinder.getZmin()        << 
";" << endl;
 
  276      cout << 
"set_variable CAN_ZMAX_M     " << 
FIXED(7,1)       << cylinder.getZmax()        << 
";" << endl;
 
  277      cout << 
"set_variable CAN_RADIUS_M   " << 
FIXED(7,1)       << cylinder.getRadius()      << 
";" << endl;
 
  278      cout << 
"set_variable CAN_DEPTH_M    " << 
FIXED(7,1)       << 
detector.getUTMZ()        << 
";" << endl;
 
  279      cout << 
"set_variable CAN_VOLUME_M3  " << 
SCIENTIFIC(12,3) << V                         << 
";" << endl;
 
  280      cout << 
"set_variable CAN_DISTANCE_M " << 
FIXED(9,3)       << D                         << 
";" << endl;
 
  281    }
  282  
  283  } else if (option == center_t || 
  284             option == CENTER_t) {
  285      
  287      
  288    if (option == center_t) {
  289 
  290      cout << "center = ";
  291      cout << showpos << 
FIXED(8,3) << center.getX() << 
' ';
 
  292      cout << showpos << 
FIXED(8,3) << center.getY() << 
' ';
 
  293      cout << showpos << 
FIXED(8,3) << center.getZ() << endl;
 
  294 
  295    } else {
  296 
  297      cout << 
"set_variable CENTER_X_M " << 
FIXED(7,1) << center.getX() << 
";" << endl;
 
  298      cout << 
"set_variable CENTER_Y_M " << 
FIXED(7,1) << center.getY() << 
";" << endl;
 
  299      cout << 
"set_variable CENTER_Z_M " << 
FIXED(7,1) << center.getZ() << 
";" << endl;
 
  300    }
  301    
  302  } else if (option == summary_t ||
  303             option == SUMMARY_t) {
  304      
  305    const int numberOfStrings    = getNumberOfStrings(
detector);
 
  309 
  311 
  313    const JRange_t floor_t (make_array(
detector.begin(), 
detector.end(), &JModule::getFloor));
 
  314 
  317 
  318    for (JDetector::const_iterator module = 
detector.begin(); module != 
detector.end(); ++module) {
 
  319      strings.insert(module->getString());
  320      modules.insert(module->getID());
  321    }
  322 
  323    if (option == summary_t) {
  324        
  325      cout << "Number of strings = " << setw(4) << numberOfStrings << endl;
  326      cout << "Number of floors  = " << setw(4) << numberOfFloors  << endl;
  327      cout << "Number of modules = " << setw(4) << numberOfModules << endl;
  328      cout << "Number of PMTs    = " << setw(4) << numberOfPMTs    << endl;
  329      cout << 
"First string      = " << setw(4) << 
string_t.first  << endl;
 
  330      cout << 
"Last  string      = " << setw(4) << 
string_t.second << endl;
 
  331      cout << "First floor       = " << setw(4) << floor_t .first  << endl;
  332      cout << "Last  floor       = " << setw(4) << floor_t .second << endl;
  333 
  334    } else {
  335 
  336      cout << "let \"NUMBER_OF_STRINGS = " << setw(5) << numberOfStrings << "\";" << endl;
  337      cout << "let \"NUMBER_OF_FLOORS  = " << setw(5) << numberOfFloors  << "\";" << endl;
  338      cout << "let \"NUMBER_OF_MODULES = " << setw(5) << numberOfModules << "\";" << endl;
  339      cout << "let \"NUMBER_OF_PMTS    = " << setw(5) << numberOfPMTs    << "\";" << endl;
  340      cout << 
"let \"FIRST_STRING      = " << setw(5) << 
string_t.first  << 
"\";" << endl;
 
  341      cout << 
"let \"LAST_STRING       = " << setw(5) << 
string_t.second << 
"\";" << endl;
 
  342      cout << "let \"FIRST_FLOOR       = " << setw(5) << floor_t .first  << "\";" << endl;
  343      cout << "let \"LAST_FLOOR        = " << setw(5) << floor_t .second << "\";" << endl;
  344      cout << "STRINGS=(";
  345      copy(strings.begin(), strings.end(), ostream_iterator<int>(cout, 
" "));
 
  346      cout << ");" << endl;
  347      cout << "MODULES=(";
  348      copy(modules.begin(), modules.end(), ostream_iterator<int>(cout, 
" "));
 
  349      cout << ");" << endl;
  350 
  351      
  352 
  353      for (const auto i : strings) {
  354        cout << 
"typeset -A " << 
getString(i) << 
";"                                         << endl;
 
  355      }
  357        cout << 
getString(i.getString()) << 
"[" << i.getFloor() << 
"]=" << i.getID() << 
";"  << endl;
 
  358      }
  359    }
  360  }
  361}
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
 
const JModuleAddressMap & get(const int id) const
Get module address map.
 
virtual const JModuleAddressMap & getDefaultModuleAddressMap() const =0
Get default module address map.
 
Data structure for a composite optical module.
 
void rotate(const JRotation3D &R)
Rotate module.
 
Data structure for unit quaternion in three dimensions.
 
Utility class to parse command line options.
 
void copy(const Head &from, JHead &to)
Copy header from from to to.
 
JMODEL::JString getString(const JFit &fit)
Get model parameters of string.
 
const char *const string_t
routing by string
 
int getNumberOfPMTs(const JModule &module)
Get number of PMTs.
 
int getNumberOfFloors(const JDetector &detector)
Get number of floors.
 
JDetectorBuilder & getDetectorBuilder()
Get detector builder.
 
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
 
bool isORCADetector(const JDetectorHeader &header)
Check if given detector header is compatible with that of ORCA.
 
bool isARCADetector(const JDetectorHeader &header)
Check if given detector header is compatible with tat of ARCA.
 
int getNumberOfModules(const JDetector &detector, const bool option=false)
Get number of modules.
 
double getMaximalDistance(const JDetector &detector, const bool option=false)
Get maximal distance between modules in detector.
 
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
 
double getMaximalTime(const double R_Hz)
Get maximal time for given rate.
 
Auxiliary data structure for floating point format specification.
 
Auxiliary interface for building detector.
 
const JModule & getModule(const int id=-1, const JLocation &location=JLocation()) const
Get module.
 
Auxiliary data structure for decomposition of quaternion in twist and swing quaternions.
 
Auxiliary class for date and time.
 
std::string toString() const
Get ASCII formatted date and time.
 
Auxiliary data structure for floating point format specification.