Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-01-18 23:29:07

0001 /** \class HLTPFTauIPFilter
0002  *
0003  *  This class is an HLTFilter able to implement
0004  *  generic cuts on the tau IP variables available in the PFTauTransverseImpactParameter collection
0005  *
0006  */
0007 
0008 #include "FWCore/Framework/interface/Frameworkfwd.h"
0009 #include "FWCore/Framework/interface/MakerMacros.h"
0010 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0011 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0012 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0013 #include "FWCore/Utilities/interface/InputTag.h"
0014 #include "DataFormats/TauReco/interface/PFTau.h"
0015 #include "DataFormats/TauReco/interface/PFTauFwd.h"
0016 #include "DataFormats/TauReco/interface/PFTauTransverseImpactParameterAssociation.h"
0017 #include "HLTrigger/HLTcore/interface/HLTFilter.h"
0018 #include "CommonTools/Utils/interface/StringCutObjectSelector.h"
0019 #include <vector>
0020 
0021 class HLTPFTauIPFilter : public HLTFilter {
0022 public:
0023   explicit HLTPFTauIPFilter(const edm::ParameterSet& config);
0024   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0025   bool hltFilter(edm::Event& event,
0026                  const edm::EventSetup& setup,
0027                  trigger::TriggerFilterObjectWithRefs& filterproduct) const override;
0028 
0029 private:
0030   const edm::InputTag m_TausInputTag;
0031   const edm::EDGetTokenT<reco::PFTauCollection> m_TausToken;
0032   const edm::EDGetTokenT<edm::AssociationVector<reco::PFTauRefProd, std::vector<reco::PFTauTransverseImpactParameterRef>>>
0033       m_TausTIPToken;
0034 
0035   const int m_MinTaus;  // min. number of taus required to pass the cuts
0036   const std::string m_tauTIPSelectorString;
0037   const StringCutObjectSelector<reco::PFTauTransverseImpactParameter> m_tauTIPSelector;
0038   const int m_TriggerType;
0039 };
0040 
0041 HLTPFTauIPFilter::HLTPFTauIPFilter(const edm::ParameterSet& config)
0042     : HLTFilter(config),
0043       m_TausInputTag(config.getParameter<edm::InputTag>("Taus")),
0044       m_TausToken(consumes(m_TausInputTag)),
0045       m_TausTIPToken(consumes(config.getParameter<edm::InputTag>("TausIP"))),
0046       m_MinTaus(config.getParameter<int>("MinN")),
0047       m_tauTIPSelectorString(config.getParameter<std::string>("Cut")),
0048       m_tauTIPSelector(m_tauTIPSelectorString),
0049       m_TriggerType(config.getParameter<int>("TriggerType")) {
0050   edm::LogInfo("") << " (HLTPFTauIPFilter) trigger cuts:\n"
0051                    << " cut string value: [" << m_tauTIPSelectorString << "]\n"
0052                    << " min no. passing taus: " << m_MinTaus << ", TriggerType: " << m_TriggerType;
0053 }
0054 
0055 void HLTPFTauIPFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0056   edm::ParameterSetDescription desc;
0057   makeHLTFilterDescription(desc);
0058   desc.add<edm::InputTag>("Taus", edm::InputTag("hltTauCollection"));
0059   desc.add<edm::InputTag>("TausIP", edm::InputTag("hltTauIPCollection"));
0060   desc.add<int>("MinN", 1);
0061   desc.add<int>("TriggerType", 84);
0062   desc.add<std::string>("Cut", "dxy > -999.");
0063   descriptions.addWithDefaultLabel(desc);
0064 }
0065 
0066 bool HLTPFTauIPFilter::hltFilter(edm::Event& event,
0067                                  const edm::EventSetup& setup,
0068                                  trigger::TriggerFilterObjectWithRefs& filterproduct) const {
0069   auto const h_Taus = event.getHandle(m_TausToken);
0070   if (saveTags())
0071     filterproduct.addCollectionTag(m_TausInputTag);
0072 
0073   auto const& TausTIP = event.get(m_TausTIPToken);
0074 
0075   int nTau = 0;
0076   for (reco::PFTauCollection::size_type iPFTau = 0; iPFTau < h_Taus->size(); iPFTau++) {
0077     reco::PFTauRef tauref(h_Taus, iPFTau);
0078 
0079     if (m_tauTIPSelector(*TausTIP[tauref])) {
0080       ++nTau;
0081       filterproduct.addObject(m_TriggerType, tauref);
0082     }
0083   }
0084 
0085   // filter decision
0086   bool const accept = (nTau >= m_MinTaus);
0087   edm::LogInfo("") << " trigger accept ? = " << accept << " nTau = " << nTau;
0088 
0089   return accept;
0090 }
0091 
0092 DEFINE_FWK_MODULE(HLTPFTauIPFilter);