Skip to content

Commit

Permalink
Merge pull request #203 from mach3-software/feature_LoweCase
Browse files Browse the repository at this point in the history
Caseinsentisitve param group
  • Loading branch information
dbarrow257 authored Nov 5, 2024
2 parents 03a351f + bfcab53 commit 54f2c77
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
14 changes: 8 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,14 @@ target_compile_options(MaCh3Warnings INTERFACE
-Wredundant-decls # Warn about multiple declarations of the same entity. Useful for code cleanup.
-Wstrict-aliasing=2 # Helps detect potential aliasing issues that could lead to undefined behavior.
-Wuseless-cast # Warn if you perform a cast to the same type (only in GCC >= 4.8)
# -Wpadded # Warn when padding is added to a structure or class for alignment
-Wnull-dereference # Warn if a null dereference is detected (only in GCC >= 6.0)
-Wold-style-cast # Warn for c-style casts
-Wconversion # Warn on type conversions that may lose data
-Wnull-dereference # Warn if a null dereference is detected (only in GCC >= 6.0)
-Wold-style-cast # Warn for c-style casts
-Wconversion # Warn on type conversions that may lose data
-Wformat-security # Warn on functions that are potentially insecure for formatting
-Walloca # Warn if `alloca` is used, as it can lead to stack overflows
#-Wswitch-enum # Warn if a `switch` statement on an enum does not cover all values
#-Wfloat-equal # Warn if floating-point values are compared directly
#-Wpadded # Warn when padding is added to a structure or class for alignment
)
# KS Some compiler options are only available in GCC, in case we move to other compilers we will have to expand this
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
Expand Down Expand Up @@ -223,8 +227,6 @@ if (MaCh3_PYTHON_ENABLED)
add_subdirectory(python)
endif()



#This is to export the target properties of MaCh3
#Anything that links to "MaCh3" will get all of these target properties
add_library(MaCh3 INTERFACE)
Expand Down
17 changes: 11 additions & 6 deletions covariance/covarianceXsec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ const std::vector<int> covarianceXsec::GetGlobalSystIndexFromDetID(const int Det
std::vector<int> returnVec;
for (auto &pair : _fSystToGlobalSystIndexMap[Type]) {
auto &SystIndex = pair.second;
if ((GetParDetID(SystIndex) & DetID)) { //If parameter applies to required DetID
if (AppliesToDetID(SystIndex, DetID)) { //If parameter applies to required DetID
returnVec.push_back(SystIndex);
}
}
Expand All @@ -216,8 +216,8 @@ const std::vector<int> covarianceXsec::GetSystIndexFromDetID(int DetID, const S
std::vector<int> returnVec;
for (auto &pair : _fSystToGlobalSystIndexMap[Type]) {
auto &SplineIndex = pair.first;
auto &SystIndex = pair.second;
if ((GetParDetID(SystIndex) & DetID)) { //If parameter applies to required DetID
auto &systIndex = pair.second;
if (AppliesToDetID(systIndex, DetID)) { //If parameter applies to required DetID
returnVec.push_back(SplineIndex);
}
}
Expand Down Expand Up @@ -306,7 +306,7 @@ template <typename FilterFunc, typename ActionFunc>
void covarianceXsec::IterateOverParams(const int DetID, FilterFunc filter, ActionFunc action) {
// ********************************************
for (int i = 0; i < _fNumPar; ++i) {
if ((GetParDetID(i) & DetID) && filter(i)) { // Common filter logic
if ((AppliesToDetID(i, DetID)) && filter(i)) { // Common filter logic
action(i); // Specific action for each function
}
}
Expand Down Expand Up @@ -515,9 +515,14 @@ void covarianceXsec::SetGroupOnlyParameters(const std::string& Group) {
// Checks if parameter belongs to a given group
bool covarianceXsec::IsParFromGroup(const int i, const std::string& Group) {
// ********************************************
std::string groupLower = Group;
std::string paramGroupLower = _ParameterGroup[i];

// KS: Convert both strings to lowercase, this way comparison will be case insensitive
std::transform(groupLower.begin(), groupLower.end(), groupLower.begin(), ::tolower);
std::transform(paramGroupLower.begin(), paramGroupLower.end(), paramGroupLower.begin(), ::tolower);

if(Group == _ParameterGroup[i]) return true;
else return false;
return groupLower == paramGroupLower;
}

// ********************************************
Expand Down
7 changes: 6 additions & 1 deletion covariance/covarianceXsec.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,12 @@ class covarianceXsec : public covarianceBase {
/// @param DetID The Detector ID used to filter parameters.
template <typename FilterFunc, typename ActionFunc>
void IterateOverParams(const int DetID, FilterFunc filter, ActionFunc action);

/// @brief Check if parameter is affecting given det ID
/// @param SystIndex number of parameter
/// @param DetID The Detector ID used to filter parameters.
bool AppliesToDetID(const int SystIndex, const int DetID) const {
return (GetParDetID(SystIndex) & DetID) != 0;
}
/// @brief Initializes the systematic parameters from the configuration file.
/// This function loads parameters like normalizations and splines from the provided YAML file.
/// @note This is used internally during the object's initialization process.
Expand Down

0 comments on commit 54f2c77

Please sign in to comment.