-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7bef2a7
commit 2ca0ed6
Showing
6 changed files
with
120 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
if (USE_PODIO) | ||
|
||
add_jana_plugin(PodioFactories) | ||
target_link_libraries(PodioFactories PUBLIC PodioDatamodel PodioDatamodelDict) | ||
|
||
else() | ||
|
||
message(STATUS "Skipping examples/PodioFactories because USE_PODIO=Off") | ||
|
||
endif() | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
|
||
#include <JANA/JApplication.h> | ||
#include <JANA/Components/JOmniFactory.h> | ||
#include <JANA/Components/JOmniFactoryGeneratorT.h> | ||
#include <PodioDatamodel/ExampleClusterCollection.h> | ||
|
||
|
||
struct PodioClusteringFactory : public JOmniFactory<PodioClusteringFactory> { | ||
|
||
PodioInput<ExampleCluster> m_protoclusters_in {this}; | ||
PodioOutput<ExampleCluster> m_clusters_out {this}; | ||
|
||
Parameter<double> m_scale {this, "scale", 1.0, "Scaling factor"}; | ||
Parameter<double> m_offset {this, "offset", 0.0, "Amount to offset [mm]"}; | ||
|
||
void Configure() { | ||
} | ||
|
||
void ChangeRun(int32_t /*run_nr*/) { | ||
} | ||
|
||
void Execute(int32_t /*run_nr*/, uint64_t /*evt_nr*/) { | ||
|
||
auto cs = std::make_unique<ExampleClusterCollection>(); | ||
|
||
for (auto protocluster : *m_protoclusters_in()) { | ||
auto cluster = cs->create(); | ||
cluster.energy((m_scale() * protocluster.energy()) + m_offset()); | ||
} | ||
|
||
m_clusters_out() = std::move(cs); | ||
} | ||
}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
|
||
#include <JANA/JApplication.h> | ||
#include <JANA/Components/JOmniFactoryGeneratorT.h> | ||
#include "PodioClusteringFactory.h" | ||
#include "PodioProtoclusteringFactory.h" | ||
|
||
extern "C"{ | ||
void InitPlugin(JApplication *app) { | ||
|
||
InitJANAPlugin(app); | ||
|
||
auto cluster_gen = new JOmniFactoryGeneratorT<PodioClusteringFactory>(); | ||
|
||
cluster_gen->AddWiring("clusterizer", | ||
{"protoclusters"}, | ||
{"clusters"}, | ||
{{"offset", "1000"}}); | ||
|
||
app->Add(cluster_gen); | ||
|
||
|
||
|
||
auto protocluster_gen = new JOmniFactoryGeneratorT<PodioProtoclusteringFactory>(); | ||
|
||
protocluster_gen->AddWiring("protoclusterizer", | ||
{"hits"}, | ||
{"protoclusters"}); | ||
|
||
app->Add(protocluster_gen); | ||
|
||
} | ||
} // "C" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright 2024, Jefferson Science Associates, LLC. | ||
// Subject to the terms in the LICENSE file found in the top-level directory. | ||
|
||
#pragma once | ||
|
||
#include <JANA/Components/JOmniFactory.h> | ||
#include <PodioDatamodel/ExampleHitCollection.h> | ||
#include <PodioDatamodel/ExampleClusterCollection.h> | ||
|
||
|
||
struct PodioProtoclusteringFactory : public JOmniFactory<PodioProtoclusteringFactory> { | ||
|
||
PodioInput<ExampleHit> hits_in {this}; | ||
PodioOutput<ExampleCluster> clusters_out {this}; | ||
|
||
void Configure() { | ||
} | ||
|
||
void ChangeRun(int32_t /*run_nr*/) { | ||
} | ||
|
||
void Execute(int32_t /*run_nr*/, uint64_t /*evt_nr*/) { | ||
|
||
auto cs = std::make_unique<ExampleClusterCollection>(); | ||
for (auto hit : *hits_in()) { | ||
auto cluster = cs->create(); | ||
cluster.energy(hit.energy()); | ||
cluster.addHits(hit); | ||
} | ||
clusters_out() = std::move(cs); | ||
} | ||
}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters