Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 /** \class HLTPFEnergyFractionsFilter
0002 *
0003 *
0004 *  \author Srimanobhas Phat
0005 *
0006 *  Please see the description of this class in
0007 *  "HLTrigger/JetMET/interface/HLTPFEnergyFractionsFilter.h"
0008 *
0009 */
0010 
0011 #include "HLTrigger/JetMET/interface/HLTPFEnergyFractionsFilter.h"
0012 
0013 #include "DataFormats/Common/interface/Handle.h"
0014 
0015 #include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h"
0016 
0017 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0018 
0019 #include "FWCore/Framework/interface/ESHandle.h"
0020 #include "FWCore/Framework/interface/EventSetup.h"
0021 
0022 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0023 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0024 #include "FWCore/Utilities/interface/InputTag.h"
0025 
0026 //
0027 // constructors and destructor
0028 //
0029 HLTPFEnergyFractionsFilter::HLTPFEnergyFractionsFilter(const edm::ParameterSet& iConfig) : HLTFilter(iConfig) {
0030   inputPFJetTag_ = iConfig.getParameter<edm::InputTag>("inputPFJetTag");
0031   nJet_ = iConfig.getParameter<unsigned int>("nJet");
0032   min_CEEF_ = iConfig.getParameter<double>("min_CEEF");
0033   max_CEEF_ = iConfig.getParameter<double>("max_CEEF");
0034   min_NEEF_ = iConfig.getParameter<double>("min_NEEF");
0035   max_NEEF_ = iConfig.getParameter<double>("max_NEEF");
0036   min_CHEF_ = iConfig.getParameter<double>("min_CHEF");
0037   max_CHEF_ = iConfig.getParameter<double>("max_CHEF");
0038   min_NHEF_ = iConfig.getParameter<double>("min_NHEF");
0039   max_NHEF_ = iConfig.getParameter<double>("max_NHEF");
0040   triggerType_ = iConfig.getParameter<int>("triggerType");
0041   m_thePFJetToken = consumes<reco::PFJetCollection>(inputPFJetTag_);
0042 }
0043 
0044 HLTPFEnergyFractionsFilter::~HLTPFEnergyFractionsFilter() = default;
0045 
0046 void HLTPFEnergyFractionsFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0047   edm::ParameterSetDescription desc;
0048   makeHLTFilterDescription(desc);
0049   desc.add<edm::InputTag>("inputPFJetTag", edm::InputTag("hltAntiKT5PFJets"));
0050   desc.add<unsigned int>("nJet", 1);
0051   desc.add<double>("min_CEEF", -99.);
0052   desc.add<double>("max_CEEF", 99.);
0053   desc.add<double>("min_NEEF", -99.);
0054   desc.add<double>("max_NEEF", 99.);
0055   desc.add<double>("min_CHEF", -99.);
0056   desc.add<double>("max_CHEF", 99.);
0057   desc.add<double>("min_NHEF", -99.);
0058   desc.add<double>("max_NHEF", 99.);
0059   desc.add<int>("triggerType", trigger::TriggerJet);
0060   descriptions.add("hltPFEnergyFractionsFilter", desc);
0061 }
0062 
0063 // ------------ method called to produce the data  ------------
0064 bool HLTPFEnergyFractionsFilter::hltFilter(edm::Event& iEvent,
0065                                            const edm::EventSetup& iSetup,
0066                                            trigger::TriggerFilterObjectWithRefs& filterproduct) const {
0067   using namespace std;
0068   using namespace edm;
0069   using namespace reco;
0070   using namespace trigger;
0071 
0072   // The filter object
0073   if (saveTags())
0074     filterproduct.addCollectionTag(inputPFJetTag_);
0075 
0076   // PFJets
0077   edm::Handle<PFJetCollection> recopfjets;
0078   iEvent.getByToken(m_thePFJetToken, recopfjets);
0079 
0080   //Checking
0081   bool accept(false);
0082 
0083   if (recopfjets->size() >= nJet_) {
0084     accept = true;
0085     unsigned int countJet(0);
0086     //PF information
0087     auto i(recopfjets->begin());
0088     for (; i != recopfjets->end(); ++i) {
0089       if (countJet >= nJet_)
0090         break;
0091       //
0092       if (i->chargedEmEnergyFraction() < min_CEEF_)
0093         accept = false;
0094       if (i->chargedEmEnergyFraction() > max_CEEF_)
0095         accept = false;
0096       //
0097       if (i->neutralEmEnergyFraction() < min_NEEF_)
0098         accept = false;
0099       if (i->neutralEmEnergyFraction() > max_NEEF_)
0100         accept = false;
0101       //
0102       if (i->chargedHadronEnergyFraction() < min_CHEF_)
0103         accept = false;
0104       if (i->chargedHadronEnergyFraction() > max_CHEF_)
0105         accept = false;
0106       //
0107       if (i->neutralHadronEnergyFraction() < min_NHEF_)
0108         accept = false;
0109       if (i->neutralHadronEnergyFraction() > max_NHEF_)
0110         accept = false;
0111       //
0112       if (accept == false)
0113         break;
0114       countJet++;
0115     }
0116 
0117     //Store NJet_ jets
0118     if (accept == true) {
0119       countJet = 0;
0120       auto i(recopfjets->begin());
0121       for (; i != recopfjets->end(); ++i) {
0122         if (countJet >= nJet_)
0123           break;
0124         filterproduct.addObject(triggerType_, PFJetRef(recopfjets, distance(recopfjets->begin(), i)));
0125         countJet++;
0126       }
0127     }
0128   }  // End of (recopfjets->size() >= nJet_)
0129 
0130   return accept;
0131 }