Project
Loading...
Searching...
No Matches
ConfigPreflight.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
13
14#include <string_view>
15#include <stdexcept>
18
21#include "Framework/Logger.h"
24
25namespace o2::its::ca
26{
27
28namespace
29{
30// This is an ITS common-CA workflow policy, not a generic tracking-parameter
31// validation. Keep the legacy namespace spelling local to the workflow that
32// rejects it, so the shared parameter library does not expose a workflow API.
33constexpr std::string_view kLegacyITSNamespace = "ITSCATrackerParam";
34} // namespace
35
36void applyConfigKeyValuesOrFatal(const std::string& configKeyValues)
37{
38 // Mirror ConfigurableParam::updateFromString()'s tokenization: split on
39 // ';', trim each token, skip empty tokens, and split at the first '='.
40 // Malformed tokens remain the configurator's responsibility.
41 const auto tokens = o2::utils::Str::tokenize(configKeyValues, ';', true);
42 for (const auto& token : tokens) {
43 const auto eq = token.find('=');
44 if (eq == std::string::npos || eq == 0 || eq == token.size() - 1) {
45 continue;
46 }
47 const auto key = token.substr(0, eq);
48 const auto dot = key.find('.');
49 const auto ns = dot == std::string::npos ? key : key.substr(0, dot);
50 if (ns == kLegacyITSNamespace) {
51 LOGP(fatal,
52 "ITS common-CA tracker workflow rejects legacy '{}' --configKeyValues override ('{}'); "
53 "use the dedicated 'ITSCommonCATrackerParam' namespace instead",
54 ns, token);
55 }
56 }
58}
59
61{
63 LOGP(fatal,
64 "ITS common-CA tracker workflow supports tracking-mode 'sync' and 'async'; '{}' is not supported",
66 }
67}
68
69VertexSource resolveVertexSource(const std::string& explicitSource, bool useDiamond, bool useTruth)
70{
71 if (!explicitSource.empty() && explicitSource != "diamond" && explicitSource != "truth") {
72 throw std::invalid_argument("--vertex-source must be diamond or truth");
73 }
74 const bool diamond = useDiamond || explicitSource == "diamond";
75 const bool truth = useTruth || explicitSource == "truth";
76 if (diamond == truth) {
77 throw std::invalid_argument(
78 "Select exactly one ITS vertex source: --vertex-source={diamond,truth}; "
79 "legacy aliases ITSCommonCATrackerParam.useDiamond and ITSVertexerParam.useTruthSeeding must agree");
80 }
82}
83
85{
86 const auto& options = context.options();
87 applyConfigKeyValuesOrFatal(options.get<std::string>("configKeyValues"));
90 result.mode = params.trackingMode == -1 ? o2::itsmft::TrackingMode::fromString(options.get<std::string>("tracking-mode"))
91 : static_cast<o2::itsmft::TrackingMode::Type>(params.trackingMode);
93 result.vertexSource = resolveVertexSource(options.get<std::string>("vertex-source"), params.useDiamond,
95 result.nThreads = params.nThreads;
96 if (result.nThreads <= 0) {
97 throw std::invalid_argument("ITSCommonCATrackerParam.nThreads must be > 0");
98 }
99 result.truthContext = options.get<std::string>("truth-context");
100 if (result.vertexSource == VertexSource::Truth && result.truthContext.empty()) {
101 throw std::invalid_argument("--truth-context must name the digitization context for --vertex-source=truth");
102 }
103 result.useMC = !options.get<bool>("disable-mc");
104 result.useFullGeometry = options.get<bool>("use-geom") || options.get<bool>("use-full-geometry");
105
106 result.writeRootOutput = !options.get<bool>("disable-root-output");
107 LOGP(info, "ITS CA resolved: mode={} threads={} vertex={} truth context={} geometry={} MC={} ROOT output={}",
109 result.vertexSource == VertexSource::Diamond ? "diamond" : "truth", result.truthContext,
110 result.useFullGeometry ? "full" : "ITS", result.useMC, result.writeRootOutput);
111 return result;
112}
113
114} // namespace o2::its::ca
Driver-level configuration and vertex-constraint preflight for the ITS common-CA tracker workflow.
StringRef key
static void updateFromString(std::string const &)
ConfigParamRegistry & options() const
GLenum mode
Definition glcorearb.h:266
GLuint64EXT * result
Definition glcorearb.h:5662
GLenum const GLfloat * params
Definition glcorearb.h:272
WorkflowOptions readWorkflowOptions(const o2::framework::ConfigContext &)
void requireSupportedTrackingModeOrFatal(o2::itsmft::TrackingMode::Type mode)
void applyConfigKeyValuesOrFatal(const std::string &configKeyValues)
VertexSource resolveVertexSource(const std::string &explicitSource, bool useDiamond, bool useTruth)
std::string toString(Type mode)
Type fromString(std::string_view str)
static std::vector< std::string > tokenize(const std::string &src, char delim, bool trimToken=true, bool skipEmpty=true)