Skip to content

Commit

Permalink
Migrate JTestRoot to new event source API
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanwbrei committed Apr 27, 2024
1 parent f2c6716 commit 2cfa896
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/plugins/JTestRoot/JTestRoot.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void InitPlugin(JApplication* app) {
InitJANAPlugin(app);

LOG << "Loading JTestRoot" << LOG_END;
app->Add(new JTestRootEventSource("dummy_root_object_source", app));
app->Add(new JTestRootEventSource);
app->Add(new JTestRootProcessor);
app->Add(new JFactoryGeneratorT<JFactory_Cluster>);
}
Expand Down
13 changes: 8 additions & 5 deletions src/plugins/JTestRoot/JTestRootEventSource.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
#include <JANA/JEvent.h>
#include <JANA/Utils/JPerfUtils.h>

JTestRootEventSource::JTestRootEventSource(std::string resource_name, JApplication* app) : JEventSource(resource_name, app) {
JTestRootEventSource::JTestRootEventSource() {
SetTypeName(NAME_OF_THIS); // Provide JANA with class name
SetCallbackStyle(CallbackStyle::ExpertMode);
}

void JTestRootEventSource::GetEvent(std::shared_ptr <JEvent> event) {
JEventSource::Result JTestRootEventSource::Emit(JEvent& event) {
/// Generate an event by inserting objects into "event".
/// (n.b. a normal event source would read these from a file or stream)

Expand All @@ -28,8 +29,8 @@ void JTestRootEventSource::GetEvent(std::shared_ptr <JEvent> event) {

// Configure event and run numbers
static size_t current_event_number = 1;
event->SetEventNumber(current_event_number++);
event->SetRunNumber(222);
event.SetEventNumber(current_event_number++);
event.SetRunNumber(222);

// Generate hit objects. We use random numbers to give some variation
// and make things look a little more realistic
Expand All @@ -44,5 +45,7 @@ void JTestRootEventSource::GetEvent(std::shared_ptr <JEvent> event) {
}

// Add Hit objects to event
event->Insert(hits);
event.Insert(hits);
return Result::Success;
}

2 changes: 1 addition & 1 deletion src/plugins/JTestRoot/JTestRootEventSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class JTestRootEventSource : public JEventSource {
JTestRootEventSource(std::string resource_name, JApplication* app);
virtual ~JTestRootEventSource() = default;

void GetEvent(std::shared_ptr<JEvent>) override;
Result Emit(JEvent& event) override;

protected:
std::default_random_engine generator;
Expand Down

0 comments on commit 2cfa896

Please sign in to comment.