Пример #1
0
/**
 *  Factory: DD4hep_XML-In-Memory
 *
 *  Though there is a file name given, it is read FIRST and then parsed.
 *  Similar to a in memory XML string.
 *
 *  \author  M.Frank
 *  \version 1.0
 *  \date    20/01/2018
 */
static int multiply_constants (Detector& detector, int argc, char** argv)  {
  bool help = false;
  for(int i=0; i<argc && argv[i]; ++i)  {
    if ( 0 == ::strncmp("-help",argv[i],4) )
      help = true;
    else
      help = true;
  }
  if ( help )   {
    /// Help printout describing the basic command line interface
    cout <<
      "Usage: -plugin <name> -arg [-arg]                              \n"
      "     name:   factory name     DD4hep_TestConstantsMultiplier   \n"
      "\tArguments given: " << arguments(argc,argv) << endl << flush;
    ::exit(EINVAL);
  }
  int num_test = 0;
  const auto& constants = detector.constants();
  for(const auto e : constants)  {
    Constant c = e.second;
    if ( c.dataType() == "number" )   {
      try {
        double res = _multiply(c.name(),1.0);
        printout(INFO,"TestConstantsMultiplier","+++ Constant: %-16s = %-16s [%s]  -> %-16s = %9.3g",
                 c.name(), c->GetTitle(), c.dataType().c_str(), c.name(), res);
        ++num_test;
      }
      catch(...)   {
      }
    }
  }
  printout(ALWAYS,"TestConstantsMultiplier",
           "+++ Tested %d numeric constants for expression evaluation.",num_test);
  return 1;
}