Skip to content

Commit

Permalink
JTest uses Expert-mode JEventProcessor
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanwbrei committed Oct 17, 2024
1 parent a9df886 commit a1cbefc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
5 changes: 5 additions & 0 deletions src/libraries/JANA/Components/JHasInputs.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ struct JHasInputs {
Input(JHasInputs* owner) {
owner->RegisterInput(this);
this->type_name = JTypeInfo::demangle<T>();
this->names.push_back("");
// For non-PODIO inputs, these are technically tags for now, not names
this->levels.push_back(JEventLevel::None);
}

Input(JHasInputs* owner, const InputOptions& options) {
Expand Down Expand Up @@ -137,6 +140,8 @@ struct JHasInputs {
PodioInput(JHasInputs* owner) {
owner->RegisterInput(this);
this->type_name = JTypeInfo::demangle<PodioT>();
this->names.push_back(this->type_name);
this->levels.push_back(JEventLevel::None);
}

PodioInput(JHasInputs* owner, const InputOptions& options) {
Expand Down
26 changes: 11 additions & 15 deletions src/plugins/JTest/JTestPlotter.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,38 +15,34 @@ class JTestPlotter : public JEventProcessor {
Parameter<size_t> m_write_bytes {this, "bytes", 1000, "Bytes written during plotting"};
Parameter<double> m_cputime_spread {this, "cputime_spread", 0.25, "Spread of time spent during plotting"};
Parameter<double> m_write_spread {this, "bytes_spread", 0.25, "Spread of bytes written during plotting"};
JBenchUtils m_bench_utils = JBenchUtils();

Input<JTestTrackData> m_track_data {this};
Input<JTestTrackAuxilliaryData> m_track_aux_data {this};

JBenchUtils m_bench_utils;

public:

JTestPlotter() {
SetPrefix("plotter");
SetTypeName(NAME_OF_THIS);
SetCallbackStyle(CallbackStyle::ExpertMode);
}

void Process(const std::shared_ptr<const JEvent>& event) override {

m_bench_utils.set_seed(event->GetEventNumber(), typeid(*this).name());

// Produce and acquire the track data
auto td = event->GetSingle<JTestTrackData>();

// Produce and acquire the track aux data
auto tad = event->Get<JTestTrackAuxilliaryData>();
void Process(const JEvent& event) override {

// Everything that happens after here is in a critical section
std::lock_guard<std::mutex> lock(m_mutex);
m_bench_utils.set_seed(event.GetEventNumber(), typeid(*this).name());

// Read the track data
m_bench_utils.read_memory(td->buffer);
m_bench_utils.read_memory(m_track_data->at(0)->buffer);

// Consume CPU
m_bench_utils.consume_cpu_ms(*m_cputime_ms + tad.at(0)->something, *m_cputime_spread);
m_bench_utils.consume_cpu_ms(*m_cputime_ms + m_track_aux_data->at(0)->something, *m_cputime_spread);

// Write the histogram data
auto hd = new JTestHistogramData;
m_bench_utils.write_memory(hd->buffer, *m_write_bytes, *m_write_spread);
event->Insert(hd);
event.Insert(hd);
}

};
Expand Down

0 comments on commit a1cbefc

Please sign in to comment.