File indexing completed on 2025-01-18 10:17:18
0001
0002
0003
0004
0005
0006 #include "DstExampleSource.h"
0007
0008 #include <JANA/JApplication.h>
0009 #include <JANA/JEvent.h>
0010 #include "DataObjects.h"
0011
0012
0013 DstExampleSource::DstExampleSource() : JEventSource() {
0014 SetTypeName(NAME_OF_THIS);
0015 SetCallbackStyle(CallbackStyle::ExpertMode);
0016 }
0017
0018 void DstExampleSource::Open() {
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028 }
0029
0030 void DstExampleSource::Close() {
0031 }
0032
0033 JEventSource::Result DstExampleSource::Emit(JEvent& event) {
0034
0035
0036
0037
0038
0039 static size_t current_event_number = 1;
0040 event.SetEventNumber(current_event_number++);
0041 event.SetRunNumber(22);
0042
0043
0044 if (current_event_number > 2) {
0045 return Result::FailureFinished;
0046 }
0047
0048
0049 std::vector<MyJObject*> my_jobjects;
0050 my_jobjects.push_back(new MyJObject(7,7,1.8));
0051 my_jobjects.push_back(new MyJObject(8,8,9.9));
0052 auto my_jobj_fac = event.Insert(my_jobjects);
0053
0054
0055 my_jobj_fac->EnableGetAs<JObject>();
0056
0057
0058 std::vector<MyRenderable*> my_renderables;
0059 my_renderables.push_back(new MyRenderable(0,0,22.2));
0060 my_renderables.push_back(new MyRenderable(0,1,17.0));
0061 my_renderables.push_back(new MyRenderable(1,0,21.9));
0062 auto my_ren_fac = event.Insert(my_renderables);
0063
0064
0065 my_ren_fac->EnableGetAs<Renderable>();
0066
0067
0068 std::vector<MyRenderableJObject*> my_renderable_jobjects;
0069 my_renderable_jobjects.push_back(new MyRenderableJObject(1,1,1.1));
0070 auto my_both_fac = event.Insert(my_renderable_jobjects, "from_source");
0071
0072
0073 my_both_fac->EnableGetAs<JObject>();
0074 my_both_fac->EnableGetAs<Renderable>();
0075
0076 return Result::Success;
0077 }
0078
0079 std::string DstExampleSource::GetDescription() {
0080 return "Dummy source for demonstrating DST example";
0081 }
0082
0083
0084 template <>
0085 double JEventSourceGeneratorT<DstExampleSource>::CheckOpenable(std::string resource_name) {
0086
0087
0088
0089
0090
0091
0092
0093
0094 return (resource_name == "DstExampleSource") ? 1.0 : 0.0;
0095 }