Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 /** \class HLTHcalTowerFilter
0002  *
0003  *  This class is an EDFilter implementing the following requirement:
0004  *  the number of caltowers with hadEnergy>E_Thr less than N_Thr for HB/HE/HF sperately.
0005  *
0006  *
0007  *  \author Li Wenbo (PKU)
0008  *
0009  */
0010 
0011 #include "HLTrigger/HLTcore/interface/HLTFilter.h"
0012 
0013 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0014 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0015 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0016 
0017 //
0018 // class declaration
0019 //
0020 class HLTHcalTowerFilter : public HLTFilter {
0021 public:
0022   explicit HLTHcalTowerFilter(const edm::ParameterSet&);
0023   ~HLTHcalTowerFilter() override;
0024   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0025 
0026 private:
0027   bool hltFilter(edm::Event&,
0028                  const edm::EventSetup&,
0029                  trigger::TriggerFilterObjectWithRefs& filterproduct) const override;
0030 
0031   edm::EDGetTokenT<CaloTowerCollection> inputToken_;
0032   edm::InputTag inputTag_;  // input tag identifying product
0033   double min_E_HB_;         // energy threshold for HB in GeV
0034   double min_E_HE_;         // energy threshold for HE in GeV
0035   double min_E_HF_;         // energy threshold for HF in GeV
0036   int max_N_HB_;            // maximum number for HB
0037   int max_N_HE_;            // maximum number for HB
0038   int max_N_HF_;            // maximum number for HB
0039   int min_N_HF_;            // minimum number for HB
0040   int min_N_HFM_;           // minimum number for HB-
0041   int min_N_HFP_;           // minimum number for HB+
0042 };
0043 
0044 #include <memory>
0045 
0046 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0047 #include "DataFormats/Common/interface/Handle.h"
0048 #include "DataFormats/Common/interface/Ref.h"
0049 #include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h"
0050 #include "DataFormats/HLTReco/interface/TriggerTypeDefs.h"
0051 
0052 //
0053 // constructors and destructor
0054 //
0055 HLTHcalTowerFilter::HLTHcalTowerFilter(const edm::ParameterSet& config)
0056     : HLTFilter(config),
0057       inputTag_(config.getParameter<edm::InputTag>("inputTag")),
0058       min_E_HB_(config.getParameter<double>("MinE_HB")),
0059       min_E_HE_(config.getParameter<double>("MinE_HE")),
0060       min_E_HF_(config.getParameter<double>("MinE_HF")),
0061       max_N_HB_(config.getParameter<int>("MaxN_HB")),
0062       max_N_HE_(config.getParameter<int>("MaxN_HE")),
0063       max_N_HF_(config.getParameter<int>("MaxN_HF")),
0064       min_N_HF_(-1),
0065       min_N_HFM_(-1),
0066       min_N_HFP_(-1) {
0067   if (config.existsAs<int>("MinN_HF")) {
0068     min_N_HF_ = config.getParameter<int>("MinN_HF");
0069   }
0070   if (config.existsAs<int>("MinN_HFM")) {
0071     min_N_HFM_ = config.getParameter<int>("MinN_HFM");
0072   }
0073   if (config.existsAs<int>("MinN_HFP")) {
0074     min_N_HFP_ = config.getParameter<int>("MinN_HFP");
0075   }
0076 
0077   inputToken_ = consumes<CaloTowerCollection>(inputTag_);
0078 }
0079 
0080 HLTHcalTowerFilter::~HLTHcalTowerFilter() = default;
0081 
0082 void HLTHcalTowerFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0083   edm::ParameterSetDescription desc;
0084   makeHLTFilterDescription(desc);
0085   desc.add<edm::InputTag>("inputTag", edm::InputTag("hltTowerMakerForHcal"));
0086   desc.add<double>("MinE_HB", 1.5);
0087   desc.add<double>("MinE_HE", 2.5);
0088   desc.add<double>("MinE_HF", 9.0);
0089   desc.add<int>("MaxN_HB", 2);
0090   desc.add<int>("MaxN_HE", 2);
0091   desc.add<int>("MaxN_HF", 8);
0092   desc.add<int>("MinN_HF", -1);
0093   desc.add<int>("MinN_HFM", -1);
0094   desc.add<int>("MinN_HFP", -1);
0095   descriptions.add("hltHcalTowerFilter", desc);
0096 }
0097 
0098 //
0099 // member functions
0100 //
0101 
0102 // ------------ method called to produce the data  ------------
0103 bool HLTHcalTowerFilter::hltFilter(edm::Event& event,
0104                                    const edm::EventSetup& setup,
0105                                    trigger::TriggerFilterObjectWithRefs& filterproduct) const {
0106   using namespace std;
0107   using namespace edm;
0108   using namespace reco;
0109   using namespace trigger;
0110 
0111   // The filter object
0112   if (saveTags())
0113     filterproduct.addCollectionTag(inputTag_);
0114 
0115   // get hold of collection of objects
0116   Handle<CaloTowerCollection> towers;
0117   event.getByToken(inputToken_, towers);
0118 
0119   // look at all objects, check cuts and add to filter object
0120   int n_HB = 0;
0121   int n_HE = 0;
0122   int n_HF = 0;
0123   int n_HFM = 0;
0124   int n_HFP = 0;
0125   double abseta = 0.0;
0126   double eta = 0.0;
0127   for (auto const& i : *towers) {
0128     eta = i.eta();
0129     abseta = std::abs(eta);
0130     if (abseta < 1.305) {
0131       if (i.hadEnergy() >= min_E_HB_) {
0132         n_HB++;
0133         //edm::Ref<CaloTowerCollection> ref(towers, std::distance(towers->begin(), i));
0134         //filterproduct.addObject(TriggerJet, ref);
0135       }
0136     } else if (abseta >= 1.305 && abseta < 3) {
0137       if (i.hadEnergy() >= min_E_HE_) {
0138         n_HE++;
0139         //edm::Ref<CaloTowerCollection> ref(towers, std::distance(towers->begin(), i));
0140         //filterproduct.addObject(TriggerJet, ref);
0141       }
0142     } else {
0143       if (i.hadEnergy() >= min_E_HF_) {
0144         n_HF++;
0145         //edm::Ref<CaloTowerCollection> ref(towers, std::distance(towers->begin(), i));
0146         //filterproduct.addObject(TriggerJet, ref);
0147         if (eta >= 3) {
0148           n_HFP++;
0149         } else {
0150           n_HFM++;
0151         }
0152       }
0153     }
0154   }
0155 
0156   // filter decision
0157   bool accept(n_HB < max_N_HB_ && n_HE < max_N_HE_ && n_HF < max_N_HF_ && n_HFP >= min_N_HFP_ && n_HFM >= min_N_HFM_ &&
0158               n_HF >= min_N_HF_);
0159 
0160   return accept;
0161 }
0162 
0163 // define as a framework module
0164 #include "FWCore/Framework/interface/MakerMacros.h"
0165 DEFINE_FWK_MODULE(HLTHcalTowerFilter);