CMS 3D CMS Logo

HLTJetL1TMatchProducer.cc
Go to the documentation of this file.
1 #include <cmath>
2 #include <memory>
3 
12 
13 template <typename T>
15  jetsInput_ = iConfig.template getParameter<edm::InputTag>("jetsInput");
16  L1Jets_ = iConfig.template getParameter<edm::InputTag>("L1Jets");
17 
18  // minimum delta-R^2 threshold with sign
19  auto const DeltaR = iConfig.template getParameter<double>("DeltaR");
20  DeltaR2_ = DeltaR * std::abs(DeltaR);
21 
22  m_theJetToken = consumes(jetsInput_);
23  m_theL1JetToken = consumes(L1Jets_);
24 
25  produces<std::vector<T>>();
26 }
27 
28 template <typename T>
31  desc.add<edm::InputTag>("jetsInput", edm::InputTag("hltAntiKT5PFJets"));
32  desc.add<edm::InputTag>("L1Jets", edm::InputTag("hltCaloStage2Digis"));
33  desc.add<double>("DeltaR", 0.5);
35 }
36 
37 template <typename T>
39  auto const& jets = iEvent.get(m_theJetToken);
40  auto const l1Jets = iEvent.getHandle(m_theL1JetToken);
41 
42  bool trigger_bx_only = true; // selection of BX not implemented
43 
44  auto result = std::make_unique<std::vector<T>>();
45 
46  if (l1Jets.isValid()) {
47  for (auto const& jet : jets) {
48  bool isMatched = false;
49  for (int ibx = l1Jets->getFirstBX(); ibx <= l1Jets->getLastBX(); ++ibx) {
50  if (trigger_bx_only && (ibx != 0))
51  continue;
52  for (auto it = l1Jets->begin(ibx); it != l1Jets->end(ibx); it++) {
53  if (it->et() == 0)
54  continue; // if you don't care about L1T candidates with zero ET.
55  if (reco::deltaR2(jet.eta(), jet.phi(), it->eta(), it->phi()) < DeltaR2_) {
56  isMatched = true;
57  break;
58  }
59  }
60  }
61  if (isMatched) {
62  result->emplace_back(jet);
63  }
64  }
65  } else {
66  edm::LogWarning("MissingProduct") << "L1Upgrade l1Jets bx collection not found.";
67  }
68 
69  iEvent.put(std::move(result));
70 }
Definition: DeltaR.py:1
std::string defaultModuleLabel()
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
int iEvent
Definition: GenABIO.cc:224
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool isMatched(TrackingRecHit const &hit)
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void produce(edm::Event &, const edm::EventSetup &) override
HLTJetL1TMatchProducer(const edm::ParameterSet &)
Log< level::Warning, false > LogWarning
def move(src, dest)
Definition: eostools.py:511