Skip to content

Commit

Permalink
feat: rm utility StringHelpers.h from which only one function ever …
Browse files Browse the repository at this point in the history
…used (#818)

`StringHelpers.h` was copied into EICrecon with many functions, but only
one function is ever used (`ReplaceAll`), and it is used many times for
the same purpose (chopping the ".so" off the plugin name, which hasn't
been necessary since November 2022).

JANA2 already removes the ".so" as of 2.0.8 in [this
commit](JeffersonLab/JANA2@8ed0703),
and this puts platform specific code where it doesn't belong (".so" will
not work for Mac when JANA2 introduces that support, for example).

Keeping `StringHelpers.h` around adds to the maintenance burden,
especially since the other functions are not explicitly or implicitly
tested by use in code.

### Does this PR introduce breaking changes? What changes might users
need to make to their code?
No.

### Does this PR change default behavior?
Yes, requires 2.0.8 explicitly now (probably the requirement should be
even higher, maybe even 2.1.0, but this change introduces the
requirement of 2.0.8...)
  • Loading branch information
wdconinc authored Jul 30, 2023
1 parent e5fdb2a commit d008f49
Show file tree
Hide file tree
Showing 24 changed files with 23 additions and 284 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ message(STATUS "${CMAKE_PROJECT_NAME}: PLUGIN_LIBRARY_OUTPUT_DIRECTORY: ${PLUGIN


# Check and print what JANA2 is used
find_package(JANA REQUIRED)
find_package(JANA 2.0.8 REQUIRED)
message(STATUS "${CMAKE_PROJECT_NAME}: JANA2 CMake : ${JANA_DIR}")
message(STATUS "${CMAKE_PROJECT_NAME}: JANA2 includes: ${JANA_INCLUDE_DIR}")
message(STATUS "${CMAKE_PROJECT_NAME}: JANA2 library : ${JANA_LIBRARY}")
Expand Down
3 changes: 1 addition & 2 deletions src/detectors/FOFFMTRK/OffMomentumReconstruction_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "OffMomentumReconstruction_factory.h"
#include "services/log/Log_service.h"
#include "extensions/spdlog/SpdlogExtensions.h"
#include "extensions/string/StringHelpers.h"

namespace eicrecon {

Expand All @@ -15,7 +14,7 @@ namespace eicrecon {

void OffMomentumReconstruction_factory::Init() {

std::string plugin_name = eicrecon::str::ReplaceAll(GetPluginName(), ".so", "");
std::string plugin_name = GetPluginName();
std::string param_prefix = plugin_name + ":" + m_input_tag + ":";

auto app = GetApplication();
Expand Down
3 changes: 1 addition & 2 deletions src/detectors/RPOTS/RomanPotsReconstruction_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include "RomanPotsReconstruction_factory.h"
#include "services/log/Log_service.h"
#include "extensions/spdlog/SpdlogExtensions.h"
#include "extensions/string/StringHelpers.h"

namespace eicrecon {

Expand All @@ -17,7 +16,7 @@ namespace eicrecon {

void RomanPotsReconstruction_factory::Init() {

std::string plugin_name = eicrecon::str::ReplaceAll(GetPluginName(), ".so", "");
std::string plugin_name = GetPluginName();
std::string param_prefix = plugin_name + ":" + m_input_tag + ":";

auto app = GetApplication();
Expand Down
4 changes: 1 addition & 3 deletions src/extensions/jana/JChainFactoryT.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include <vector>

#include "services/io/podio/JFactoryPodioT.h"
#include "extensions/string/StringHelpers.h"


/// This struct might be used for factories that has no underlying config class
Expand Down Expand Up @@ -66,8 +65,7 @@ class JChainFactoryT : public BaseT<OutT> {

/// Get default prefix name
std::string GetDefaultParameterPrefix() {
std::string plugin_name = eicrecon::str::ReplaceAll(this->GetPluginName(), ".so", "");
std::string param_prefix = plugin_name+ ":" + this->GetTag();
std::string param_prefix = this->GetPluginName() + ":" + this->GetTag();
return std::move(param_prefix);
}

Expand Down
4 changes: 2 additions & 2 deletions src/extensions/jana/JChainMultifactoryGeneratorT.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ class JChainMultifactoryGeneratorT : public JFactoryGenerator {


void Init() {
std::string plugin_name = eicrecon::str::ReplaceAll(this->GetPluginName(), ".so", "");
m_prefix = plugin_name+ ":" + m_tag;
std::string plugin_name = this->GetPluginName();
m_prefix = plugin_name + ":" + m_tag;

// Get input data tags
m_app->SetDefaultParameter(m_prefix + ":InputTags", m_input_tags, "Input data tag names");
Expand Down
1 change: 0 additions & 1 deletion src/extensions/jana/JChainMultifactoryT.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "datamodel_glue.h"
#include <JANA/JMultifactory.h>
#include "extensions/jana/JChainFactoryT.h" // Just to pull in struct NoConfig
#include "extensions/string/StringHelpers.h"


template <typename ConfigT = NoConfig>
Expand Down
243 changes: 0 additions & 243 deletions src/extensions/string/StringHelpers.h

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class CalorimeterClusterRecoCoG_factoryT :
auto app = GetApplication();

// This prefix will be used for parameters
std::string plugin_name = eicrecon::str::ReplaceAll(GetPluginName(), ".so", "");
std::string plugin_name = GetPluginName();
std::string param_prefix = plugin_name + ":" + GetTag();

// Use JDD4hep_service to get dd4hep::Detector
Expand Down
2 changes: 1 addition & 1 deletion src/factories/calorimetry/CalorimeterHitDigi_factoryT.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace eicrecon {
auto app = GetApplication();

// This prefix will be used for parameters
std::string plugin_name = eicrecon::str::ReplaceAll(GetPluginName(), ".so", "");
std::string plugin_name = GetPluginName();
std::string param_prefix = plugin_name + ":" + GetTag();

// Use JDD4hep_service to get dd4hep::Detector
Expand Down
2 changes: 1 addition & 1 deletion src/factories/calorimetry/CalorimeterHitReco_factoryT.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class CalorimeterHitReco_factoryT :
auto app = GetApplication();

// This prefix will be used for parameters
std::string plugin_name = eicrecon::str::ReplaceAll(GetPluginName(), ".so", "");
std::string plugin_name = GetPluginName();
std::string param_prefix = plugin_name + ":" + GetTag();

// Use JDD4hep_service to get dd4hep::Detector
Expand Down
2 changes: 1 addition & 1 deletion src/factories/calorimetry/CalorimeterHitsMerger_factoryT.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class CalorimeterHitsMerger_factoryT :
auto app = GetApplication();

// This prefix will be used for parameters
std::string plugin_name = eicrecon::str::ReplaceAll(GetPluginName(), ".so", "");
std::string plugin_name = GetPluginName();
std::string param_prefix = plugin_name + ":" + GetTag();

// Use JDD4hep_service to get dd4hep::Detector
Expand Down
5 changes: 1 addition & 4 deletions src/global/digi/SiliconTrackerDigi_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,14 @@

#include "services/log/Log_service.h"
#include "extensions/spdlog/SpdlogExtensions.h"
#include "extensions/string/StringHelpers.h"
#include "SiliconTrackerDigi_factory.h"


void eicrecon::SiliconTrackerDigi_factory::Init() {
using namespace eicrecon::str;

auto app = GetApplication();
auto pm = app->GetJParameterManager();

std::string plugin_name = ReplaceAll(GetPluginName(), ".so", "");
std::string plugin_name = GetPluginName();

// We will use plugin name to get parameters for correct factory
// So if we use <plugin name>:parameter whichever plugin uses this template. eg:
Expand Down
3 changes: 1 addition & 2 deletions src/global/tracking/CKFTracking_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <JANA/JEvent.h>

#include "extensions/spdlog/SpdlogExtensions.h"
#include "extensions/string/StringHelpers.h"
#include "services/geometry/acts/ACTSGeo_service.h"
#include "services/geometry/dd4hep/JDD4hep_service.h"
#include "services/log/Log_service.h"
Expand All @@ -19,7 +18,7 @@ void eicrecon::CKFTracking_factory::Init() {
auto app = GetApplication();

// This prefix will be used for parameters
std::string plugin_name = eicrecon::str::ReplaceAll(GetPluginName(), ".so", "");
std::string plugin_name = GetPluginName();
std::string param_prefix = plugin_name+ ":" + GetTag();

// Initialize input tags
Expand Down
Loading

0 comments on commit d008f49

Please sign in to comment.