test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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_(0), leptonBar_(0), b_(0),
12  bBar_(0), neutrino_(0), neutrinoBar_(0)
13 {
14  getMatch_ = false;
15  if( cfg.exists("match") ) {
16  getMatch_ = true;
17  matchToken_ = consumes<std::vector<std::vector<int> > >(cfg.getParameter<edm::InputTag>("match"));
18  }
19  // if no other correction is given apply L3 (abs) correction
20  jetCorrectionLevel_ = "abs";
21  if( cfg.exists("jetCorrectionLevel") ) {
22  jetCorrectionLevel_ = cfg.getParameter<std::string>("jetCorrectionLevel");
23  }
24  else{ // if no other correction is given apply L3 (abs) correction
25  jetCorrectionLevel_ = "abs";
26  }
27  produces<std::vector<std::pair<reco::CompositeCandidate, std::vector<int> > > >();
28  produces<int>("Key");
29 }
30 
33 {
34  if( lepton_ ) delete lepton_;
35  if( leptonBar_ ) delete leptonBar_;
36  if( b_ ) delete b_;
37  if( bBar_ ) delete bBar_;
38  if( neutrino_ ) delete neutrino_;
39  if( neutrinoBar_ ) delete neutrinoBar_;
40  //if( met_ ) delete met_;
41 }
42 
44 void
46 {
48  evt.getByToken(elecsToken_, elecs);
49 
51  evt.getByToken(musToken_, mus);
52 
54  evt.getByToken(jetsToken_, jets);
55 
57  evt.getByToken(metsToken_, mets);
58 
59  std::vector<std::vector<int> > matchVec;
60  if( getMatch_ ) {
62  evt.getByToken(matchToken_, matchHandle);;
63  matchVec = *matchHandle;
64  }
65  else {
66  std::vector<int> dummyMatch;
67  for(unsigned int i = 0; i < 4; ++i)
68  dummyMatch.push_back( -1 );
69  matchVec.push_back( dummyMatch );
70  }
71 
72  // declare auto_ptr for products
73  std::auto_ptr<std::vector<std::pair<reco::CompositeCandidate, std::vector<int> > > >
74  pOut( new std::vector<std::pair<reco::CompositeCandidate, std::vector<int> > > );
75  std::auto_ptr<int> pKey(new int);
76 
77  // build and feed out key
78  buildKey();
79  *pKey=key();
80  evt.put(pKey, "Key");
81 
82  // go through given vector of jet combinations
83  unsigned int idMatch = 0;
84  typedef std::vector<std::vector<int> >::iterator MatchVecIterator;
85  for(MatchVecIterator match = matchVec.begin(); match != matchVec.end(); ++match) {
86  // reset pointers
88  // build hypothesis
89  buildHypo(evt, elecs, mus, jets, mets, *match, idMatch++);
90  pOut->push_back( std::make_pair(hypo(), *match) );
91  }
92  // feed out hyps and matches
93  evt.put(pOut);
94 }
95 
97 void
99 {
100  lepton_ = 0;
101  leptonBar_ = 0;
102  b_ = 0;
103  bBar_ = 0;
104  neutrino_ = 0;
105  neutrinoBar_= 0;
106  //met_ = 0;
107 }
108 
112 {
113  // check for sanity of the hypothesis
114  if( !lepton_ || !leptonBar_ || !b_ || !bBar_ ){
115  return reco::CompositeCandidate();
116  }
117 
119  edm::LogInfo("TtFullHypothesis") << "no neutrinos for gen match" << std::endl;
120  return reco::CompositeCandidate();
121  }
123  edm::LogInfo("TtFullHypothesis") << "no neutrinos for kin solution" << std::endl;
124  return reco::CompositeCandidate();
125  }
126 
127  // setup transient references
129 
130  AddFourMomenta addFourMomenta;
131 
132  // build up the top branch
138  addFourMomenta.set(WPlus);
141  addFourMomenta.set(Top);
142 
143  // build up the anti top branch
149  addFourMomenta.set(WMinus);
150  TopBar.addDaughter(WMinus, TtFullLepDaughter::WMinus);
152  addFourMomenta.set(TopBar);
153 
154  // build ttbar hypothesis
157  addFourMomenta.set( hyp );
158 
159  // the four momentum of the met is not added to the hypothesis
160  // because it is allready included through the neutrinos
161  //hyp.addDaughter(*met_, TtFullLepDaughter::Met);
162  return hyp;
163 }
164 
166 void
167 TtFullLepHypothesis::setCandidate(const edm::Handle<std::vector<pat::Jet> >& handle, const int& idx, reco::ShallowClonePtrCandidate*& clone, const std::string& correctionLevel)
168 {
170  clone = new reco::ShallowClonePtrCandidate( ptr, ptr->charge(), ptr->correctedJet(jetCorrectionLevel_, "bottom").p4(), ptr->vertex() );
171 }
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
reco::ShallowClonePtrCandidate * neutrino_
reco::ShallowClonePtrCandidate * leptonBar_
static const std::string WMinus
tuple cfg
Definition: looper.py:293
reco::LeafCandidate * recNuBar
static const std::string Nu
void setCandidate(const edm::Handle< C > &handle, const int &idx, reco::ShallowClonePtrCandidate *&clone)
use one object in a collection to set a ShallowClonePtrCandidate
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
virtual void buildKey()=0
build the event hypothesis key
bool exists(std::string const &parameterName) const
checks if a parameter exists
reco::LeafCandidate * recNu
candidates needed for the genmatch hypothesis
static const std::string WPlus
static const std::string B
static const std::string Top
static const std::string Top
static const std::string TopBar
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
vector< PseudoJet > jets
tuple handle
Definition: patZpeak.py:22
static const std::string WMinus
static const std::string LepBar
edm::EDGetTokenT< std::vector< pat::Jet > > jetsToken_
void addDaughter(const Candidate &, const std::string &s="")
add a clone of the passed candidate as daughter
void resetCandidates()
reset candidate pointers before hypo build process
reco::CompositeCandidate hypo()
return event hypothesis
static const std::string WPlus
static const std::string TopBar
edm::EDGetTokenT< std::vector< std::vector< int > > > matchToken_
input label for all necessary collections
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::EDGetTokenT< std::vector< pat::Electron > > elecsToken_
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
reco::ShallowClonePtrCandidate * lepton_
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
reco::ShallowClonePtrCandidate * bBar_
std::string jetCorrectionLevel_
edm::EDGetTokenT< std::vector< pat::MET > > metsToken_
static const std::string BBar
int key() const
return key
~TtFullLepHypothesis()
default destructor
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
void set(reco::Candidate &c) const
set up a candidate
reco::ShallowClonePtrCandidate * b_
TtFullLepHypothesis(const edm::ParameterSet &)
default constructor
virtual void produce(edm::Event &, const edm::EventSetup &)
produce the event hypothesis as CompositeCandidate and Key
static const std::string NuBar
static const std::string Lep
reco::ShallowClonePtrCandidate * neutrinoBar_
edm::EDGetTokenT< std::vector< pat::Muon > > musToken_