-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Timeframe splitting #1510
Draft
nathanwbrei
wants to merge
2
commits into
main
Choose a base branch
from
nbrei_timeframe_splitting
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
WIP: Timeframe splitting #1510
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,34 @@ | ||
cmake_minimum_required(VERSION 3.16) | ||
|
||
get_filename_component(PLUGIN_NAME ${CMAKE_CURRENT_LIST_DIR} NAME) | ||
|
||
# Function creates ${PLUGIN_NAME}_plugin and ${PLUGIN_NAME}_library targets | ||
# Setting default includes, libraries and installation paths | ||
plugin_add(${PLUGIN_NAME} PLUGIN_USE_CC_ONLY) | ||
|
||
# The macro grabs sources as *.cc *.cpp *.c and headers as *.h *.hh *.hpp Then | ||
# correctly sets sources for ${_name}_plugin and ${_name}_library targets Adds | ||
# headers to the correct installation directory | ||
plugin_glob_all(${PLUGIN_NAME}) | ||
|
||
# Find dependencies plugin_add_dd4hep(${PLUGIN_NAME}#) | ||
# plugin_add_acts(${PLUGIN_NAME}) plugin_add_cern_root(${PLUGIN_NAME}) | ||
plugin_add_event_model(${PLUGIN_NAME}) | ||
|
||
# Add include directories (works same as target_include_directories) | ||
# plugin_include_directories(${PLUGIN_NAME} SYSTEM PUBLIC ... ) | ||
|
||
# Add libraries (same as target_include_directories but for both plugin and | ||
# library) | ||
plugin_link_libraries(${PLUGIN_NAME} algorithms_digi_library | ||
algorithms_tracking_library) | ||
# | ||
# Add include directories (works same as target_include_directories) | ||
# plugin_include_directories(${PLUGIN_NAME} PUBLIC ${CMAKE_CURRENT_LIST_DIR} | ||
# SYSTEM PUBLIC ${podio_INCLUDE_DIR} ${EDM4HEP_INCLUDE_DIR} | ||
# ${DD4hep_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS} ${EDM4EIC_INCLUDE_DIRS}) | ||
# | ||
# Add libraries (works same as target_include_directories) | ||
# plugin_link_libraries(${PLUGIN_NAME} ${ROOT_LIBRARIES} | ||
# algorithms_tracking_library EDM4HEP::edm4hep EDM4EIC::edm4eic spdlog::spdlog | ||
# Boost::boost ${ROOT_EG_LIBRARY}) |
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,44 @@ | ||
// Copyright 2024, Jefferson Science Associates, LLC. | ||
// Subject to the terms in the LICENSE file found in the top-level directory. | ||
|
||
#pragma once | ||
|
||
#include <JANA/JEventUnfolder.h> | ||
|
||
struct TimeframeSplitter : public JEventUnfolder { | ||
|
||
// PodioInput<ExampleCluster> m_timeslice_clusters_in {this, {.name = "ts_protoclusters", .level = JEventLevel::Timeslice}}; | ||
|
||
// PodioOutput<ExampleCluster> m_event_clusters_out {this, "evt_protoclusters"}; | ||
// PodioOutput<EventInfo> m_event_info_out {this, "evt_info"}; | ||
|
||
TimeframeSplitter() { | ||
SetTypeName(NAME_OF_THIS); | ||
SetParentLevel(JEventLevel::Timeslice); | ||
SetChildLevel(JEventLevel::PhysicsEvent); | ||
} | ||
|
||
|
||
Result Unfold(const JEvent& parent, JEvent& child, int child_idx) override { | ||
|
||
auto timeslice_nr = parent.GetEventNumber(); | ||
size_t event_nr = 100*timeslice_nr + child_idx; | ||
child.SetEventNumber(event_nr); | ||
|
||
// For now, a one-to-one relationship between timeslices and events | ||
|
||
/* | ||
auto event_clusters_out = std::make_unique<ExampleClusterCollection>(); | ||
event_clusters_out->setSubsetCollection(true); | ||
event_clusters_out->push_back(m_timeslice_clusters_in()->at(child_idx)); | ||
|
||
auto event_info_out = std::make_unique<EventInfoCollection>(); | ||
event_info_out->push_back(MutableEventInfo(event_nr, timeslice_nr, 0)); | ||
|
||
m_event_clusters_out() = std::move(event_clusters_out); | ||
m_event_info_out() = std::move(event_info_out); | ||
*/ | ||
|
||
return (child_idx == 2) ? Result::NextChildNextParent : Result::NextChildKeepParent; | ||
} | ||
}; |
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,28 @@ | ||||||||||
// Copyright 2024, Jefferson Science Associates, LLC. | ||||||||||
// Subject to the terms in the LICENSE file found in the top-level directory. | ||||||||||
|
||||||||||
Comment on lines
+1
to
+3
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
#include "TimeframeSplitter.h" | ||||||||||
#include <JANA/JApplication.h> | ||||||||||
|
||||||||||
|
||||||||||
extern "C"{ | ||||||||||
void InitPlugin(JApplication *app) { | ||||||||||
|
||||||||||
InitJANAPlugin(app); | ||||||||||
|
||||||||||
// Unfolder that takes timeframes and splits them into physics events. | ||||||||||
app->Add(new TimeframeSplitter()); | ||||||||||
|
||||||||||
// Factory that produces timeslice-level protoclusters from timeslice-level hits | ||||||||||
/* | ||||||||||
app->Add(new JOmniFactoryGeneratorT<MyProtoclusterFactory>( | ||||||||||
{ .tag = "timeslice_protoclusterizer", | ||||||||||
.level = JEventLevel::Timeslice, | ||||||||||
.input_names = {"hits"}, | ||||||||||
.output_names = {"ts_protoclusters"} | ||||||||||
})); | ||||||||||
*/ | ||||||||||
|
||||||||||
} | ||||||||||
} // "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 @@ | ||||||||
|
||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
|
||||||||
#include <JANA/JEventSourceGenerator.h> | ||||||||
#include "JEventSourcePODIO.h" | ||||||||
|
||||||||
|
||||||||
class JEventSourcePODIO_generator : public JEventSourceGenerator { | ||||||||
|
||||||||
JEventSource* MakeJEventSource(std::string resource_name) override { | ||||||||
|
||||||||
auto* source = new JEventSourcePODIO(resource_name, nullptr); | ||||||||
source->SetResourceName(resource_name); | ||||||||
|
||||||||
// Check if the string "timeslices" appears anywhere in our filename. | ||||||||
// If so, we assume the file contains timeslices, otherwise it contains physics events. | ||||||||
// Another approach might be to peek at the file's contents | ||||||||
if (resource_name.find("timeslices") != std::string::npos) { | ||||||||
source->SetLevel(JEventLevel::Timeslice); | ||||||||
} | ||||||||
else { | ||||||||
source->SetLevel(JEventLevel::PhysicsEvent); | ||||||||
} | ||||||||
return source; | ||||||||
} | ||||||||
|
||||||||
double CheckOpenable(std::string resource_name) override { | ||||||||
// In theory, we should check whether PODIO can open the file and | ||||||||
// whether it contains an 'events' or 'timeslices' tree. If not, return 0. | ||||||||
if (resource_name.find(".root") != std::string::npos) { | ||||||||
return 0.01; | ||||||||
} | ||||||||
return 0; | ||||||||
} | ||||||||
}; |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.