File indexing completed on 2023-10-25 10:05:30
0001 #include <vector>
0002 #include <cstring>
0003 #include <iostream>
0004 #include <string_view>
0005
0006 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0007 #include "DataFormats/HepMCCandidate/interface/GenParticle.h"
0008
0009 class TtDecayChannelSelector {
0010 public:
0011
0012 enum { Elec = 0, Muon = 1, Tau = 2 };
0013
0014 typedef std::vector<int> Decay;
0015
0016
0017 TtDecayChannelSelector(const edm::ParameterSet&);
0018
0019 bool operator()(const reco::GenParticleCollection& parts, std::string_view inputType) const;
0020
0021 private:
0022
0023 unsigned int decayChannel() const;
0024
0025 unsigned int checkSum(const Decay& vec) const;
0026
0027 bool search(reco::GenParticleCollection::const_iterator& part, int pdgId, std::string_view inputType) const;
0028
0029 bool search(reco::GenParticle::const_iterator& part, int pdgId, std::string_view inputType) const;
0030
0031 bool tauDecay(const reco::Candidate&) const;
0032
0033 unsigned int countProngs(const reco::Candidate& part) const;
0034
0035 private:
0036
0037 bool invert_;
0038
0039 bool restrictTauDecays_;
0040
0041 bool allowElectron_;
0042
0043 bool allowMuon_;
0044
0045 bool allow1Prong_;
0046
0047 bool allow3Prong_;
0048
0049 Decay decayBranchA_;
0050
0051 Decay decayBranchB_;
0052
0053
0054 Decay allowedDecays_;
0055 };
0056
0057 inline unsigned int TtDecayChannelSelector::decayChannel() const {
0058 unsigned int channel = 0;
0059 if (std::count(decayBranchA_.begin(), decayBranchA_.end(), 1) > 0) {
0060 ++channel;
0061 }
0062 if (std::count(decayBranchB_.begin(), decayBranchB_.end(), 1) > 0) {
0063 ++channel;
0064 }
0065 return channel;
0066 }
0067
0068 inline unsigned int TtDecayChannelSelector::checkSum(const Decay& vec) const {
0069 unsigned int sum = 0;
0070 for (unsigned int d = 0; d < vec.size(); ++d) {
0071 sum += vec[d];
0072 }
0073 return sum;
0074 }