24 #include <boost/regex.hpp>
30 using namespace reco::isodeposit;
33 static boost::regex re(
"^[+-]?(\\d+\\.?|\\d*\\.\\d*)$");
34 return regex_match(str.c_str(), re);
37 return atof(str.c_str());
42 deltaR_(iConfig.getParameter<double>(
"deltaR")),
43 weightExpr_(iConfig.getParameter<std::
string>(
"weight")),
44 skipDefaultVeto_(iConfig.getParameter<bool>(
"skipDefaultVeto")),
45 usePivotForBarrelEndcaps_(iConfig.getParameter<bool>(
"PivotCoordinatesForEBEE"))
57 else throw cms::Exception(
"Not Implemented") <<
"Mode '" << mode <<
"' not implemented. " <<
58 "Supported modes are 'sum', 'sumRelative', 'count'." <<
60 "New methods can be easily implemented if requested.";
61 typedef std::vector<std::string>
vstring;
62 vstring vetos = iConfig.
getParameter< vstring >(
"vetos");
64 static boost::regex ecalSwitch(
"^Ecal(Barrel|Endcaps):(.*)");
66 for (vstring::const_iterator it = vetos.begin(), ed = vetos.end(); it != ed; ++it) {
70 if (regex_match(it->c_str(),
match, ecalSwitch))
72 if(match[1] ==
"Barrel") {
76 if(match[1] ==
"Endcaps") {
105 for (AbsVetos::iterator it = barrelVetos_.begin(), ed = barrelVetos_.end(); it != ed; ++it) {
108 for (AbsVetos::iterator it = endcapVetos_.begin(), ed = endcapVetos_.end(); it != ed; ++it) {
111 barrelVetos_.clear();
112 endcapVetos_.clear();
118 for (EventDependentAbsVetos::iterator it = evdepVetos_.begin(), ed = evdepVetos_.end(); it != ed; ++it) {
119 (*it)->setEvent(iEvent,iSetup);
128 if( usePivotForBarrelEndcaps_) {
138 barrel = ( fabs(myRecoCand->
superCluster()->eta())<1.479 );
145 for (AbsVetos::iterator it = vetos->begin(), ed = vetos->end(); it != ed; ++it) {
146 (*it)->centerOn(eta,
phi);
148 double weight = (usesFunction_ ? weightExpr_(*cand) : weight_);
159 throw cms::Exception(
"Logic error") <<
"Should not happen at " << __FILE__ <<
", line " << __LINE__;
164 typedef std::vector<edm::ParameterSet> VPSet;
166 for (VPSet::const_iterator it = depPSets.begin(), ed = depPSets.end(); it != ed; ++it) {
169 if (
sources_.size() == 0)
throw cms::Exception(
"Configuration Error") <<
"Please specify at least one deposit!";
170 produces<CandDoubleMap>();
176 for (it = begin; it !=
end; ++it) it->cleanup();
183 for (it = begin; it !=
end; ++it) it->open(event, eventSetup);
188 event.put(std::auto_ptr<CandDoubleMap>(
new CandDoubleMap()));
194 typedef reco::IsoDepositMap::const_iterator iterator_i;
195 typedef reco::IsoDepositMap::container::const_iterator iterator_ii;
196 iterator_i depI = map.
begin();
197 iterator_i depIEnd = map.
end();
198 for (; depI != depIEnd; ++depI){
199 std::vector<double> retV(depI.size(),0);
201 event.get(depI.id(), candH);
204 iterator_ii depII = depI.
begin();
205 iterator_ii depIIEnd = depI.end();
207 for (; depII != depIIEnd; ++depII,++iRet){
209 for (it = begin; it !=
end; ++it) sum += it->compute(candV.
refAt(iRet));
212 filler.
insert(candH, retV.begin(), retV.end());
static reco::isodeposit::AbsVeto * make(const char *string, edm::ConsumesCollector &iC)
T getParameter(std::string const &) const
double candEnergy() const
Get energy or pT attached to cand trajectory.
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)
double countWithin(double coneSize, const AbsVetos &vetos=AbsVetos(), bool skipDepositVeto=false) const
SingleDeposit(const edm::ParameterSet &, edm::ConsumesCollector &&iC)
virtual ~PFCandIsolatorFromDeposits()
destructor
double maxWithin(double coneSize, const AbsVetos &vetos=AbsVetos(), bool skipDepositVeto=false) const
const math::XYZPointF & positionAtECALEntrance() const
double sumWithin(double coneSize, const AbsVetos &vetos=AbsVetos(), bool skipDepositVeto=false) const
reco::isodeposit::AbsVetos barrelVetos_
RefToBase< value_type > refAt(size_type i) const
virtual void produce(edm::Event &, const edm::EventSetup &)
build deposits
reco::isodeposit::EventDependentAbsVetos evdepVetos_
const_iterator begin() const
double nearestDR(double coneSize, const AbsVetos &vetos=AbsVetos(), bool skipDepositVeto=false) const
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
bool isNumber(const std::string &str) const
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
PFCandIsolatorFromDeposits(const edm::ParameterSet &)
constructor with config
bool usePivotForBarrelEndcaps_
const_iterator begin() 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