CMS 3D CMS Logo

HLTHcalPFClusterIsolationProducer.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <vector>
3 #include <memory>
4 
13 
16 
19 
22 
24 
27 
30 
33 
34 template <typename T1>
36  typedef std::vector<T1> T1Collection;
39 
40 public:
43 
44  void produce(edm::StreamID sid, edm::Event&, const edm::EventSetup&) const override;
45  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
46 
47 private:
53 
54  const bool useHF_;
55 
56  const double drMax_;
57  const double drVetoBarrel_;
58  const double drVetoEndcap_;
59  const double etaStripBarrel_;
60  const double etaStripEndcap_;
61  const double energyBarrel_;
62  const double energyEndcap_;
63  const bool useEt_;
64 
65  const bool doRhoCorrection_;
66  const double rhoMax_;
67  const double rhoScale_;
68  const std::vector<double> effectiveAreas_;
69  const std::vector<double> absEtaLowEdges_;
70 };
71 
72 template <typename T1>
74  : pfClusterProducerHCAL_(
75  consumes<reco::PFClusterCollection>(config.getParameter<edm::InputTag>("pfClusterProducerHCAL"))),
76  rhoProducer_(consumes<double>(config.getParameter<edm::InputTag>("rhoProducer"))),
77  pfClusterProducerHFEM_(
78  consumes<reco::PFClusterCollection>(config.getParameter<edm::InputTag>("pfClusterProducerHFEM"))),
79  pfClusterProducerHFHAD_(
80  consumes<reco::PFClusterCollection>(config.getParameter<edm::InputTag>("pfClusterProducerHFHAD"))),
81  useHF_(config.getParameter<bool>("useHF")),
82  drMax_(config.getParameter<double>("drMax")),
83  drVetoBarrel_(config.getParameter<double>("drVetoBarrel")),
84  drVetoEndcap_(config.getParameter<double>("drVetoEndcap")),
85  etaStripBarrel_(config.getParameter<double>("etaStripBarrel")),
86  etaStripEndcap_(config.getParameter<double>("etaStripEndcap")),
87  energyBarrel_(config.getParameter<double>("energyBarrel")),
88  energyEndcap_(config.getParameter<double>("energyEndcap")),
89  useEt_(config.getParameter<bool>("useEt")),
90  doRhoCorrection_(config.getParameter<bool>("doRhoCorrection")),
91  rhoMax_(config.getParameter<double>("rhoMax")),
92  rhoScale_(config.getParameter<double>("rhoScale")),
93  effectiveAreas_(config.getParameter<std::vector<double>>("effectiveAreas")),
94  absEtaLowEdges_(config.getParameter<std::vector<double>>("absEtaLowEdges")) {
95  if (doRhoCorrection_) {
96  if (absEtaLowEdges_.size() != effectiveAreas_.size())
97  throw cms::Exception("IncompatibleVects") << "absEtaLowEdges and effectiveAreas should be of the same size. \n";
98 
99  if (absEtaLowEdges_.at(0) != 0.0)
100  throw cms::Exception("IncompleteCoverage") << "absEtaLowEdges should start from 0. \n";
101 
102  for (unsigned int aIt = 0; aIt < absEtaLowEdges_.size() - 1; aIt++) {
103  if (!(absEtaLowEdges_.at(aIt) < absEtaLowEdges_.at(aIt + 1)))
104  throw cms::Exception("ImproperBinning") << "absEtaLowEdges entries should be in increasing order. \n";
105  }
106  }
107 
108  std::string recoCandidateProducerName = "recoCandidateProducer";
111  recoCandidateProducerName = "recoEcalCandidateProducer";
112  recoCandidateProducer_ = consumes<T1Collection>(config.getParameter<edm::InputTag>(recoCandidateProducerName));
113 
114  produces<T1IsolationMap>();
115 }
116 
117 template <typename T1>
119 
120 template <typename T1>
122  std::string recoCandidateProducerName = "recoCandidateProducer";
125  recoCandidateProducerName = "recoEcalCandidateProducer";
126 
128  desc.add<edm::InputTag>(recoCandidateProducerName, edm::InputTag("hltL1SeededRecoEcalCandidatePF"));
129  desc.add<edm::InputTag>("pfClusterProducerHCAL", edm::InputTag("hltParticleFlowClusterHCAL"));
130  desc.ifValue(
131  edm::ParameterDescription<bool>("useHF", false, true),
133  "pfClusterProducerHFEM", edm::InputTag("hltParticleFlowClusterHFEM"), true) and
135  "pfClusterProducerHFHAD", edm::InputTag("hltParticleFlowClusterHFHAD"), true)) or
136  false >> (edm::ParameterDescription<edm::InputTag>("pfClusterProducerHFEM", edm::InputTag(""), true) and
137  edm::ParameterDescription<edm::InputTag>("pfClusterProducerHFHAD", edm::InputTag(""), true)));
138  desc.add<edm::InputTag>("rhoProducer", edm::InputTag("fixedGridRhoFastjetAllCalo"));
139  desc.add<bool>("doRhoCorrection", false);
140  desc.add<double>("rhoMax", 9.9999999E7);
141  desc.add<double>("rhoScale", 1.0);
142  desc.add<double>("drMax", 0.3);
143  desc.add<double>("drVetoBarrel", 0.0);
144  desc.add<double>("drVetoEndcap", 0.0);
145  desc.add<double>("etaStripBarrel", 0.0);
146  desc.add<double>("etaStripEndcap", 0.0);
147  desc.add<double>("energyBarrel", 0.0);
148  desc.add<double>("energyEndcap", 0.0);
149  desc.add<bool>("useEt", true);
150  desc.add<std::vector<double>>("effectiveAreas", {0.2, 0.25}); // 2016 post-ichep sinEle default
151  desc.add<std::vector<double>>("absEtaLowEdges", {0.0, 1.479}); // Barrel, Endcap
153 }
154 
155 template <typename T1>
158  const edm::EventSetup&) const {
159  edm::Handle<double> rhoHandle;
160  double rho = 0.0;
161  if (doRhoCorrection_) {
162  iEvent.getByToken(rhoProducer_, rhoHandle);
163  rho = *(rhoHandle.product());
164  }
165 
166  if (rho > rhoMax_)
167  rho = rhoMax_;
168 
169  rho = rho * rhoScale_;
170 
171  edm::Handle<T1Collection> recoCandHandle;
172 
173  std::vector<edm::Handle<reco::PFClusterCollection>> clusterHandles;
174  edm::Handle<reco::PFClusterCollection> clusterHcalHandle;
175  edm::Handle<reco::PFClusterCollection> clusterHfemHandle;
176  edm::Handle<reco::PFClusterCollection> clusterHfhadHandle;
177 
178  iEvent.getByToken(recoCandidateProducer_, recoCandHandle);
179  iEvent.getByToken(pfClusterProducerHCAL_, clusterHcalHandle);
180  //const reco::PFClusterCollection* forIsolationHcal = clusterHcalHandle.product();
181  clusterHandles.push_back(clusterHcalHandle);
182 
183  if (useHF_) {
184  iEvent.getByToken(pfClusterProducerHFEM_, clusterHfemHandle);
185  clusterHandles.push_back(clusterHfemHandle);
186  iEvent.getByToken(pfClusterProducerHFHAD_, clusterHfhadHandle);
187  clusterHandles.push_back(clusterHfhadHandle);
188  }
189 
190  T1IsolationMap recoCandMap(recoCandHandle);
192  drMax_, drVetoBarrel_, drVetoEndcap_, etaStripBarrel_, etaStripEndcap_, energyBarrel_, energyEndcap_, useEt_);
193 
194  for (unsigned int iReco = 0; iReco < recoCandHandle->size(); iReco++) {
195  T1Ref candRef(recoCandHandle, iReco);
196 
197  float sum = isoAlgo.getSum(candRef, clusterHandles);
198 
199  if (doRhoCorrection_) {
200  int iEA = -1;
201  auto cEta = std::abs(candRef->eta());
202  for (int bIt = absEtaLowEdges_.size() - 1; bIt > -1; bIt--) {
203  if (cEta > absEtaLowEdges_.at(bIt)) {
204  iEA = bIt;
205  break;
206  }
207  }
208 
209  sum = sum - rho * effectiveAreas_.at(iEA);
210  }
211 
212  recoCandMap.insert(candRef, sum);
213  }
214 
215  iEvent.put(std::make_unique<T1IsolationMap>(recoCandMap));
216 }
217 
220 
RecoEcalCandidateIsolation.h
defaultModuleLabel.h
ConfigurationDescriptions.h
edm::StreamID
Definition: StreamID.h:30
HLTHcalPFClusterIsolationProducer::rhoMax_
const double rhoMax_
Definition: HLTHcalPFClusterIsolationProducer.cc:66
Handle.h
HLTHcalPFClusterIsolationProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: HLTHcalPFClusterIsolationProducer.cc:121
electrons_cff.bool
bool
Definition: electrons_cff.py:366
MessageLogger.h
edm::Handle::product
T const * product() const
Definition: Handle.h:70
ESHandle.h
HLTHcalPFClusterIsolationProducer::energyBarrel_
const double energyBarrel_
Definition: HLTHcalPFClusterIsolationProducer.cc:61
HcalPFClusterIsolation::getSum
double getSum(const T1Ref candRef, const std::vector< edm::Handle< reco::PFClusterCollection >> &clusterHandles)
Definition: HcalPFClusterIsolation.cc:32
edm::EDGetTokenT< T1Collection >
edm
HLT enums.
Definition: AlignableModifier.h:19
ZElectronSkim_cff.rho
rho
Definition: ZElectronSkim_cff.py:38
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
HLTHcalPFClusterIsolationProducer::rhoScale_
const double rhoScale_
Definition: HLTHcalPFClusterIsolationProducer.cc:67
HLTHcalPFClusterIsolationProducer::pfClusterProducerHCAL_
const edm::EDGetTokenT< reco::PFClusterCollection > pfClusterProducerHCAL_
Definition: HLTHcalPFClusterIsolationProducer.cc:49
HLTHcalPFClusterIsolationProducer::energyEndcap_
const double energyEndcap_
Definition: HLTHcalPFClusterIsolationProducer.cc:62
HLTHcalPFClusterIsolationProducer::doRhoCorrection_
const bool doRhoCorrection_
Definition: HLTHcalPFClusterIsolationProducer.cc:65
HLTHcalPFClusterIsolationProducer::etaStripBarrel_
const double etaStripBarrel_
Definition: HLTHcalPFClusterIsolationProducer.cc:59
HLTHcalPFClusterIsolationProducer::pfClusterProducerHFHAD_
const edm::EDGetTokenT< reco::PFClusterCollection > pfClusterProducerHFHAD_
Definition: HLTHcalPFClusterIsolationProducer.cc:52
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:46
RecoChargedCandidateIsolation.h
MuonHLTHcalPFClusterIsolationProducer
HLTHcalPFClusterIsolationProducer< reco::RecoChargedCandidate > MuonHLTHcalPFClusterIsolationProducer
Definition: HLTHcalPFClusterIsolationProducer.cc:219
edm::Handle< double >
edm::Ref
Definition: AssociativeIterator.h:58
config
Definition: config.py:1
MakerMacros.h
HLTHcalPFClusterIsolationProducer::useHF_
const bool useHF_
Definition: HLTHcalPFClusterIsolationProducer.cc:54
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
PFCluster.h
HLTHcalPFClusterIsolationProducer::T1IsolationMap
edm::AssociationMap< edm::OneToValue< std::vector< T1 >, float > > T1IsolationMap
Definition: HLTHcalPFClusterIsolationProducer.cc:38
ParameterSetDescription.h
edm::global::EDProducer
Definition: EDProducer.h:32
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
HLTHcalPFClusterIsolationProducer::recoCandidateProducer_
edm::EDGetTokenT< T1Collection > recoCandidateProducer_
Definition: HLTHcalPFClusterIsolationProducer.cc:48
HLTHcalPFClusterIsolationProducer::useEt_
const bool useEt_
Definition: HLTHcalPFClusterIsolationProducer.cc:63
HLTHcalPFClusterIsolationProducer::drVetoBarrel_
const double drVetoBarrel_
Definition: HLTHcalPFClusterIsolationProducer.cc:57
edm::ParameterSet
Definition: ParameterSet.h:47
defaultModuleLabel
std::string defaultModuleLabel()
Definition: defaultModuleLabel.h:16
Event.h
HLTHcalPFClusterIsolationProducer::~HLTHcalPFClusterIsolationProducer
~HLTHcalPFClusterIsolationProducer() override
Definition: HLTHcalPFClusterIsolationProducer.cc:118
edm::AssociationMap
Definition: AssociationMap.h:48
HLTHcalPFClusterIsolationProducer::T1Ref
edm::Ref< T1Collection > T1Ref
Definition: HLTHcalPFClusterIsolationProducer.cc:37
iEvent
int iEvent
Definition: GenABIO.cc:224
PFClusterFwd.h
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
edm::EventSetup
Definition: EventSetup.h:58
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HLTHcalPFClusterIsolationProducer::HLTHcalPFClusterIsolationProducer
HLTHcalPFClusterIsolationProducer(const edm::ParameterSet &)
Definition: HLTHcalPFClusterIsolationProducer.cc:73
HLTHcalPFClusterIsolationProducer::etaStripEndcap_
const double etaStripEndcap_
Definition: HLTHcalPFClusterIsolationProducer.cc:60
HLTHcalPFClusterIsolationProducer::rhoProducer_
const edm::EDGetTokenT< double > rhoProducer_
Definition: HLTHcalPFClusterIsolationProducer.cc:50
HLTHcalPFClusterIsolationProducer::effectiveAreas_
const std::vector< double > effectiveAreas_
Definition: HLTHcalPFClusterIsolationProducer.cc:68
HLTHcalPFClusterIsolationProducer::pfClusterProducerHFEM_
const edm::EDGetTokenT< reco::PFClusterCollection > pfClusterProducerHFEM_
Definition: HLTHcalPFClusterIsolationProducer.cc:51
HLTHcalPFClusterIsolationProducer::drVetoEndcap_
const double drVetoEndcap_
Definition: HLTHcalPFClusterIsolationProducer.cc:58
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
HLTHcalPFClusterIsolationProducer::T1Collection
std::vector< T1 > T1Collection
Definition: HLTHcalPFClusterIsolationProducer.cc:36
std
Definition: JetResolutionObject.h:76
RecoEcalCandidate.h
RecoChargedCandidate.h
Frameworkfwd.h
Exception
Definition: hltDiff.cc:245
EventSetup.h
or
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
Exception.h
EgammaHLTHcalPFClusterIsolationProducer
HLTHcalPFClusterIsolationProducer< reco::RecoEcalCandidate > EgammaHLTHcalPFClusterIsolationProducer
Definition: HLTHcalPFClusterIsolationProducer.cc:218
HLTHcalPFClusterIsolationProducer::drMax_
const double drMax_
Definition: HLTHcalPFClusterIsolationProducer.cc:56
cms::Exception
Definition: Exception.h:70
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ParameterSet.h
HcalPFClusterIsolation.h
EDProducer.h
edm::Event
Definition: Event.h:73
HcalPFClusterIsolation
Definition: HcalPFClusterIsolation.h:17
edm::ParameterDescription
Definition: ParameterDescription.h:110
HLTHcalPFClusterIsolationProducer::absEtaLowEdges_
const std::vector< double > absEtaLowEdges_
Definition: HLTHcalPFClusterIsolationProducer.cc:69
HLTHcalPFClusterIsolationProducer
Definition: HLTHcalPFClusterIsolationProducer.cc:35
l1t::PFClusterCollection
std::vector< l1t::PFCluster > PFClusterCollection
Definition: PFCluster.h:73
edm::InputTag
Definition: InputTag.h:15
HLTHcalPFClusterIsolationProducer::produce
void produce(edm::StreamID sid, edm::Event &, const edm::EventSetup &) const override
Definition: HLTHcalPFClusterIsolationProducer.cc:156