CMS 3D CMS Logo

HLTEcalPFClusterIsolationProducer.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <vector>
3 #include <memory>
4 
13 
16 
19 
21 
24 
27 
30 
32 
35 
38 
41 
42 template <typename T1>
44  typedef std::vector<T1> T1Collection;
47 
48 public:
51 
52  void produce(edm::Event&, const edm::EventSetup&) override;
53  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
54 
55 private:
56  bool computedRVeto(T1Ref candRef, reco::PFClusterRef pfclu);
57 
61 
62  const double drMax_;
63  const double drVetoBarrel_;
64  const double drVetoEndcap_;
65  const double etaStripBarrel_;
66  const double etaStripEndcap_;
67  const double energyBarrel_;
68  const double energyEndcap_;
69 
70  const bool doRhoCorrection_;
71  const double rhoMax_;
72  const double rhoScale_;
73  const std::vector<double> effectiveAreas_;
74  const std::vector<double> absEtaLowEdges_;
75 };
76 
77 template <typename T1>
79  : pfClusterProducer_(consumes<reco::PFClusterCollection>(config.getParameter<edm::InputTag>("pfClusterProducer"))),
80  rhoProducer_(consumes<double>(config.getParameter<edm::InputTag>("rhoProducer"))),
81  drMax_(config.getParameter<double>("drMax")),
82  drVetoBarrel_(config.getParameter<double>("drVetoBarrel")),
83  drVetoEndcap_(config.getParameter<double>("drVetoEndcap")),
84  etaStripBarrel_(config.getParameter<double>("etaStripBarrel")),
85  etaStripEndcap_(config.getParameter<double>("etaStripEndcap")),
86  energyBarrel_(config.getParameter<double>("energyBarrel")),
87  energyEndcap_(config.getParameter<double>("energyEndcap")),
88  doRhoCorrection_(config.getParameter<bool>("doRhoCorrection")),
89  rhoMax_(config.getParameter<double>("rhoMax")),
90  rhoScale_(config.getParameter<double>("rhoScale")),
91  effectiveAreas_(config.getParameter<std::vector<double>>("effectiveAreas")),
92  absEtaLowEdges_(config.getParameter<std::vector<double>>("absEtaLowEdges")) {
93  if (doRhoCorrection_) {
94  if (absEtaLowEdges_.size() != effectiveAreas_.size())
95  throw cms::Exception("IncompatibleVects") << "absEtaLowEdges and effectiveAreas should be of the same size. \n";
96 
97  if (absEtaLowEdges_.at(0) != 0.0)
98  throw cms::Exception("IncompleteCoverage") << "absEtaLowEdges should start from 0. \n";
99 
100  for (unsigned int aIt = 0; aIt < absEtaLowEdges_.size() - 1; aIt++) {
101  if (!(absEtaLowEdges_.at(aIt) < absEtaLowEdges_.at(aIt + 1)))
102  throw cms::Exception("ImproperBinning") << "absEtaLowEdges entries should be in increasing order. \n";
103  }
104  }
105 
106  std::string recoCandidateProducerName = "recoCandidateProducer";
109  recoCandidateProducerName = "recoEcalCandidateProducer";
110 
111  recoCandidateProducer_ = consumes<T1Collection>(config.getParameter<edm::InputTag>(recoCandidateProducerName));
112  produces<T1IsolationMap>();
113 }
114 
115 template <typename T1>
117 
118 template <typename T1>
120  std::string recoCandidateProducerName = "recoCandidateProducer";
123  recoCandidateProducerName = "recoEcalCandidateProducer";
124 
126  desc.add<edm::InputTag>(recoCandidateProducerName, edm::InputTag("hltL1SeededRecoEcalCandidatePF"));
127  desc.add<edm::InputTag>("pfClusterProducer", edm::InputTag("hltParticleFlowClusterECAL"));
128  desc.add<edm::InputTag>("rhoProducer", edm::InputTag("fixedGridRhoFastjetAllCalo"));
129  desc.add<bool>("doRhoCorrection", false);
130  desc.add<double>("rhoMax", 9.9999999E7);
131  desc.add<double>("rhoScale", 1.0);
132  desc.add<double>("drMax", 0.3);
133  desc.add<double>("drVetoBarrel", 0.0);
134  desc.add<double>("drVetoEndcap", 0.0);
135  desc.add<double>("etaStripBarrel", 0.0);
136  desc.add<double>("etaStripEndcap", 0.0);
137  desc.add<double>("energyBarrel", 0.0);
138  desc.add<double>("energyEndcap", 0.0);
139  desc.add<std::vector<double>>("effectiveAreas", {0.29, 0.21}); // 2016 post-ichep sinEle default
140  desc.add<std::vector<double>>("absEtaLowEdges", {0.0, 1.479}); // Barrel, Endcap
142 }
143 
144 template <typename T1>
146  edm::Handle<double> rhoHandle;
147  double rho = 0.0;
148  if (doRhoCorrection_) {
149  iEvent.getByToken(rhoProducer_, rhoHandle);
150  rho = *(rhoHandle.product());
151  }
152 
153  if (rho > rhoMax_)
154  rho = rhoMax_;
155 
156  rho = rho * rhoScale_;
157 
158  edm::Handle<T1Collection> recoCandHandle;
160 
161  iEvent.getByToken(recoCandidateProducer_, recoCandHandle);
162  iEvent.getByToken(pfClusterProducer_, clusterHandle);
163 
165  drMax_, drVetoBarrel_, drVetoEndcap_, etaStripBarrel_, etaStripEndcap_, energyBarrel_, energyEndcap_);
166  T1IsolationMap recoCandMap(recoCandHandle);
167 
168  for (unsigned int iReco = 0; iReco < recoCandHandle->size(); iReco++) {
169  T1Ref candRef(recoCandHandle, iReco);
170 
171  float sum = isoAlgo.getSum(candRef, clusterHandle);
172 
173  if (doRhoCorrection_) {
174  int iEA = -1;
175  auto cEta = std::abs(candRef->eta());
176  for (int bIt = absEtaLowEdges_.size() - 1; bIt > -1; bIt--) {
177  if (cEta > absEtaLowEdges_.at(bIt)) {
178  iEA = bIt;
179  break;
180  }
181  }
182 
183  sum = sum - rho * effectiveAreas_.at(iEA);
184  }
185 
186  recoCandMap.insert(candRef, sum);
187  }
188 
189  iEvent.put(std::make_unique<T1IsolationMap>(recoCandMap));
190 }
191 
194 
RecoEcalCandidateIsolation.h
defaultModuleLabel.h
ConfigurationDescriptions.h
Handle.h
electrons_cff.bool
bool
Definition: electrons_cff.py:366
MessageLogger.h
edm::Handle::product
T const * product() const
Definition: Handle.h:70
ESHandle.h
MuonHLTEcalPFClusterIsolationProducer
HLTEcalPFClusterIsolationProducer< reco::RecoChargedCandidate > MuonHLTEcalPFClusterIsolationProducer
Definition: HLTEcalPFClusterIsolationProducer.cc:193
edm::EDGetTokenT< T1Collection >
edm
HLT enums.
Definition: AlignableModifier.h:19
HLTEcalPFClusterIsolationProducer::T1Collection
std::vector< T1 > T1Collection
Definition: HLTEcalPFClusterIsolationProducer.cc:44
ZElectronSkim_cff.rho
rho
Definition: ZElectronSkim_cff.py:38
HLTEcalPFClusterIsolationProducer::etaStripEndcap_
const double etaStripEndcap_
Definition: HLTEcalPFClusterIsolationProducer.cc:66
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89285
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
HLTEcalPFClusterIsolationProducer::effectiveAreas_
const std::vector< double > effectiveAreas_
Definition: HLTEcalPFClusterIsolationProducer.cc:73
EDProducer.h
HLTEcalPFClusterIsolationProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: HLTEcalPFClusterIsolationProducer.cc:145
HLTEcalPFClusterIsolationProducer::energyEndcap_
const double energyEndcap_
Definition: HLTEcalPFClusterIsolationProducer.cc:68
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
RecoChargedCandidateIsolation.h
HLTEcalPFClusterIsolationProducer::HLTEcalPFClusterIsolationProducer
HLTEcalPFClusterIsolationProducer(const edm::ParameterSet &)
Definition: HLTEcalPFClusterIsolationProducer.cc:78
EcalPFClusterIsolation::getSum
double getSum(T1Ref, edm::Handle< std::vector< reco::PFCluster > >)
Definition: EcalPFClusterIsolation.cc:38
edm::Handle< double >
edm::Ref
Definition: AssociativeIterator.h:58
HLTEcalPFClusterIsolationProducer::recoCandidateProducer_
edm::EDGetTokenT< T1Collection > recoCandidateProducer_
Definition: HLTEcalPFClusterIsolationProducer.cc:58
HLTEcalPFClusterIsolationProducer::T1Ref
edm::Ref< T1Collection > T1Ref
Definition: HLTEcalPFClusterIsolationProducer.cc:45
config
Definition: config.py:1
MakerMacros.h
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
HLTEcalPFClusterIsolationProducer::absEtaLowEdges_
const std::vector< double > absEtaLowEdges_
Definition: HLTEcalPFClusterIsolationProducer.cc:74
EcalPFClusterIsolation.h
PFCluster.h
ParameterSetDescription.h
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HLTEcalPFClusterIsolationProducer::drVetoEndcap_
const double drVetoEndcap_
Definition: HLTEcalPFClusterIsolationProducer.cc:64
HLTEcalPFClusterIsolationProducer::pfClusterProducer_
const edm::EDGetTokenT< reco::PFClusterCollection > pfClusterProducer_
Definition: HLTEcalPFClusterIsolationProducer.cc:59
edm::ParameterSet
Definition: ParameterSet.h:47
defaultModuleLabel
std::string defaultModuleLabel()
Definition: defaultModuleLabel.h:16
Event.h
deltaR.h
HLTEcalPFClusterIsolationProducer::etaStripBarrel_
const double etaStripBarrel_
Definition: HLTEcalPFClusterIsolationProducer.cc:65
edm::AssociationMap
Definition: AssociationMap.h:48
iEvent
int iEvent
Definition: GenABIO.cc:224
PFClusterFwd.h
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
edm::stream::EDProducer
Definition: EDProducer.h:38
edm::EventSetup
Definition: EventSetup.h:58
HLTEcalPFClusterIsolationProducer::rhoMax_
const double rhoMax_
Definition: HLTEcalPFClusterIsolationProducer.cc:71
HLTEcalPFClusterIsolationProducer::rhoScale_
const double rhoScale_
Definition: HLTEcalPFClusterIsolationProducer.cc:72
HLTEcalPFClusterIsolationProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: HLTEcalPFClusterIsolationProducer.cc:119
edm::AssociationMap::insert
void insert(const key_type &k, const data_type &v)
insert an association
Definition: AssociationMap.h:166
HLTEcalPFClusterIsolationProducer::drMax_
const double drMax_
Definition: HLTEcalPFClusterIsolationProducer.cc:62
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
std
Definition: JetResolutionObject.h:76
RecoEcalCandidate.h
RecoChargedCandidate.h
Frameworkfwd.h
HLTEcalPFClusterIsolationProducer
Definition: HLTEcalPFClusterIsolationProducer.cc:43
HLTEcalPFClusterIsolationProducer::doRhoCorrection_
const bool doRhoCorrection_
Definition: HLTEcalPFClusterIsolationProducer.cc:70
Exception
Definition: hltDiff.cc:245
EventSetup.h
HLTEcalPFClusterIsolationProducer::~HLTEcalPFClusterIsolationProducer
~HLTEcalPFClusterIsolationProducer() override
Definition: HLTEcalPFClusterIsolationProducer.cc:116
HLTEcalPFClusterIsolationProducer::T1IsolationMap
edm::AssociationMap< edm::OneToValue< std::vector< T1 >, float > > T1IsolationMap
Definition: HLTEcalPFClusterIsolationProducer.cc:46
EgammaHLTEcalPFClusterIsolationProducer
HLTEcalPFClusterIsolationProducer< reco::RecoEcalCandidate > EgammaHLTEcalPFClusterIsolationProducer
Definition: HLTEcalPFClusterIsolationProducer.cc:192
Exception.h
EcalPFClusterIsolation
Definition: EcalPFClusterIsolation.h:17
cms::Exception
Definition: Exception.h:70
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
HLTEcalPFClusterIsolationProducer::drVetoBarrel_
const double drVetoBarrel_
Definition: HLTEcalPFClusterIsolationProducer.cc:63
ParameterSet.h
HLTEcalPFClusterIsolationProducer::rhoProducer_
const edm::EDGetTokenT< double > rhoProducer_
Definition: HLTEcalPFClusterIsolationProducer.cc:60
edm::Event
Definition: Event.h:73
HLTEcalPFClusterIsolationProducer::computedRVeto
bool computedRVeto(T1Ref candRef, reco::PFClusterRef pfclu)
l1t::PFClusterCollection
std::vector< l1t::PFCluster > PFClusterCollection
Definition: PFCluster.h:73
edm::InputTag
Definition: InputTag.h:15
HLTEcalPFClusterIsolationProducer::energyBarrel_
const double energyBarrel_
Definition: HLTEcalPFClusterIsolationProducer.cc:67