Skip to content
Draft
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .github/workflows/linux-eic-shell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,63 @@ jobs:
path: rec_${{ matrix.particle }}_1GeV_20GeV_${{ matrix.detector_config }}_${{ matrix.test_plugins }}.hists.root
if-no-files-found: error

eicrecon-input-collections-test:
runs-on: ubuntu-24.04
needs:
- build
- npsim-gun
strategy:
matrix:
CXX: [g++]
particle: [e]
detector_config: [craterlake]
steps:
- name: Checkout .github
uses: actions/checkout@v5
with:
sparse-checkout: .github
- name: Download install directory
uses: actions/download-artifact@v5
with:
name: install-${{ matrix.CXX }}-eic-shell-Release-${{ env.platform }}-${{ env.release }}-ASAN
- name: Unarchive install directory
run: tar -xaf install.tar.zst
- uses: actions/download-artifact@v5
with:
name: sim_${{ matrix.particle }}_1GeV_20GeV_${{ matrix.detector_config }}.edm4hep.root
- uses: cvmfs-contrib/github-action-cvmfs@v5
- name: Run EICrecon with all collections (baseline)
uses: eic/run-cvmfs-osg-eic-shell@main
with:
platform-release: "${{ env.platform }}:${{ env.release }}"
setup: "/opt/detector/epic-${{ env.detector-version }}/bin/thisepic.sh"
run: |
export DETECTOR_CONFIG=${DETECTOR}_${{ matrix.detector_config }}
export LD_LIBRARY_PATH=$PWD/install/lib:$LD_LIBRARY_PATH
export JANA_PLUGIN_PATH=$PWD/install/lib/EICrecon/plugins${JANA_PLUGIN_PATH:+:${JANA_PLUGIN_PATH}}
$PWD/install/bin/eicrecon ${{env.JANA_OPTIONS}} ${{env.JANA_OPTIONS_GUN}} -Ppodio:output_file=rec_${{ matrix.particle }}_1GeV_20GeV_${{ matrix.detector_config }}_all_collections.edm4eic.root sim_${{ matrix.particle }}_1GeV_20GeV_${{ matrix.detector_config }}.edm4hep.root -Ppodio:output_collections=EventHeader,EcalBarrelScFiRawHits,EcalBarrelImagingRawHits,CentralTrackingRecHits -Pjana:nevents=5
- name: Run EICrecon without MCParticles (test input filtering)
uses: eic/run-cvmfs-osg-eic-shell@main
with:
platform-release: "${{ env.platform }}:${{ env.release }}"
setup: "/opt/detector/epic-${{ env.detector-version }}/bin/thisepic.sh"
run: |
export DETECTOR_CONFIG=${DETECTOR}_${{ matrix.detector_config }}
export LD_LIBRARY_PATH=$PWD/install/lib:$LD_LIBRARY_PATH
export JANA_PLUGIN_PATH=$PWD/install/lib/EICrecon/plugins${JANA_PLUGIN_PATH:+:${JANA_PLUGIN_PATH}}
# Test that our input_collections parameter works to exclude MCParticles - simulating real data without MC truth
$PWD/install/bin/eicrecon ${{env.JANA_OPTIONS}} ${{env.JANA_OPTIONS_GUN}} -Ppodio:input_collections=EventHeader,EcalBarrelScFiRawHits,EcalBarrelImagingRawHits,EcalBarrelScFiHits,EcalBarrelImagingHits,HcalBarrelRawHits,HcalBarrelHits,SiBarrelRawHits,SiBarrelHits -Ppodio:output_file=rec_${{ matrix.particle }}_1GeV_20GeV_${{ matrix.detector_config }}_no_mc.edm4eic.root sim_${{ matrix.particle }}_1GeV_20GeV_${{ matrix.detector_config }}.edm4hep.root -Ppodio:output_collections=EventHeader,EcalBarrelScFiRawHits,EcalBarrelImagingRawHits,CentralTrackingRecHits -Pjana:nevents=5
- uses: actions/upload-artifact@v4
with:
name: rec_${{ matrix.particle }}_1GeV_20GeV_${{ matrix.detector_config }}_all_collections.edm4eic.root
path: rec_${{ matrix.particle }}_1GeV_20GeV_${{ matrix.detector_config }}_all_collections.edm4eic.root
if-no-files-found: error
- uses: actions/upload-artifact@v4
with:
name: rec_${{ matrix.particle }}_1GeV_20GeV_${{ matrix.detector_config }}_no_mc.edm4eic.root
path: rec_${{ matrix.particle }}_1GeV_20GeV_${{ matrix.detector_config }}_no_mc.edm4eic.root
if-no-files-found: error

eicrecon-benchmarks-plugins:
runs-on: ubuntu-24.04
needs:
Expand Down
40 changes: 39 additions & 1 deletion src/services/io/podio/JEventSourcePODIO.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,26 @@ JEventSourcePODIO::JEventSourcePODIO(std::string resource_name, JApplication* ap
GetApplication()->SetDefaultParameter("podio:print_type_table", print_type_table,
"Print list of collection names and their types");

// Get the list of input collections to include
std::vector<std::string> input_collections;
GetApplication()->SetDefaultParameter(
"podio:input_collections", input_collections,
"Comma separated list of collection names to read from input. If not set, all collections "
"will be "
"read from input file. Setting this allows filtering which collections are loaded.");

m_input_collections = std::set<std::string>(input_collections.begin(), input_collections.end());

// Log input collections configuration for debugging
if (!input_collections.empty()) {
m_log->info("podio:input_collections parameter set - will only load specified collections:");
for (const auto& coll : input_collections) {
m_log->info(" - {}", coll);
}
} else {
m_log->debug("podio:input_collections not set - will load all available collections");
}

// Hopefully we won't need to reimplement background event merging. Using podio frames, it looks like we would
// have to do a deep copy of all data in order to insert it into the same frame, which would probably be
// quite inefficient.
Expand Down Expand Up @@ -217,9 +237,27 @@ void JEventSourcePODIO::GetEvent(std::shared_ptr<JEvent> _event) {
}
}

// Insert contents odf frame into JFactories
// Insert contents of frame into JFactories
VisitPodioCollection<InsertingVisitor> visit;

// Log collection filtering info on first event only
static bool first_event = true;
if (first_event && !m_input_collections.empty()) {
m_log->info("Filtering input collections - loading {} of {} available collections",
m_input_collections.size(), frame->getAvailableCollections().size());
first_event = false;
}

for (const std::string& coll_name : frame->getAvailableCollections()) {
// Filter collections based on input_collections parameter
// If input_collections is not set (empty), load all collections (default behavior)
// If input_collections is set, only load collections that are in the set
if (!m_input_collections.empty() &&
m_input_collections.find(coll_name) == m_input_collections.end()) {
// Skip this collection as it's not in the input_collections list
continue;
}

const podio::CollectionBase* collection = frame->get(coll_name);
InsertingVisitor visitor(event, coll_name);
visit(visitor, *collection);
Expand Down
3 changes: 3 additions & 0 deletions src/services/io/podio/JEventSourcePODIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <spdlog/logger.h>
#include <cstddef>
#include <memory>
#include <set>
#include <string>

#if ((JANA_VERSION_MAJOR == 2) && (JANA_VERSION_MINOR >= 3)) || (JANA_VERSION_MAJOR > 2)
Expand Down Expand Up @@ -49,6 +50,8 @@ class JEventSourcePODIO : public JEventSource {
bool m_run_forever = false;
bool m_use_event_headers = true;

std::set<std::string> m_input_collections; // config. parameter

private:
std::shared_ptr<spdlog::logger> m_log;
};
Expand Down
Loading