CMS 3D CMS Logo

HLTJetHFCleaner.h
Go to the documentation of this file.
1 #ifndef HLTrigger_JetMET_plugins_HLTJetHFCleaner_h
2 #define HLTrigger_JetMET_plugins_HLTJetHFCleaner_h
3 
4 // -*- C++ -*-
5 //
6 // Package: HLTrigger/JetMET
7 // Class: HLTJetHFCleaner
8 //
30 //
31 // Original Author: Alp Akpinar
32 // Created: Wed, 01 Dec 2021 15:47:19 GMT
33 //
34 //
35 
36 #include <memory>
37 #include <vector>
38 
50 
51 template <typename JetType>
53 public:
54  typedef std::vector<JetType> JetCollection;
56  explicit HLTJetHFCleaner(const edm::ParameterSet&);
57  ~HLTJetHFCleaner() override = default;
58 
59  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
60 
61 private:
62  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
63 
66 
70 
71  // Minimum jet pt to consider while applying HF cuts
72  const float jetPtMin_;
73  const float dphiJetMetMin_;
74 
75  // Cuts will be applied to jets only with jetEtaMin_ < |eta| < jetEtaMax_
76  const float jetEtaMin_;
77  const float jetEtaMax_;
78 
79  const float sigmaEtaPhiDiffMax_;
81  const float cornerCutSigmaEtaEta_;
82  const float cornerCutSigmaPhiPhi_;
85  const bool applyStripSizeCut_;
86 };
87 
88 template <typename JetType>
90  : jetToken_(consumes(iConfig.getParameter<edm::InputTag>("jets"))),
91  metToken_(consumes(iConfig.getParameter<edm::InputTag>("mets"))),
92  sigmaEtaEtaToken_(consumes(iConfig.getParameter<edm::InputTag>("sigmaEtaEta"))),
93  sigmaPhiPhiToken_(consumes(iConfig.getParameter<edm::InputTag>("sigmaPhiPhi"))),
94  centralEtaStripSizeToken_(consumes(iConfig.getParameter<edm::InputTag>("centralEtaStripSize"))),
95  jetPtMin_(iConfig.getParameter<double>("jetPtMin")),
96  dphiJetMetMin_(iConfig.getParameter<double>("dphiJetMetMin")),
97  jetEtaMin_(iConfig.getParameter<double>("jetEtaMin")),
98  jetEtaMax_(iConfig.getParameter<double>("jetEtaMax")),
99  sigmaEtaPhiDiffMax_(iConfig.getParameter<double>("sigmaEtaPhiDiffMax")),
100  centralEtaStripSizeMax_(iConfig.getParameter<int>("centralEtaStripSizeMax")),
101  cornerCutSigmaEtaEta_(iConfig.getParameter<double>("cornerCutSigmaEtaEta")),
102  cornerCutSigmaPhiPhi_(iConfig.getParameter<double>("cornerCutSigmaPhiPhi")),
103  applySigmaEtaPhiCornerCut_(iConfig.getParameter<bool>("applySigmaEtaPhiCornerCut")),
104  applySigmaEtaPhiCut_(iConfig.getParameter<bool>("applySigmaEtaPhiCut")),
105  applyStripSizeCut_(iConfig.getParameter<bool>("applyStripSizeCut")) {
106  produces<JetCollection>();
107 }
108 
109 template <typename JetType>
111  auto const jets = iEvent.getHandle(jetToken_);
112  auto const& mets = iEvent.get(metToken_);
113 
114  // The set of cleaned jets
115  auto cleaned_jets = std::make_unique<JetCollection>();
116  cleaned_jets->reserve(jets->size());
117 
118  // Check if length of the MET vector is 1, throw exception otherwise
119  if (mets.size() != 1) {
120  throw cms::Exception("ComparisonFailure") << "Size of reco::MET collection is different from 1";
121  }
122  auto const met_phi = mets.front().phi();
123 
124  // HF shape variables gathered from valueMaps
125  // Normally, these valueMaps are the output of the HFJetShowerShape module:
126  // https://github.com/cms-sw/cmssw/blob/master/RecoJets/JetProducers/plugins/HFJetShowerShape.cc
127  auto const& sigmaEtaEtas = iEvent.get(sigmaEtaEtaToken_);
128  auto const& sigmaPhiPhis = iEvent.get(sigmaPhiPhiToken_);
129  auto const& centralEtaStripSizes = iEvent.get(centralEtaStripSizeToken_);
130 
131  // Loop over the jets and do cleaning
132  for (uint ijet = 0; ijet < jets->size(); ijet++) {
133  auto const jet = (*jets)[ijet];
134  auto const withinEtaRange = (std::abs(jet.eta()) < jetEtaMax_) and (std::abs(jet.eta()) > jetEtaMin_);
135  // Cuts are applied to jets that are back to back with MET
136  if (std::abs(reco::deltaPhi(jet.phi(), met_phi)) <= dphiJetMetMin_) {
137  cleaned_jets->emplace_back(jet);
138  continue;
139  }
140  // If the jet is outside the range that we're interested in,
141  // append it to the cleaned jets collection and continue
142  if ((jet.pt() < jetPtMin_) or (!withinEtaRange)) {
143  cleaned_jets->emplace_back(jet);
144  continue;
145  }
146 
147  JetRef const jetRef(jets, ijet);
148 
149  // Cuts related to eta and phi width of HF showers:
150  // Sigma eta-phi based cut + central strip size cut
151  // We'll apply the sigma eta+phi dependent cut only if requested via the config file
152  if (applySigmaEtaPhiCut_) {
153  // Sigma eta eta and sigma phi phi
154  auto const sigmaEtaEta = sigmaEtaEtas[jetRef];
155  auto const sigmaPhiPhi = sigmaPhiPhis[jetRef];
156 
157  // Check if sigma eta eta and sigma phi phi are both set to -1.
158  // If this is the case, we can skip the jet without evaluating any mask.
159  if ((sigmaEtaEta < 0) and (sigmaPhiPhi < 0)) {
160  cleaned_jets->emplace_back(jet);
161  continue;
162  }
163 
164  auto passSigmaEtaPhiCut = (sigmaEtaEta - sigmaPhiPhi) <= sigmaEtaPhiDiffMax_;
165 
166  if (applySigmaEtaPhiCornerCut_) {
167  auto const inCorner = (sigmaEtaEta < cornerCutSigmaEtaEta_) and (sigmaPhiPhi < cornerCutSigmaPhiPhi_);
168  passSigmaEtaPhiCut &= !inCorner;
169  }
170  if (!passSigmaEtaPhiCut) {
171  continue;
172  }
173  }
174 
175  // Cut related to central strip size
176  if (applyStripSizeCut_ and (centralEtaStripSizes[jetRef] > centralEtaStripSizeMax_)) {
177  continue;
178  }
179 
180  cleaned_jets->emplace_back(jet);
181  }
182 
183  iEvent.put(std::move(cleaned_jets));
184 }
185 
186 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
187 template <typename JetType>
190  desc.add<edm::InputTag>("jets", edm::InputTag("hltAK4PFJetsTightIDCorrected"))->setComment("Input jet collection.");
191  desc.add<edm::InputTag>("mets", edm::InputTag("hltMet"))->setComment("Input MET collection.");
192  desc.add<edm::InputTag>("sigmaEtaEta", edm::InputTag("hltHFJetShowerShape", "sigmaEtaEta"))
193  ->setComment("Input collection which stores the sigmaEtaEta values per jet.");
194  desc.add<edm::InputTag>("sigmaPhiPhi", edm::InputTag("hltHFJetShowerShape", "sigmaPhiPhi"))
195  ->setComment("Input collection which stores the sigmaPhiPhis values per jet.");
196  desc.add<edm::InputTag>("centralEtaStripSize", edm::InputTag("hltHFJetShowerShape", "centralEtaStripSize"))
197  ->setComment("Input collection which stores the central strip size values per jet.");
198  desc.add<double>("jetPtMin", 100)->setComment("The minimum pt value for a jet such that the cuts will be applied.");
199  desc.add<double>("dphiJetMetMin", 2.5)
200  ->setComment(
201  "The minimum value for deltaPhi between jet and MET, such that the cuts will be applied to a given jet.");
202  desc.add<double>("jetEtaMin", 2.9)->setComment("Minimum value of jet |eta| for which the cuts will be applied.");
203  desc.add<double>("jetEtaMax", 5.0)->setComment("Maximum value of jet |eta| for which the cuts will be applied.");
204  desc.add<double>("sigmaEtaPhiDiffMax", 0.05)
205  ->setComment("Determines the threshold in the following cut: sigmaEtaEta-sigmaPhiPhi <= X");
206  desc.add<double>("cornerCutSigmaEtaEta", 0.02)
207  ->setComment(
208  "Corner cut value for sigmaEtaEta. Jets will be cut if both sigmaEtaEta and sigmaPhiPhi are lower than the "
209  "corner value.");
210  desc.add<double>("cornerCutSigmaPhiPhi", 0.02)
211  ->setComment(
212  "Corner cut value for sigmaPhiPhi. Jets will be cut if both sigmaEtaEta and sigmaPhiPhi are lower than the "
213  "corner value.");
214  desc.add<int>("centralEtaStripSizeMax", 2)
215  ->setComment("Determines the threshold in the following cut: centralEtaStripSize <= X");
216  desc.add<bool>("applySigmaEtaPhiCornerCut", true)->setComment("Boolean specifying whether to apply the corner cut.");
217  desc.add<bool>("applySigmaEtaPhiCut", true)
218  ->setComment("Boolean specifying whether to apply the sigmaEtaEta-sigmaPhiPhi cut.");
219  desc.add<bool>("applyStripSizeCut", true)
220  ->setComment("Boolean specifying whether to apply the centralEtaStripSize cut.");
221  descriptions.addWithDefaultLabel(desc);
222 }
223 
224 #endif
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:26
edm::Ref< JetCollection > JetRef
const float cornerCutSigmaPhiPhi_
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
const edm::EDGetTokenT< edm::View< reco::MET > > metToken_
HLTJetHFCleaner(const edm::ParameterSet &)
const float dphiJetMetMin_
const float sigmaEtaPhiDiffMax_
const float centralEtaStripSizeMax_
const edm::EDGetTokenT< edm::ValueMap< int > > centralEtaStripSizeToken_
const float cornerCutSigmaEtaEta_
const float jetEtaMin_
const float jetEtaMax_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
~HLTJetHFCleaner() override=default
int iEvent
Definition: GenABIO.cc:224
const float jetPtMin_
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const edm::EDGetTokenT< std::vector< JetType > > jetToken_
const edm::EDGetTokenT< edm::ValueMap< float > > sigmaPhiPhiToken_
const bool applySigmaEtaPhiCut_
HLT enums.
const bool applyStripSizeCut_
std::vector< JetType > JetCollection
const bool applySigmaEtaPhiCornerCut_
def move(src, dest)
Definition: eostools.py:511
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
const edm::EDGetTokenT< edm::ValueMap< float > > sigmaEtaEtaToken_