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 
edm::EDGetTokenT< T1Collection > recoCandidateProducer_
double getSum(T1, edm::Handle< std::vector< reco::PFCluster > >)
T const * product() const
Definition: Handle.h:70
Definition: config.py:1
std::string defaultModuleLabel()
bool computedRVeto(T1Ref candRef, reco::PFClusterRef pfclu)
edm::AssociationMap< edm::OneToValue< std::vector< T1 >, float > > T1IsolationMap
int iEvent
Definition: GenABIO.cc:224
void produce(edm::Event &, const edm::EventSetup &) override
HLTEcalPFClusterIsolationProducer< reco::RecoChargedCandidate > MuonHLTEcalPFClusterIsolationProducer
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
HLTEcalPFClusterIsolationProducer(const edm::ParameterSet &)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::vector< l1t::PFCluster > PFClusterCollection
Definition: PFCluster.h:87
void insert(const key_type &k, const data_type &v)
insert an association
void add(std::string const &label, ParameterSetDescription const &psetDescription)
fixed size matrix
HLT enums.
const edm::EDGetTokenT< reco::PFClusterCollection > pfClusterProducer_
HLTEcalPFClusterIsolationProducer< reco::RecoEcalCandidate > EgammaHLTEcalPFClusterIsolationProducer