71{
   74 
   75  string         detectorFile;
   76  string         option;
   77  double         precision;
   79 
   80  try {
   81 
   82    JParser<> zap(
"Auxiliary program to print detector file in human friendly format.");
 
   83 
   86 
   87      default_t,
   88 
   89      pmts_t,
   90      modules_t,
   91      geometry_t,
   92 
   93      comment_t,
   94      header_t,
   95      version_t,
   96      identifier_t,
   97      can_t,
   98      center_t,
   99      summary_t,
  100 
  101      GEOMETRY_t,
  102      HEADER_t,
  103      VERSION_t,
  104      IDENTIFIER_t,
  105      CAN_t,
  106      CENTER_t,
  107      SUMMARY_t;
  108 
  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  
  120 
  121  try {
  123  }
  126  }
  127 
  128  if        (option == default_t) {
  129 
  131 
  132  } else if (option == modules_t) {
  133      
  135 
  136    for (JDetector::const_iterator module = 
detector.begin(); module != 
detector.end(); ++module) {
 
  137 
  138      cout << "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();
 
  146      
  147      if (module->getFloor() != 0) {
  148        {
  150 
  153 
  154          const double phi = (JVector3Z_t.getDot(q1.twist) >= 0.0 ? +1.0 : -1.0) * q1.twist.getAngle();
  155 
  156          cout << 
' ' << 
FIXED(7,2) << phi;
 
  157        }
  158        {
  161 
  162          const double phi = (JVector3Z_t.getDot(q1.twist) >= 0.0 ? +1.0 : -1.0) * q1.twist.getAngle();
  163       
  164          cout << 
' ' << 
FIXED(7,2) << phi;         
 
  165        }
  166        {
  168 
  169          const JRotation3D R = getRotation(buffer, *module);
 
  170 
  172 
  173          cout << ' ' << (JModule::compare(buffer, *module, precision) ? "==" : "!=") 
  175        }
  176      }
  177 
  178      cout << endl;
  179    }
  180    
  181  } else if (option == pmts_t) {
  182 
  184 
  185    for (JDetector::const_iterator module = 
detector.begin(); module != 
detector.end(); ++module) {
 
  186 
  188      
  189      for (size_t i = 0; i != module->size(); ++i) {
  190 
  191        const JPMT&                pmt     = 
module->getPMT(i);
 
  193 
  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();
 
  205        cout << endl;
  206      }
  207    }
  208 
  209  } else if (option == geometry_t ||
  210             option == GEOMETRY_t) {
  211 
  212    if (option == geometry_t) {
  213 
  217 
  218    } else {
  219 
  222    }
  223 
  224  } else if (option == comment_t) {
  225 
  227  
  228  } else if (option == header_t ||
  229             option == HEADER_t) {
  230 
  231    if (option == header_t) {
  232 
  233      cout << 
detector.getProperties() << endl;
 
  236                            "unknown") << endl;
  237      cout << "validity = " 
  240 
  241    } else {
  242 
  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;
 
  248    }
  249 
  250  } else if (option == version_t || 
  251             option == VERSION_t) {
  252 
  253    if (option == version_t) {
  254 
  255      cout << 
detector.getVersion() << endl;
 
  256 
  257    } else {
  258 
  259      cout << 
"set_variable DETECTOR_VERSION " << 
detector.getVersion() << 
";" << endl;
 
  260    }
  261 
  262  } else if (option == identifier_t ||
  263             option == IDENTIFIER_t) {
  264 
  265    if (option == identifier_t) {
  266 
  267      cout << 
"Detector " << 
detector.getID() << endl;
 
  268 
  269    } else {
  270 
  271      cout << 
"set_variable DETECTOR_ID      " << 
detector.getID() << 
";" << endl;
 
  272    }
  273 
  274  } else if (option == can_t ||
  275             option == CAN_t) {
  276 
  278 
  279    const double      V = (cylinder.getZmax() - cylinder.getZmin()) * PI * cylinder.getRadius() * cylinder.getRadius(); 
  281 
  282    if (option == can_t) {
  283      
  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;
 
  292 
  293    } else {
  294 
  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;
 
  303    }
  304  
  305  } else if (option == center_t || 
  306             option == CENTER_t) {
  307      
  309      
  310    if (option == center_t) {
  311 
  312      cout << "center = ";
  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;
 
  316 
  317    } else {
  318 
  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;
 
  322    }
  323    
  324  } else if (option == summary_t ||
  325             option == SUMMARY_t) {
  326      
  327    const int numberOfStrings    = getNumberOfStrings(
detector);
 
  331 
  333 
  335    const JRange_t floor_t (make_array(
detector.begin(), 
detector.end(), &JModule::getFloor));
 
  336 
  339 
  340    for (JDetector::const_iterator module = 
detector.begin(); module != 
detector.end(); ++module) {
 
  341      strings.insert(module->getString());
  342      modules.insert(module->getID());
  343    }
  344 
  345    if (option == summary_t) {
  346        
  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;
  355 
  356    } else {
  357 
  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;
  366      cout << "STRINGS=(";
  367      copy(strings.begin(), strings.end(), ostream_iterator<int>(cout, 
" "));
 
  368      cout << ");" << endl;
  369      cout << "MODULES=(";
  370      copy(modules.begin(), modules.end(), ostream_iterator<int>(cout, 
" "));
 
  371      cout << ");" << endl;
  372 
  373      
  374 
  375      for (const auto i : strings) {
  376        cout << 
"typeset -A " << 
getString(i) << 
";"                                         << endl;
 
  377      }
  379        cout << 
getString(i.getString()) << 
"[" << i.getFloor() << 
"]=" << i.getID() << 
";"  << endl;
 
  380      }
  381    }
  382  }
  383}
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
 
double getT0() const
Get time offset.
 
Lookup table for PMT addresses in detector.
 
const JModuleAddressMap & get(const int id) const
Get module address map.
 
virtual const JModuleAddressMap & getDefaultModuleAddressMap() const =0
Get default module address map.
 
Lookup table for PMT addresses in optical module.
 
const JPMTPhysicalAddress & getPMTPhysicalAddress(const int tdc) const
Get PMT physical address.
 
Data structure for a composite optical module.
 
void rotate(const JRotation3D &R)
Rotate module.
 
Data structure for PMT physical address.
 
Data structure for PMT geometry, calibration and status.
 
Data structure for unit quaternion in three dimensions.
 
double getY() const
Get y position.
 
double getZ() const
Get z position.
 
double getX() const
Get x position.
 
double getDY() const
Get y direction.
 
double getDX() const
Get x direction.
 
double getDZ() const
Get z direction.
 
int getID() const
Get identifier.
 
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.
 
JDetectorAddressMap & getDetectorAddressMap()
Get detector address map.
 
int getNumberOfModules(const JDetector &detector, const bool option=false)
Get number of modules.
 
double getMinimalDistance(const JDetector &detector)
Get minimal distance between modules in detector.
 
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 sequence of same character.
 
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.
 
int getStatus() const
Get status.
 
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.