File indexing completed on 2025-01-18 10:01:38
0001
0002
0003
0004 #pragma once
0005
0006 #include <JANA/JEventUnfolder.h>
0007 #include <PodioDatamodel/EventInfoCollection.h>
0008 #include "CollectionTabulators.h"
0009
0010 struct MyTimesliceSplitter : public JEventUnfolder {
0011
0012 PodioInput<ExampleCluster> m_timeslice_clusters_in {this, {.name = "ts_protoclusters",
0013 .level = JEventLevel::Timeslice}};
0014
0015 PodioOutput<ExampleCluster> m_event_clusters_out {this, "evt_protoclusters"};
0016 PodioOutput<EventInfo> m_event_info_out {this, "evt_info"};
0017
0018 MyTimesliceSplitter() {
0019 SetTypeName(NAME_OF_THIS);
0020 SetParentLevel(JEventLevel::Timeslice);
0021 SetChildLevel(JEventLevel::PhysicsEvent);
0022 }
0023
0024
0025 Result Unfold(const JEvent& parent, JEvent& child, int child_idx) override {
0026
0027 auto timeslice_nr = parent.GetEventNumber();
0028 size_t event_nr = 100*timeslice_nr + child_idx;
0029 child.SetEventNumber(event_nr);
0030
0031
0032
0033 auto event_clusters_out = std::make_unique<ExampleClusterCollection>();
0034 event_clusters_out->setSubsetCollection(true);
0035 event_clusters_out->push_back(m_timeslice_clusters_in()->at(child_idx));
0036
0037 auto event_info_out = std::make_unique<EventInfoCollection>();
0038 event_info_out->push_back(MutableEventInfo(event_nr, timeslice_nr, 0));
0039
0040 LOG_DEBUG(GetLogger()) << "MyTimesliceSplitter: Timeslice " << parent.GetEventNumber()
0041 << ", Event " << child.GetEventNumber()
0042 << "\nTimeslice clusters in:\n"
0043 << TabulateClusters(m_timeslice_clusters_in())
0044 << "\nEvent clusters out:\n"
0045 << TabulateClusters(event_clusters_out.get())
0046 << LOG_END;
0047
0048 m_event_clusters_out() = std::move(event_clusters_out);
0049 m_event_info_out() = std::move(event_info_out);
0050
0051 return (child_idx == 2) ? Result::NextChildNextParent : Result::NextChildKeepParent;
0052 }
0053 };
0054
0055
0056