CMS 3D CMS Logo

EgammaHLTCaloTowerProducer.cc
Go to the documentation of this file.
1 // makes CaloTowerCandidates from CaloTowers
2 // original author: M. Sani (UCSD)
3 
4 #include <cmath>
11 
14 
17 
18 // Math
19 #include "Math/GenVector/VectorUtil.h"
20 #include <cmath>
21 
22 using namespace edm;
23 using namespace reco;
24 using namespace std;
25 using namespace l1extra ;
26 
27 EgammaHLTCaloTowerProducer::EgammaHLTCaloTowerProducer( const ParameterSet & p ) : towers_ (consumes<CaloTowerCollection>(p.getParameter<InputTag> ("towerCollection"))),
28  cone_ (p.getParameter<double> ("useTowersInCone")),
29  l1isoseeds_ (consumes<edm::View<reco::Candidate>>(p.getParameter< edm::InputTag > ("L1IsoCand"))),
30  l1nonisoseeds_ (consumes<edm::View<reco::Candidate>>(p.getParameter< edm::InputTag > ("L1NonIsoCand"))),
31  EtThreshold_ (p.getParameter<double> ("EtMin")),
32  EThreshold_ (p.getParameter<double> ("EMin")) {
33 
34  produces<CaloTowerCollection>();
35 }
36 
38 
40 
41  desc.add<edm::InputTag>(("towerCollection"), edm::InputTag("hltRecoEcalCandidate"));
42  desc.add<edm::InputTag>(("L1IsoCand"), edm::InputTag("hltTowerMakerForAll"));
43  desc.add<edm::InputTag>(("L1NonIsoCand"), edm::InputTag("fixedGridRhoFastjetAllCalo"));
44  desc.add<double>(("useTowersInCone"), 0.8);
45  desc.add<double>(("EtMin"), 1.0);
46  desc.add<double>(("EMin"), 1.0);
47  descriptions.add(("hltCaloTowerForEgamma"), desc);
48 }
49 
50 
52 {
54  evt.getByToken(towers_, caloTowers);
55 
57  evt.getByToken(l1isoseeds_, emIsolColl);
59  evt.getByToken(l1nonisoseeds_, emNonIsolColl);
60  auto cands = std::make_unique<CaloTowerCollection>();
61  cands->reserve(caloTowers->size());
62 
63  for (unsigned idx = 0; idx < caloTowers->size(); idx++) {
64  const CaloTower* cal = &((*caloTowers) [idx]);
65  if (cal->et() >= EtThreshold_ && cal->energy() >= EThreshold_) {
66  bool fill = false;
67  math::PtEtaPhiELorentzVector p(cal->et(), cal->eta(), cal->phi(), cal->energy());
68  for (edm::View<reco::Candidate>::const_iterator emItr = emIsolColl->begin(); emItr != emIsolColl->end() ;++emItr) {
69  double delta = ROOT::Math::VectorUtil::DeltaR((*emItr).p4().Vect(), p);
70  if(delta < cone_) {
71  cands->push_back(*cal);
72  fill = true;
73  break;
74  }
75  }
76 
77  if (!fill) {
78  for(edm::View<reco::Candidate>::const_iterator emItr = emNonIsolColl->begin(); emItr != emNonIsolColl->end() ;++emItr) {
79  double delta = ROOT::Math::VectorUtil::DeltaR((*emItr).p4().Vect(), p);
80  if(delta < cone_) {
81  cands->push_back(*cal);
82  break;
83  }
84  }
85  }
86  }
87  }
88 
89  evt.put(std::move(cands));
90 }
dbl * delta
Definition: mlp_gen.cc:36
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:136
double eta() const final
momentum pseudorapidity
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
EgammaHLTCaloTowerProducer(const edm::ParameterSet &)
double energy() const final
energy
ParameterDescriptionBase * add(U const &iLabel, T const &value)
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)
fixed size matrix
HLT enums.
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
size_type size() const
const edm::EDGetTokenT< edm::View< reco::Candidate > > l1nonisoseeds_
double et(double vtxZ) const
Definition: CaloTower.h:132
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
double phi() const final
momentum azimuthal angle
void produce(edm::StreamID, edm::Event &, edm::EventSetup const &) const final
def move(src, dest)
Definition: eostools.py:510