Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:11:48

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 #pragma once
0006 #include <JANA/JEvent.h>
0007 #include <JANA/JEventSource.h>
0008 
0009 template <typename T>
0010 class JGetObjectsFactory : public JFactoryT<T> {
0011 
0012     /// JGetObjectsFactory allows us to use `JEventSource::GetObjects` with JANA2.
0013     /// Use of GetObjects is deprecated and strongly discouraged in favor of using
0014     /// JEvent::Insert instead. However, rewriting the halld event sources is a
0015     /// monumental task, so we keep GetObjects for now and use this as the mechanism
0016     /// to call into it.
0017 
0018 public:
0019     JGetObjectsFactory(std::string tag="") {
0020         JFactory::SetTag(tag);
0021     }
0022 
0023     void Process(const std::shared_ptr<const JEvent>& event) {
0024         JEventSource* source = event->GetJEventSource();
0025         source->GetObjects(event, this);
0026         // if (!result) throw JException("JGetObjectsFactory registered with a source that doesn't provide said objects");
0027         // JANA can't/shouldn't distinguish between "Source can't provide said objects" and "Source provided zero"
0028         // Examples: DMCThrown, DDIRCTruthBarHit
0029         JFactory::mCreationStatus = JFactory::CreationStatus::InsertedViaGetObjects;
0030     }
0031 
0032 };