CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
HGCalIsoCalculator Class Reference

#include <HGCalIsoCalculator.h>

Public Member Functions

const float getIso (const unsigned int ring) const
 
 HGCalIsoCalculator ()
 
void produceHGCalIso (const reco::CaloClusterPtr &seedCluster)
 
void setDeltaR (const float dr)
 
void setMinDeltaR (const float dr)
 
void setNLayers (unsigned int nLayers)
 
void setNRings (const size_t nrings)
 
void setRecHits (edm::Handle< HGCRecHitCollection > hitsEE, edm::Handle< HGCRecHitCollection > hitsFH, edm::Handle< HGCRecHitCollection > hitsBH)
 fill - once per event More...
 
void setRecHitTools (const hgcal::RecHitTools *recHitTools)
 
 ~HGCalIsoCalculator ()
 

Private Attributes

bool debug_
 
float dr2_
 
std::vector< std::pair< float, float > > hitEtaPhiCache_
 
std::vector< float > isoringdeposits_
 
float mindr2_
 
unsigned int nlayers_
 
edm::Handle< HGCRecHitCollectionrecHitsBH_
 
edm::Handle< HGCRecHitCollectionrecHitsEE_
 
edm::Handle< HGCRecHitCollectionrecHitsFH_
 
const hgcal::RecHitToolsrechittools_
 
std::vector< unsigned int > ringasso_
 

Detailed Description

Definition at line 46 of file HGCalIsoCalculator.h.

Constructor & Destructor Documentation

◆ HGCalIsoCalculator()

HGCalIsoCalculator::HGCalIsoCalculator ( )

Definition at line 11 of file HGCalIsoCalculator.cc.

12  : dr2_(0.15 * 0.15), mindr2_(0), rechittools_(nullptr), debug_(false), nlayers_(30) {
13  setNRings(5);
14 }

References setNRings().

◆ ~HGCalIsoCalculator()

HGCalIsoCalculator::~HGCalIsoCalculator ( )

Definition at line 16 of file HGCalIsoCalculator.cc.

16 {}

Member Function Documentation

◆ getIso()

const float HGCalIsoCalculator::getIso ( const unsigned int  ring) const

Definition at line 114 of file HGCalIsoCalculator.cc.

114  {
115  if (ring >= isoringdeposits_.size())
116  throw cms::Exception("HGCalIsoCalculator::getIso: ring index out of range");
117  return isoringdeposits_[ring];
118 }

References isoringdeposits_, and relativeConstraints::ring.

Referenced by HGCalEgammaIDHelper::getIsolationRing().

◆ produceHGCalIso()

void HGCalIsoCalculator::produceHGCalIso ( const reco::CaloClusterPtr seedCluster)

Definition at line 48 of file HGCalIsoCalculator.cc.

48  {
49  if (!rechittools_)
50  throw cms::Exception("HGCalIsoCalculator::produceHGCalIso: rechittools not set");
51 
52  for (auto& r : isoringdeposits_)
53  r = 0;
54 
55  // make local temporaries to pass to the lambda
56  // avoids recomputing every iteration
57  const float seedEta = seed->eta();
58  const float seedPhi = seed->phi();
59  const std::vector<std::pair<DetId, float>>& seedHitsAndFractions = seed->hitsAndFractions();
60 
61  auto checkAndFill = [this, &seedEta, &seedPhi, &seedHitsAndFractions](const HGCRecHit& hit,
62  std::pair<float, float> etaphiVal) {
63  float deltar2 = reco::deltaR2(etaphiVal.first, etaphiVal.second, seedEta, seedPhi);
64  if (deltar2 > dr2_ || deltar2 < mindr2_)
65  return;
66 
67  unsigned int layer = rechittools_->getLayerWithOffset(hit.id());
68  if (layer >= nlayers_)
69  return;
70 
71  //do not consider hits associated to the photon cluster
72  if (std::none_of(seedHitsAndFractions.begin(), seedHitsAndFractions.end(), [&hit](const auto& seedhit) {
73  return hit.id() == seedhit.first;
74  })) {
75  const unsigned int ring = ringasso_.at(layer);
76  isoringdeposits_.at(ring) += hit.energy();
77  }
78  };
79 
80  // The cache order is EE,FH,BH, so we should loop over them the same here
81  auto itEtaPhiCache = hitEtaPhiCache_.cbegin();
82  for (const auto& hit : *recHitsEE_) {
83  checkAndFill(hit, *itEtaPhiCache);
84  itEtaPhiCache++;
85  }
86  for (const auto& hit : *recHitsFH_) {
87  checkAndFill(hit, *itEtaPhiCache);
88  itEtaPhiCache++;
89  }
90  for (const auto& hit : *recHitsBH_) {
91  checkAndFill(hit, *itEtaPhiCache);
92  itEtaPhiCache++;
93  }
94 }

References reco::deltaR2(), dr2_, Exception, hgcal::RecHitTools::getLayerWithOffset(), hitEtaPhiCache_, hit::id, isoringdeposits_, mindr2_, nlayers_, alignCSCRings::r, recHitsBH_, recHitsEE_, recHitsFH_, rechittools_, relativeConstraints::ring, ringasso_, and SurveyInfoScenario_cff::seed.

Referenced by HGCalEgammaIDHelper::computeHGCAL().

◆ setDeltaR()

void HGCalIsoCalculator::setDeltaR ( const float  dr)
inline

Definition at line 52 of file HGCalIsoCalculator.h.

52 { dr2_ = dr * dr; }

References flavorHistoryFilter_cfi::dr, and dr2_.

Referenced by HGCalEgammaIDHelper::HGCalEgammaIDHelper().

◆ setMinDeltaR()

void HGCalIsoCalculator::setMinDeltaR ( const float  dr)
inline

Definition at line 54 of file HGCalIsoCalculator.h.

54 { mindr2_ = dr * dr; }

References flavorHistoryFilter_cfi::dr, and mindr2_.

Referenced by HGCalEgammaIDHelper::HGCalEgammaIDHelper().

◆ setNLayers()

void HGCalIsoCalculator::setNLayers ( unsigned int  nLayers)
inline

Definition at line 60 of file HGCalIsoCalculator.h.

60 { nlayers_ = nLayers; }

References MuonTCMETValueMapProducer_cff::nLayers, and nlayers_.

◆ setNRings()

void HGCalIsoCalculator::setNRings ( const size_t  nrings)

Definition at line 96 of file HGCalIsoCalculator.cc.

96  {
97  if (nrings > nlayers_)
98  throw std::logic_error("PhotonHGCalIsoCalculator::setNRings: max number of rings reached");
99 
100  ringasso_.clear();
101  isoringdeposits_.clear();
102  unsigned int separator = nlayers_ / nrings;
103  size_t counter = 0;
104  for (size_t i = 0; i < nlayers_ + 1; i++) {
105  ringasso_.push_back(counter);
106  //the last ring might be larger.
107  if (i && !(i % separator) && (int)counter < (int)nrings - 1) {
108  counter++;
109  }
110  }
111  isoringdeposits_.resize(nrings, 0);
112 }

References mps_fire::i, isoringdeposits_, nlayers_, ringasso_, and mps_merge::separator.

Referenced by HGCalEgammaIDHelper::HGCalEgammaIDHelper(), and HGCalIsoCalculator().

◆ setRecHits()

void HGCalIsoCalculator::setRecHits ( edm::Handle< HGCRecHitCollection hitsEE,
edm::Handle< HGCRecHitCollection hitsFH,
edm::Handle< HGCRecHitCollection hitsBH 
)

fill - once per event

Definition at line 18 of file HGCalIsoCalculator.cc.

20  {
21  recHitsEE_ = hitsEE;
22  recHitsFH_ = hitsFH;
23  recHitsBH_ = hitsBH;
24 
25  if (!rechittools_)
26  throw cms::Exception("HGCalIsoCalculator::produceHGCalIso: rechittools not set");
27 
28  hitEtaPhiCache_.clear();
29  hitEtaPhiCache_.reserve(recHitsEE_->size() + recHitsFH_->size() + recHitsBH_->size());
30 
31  // Since HGCal is not projective and the rechits don't cache any
32  // eta,phi, we make our own here
33  auto makeEtaPhiPair = [this](const auto& hit) {
35  float eta = rechittools_->getEta(position, 0); //assume vertex at z=0
36  float phi = rechittools_->getPhi(position);
37  return std::make_pair(eta, phi);
38  };
39 
40  for (const auto& hit : *recHitsEE_)
41  hitEtaPhiCache_.push_back(makeEtaPhiPair(hit));
42  for (const auto& hit : *recHitsFH_)
43  hitEtaPhiCache_.push_back(makeEtaPhiPair(hit));
44  for (const auto& hit : *recHitsBH_)
45  hitEtaPhiCache_.push_back(makeEtaPhiPair(hit));
46 }

References PVValHelper::eta, Exception, hgcal::RecHitTools::getEta(), hgcal::RecHitTools::getPhi(), hgcal::RecHitTools::getPosition(), hitEtaPhiCache_, hit::id, phi, position, recHitsBH_, recHitsEE_, recHitsFH_, and rechittools_.

Referenced by HGCalEgammaIDHelper::eventInit().

◆ setRecHitTools()

void HGCalIsoCalculator::setRecHitTools ( const hgcal::RecHitTools recHitTools)
inline

Definition at line 56 of file HGCalIsoCalculator.h.

56 { rechittools_ = recHitTools; }

References rechittools_.

Referenced by HGCalEgammaIDHelper::eventInit().

Member Data Documentation

◆ debug_

bool HGCalIsoCalculator::debug_
private

Definition at line 82 of file HGCalIsoCalculator.h.

◆ dr2_

float HGCalIsoCalculator::dr2_
private

Definition at line 75 of file HGCalIsoCalculator.h.

Referenced by produceHGCalIso(), and setDeltaR().

◆ hitEtaPhiCache_

std::vector<std::pair<float, float> > HGCalIsoCalculator::hitEtaPhiCache_
private

Definition at line 81 of file HGCalIsoCalculator.h.

Referenced by produceHGCalIso(), and setRecHits().

◆ isoringdeposits_

std::vector<float> HGCalIsoCalculator::isoringdeposits_
private

Definition at line 72 of file HGCalIsoCalculator.h.

Referenced by getIso(), produceHGCalIso(), and setNRings().

◆ mindr2_

float HGCalIsoCalculator::mindr2_
private

Definition at line 75 of file HGCalIsoCalculator.h.

Referenced by produceHGCalIso(), and setMinDeltaR().

◆ nlayers_

unsigned int HGCalIsoCalculator::nlayers_
private

Definition at line 83 of file HGCalIsoCalculator.h.

Referenced by produceHGCalIso(), setNLayers(), and setNRings().

◆ recHitsBH_

edm::Handle<HGCRecHitCollection> HGCalIsoCalculator::recHitsBH_
private

Definition at line 80 of file HGCalIsoCalculator.h.

Referenced by produceHGCalIso(), and setRecHits().

◆ recHitsEE_

edm::Handle<HGCRecHitCollection> HGCalIsoCalculator::recHitsEE_
private

Definition at line 78 of file HGCalIsoCalculator.h.

Referenced by produceHGCalIso(), and setRecHits().

◆ recHitsFH_

edm::Handle<HGCRecHitCollection> HGCalIsoCalculator::recHitsFH_
private

Definition at line 79 of file HGCalIsoCalculator.h.

Referenced by produceHGCalIso(), and setRecHits().

◆ rechittools_

const hgcal::RecHitTools* HGCalIsoCalculator::rechittools_
private

Definition at line 77 of file HGCalIsoCalculator.h.

Referenced by produceHGCalIso(), setRecHits(), and setRecHitTools().

◆ ringasso_

std::vector<unsigned int> HGCalIsoCalculator::ringasso_
private

Definition at line 73 of file HGCalIsoCalculator.h.

Referenced by produceHGCalIso(), and setNRings().

counter
Definition: counter.py:1
mps_fire.i
i
Definition: mps_fire.py:355
hit::id
unsigned int id
Definition: SiStripHitEffFromCalibTree.cc:92
HGCalIsoCalculator::ringasso_
std::vector< unsigned int > ringasso_
Definition: HGCalIsoCalculator.h:73
mps_merge.separator
string separator
Definition: mps_merge.py:79
HGCalIsoCalculator::rechittools_
const hgcal::RecHitTools * rechittools_
Definition: HGCalIsoCalculator.h:77
HGCalIsoCalculator::recHitsFH_
edm::Handle< HGCRecHitCollection > recHitsFH_
Definition: HGCalIsoCalculator.h:79
PVValHelper::eta
Definition: PVValidationHelpers.h:69
Point3DBase< float, GlobalTag >
HGCalIsoCalculator::mindr2_
float mindr2_
Definition: HGCalIsoCalculator.h:75
HGCalIsoCalculator::setNRings
void setNRings(const size_t nrings)
Definition: HGCalIsoCalculator.cc:96
HGCRecHit
Definition: HGCRecHit.h:14
MuonTCMETValueMapProducer_cff.nLayers
nLayers
Definition: MuonTCMETValueMapProducer_cff.py:38
HGCalIsoCalculator::isoringdeposits_
std::vector< float > isoringdeposits_
Definition: HGCalIsoCalculator.h:72
hgcal::RecHitTools::getPhi
float getPhi(const GlobalPoint &position) const
Definition: RecHitTools.cc:437
HGCalIsoCalculator::debug_
bool debug_
Definition: HGCalIsoCalculator.h:82
hgcal::RecHitTools::getLayerWithOffset
unsigned int getLayerWithOffset(const DetId &) const
Definition: RecHitTools.cc:352
reco::deltaR2
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
position
static int position[264][3]
Definition: ReadPGInfo.cc:289
HGCalIsoCalculator::hitEtaPhiCache_
std::vector< std::pair< float, float > > hitEtaPhiCache_
Definition: HGCalIsoCalculator.h:81
HGCalIsoCalculator::nlayers_
unsigned int nlayers_
Definition: HGCalIsoCalculator.h:83
HGCalIsoCalculator::dr2_
float dr2_
Definition: HGCalIsoCalculator.h:75
alignCSCRings.r
r
Definition: alignCSCRings.py:93
DDAxes::phi
hgcal::RecHitTools::getEta
float getEta(const GlobalPoint &position, const float &vertex_z=0.) const
Definition: RecHitTools.cc:426
flavorHistoryFilter_cfi.dr
dr
Definition: flavorHistoryFilter_cfi.py:37
Exception
Definition: hltDiff.cc:246
relativeConstraints.ring
ring
Definition: relativeConstraints.py:68
HGCalIsoCalculator::recHitsEE_
edm::Handle< HGCRecHitCollection > recHitsEE_
Definition: HGCalIsoCalculator.h:78
cms::Exception
Definition: Exception.h:70
hgcal::RecHitTools::getPosition
GlobalPoint getPosition(const DetId &id) const
Definition: RecHitTools.cc:126
HGCalIsoCalculator::recHitsBH_
edm::Handle< HGCRecHitCollection > recHitsBH_
Definition: HGCalIsoCalculator.h:80
SurveyInfoScenario_cff.seed
seed
Definition: SurveyInfoScenario_cff.py:295
hit
Definition: SiStripHitEffFromCalibTree.cc:88