Go to the documentation of this file.00001 #include "PhysicsTools/PatUtils/interface/EventHypothesisTools.h"
00002
00003 using namespace pat::eventhypothesis;
00004
00005 AndFilter::AndFilter(ParticleFilter *f1, ParticleFilter *f2) :
00006 filters_(2)
00007 {
00008 filters_.push_back(f1); filters_.push_back(f2);
00009 }
00010
00011 bool AndFilter::operator()(const CandRefType &cand, const std::string &role) const {
00012 for (boost::ptr_vector<ParticleFilter>::const_iterator it = filters_.begin(); it != filters_.end(); ++it) {
00013 if (! (*it)(cand, role) ) return false;
00014 }
00015 return true;
00016 }
00017
00018 OrFilter::OrFilter(ParticleFilter *f1, ParticleFilter *f2) :
00019 filters_(2)
00020 {
00021 filters_.push_back(f1); filters_.push_back(f2);
00022 }
00023
00024 bool OrFilter::operator()(const CandRefType &cand, const std::string &role) const {
00025 for (boost::ptr_vector<ParticleFilter>::const_iterator it = filters_.begin(); it != filters_.end(); ++it) {
00026 if ( (*it)(cand, role) ) return true;
00027 }
00028 return false;
00029 }
00030
00031 ByPdgId::ByPdgId(int32_t pdgCode, bool alsoAntiparticle) :
00032 pdgCode_(alsoAntiparticle ? std::abs(pdgCode) : pdgCode),
00033 antiparticle_(alsoAntiparticle)
00034 {
00035 }
00036
00037 bool ByPdgId::operator()(const CandRefType &cand, const std::string &role) const {
00038 return antiparticle_ ?
00039 (std::abs(cand->pdgId()) == pdgCode_) :
00040 (cand->pdgId() == pdgCode_);
00041 }
00042
00043 ByString::ByString(const std::string &cut) :
00044 sel_(cut)
00045 {
00046 }
00047
00048 bool ByString::operator()(const CandRefType &cand, const std::string &role) const {
00049 return sel_(*cand);
00050 }