CMS 3D CMS Logo

EgammaHLTBcHcalIsolationProducersRegional.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: EgammaHLTProducers
4 // Class: EgammaHLTBcHcalIsolationProducersRegional
5 //
6 // Original Author: Matteo Sani (UCSD)
7 // Created: Thu Nov 24 11:38:00 CEST 2011
8 //
9 
19 
20 //this class produces either Hcal isolation or H for H/E depending if doEtSum=true or false
21 //H for H/E = towers behind SC, hcal isolation has these towers excluded
22 //a rho correction can be applied
23 
25 public:
27 
28 public:
29  void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const final;
30  static void fillDescriptions(edm::ConfigurationDescriptions &descriptions);
31 
32 private:
33  const bool doEtSum_;
34  const double etMin_;
35  const double innerCone_;
36  const double outerCone_;
37  const int depth_;
38  const bool useSingleTower_;
39 
40  const bool doRhoCorrection_;
41  const double rhoScale_;
42  const double rhoMax_;
43  const std::vector<double> effectiveAreas_;
44  const std::vector<double> absEtaLowEdges_;
45 
49 
51 
53 };
54 
56  : doEtSum_(config.getParameter<bool>("doEtSum")),
57  etMin_(config.getParameter<double>("etMin")),
58  innerCone_(config.getParameter<double>("innerCone")),
59  outerCone_(config.getParameter<double>("outerCone")),
60  depth_(config.getParameter<int>("depth")),
61  useSingleTower_(config.getParameter<bool>("useSingleTower")),
62  doRhoCorrection_(config.getParameter<bool>("doRhoCorrection")),
63  rhoScale_(config.getParameter<double>("rhoScale")),
64  rhoMax_(config.getParameter<double>("rhoMax")),
65  effectiveAreas_(config.getParameter<std::vector<double> >("effectiveAreas")),
66  absEtaLowEdges_(config.getParameter<std::vector<double> >("absEtaLowEdges")),
67  recoEcalCandidateProducer_(consumes(config.getParameter<edm::InputTag>("recoEcalCandidateProducer"))),
68  caloTowerProducer_(consumes(config.getParameter<edm::InputTag>("caloTowerProducer"))),
69  rhoProducer_(doRhoCorrection_ ? consumes<double>(config.getParameter<edm::InputTag>("rhoProducer"))
70  : edm::EDGetTokenT<double>()),
71  caloTowerConstituentsMapToken_{esConsumes()},
72  putToken_{produces<reco::RecoEcalCandidateIsolationMap>()} {
73  if (doRhoCorrection_) {
74  if (absEtaLowEdges_.size() != effectiveAreas_.size()) {
75  throw cms::Exception("IncompatibleVects") << "absEtaLowEdges and effectiveAreas should be of the same size. \n";
76  }
77 
78  if (absEtaLowEdges_.at(0) != 0.0) {
79  throw cms::Exception("IncompleteCoverage") << "absEtaLowEdges should start from 0. \n";
80  }
81 
82  for (unsigned int aIt = 0; aIt < absEtaLowEdges_.size() - 1; aIt++) {
83  if (!(absEtaLowEdges_.at(aIt) < absEtaLowEdges_.at(aIt + 1))) {
84  throw cms::Exception("ImproperBinning") << "absEtaLowEdges entries should be in increasing order. \n";
85  }
86  }
87  }
88 }
89 
92 
93  desc.add<edm::InputTag>(("recoEcalCandidateProducer"), edm::InputTag("hltRecoEcalCandidate"));
94  desc.add<edm::InputTag>(("caloTowerProducer"), edm::InputTag("hltTowerMakerForAll"));
95  desc.add<edm::InputTag>(("rhoProducer"), edm::InputTag("fixedGridRhoFastjetAllCalo"));
96  desc.add<bool>(("doRhoCorrection"), false);
97  desc.add<double>(("rhoMax"), 999999.);
98  desc.add<double>(("rhoScale"), 1.0);
99  desc.add<double>(("etMin"), -1.0);
100  desc.add<double>(("innerCone"), 0);
101  desc.add<double>(("outerCone"), 0.15);
102  desc.add<int>(("depth"), -1);
103  desc.add<bool>(("doEtSum"), false);
104  desc.add<bool>(("useSingleTower"), false);
105  desc.add<std::vector<double> >("effectiveAreas", {0.079, 0.25}); // 2016 post-ichep sinEle default
106  desc.add<std::vector<double> >("absEtaLowEdges", {0.0, 1.479}); // Barrel, Endcap
107  descriptions.add(("hltEgammaHLTBcHcalIsolationProducersRegional"), desc);
108 }
109 
112  const edm::EventSetup &iSetup) const {
113  // Get the HLT filtered objects
114  auto recoEcalCandHandle = iEvent.getHandle(recoEcalCandidateProducer_);
115 
116  double rho = 0.0;
117 
118  if (doRhoCorrection_) {
119  rho = iEvent.get(rhoProducer_);
120  if (rho > rhoMax_) {
121  rho = rhoMax_;
122  }
123  rho = rho * rhoScale_;
124  }
125 
126  auto const &caloTowers = iEvent.get(caloTowerProducer_);
127  auto const &ctmaph = iSetup.getData(caloTowerConstituentsMapToken_);
128 
129  const EgammaTowerIsolation towerIso1(outerCone_, 0., etMin_, 1, &caloTowers);
130  const EgammaTowerIsolation towerIso2(outerCone_, 0., etMin_, 2, &caloTowers);
131 
132  reco::RecoEcalCandidateIsolationMap isoMap(recoEcalCandHandle);
133 
134  for (unsigned int iRecoEcalCand = 0; iRecoEcalCand < recoEcalCandHandle->size(); iRecoEcalCand++) {
135  reco::RecoEcalCandidateRef recoEcalCandRef(recoEcalCandHandle, iRecoEcalCand);
136 
137  float isol = 0;
138 
139  auto towersBehindCluster =
140  useSingleTower_ ? egamma::towersOf(*(recoEcalCandRef->superCluster()), ctmaph) : std::vector<CaloTowerDetId>{};
141 
142  if (doEtSum_) { //calculate hcal isolation excluding the towers behind the cluster which will be used for H for H/E
144  if (useSingleTower_) {
145  // towersBehindCluster are excluded from the isolation sum
146  isol = isolAlgo.getTowerEtSum(recoEcalCandRef.get(), &towersBehindCluster);
147  } else {
148  isol = isolAlgo.getTowerEtSum(recoEcalCandRef.get());
149  }
150 
151  } else { //calcuate H for H/E
152  if (useSingleTower_)
153  isol = egamma::depth1HcalESum(towersBehindCluster, caloTowers) +
154  egamma::depth2HcalESum(towersBehindCluster, caloTowers);
155  else {
156  auto const &sc = recoEcalCandRef->superCluster().get();
157  isol = towerIso1.getTowerESum(sc) + towerIso2.getTowerESum(sc);
158  }
159  }
160 
161  if (doRhoCorrection_) {
162  int iEA = -1;
163  auto scEta = std::abs(recoEcalCandRef->superCluster()->eta());
164  for (int bIt = absEtaLowEdges_.size() - 1; bIt > -1; bIt--) {
165  if (scEta > absEtaLowEdges_.at(bIt)) {
166  iEA = bIt;
167  break;
168  }
169  }
170  isol = isol - rho * effectiveAreas_.at(iEA);
171  }
172 
173  isoMap.insert(recoEcalCandRef, isol);
174  }
175 
176  iEvent.emplace(putToken_, isoMap);
177 }
178 
RecoEcalCandidateIsolation.h
ConfigurationDescriptions.h
edm::StreamID
Definition: StreamID.h:30
EgammaHLTBcHcalIsolationProducersRegional::rhoProducer_
const edm::EDGetTokenT< double > rhoProducer_
Definition: EgammaHLTBcHcalIsolationProducersRegional.cc:48
EgammaHLTBcHcalIsolationProducersRegional::outerCone_
const double outerCone_
Definition: EgammaHLTBcHcalIsolationProducersRegional.cc:36
electrons_cff.bool
bool
Definition: electrons_cff.py:393
EgammaHLTBcHcalIsolationProducersRegional::rhoMax_
const double rhoMax_
Definition: EgammaHLTBcHcalIsolationProducersRegional.cc:42
EgammaHLTBcHcalIsolationProducersRegional::EgammaHLTBcHcalIsolationProducersRegional
EgammaHLTBcHcalIsolationProducersRegional(const edm::ParameterSet &)
Definition: EgammaHLTBcHcalIsolationProducersRegional.cc:55
edm::EDGetTokenT< reco::RecoEcalCandidateCollection >
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::EDPutTokenT
Definition: EDPutToken.h:33
EgammaHLTBcHcalIsolationProducersRegional::depth_
const int depth_
Definition: EgammaHLTBcHcalIsolationProducersRegional.cc:37
EgammaHLTBcHcalIsolationProducersRegional::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: EgammaHLTBcHcalIsolationProducersRegional.cc:90
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89353
EgammaHLTBcHcalIsolationProducersRegional::produce
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const final
Definition: EgammaHLTBcHcalIsolationProducersRegional.cc:110
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
edm::Ref::get
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:232
egamma::depth2HcalESum
double depth2HcalESum(std::vector< CaloTowerDetId > const &towers, CaloTowerCollection const &)
Definition: EgammaHadTower.cc:83
EgammaHadTower.h
edm::Ref
Definition: AssociativeIterator.h:58
config
Definition: config.py:1
EgammaHLTBcHcalIsolationProducersRegional::recoEcalCandidateProducer_
const edm::EDGetTokenT< reco::RecoEcalCandidateCollection > recoEcalCandidateProducer_
Definition: EgammaHLTBcHcalIsolationProducersRegional.cc:46
MakerMacros.h
EgammaTowerIsolation::getTowerESum
double getTowerESum(const reco::Candidate *cand, const std::vector< CaloTowerDetId > *detIdToExclude=nullptr) const
Definition: EgammaTowerIsolation.h:209
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
EgammaHLTBcHcalIsolationProducersRegional::effectiveAreas_
const std::vector< double > effectiveAreas_
Definition: EgammaHLTBcHcalIsolationProducersRegional.cc:43
EgammaHLTBcHcalIsolationProducersRegional::caloTowerProducer_
const edm::EDGetTokenT< CaloTowerCollection > caloTowerProducer_
Definition: EgammaHLTBcHcalIsolationProducersRegional.cc:47
EgammaTowerIsolation.h
edm::global::EDProducer
Definition: EDProducer.h:32
CaloGeometryRecord.h
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
DDAxes::rho
egamma::towersOf
std::vector< CaloTowerDetId > towersOf(reco::SuperCluster const &sc, CaloTowerConstituentsMap const &towerMap, HoeMode mode=HoeMode::SingleTower)
Definition: EgammaHadTower.cc:25
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
eleHcalExtractorBlocks_cff.caloTowers
caloTowers
Definition: eleHcalExtractorBlocks_cff.py:15
edm::AssociationMap
Definition: AssociationMap.h:48
EgammaHLTBcHcalIsolationProducersRegional::rhoScale_
const double rhoScale_
Definition: EgammaHLTBcHcalIsolationProducersRegional.cc:41
EgammaTowerIsolation
Definition: EgammaTowerIsolation.h:197
createfilelist.int
int
Definition: createfilelist.py:10
iEvent
int iEvent
Definition: GenABIO.cc:224
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
edm::EventSetup
Definition: EventSetup.h:57
EgammaHLTBcHcalIsolationProducersRegional::etMin_
const double etMin_
Definition: EgammaHLTBcHcalIsolationProducersRegional.cc:34
EgammaHLTBcHcalIsolationProducersRegional::useSingleTower_
const bool useSingleTower_
Definition: EgammaHLTBcHcalIsolationProducersRegional.cc:38
EgammaHLTBcHcalIsolationProducersRegional::putToken_
const edm::EDPutTokenT< reco::RecoEcalCandidateIsolationMap > putToken_
Definition: EgammaHLTBcHcalIsolationProducersRegional.cc:52
edm::ESGetToken< CaloTowerConstituentsMap, CaloGeometryRecord >
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:120
EgammaHLTBcHcalIsolationProducersRegional
Definition: EgammaHLTBcHcalIsolationProducersRegional.cc:24
edm::AssociationMap::insert
void insert(const key_type &k, const data_type &v)
insert an association
Definition: AssociationMap.h:166
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
std
Definition: JetResolutionObject.h:76
RecoEcalCandidate.h
EgammaHLTBcHcalIsolationProducersRegional::doEtSum_
const bool doEtSum_
Definition: EgammaHLTBcHcalIsolationProducersRegional.cc:33
Exception
Definition: hltDiff.cc:246
egamma::depth1HcalESum
double depth1HcalESum(std::vector< CaloTowerDetId > const &towers, CaloTowerCollection const &)
Definition: EgammaHadTower.cc:73
EgammaTowerIsolation::getTowerEtSum
double getTowerEtSum(const reco::Candidate *cand, const std::vector< CaloTowerDetId > *detIdToExclude=nullptr) const
Definition: EgammaTowerIsolation.h:205
Exception.h
edm::EDConsumerBase::esConsumes
auto esConsumes()
Definition: EDConsumerBase.h:200
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
EDProducer.h
EgammaHLTBcHcalIsolationProducersRegional::innerCone_
const double innerCone_
Definition: EgammaHLTBcHcalIsolationProducersRegional.cc:35
edm::Event
Definition: Event.h:73
EgammaHLTBcHcalIsolationProducersRegional::caloTowerConstituentsMapToken_
const edm::ESGetToken< CaloTowerConstituentsMap, CaloGeometryRecord > caloTowerConstituentsMapToken_
Definition: EgammaHLTBcHcalIsolationProducersRegional.cc:50
EgammaHLTBcHcalIsolationProducersRegional::doRhoCorrection_
const bool doRhoCorrection_
Definition: EgammaHLTBcHcalIsolationProducersRegional.cc:40
edm::InputTag
Definition: InputTag.h:15
EgammaHLTBcHcalIsolationProducersRegional::absEtaLowEdges_
const std::vector< double > absEtaLowEdges_
Definition: EgammaHLTBcHcalIsolationProducersRegional.cc:44