Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:23:08

0001 #include "FWCore/Framework/interface/Frameworkfwd.h"
0002 #include "FWCore/Framework/interface/global/EDProducer.h"
0003 #include "FWCore/Framework/interface/Event.h"
0004 #include "FWCore/Framework/interface/MakerMacros.h"
0005 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0006 
0007 #include "DataFormats/L1THGCal/interface/HGCalMulticluster.h"
0008 #include "CommonTools/Utils/interface/StringCutObjectSelector.h"
0009 
0010 namespace l1t {
0011   class HGC3DClusterSimpleSelector : public edm::global::EDProducer<> {
0012   public:
0013     explicit HGC3DClusterSimpleSelector(const edm::ParameterSet &);
0014     ~HGC3DClusterSimpleSelector() override {}
0015     void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override;
0016 
0017   private:
0018     const edm::EDGetTokenT<l1t::HGCalMulticlusterBxCollection> src_;
0019     const StringCutObjectSelector<l1t::HGCalMulticluster> cut_;
0020 
0021   };  // class
0022 }  // namespace l1t
0023 
0024 l1t::HGC3DClusterSimpleSelector::HGC3DClusterSimpleSelector(const edm::ParameterSet &iConfig)
0025     : src_(consumes<l1t::HGCalMulticlusterBxCollection>(iConfig.getParameter<edm::InputTag>("src"))),
0026       cut_(iConfig.getParameter<std::string>("cut")) {
0027   produces<l1t::HGCalMulticlusterBxCollection>();
0028 }
0029 
0030 void l1t::HGC3DClusterSimpleSelector::produce(edm::StreamID, edm::Event &iEvent, const edm::EventSetup &) const {
0031   std::unique_ptr<l1t::HGCalMulticlusterBxCollection> out = std::make_unique<l1t::HGCalMulticlusterBxCollection>();
0032 
0033   edm::Handle<l1t::HGCalMulticlusterBxCollection> multiclusters;
0034   iEvent.getByToken(src_, multiclusters);
0035 
0036   for (int bx = multiclusters->getFirstBX(); bx <= multiclusters->getLastBX(); ++bx) {
0037     for (auto it = multiclusters->begin(bx), ed = multiclusters->end(bx); it != ed; ++it) {
0038       const auto &c = *it;
0039       if (cut_(c)) {
0040         out->push_back(bx, c);
0041       }
0042     }
0043   }
0044 
0045   iEvent.put(std::move(out));
0046 }
0047 using l1t::HGC3DClusterSimpleSelector;
0048 DEFINE_FWK_MODULE(HGC3DClusterSimpleSelector);