Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:53:06

0001 #ifndef HLTCAWZTagFilter_h
0002 #define HLTCAWZTagFilter_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 "DataFormats/BTauReco/interface/CATopJetTagInfo.h"
0013 #include "FWCore/Utilities/interface/InputTag.h"
0014 #include "DataFormats/JetReco/interface/BasicJet.h"
0015 #include "DataFormats/JetReco/interface/CaloJet.h"
0016 #include "DataFormats/Candidate/interface/CompositeCandidate.h"
0017 #include "CommonTools/CandUtils/interface/AddFourMomenta.h"
0018 #include "DataFormats/Candidate/interface/CandMatchMap.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 CAWZJetHelperUser {
0026 public:
0027   CAWZJetHelperUser(double massdropcut) : massdropcut_(massdropcut) {}
0028 
0029   reco::CATopJetProperties operator()(reco::Jet const& ihardJet) const;
0030 
0031 protected:
0032   double massdropcut_;
0033 };
0034 
0035 //
0036 // class declaration
0037 //
0038 
0039 class HLTCAWZTagFilter : public HLTFilter {
0040 public:
0041   explicit HLTCAWZTagFilter(const edm::ParameterSet&);
0042   ~HLTCAWZTagFilter() override;
0043   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0044   bool hltFilter(edm::Event&,
0045                  const edm::EventSetup&,
0046                  trigger::TriggerFilterObjectWithRefs& filterobject) const override;
0047 
0048 private:
0049   // ----------member data ---------------------------
0050 
0051   edm::InputTag src_;
0052   edm::InputTag pfsrc_;
0053   const edm::EDGetTokenT<reco::BasicJetCollection> inputToken_;
0054   const edm::EDGetTokenT<reco::PFJetCollection> inputPFToken_;
0055   double minWMass_;
0056   double maxWMass_;
0057   double massdropcut_;
0058 };
0059 
0060 inline reco::CATopJetProperties CAWZJetHelperUser::operator()(reco::Jet const& ihardJet) const {
0061   reco::CATopJetProperties properties;
0062   // Get subjets
0063   reco::Jet::Constituents subjets = ihardJet.getJetConstituents();
0064   properties.nSubJets = subjets.size();  // number of subjets
0065   properties.wMass = 999999.;            // best W mass
0066   properties.topMass = 999999.;
0067   properties.minMass = -1;
0068 
0069   if (properties.nSubJets == 2) {
0070     sort(subjets.begin(), subjets.end(), [](auto const& t1, auto const& t2) { return t1->pt() > t2->pt(); });
0071 
0072     reco::Jet::Constituent icandJet = subjets[0];
0073 
0074     reco::Candidate::LorentzVector isubJet = icandJet->p4();
0075     double imass = isubJet.mass();
0076     double imw = ihardJet.mass();
0077 
0078     if (imass / imw < massdropcut_) {
0079       // Get the candidate mass
0080       properties.wMass = imw;
0081     }
0082   }
0083 
0084   return properties;
0085 }
0086 
0087 #endif