Warning, file /juggler/JugReco/src/components/TrackingHitsCollector2.cpp was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005 #include "Gaudi/Algorithm.h"
0006 #include "Gaudi/Property.h"
0007
0008 #include <k4FWCore/DataHandle.h>
0009
0010
0011 #include "edm4eic/TrackerHitCollection.h"
0012
0013 namespace Jug::Reco {
0014
0015
0016
0017
0018
0019
0020
0021
0022 class TrackingHitsCollector2 : public Gaudi::Algorithm {
0023 private:
0024 Gaudi::Property<std::vector<std::string>> m_inputTrackingHits{this, "inputTrackingHits", {},"Tracker hits to be aggregated"};
0025 mutable DataHandle<edm4eic::TrackerHitCollection> m_trackingHits{"trackingHits", Gaudi::DataHandle::Writer, this};
0026
0027 mutable std::vector<DataHandle<edm4eic::TrackerHitCollection>*> m_hitCollections;
0028
0029 public:
0030 TrackingHitsCollector2(const std::string& name, ISvcLocator* svcLoc)
0031 : Gaudi::Algorithm(name, svcLoc)
0032 {
0033 declareProperty("trackingHits", m_trackingHits, "output hits combined into single collection");
0034 }
0035 ~TrackingHitsCollector2() {
0036 for (auto* col : m_hitCollections) {
0037 delete col;
0038 }
0039 }
0040
0041 StatusCode initialize() override {
0042 if (Gaudi::Algorithm::initialize().isFailure()) {
0043 return StatusCode::FAILURE;
0044 }
0045 for (auto colname : m_inputTrackingHits) {
0046 debug() << "initializing collection: " << colname << endmsg;
0047 m_hitCollections.push_back(new DataHandle<edm4eic::TrackerHitCollection>{colname, Gaudi::DataHandle::Reader, this});
0048 }
0049 return StatusCode::SUCCESS;
0050 }
0051
0052 StatusCode execute(const EventContext&) const override
0053 {
0054 auto* outputHits = m_trackingHits.createAndPut();
0055 if (msgLevel(MSG::DEBUG)) {
0056 debug() << "execute collector" << endmsg;
0057 }
0058 for(const auto& hits: m_hitCollections) {
0059 const edm4eic::TrackerHitCollection* hitCol = hits->get();
0060 if (msgLevel(MSG::DEBUG)) {
0061 debug() << "col n hits: " << hitCol->size() << endmsg;
0062 }
0063 for (const auto& ahit : *hitCol) {
0064 outputHits->push_back(ahit.clone());
0065 }
0066 }
0067
0068 return StatusCode::SUCCESS;
0069 }
0070 };
0071
0072 DECLARE_COMPONENT_WITH_ID(TrackingHitsCollector2, "TrackingHitsCollector")
0073
0074 DECLARE_COMPONENT(TrackingHitsCollector2)
0075
0076 }