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 Attributes | |
double | deltaR_ |
reco::isodeposit::EventDependentAbsVetos | evdepVetos_ |
edm::Handle< reco::IsoDepositMap > | hDeps_ |
Mode | mode_ |
bool | skipDefaultVeto_ |
edm::InputTag | src_ |
bool | usesFunction_ |
reco::isodeposit::AbsVetos | vetos_ |
double | weight_ |
StringObjectFunction < reco::Candidate > | weightExpr_ |
Definition at line 35 of file CandIsolatorFromDeposits.h.
CandIsolatorFromDeposits::SingleDeposit::SingleDeposit | ( | const edm::ParameterSet & | iConfig | ) |
Definition at line 39 of file CandIsolatorFromDeposits.cc.
References CandIsolatorFromDeposits::Count, evdepVetos_, Exception, edm::ParameterSet::getParameter(), isNumber(), it, IsoDepositVetoFactory::make(), CandIsolatorFromDeposits::Max, CandIsolatorFromDeposits::MaxRelative, mode, mode_, CandIsolatorFromDeposits::Sum, CandIsolatorFromDeposits::Sum2, CandIsolatorFromDeposits::Sum2Relative, CandIsolatorFromDeposits::SumRelative, toNumber(), usesFunction_, vetos_, weight, and weight_.
00039 : 00040 src_(iConfig.getParameter<edm::InputTag>("src")), 00041 deltaR_(iConfig.getParameter<double>("deltaR")), 00042 weightExpr_(iConfig.getParameter<std::string>("weight")), 00043 skipDefaultVeto_(iConfig.getParameter<bool>("skipDefaultVeto")) 00044 //,vetos_(new AbsVetos()) 00045 { 00046 std::string mode = iConfig.getParameter<std::string>("mode"); 00047 if (mode == "sum") mode_ = Sum; 00048 else if (mode == "sumRelative") mode_ = SumRelative; 00049 else if (mode == "sum2") mode_ = Sum2; 00050 else if (mode == "sum2Relative") mode_ = Sum2Relative; 00051 else if (mode == "max") mode_ = Max; 00052 else if (mode == "maxRelative") mode_ = MaxRelative; 00053 else if (mode == "count") mode_ = Count; 00054 else throw cms::Exception("Not Implemented") << "Mode '" << mode << "' not implemented. " << 00055 "Supported modes are 'sum', 'sumRelative', 'count'." << 00056 //"Supported modes are 'sum', 'sumRelative', 'max', 'maxRelative', 'count'." << // TODO: on request only 00057 "New methods can be easily implemented if requested."; 00058 typedef std::vector<std::string> vstring; 00059 vstring vetos = iConfig.getParameter< vstring >("vetos"); 00060 reco::isodeposit::EventDependentAbsVeto *evdep; 00061 for (vstring::const_iterator it = vetos.begin(), ed = vetos.end(); it != ed; ++it) { 00062 vetos_.push_back(IsoDepositVetoFactory::make(it->c_str(), evdep)); 00063 if (evdep) evdepVetos_.push_back(evdep); 00064 } 00065 std::string weight = iConfig.getParameter<std::string>("weight"); 00066 if (isNumber(weight)) { 00067 //std::cout << "Weight is a simple number, " << toNumber(weight) << std::endl; 00068 weight_ = toNumber(weight); 00069 usesFunction_ = false; 00070 } else { 00071 usesFunction_ = true; 00072 //std::cout << "Weight is a function, this might slow you down... " << std::endl; 00073 } 00074 //std::cout << "CandIsolatorFromDeposits::SingleDeposit::SingleDeposit: Total of " << vetos_.size() << " vetos" << std::endl; 00075 } void CandIsolatorFromDeposits::SingleDeposit::cleanup() {
Definition at line 76 of file CandIsolatorFromDeposits.cc.
References evdepVetos_, it, and vetos_.
00076 { 00077 for (AbsVetos::iterator it = vetos_.begin(), ed = vetos_.end(); it != ed; ++it) { 00078 delete *it; 00079 } 00080 vetos_.clear(); 00081 // NOTE: we DON'T have to delete the evdepVetos_, they have already been deleted above. We just clear the vectors 00082 evdepVetos_.clear(); 00083 }
double CandIsolatorFromDeposits::SingleDeposit::compute | ( | const reco::CandidateBaseRef & | cand | ) |
Definition at line 91 of file CandIsolatorFromDeposits.cc.
References reco::IsoDeposit::candEnergy(), CandIsolatorFromDeposits::Count, reco::IsoDeposit::countWithin(), deltaR_, eta, reco::IsoDeposit::eta(), Exception, it, CandIsolatorFromDeposits::Max, CandIsolatorFromDeposits::MaxRelative, reco::IsoDeposit::maxWithin(), mode_, phi, reco::IsoDeposit::phi(), skipDefaultVeto_, CandIsolatorFromDeposits::Sum, CandIsolatorFromDeposits::Sum2, CandIsolatorFromDeposits::Sum2Relative, reco::IsoDeposit::sum2Within(), CandIsolatorFromDeposits::SumRelative, reco::IsoDeposit::sumWithin(), usesFunction_, vetos_, weight, weight_, and weightExpr_.
00091 { 00092 const IsoDeposit &dep = (*hDeps_)[cand]; 00093 double eta = dep.eta(), phi = dep.phi(); // better to center on the deposit direction 00094 // that could be, e.g., the impact point at calo 00095 for (AbsVetos::iterator it = vetos_.begin(), ed = vetos_.end(); it != ed; ++it) { 00096 (*it)->centerOn(eta, phi); 00097 } 00098 double weight = (usesFunction_ ? weightExpr_(*cand) : weight_); 00099 switch (mode_) { 00100 case Count: return weight * dep.countWithin(deltaR_, vetos_, skipDefaultVeto_); 00101 case Sum: return weight * dep.sumWithin(deltaR_, vetos_, skipDefaultVeto_); 00102 case SumRelative: return weight * dep.sumWithin(deltaR_, vetos_, skipDefaultVeto_) / dep.candEnergy() ; 00103 case Sum2: return weight * dep.sum2Within(deltaR_, vetos_, skipDefaultVeto_); 00104 case Sum2Relative: return weight * dep.sum2Within(deltaR_, vetos_, skipDefaultVeto_) / (dep.candEnergy() * dep.candEnergy()) ; 00105 case Max: return weight * dep.maxWithin(deltaR_, vetos_, skipDefaultVeto_); 00106 case MaxRelative: return weight * dep.maxWithin(deltaR_, vetos_, skipDefaultVeto_) / dep.candEnergy() ; 00107 } 00108 throw cms::Exception("Logic error") << "Should not happen at " << __FILE__ << ", line " << __LINE__; // avoid gcc warning 00109 }
const reco::IsoDepositMap& CandIsolatorFromDeposits::SingleDeposit::map | ( | void | ) | [inline] |
Definition at line 41 of file CandIsolatorFromDeposits.h.
References hDeps_.
00041 { return *hDeps_; }
void CandIsolatorFromDeposits::SingleDeposit::open | ( | const edm::Event & | iEvent, | |
const edm::EventSetup & | iSetup | |||
) |
Definition at line 84 of file CandIsolatorFromDeposits.cc.
References evdepVetos_, edm::Event::getByLabel(), hDeps_, it, and src_.
00084 { 00085 iEvent.getByLabel(src_, hDeps_); 00086 for (EventDependentAbsVetos::iterator it = evdepVetos_.begin(), ed = evdepVetos_.end(); it != ed; ++it) { 00087 (*it)->setEvent(iEvent,iSetup); 00088 } 00089 }
double CandIsolatorFromDeposits::SingleDeposit::deltaR_ [private] |
reco::isodeposit::EventDependentAbsVetos CandIsolatorFromDeposits::SingleDeposit::evdepVetos_ [private] |
Definition at line 50 of file CandIsolatorFromDeposits.h.
Referenced by cleanup(), open(), and SingleDeposit().
Definition at line 43 of file CandIsolatorFromDeposits.h.
Referenced by compute(), and SingleDeposit().
Definition at line 46 of file CandIsolatorFromDeposits.h.
Referenced by compute(), and SingleDeposit().
Definition at line 49 of file CandIsolatorFromDeposits.h.
Referenced by cleanup(), compute(), and SingleDeposit().
double CandIsolatorFromDeposits::SingleDeposit::weight_ [private] |
Definition at line 47 of file CandIsolatorFromDeposits.h.
Referenced by compute(), and SingleDeposit().