64 using namespace reco::isodeposit;
67 static const std::regex re(
"^[+-]?(\\d+\\.?|\\d*\\.\\d*)$");
68 return regex_match(str.c_str(), re);
74 deltaR_(iConfig.getParameter<double>(
"deltaR")),
75 weightExpr_(iConfig.getParameter<std::
string>(
"weight")),
76 skipDefaultVeto_(iConfig.getParameter<bool>(
"skipDefaultVeto"))
82 else if (mode ==
"sumRelative")
84 else if (mode ==
"sum2")
86 else if (mode ==
"sum2Relative")
88 else if (mode ==
"max")
90 else if (mode ==
"maxRelative")
92 else if (mode ==
"nearestDR")
94 else if (mode ==
"count")
96 else if (mode ==
"meanDR")
98 else if (mode ==
"sumDR")
101 throw cms::Exception(
"Not Implemented") <<
"Mode '" << mode <<
"' not implemented. "
102 <<
"Supported modes are 'sum', 'sumRelative', 'count'." <<
104 "New methods can be easily implemented if requested.";
105 typedef std::vector<std::string>
vstring;
108 for (vstring::const_iterator it = vetos.begin(), ed = vetos.end(); it != ed; ++it) {
125 for (AbsVetos::iterator it = vetos_.begin(), ed = vetos_.end(); it != ed; ++it) {
134 for (EventDependentAbsVetos::iterator it = evdepVetos_.begin(), ed = evdepVetos_.end(); it != ed; ++it) {
135 (*it)->setEvent(iEvent, iSetup);
143 for (AbsVetos::iterator it = vetos_.begin(), ed = vetos_.end(); it != ed; ++it) {
144 (*it)->centerOn(eta,
phi);
146 double weight = (usesFunction_ ? weightExpr_(*cand) : weight_);
149 return weight * dep.
countWithin(deltaR_, vetos_, skipDefaultVeto_);
151 return weight * dep.
sumWithin(deltaR_, vetos_, skipDefaultVeto_);
155 return weight * dep.
sum2Within(deltaR_, vetos_, skipDefaultVeto_);
159 return weight * dep.
maxWithin(deltaR_, vetos_, skipDefaultVeto_);
161 return weight * dep.
nearestDR(deltaR_, vetos_, skipDefaultVeto_);
169 throw cms::Exception(
"Logic error") <<
"Should not happen at " << __FILE__ <<
", line "
175 typedef std::vector<edm::ParameterSet>
VPSet;
177 for (VPSet::const_iterator it = depPSets.begin(), ed = depPSets.end(); it != ed; ++it) {
181 throw cms::Exception(
"Configuration Error") <<
"Please specify at least one deposit!";
182 produces<CandDoubleMap>();
188 for (it = begin; it !=
end; ++it)
195 for (it = begin; it !=
end; ++it)
196 it->open(event, eventSetup);
201 event.put(std::make_unique<CandDoubleMap>());
204 auto ret = std::make_unique<CandDoubleMap>();
209 iterator_i depI = map.
begin();
210 iterator_i depIEnd = map.
end();
211 for (; depI != depIEnd; ++depI) {
212 std::vector<double> retV(depI.size(), 0);
214 event.get(depI.id(), candH);
217 iterator_ii depII = depI.
begin();
218 iterator_ii depIIEnd = depI.end();
220 for (; depII != depIIEnd; ++depII, ++iRet) {
222 for (it = begin; it !=
end; ++it)
223 sum += it->compute(candV.
refAt(iRet));
226 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.
bool isNumber(const std::string &str)
tuple ret
prodAgent to be discontinued
double sum2Within(double coneSize, const AbsVetos &vetos=AbsVetos(), bool skipDepositVeto=false) const
double compute(const reco::CandidateBaseRef &cand)
const_iterator end() const
SingleDeposit(const edm::ParameterSet &, edm::ConsumesCollector &&iC)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
double algoWithin(double coneSize, const AbsVetos &vetos=AbsVetos(), bool skipDepositVeto=false) const
Get some info about the deposit (e.g. sum, max, sum2, count)
StringObjectFunction< reco::Candidate > weightExpr_
std::vector< SingleDeposit > sources_
double countWithin(double coneSize, const AbsVetos &vetos=AbsVetos(), bool skipDepositVeto=false) const
double maxWithin(double coneSize, const AbsVetos &vetos=AbsVetos(), bool skipDepositVeto=false) const
edm::ValueMap< double > CandDoubleMap
edm::Handle< reco::IsoDepositMap > hDeps_
std::vector< EventDependentAbsVeto * > EventDependentAbsVetos
double sumWithin(double coneSize, const AbsVetos &vetos=AbsVetos(), bool skipDepositVeto=false) const
RefToBase< value_type > refAt(size_type i) const
double toNumber(const std::string &str)
const_iterator begin() const
const reco::IsoDepositMap & map()
double nearestDR(double coneSize, const AbsVetos &vetos=AbsVetos(), bool skipDepositVeto=false) const
void open(const edm::Event &iEvent, const edm::EventSetup &iSetup)
reco::isodeposit::AbsVetos vetos_
edm::EDGetTokenT< reco::IsoDepositMap > srcToken_
const_iterator begin() const
T getParameter(std::string const &) const
void produce(edm::Event &, const edm::EventSetup &) override
build deposits
~CandIsolatorFromDeposits() override
destructor
CandIsolatorFromDeposits(const edm::ParameterSet &)
constructor with config
std::vector< AbsVeto * > AbsVetos
reco::isodeposit::EventDependentAbsVetos evdepVetos_