Skip to content
Snippets Groups Projects
V0TriggerConfig.cxx 1.39 KiB
/* Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
   SPDX-License-Identifier: GPL-3.0-only
   Authors: Volker Friese [committer] */

#include "V0TriggerConfig.h"


namespace cbm::algo::evbuild
{

  // -----   Constructor from YAML   ------------------------------------------
  V0TriggerConfig::V0TriggerConfig(YAML::Node config)
  {
    if (!config) {
      fIsSet = false;
      return;
    }

    auto cutTime = config["max_time_diff"];
    if (!cutTime) throw std::runtime_error("time difference cut is not specified");
    fCutTime = cutTime.as<double>();

    auto cutZ = config["min_z_pca"];
    if (!cutZ) throw std::runtime_error("PCA position cut is not specified");
    fCutZ = cutZ.as<double>();

    auto cutDist = config["max_dist_at_pca"];
    if (!cutDist) throw std::runtime_error("track distance cut is not specified");
    fCutDist = cutDist.as<size_t>();

    fIsSet = true;
  }
  // --------------------------------------------------------------------------


  // -----   Save to YAML   ---------------------------------------------------
  YAML::Node V0TriggerConfig::ToYaml() const
  {
    YAML::Node result;
    result["max_time_diff"]   = fCutTime;
    result["min_z_pca"]       = fCutZ;
    result["max_dist_at_pca"] = fCutDist;
    return result;
  }
  // --------------------------------------------------------------------------


}  // namespace cbm::algo::evbuild