CMS 3D CMS Logo

TtFullLepHypothesis.cc
Go to the documentation of this file.
3 
6  : elecsToken_(consumes<std::vector<pat::Electron> >(cfg.getParameter<edm::InputTag>("electrons"))),
7  musToken_(consumes<std::vector<pat::Muon> >(cfg.getParameter<edm::InputTag>("muons"))),
8  jetsToken_(consumes<std::vector<pat::Jet> >(cfg.getParameter<edm::InputTag>("jets"))),
9  metsToken_(consumes<std::vector<pat::MET> >(cfg.getParameter<edm::InputTag>("mets"))),
10 
11  lepton_(nullptr),
12  leptonBar_(nullptr),
13  b_(nullptr),
14  bBar_(nullptr),
15  neutrino_(nullptr),
16  neutrinoBar_(nullptr) {
17  getMatch_ = false;
18  if (cfg.exists("match")) {
19  getMatch_ = true;
20  matchToken_ = consumes<std::vector<std::vector<int> > >(cfg.getParameter<edm::InputTag>("match"));
21  }
22  // if no other correction is given apply L3 (abs) correction
23  jetCorrectionLevel_ = "abs";
24  if (cfg.exists("jetCorrectionLevel")) {
25  jetCorrectionLevel_ = cfg.getParameter<std::string>("jetCorrectionLevel");
26  } else { // if no other correction is given apply L3 (abs) correction
27  jetCorrectionLevel_ = "abs";
28  }
29  produces<std::vector<std::pair<reco::CompositeCandidate, std::vector<int> > > >();
30  produces<int>("Key");
31 }
32 
35  if (lepton_)
36  delete lepton_;
37  if (leptonBar_)
38  delete leptonBar_;
39  if (b_)
40  delete b_;
41  if (bBar_)
42  delete bBar_;
43  if (neutrino_)
44  delete neutrino_;
45  if (neutrinoBar_)
46  delete neutrinoBar_;
47  //if( met_ ) delete met_;
48 }
49 
54 
56  evt.getByToken(musToken_, mus);
57 
60 
63 
64  std::vector<std::vector<int> > matchVec;
65  if (getMatch_) {
67  evt.getByToken(matchToken_, matchHandle);
68  ;
69  matchVec = *matchHandle;
70  } else {
71  std::vector<int> dummyMatch;
72  for (unsigned int i = 0; i < 4; ++i)
73  dummyMatch.push_back(-1);
74  matchVec.push_back(dummyMatch);
75  }
76 
77  // declare unique_ptr for products
78  std::unique_ptr<std::vector<std::pair<reco::CompositeCandidate, std::vector<int> > > > pOut(
79  new std::vector<std::pair<reco::CompositeCandidate, std::vector<int> > >);
80  std::unique_ptr<int> pKey(new int);
81 
82  // build and feed out key
83  buildKey();
84  *pKey = key();
85  evt.put(std::move(pKey), "Key");
86 
87  // go through given vector of jet combinations
88  unsigned int idMatch = 0;
89  typedef std::vector<std::vector<int> >::iterator MatchVecIterator;
90  for (MatchVecIterator match = matchVec.begin(); match != matchVec.end(); ++match) {
91  // reset pointers
93  // build hypothesis
94  buildHypo(evt, elecs, mus, jets, mets, *match, idMatch++);
95  pOut->push_back(std::make_pair(hypo(), *match));
96  }
97  // feed out hyps and matches
98  evt.put(std::move(pOut));
99 }
100 
103  lepton_ = nullptr;
104  leptonBar_ = nullptr;
105  b_ = nullptr;
106  bBar_ = nullptr;
107  neutrino_ = nullptr;
108  neutrinoBar_ = nullptr;
109  //met_ = 0;
110 }
111 
114  // check for sanity of the hypothesis
115  if (!lepton_ || !leptonBar_ || !b_ || !bBar_) {
116  return reco::CompositeCandidate();
117  }
118 
119  if (key() == TtFullLeptonicEvent::kGenMatch && (!recNu || !recNuBar)) {
120  edm::LogInfo("TtFullHypothesis") << "no neutrinos for gen match" << std::endl;
121  return reco::CompositeCandidate();
122  }
124  edm::LogInfo("TtFullHypothesis") << "no neutrinos for kin solution" << std::endl;
125  return reco::CompositeCandidate();
126  }
127 
128  // setup transient references
130 
131  AddFourMomenta addFourMomenta;
132 
133  // build up the top branch
136  WPlus.addDaughter(*neutrino_, TtFullLepDaughter::Nu);
137  else if (key() == TtFullLeptonicEvent::kGenMatch)
138  WPlus.addDaughter(*recNu, TtFullLepDaughter::Nu);
139  addFourMomenta.set(WPlus);
140  Top.addDaughter(WPlus, TtFullLepDaughter::WPlus);
141  Top.addDaughter(*b_, TtFullLepDaughter::B);
142  addFourMomenta.set(Top);
143 
144  // build up the anti top branch
145  WMinus.addDaughter(*lepton_, TtFullLepDaughter::Lep);
148  else if (key() == TtFullLeptonicEvent::kGenMatch)
150  addFourMomenta.set(WMinus);
152  TopBar.addDaughter(*bBar_, TtFullLepDaughter::BBar);
153  addFourMomenta.set(TopBar);
154 
155  // build ttbar hypothesis
158  addFourMomenta.set(hyp);
159 
160  // the four momentum of the met is not added to the hypothesis
161  // because it is allready included through the neutrinos
162  //hyp.addDaughter(*met_, TtFullLepDaughter::Met);
163  return hyp;
164 }
165 
167 void TtFullLepHypothesis::setCandidate(const edm::Handle<std::vector<pat::Jet> >& handle,
168  const int& idx,
170  const std::string& correctionLevel) {
173  ptr, ptr->charge(), ptr->correctedJet(jetCorrectionLevel_, "bottom").p4(), ptr->vertex());
174 }
mps_fire.i
i
Definition: mps_fire.py:428
TtFullLepHypothesis::jetsToken_
edm::EDGetTokenT< std::vector< pat::Jet > > jetsToken_
Definition: TtFullLepHypothesis.h:87
patZpeak.handle
handle
Definition: patZpeak.py:23
Electron
Definition: Electron.py:1
edm
HLT enums.
Definition: AlignableModifier.h:19
TtFullLepHypothesis::setCandidate
void setCandidate(const edm::Handle< C > &handle, const int &idx, reco::ShallowClonePtrCandidate *&clone)
use one object in a collection to set a ShallowClonePtrCandidate
Definition: TtFullLepHypothesis.h:112
TtFullLepDaughter::B
static const std::string B
Definition: TtFullLeptonicEvent.h:9
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89287
TtFullLepHypothesis::b_
reco::ShallowClonePtrCandidate * b_
Definition: TtFullLepHypothesis.h:98
TtFullLepHypothesis::buildKey
virtual void buildKey()=0
build the event hypothesis key
TtFullLepHypothesis::neutrinoBar_
reco::ShallowClonePtrCandidate * neutrinoBar_
Definition: TtFullLepHypothesis.h:101
TtFullHadDaughter::WMinus
static const std::string WMinus
Definition: TtFullHadronicEvent.h:10
singleTopDQM_cfi.jets
jets
Definition: singleTopDQM_cfi.py:42
TtFullLepDaughter::LepBar
static const std::string LepBar
Definition: TtFullLeptonicEvent.h:9
singleTopDQM_cfi.mets
mets
Definition: singleTopDQM_cfi.py:43
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
edm::Handle
Definition: AssociativeIterator.h:50
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
Muon
Definition: Muon.py:1
heavyIonCSV_trainingSettings.idx
idx
Definition: heavyIonCSV_trainingSettings.py:5
TtFullLepHypothesis::resetCandidates
void resetCandidates()
reset candidate pointers before hypo build process
Definition: TtFullLepHypothesis.cc:102
Jet
Definition: Jet.py:1
TtFullLepHypothesis::hypo
reco::CompositeCandidate hypo()
return event hypothesis
Definition: TtFullLepHypothesis.cc:113
clone
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
TtFullLepHypothesis::~TtFullLepHypothesis
~TtFullLepHypothesis() override
default destructor
Definition: TtFullLepHypothesis.cc:34
TtFullLepHypothesis::getMatch_
bool getMatch_
Definition: TtFullLepHypothesis.h:82
TtFullLepHypothesis::produce
void produce(edm::Event &, const edm::EventSetup &) override
produce the event hypothesis as CompositeCandidate and Key
Definition: TtFullLepHypothesis.cc:51
singleTopDQM_cfi.elecs
elecs
Definition: singleTopDQM_cfi.py:41
TtFullLepHypothesis.h
TtFullLepHypothesis::key
int key() const
return key
Definition: TtFullLepHypothesis.h:55
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:531
TtFullHadDaughter::Top
static const std::string Top
Definition: TtFullHadronicEvent.h:9
reco::CompositeCandidate::addDaughter
void addDaughter(const Candidate &, const std::string &s="")
add a clone of the passed candidate as daughter
Definition: CompositeCandidate.cc:108
TtFullLepDaughter::NuBar
static const std::string NuBar
Definition: TtFullLeptonicEvent.h:10
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
TtFullLepHypothesis::recNuBar
reco::LeafCandidate * recNuBar
Definition: TtFullLepHypothesis.h:106
TtFullLepHypothesis::matchToken_
edm::EDGetTokenT< std::vector< std::vector< int > > > matchToken_
input label for all necessary collections
Definition: TtFullLepHypothesis.h:84
TtFullLepDaughter::WPlus
static const std::string WPlus
Definition: TtFullLeptonicEvent.h:9
edm::ParameterSet
Definition: ParameterSet.h:47
TtFullLepHypothesis::musToken_
edm::EDGetTokenT< std::vector< pat::Muon > > musToken_
Definition: TtFullLepHypothesis.h:86
TtFullLepHypothesis::lepton_
reco::ShallowClonePtrCandidate * lepton_
Definition: TtFullLepHypothesis.h:96
TtFullHadDaughter::WPlus
static const std::string WPlus
Definition: TtFullHadronicEvent.h:9
match
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
AddFourMomenta.h
TtFullLepDaughter::WMinus
static const std::string WMinus
Definition: TtFullLeptonicEvent.h:10
TtFullLepHypothesis::metsToken_
edm::EDGetTokenT< std::vector< pat::MET > > metsToken_
Definition: TtFullLepHypothesis.h:88
reco::LeafCandidate::p4
const LorentzVector & p4() const final
four-momentum Lorentz vector
Definition: LeafCandidate.h:114
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
reco::LeafCandidate::charge
int charge() const final
electric charge
Definition: LeafCandidate.h:106
edm::EventSetup
Definition: EventSetup.h:57
pat
Definition: HeavyIon.h:7
TtFullLepDaughter::Lep
static const std::string Lep
Definition: TtFullLeptonicEvent.h:10
TtFullLepDaughter::BBar
static const std::string BBar
Definition: TtFullLeptonicEvent.h:10
reco::LeafCandidate::vertex
const Point & vertex() const override
vertex position (overwritten by PF...)
Definition: LeafCandidate.h:165
edm::Ptr< pat::Jet >
looper.cfg
cfg
Definition: looper.py:297
TtFullLepHypothesis::elecsToken_
edm::EDGetTokenT< std::vector< pat::Electron > > elecsToken_
Definition: TtFullLepHypothesis.h:85
TtEvent::kGenMatch
Definition: TtEvent.h:30
TtFullHadDaughter::TopBar
static const std::string TopBar
Definition: TtFullHadronicEvent.h:11
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
TtFullLepHypothesis::TtFullLepHypothesis
TtFullLepHypothesis(const edm::ParameterSet &)
default constructor
Definition: TtFullLepHypothesis.cc:5
TtEvent::kKinSolution
Definition: TtEvent.h:33
TtFullLepHypothesis::recNu
reco::LeafCandidate * recNu
candidates needed for the genmatch hypothesis
Definition: TtFullLepHypothesis.h:105
AddFourMomenta::set
void set(reco::Candidate &c) const
set up a candidate
Definition: AddFourMomenta.cc:6
TtFullLepHypothesis::jetCorrectionLevel_
std::string jetCorrectionLevel_
Definition: TtFullLepHypothesis.h:91
pat::Jet::correctedJet
Jet correctedJet(const std::string &level, const std::string &flavor="none", const std::string &set="") const
MET
TtFullLepHypothesis::neutrino_
reco::ShallowClonePtrCandidate * neutrino_
Definition: TtFullLepHypothesis.h:100
TtFullLepDaughter::Nu
static const std::string Nu
Definition: TtFullLeptonicEvent.h:9
TtFullLepHypothesis::leptonBar_
reco::ShallowClonePtrCandidate * leptonBar_
Definition: TtFullLepHypothesis.h:97
AddFourMomenta
Definition: AddFourMomenta.h:18
reco::ShallowClonePtrCandidate
Definition: ShallowClonePtrCandidate.h:15
TtFullLepDaughter::TopBar
static const std::string TopBar
Definition: TtFullLeptonicEvent.h:10
TtFullLepHypothesis::buildHypo
virtual void buildHypo(edm::Event &evt, const edm::Handle< std::vector< pat::Electron > > &elecs, const edm::Handle< std::vector< pat::Muon > > &mus, const edm::Handle< std::vector< pat::Jet > > &jets, const edm::Handle< std::vector< pat::MET > > &mets, std::vector< int > &match, const unsigned int iComb)=0
build event hypothesis from the reco objects of a semi-leptonic event
edm::Event
Definition: Event.h:73
TtFullLepHypothesis::bBar_
reco::ShallowClonePtrCandidate * bBar_
Definition: TtFullLepHypothesis.h:99
edm::InputTag
Definition: InputTag.h:15
reco::CompositeCandidate
Definition: CompositeCandidate.h:21
TtFullLepDaughter::Top
static const std::string Top
Definition: TtFullLeptonicEvent.h:9