ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/DGele/PhysicsTools/PatUtils/src/EventHypothesisTools.cc
Revision: 1.1.1.1 (vendor branch)
Committed: Tue Oct 20 17:15:14 2009 UTC (15 years, 6 months ago) by dgele
Content type: text/plain
Branch: ANA
CVS Tags: start
Changes since 1.1: +0 -0 lines
Log Message:
version CMSSW_2_2_10

File Contents

# User Rev Content
1 dgele 1.1 #include "PhysicsTools/PatUtils/interface/EventHypothesisTools.h"
2    
3     using namespace pat::eventhypothesis;
4    
5     AndFilter::AndFilter(ParticleFilter *f1, ParticleFilter *f2) :
6     filters_(2)
7     {
8     filters_.push_back(f1); filters_.push_back(f2);
9     }
10    
11     bool AndFilter::operator()(const CandRefType &cand, const std::string &role) const {
12     for (boost::ptr_vector<ParticleFilter>::const_iterator it = filters_.begin(); it != filters_.end(); ++it) {
13     if (! (*it)(cand, role) ) return false;
14     }
15     return true;
16     }
17    
18     OrFilter::OrFilter(ParticleFilter *f1, ParticleFilter *f2) :
19     filters_(2)
20     {
21     filters_.push_back(f1); filters_.push_back(f2);
22     }
23    
24     bool OrFilter::operator()(const CandRefType &cand, const std::string &role) const {
25     for (boost::ptr_vector<ParticleFilter>::const_iterator it = filters_.begin(); it != filters_.end(); ++it) {
26     if ( (*it)(cand, role) ) return true;
27     }
28     return false;
29     }
30    
31     ByPdgId::ByPdgId(int32_t pdgCode, bool alsoAntiparticle) :
32     pdgCode_(alsoAntiparticle ? std::abs(pdgCode) : pdgCode),
33     antiparticle_(alsoAntiparticle)
34     {
35     }
36    
37     bool ByPdgId::operator()(const CandRefType &cand, const std::string &role) const {
38     return antiparticle_ ?
39     (std::abs(cand->pdgId()) == pdgCode_) :
40     (cand->pdgId() == pdgCode_);
41     }
42    
43     ByString::ByString(const std::string &cut) :
44     sel_(cut)
45     {
46     }
47    
48     bool ByString::operator()(const CandRefType &cand, const std::string &role) const {
49     return sel_(*cand);
50     }