Back to home page

Project CMSSW displayed by LXR

 
 

    


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   /// leafs of leptonic decay channel vector decay_
0012   enum { Elec = 0, Muon = 1, Tau = 2 };
0013   /// typedef to simplify the decay vectors
0014   typedef std::vector<int> Decay;
0015 
0016   /// std contructor
0017   TtDecayChannelSelector(const edm::ParameterSet&);
0018   /// operator for decay channel selection
0019   bool operator()(const reco::GenParticleCollection& parts, std::string_view inputType) const;
0020 
0021 private:
0022   /// return decay channel to select for from configuration
0023   unsigned int decayChannel() const;
0024   // return the check sum of all entries
0025   unsigned int checkSum(const Decay& vec) const;
0026   /// search for particle with pdgId in given listing (for top)
0027   bool search(reco::GenParticleCollection::const_iterator& part, int pdgId, std::string_view inputType) const;
0028   /// search for particle with pdgId in given listing (for top daughters)
0029   bool search(reco::GenParticle::const_iterator& part, int pdgId, std::string_view inputType) const;
0030   /// check tau decay to be leptonic, 1-prong or 3-prong
0031   bool tauDecay(const reco::Candidate&) const;
0032   /// count the number of charged particles for tau decays
0033   unsigned int countProngs(const reco::Candidate& part) const;
0034 
0035 private:
0036   /// invert selection
0037   bool invert_;
0038   /// restrict tau decays
0039   bool restrictTauDecays_;
0040   /// allow tau decays into electron
0041   bool allowElectron_;
0042   /// allow tau decays into muon
0043   bool allowMuon_;
0044   /// allow 1-prong tau decays
0045   bool allow1Prong_;
0046   /// allow 2-prong tau decays
0047   bool allow3Prong_;
0048   /// top decay branch 1
0049   Decay decayBranchA_;
0050   /// top decay branch 2
0051   Decay decayBranchB_;
0052   /// vector of allowed lepton decay channels; values
0053   /// may be 0,1,2 for the entries 'Elec','Muon','Tau'
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 }