Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef HLTCATopTagFilter_h
0002 #define HLTCATopTagFilter_h
0003 
0004 // system include files
0005 #include <memory>
0006 #include <vector>
0007 #include <sstream>
0008 
0009 // user include files
0010 #include "FWCore/Framework/interface/Event.h"
0011 #include "FWCore/Framework/interface/MakerMacros.h"
0012 #include "FWCore/PluginManager/interface/ModuleDef.h"
0013 #include "FWCore/Framework/interface/Frameworkfwd.h"
0014 #include "DataFormats/BTauReco/interface/CATopJetTagInfo.h"
0015 #include "FWCore/Utilities/interface/InputTag.h"
0016 #include "DataFormats/Math/interface/deltaR.h"
0017 #include "DataFormats/JetReco/interface/BasicJet.h"
0018 #include "DataFormats/Candidate/interface/CompositeCandidate.h"
0019 #include "DataFormats/HLTReco/interface/TriggerTypeDefs.h"
0020 #include "HLTrigger/HLTcore/interface/HLTFilter.h"
0021 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0022 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0023 #include <Math/VectorUtil.h>
0024 
0025 class CATopJetHelperUser {
0026 public:
0027   CATopJetHelperUser(double TopMass) : TopMass_(TopMass) {}
0028 
0029   reco::CATopJetProperties operator()(reco::Jet const& ihardJet) const;
0030 
0031 protected:
0032   double TopMass_;
0033 };
0034 
0035 struct GreaterByPtCandPtrUser {
0036   bool operator()(const edm::Ptr<reco::Candidate>& t1, const edm::Ptr<reco::Candidate>& t2) const {
0037     return t1->pt() > t2->pt();
0038   }
0039 };
0040 
0041 //
0042 // class declaration
0043 //
0044 
0045 class HLTCATopTagFilter : public HLTFilter {
0046 public:
0047   explicit HLTCATopTagFilter(const edm::ParameterSet&);
0048   ~HLTCATopTagFilter() override;
0049   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0050   bool hltFilter(edm::Event&,
0051                  const edm::EventSetup&,
0052                  trigger::TriggerFilterObjectWithRefs& filterobject) const override;
0053 
0054 private:
0055   // ----------member data ---------------------------
0056 
0057   edm::InputTag src_;
0058   edm::InputTag pfsrc_;
0059   const edm::EDGetTokenT<reco::BasicJetCollection> inputToken_;
0060   const edm::EDGetTokenT<reco::PFJetCollection> inputPFToken_;
0061   double TopMass_;
0062   double minTopMass_;
0063   double maxTopMass_;
0064   double minMinMass_;
0065 };
0066 
0067 inline reco::CATopJetProperties CATopJetHelperUser::operator()(reco::Jet const& ihardJet) const {
0068   reco::CATopJetProperties properties;
0069   // Get subjets
0070   reco::Jet::Constituents subjets = ihardJet.getJetConstituents();
0071   properties.nSubJets = subjets.size();  // number of subjets
0072   properties.topMass = ihardJet.mass();  // jet mass
0073   properties.minMass = 999999.;          // minimum mass pairing
0074 
0075   // Require at least three subjets in all cases, if not, untagged
0076   if (properties.nSubJets >= 3) {
0077     // Take the highest 3 pt subjets for cuts
0078     sort(subjets.begin(), subjets.end(), GreaterByPtCandPtrUser());
0079 
0080     // Now look at the subjets that were formed
0081     for (int isub = 0; isub < 2; ++isub) {
0082       // Get this subjet
0083       reco::Jet::Constituent icandJet = subjets[isub];
0084 
0085       // Now look at the "other" subjets than this one, form the minimum invariant mass
0086       // pairing, as well as the "closest" combination to the W mass
0087       for (int jsub = isub + 1; jsub < 3; ++jsub) {
0088         // Get the second subjet
0089         reco::Jet::Constituent jcandJet = subjets[jsub];
0090 
0091         reco::Candidate::LorentzVector wCand = icandJet->p4() + jcandJet->p4();
0092 
0093         // Get the candidate mass
0094         double imw = wCand.mass();
0095 
0096         // Find the minimum mass pairing.
0097         if (fabs(imw) < properties.minMass) {
0098           properties.minMass = imw;
0099         }
0100       }  // end second loop over subjets
0101     }    // end first loop over subjets
0102   }      // endif 3 subjets
0103 
0104   if (properties.minMass == 999999)
0105     properties.minMass = -1;
0106 
0107   return properties;
0108 }
0109 
0110 #endif