Skip to content

Commit

Permalink
fix: move remaining JChainFactory algorithms to JChainMultifactory (#…
Browse files Browse the repository at this point in the history
…1142)

### Briefly, what does this PR introduce?
We still had a number of algorithms inheriting JChainFactory, not
JChainMultifactory. This migrates these remaining ones to
JChainMultifactory.

### What kind of change does this PR introduce?
- [x] Bug fix (issue: migrate all algorithms to JChainMultifactory)
- [ ] New feature (issue #__)
- [ ] Documentation update
- [ ] Other: __

### Please check if this PR fulfills the following:
- [ ] Tests for the changes have been added
- [ ] Documentation has been added / updated
- [ ] Changes have been communicated to collaborators

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

### Does this PR change default behavior?
No.
  • Loading branch information
wdconinc committed Nov 30, 2023
1 parent c72232d commit f7d793d
Show file tree
Hide file tree
Showing 25 changed files with 168 additions and 339 deletions.
2 changes: 1 addition & 1 deletion src/algorithms/tracking/TrackerMeasurementFromHits.cc
Expand Up @@ -37,7 +37,7 @@ namespace eicrecon {
std::shared_ptr<spdlog::logger> logger) {
m_dd4hepGeo = detector;
m_converter = converter;
m_log = std::move(logger);
m_log = logger;
m_acts_context = std::move(acts_context);
m_detid_b0tracker = m_dd4hepGeo->constant<int>("B0Tracker_Station_1_ID");
}
Expand Down
16 changes: 10 additions & 6 deletions src/detectors/DRICH/DRICH.cc
Expand Up @@ -12,7 +12,6 @@
#include "algorithms/digi/PhotoMultiplierHitDigiConfig.h"
#include "algorithms/pid/IrtCherenkovParticleIDConfig.h"
#include "algorithms/pid/MergeParticleIDConfig.h"
#include "extensions/jana/JChainFactoryGeneratorT.h"
#include "extensions/jana/JChainMultifactoryGeneratorT.h"
// factories
#include "global/digi/PhotoMultiplierHitDigi_factory.h"
Expand Down Expand Up @@ -117,9 +116,12 @@ extern "C" {
track_cfg,
app
));
app->Add(new JChainFactoryGeneratorT<MergeTrack_factory>(
app->Add(new JChainMultifactoryGeneratorT<MergeTrack_factory>(
"DRICHMergedTracks",
{"DRICHAerogelTracks", "DRICHGasTracks"},
"DRICHMergedTracks"
{"DRICHMergedTracks"},
{},
app
));

// PID algorithm
Expand All @@ -136,10 +138,12 @@ extern "C" {
));

// merge aerogel and gas PID results
app->Add(new JChainFactoryGeneratorT<MergeCherenkovParticleID_factory>(
{"DRICHAerogelIrtCherenkovParticleID", "DRICHGasIrtCherenkovParticleID"},
app->Add(new JChainMultifactoryGeneratorT<MergeCherenkovParticleID_factory>(
"DRICHMergedIrtCherenkovParticleID",
merge_cfg
{"DRICHAerogelIrtCherenkovParticleID", "DRICHGasIrtCherenkovParticleID"},
{"DRICHMergedIrtCherenkovParticleID"},
merge_cfg,
app
));

// clang-format on
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/README.md
@@ -1,6 +1,6 @@
This directory holds additional helper methods and classes for the used frameworks and libraries

- jana - JANA2 extension classes such as JChainFactory
- jana - JANA2 extension classes such as JChainMultifactory
- spdlog - parsing spdlog classes
- string - std::string extensions such as trim()

Expand Down
59 changes: 0 additions & 59 deletions src/extensions/jana/JChainFactoryGeneratorT.h

This file was deleted.

79 changes: 0 additions & 79 deletions src/extensions/jana/JChainFactoryT.h

This file was deleted.

2 changes: 1 addition & 1 deletion src/extensions/jana/JChainMultifactoryT.h
Expand Up @@ -20,9 +20,9 @@
#include <vector>

#include "datamodel_glue.h"
#include <JANA/JEvent.h>
#include <JANA/JMultifactory.h>
#include "algorithms/interfaces/WithPodConfig.h"
#include "extensions/jana/JChainFactoryT.h" // Just to pull in struct NoConfig


template <typename ConfigT = eicrecon::NoConfig>
Expand Down
11 changes: 3 additions & 8 deletions src/global/pid/MergeCherenkovParticleID_factory.cc
Expand Up @@ -4,11 +4,12 @@
#include "MergeCherenkovParticleID_factory.h"

#include <JANA/JApplication.h>
#include <JANA/JException.h>
#include <fmt/core.h>
#include <spdlog/logger.h>
#include <exception>

#include "services/io/podio/JFactoryPodioT.h"
#include "datamodel_glue.h"

//-----------------------------------------------------------------------------
void eicrecon::MergeCherenkovParticleID_factory::Init() {
Expand All @@ -17,7 +18,6 @@ void eicrecon::MergeCherenkovParticleID_factory::Init() {
auto app = GetApplication();
auto plugin = GetPluginName();
auto prefix = plugin + ":" + GetTag();
InitDataTags(prefix);

// services
InitLogger(app, prefix, "info");
Expand All @@ -36,11 +36,6 @@ void eicrecon::MergeCherenkovParticleID_factory::Init() {
m_algo.AlgorithmInit(m_log);
}

//-----------------------------------------------------------------------------
void eicrecon::MergeCherenkovParticleID_factory::BeginRun(const std::shared_ptr<const JEvent> &event) {
m_algo.AlgorithmChangeRun();
}

//-----------------------------------------------------------------------------
void eicrecon::MergeCherenkovParticleID_factory::Process(const std::shared_ptr<const JEvent> &event) {

Expand All @@ -54,7 +49,7 @@ void eicrecon::MergeCherenkovParticleID_factory::Process(const std::shared_ptr<c
// call the MergeParticleID algorithm
try {
auto merged_pids = m_algo.AlgorithmProcess(cherenkov_pids);
SetCollection(std::move(merged_pids));
SetCollection<edm4eic::CherenkovParticleID>(GetOutputTags()[0], std::move(merged_pids));
}
catch(std::exception &e) {
throw JException(e.what());
Expand Down
19 changes: 9 additions & 10 deletions src/global/pid/MergeCherenkovParticleID_factory.h
Expand Up @@ -6,7 +6,6 @@
#pragma once

#include <JANA/JEvent.h>
#include <JANA/JException.h>
#include <edm4eic/CherenkovParticleIDCollection.h>
#include <cstddef>
#include <memory>
Expand All @@ -19,31 +18,31 @@
#include "algorithms/pid/MergeParticleID.h"
#include "algorithms/pid/MergeParticleIDConfig.h"
// JANA
#include "extensions/jana/JChainFactoryT.h"
#include "extensions/jana/JChainMultifactoryT.h"
// services
#include "extensions/spdlog/SpdlogMixin.h"

namespace eicrecon {

class MergeCherenkovParticleID_factory :
public JChainFactoryT<edm4eic::CherenkovParticleID, MergeParticleIDConfig>,
public JChainMultifactoryT<MergeParticleIDConfig>,
public SpdlogMixin
{

public:

explicit MergeCherenkovParticleID_factory(
std::vector<std::string> default_input_tags,
MergeParticleIDConfig cfg
):
JChainFactoryT<edm4eic::CherenkovParticleID, MergeParticleIDConfig>(std::move(default_input_tags), cfg) {}
std::string tag,
const std::vector<std::string>& input_tags,
const std::vector<std::string>& output_tags,
MergeParticleIDConfig cfg)
: JChainMultifactoryT<MergeParticleIDConfig>(std::move(tag), input_tags, output_tags, cfg) {
DeclarePodioOutput<edm4eic::CherenkovParticleID>(GetOutputTags()[0]);
}

/** One time initialization **/
void Init() override;

/** On run change preparations **/
void BeginRun(const std::shared_ptr<const JEvent> &event) override;

/** Event by event processing **/
void Process(const std::shared_ptr<const JEvent> &event) override;

Expand Down
10 changes: 3 additions & 7 deletions src/global/pid/MergeTrack_factory.cc
Expand Up @@ -3,11 +3,12 @@

#include "MergeTrack_factory.h"

#include <JANA/JException.h>
#include <fmt/core.h>
#include <spdlog/logger.h>
#include <exception>

#include "services/io/podio/JFactoryPodioT.h"
#include "datamodel_glue.h"

//-----------------------------------------------------------------------------
void eicrecon::MergeTrack_factory::Init() {
Expand All @@ -16,7 +17,6 @@ void eicrecon::MergeTrack_factory::Init() {
auto *app = GetApplication();
auto plugin = GetPluginName();
auto prefix = plugin + ":" + GetTag();
InitDataTags(prefix);

// services
InitLogger(app, prefix, "info");
Expand All @@ -25,10 +25,6 @@ void eicrecon::MergeTrack_factory::Init() {

}

//-----------------------------------------------------------------------------
void eicrecon::MergeTrack_factory::BeginRun(const std::shared_ptr<const JEvent> &event) {
}

//-----------------------------------------------------------------------------
void eicrecon::MergeTrack_factory::Process(const std::shared_ptr<const JEvent> &event) {

Expand All @@ -42,7 +38,7 @@ void eicrecon::MergeTrack_factory::Process(const std::shared_ptr<const JEvent> &
// call the MergeTracks algorithm
try {
auto out_track_collection = m_algo.AlgorithmProcess(in_track_collections);
SetCollection(std::move(out_track_collection));
SetCollection<edm4eic::TrackSegment>(GetOutputTags()[0], std::move(out_track_collection));
}
catch(std::exception &e) {
throw JException(e.what());
Expand Down
18 changes: 10 additions & 8 deletions src/global/pid/MergeTrack_factory.h
Expand Up @@ -4,7 +4,6 @@
#pragma once

#include <JANA/JEvent.h>
#include <JANA/JException.h>
#include <edm4eic/TrackSegmentCollection.h>
#include <cstddef>
#include <memory>
Expand All @@ -14,30 +13,33 @@
#include <vector>

// algorithms
#include "algorithms/interfaces/WithPodConfig.h"
#include "algorithms/pid/MergeTracks.h"
// JANA
#include "extensions/jana/JChainFactoryT.h"
#include "extensions/jana/JChainMultifactoryT.h"
// services
#include "extensions/spdlog/SpdlogMixin.h"

namespace eicrecon {

class MergeTrack_factory :
public JChainFactoryT<edm4eic::TrackSegment>,
public JChainMultifactoryT<NoConfig>,
public SpdlogMixin
{

public:

explicit MergeTrack_factory(std::vector<std::string> default_input_tags) :
JChainFactoryT<edm4eic::TrackSegment>(std::move(default_input_tags)) {}
explicit MergeTrack_factory(
std::string tag,
const std::vector<std::string>& input_tags,
const std::vector<std::string>& output_tags)
: JChainMultifactoryT<NoConfig>(std::move(tag), input_tags, output_tags) {
DeclarePodioOutput<edm4eic::TrackSegment>(GetOutputTags()[0]);
}

/** One time initialization **/
void Init() override;

/** On run change preparations **/
void BeginRun(const std::shared_ptr<const JEvent> &event) override;

/** Event by event processing **/
void Process(const std::shared_ptr<const JEvent> &event) override;

Expand Down

0 comments on commit f7d793d

Please sign in to comment.