77 using namespace reco::isodeposit;
80 static const std::regex re(
"^[+-]?(\\d+\\.?|\\d*\\.\\d*)$");
81 return regex_match(str.c_str(), re);
87 deltaR_(iConfig.getParameter<double>(
"deltaR")),
88 weightExpr_(iConfig.getParameter<std::
string>(
"weight")),
89 skipDefaultVeto_(iConfig.getParameter<bool>(
"skipDefaultVeto")),
90 usePivotForBarrelEndcaps_(iConfig.getParameter<bool>(
"PivotCoordinatesForEBEE"))
96 else if (mode ==
"sumRelative")
98 else if (mode ==
"sum2")
100 else if (mode ==
"sum2Relative")
102 else if (mode ==
"max")
104 else if (mode ==
"maxRelative")
106 else if (mode ==
"nearestDR")
108 else if (mode ==
"count")
111 throw cms::Exception(
"Not Implemented") <<
"Mode '" << mode <<
"' not implemented. "
112 <<
"Supported modes are 'sum', 'sumRelative', 'count'." <<
114 "New methods can be easily implemented if requested.";
115 typedef std::vector<std::string>
vstring;
118 static const std::regex ecalSwitch(
"^Ecal(Barrel|Endcaps):(.*)");
120 for (vstring::const_iterator it = vetos.begin(), ed = vetos.end(); it != ed; ++it) {
124 if (regex_match(it->c_str(),
match, ecalSwitch)) {
125 if (match[1] ==
"Barrel") {
130 if (match[1] ==
"Endcaps") {
158 for (AbsVetos::iterator it = barrelVetos_.begin(), ed = barrelVetos_.end(); it != ed; ++it) {
161 for (AbsVetos::iterator it = endcapVetos_.begin(), ed = endcapVetos_.end(); it != ed; ++it) {
164 barrelVetos_.clear();
165 endcapVetos_.clear();
171 for (EventDependentAbsVetos::iterator it = evdepVetos_.begin(), ed = evdepVetos_.end(); it != ed; ++it) {
172 (*it)->setEvent(iEvent, iSetup);
181 if (usePivotForBarrelEndcaps_) {
190 barrel = (fabs(myRecoCand->
superCluster()->eta()) < 1.479);
197 for (AbsVetos::iterator it = vetos->begin(), ed = vetos->end(); it != ed; ++it) {
198 (*it)->centerOn(eta,
phi);
200 double weight = (usesFunction_ ? weightExpr_(*cand) : weight_);
203 return weight * dep.
countWithin(deltaR_, *vetos, skipDefaultVeto_);
205 return weight * dep.
sumWithin(deltaR_, *vetos, skipDefaultVeto_);
209 return weight * dep.
sum2Within(deltaR_, *vetos, skipDefaultVeto_);
213 return weight * dep.
maxWithin(deltaR_, *vetos, skipDefaultVeto_);
215 return weight * dep.
nearestDR(deltaR_, *vetos, skipDefaultVeto_);
219 throw cms::Exception(
"Logic error") <<
"Should not happen at " << __FILE__ <<
", line "
225 typedef std::vector<edm::ParameterSet>
VPSet;
227 for (VPSet::const_iterator it = depPSets.begin(), ed = depPSets.end(); it != ed; ++it) {
231 throw cms::Exception(
"Configuration Error") <<
"Please specify at least one deposit!";
232 produces<CandDoubleMap>();
238 for (it = begin; it !=
end; ++it)
245 for (it = begin; it !=
end; ++it)
246 it->open(event, eventSetup);
251 event.put(std::make_unique<CandDoubleMap>());
259 iterator_i depI = map.
begin();
260 iterator_i depIEnd = map.
end();
261 for (; depI != depIEnd; ++depI) {
262 std::vector<double> retV(depI.size(), 0);
264 event.get(depI.id(), candH);
267 iterator_ii depII = depI.
begin();
268 iterator_ii depIIEnd = depI.end();
270 for (; depII != depIIEnd; ++depII, ++iRet) {
272 for (it = begin; it !=
end; ++it)
273 sum += it->compute(candV.
refAt(iRet));
276 filler.
insert(candH, retV.begin(), retV.end());
static reco::isodeposit::AbsVeto * make(const char *string, edm::ConsumesCollector &iC)
double candEnergy() const
Get energy or pT attached to cand trajectory.
tuple ret
prodAgent to be discontinued
double sum2Within(double coneSize, const AbsVetos &vetos=AbsVetos(), bool skipDepositVeto=false) const
std::vector< SingleDeposit > sources_
const_iterator end() const
double compute(const reco::CandidateBaseRef &cand)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
reco::isodeposit::AbsVetos endcapVetos_
#define DEFINE_FWK_MODULE(type)
void insert(const H &h, I begin, I end)
StringObjectFunction< reco::Candidate > weightExpr_
double countWithin(double coneSize, const AbsVetos &vetos=AbsVetos(), bool skipDepositVeto=false) const
SingleDeposit(const edm::ParameterSet &, edm::ConsumesCollector &&iC)
double maxWithin(double coneSize, const AbsVetos &vetos=AbsVetos(), bool skipDepositVeto=false) const
const math::XYZPointF & positionAtECALEntrance() const
std::vector< EventDependentAbsVeto * > EventDependentAbsVetos
double sumWithin(double coneSize, const AbsVetos &vetos=AbsVetos(), bool skipDepositVeto=false) const
const reco::IsoDepositMap & map()
reco::isodeposit::AbsVetos barrelVetos_
RefToBase< value_type > refAt(size_type i) const
~PFCandIsolatorFromDeposits() override
destructor
reco::isodeposit::EventDependentAbsVetos evdepVetos_
const_iterator begin() const
edm::Handle< reco::IsoDepositMap > hDeps_
double nearestDR(double coneSize, const AbsVetos &vetos=AbsVetos(), bool skipDepositVeto=false) const
edm::EDGetTokenT< reco::IsoDepositMap > srcToken_
bool isNumber(const std::string &str) const
void produce(edm::Event &, const edm::EventSetup &) override
build deposits
PFCandIsolatorFromDeposits(const edm::ParameterSet &)
constructor with config
bool usePivotForBarrelEndcaps_
const_iterator begin() const
T getParameter(std::string const &) const
void open(const edm::Event &iEvent, const edm::EventSetup &iSetup)
Particle reconstructed by the particle flow algorithm.
std::vector< AbsVeto * > AbsVetos
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
double toNumber(const std::string &str) const
edm::ValueMap< double > CandDoubleMap
virtual reco::SuperClusterRef superCluster() const
reference to a SuperCluster