Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:33:10

0001 #ifndef PhysicsTools_PatUtils_interface_EventHypothesisTools_h
0002 #define PhysicsTools_PatUtils_interface_EventHypothesisTools_h
0003 
0004 #include "DataFormats/PatCandidates/interface/EventHypothesis.h"
0005 #include "CommonTools/Utils/interface/StringCutObjectSelector.h"
0006 
0007 #include <memory>
0008 #include <vector>
0009 
0010 namespace pat {
0011   namespace eventhypothesis {
0012 
0013     /** Does the AND of some filters. OWNS the pointers to the filters */
0014     class AndFilter : public ParticleFilter {
0015     public:
0016       AndFilter() : filters_(2) {}
0017       AndFilter(ParticleFilter *f1, ParticleFilter *f2);
0018       ~AndFilter() override {}
0019       AndFilter &operator&=(ParticleFilter *filter) {
0020         filters_.emplace_back(filter);
0021         return *this;
0022       }
0023       bool operator()(const CandRefType &cand, const std::string &role) const override;
0024 
0025     private:
0026       std::vector<std::unique_ptr<ParticleFilter>> filters_;
0027     };
0028 
0029     /** Does the OR of some filters. OWNS the pointers to the filters */
0030     class OrFilter : public ParticleFilter {
0031     public:
0032       OrFilter() : filters_(2) {}
0033       OrFilter(ParticleFilter *f1, ParticleFilter *f2);
0034       ~OrFilter() override {}
0035       OrFilter &operator&=(ParticleFilter *filter) {
0036         filters_.emplace_back(filter);
0037         return *this;
0038       }
0039       bool operator()(const CandRefType &cand, const std::string &role) const override;
0040 
0041     private:
0042       std::vector<std::unique_ptr<ParticleFilter>> filters_;
0043     };
0044 
0045     class ByPdgId : public ParticleFilter {
0046     public:
0047       explicit ByPdgId(int32_t pdgCode, bool alsoAntiparticle = true);
0048       ~ByPdgId() override {}
0049       bool operator()(const CandRefType &cand, const std::string &role) const override;
0050 
0051     private:
0052       int32_t pdgCode_;
0053       bool antiparticle_;
0054     };
0055 
0056     class ByString : public ParticleFilter {
0057     public:
0058       ByString(const std::string &cut);  // not putting the explicit on purpose, I want to see what happens
0059       ~ByString() override {}
0060       bool operator()(const CandRefType &cand, const std::string &role) const override;
0061 
0062     private:
0063       StringCutObjectSelector<reco::Candidate> sel_;
0064     };
0065 
0066   }  // namespace eventhypothesis
0067 }  // namespace pat
0068 
0069 #endif