CMS 3D CMS Logo

EgammaHLTHcalVarProducerFromRecHit.cc
Go to the documentation of this file.
1 // Class: EgammaHLTHcalVarProducerFromRecHit
2 
3 /*
4 
5 Author: Swagata Mukherjee
6 
7 Date: August 2021
8 
9 This class is similar to the existing class EgammaHLTBcHcalIsolationProducersRegional,
10 but the new feature in this code is that the HCAL recHits are used instead of the
11 calotowers which is expected to be phased out sometime in Run3.
12 The old class can also be used until calotowers stay. After that, one need to switch to this new one.
13 
14 As the old producer code, this one also produces either Hcal isolation or H for H/E depending if doEtSum=true or false.
15 H for H/E = either a single HCAL tower behind SC, or towers in a cone, and hcal isolation has these tower(s) excluded.
16 A rho correction can be applied
17 
18 */
19 
35 
37 public:
39 
40 public:
41  void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const final;
42  static void fillDescriptions(edm::ConfigurationDescriptions &descriptions);
43 
44 private:
45  const bool doEtSum_;
50  const double innerCone_;
51  const double outerCone_;
52  const int depth_;
53  const int maxSeverityHB_;
54  const int maxSeverityHE_;
55  const bool useSingleTower_;
56  const bool doRhoCorrection_;
57  const double rhoScale_;
58  const double rhoMax_;
59  const std::vector<double> effectiveAreas_;
60  const std::vector<double> absEtaLowEdges_;
70 };
71 
73  : doEtSum_(config.getParameter<bool>("doEtSum")),
74  eThresHB_(config.getParameter<EgammaHcalIsolation::arrayHB>("eThresHB")),
75  etThresHB_(config.getParameter<EgammaHcalIsolation::arrayHB>("etThresHB")),
76  eThresHE_(config.getParameter<EgammaHcalIsolation::arrayHE>("eThresHE")),
77  etThresHE_(config.getParameter<EgammaHcalIsolation::arrayHE>("etThresHE")),
78  innerCone_(config.getParameter<double>("innerCone")),
79  outerCone_(config.getParameter<double>("outerCone")),
80  depth_(config.getParameter<int>("depth")),
81  maxSeverityHB_(config.getParameter<int>("maxSeverityHB")),
82  maxSeverityHE_(config.getParameter<int>("maxSeverityHE")),
83  useSingleTower_(config.getParameter<bool>("useSingleTower")),
84  doRhoCorrection_(config.getParameter<bool>("doRhoCorrection")),
85  rhoScale_(config.getParameter<double>("rhoScale")),
86  rhoMax_(config.getParameter<double>("rhoMax")),
87  effectiveAreas_(config.getParameter<std::vector<double> >("effectiveAreas")),
88  absEtaLowEdges_(config.getParameter<std::vector<double> >("absEtaLowEdges")),
89  recoEcalCandidateProducer_(consumes(config.getParameter<edm::InputTag>("recoEcalCandidateProducer"))),
90  hbheRecHitsTag_(consumes(config.getParameter<edm::InputTag>("hbheRecHitsTag"))),
91  rhoProducer_(doRhoCorrection_ ? consumes<double>(config.getParameter<edm::InputTag>("rhoProducer"))
92  : edm::EDGetTokenT<double>()),
93  caloGeometryToken_{esConsumes()},
94  hcalTopologyToken_{esConsumes()},
95  hcalChannelQualityToken_{esConsumes(edm::ESInputTag("", "withTopo"))},
96  hcalSevLvlComputerToken_{esConsumes()},
97  caloTowerConstituentsMapToken_{esConsumes()},
98  putToken_{produces<reco::RecoEcalCandidateIsolationMap>()} {
99  if (doRhoCorrection_) {
100  if (absEtaLowEdges_.size() != effectiveAreas_.size()) {
101  throw cms::Exception("IncompatibleVects") << "absEtaLowEdges and effectiveAreas should be of the same size. \n";
102  }
103 
104  if (absEtaLowEdges_.at(0) != 0.0) {
105  throw cms::Exception("IncompleteCoverage") << "absEtaLowEdges should start from 0. \n";
106  }
107 
108  for (unsigned int aIt = 0; aIt < absEtaLowEdges_.size() - 1; aIt++) {
109  if (!(absEtaLowEdges_.at(aIt) < absEtaLowEdges_.at(aIt + 1))) {
110  throw cms::Exception("ImproperBinning") << "absEtaLowEdges entries should be in increasing order. \n";
111  }
112  }
113  }
114 }
115 
118 
119  desc.add<edm::InputTag>("recoEcalCandidateProducer", edm::InputTag("hltRecoEcalCandidate"));
120  desc.add<edm::InputTag>("rhoProducer", edm::InputTag("fixedGridRhoFastjetAllCalo"));
121  desc.add<edm::InputTag>("hbheRecHitsTag", edm::InputTag("hltHbhereco"));
122  desc.add<bool>("doRhoCorrection", false);
123  desc.add<double>("rhoMax", 999999.);
124  desc.add<double>(("rhoScale"), 1.0);
125  //eThresHB/HE are from RecoParticleFlow/PFClusterProducer/python/particleFlowRecHitHBHE_cfi.py
126  desc.add<std::vector<double> >("eThresHB", {0.1, 0.2, 0.3, 0.3});
127  desc.add<std::vector<double> >("etThresHB", {0, 0, 0, 0});
128  desc.add<std::vector<double> >("eThresHE", {0.1, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2});
129  desc.add<std::vector<double> >("etThresHE", {0, 0, 0, 0, 0, 0, 0});
130  desc.add<double>("innerCone", 0);
131  desc.add<double>("outerCone", 0.14);
132  desc.add<int>("depth", 0);
133  desc.add<int>("maxSeverityHB", 9);
134  desc.add<int>("maxSeverityHE", 9);
135  desc.add<bool>("doEtSum", false);
136  desc.add<bool>("useSingleTower", false);
137  desc.add<std::vector<double> >("effectiveAreas", {0.079, 0.25}); // 2016 post-ichep sinEle default
138  desc.add<std::vector<double> >("absEtaLowEdges", {0.0, 1.479}); // Barrel, Endcap
139  descriptions.add("hltEgammaHLTHcalVarProducerFromRecHit", desc);
140 }
141 
144  const edm::EventSetup &iSetup) const {
145  auto recoEcalCandHandle = iEvent.getHandle(recoEcalCandidateProducer_);
146 
147  double rho = 0.0;
148 
149  if (doRhoCorrection_) {
150  rho = iEvent.get(rhoProducer_);
151  if (rho > rhoMax_) {
152  rho = rhoMax_;
153  }
154  rho = rho * rhoScale_;
155  }
156 
157  reco::RecoEcalCandidateIsolationMap isoMap(recoEcalCandHandle);
158 
159  for (unsigned int iRecoEcalCand = 0; iRecoEcalCand < recoEcalCandHandle->size(); iRecoEcalCand++) {
160  reco::RecoEcalCandidateRef recoEcalCandRef(recoEcalCandHandle, iRecoEcalCand);
161 
162  float isol = 0;
165 
166  if (useSingleTower_) {
167  if (!doEtSum_) { //this is single tower based H/E
170  } else { //this is cone-based HCAL isolation with single tower based footprint removal
173  }
174  } else { //useSingleTower_=False means H/E is cone-based
177  }
178 
180  outerCone_,
181  internal,
182  innerCone_,
183  eThresHB_,
184  etThresHB_,
186  eThresHE_,
187  etThresHE_,
189  iEvent.get(hbheRecHitsTag_),
190  iSetup.getData(caloGeometryToken_),
191  iSetup.getData(hcalTopologyToken_),
195 
196  if (useSingleTower_) {
197  if (doEtSum_) { //this is cone-based HCAL isolation with single tower based footprint removal
198  isol = thisHcalVar_.getHcalEtSumBc(recoEcalCandRef.get(), depth_); //depth=0 means all depths
199  } else { //this is single tower based H/E
200  isol = thisHcalVar_.getHcalESumBc(recoEcalCandRef.get(), depth_); //depth=0 means all depths
201  }
202  } else { //useSingleTower_=False means H/E is cone-based.
203  if (doEtSum_) { //hcal iso
204  isol = thisHcalVar_.getHcalEtSum(recoEcalCandRef.get(), depth_); //depth=0 means all depths
205  } else { // doEtSum_=False means sum up energy, this is for H/E
206  isol = thisHcalVar_.getHcalESum(recoEcalCandRef.get(), depth_); //depth=0 means all depths
207  }
208  }
209 
210  if (doRhoCorrection_) {
211  int iEA = -1;
212  auto scEta = std::abs(recoEcalCandRef->superCluster()->eta());
213  for (int bIt = absEtaLowEdges_.size() - 1; bIt > -1; bIt--) {
214  if (scEta > absEtaLowEdges_.at(bIt)) {
215  iEA = bIt;
216  break;
217  }
218  }
219  isol = isol - rho * effectiveAreas_.at(iEA);
220  }
221 
222  isoMap.insert(recoEcalCandRef, isol);
223  }
224 
225  iEvent.emplace(putToken_, isoMap);
226 }
227 
const edm::ESGetToken< HcalSeverityLevelComputer, HcalSeverityLevelComputerRcd > hcalSevLvlComputerToken_
double getHcalESum(const reco::Candidate *c, int depth) const
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
const edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeometryToken_
Definition: config.py:1
int iEvent
Definition: GenABIO.cc:224
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const final
double getHcalESumBc(const reco::Candidate *c, int depth) const
const edm::ESGetToken< CaloTowerConstituentsMap, CaloGeometryRecord > caloTowerConstituentsMapToken_
const edm::ESGetToken< HcalChannelQuality, HcalChannelQualityRcd > hcalChannelQualityToken_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
double getHcalEtSum(const reco::Candidate *c, int depth) const
double getHcalEtSumBc(const reco::Candidate *c, int depth) const
const edm::EDGetTokenT< HBHERecHitCollection > hbheRecHitsTag_
const edm::EDGetTokenT< reco::RecoEcalCandidateCollection > recoEcalCandidateProducer_
void insert(const key_type &k, const data_type &v)
insert an association
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
HLT enums.
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:232
std::array< double, 4 > arrayHB
const edm::ESGetToken< HcalTopology, HcalRecNumberingRecord > hcalTopologyToken_
const edm::EDPutTokenT< reco::RecoEcalCandidateIsolationMap > putToken_
std::array< double, 7 > arrayHE