Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:18:40

0001 /** \class HLTEcalTowerFilter
0002  *
0003  *
0004  *  This class is an HLTFilter (-> EDFilter) implementing a
0005  *  single CaloTower requirement with an emEnergy threshold (not Et!)
0006  *
0007  *
0008  *  \author Seth Cooper
0009  *
0010  */
0011 
0012 #include "HLTrigger/HLTcore/interface/HLTFilter.h"
0013 
0014 #include <memory>
0015 
0016 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0017 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0018 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0019 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0020 #include "DataFormats/Common/interface/Handle.h"
0021 #include "DataFormats/Common/interface/Ref.h"
0022 #include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h"
0023 #include "DataFormats/HLTReco/interface/TriggerTypeDefs.h"
0024 
0025 //
0026 // class declaration
0027 //
0028 
0029 class HLTEcalTowerFilter : public HLTFilter {
0030 public:
0031   explicit HLTEcalTowerFilter(const edm::ParameterSet&);
0032   ~HLTEcalTowerFilter() override;
0033   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0034 
0035 private:
0036   bool hltFilter(edm::Event&,
0037                  const edm::EventSetup&,
0038                  trigger::TriggerFilterObjectWithRefs& filterproduct) const override;
0039 
0040   edm::EDGetTokenT<CaloTowerCollection> inputToken_;
0041   edm::InputTag inputTag_;  // input tag identifying product
0042   double min_E_;            // energy threshold in GeV
0043   double max_Eta_;          // maximum eta
0044   int min_N_;               // minimum number
0045 };
0046 
0047 //
0048 // constructors and destructor
0049 //
0050 HLTEcalTowerFilter::HLTEcalTowerFilter(const edm::ParameterSet& config)
0051     : HLTFilter(config),
0052       inputTag_(config.getParameter<edm::InputTag>("inputTag")),
0053       min_E_(config.getParameter<double>("MinE")),
0054       max_Eta_(config.getParameter<double>("MaxEta")),
0055       min_N_(config.getParameter<int>("MinN")) {
0056   inputToken_ = consumes<CaloTowerCollection>(inputTag_);
0057   LogDebug("") << "Input/ecut/etacut/ncut : " << inputTag_.encode() << " " << min_E_ << " " << max_Eta_ << " "
0058                << min_N_;
0059 }
0060 
0061 HLTEcalTowerFilter::~HLTEcalTowerFilter() = default;
0062 
0063 void HLTEcalTowerFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0064   edm::ParameterSetDescription desc;
0065   makeHLTFilterDescription(desc);
0066   desc.add<edm::InputTag>("inputTag", edm::InputTag("hltTowerMakerForEcal"));
0067   desc.add<double>("MinE", 10.);
0068   desc.add<double>("MaxEta", 3.);
0069   desc.add<int>("MinN", 1);
0070   descriptions.add("hltEcalTowerFilter", desc);
0071 }
0072 
0073 //
0074 // member functions
0075 //
0076 
0077 // ------------ method called to produce the data  ------------
0078 bool HLTEcalTowerFilter::hltFilter(edm::Event& event,
0079                                    const edm::EventSetup& setup,
0080                                    trigger::TriggerFilterObjectWithRefs& filterproduct) const {
0081   using namespace std;
0082   using namespace edm;
0083   using namespace reco;
0084   using namespace trigger;
0085 
0086   // All HLT filters must create and fill an HLT filter object,
0087   // recording any reconstructed physics objects satisfying (or not)
0088   // this HLT filter, and place it in the Event.
0089 
0090   // The filter object
0091   if (saveTags())
0092     filterproduct.addCollectionTag(inputTag_);
0093 
0094   // get hold of collection of objects
0095   Handle<CaloTowerCollection> towers;
0096   event.getByToken(inputToken_, towers);
0097 
0098   LogDebug("HLTEcalTowerFilter") << "Number of towers: " << towers->size();
0099 
0100   // look at all objects, check cuts and add to filter object
0101   int n = 0;
0102   for (auto const& i : *towers) {
0103     if (i.emEnergy() >= min_E_ and fabs(i.eta()) <= max_Eta_) {
0104       ++n;
0105       //edm::Ref<CaloTowerCollection> ref(towers, std::distance(towers->begin(), i));
0106       //filterproduct.addObject(TriggerJet, ref);
0107     }
0108   }
0109 
0110   LogDebug("HLTEcalTowerFilter") << "Number of towers with eta < " << max_Eta_ << " and energy > " << min_E_ << ": "
0111                                  << n;
0112 
0113   // filter decision
0114   bool accept(n >= min_N_);
0115 
0116   return accept;
0117 }
0118 
0119 // define as a framework module
0120 #include "FWCore/Framework/interface/MakerMacros.h"
0121 DEFINE_FWK_MODULE(HLTEcalTowerFilter);