20#define BOOST_BIND_GLOBAL_PLACEHOLDERS
21#include <boost/algorithm/string/predicate.hpp>
22#include <boost/property_tree/ptree.hpp>
23#include <boost/property_tree/ini_parser.hpp>
24#include <boost/property_tree/json_parser.hpp>
25#include <boost/tokenizer.hpp>
26#include <boost/lexical_cast.hpp>
42#include <fairlogger/Logger.h>
45#include "TDataMember.h"
49#include "TEnumConstant.h"
52#include <unordered_map>
54#include <unordered_set>
63std::vector<ConfigurableParam*>* ConfigurableParam::sRegisteredParamClasses =
nullptr;
64boost::property_tree::ptree* ConfigurableParam::sPtree =
nullptr;
70bool ConfigurableParam::sIsFullyInitialized =
false;
71bool ConfigurableParam::sRegisterMode =
true;
75std::map<std::string, std::string> sKeyToContainerTypeMap;
87bool keyInTree(boost::property_tree::ptree* pt,
const std::string&
key)
89 if (
key.size() == 0 || pt ==
nullptr) {
94 reply = pt->get_optional<std::string>(
key).is_initialized();
95 }
catch (std::exception
const&
e) {
96 LOG(
error) <<
"ConfigurableParam: Exception when checking for key " <<
key <<
" : " <<
e.what();
104 if (
type ==
typeid(
float)) {
107 if (
type ==
typeid(
long double)) {
110 if (
type ==
typeid(
unsigned int)) {
113 if (
type ==
typeid(
unsigned long)) {
116 if (
type ==
typeid(
long long)) {
119 if (
type ==
typeid(
unsigned long long)) {
128struct ContainerHandler {
135struct ContainerHandlerRegistry {
136 std::map<std::string, ContainerHandler>
byName;
137 std::map<std::type_index, ContainerHandler>
byType;
141struct IsUnorderedSet : std::false_type {
144template <
typename T,
typename Hash,
typename KeyEqual,
typename Allocator>
145struct IsUnorderedSet<
std::unordered_set<T, Hash, KeyEqual, Allocator>> : std::true_type {
149struct IsUnorderedMap : std::false_type {
152template <
typename Key,
typename T,
typename Hash,
typename KeyEqual,
typename Allocator>
153struct IsUnorderedMap<
std::unordered_map<Key, T, Hash, KeyEqual, Allocator>> : std::true_type {
156std::string normalizeContainerTypeName(std::string typeName)
159 for (
size_t pos = typeName.find(
"std::");
pos != std::string::npos;
pos = typeName.find(
"std::",
pos)) {
160 typeName.erase(
pos, 5);
164 bool pendingSpace =
false;
165 for (
char c : typeName) {
166 if (std::isspace(
static_cast<unsigned char>(
c))) {
167 if (!out.empty() && out.back() !=
'<' && out.back() !=
',') {
172 if ((
c ==
',' ||
c ==
'>') && !out.empty() && out.back() ==
' ') {
175 if (pendingSpace &&
c !=
',' &&
c !=
'>' && !out.empty() && out.back() !=
'<' && out.back() !=
',') {
179 pendingSpace =
false;
187#define REGISTER_SCALAR_NAME(TYPE, NAME) \
189 struct TypeName<TYPE> { \
190 static constexpr const char* value = NAME; \
209#undef REGISTER_SCALAR_NAME
212std::string scalarAsString(
const T&
value)
214 if constexpr (std::is_same_v<T, bool>) {
215 return value ?
"1" :
"0";
216 }
else if constexpr (std::is_same_v<T, char> || std::is_same_v<T, signed char>) {
218 }
else if constexpr (std::is_same_v<T, unsigned char>) {
220 }
else if constexpr (std::is_same_v<T, std::string>) {
222 }
else if constexpr (std::is_floating_point_v<T>) {
223 std::ostringstream out;
224 out << std::setprecision(std::numeric_limits<T>::max_digits10) <<
value;
231template <
typename ContainerT>
232std::string sequenceAsString(
const ContainerT& container)
234 using ValueType =
typename ContainerT::value_type;
235 std::ostringstream out;
238 std::vector<std::string> unorderedValues;
239 if constexpr (IsUnorderedSet<ContainerT>::value) {
240 for (
const auto&
value : container) {
241 unorderedValues.push_back(scalarAsString(
static_cast<ValueType
>(
value)));
243 std::sort(unorderedValues.begin(), unorderedValues.end());
245 const auto emitValue = [&out, &
first](
const std::string&
value) {
252 if constexpr (IsUnorderedSet<ContainerT>::value) {
253 for (
const auto&
value : unorderedValues) {
257 for (
const auto&
value : container) {
258 emitValue(scalarAsString(
static_cast<ValueType
>(
value)));
265template <
typename MapT>
266std::string mapAsString(
const MapT& container)
268 std::ostringstream out;
271 std::vector<std::pair<std::string, std::string>> unorderedValues;
272 if constexpr (IsUnorderedMap<MapT>::value) {
273 for (
const auto& [
key,
value] : container) {
274 unorderedValues.emplace_back(scalarAsString(
key), scalarAsString(
value));
276 std::sort(unorderedValues.begin(), unorderedValues.end());
278 const auto emitValue = [&out, &
first](
const std::string&
key,
const std::string&
value) {
285 if constexpr (IsUnorderedMap<MapT>::value) {
286 for (
const auto& [
key,
value] : unorderedValues) {
290 for (
const auto& [
key,
value] : container) {
291 emitValue(scalarAsString(
key), scalarAsString(
value));
298template <
typename ContainerT>
299ContainerHandler makeSequenceHandler()
303 *
static_cast<ContainerT*
>(
target) = ContainerParser::parse<ContainerT>(
value);
306 return sequenceAsString(*
static_cast<const ContainerT*
>(
source));
309 *
static_cast<ContainerT*
>(
target) = *
static_cast<const ContainerT*
>(
source);
311 [](
const void*
lhs,
const void*
rhs) {
312 return *
static_cast<const ContainerT*
>(
lhs) == *
static_cast<const ContainerT*
>(rhs);
316template <
typename MapT>
317ContainerHandler makeMapHandler()
321 *
static_cast<MapT*
>(
target) = ContainerParser::parse<MapT>(
value);
324 return mapAsString(*
static_cast<const MapT*
>(
source));
327 *
static_cast<MapT*
>(
target) = *
static_cast<const MapT*
>(
source);
329 [](
const void*
lhs,
const void*
rhs) {
330 return *
static_cast<const MapT*
>(
lhs) == *
static_cast<const MapT*
>(rhs);
334template <
typename ContainerT>
335void addHandler(ContainerHandlerRegistry& registry,
const std::string&
name, ContainerHandler handler)
337 registry.byName.emplace(normalizeContainerTypeName(
name), handler);
338 registry.byType.emplace(std::type_index(
typeid(ContainerT)), std::move(handler));
342void addSequenceHandlers(ContainerHandlerRegistry& registry)
344 const std::string tname = TypeName<T>::value;
345 addHandler<std::vector<T>>(registry,
"vector<" + tname +
">", makeSequenceHandler<std::vector<T>>());
346 addHandler<std::list<T>>(registry,
"list<" + tname +
">", makeSequenceHandler<std::list<T>>());
347 addHandler<std::deque<T>>(registry,
"deque<" + tname +
">", makeSequenceHandler<std::deque<T>>());
348 addHandler<std::set<T>>(registry,
"set<" + tname +
">", makeSequenceHandler<std::set<T>>());
349 addHandler<std::unordered_set<T>>(registry,
"unordered_set<" + tname +
">", makeSequenceHandler<std::unordered_set<T>>());
352template <
typename K,
typename V>
353void addMapHandlers(ContainerHandlerRegistry& registry)
355 const std::string kname = TypeName<K>::value;
356 const std::string vname = TypeName<V>::value;
357 addHandler<std::map<K, V>>(registry,
"map<" + kname +
"," + vname +
">", makeMapHandler<std::map<K, V>>());
358 addHandler<std::unordered_map<K, V>>(registry,
"unordered_map<" + kname +
"," + vname +
">", makeMapHandler<std::unordered_map<K, V>>());
362void addMapHandlersForKey(ContainerHandlerRegistry& registry)
364 addMapHandlers<K, bool>(registry);
365 addMapHandlers<K, char>(registry);
366 addMapHandlers<K, signed char>(registry);
367 addMapHandlers<K, unsigned char>(registry);
368 addMapHandlers<K, short>(registry);
369 addMapHandlers<K, unsigned short>(registry);
370 addMapHandlers<K, int>(registry);
371 addMapHandlers<K, unsigned int>(registry);
372 addMapHandlers<K, long>(registry);
373 addMapHandlers<K, unsigned long>(registry);
374 addMapHandlers<K, long long>(registry);
375 addMapHandlers<K, unsigned long long>(registry);
376 addMapHandlers<K, float>(registry);
377 addMapHandlers<K, double>(registry);
378 addMapHandlers<K, std::string>(registry);
381const ContainerHandlerRegistry& containerHandlers()
383 static const ContainerHandlerRegistry handlers = [] {
384 ContainerHandlerRegistry
result;
386 addSequenceHandlers<bool>(
result);
387 addSequenceHandlers<char>(
result);
388 addSequenceHandlers<signed char>(
result);
389 addSequenceHandlers<unsigned char>(
result);
390 addSequenceHandlers<short>(
result);
391 addSequenceHandlers<unsigned short>(
result);
392 addSequenceHandlers<int>(
result);
393 addSequenceHandlers<unsigned int>(
result);
394 addSequenceHandlers<long>(
result);
395 addSequenceHandlers<unsigned long>(
result);
396 addSequenceHandlers<long long>(
result);
397 addSequenceHandlers<unsigned long long>(
result);
398 addSequenceHandlers<float>(
result);
399 addSequenceHandlers<double>(
result);
400 addSequenceHandlers<std::string>(
result);
402 addMapHandlersForKey<bool>(
result);
403 addMapHandlersForKey<char>(
result);
404 addMapHandlersForKey<signed char>(
result);
405 addMapHandlersForKey<unsigned char>(
result);
406 addMapHandlersForKey<short>(
result);
407 addMapHandlersForKey<unsigned short>(
result);
408 addMapHandlersForKey<int>(
result);
409 addMapHandlersForKey<unsigned int>(
result);
410 addMapHandlersForKey<long>(
result);
411 addMapHandlersForKey<unsigned long>(
result);
412 addMapHandlersForKey<long long>(
result);
413 addMapHandlersForKey<unsigned long long>(
result);
414 addMapHandlersForKey<float>(
result);
415 addMapHandlersForKey<double>(
result);
416 addMapHandlersForKey<std::string>(
result);
423const ContainerHandler* getContainerHandler(
const std::string& typeName)
425 const auto normalized = normalizeContainerTypeName(typeName);
426 const auto& handlers = containerHandlers().byName;
428 return iter == handlers.end() ? nullptr : &iter->second;
431const ContainerHandler* getContainerHandler(
const std::type_info&
type)
433 const auto& handlers = containerHandlers().byType;
434 auto iter = handlers.find(std::type_index(
type));
435 return iter == handlers.end() ? nullptr : &iter->second;
438std::pair<std::string_view, std::string_view> splitConfigurableParamKey(std::string_view
key)
440 const auto separator =
key.find(
'.');
441 if (separator == std::string_view::npos) {
444 return {
key.substr(0, separator),
key.substr(separator + 1)};
447std::string findClosestConfigurableParamKey(
const std::string& requestedKey,
448 const std::map<std::string, std::pair<std::type_info const&, void*>>& storageMap)
450 if (storageMap.empty()) {
454 const auto [requestedMainKey, requestedSubKey] = splitConfigurableParamKey(requestedKey);
455 bool mainKeyExists =
false;
456 for (
const auto&
entry : storageMap) {
457 const auto mainKey = splitConfigurableParamKey(
entry.first).first;
458 if (mainKey == requestedMainKey) {
459 mainKeyExists =
true;
465 std::size_t closestDistance = std::numeric_limits<std::size_t>::max();
466 for (
const auto&
entry : storageMap) {
468 const auto [mainKey, subKey] = splitConfigurableParamKey(
key);
469 if (mainKeyExists && mainKey != requestedMainKey) {
473 if (
distance < closestDistance || (
distance == closestDistance && (closest.empty() ||
key < closest))) {
481std::string formatUnknownConfigurableParamKeyMessage(
const std::string& prefix,
const std::string&
key,
482 const std::map<std::string, std::pair<std::type_info const&, void*>>& storageMap)
485 auto closest = findClosestConfigurableParamKey(
key, storageMap);
486 if (!closest.empty()) {
487 message +=
". Did you mean '" + closest +
"'?";
498 if (!dm->IsEnum() || this->contains(
key)) {
503 auto enumtype = TEnum::GetEnum(dm->GetTypeName());
504 assert(enumtype !=
nullptr);
505 auto constantlist = enumtype->GetConstants();
506 assert(constantlist !=
nullptr);
508 for (
int i = 0;
i < constantlist->GetEntries(); ++
i) {
509 auto e = (TEnumConstant*)(constantlist->At(
i));
510 std::pair<std::string, int>
val(
e->GetName(), (
int)
e->GetValue());
526 auto entry = std::pair<std::string, EnumLegalValues>(
key, legalVals);
532 std::string out =
"";
534 out.append(
entry.first +
" => ");
535 out.append(
entry.second.toString());
544 std::string out =
"";
548 out.append(
value.first);
566 int val = boost::lexical_cast<int>(
value);
570 }
catch (
const boost::bad_lexical_cast&
e) {
573 if (pair.first ==
value) {
587 return getContainerHandler(typeName) !=
nullptr;
592 sKeyToContainerTypeMap[
key] = typeName;
597 auto iter = sKeyToContainerTypeMap.find(
key);
598 return iter == sKeyToContainerTypeMap.end() ? std::string{} : iter->second;
603 if (
const auto* handler = getContainerHandler(typeName)) {
612 if (
const auto* handler = getContainerHandler(typeName)) {
613 return handler->equal(lhs, rhs);
620 if (
const auto* handler = getContainerHandler(typeName)) {
621 return handler->serialize(
source);
635 throw std::invalid_argument(fmt::format(
"ConfigurabeParam output file name {} extension is neither .json nor .ini",
filename));
649 if (!keyOnly.empty()) {
651 boost::property_tree::ptree kTree;
653 for (
const auto& k :
keys) {
654 kTree.add_child(k, sPtree->get_child(k));
656 boost::property_tree::write_ini(outfilename, kTree);
657 }
catch (
const boost::property_tree::ptree_bad_path& err) {
658 LOG(fatal) <<
"non-existing key " << keyOnly <<
" provided to writeINI";
661 boost::property_tree::write_ini(outfilename, *sPtree);
676 if (!sIsFullyInitialized) {
680 auto setValueImpl = [&](std::string
const&
value) {
688 if (sPtree->get_optional<std::string>(
key).is_initialized()) {
698 setValueImpl(valuestring);
703 std::cerr <<
"Error in setValue (string) key is not known\n";
707 if (!expectedSuffix.empty()) {
708 auto valuestringLower = valuestring;
709 std::transform(valuestring.cbegin(), valuestring.cend(), valuestringLower.begin(), [](
unsigned char c) { return static_cast<char>(std::tolower(c)); });
710 if (valuestringLower.ends_with(expectedSuffix)) {
711 std::string strippedValue = valuestringLower.substr(0, valuestringLower.length() - expectedSuffix.length());
712 setValueImpl(strippedValue);
715 for (
const auto& suffix : {
"f",
"l",
"u",
"ul",
"ll",
"ull"}) {
716 if (valuestringLower.ends_with(suffix) && suffix != expectedSuffix) {
717 throw std::invalid_argument(
"Wrong type suffix: expected " + expectedSuffix +
" but got " + suffix);
725 }
catch (std::exception
const&
e) {
726 std::cerr <<
"Error in setValue (string) " <<
e.what() <<
"\n";
735 LOG(info) <<
"ignoring writing of json file " <<
filename;
740 if (!keyOnly.empty()) {
742 boost::property_tree::ptree kTree;
744 for (
const auto& k :
keys) {
745 kTree.add_child(k, sPtree->get_child(k));
747 boost::property_tree::write_json(outfilename, kTree);
748 }
catch (
const boost::property_tree::ptree_bad_path& err) {
749 LOG(fatal) <<
"non-existing key " << keyOnly <<
" provided to writeJSON";
752 boost::property_tree::write_json(outfilename, *sPtree);
761 std::ostringstream os;
762 if (!keyOnly.empty()) {
764 boost::property_tree::ptree kTree;
766 for (
const auto& k :
keys) {
767 kTree.add_child(k, sPtree->get_child(k));
769 boost::property_tree::write_json(os, kTree);
770 }
catch (
const boost::property_tree::ptree_bad_path& err) {
771 LOG(fatal) <<
"non-existing key " << keyOnly <<
" provided to writeJSON";
774 boost::property_tree::write_json(os, *sPtree);
784 for (
auto p : *sRegisteredParamClasses) {
785 p->putKeyValues(sPtree);
793 if (!sIsFullyInitialized) {
796 std::cout <<
"####\n";
797 for (
auto p : *sRegisteredParamClasses) {
798 p->printKeyValues(
true, useLogger);
800 std::cout <<
"----\n";
807 if (!sIsFullyInitialized) {
812 throw std::runtime_error(fmt::format(
"provenace of unknown {:s} parameter is requested",
key));
823 if (!sIsFullyInitialized) {
827 for (
auto p : *sRegisteredParamClasses) {
828 p->serializeTo(&
file);
837 if (!sIsFullyInitialized) {
841 for (
auto p : *sRegisteredParamClasses) {
851 if (sRegisteredParamClasses ==
nullptr) {
852 sRegisteredParamClasses =
new std::vector<ConfigurableParam*>;
854 if (sPtree ==
nullptr) {
855 sPtree =
new boost::property_tree::ptree;
858 sKeyToStorageMap =
new std::map<std::string, std::pair<std::type_info const&, void*>>;
868 if (sRegisterMode ==
true) {
869 sRegisteredParamClasses->push_back(
this);
883 sIsFullyInitialized =
true;
890 for (
auto p : *sRegisteredParamClasses) {
891 std::cout << p->getName() <<
"\n";
899void updateFromPropertyTree(boost::property_tree::ptree
const& pt, std::string
const&
source, std::string
const& paramsList,
bool unchangedOnly)
901 std::vector<std::pair<std::string, std::string>> keyValPairs;
903 std::unordered_map<std::string, int> requestMap;
904 for (
const auto& par : request) {
911 for (
auto& section : pt) {
912 std::string mainKey = section.first;
913 if (requestMap.size()) {
914 if (requestMap.find(mainKey) == requestMap.end()) {
917 requestMap[mainKey] = 1;
920 for (
auto& subKey : section.second) {
921 auto name = subKey.first;
922 auto value = subKey.second.get_value<std::string>();
923 std::string
key = mainKey +
"." +
name;
926 keyValPairs.push_back(pair);
930 }
catch (std::exception
const&
error) {
931 LOG(
error) <<
"Error while updating params " <<
error.what();
933 LOG(
error) <<
"Unknown while updating params ";
937 for (
const auto& req : requestMap) {
938 if (req.second == 0) {
939 throw std::runtime_error(fmt::format(
"Param {:s} was not found in {:s}", req.first,
source));
945 }
catch (std::exception
const&
error) {
959 if (!sIsFullyInitialized) {
965 if (cfgfile.length() == 0) {
976 if (!sIsFullyInitialized) {
981 if (
json.length() == 0) {
985 boost::property_tree::ptree pt;
986 std::istringstream input(
json);
988 boost::property_tree::read_json(input, pt);
989 }
catch (
const boost::property_tree::ptree_error&
e) {
990 LOG(fatal) <<
"Failed to read JSON config string (" <<
e.what() <<
")";
993 updateFromPropertyTree(pt,
"provided JSON string", paramsList, unchangedOnly);
1001 if (!sIsFullyInitialized) {
1006 if (cfgStr.length() == 0) {
1012 auto toKeyValPairs = [](std::vector<std::string>& tokens) {
1013 std::vector<std::pair<std::string, std::string>> pairs;
1015 for (
auto& token : tokens) {
1016 auto s = token.find(
'=');
1017 if (
s == 0 ||
s == std::string::npos ||
s == token.size() - 1) {
1018 LOG(fatal) <<
"Illegal command-line key/value string: " << token;
1021 pairs.emplace_back(token.substr(0,
s), token.substr(
s + 1, token.size()));
1050 auto keyValues = toKeyValPairs(
params);
1059 if (kv.output_dir ==
"/dev/null") {
1071 auto isArray = [](std::string& el) {
1072 return el.size() > 0 && (el.at(0) ==
'[') && (el.at(el.size() - 1) ==
']');
1075 bool nonFatal = getenv(
"ALICEO2_CONFIGURABLEPARAM_WRONGKEYISNONFATAL") !=
nullptr;
1084 for (
auto& keyValue : keyValues) {
1085 std::string
key = keyValue.first;
1090 LOG(warn) << formatUnknownConfigurableParamKeyMessage(
"Ignoring non-existent ConfigurableParam key: ",
key, *
sKeyToStorageMap);
1093 LOG(fatal) << formatUnknownConfigurableParamKeyMessage(
"Inexistent ConfigurableParam key: ",
key, *
sKeyToStorageMap);
1112 if (
value ==
"true") {
1114 }
else if (
value ==
"false") {
1134 for (
int i = 0;
i < elems.size(); ++
i) {
1144 LOG(
error) <<
"Container parameter " <<
key <<
" not found";
1147 void* targetAddress = iter->second.second;
1149 const auto* handler = typeName.empty() ? getContainerHandler(iter->second.first) : getContainerHandler(typeName);
1151 LOG(
error) <<
"Unsupported container configuration: " << (typeName.empty() ? iter->second.first.name() : typeName);
1155 handler->parseAssign(targetAddress,
value);
1156 sPtree->put(
key, handler->serialize(targetAddress));
1160 }
catch (
const std::exception&
e) {
1161 LOG(
error) <<
"Failed to parse container " <<
key <<
": " <<
e.what();
1167 int val = (*sEnumRegistry)[
key]->getIntValue(
value);
1169 LOG(fatal) <<
"Illegal value "
1171 <<
". Legal string|int values:\n"
1172 << (*sEnumRegistry)[
key]->toString() << std::endl;
1178void unsupp() { std::cerr <<
"currently unsupported\n"; }
1180template <
typename T>
1184 for (
int i = 0;
i <
sizeof(T) /
sizeof(
char); ++
i) {
1185 if (((
char*)block1)[
i] != ((
char*)block2)[
i]) {
1194template <
typename T>
1197 if (isMemblockDifferent<T>(addr, targetaddr)) {
1198 std::memcpy(targetaddr, addr,
sizeof(T));
1208 auto key = mainkey +
"." + subkey;
1211 LOG(warn) <<
"Cannot update parameter " <<
key <<
" not found";
1216 int type = TDataType::GetType(tinfo);
1219 if (iter->second.first != tinfo) {
1220 LOG(warn) <<
"Types do not match; cannot update value";
1224 auto targetaddress = iter->second.second;
1227 return Copy<char>(addr, targetaddress);
1231 return Copy<unsigned char>(addr, targetaddress);
1235 return Copy<short>(addr, targetaddress);
1239 return Copy<unsigned short>(addr, targetaddress);
1243 return Copy<int>(addr, targetaddress);
1247 return Copy<unsigned int>(addr, targetaddress);
1251 return Copy<long>(addr, targetaddress);
1255 return Copy<unsigned long>(addr, targetaddress);
1259 return Copy<float>(addr, targetaddress);
1263 return Copy<double>(addr, targetaddress);
1267 return Copy<double>(addr, targetaddress);
1275 return Copy<bool>(addr, targetaddress);
1279 return Copy<long long>(addr, targetaddress);
1283 return Copy<unsigned long long>(addr, targetaddress);
1303 return Copy<char*>(addr, targetaddress);
1314 case kDataTypeAliasUnsigned_t: {
1335template <
typename T>
1338 auto addr = boost::lexical_cast<T>(valuestring);
1339 if (isMemblockDifferent<T>(targetaddr, (
void*)&addr)) {
1340 std::memcpy(targetaddr, (
void*)&addr,
sizeof(T));
1350 std::string&
target = *((std::string*)targetaddr);
1351 if (
target.compare(valuestring) != 0) {
1364 int intvalue = boost::lexical_cast<int>(valuestring);
1365 if (intvalue > std::numeric_limits<char>::max() || intvalue < std::numeric_limits<char>::min()) {
1366 LOG(
error) <<
"Cannot assign " << valuestring <<
" to a char variable";
1369 char addr = intvalue;
1370 if (isMemblockDifferent<char>(targetaddr, (
void*)&addr)) {
1371 std::memcpy(targetaddr, (
void*)&addr,
sizeof(
char));
1380 unsigned int intvalue = boost::lexical_cast<int>(valuestring);
1381 if (intvalue > std::numeric_limits<unsigned char>::max() || intvalue < std::numeric_limits<unsigned char>::min()) {
1382 LOG(
error) <<
"Cannot assign " << valuestring <<
" to an unsigned char variable";
1385 unsigned char addr = intvalue;
1386 if (isMemblockDifferent<unsigned char>(targetaddr, (
void*)&addr)) {
1387 std::memcpy(targetaddr, (
void*)&addr,
sizeof(
unsigned char));
1398 LOG(warn) <<
"Cannot update parameter " <<
key <<
" (parameter not found) ";
1402 auto targetaddress = iter->second.second;
1406 if (iter->second.first ==
typeid(std::string)) {
1411 int targettype = TDataType::GetType(iter->second.first);
1413 switch (targettype) {
1423 return ConvertAndCopy<short>(valuestring, targetaddress);
1427 return ConvertAndCopy<unsigned short>(valuestring, targetaddress);
1431 return ConvertAndCopy<int>(valuestring, targetaddress);
1435 return ConvertAndCopy<unsigned int>(valuestring, targetaddress);
1439 return ConvertAndCopy<long>(valuestring, targetaddress);
1443 return ConvertAndCopy<unsigned long>(valuestring, targetaddress);
1447 return ConvertAndCopy<float>(valuestring, targetaddress);
1451 return ConvertAndCopy<double>(valuestring, targetaddress);
1455 return ConvertAndCopy<double>(valuestring, targetaddress);
1463 return ConvertAndCopy<bool>(valuestring, targetaddress);
1467 return ConvertAndCopy<long long>(valuestring, targetaddress);
1471 return ConvertAndCopy<unsigned long long>(valuestring, targetaddress);
1503 case kDataTypeAliasUnsigned_t: {
std::function< void(void *, const std::string &)> parseAssign
std::function< bool(const void *, const void *)> equal
std::function< std::string(const void *)> serialize
#define REGISTER_SCALAR_NAME(TYPE, NAME)
std::function< void(void *, const void *)> assign
std::map< std::type_index, ContainerHandler > byType
std::map< std::string, ContainerHandler > byName
std::vector< long > entries
std::vector< std::string > keys
configStandalone Light OpenGL display display_light Apply smoothing to points Enable Z buffer Highlight links Highlight seeds Highlight sector tracks Highlight final tracks Show individual Show related Highlight grid Show only individual collision Color clusters belonging to track objects Set line Enable drawing TPC data Enable drawing TOF data Enable drawing magnetic field Set field line step count Invert colors configStandalone Heavy OpenGL display display_heavy Show tracks with ITS contribution Show tracks with TOF contribution Enable propagation of loopers Show clusters at nominal x of pad row for early transformed data Split CE tracks when they cross the central Mark clusters Mark adjacent clusters Hide rejected tracks Apply filter on tracks to be displayed Separate increase X h configStandalone Camera window renderer OpenGL display display_camera Orient the camera such that the y axis is always upwards Full Screen MultiSample Anti Downsampling Anti Enable Vertical Sync Target frame or if the backend cannot limit to the refresh Use OpenGL indirect draws to reduce number of draw calls Display h configStandalone Vulkan display display_vulkan Have uniform buffers in host accessible device memory h configStandalone Internal display display_internal Number of updates the Qt GUI may send ahead of the last one the display has before it waits for the display Opacity of the console background Number of console lines the history is shortened to this when it reaches twice the size Time in seconds an info message fades out after setInfoTime h OpenGL display display Font size Do not use Freetype for font Renderer for event Frontend to use for event ROOT macros used as track filter Console script file
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 s
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 bool
char error[CURL_ERROR_SIZE]
static const KeyValParam & Instance()
static void setInputDir(const std::string &d)
static boost::property_tree::ptree readConfigFile(std::string const &filepath)
static const std::string & getInputDir()
static EParamUpdateStatus updateThroughStorageMapWithConversion(std::string const &, std::string const &)
static std::string registeredContainerAsString(const std::string &typeName, const void *source)
static void setEnumValue(const std::string &, const std::string &)
static void writeINI(std::string const &filename, std::string const &keyOnly="")
static void setValues(std::vector< std::pair< std::string, std::string > > const &keyValues)
static bool configFileExists(std::string const &filepath)
static std::map< std::string, std::pair< std::type_info const &, void * > > * sKeyToStorageMap
static void printAllRegisteredParamNames()
static bool areRegisteredContainersEqual(const std::string &typeName, const void *lhs, const void *rhs)
static void registerContainerType(const std::string &key, const std::string &typeName)
static std::string asJSON(std::string const &keyOnly="")
static void updateFromFile(std::string const &, std::string const ¶msList="", bool unchangedOnly=false)
static void write(std::string const &filename, std::string const &keyOnly="")
static bool isRegisteredContainerType(const std::string &typeName)
static bool assignRegisteredContainer(const std::string &typeName, void *target, const void *source)
static void setArrayValue(const std::string &, const std::string &)
static void initPropertyTree()
static void setValue(std::string const &mainkey, std::string const &subkey, T x)
static std::string sOutputDir
static std::map< std::string, ConfigurableParam::EParamProvenance > * sValueProvenanceMap
static EParamProvenance getProvenance(const std::string &key)
static void printAllKeyValuePairs(bool useLogger=false)
static void toCCDB(std::string filename)
static void writeJSON(std::string const &filename, std::string const &keyOnly="")
static EParamUpdateStatus updateThroughStorageMap(std::string, std::string, std::type_info const &, void *)
static void setContainerValue(const std::string &, const std::string &)
static void updateFromJSONString(std::string const &, std::string const ¶msList="", bool unchangedOnly=false)
static EnumRegistry * sEnumRegistry
static std::string getRegisteredContainerType(const std::string &key)
static void fromCCDB(std::string filename)
static void updateFromString(std::string const &)
static std::string trim(const std::string &str)
void add(const std::string &key, const TDataMember *dm)
std::string toString() const
bool contains(const std::string &key) const
GLuint const GLchar * name
GLsizei GLsizei GLchar * source
GLsizei GLsizei GLfloat distance
GLsizei const GLfloat * value
GLint GLint GLsizei GLint GLenum GLenum type
GLenum const GLfloat * params
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLint GLenum GLboolean normalized
GLuint GLsizei const GLchar * message
std::string getLiteralSuffixFromType(const std::type_info &type)
std::size_t damerauLevenshteinDistance(std::string_view a, std::string_view b)
bool keyInTree(boost::property_tree::ptree *pt, const std::string &key)
ConfigurableParam::EParamUpdateStatus ConvertAndCopy< unsigned char >(std::string const &valuestring, void *targetaddr)
bool isMemblockDifferent(void const *block1, void const *block2)
std::ostream & operator<<(std::ostream &out, ConfigurableParam const ¶m)
ConfigurableParam::EParamUpdateStatus ConvertAndCopy< std::string >(std::string const &valuestring, void *targetaddr)
ConfigurableParam::EParamUpdateStatus ConvertAndCopy< char >(std::string const &valuestring, void *targetaddr)
ConfigurableParam::EParamUpdateStatus ConvertAndCopy(std::string const &valuestring, void *targetaddr)
D const SVectorGPU< T, D > & rhs
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::string to_string(gsl::span< T, Size > span)
bool isLegal(const std::string &value) const
std::vector< std::pair< std::string, int > > vvalues
int getIntValue(const std::string &value) const
std::string toString() const
static std::string rectifyDirectory(const std::string_view p)
static std::vector< std::string > tokenize(const std::string &src, char delim, bool trimToken=true, bool skipEmpty=true)
static std::string trim_copy(const std::string &s)
static std::string concat_string(Ts const &... ts)
static bool endsWith(const std::string &s, const std::string &ending)
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"