Public Member Functions | |
void | cleanup () |
double | compute (const reco::CandidateBaseRef &cand) |
const reco::IsoDepositMap & | map () |
void | open (const edm::Event &iEvent, const edm::EventSetup &iSetup) |
SingleDeposit (const edm::ParameterSet &) | |
Private Member Functions | |
bool | isNumber (const std::string &str) const |
double | toNumber (const std::string &str) const |
Private Attributes | |
reco::isodeposit::AbsVetos | barrelVetos_ |
double | deltaR_ |
reco::isodeposit::AbsVetos | endcapVetos_ |
reco::isodeposit::EventDependentAbsVetos | evdepVetos_ |
edm::Handle< reco::IsoDepositMap > | hDeps_ |
Mode | mode_ |
bool | skipDefaultVeto_ |
edm::InputTag | src_ |
bool | usePivotForBarrelEndcaps_ |
bool | usesFunction_ |
double | weight_ |
StringObjectFunction < reco::Candidate > | weightExpr_ |
Definition at line 35 of file PFCandIsolatorFromDeposit.h.
PFCandIsolatorFromDeposits::SingleDeposit::SingleDeposit | ( | const edm::ParameterSet & | iConfig | ) |
Definition at line 40 of file PFCandIsolatorFromDeposit.cc.
References barrelVetos_, PFCandIsolatorFromDeposits::Count, endcapVetos_, evdepVetos_, Exception, edm::ParameterSet::getParameter(), isNumber(), IsoDepositVetoFactory::make(), match(), PFCandIsolatorFromDeposits::Max, PFCandIsolatorFromDeposits::MaxRelative, mode, mode_, PFCandIsolatorFromDeposits::NearestDR, PFCandIsolatorFromDeposits::Sum, PFCandIsolatorFromDeposits::Sum2, PFCandIsolatorFromDeposits::Sum2Relative, PFCandIsolatorFromDeposits::SumRelative, toNumber(), usePivotForBarrelEndcaps_, usesFunction_, CommonMethods::weight(), and weight_.
: src_(iConfig.getParameter<edm::InputTag>("src")), deltaR_(iConfig.getParameter<double>("deltaR")), weightExpr_(iConfig.getParameter<std::string>("weight")), skipDefaultVeto_(iConfig.getParameter<bool>("skipDefaultVeto")), usePivotForBarrelEndcaps_(iConfig.getParameter<bool>("PivotCoordinatesForEBEE")) //,vetos_(new AbsVetos()) { std::string mode = iConfig.getParameter<std::string>("mode"); if (mode == "sum") mode_ = Sum; else if (mode == "sumRelative") mode_ = SumRelative; else if (mode == "sum2") mode_ = Sum2; else if (mode == "sum2Relative") mode_ = Sum2Relative; else if (mode == "max") mode_ = Max; else if (mode == "maxRelative") mode_ = MaxRelative; else if (mode == "nearestDR") mode_ = NearestDR; else if (mode == "count") mode_ = Count; else throw cms::Exception("Not Implemented") << "Mode '" << mode << "' not implemented. " << "Supported modes are 'sum', 'sumRelative', 'count'." << //"Supported modes are 'sum', 'sumRelative', 'max', 'maxRelative', 'count'." << // TODO: on request only "New methods can be easily implemented if requested."; typedef std::vector<std::string> vstring; vstring vetos = iConfig.getParameter< vstring >("vetos"); reco::isodeposit::EventDependentAbsVeto *evdep=0; static boost::regex ecalSwitch("^Ecal(Barrel|Endcaps):(.*)"); for (vstring::const_iterator it = vetos.begin(), ed = vetos.end(); it != ed; ++it) { boost::cmatch match; // in that case, make two series of vetoes if( usePivotForBarrelEndcaps_) { if (regex_match(it->c_str(), match, ecalSwitch)) { if(match[1] == "Barrel") { // std::cout << " Adding Barrel veto " << std::string(match[2]) << std::endl; barrelVetos_.push_back(IsoDepositVetoFactory::make(std::string(match[2]).c_str(), evdep)); // I don't know a better syntax } if(match[1] == "Endcaps") { // std::cout << " Adding Endcap veto " << std::string(match[2]) << std::endl; endcapVetos_.push_back(IsoDepositVetoFactory::make(std::string(match[2]).c_str(), evdep)); } } else { barrelVetos_.push_back(IsoDepositVetoFactory::make(it->c_str(), evdep)); endcapVetos_.push_back(IsoDepositVetoFactory::make(it->c_str(), evdep)); } } else { //only one serie of vetoes, just barrel barrelVetos_.push_back(IsoDepositVetoFactory::make(it->c_str(), evdep)); } if (evdep) evdepVetos_.push_back(evdep); } std::string weight = iConfig.getParameter<std::string>("weight"); if (isNumber(weight)) { //std::cout << "Weight is a simple number, " << toNumber(weight) << std::endl; weight_ = toNumber(weight); usesFunction_ = false; } else { usesFunction_ = true; //std::cout << "Weight is a function, this might slow you down... " << std::endl; } //std::cout << "PFCandIsolatorFromDeposits::SingleDeposit::SingleDeposit: Total of " << vetos_.size() << " vetos" << std::endl; }
void PFCandIsolatorFromDeposits::SingleDeposit::cleanup | ( | ) |
Definition at line 104 of file PFCandIsolatorFromDeposit.cc.
{ for (AbsVetos::iterator it = barrelVetos_.begin(), ed = barrelVetos_.end(); it != ed; ++it) { delete *it; } for (AbsVetos::iterator it = endcapVetos_.begin(), ed = endcapVetos_.end(); it != ed; ++it) { delete *it; } barrelVetos_.clear(); endcapVetos_.clear(); // NOTE: we DON'T have to delete the evdepVetos_, they have already been deleted above. We just clear the vectors evdepVetos_.clear(); }
double PFCandIsolatorFromDeposits::SingleDeposit::compute | ( | const reco::CandidateBaseRef & | cand | ) |
Definition at line 123 of file PFCandIsolatorFromDeposit.cc.
References Reference_intrackfit_cff::barrel, reco::IsoDeposit::candEnergy(), PFCandIsolatorFromDeposits::Count, reco::IsoDeposit::countWithin(), deltaR_, eta(), reco::IsoDeposit::eta(), Exception, PFCandIsolatorFromDeposits::Max, PFCandIsolatorFromDeposits::MaxRelative, reco::IsoDeposit::maxWithin(), PFCandIsolatorFromDeposits::NearestDR, reco::IsoDeposit::nearestDR(), phi, reco::IsoDeposit::phi(), reco::PFCandidate::positionAtECALEntrance(), PFCandIsolatorFromDeposits::Sum, PFCandIsolatorFromDeposits::Sum2, PFCandIsolatorFromDeposits::Sum2Relative, reco::IsoDeposit::sum2Within(), PFCandIsolatorFromDeposits::SumRelative, reco::IsoDeposit::sumWithin(), reco::RecoCandidate::superCluster(), and CommonMethods::weight().
{ const IsoDeposit &dep = (*hDeps_)[cand]; double eta = dep.eta(), phi = dep.phi(); // better to center on the deposit direction // that could be, e.g., the impact point at calo bool barrel=true; if( usePivotForBarrelEndcaps_) { const reco::PFCandidate * myPFCand = dynamic_cast<const reco::PFCandidate*>(&(*cand)); if(myPFCand) { // exact barrel boundary barrel = fabs(myPFCand->positionAtECALEntrance().eta())<1.479; } else { const reco::RecoCandidate * myRecoCand = dynamic_cast<const reco::RecoCandidate*>(&(*cand)); if(myRecoCand) { // not optimal. isEB should be used. barrel = ( fabs(myRecoCand->superCluster()->eta())<1.479 ); } } } // if ! usePivotForBarrelEndcaps_ only the barrel series is used, which does not prevent the vetoes do be different in barrel & endcaps reco::isodeposit::AbsVetos * vetos = (barrel) ? &barrelVetos_ : &endcapVetos_; for (AbsVetos::iterator it = vetos->begin(), ed = vetos->end(); it != ed; ++it) { (*it)->centerOn(eta, phi); } double weight = (usesFunction_ ? weightExpr_(*cand) : weight_); switch (mode_) { case Count: return weight * dep.countWithin(deltaR_, *vetos, skipDefaultVeto_); case Sum: return weight * dep.sumWithin(deltaR_, *vetos, skipDefaultVeto_); case SumRelative: return weight * dep.sumWithin(deltaR_, *vetos, skipDefaultVeto_) / dep.candEnergy() ; case Sum2: return weight * dep.sum2Within(deltaR_, *vetos, skipDefaultVeto_); case Sum2Relative: return weight * dep.sum2Within(deltaR_, *vetos, skipDefaultVeto_) / (dep.candEnergy() * dep.candEnergy()) ; case Max: return weight * dep.maxWithin(deltaR_, *vetos, skipDefaultVeto_); case NearestDR: return weight * dep.nearestDR(deltaR_, *vetos, skipDefaultVeto_); case MaxRelative: return weight * dep.maxWithin(deltaR_, *vetos, skipDefaultVeto_) / dep.candEnergy() ; } throw cms::Exception("Logic error") << "Should not happen at " << __FILE__ << ", line " << __LINE__; // avoid gcc warning }
bool PFCandIsolatorFromDeposits::SingleDeposit::isNumber | ( | const std::string & | str | ) | const [private] |
Definition at line 32 of file PFCandIsolatorFromDeposit.cc.
Referenced by SingleDeposit().
{ static boost::regex re("^[+-]?(\\d+\\.?|\\d*\\.\\d*)$"); return regex_match(str.c_str(), re); }
const reco::IsoDepositMap& PFCandIsolatorFromDeposits::SingleDeposit::map | ( | ) | [inline] |
void PFCandIsolatorFromDeposits::SingleDeposit::open | ( | const edm::Event & | iEvent, |
const edm::EventSetup & | iSetup | ||
) |
Definition at line 116 of file PFCandIsolatorFromDeposit.cc.
References edm::Event::getByLabel().
{ iEvent.getByLabel(src_, hDeps_); for (EventDependentAbsVetos::iterator it = evdepVetos_.begin(), ed = evdepVetos_.end(); it != ed; ++it) { (*it)->setEvent(iEvent,iSetup); } }
double PFCandIsolatorFromDeposits::SingleDeposit::toNumber | ( | const std::string & | str | ) | const [private] |
Definition at line 36 of file PFCandIsolatorFromDeposit.cc.
Referenced by SingleDeposit().
{
return atof(str.c_str());
}
Definition at line 50 of file PFCandIsolatorFromDeposit.h.
Referenced by SingleDeposit().
double PFCandIsolatorFromDeposits::SingleDeposit::deltaR_ [private] |
Definition at line 45 of file PFCandIsolatorFromDeposit.h.
Definition at line 51 of file PFCandIsolatorFromDeposit.h.
Referenced by SingleDeposit().
reco::isodeposit::EventDependentAbsVetos PFCandIsolatorFromDeposits::SingleDeposit::evdepVetos_ [private] |
Definition at line 52 of file PFCandIsolatorFromDeposit.h.
Referenced by SingleDeposit().
Definition at line 55 of file PFCandIsolatorFromDeposit.h.
Referenced by map().
Definition at line 43 of file PFCandIsolatorFromDeposit.h.
Referenced by SingleDeposit().
bool PFCandIsolatorFromDeposits::SingleDeposit::skipDefaultVeto_ [private] |
Definition at line 53 of file PFCandIsolatorFromDeposit.h.
Definition at line 44 of file PFCandIsolatorFromDeposit.h.
Definition at line 54 of file PFCandIsolatorFromDeposit.h.
Referenced by SingleDeposit().
bool PFCandIsolatorFromDeposits::SingleDeposit::usesFunction_ [private] |
Definition at line 46 of file PFCandIsolatorFromDeposit.h.
Referenced by SingleDeposit().
double PFCandIsolatorFromDeposits::SingleDeposit::weight_ [private] |
Definition at line 47 of file PFCandIsolatorFromDeposit.h.
Referenced by SingleDeposit().
StringObjectFunction<reco::Candidate> PFCandIsolatorFromDeposits::SingleDeposit::weightExpr_ [private] |
Definition at line 49 of file PFCandIsolatorFromDeposit.h.