Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:01:38

0001 // Copyright 2024, Jefferson Science Associates, LLC.
0002 // Subject to the terms in the LICENSE file found in the top-level directory.
0003 
0004 #pragma once
0005 
0006 #include <JANA/JEventSource.h>
0007 #include <PodioDatamodel/TimesliceInfoCollection.h>
0008 #include <PodioDatamodel/EventInfoCollection.h>
0009 #include "CollectionTabulators.h"
0010 
0011 
0012 struct MyFileReader : public JEventSource {
0013 
0014     PodioOutput<ExampleHit> m_hits_out {this, "hits"};
0015 
0016     MyFileReader() {
0017         SetTypeName(NAME_OF_THIS);
0018         SetCallbackStyle(CallbackStyle::ExpertMode);
0019     }
0020 
0021     void Open() override { }
0022 
0023     void Close() override { }
0024 
0025     Result Emit(JEvent& event) override {
0026 
0027         auto event_nr = event.GetEventNumber();
0028 
0029         auto hits_out  = std::make_unique<ExampleHitCollection>();
0030 
0031         // ExampleHit(unsigned long long cellID, double x, double y, double z, double energy, std::uint64_t time);
0032         hits_out->push_back(MutableExampleHit(event_nr, 0, 22, 22, 22, 0));
0033         hits_out->push_back(MutableExampleHit(event_nr, 0, 49, 49, 49, 1));
0034         hits_out->push_back(MutableExampleHit(event_nr, 0, 7.6, 7.6, 7.6, 2));
0035 
0036         LOG_DEBUG(GetLogger()) << "MySource: Emitted " << GetLevel() << " " << event.GetEventNumber() << "\n"
0037             << TabulateHits(hits_out.get())
0038             << LOG_END;
0039 
0040         m_hits_out() = std::move(hits_out);
0041 
0042         // Furnish this event with info object
0043         if (GetLevel() == JEventLevel::Timeslice) {
0044             TimesliceInfoCollection info;
0045             info.push_back(MutableTimesliceInfo(event_nr, 0)); // event nr, run nr
0046             event.InsertCollection<TimesliceInfo>(std::move(info), "ts_info");
0047         }
0048         else {
0049             EventInfoCollection info;
0050             info.push_back(MutableEventInfo(event_nr, 0, 0)); // event nr, timeslice nr, run nr
0051             event.InsertCollection<EventInfo>(std::move(info), "evt_info");
0052         }
0053         return Result::Success;
0054     }
0055 };