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