Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:49:44

0001 /** \class L1TPFTauFilter
0002  *
0003  * See header file for documentation
0004  *
0005  *
0006  *  \author Martin Grunewald
0007  *  \author Sandeep Bhowmik 
0008  *  \author Thiago Tomei
0009  *
0010  */
0011 
0012 #include "L1TPFTauFilter.h"
0013 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0014 
0015 #include "DataFormats/Common/interface/Handle.h"
0016 
0017 #include "DataFormats/Common/interface/Ref.h"
0018 #include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h"
0019 #include "DataFormats/HLTReco/interface/TriggerTypeDefs.h"
0020 
0021 #include "FWCore/Framework/interface/EventSetup.h"
0022 #include "FWCore/Framework/interface/EventSetupRecord.h"
0023 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0024 
0025 //
0026 // constructors and destructor
0027 //
0028 
0029 L1TPFTauFilter::L1TPFTauFilter(const edm::ParameterSet& iConfig)
0030     : HLTFilter(iConfig),
0031       l1PFTauTag_(iConfig.getParameter<edm::InputTag>("inputTag")),
0032       pfTauToken_(consumes<l1t::PFTauCollection>(l1PFTauTag_)) {
0033   min_Pt_ = iConfig.getParameter<double>("MinPt");
0034   min_N_ = iConfig.getParameter<int>("MinN");
0035   min_Eta_ = iConfig.getParameter<double>("MinEta");
0036   max_Eta_ = iConfig.getParameter<double>("MaxEta");
0037   maxChargedIso_ = iConfig.getParameter<double>("MaxChargedIso");
0038   maxFullIso_ = iConfig.getParameter<double>("MaxFullIso");
0039   passLooseNN_ = iConfig.getParameter<int>("PassLooseNN");
0040   passTightNN_ = iConfig.getParameter<int>("PassTightNN");
0041   scalings_ = iConfig.getParameter<edm::ParameterSet>("Scalings");
0042   barrelScalings_ = scalings_.getParameter<std::vector<double> >("barrel");
0043   endcapScalings_ = scalings_.getParameter<std::vector<double> >("endcap");
0044 }
0045 
0046 L1TPFTauFilter::~L1TPFTauFilter() = default;
0047 
0048 //
0049 // member functions
0050 //
0051 
0052 void L1TPFTauFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0053   edm::ParameterSetDescription desc;
0054   makeHLTFilterDescription(desc);
0055   desc.add<double>("MinPt", -1.0);
0056   desc.add<double>("MinEta", -5.0);
0057   desc.add<double>("MaxEta", 5.0);
0058   desc.add<int>("MinN", 1);
0059   desc.add<double>("MaxChargedIso", 1.0E9);  // could use std::numeric_limits<double>::max(), but it is overkill...
0060   desc.add<double>("MaxFullIso", 1.0E9);
0061   desc.add<int>("PassLooseNN", -1);
0062   desc.add<int>("PassTightNN", -1);
0063   desc.add<edm::InputTag>("inputTag", edm::InputTag("L1PFTausNN"));
0064 
0065   edm::ParameterSetDescription descScalings;
0066   descScalings.add<std::vector<double> >("barrel", {0.0, 1.0, 0.0});
0067   descScalings.add<std::vector<double> >("overlap", {0.0, 1.0, 0.0});
0068   descScalings.add<std::vector<double> >("endcap", {0.0, 1.0, 0.0});
0069   desc.add<edm::ParameterSetDescription>("Scalings", descScalings);
0070 
0071   descriptions.add("L1TPFTauFilter", desc);
0072 }
0073 
0074 // ------------ method called to produce the data  ------------
0075 bool L1TPFTauFilter::hltFilter(edm::Event& iEvent,
0076                                const edm::EventSetup& iSetup,
0077                                trigger::TriggerFilterObjectWithRefs& filterproduct) const {
0078   using namespace std;
0079   using namespace edm;
0080   using namespace reco;
0081   using namespace trigger;
0082 
0083   // All HLT filters must create and fill an HLT filter object,
0084   // recording any reconstructed physics objects satisfying (or not)
0085   // this HLT filter, and place it in the Event.
0086 
0087   // The filter object
0088   if (saveTags()) {
0089     filterproduct.addCollectionTag(l1PFTauTag_);
0090   }
0091 
0092   // Specific filter code
0093 
0094   // get hold of products from Event
0095   Handle<l1t::PFTauCollection> PFTaus;
0096   iEvent.getByToken(pfTauToken_, PFTaus);
0097 
0098   // pftau
0099   int npftau(0);
0100   auto apftaus(PFTaus->begin());
0101   auto opftaus(PFTaus->end());
0102   l1t::PFTauCollection::const_iterator iPFTau;
0103   for (iPFTau = apftaus; iPFTau != opftaus; iPFTau++) {
0104     double offlinePt = this->PFTauOfflineEt(iPFTau->pt(), iPFTau->eta());
0105     if (offlinePt >= min_Pt_ && iPFTau->eta() <= max_Eta_ && iPFTau->eta() >= min_Eta_ &&
0106         iPFTau->passLooseNN() > passLooseNN_ && iPFTau->passTightNN() > passTightNN_ &&
0107         iPFTau->chargedIso() < maxChargedIso_ && iPFTau->fullIso() < maxFullIso_) {
0108       npftau++;
0109       l1t::PFTauRef ref(l1t::PFTauRef(PFTaus, distance(apftaus, iPFTau)));
0110       filterproduct.addObject(trigger::TriggerObjectType::TriggerL1PFTau, ref);
0111     }
0112   }
0113 
0114   // return with final filter decision
0115   const bool accept(npftau >= min_N_);
0116   return accept;
0117 }
0118 
0119 double L1TPFTauFilter::PFTauOfflineEt(double Et, double Eta) const {
0120   if (std::abs(Eta) < 1.5)
0121     return (barrelScalings_.at(0) + Et * barrelScalings_.at(1) + Et * Et * barrelScalings_.at(2));
0122   else
0123     return (endcapScalings_.at(0) + Et * endcapScalings_.at(1) + Et * Et * endcapScalings_.at(2));
0124 }