File indexing completed on 2025-01-18 10:17:19
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include "JTestRootEventSource.h"
0012 #include "Hit.h"
0013
0014 #include <JANA/JApplication.h>
0015 #include <JANA/JEvent.h>
0016
0017 JTestRootEventSource::JTestRootEventSource() {
0018 SetTypeName(NAME_OF_THIS);
0019 SetCallbackStyle(CallbackStyle::ExpertMode);
0020 }
0021
0022 JEventSource::Result JTestRootEventSource::Emit(JEvent& event) {
0023
0024
0025
0026
0027 static size_t current_event_number = 1;
0028 event.SetEventNumber(current_event_number++);
0029 event.SetRunNumber(222);
0030
0031 m_bench_utils.set_seed(event.GetEventNumber(), NAME_OF_THIS);
0032
0033 m_bench_utils.consume_cpu_ms(5);
0034
0035
0036
0037 std::uniform_int_distribution<int> Hits_dist(3,10);
0038 std::uniform_int_distribution<int> Chan_dist(-40,400);
0039 std::normal_distribution<double> E_dist(0.75, 0.3);
0040 std::uniform_real_distribution<float> t_dist(30.0, 80.);
0041 std::vector<Hit*> hits;
0042 auto Nhits = Hits_dist(generator);
0043 for( int i=0; i< Nhits; i++ ) {
0044 hits.push_back(new Hit(Chan_dist(generator), Chan_dist(generator), E_dist(generator), t_dist(generator)));
0045 }
0046
0047
0048 event.Insert(hits);
0049 return Result::Success;
0050 }
0051