Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:24:06

0001 
0002 #include "PhysicsTools/PatUtils/interface/EventHypothesisTools.h"
0003 
0004 using namespace pat::eventhypothesis;
0005 
0006 AndFilter::AndFilter(ParticleFilter *f1, ParticleFilter *f2) : filters_(2) {
0007   filters_.emplace_back(f1);
0008   filters_.emplace_back(f2);
0009 }
0010 
0011 bool AndFilter::operator()(const CandRefType &cand, const std::string &role) const {
0012   for (const auto &it : filters_) {
0013     if (!(*it)(cand, role))
0014       return false;
0015   }
0016   return true;
0017 }
0018 
0019 OrFilter::OrFilter(ParticleFilter *f1, ParticleFilter *f2) : filters_(2) {
0020   filters_.emplace_back(f1);
0021   filters_.emplace_back(f2);
0022 }
0023 
0024 bool OrFilter::operator()(const CandRefType &cand, const std::string &role) const {
0025   for (const auto &it : filters_) {
0026     if ((*it)(cand, role))
0027       return true;
0028   }
0029   return false;
0030 }
0031 
0032 ByPdgId::ByPdgId(int32_t pdgCode, bool alsoAntiparticle)
0033     : pdgCode_(alsoAntiparticle ? std::abs(pdgCode) : pdgCode), antiparticle_(alsoAntiparticle) {}
0034 
0035 bool ByPdgId::operator()(const CandRefType &cand, const std::string &role) const {
0036   return antiparticle_ ? (std::abs(cand->pdgId()) == pdgCode_) : (cand->pdgId() == pdgCode_);
0037 }
0038 
0039 ByString::ByString(const std::string &cut) : sel_(cut) {}
0040 
0041 bool ByString::operator()(const CandRefType &cand, const std::string &role) const { return sel_(*cand); }