CMS 3D CMS Logo

EgammaHLTCaloTowerProducer.cc
Go to the documentation of this file.
1 
19 
22 
25 
26 #include "Math/GenVector/VectorUtil.h"
27 
28 #include <cmath>
29 #include <string>
30 
32 public:
35  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
36  void produce(edm::StreamID, edm::Event&, edm::EventSetup const&) const final;
37 
39  const double cone_;
42  const double EtThreshold_;
43  const double EThreshold_;
44 };
45 
46 using namespace edm;
47 using namespace reco;
48 using namespace std;
49 using namespace l1extra;
50 
52  : towers_(consumes<CaloTowerCollection>(p.getParameter<InputTag>("towerCollection"))),
53  cone_(p.getParameter<double>("useTowersInCone")),
54  l1isoseeds_(consumes<edm::View<reco::Candidate>>(p.getParameter<edm::InputTag>("L1IsoCand"))),
55  l1nonisoseeds_(consumes<edm::View<reco::Candidate>>(p.getParameter<edm::InputTag>("L1NonIsoCand"))),
56  EtThreshold_(p.getParameter<double>("EtMin")),
57  EThreshold_(p.getParameter<double>("EMin")) {
58  produces<CaloTowerCollection>();
59 }
60 
63 
64  desc.add<edm::InputTag>(("towerCollection"), edm::InputTag("hltRecoEcalCandidate"));
65  desc.add<edm::InputTag>(("L1IsoCand"), edm::InputTag("hltTowerMakerForAll"));
66  desc.add<edm::InputTag>(("L1NonIsoCand"), edm::InputTag("fixedGridRhoFastjetAllCalo"));
67  desc.add<double>(("useTowersInCone"), 0.8);
68  desc.add<double>(("EtMin"), 1.0);
69  desc.add<double>(("EMin"), 1.0);
70  descriptions.add(("hltCaloTowerForEgamma"), desc);
71 }
72 
76 
78  evt.getByToken(l1isoseeds_, emIsolColl);
80  evt.getByToken(l1nonisoseeds_, emNonIsolColl);
81  auto cands = std::make_unique<CaloTowerCollection>();
82  cands->reserve(caloTowers->size());
83 
84  for (unsigned idx = 0; idx < caloTowers->size(); idx++) {
85  const CaloTower* cal = &((*caloTowers)[idx]);
86  if (cal->et() >= EtThreshold_ && cal->energy() >= EThreshold_) {
87  bool fill = false;
88  math::PtEtaPhiELorentzVector p(cal->et(), cal->eta(), cal->phi(), cal->energy());
89  for (edm::View<reco::Candidate>::const_iterator emItr = emIsolColl->begin(); emItr != emIsolColl->end();
90  ++emItr) {
91  double delta = ROOT::Math::VectorUtil::DeltaR((*emItr).p4().Vect(), p);
92  if (delta < cone_) {
93  cands->push_back(*cal);
94  fill = true;
95  break;
96  }
97  }
98 
99  if (!fill) {
100  for (edm::View<reco::Candidate>::const_iterator emItr = emNonIsolColl->begin(); emItr != emNonIsolColl->end();
101  ++emItr) {
102  double delta = ROOT::Math::VectorUtil::DeltaR((*emItr).p4().Vect(), p);
103  if (delta < cone_) {
104  cands->push_back(*cal);
105  break;
106  }
107  }
108  }
109  }
110  }
111 
112  evt.put(std::move(cands));
113 }
114 
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
EgammaHLTCaloTowerProducer(const edm::ParameterSet &)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
double et(double vtxZ) const
Definition: CaloTower.h:150
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
PtEtaPhiELorentzVectorD PtEtaPhiELorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:27
const edm::EDGetTokenT< CaloTowerCollection > towers_
const edm::EDGetTokenT< edm::View< reco::Candidate > > l1isoseeds_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void produce(edm::StreamID, edm::Event &, edm::EventSetup const &) const final
fixed size matrix
HLT enums.
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
const edm::EDGetTokenT< edm::View< reco::Candidate > > l1nonisoseeds_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
double phi() const final
momentum azimuthal angle
def move(src, dest)
Definition: eostools.py:511
double energy() const final
energy
double eta() const final
momentum pseudorapidity