Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:20:39

0001 // -*- C++ -*-
0002 //
0003 // Package:    HLTCaloTowerFilter
0004 // Class:      HLTCaloTowerFilter
0005 //
0006 /**\class HLTCaloTowerFilter HLTCaloTowerFilter.cc Work/HLTCaloTowerFilter/src/HLTCaloTowerFilter.cc
0007 
0008  Description: <one line class summary>
0009 
0010  Implementation:
0011      <Notes on implementation>
0012 */
0013 // Original Author:  Yen-Jie Lee
0014 //         Created:  Wed Nov 13 16:12:29 CEST 2009
0015 
0016 // user include files
0017 #include "FWCore/Framework/interface/Frameworkfwd.h"
0018 #include "FWCore/Framework/interface/Event.h"
0019 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0020 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0021 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0022 #include "DataFormats/Common/interface/Handle.h"
0023 #include "DataFormats/CaloTowers/interface/CaloTower.h"
0024 #include "DataFormats/CaloTowers/interface/CaloTowerDefs.h"
0025 #include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h"
0026 #include "DataFormats/HLTReco/interface/TriggerTypeDefs.h"
0027 #include "HLTrigger/HLTcore/interface/HLTFilter.h"
0028 
0029 //
0030 // class declaration
0031 //
0032 class HLTCaloTowerFilter : public HLTFilter {
0033 public:
0034   explicit HLTCaloTowerFilter(const edm::ParameterSet&);
0035   ~HLTCaloTowerFilter() override;
0036   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0037 
0038 private:
0039   bool hltFilter(edm::Event&,
0040                  const edm::EventSetup&,
0041                  trigger::TriggerFilterObjectWithRefs& filterproduct) const override;
0042 
0043   // ----------member data ---------------------------
0044   edm::EDGetTokenT<CaloTowerCollection> inputToken_;
0045   edm::InputTag inputTag_;  // input tag identifying product
0046   double min_Pt_;           // pt threshold in GeV
0047   double max_Eta_;          // eta range (symmetric)
0048   unsigned int min_N_;      // number of objects passing cuts required
0049 };
0050 
0051 //
0052 // constructors and destructor
0053 //
0054 HLTCaloTowerFilter::HLTCaloTowerFilter(const edm::ParameterSet& config)
0055     : HLTFilter(config),
0056       inputTag_(config.getParameter<edm::InputTag>("inputTag")),
0057       min_Pt_(config.getParameter<double>("MinPt")),
0058       max_Eta_(config.getParameter<double>("MaxEta")),
0059       min_N_(config.getParameter<unsigned int>("MinN")) {
0060   inputToken_ = consumes<CaloTowerCollection>(inputTag_);
0061 }
0062 
0063 HLTCaloTowerFilter::~HLTCaloTowerFilter() {
0064   // do anything here that needs to be done at desctruction time
0065   // (e.g. close files, deallocate resources etc.)
0066 }
0067 
0068 void HLTCaloTowerFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0069   edm::ParameterSetDescription desc;
0070   makeHLTFilterDescription(desc);
0071   desc.add<edm::InputTag>("inputTag", edm::InputTag("hltTowerMakerForEcal"));
0072   desc.add<double>("MinPt", 3.0);
0073   desc.add<double>("MaxEta", 3.0);
0074   desc.add<unsigned int>("MinN", 1);
0075   descriptions.add("hltCaloTowerFilter", desc);
0076 }
0077 
0078 //
0079 // member functions
0080 //
0081 
0082 // ------------ method called on each new Event  ------------
0083 bool HLTCaloTowerFilter::hltFilter(edm::Event& event,
0084                                    const edm::EventSetup& setup,
0085                                    trigger::TriggerFilterObjectWithRefs& filterproduct) const {
0086   using namespace std;
0087   using namespace edm;
0088   using namespace reco;
0089 
0090   // All HLT filters must create and fill an HLT filter object,
0091   // recording any reconstructed physics objects satisfying (or not)
0092   // this HLT filter, and place it in the Event.
0093 
0094   // The filter object
0095   if (saveTags())
0096     filterproduct.addCollectionTag(inputTag_);
0097 
0098   // get hold of collection of objects
0099   Handle<CaloTowerCollection> caloTowers;
0100   event.getByToken(inputToken_, caloTowers);
0101 
0102   // look at all objects, check cuts and add to filter object
0103   unsigned int n = 0;
0104   for (auto const& i : *caloTowers) {
0105     if ((i.pt() >= min_Pt_) and ((max_Eta_ < 0.0) or (std::abs(i.eta()) <= max_Eta_)))
0106       ++n;
0107     //edm::Ref<CaloTowerCollection> ref(towers, std::distance(caloTowers->begin(), i));
0108     //filterproduct.addObject(TriggerJet, ref);
0109   }
0110 
0111   // filter decision
0112   return (n >= min_N_);
0113 }
0114 
0115 // declare this class as a framework plugin
0116 #include "FWCore/Framework/interface/MakerMacros.h"
0117 DEFINE_FWK_MODULE(HLTCaloTowerFilter);