Back to home page

EIC code displayed by LXR

 
 

    


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

0001 
0002 // Copyright 2020, Jefferson Science Associates, LLC.
0003 // Subject to the terms in the LICENSE file found in the top-level directory.
0004 
0005 
0006 #include "DstExampleProcessor.h"
0007 #include "DataObjects.h"
0008 #include <JANA/JLogger.h>
0009 
0010 DstExampleProcessor::DstExampleProcessor() {
0011     SetTypeName(NAME_OF_THIS); // Provide JANA with this class's name
0012     SetCallbackStyle(CallbackStyle::ExpertMode);
0013 }
0014 
0015 void DstExampleProcessor::Init() {
0016     LOG << "DstExampleProcessor::Init" << LOG_END;
0017     // Open TFiles, set up TTree branches, etc
0018 }
0019 
0020 void DstExampleProcessor::Process(const JEvent& event) {
0021     LOG << "DstExampleProcessor::Process, Event #" << event.GetEventNumber() << LOG_END;
0022 
0023     /// Note that GetAllChildren won't trigger any new computations, it will only
0024     /// project down results which already exist in the JEvent. In order to obtain
0025     /// results from our DstExampleFactory, we need to trigger it explicitly using
0026     /// either JEvent::Get or JEvent::GetAll.
0027 
0028     event.Get<MyRenderableJObject>("from_factory");
0029 
0030     /// Now we can project our event down to a map of Renderables and a separate
0031     /// map of JObjects. Note we do this in parallel.
0032     auto renderable_map = event.GetAllChildren<Renderable>();
0033     auto jobject_map = event.GetAllChildren<JObject>();
0034 
0035     /// Senquentially, we iterate over all of our Renderables and JObjects and use
0036     /// whatever functionality each interface provides.
0037 
0038     std::lock_guard<std::mutex>lock(m_mutex);
0039     for (const auto& item : renderable_map) {
0040         // destructure
0041         std::string factory_name = item.first.first;
0042         std::string factory_tag = item.first.second;
0043         const std::vector<Renderable*>& renderables = item.second;
0044 
0045         LOG << "----------------------------------" << LOG_END;
0046         LOG << "Found factory producing Renderables: " << factory_name << ", " << factory_tag << LOG_END;
0047         for (auto renderable : renderables) {
0048             renderable->Render();
0049         }
0050     }
0051 
0052     for (const auto& item : jobject_map) {
0053         // destructure
0054         std::string factory_name = item.first.first;
0055         std::string factory_tag = item.first.second;
0056         const std::vector<JObject*>& jobjects = item.second;
0057 
0058         LOG << "----------------------------------" << LOG_END;
0059         LOG << "Found factory producing JObjects: " << factory_name << ", " << factory_tag << LOG_END;
0060 
0061         for (auto jobject : jobjects) {
0062             LOG << "Found JObject with classname " << jobject->className() << LOG_END;
0063         }
0064     }
0065     LOG << "----------------------------------" << LOG_END;
0066 }
0067 
0068 void DstExampleProcessor::Finish() {
0069     // Close any resources
0070     LOG << "DstExampleProcessor::Finish" << LOG_END;
0071 }
0072