示例#1
0
bool DuplicateFaceFinder::hasSimilarCoords(FaceData *f2, FaceData *f1)
{
	//  make sure feature coords are loaded
	if (!f1->getFeaturesCoords())
		f1->loadFeatureCoords(_sqlConn);
	if (!f2->getFeaturesCoords())
		f2->loadFeatureCoords(_sqlConn);

	FeaturesCoords *f1coords = f1->getFeaturesCoords();
	FeaturesCoords *f2coords = f2->getFeaturesCoords();

	bool overlap = false;
	overlap = isContainedIn(f1coords,f2coords);
	if (!overlap)
		overlap = isContainedIn(f2coords,f1coords);
	return overlap;
}
/**
 * Set algorithm properties according to the given options
 * @param alg :: [input, output] Algorithm to set properties to
 * @param options :: [input] Options to get properties from
 */
void MuonAnalysisDataLoader::setProcessAlgorithmProperties(
    IAlgorithm_sptr alg, const AnalysisOptions &options) const {
  alg->setProperty("Mode", "Analyse");
  alg->setProperty("TimeZero", options.timeZero);             // user input
  alg->setProperty("LoadedTimeZero", options.loadedTimeZero); // from file
  alg->setProperty("CropWorkspace", false);
  alg->setProperty("Xmin", options.timeLimits.first);
  double Xmax = options.timeLimits.second;
  if (Xmax != Mantid::EMPTY_DBL()) {
    alg->setProperty("Xmax", Xmax);
  }
  if (!options.rebinArgs.empty()) {
    alg->setProperty("RebinParams", options.rebinArgs);
  }

  // ---- Analysis ----

  // Find index of a name in a collection
  const auto indexOf = [](const std::string &name,
                          const std::vector<std::string> &collection) {
    return std::distance(collection.begin(),
                         std::find(collection.begin(), collection.end(), name));
  };
  if (isContainedIn(options.groupPairName, options.grouping.groupNames)) {
    // Group
    std::string outputType;
    switch (options.plotType) {
    case Muon::PlotType::Counts:
    case Muon::PlotType::Logarithm:
      outputType = "GroupCounts";
      break;
    case Muon::PlotType::Asymmetry:
      outputType = "GroupAsymmetry";
      break;
    default:
      throw std::invalid_argument(
          "Cannot create analysis workspace: Unsupported plot type");
    }
    alg->setProperty("OutputType", outputType);

    const auto groupNum =
        indexOf(options.groupPairName, options.grouping.groupNames);
    alg->setProperty("GroupIndex", static_cast<int>(groupNum));
  } else if (isContainedIn(options.groupPairName, options.grouping.pairNames)) {
    // Pair
    if (options.plotType == Muon::PlotType::Asymmetry)
      alg->setProperty("OutputType", "PairAsymmetry");
    else
      throw std::invalid_argument("Cannot create analysis workspace: Pairs "
                                  "support asymmetry plot type only");

    const auto pairNum =
        indexOf(options.groupPairName, options.grouping.pairNames);
    alg->setProperty(
        "PairFirstIndex",
        static_cast<int>(options.grouping.pairs.at(pairNum).first));
    alg->setProperty(
        "PairSecondIndex",
        static_cast<int>(options.grouping.pairs.at(pairNum).second));
    alg->setProperty("Alpha", options.grouping.pairAlphas.at(pairNum));
  } else {
    throw std::invalid_argument("Cannot create analysis workspace: Group/pair "
                                "name not found in grouping");
  }
}