File indexing completed on 2024-04-06 12:31:19
0001 #ifndef TtFullLepHypothesis_h
0002 #define TtFullLepHypothesis_h
0003
0004 #include <memory>
0005 #include <vector>
0006
0007 #include "FWCore/Framework/interface/Event.h"
0008 #include "FWCore/Framework/interface/stream/EDProducer.h"
0009 #include "FWCore/Framework/interface/Frameworkfwd.h"
0010 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0011 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0012
0013 #include "DataFormats/PatCandidates/interface/Electron.h"
0014 #include "DataFormats/PatCandidates/interface/Muon.h"
0015 #include "DataFormats/PatCandidates/interface/Jet.h"
0016 #include "DataFormats/PatCandidates/interface/MET.h"
0017 #include "DataFormats/RecoCandidate/interface/RecoCandidate.h"
0018 #include "DataFormats/Candidate/interface/ShallowClonePtrCandidate.h"
0019
0020 #include "AnalysisDataFormats/TopObjects/interface/TtFullLeptonicEvent.h"
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 class TtFullLepHypothesis : public edm::stream::EDProducer<> {
0035 public:
0036
0037 explicit TtFullLepHypothesis(const edm::ParameterSet&);
0038
0039 protected:
0040
0041 void produce(edm::Event&, const edm::EventSetup&) override;
0042
0043 void resetCandidates();
0044
0045 template <typename C>
0046 std::unique_ptr<reco::ShallowClonePtrCandidate> makeCandidate(const edm::Handle<C>& handle, const int& idx);
0047
0048 std::unique_ptr<reco::ShallowClonePtrCandidate> makeCandidate(const edm::Handle<std::vector<pat::Jet> >& handle,
0049 const int& idx,
0050 const std::string& correctionLevel);
0051
0052 int key() const { return key_; };
0053
0054 reco::CompositeCandidate hypo();
0055
0056 bool isValid(const int& idx, const edm::Handle<std::vector<pat::Jet> >& jets) {
0057 return (0 <= idx && idx < (int)jets->size());
0058 };
0059
0060
0061
0062
0063
0064
0065
0066 virtual void buildKey() = 0;
0067
0068 virtual void buildHypo(edm::Event& evt,
0069 const edm::Handle<std::vector<pat::Electron> >& elecs,
0070 const edm::Handle<std::vector<pat::Muon> >& mus,
0071 const edm::Handle<std::vector<pat::Jet> >& jets,
0072 const edm::Handle<std::vector<pat::MET> >& mets,
0073 std::vector<int>& match,
0074 const unsigned int iComb) = 0;
0075
0076 protected:
0077
0078
0079 bool getMatch_;
0080
0081 edm::EDGetTokenT<std::vector<std::vector<int> > > matchToken_;
0082 edm::EDGetTokenT<std::vector<pat::Electron> > elecsToken_;
0083 edm::EDGetTokenT<std::vector<pat::Muon> > musToken_;
0084 edm::EDGetTokenT<std::vector<pat::Jet> > jetsToken_;
0085 edm::EDGetTokenT<std::vector<pat::MET> > metsToken_;
0086
0087
0088 std::string jetCorrectionLevel_;
0089
0090 int key_;
0091
0092
0093 std::unique_ptr<reco::ShallowClonePtrCandidate> lepton_;
0094 std::unique_ptr<reco::ShallowClonePtrCandidate> leptonBar_;
0095 std::unique_ptr<reco::ShallowClonePtrCandidate> b_;
0096 std::unique_ptr<reco::ShallowClonePtrCandidate> bBar_;
0097 std::unique_ptr<reco::ShallowClonePtrCandidate> neutrino_;
0098 std::unique_ptr<reco::ShallowClonePtrCandidate> neutrinoBar_;
0099
0100
0101
0102 std::unique_ptr<reco::LeafCandidate> recNu;
0103 std::unique_ptr<reco::LeafCandidate> recNuBar;
0104 };
0105
0106
0107
0108 template <typename C>
0109 std::unique_ptr<reco::ShallowClonePtrCandidate> TtFullLepHypothesis::makeCandidate(const edm::Handle<C>& handle,
0110 const int& idx) {
0111 typedef typename C::value_type O;
0112 edm::Ptr<O> ptr = edm::Ptr<O>(handle, idx);
0113 return std::make_unique<reco::ShallowClonePtrCandidate>(ptr, ptr->charge(), ptr->p4(), ptr->vertex());
0114 }
0115
0116 #endif