Project
Loading...
Searching...
No Matches
ConfigParamRegistry.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.
13#include "Framework/Array2D.h"
14
15#include <string_view>
16#include <type_traits>
17
18namespace o2::framework
19{
20
21ConfigParamRegistry::ConfigParamRegistry(std::unique_ptr<ConfigParamStore> store)
22 : mStore{std::move(store)}
23{
24}
25
26bool ConfigParamRegistry::isSet(const char* key) const
27{
28 return mStore->store().count(key);
29}
30
31bool ConfigParamRegistry::hasOption(const char* key) const
32{
33 return mStore->store().get_child_optional(key).is_initialized();
34}
35
36bool ConfigParamRegistry::isDefault(const char* key) const
37{
38 return mStore->store().count(key) > 0 && mStore->provenance(key) != "default";
39}
40
41namespace
42{
43template <SimpleConfigValueType T>
44T getImpl(boost::property_tree::ptree const& tree, const char* key)
45{
46 return tree.get<T>(key);
47}
48
49template <StringConfigValueType T>
50T getImpl(boost::property_tree::ptree const& tree, const char* key)
51{
52 return tree.get<std::string>(key);
53}
54
55template <typename T>
57auto getImpl(boost::property_tree::ptree const& tree, const char* key)
58{
59 return o2::framework::vectorFromBranch<typename T::value_type>(tree.get_child(key));
60}
61
62template <Array2DLike T>
63auto getImpl(boost::property_tree::ptree& tree, const char* key)
64{
65 return array2DFromBranch<typename T::element_t>(tree.get_child(key));
66}
67
68template <LabeledArrayLike T>
69auto getImpl(boost::property_tree::ptree& tree, const char* key)
70{
71 return labeledArrayFromBranch<typename T::element_t>(tree.get_child(key));
72}
73
74// ptree::erase only removes direct children, so the parent of a nested key has to be looked up first
75void eraseImpl(boost::property_tree::ptree& tree, std::string_view key)
76{
77 auto pos = key.rfind('.');
78 if (pos == std::string_view::npos) {
79 tree.erase(std::string(key));
80 return;
81 }
82 if (auto parent = tree.get_child_optional(std::string(key.substr(0, pos)))) {
83 parent->erase(std::string(key.substr(pos + 1)));
84 }
85}
86} // namespace
87
88template <ConfigValueType T>
89T ConfigParamRegistry::get(const char* key) const
90{
91 try {
92 return getImpl<T>(this->mStore->store(), key);
93 } catch (std::exception& e) {
94 throw std::invalid_argument(std::string("missing option: ") + key + " (" + e.what() + ")");
95 } catch (...) {
96 throw std::invalid_argument(std::string("error parsing option: ") + key);
97 }
98}
99
100void ConfigParamRegistry::override(const char* key, ConfigValueType auto const& val) const
101{
102 using T = std::decay_t<decltype(val)>;
103 try {
104 auto& store = mStore->store();
106 store.put(key, val);
107 } else if constexpr (VectorConfigValueType<T>) {
108 // arrays are stored as subtrees, which have to be replaced as a whole
109 store.put_child(key, vectorToBranch(val.data(), val.size()));
110 } else if constexpr (Array2DLike<T>) {
111 store.put_child(key, array2DToBranch(T(val)));
112 } else if constexpr (LabeledArrayLike<T>) {
113 store.put_child(key, labeledArrayToBranch(T(val)));
114 }
115 } catch (std::exception& e) {
116 throw std::invalid_argument(std::string("failed to store an option: ") + key + " (" + e.what() + ")");
117 } catch (...) {
118 throw std::invalid_argument(std::string("failed to store an option: ") + key);
119 }
120}
121
122void ConfigParamRegistry::erase(const char* key) const
123{
124 eraseImpl(mStore->store(), key);
125 eraseImpl(mStore->provenanceTree(), key);
126}
127
128// Load extra parameters discovered while we process data
129void ConfigParamRegistry::loadExtra(std::vector<ConfigParamSpec>& extras)
130{
131 mStore->load(extras);
132}
133
134[[nodiscard]] std::vector<ConfigParamSpec> const& ConfigParamRegistry::specs() const
135{
136 return mStore->specs();
137}
138
139template int8_t ConfigParamRegistry::get<int8_t>(const char* key) const;
140template short ConfigParamRegistry::get<short>(const char* key) const;
141template int ConfigParamRegistry::get<int>(const char* key) const;
142template long ConfigParamRegistry::get<long>(const char* key) const;
143template long long ConfigParamRegistry::get<long long>(const char* key) const;
144template uint8_t ConfigParamRegistry::get<uint8_t>(const char* key) const;
145template uint16_t ConfigParamRegistry::get<uint16_t>(const char* key) const;
146template unsigned long ConfigParamRegistry::get<unsigned long>(const char* key) const;
147template unsigned long long ConfigParamRegistry::get<unsigned long long>(const char* key) const;
148template unsigned int ConfigParamRegistry::get<unsigned int>(const char* key) const;
149template LabeledArray<std::string> ConfigParamRegistry::get<LabeledArray<std::string>>(const char* key) const;
150template LabeledArray<double> ConfigParamRegistry::get<LabeledArray<double>>(const char* key) const;
151template LabeledArray<float> ConfigParamRegistry::get<LabeledArray<float>>(const char* key) const;
152template LabeledArray<int> ConfigParamRegistry::get<LabeledArray<int>>(const char* key) const;
153template Array2D<std::string> ConfigParamRegistry::get<Array2D<std::string>>(const char* key) const;
154template Array2D<double> ConfigParamRegistry::get<Array2D<double>>(const char* key) const;
155template Array2D<float> ConfigParamRegistry::get<Array2D<float>>(const char* key) const;
156template Array2D<int> ConfigParamRegistry::get<Array2D<int>>(const char* key) const;
157template std::vector<std::string> ConfigParamRegistry::get<std::vector<std::string>>(const char* key) const;
158template std::vector<double> ConfigParamRegistry::get<std::vector<double>>(const char* key) const;
159template std::vector<float> ConfigParamRegistry::get<std::vector<float>>(const char* key) const;
160template std::vector<int> ConfigParamRegistry::get<std::vector<int>>(const char* key) const;
161template float ConfigParamRegistry::get<float>(const char* key) const;
162template double ConfigParamRegistry::get<double>(const char* key) const;
163template std::string ConfigParamRegistry::get<std::string>(const char* key) const;
164template bool ConfigParamRegistry::get<bool>(const char* key) const;
165
166template void ConfigParamRegistry::override(const char* key, int8_t const&) const;
167template void ConfigParamRegistry::override(const char* key, int16_t const&) const;
168template void ConfigParamRegistry::override(const char* key, int32_t const&) const;
169template void ConfigParamRegistry::override(const char* key, int64_t const&) const;
170template void ConfigParamRegistry::override(const char* key, uint8_t const&) const;
171template void ConfigParamRegistry::override(const char* key, uint16_t const&) const;
172template void ConfigParamRegistry::override(const char* key, uint32_t const&) const;
173template void ConfigParamRegistry::override(const char* key, uint64_t const&) const;
174template void ConfigParamRegistry::override(const char* key, float const&) const;
175template void ConfigParamRegistry::override(const char* key, double const&) const;
176template void ConfigParamRegistry::override(const char* key, std::string const&) const;
177template void ConfigParamRegistry::override(const char* key, bool const&) const;
178
179template void ConfigParamRegistry::override(char const* key, LabeledArray<std::string> const&) const;
180template void ConfigParamRegistry::override(char const* key, LabeledArray<double> const&) const;
181template void ConfigParamRegistry::override(char const* key, LabeledArray<float> const&) const;
182template void ConfigParamRegistry::override(char const* key, LabeledArray<int> const&) const;
183template void ConfigParamRegistry::override(char const* key, Array2D<std::string> const&) const;
184template void ConfigParamRegistry::override(char const* key, Array2D<double> const&) const;
185template void ConfigParamRegistry::override(char const* key, Array2D<float> const&) const;
186template void ConfigParamRegistry::override(char const* key, Array2D<int> const&) const;
187template void ConfigParamRegistry::override(char const* key, std::vector<std::string> const&) const;
188template void ConfigParamRegistry::override(char const* key, std::vector<double> const&) const;
189template void ConfigParamRegistry::override(char const* key, std::vector<float> const&) const;
190template void ConfigParamRegistry::override(char const* key, std::vector<int> const&) const;
191} // namespace o2::framework
unsigned short int uint16_t
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events Show standalone event Run event generator maximum time bin of continuous for triggered for automatic continuous for automatic continuous triggered uint64_t
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char e
configStandalone Reconstruction rec_tpc multiplier for the combined cluster track error during track following area in cm for the search of for z only used if decrease removal by when above this local occupancy rowx Shift of TPC revert cluster flag edge bit distance to edge exceeds this ZOffset for secondary multiple of radius max P of electron K BB bands crossing max P of electron p BB bands crossing max P of electron d BB bands crossing max P of electron t BB bands crossing min accepted dEdxMaxTPC of the track Additive extra cluster error for Y2 if edge flag set Additive extra cluster error for Y2 if single set Additive extra cluster error for Y2 if or single set Additive extra cluster error for Z2 if or single set Extra errors to add to track when crossing depending on addErrorsCECrossing Inner portion of y range in sector that is not used in searching for extrapolated track candidates factor2YS for track merging factor2K for track merging Margin in cm of Y position when rejecting edge clusters based on uncorrected track Y Max fraction of shared clusters for tracklet Except pad from cluster finding if total number of charges in a fragment is above this Except pad from cluster finding if number of consecutive charges in a fragment is above this Threshold where a timebin is considered disabling the noisy pad check for that pad Treat signal above this minimum as saturated Smoothing factor for the exponential Highly Ionising Particle tail filter Number of timebins to use for the averaging Add additional custom track errors when crossing relative as fraction of Do N fit passes in final fit of< 0:reject at max -n hits") AddOptionRTC(rejectIFCLowRadiusCluster, uint8_t, 1, "", 0, "Reject clusters that get the IFC mask error during refit") AddOptionRTC(dEdxTruncLow, uint8_t, 2, "", 0, "Low truncation threshold, fraction of 128") AddOptionRTC(dEdxTruncHigh, uint8_t, 77, "", 0, "High truncation threshold, fraction of 128") AddOptionRTC(extrapolationTracking, int8_t, 1, "", 0, "Enable Extrapolation Tracking(prolong tracks to adjacent sectors to find short segments)") AddOptionRTC(disableRefitAttachment, uint8_t, 0, "", 0, "Bitmask to disable certain attachment steps during refit(1:attachment, 2:propagation, 4:loop following, 8:mirroring)") AddOptionRTC(rejectionStrategy, uint8_t, o2::gpu::GPUSettings::RejectionStrategyA, "", 0, "Enable rejection of TPC clusters for compression(0=no, 1=strategy A, 2=strategy B)") AddOptionRTC(mergeLoopersAfterburner, uint8_t, 1, "", 0, "Run afterburner for additional looper merging") AddOptionRTC(compressionTypeMask, uint8_t, o2::gpu::GPUSettings::CompressionFull, "", 0, "TPC Compression mode bits(1=truncate charge/width LSB, 2=differences, 4=track-model)") AddOptionRTC(compressionSortOrder, uint8_t, o2::gpu::GPUSettings::SortTime, "", 0, "Sort order of TPC compression(0=time, 1=pad, 2=Z-time-pad, 3=Z-pad-time, 4=no sorting(use incoming order))") AddOptionRTC(sigBitsCharge, uint8_t, 4, "", 0, "Number of significant bits for TPC cluster charge in compression mode 1") AddOptionRTC(sigBitsWidth, uint8_t, 3, "", 0, "Number of significant bits for TPC cluster width in compression mode 1") AddOptionRTC(dropLoopers, uint8_t, 0, "", 0, "Drop looping tracks starting from second loop") AddOptionRTC(mergerInterpolateErrors, uint8_t, 1, "", 0, "Use interpolation instead of extrapolation for chi2 based cluster rejection") AddOptionRTC(mergerInterpolateRejectAlsoOnCurrentPosition, uint8_t, 1, "", 0, "When using mergerInterpolateErrors, reject based on chi2 twice computed with interpolated and current track position starting from NDF > mergerNonInterpolateRejectMinNDF Merge tracks accross the central electrode Enable PID response Add sub threshold clusters in TPC dEdx computation OR mask of TPC flags that will reject the cluster in alternative dEdx Reject edge clusters based on uncorrected track Y during track fit Increase decrease removal by when on this number of pads from the edge h configStandalone Reconstruction rec_trd Max chi2 for TRD tracklets to be matched to a track Chi2 cut for strict matching mode Number of sigmas for ITS TPC track time error estimate Addition to search road around track prolongation along Y in cm Optimal tracklet rphi resolution in maximum chi2 per attached tracklet for TRD tracks take into account the full likelihood of the slope including exponential tails Tracks with less attached tracklets are discarded after the tracking Post trigger Pile up integration time in BCs fits all iterations but the last one in projections Use material lookup table for TPC refit Apply workarounds to avoid cyclic merge should not be needed tpc dyn configStandalone Processing proc_rtc Replace constant variables static by constexpr expressions Compile RTC in deterministic with NO_FAST_MATH flags and GPUCA_DETERMINISTIC_MODE define Use RTC to optimize GPU code h configStandalone Processing proc_rtctech Use a file lock to serialize access to the cache folder int32_t
uint16_t pos
Definition RawData.h:3
StringRef key
void loadExtra(std::vector< ConfigParamSpec > &extras)
ConfigParamRegistry(std::unique_ptr< ConfigParamStore > store)
bool isDefault(const char *key) const
bool hasOption(const char *key) const
void override(const char *key, ConfigValueType auto const &val) const
std::vector< ConfigParamSpec > const & specs() const
GLuint GLfloat * val
Definition glcorearb.h:1582
Defining ITS Vertex explicitly as messageable.
Definition Cartesian.h:288
boost::property_tree::ptree labeledArrayToBranch(LabeledArray< T > &&array)
boost::property_tree::ptree array2DToBranch(Array2D< T > &&array)
boost::property_tree::ptree vectorToBranch(T const *values, size_t size)
std::unique_ptr< TTree > tree((TTree *) flIn.Get(std::string(o2::base::NameConf::CTFTREENAME).c_str()))