Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-06-13 03:24:00

0001 // Author: Felice Pantaleo, Wahid Redjeb, Aurora Perego (CERN) - felice.pantaleo@cern.ch, wahid.redjeb@cern.ch, aurora.perego@cern.ch
0002 // Date: 12/2023
0003 #include "FWCore/Framework/interface/stream/EDProducer.h"
0004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0005 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0006 #include "FWCore/ParameterSet/interface/PluginDescription.h"
0007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0008 #include "FWCore/Utilities/interface/ESGetToken.h"
0009 #include "FWCore/Framework/interface/ESHandle.h"
0010 #include "FWCore/Framework/interface/Frameworkfwd.h"
0011 #include "FWCore/Framework/interface/MakerMacros.h"
0012 #include "DataFormats/HGCalReco/interface/Trackster.h"
0013 
0014 using namespace ticl;
0015 
0016 class MergedTrackstersProducer : public edm::stream::EDProducer<> {
0017 public:
0018   explicit MergedTrackstersProducer(const edm::ParameterSet &ps);
0019   ~MergedTrackstersProducer() override{};
0020   void produce(edm::Event &, const edm::EventSetup &) override;
0021   static void fillDescriptions(edm::ConfigurationDescriptions &descriptions);
0022 
0023 private:
0024   edm::EDGetTokenT<std::vector<Trackster>> egamma_tracksters_token_;
0025 
0026   edm::EDGetTokenT<std::vector<Trackster>> general_tracksters_token_;
0027 };
0028 
0029 MergedTrackstersProducer::MergedTrackstersProducer(const edm::ParameterSet &ps)
0030     : egamma_tracksters_token_(
0031           consumes<std::vector<ticl::Trackster>>(ps.getParameter<edm::InputTag>("egamma_tracksters"))),
0032       general_tracksters_token_(
0033           consumes<std::vector<ticl::Trackster>>(ps.getParameter<edm::InputTag>("had_tracksters"))) {
0034   produces<std::vector<Trackster>>();
0035 }
0036 
0037 void MergedTrackstersProducer::produce(edm::Event &evt, const edm::EventSetup &es) {
0038   auto resultTracksters = std::make_unique<std::vector<Trackster>>();
0039   auto const &egamma_tracksters = evt.get(egamma_tracksters_token_);
0040   auto const &had_tracksters = evt.get(general_tracksters_token_);
0041   for (auto const &eg_trackster : egamma_tracksters) {
0042     resultTracksters->push_back(eg_trackster);
0043   }
0044   for (auto const &had_trackster : had_tracksters) {
0045     resultTracksters->push_back(had_trackster);
0046   }
0047 
0048   evt.put(std::move(resultTracksters));
0049 }
0050 
0051 void MergedTrackstersProducer::fillDescriptions(edm::ConfigurationDescriptions &descriptions) {
0052   edm::ParameterSetDescription desc;
0053   desc.add<edm::InputTag>("egamma_tracksters", edm::InputTag("ticlTrackstersCLUE3DEM"));
0054   desc.add<edm::InputTag>("had_tracksters", edm::InputTag("ticlTrackstersCLUE3DHAD"));
0055   descriptions.add("mergedTrackstersProducer", desc);
0056 }
0057 
0058 DEFINE_FWK_MODULE(MergedTrackstersProducer);