File indexing completed on 2024-04-06 12:31:19
0001 #ifndef TtFullHadHypothesis_h
0002 #define TtFullHadHypothesis_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
0012 #include "DataFormats/PatCandidates/interface/Jet.h"
0013 #include "DataFormats/Candidate/interface/ShallowClonePtrCandidate.h"
0014
0015 #include "AnalysisDataFormats/TopObjects/interface/TtFullHadronicEvent.h"
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029 class TtFullHadHypothesis : public edm::stream::EDProducer<> {
0030 public:
0031
0032 explicit TtFullHadHypothesis(const edm::ParameterSet& cfg);
0033
0034 protected:
0035
0036 void produce(edm::Event&, const edm::EventSetup&) override;
0037
0038 void resetCandidates();
0039
0040
0041 std::string jetCorrectionLevel(const std::string& quarkType);
0042
0043 template <typename C>
0044 std::unique_ptr<reco::ShallowClonePtrCandidate> makeCandidate(const edm::Handle<C>& handle, const int& idx);
0045
0046 std::unique_ptr<reco::ShallowClonePtrCandidate> makeCandidate(const edm::Handle<std::vector<pat::Jet> >& handle,
0047 const int& idx,
0048 const std::string& correctionLevel);
0049
0050 int key() const { return key_; };
0051
0052 reco::CompositeCandidate hypo();
0053
0054 bool isValid(const int& idx, const edm::Handle<std::vector<pat::Jet> >& jets) {
0055 return (0 <= idx && idx < (int)jets->size());
0056 };
0057
0058
0059
0060
0061
0062
0063
0064 virtual void buildKey() = 0;
0065
0066 virtual void buildHypo(edm::Event& event,
0067 const edm::Handle<std::vector<pat::Jet> >& jets,
0068 std::vector<int>& jetPartonAssociation,
0069 const unsigned int iComb) = 0;
0070
0071 protected:
0072
0073
0074 bool getMatch_;
0075
0076 edm::EDGetTokenT<std::vector<pat::Jet> > jetsToken_;
0077 edm::EDGetTokenT<std::vector<std::vector<int> > > matchToken_;
0078
0079
0080 std::string jetCorrectionLevel_;
0081
0082 int key_;
0083
0084
0085 std::unique_ptr<reco::ShallowClonePtrCandidate> lightQ_;
0086 std::unique_ptr<reco::ShallowClonePtrCandidate> lightQBar_;
0087 std::unique_ptr<reco::ShallowClonePtrCandidate> b_;
0088 std::unique_ptr<reco::ShallowClonePtrCandidate> bBar_;
0089 std::unique_ptr<reco::ShallowClonePtrCandidate> lightP_;
0090 std::unique_ptr<reco::ShallowClonePtrCandidate> lightPBar_;
0091 };
0092
0093
0094
0095 template <typename C>
0096 std::unique_ptr<reco::ShallowClonePtrCandidate> TtFullHadHypothesis::makeCandidate(const edm::Handle<C>& handle,
0097 const int& idx) {
0098 typedef typename C::value_type O;
0099 edm::Ptr<O> ptr = edm::Ptr<O>(handle, idx);
0100 return std::make_unique<reco::ShallowClonePtrCandidate>(ptr, ptr->charge(), ptr->p4(), ptr->vertex());
0101 }
0102 #endif