void Run()
    {
        const RangeMultiD param_range({ args.range_x(), args.range_y() });
        Range m_H_range;
        const auto& limits = ReadInterpolatedLimits(args.input(), m_H_range, args.units());
        const auto model_reader = ModelReaderFactory::Make(args.model_file(), args.model_file_version());
        const auto model = ModelFactory::Make(args.model(), model_reader);
        std::vector<double> x_list, y_list, z_list_pred;
        std::vector<std::vector<double>> z_list(limits.size());

        for(const auto& desc : model->GetAvailablePoints()) {
            if(!param_range.Contains(desc.point)) continue;
            const double th_predicted = std::max(desc.GetProcessBR_CS(args.process()), 0.0);
            const double m_H = desc.GetMass(Particle::H);
            if(!m_H_range.Contains(m_H) || !th_predicted) continue;
            x_list.push_back(desc.point.at(0));
            y_list.push_back(desc.point.at(1));
            z_list_pred.push_back(th_predicted);
            for(size_t n = 0; n < limits.size(); ++n) {
                const double r = limits.at(n)->Eval(m_H) / th_predicted;
                z_list.at(n).push_back(r);
            }
        }

        const auto ref_hist = model_reader->GetReferenceHistogram();
        auto output_file = root_ext::CreateRootFile(args.output());
        for(size_t n = 0; n < limits.size(); ++n)
            CreateOutput(x_list, y_list, z_list.at(n), output_file, all_limit_quantile_names.at(n), ref_hist,
                         1.0, 0.05, 1.0);
        CreateOutput(x_list, y_list, z_list_pred, output_file, "predicted_CS_BR", ref_hist);

        std::cout << "File '" << args.output() << "' successfully created.\n";
    }
Example #2
0
void repl_init() {
  char input[INPUT_SIZE] = "";
  printf("%s", ">>> ");
  init_system();
  symboltable_t* context = newSymbolTable();
  while (EXIT_STATUS == 0 && fgets(input, INPUT_SIZE, stdin)) {

    list_t* expressions = parse(input)->value->value.l;
    object_t* value = eval(expressions, context);
    object_t* o = z_list();
    z_conj(o->value->value.l, value);
    z_println(o->value->value.l);
    free(expressions);

    if (EXIT_STATUS == 0) {
      printf("%s", ">>> ");
    }
  }
}
Example #3
0
object_t* z_print(list_t* args) {
  object_t* obj = newObject();
  object_t* o = z_first(args);
  struct atom *atom;
  if(o == NULL) {
    printf("undefined");
    return obj;
  }

  switch(o->value->type) {
    case Int:
      printf("%d", o->value->value.i);
      return obj;
    case Float:
      printf("%f", o->value->value.f);
      return obj;
    case Char:
      printf("%c", o->value->value.c);
      return obj;
    case String:
      printf("%s",o->value->value.s);
      return obj;
    case Bool:
      if(o->value->value.b) {
        printf("True");
      } else {
        printf("False");
      }
      return obj;
    case List:
      atom = o->value->value.l->head;
      printf("( ");
      while (atom != NULL) {
        object_t *l = z_list();
        z_conj(l->value->value.l, atom->value);
        z_print(l->value->value.l);
        printf(" ");
        atom = atom->next;
      }
      printf(")");
      return obj;
    case Exception:
      printf("<Exception Object>");
      return obj;
    case Function:
      if (o->value->value.function->body != NULL) {
        printf("<Function Object> ( %s ", o->value->value.function->name);
        atom = o->value->value.function->args->head;
        printf("( ");
        while (atom != NULL) {
          object_t *l = z_list();
          z_conj(l->value->value.l, atom->value);
          z_print(l->value->value.l);
          printf(" ");
          atom = atom->next;
        }
        printf(") ");
        atom = o->value->value.function->body->head;
        printf("( ");
        while (atom != NULL) {
          object_t *l = z_list();
          z_conj(l->value->value.l, atom->value);
          z_print(l->value->value.l);
          printf(" ");
          atom = atom->next;
        }
        printf(") )");
      } else {
        printf("<Native Function Object>");
      }
      return obj;
    case FunctionReference:
      printf("%s",o->value->value.s);
      return obj;
    case Symbol:
      printf("%s", o->value->value.s);
      return obj;
  }
  printf("<object> @ %d", o->id);
}