CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions
TtFullLepHypGenMatch Class Reference

#include <TtFullLepHypGenMatch.h>

Inheritance diagram for TtFullLepHypGenMatch:
TtFullLepHypothesis edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

Public Member Functions

 TtFullLepHypGenMatch (const edm::ParameterSet &)
 
 ~TtFullLepHypGenMatch ()
 
- Public Member Functions inherited from TtFullLepHypothesis
 TtFullLepHypothesis (const edm::ParameterSet &)
 default constructor More...
 
 ~TtFullLepHypothesis ()
 default destructor More...
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Member Functions

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)
 build event hypothesis from the reco objects of a semi-leptonic event More...
 
virtual void buildKey ()
 build the event hypothesis key More...
 
void buildMatchingNeutrinos (edm::Event &, const edm::Handle< std::vector< pat::MET > > &)
 
template<typename O >
int findMatchingLepton (const reco::GenParticle *, const edm::Handle< std::vector< O > > &)
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from TtFullLepHypothesis
reco::CompositeCandidate hypo ()
 return event hypothesis More...
 
bool isValid (const int &idx, const edm::Handle< std::vector< pat::Jet > > &jets)
 check if index is in valid range of selected jets More...
 
int key () const
 return key More...
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 produce the event hypothesis as CompositeCandidate and Key More...
 
void resetCandidates ()
 reset candidate pointers before hypo build process More...
 
template<typename C >
void setCandidate (const edm::Handle< C > &handle, const int &idx, reco::ShallowClonePtrCandidate *&clone)
 use one object in a collection to set a ShallowClonePtrCandidate More...
 
void setCandidate (const edm::Handle< std::vector< pat::Jet > > &handle, const int &idx, reco::ShallowClonePtrCandidate *&clone, const std::string &correctionLevel)
 use one object in a jet collection to set a ShallowClonePtrCandidate with proper jet corrections More...
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 
- Protected Attributes inherited from TtFullLepHypothesis
reco::ShallowClonePtrCandidateb_
 
reco::ShallowClonePtrCandidatebBar_
 
edm::InputTag elecs_
 
bool getMatch_
 
std::string jetCorrectionLevel_
 
edm::InputTag jets_
 
int key_
 hypothesis key (to be set by the buildKey function) More...
 
reco::ShallowClonePtrCandidatelepton_
 
reco::ShallowClonePtrCandidateleptonBar_
 
edm::InputTag match_
 input label for all necessary collections More...
 
edm::InputTag mets_
 
edm::InputTag mus_
 
reco::ShallowClonePtrCandidateneutrino_
 
reco::ShallowClonePtrCandidateneutrinoBar_
 
reco::LeafCandidaterecNu
 candidates needed for the genmatch hypothesis More...
 
reco::LeafCandidaterecNuBar
 

Detailed Description

Definition at line 7 of file TtFullLepHypGenMatch.h.

Constructor & Destructor Documentation

TtFullLepHypGenMatch::TtFullLepHypGenMatch ( const edm::ParameterSet cfg)
explicit

Definition at line 5 of file TtFullLepHypGenMatch.cc.

5  :
6  TtFullLepHypothesis( cfg )
7 {
8 }
TtFullLepHypothesis(const edm::ParameterSet &)
default constructor
TtFullLepHypGenMatch::~TtFullLepHypGenMatch ( )

Definition at line 10 of file TtFullLepHypGenMatch.cc.

10 { }

Member Function Documentation

void TtFullLepHypGenMatch::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 
)
privatevirtual

build event hypothesis from the reco objects of a semi-leptonic event

Implements TtFullLepHypothesis.

Definition at line 13 of file TtFullLepHypGenMatch.cc.

References TtFullLepEvtPartons::B, TtFullLepHypothesis::b_, TtFullLepEvtPartons::BBar, TtFullLepHypothesis::bBar_, buildMatchingNeutrinos(), findMatchingLepton(), TtGenEvtProducer_cfi::genEvt, edm::Event::getByLabel(), TtFullLepHypothesis::isValid(), TtFullLepHypothesis::jetCorrectionLevel_, fwrapper::jets, WDecay::kElec, WDecay::kMuon, TtFullLepHypothesis::lepton_, TtFullLepHypothesis::leptonBar_, and TtFullLepHypothesis::setCandidate().

20 {
21  // -----------------------------------------------------
22  // add jets
23  // -----------------------------------------------------
24  for(unsigned idx=0; idx<match.size(); ++idx){
25  if( isValid(match[idx], jets) ){
26  switch(idx){
28  setCandidate(jets, match[idx], b_ , jetCorrectionLevel_); break;
30  setCandidate(jets, match[idx], bBar_, jetCorrectionLevel_); break;
31  }
32  }
33  }
34 
35  // -----------------------------------------------------
36  // add leptons
37  // -----------------------------------------------------
38  // get genEvent
40  evt.getByLabel("genEvt", genEvt);
41 
42  // push back fake indices if no leptons in genevent
43  if( !genEvt->isFullLeptonic() || !genEvt->lepton() || !genEvt->leptonBar() ){
44  match.push_back( -1 );
45  match.push_back( -1 );
46  match.push_back( -1 );
47  match.push_back( -1 );
48  }
49  else if(genEvt->isFullLeptonic(WDecay::kElec, WDecay::kElec) && elecs->size()>=2){
50  //search indices for electrons
51  int iLepBar = findMatchingLepton(genEvt->leptonBar(), elecs);
52  setCandidate(elecs, iLepBar, leptonBar_);
53  match.push_back( iLepBar );
54  int iLep = findMatchingLepton(genEvt->lepton(), elecs);
55  setCandidate(elecs, iLep, lepton_);
56  match.push_back( iLep );
57 
58  // fake indices for muons
59  match.push_back( -1 );
60  match.push_back( -1 );
61  }
62  else if(genEvt->isFullLeptonic(WDecay::kElec, WDecay::kMuon) && !elecs->empty() && !mus->empty() ){
63  if(genEvt->leptonBar()->isElectron()){
64  // push back index for e+
65  int iLepBar = findMatchingLepton(genEvt->leptonBar(), elecs);
66  setCandidate(elecs, iLepBar, leptonBar_);
67  match.push_back( iLepBar );
68  // push back fake indices for e- and mu+
69  match.push_back( -1 );
70  match.push_back( -1 );
71  // push back index for mu-
72  int iLep = findMatchingLepton(genEvt->lepton(), mus);
73  setCandidate(mus, iLep, lepton_);
74  match.push_back( iLep );
75  }
76  else{
77  // push back fake index for e+
78  match.push_back( -1 );
79  // push back index for e-
80  int iLepBar = findMatchingLepton(genEvt->leptonBar(), mus);
81  setCandidate(mus, iLepBar, leptonBar_);
82  match.push_back( iLepBar );
83  // push back index for mu+
84  int iLep = findMatchingLepton(genEvt->lepton(), elecs);
85  setCandidate(elecs, iLep, lepton_);
86  match.push_back( iLep );
87  // push back fake index for mu-
88  match.push_back( -1 );
89  }
90  }
91  else if(genEvt->isFullLeptonic(WDecay::kMuon, WDecay::kMuon) && mus->size()>=2 ){
92  // fake indices for electrons
93  match.push_back( -1 );
94  match.push_back( -1 );
95 
96  //search indices for electrons
97  int iLepBar = findMatchingLepton(genEvt->leptonBar(), mus);
98  setCandidate(mus, iLepBar, leptonBar_);
99  match.push_back( iLepBar );
100  int iLep = findMatchingLepton(genEvt->lepton(), mus);
101  setCandidate(mus, iLep, lepton_);
102  match.push_back( iLep );
103  }
104  else{ //this 'else' should happen if at least one genlepton is a tau
105  match.push_back( -1 );
106  match.push_back( -1 );
107  match.push_back( -1 );
108  match.push_back( -1 );
109  }
110 
111  // -----------------------------------------------------
112  // add met and neutrinos
113  // -----------------------------------------------------
114  if( !mets->empty() ){
115  //setCandidate(mets, 0, met_);
116  buildMatchingNeutrinos(evt, mets);
117  }
118 }
reco::ShallowClonePtrCandidate * leptonBar_
void setCandidate(const edm::Handle< C > &handle, const int &idx, reco::ShallowClonePtrCandidate *&clone)
use one object in a collection to set a ShallowClonePtrCandidate
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
void buildMatchingNeutrinos(edm::Event &, const edm::Handle< std::vector< pat::MET > > &)
reco::ShallowClonePtrCandidate * lepton_
int findMatchingLepton(const reco::GenParticle *, const edm::Handle< std::vector< O > > &)
reco::ShallowClonePtrCandidate * bBar_
std::string jetCorrectionLevel_
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:6
reco::ShallowClonePtrCandidate * b_
bool isValid(const int &idx, const edm::Handle< std::vector< pat::Jet > > &jets)
check if index is in valid range of selected jets
virtual void TtFullLepHypGenMatch::buildKey ( )
inlineprivatevirtual

build the event hypothesis key

Implements TtFullLepHypothesis.

Definition at line 17 of file TtFullLepHypGenMatch.h.

References TtFullLepHypothesis::key_, and TtEvent::kGenMatch.

int key_
hypothesis key (to be set by the buildKey function)
void TtFullLepHypGenMatch::buildMatchingNeutrinos ( edm::Event evt,
const edm::Handle< std::vector< pat::MET > > &  mets 
)
private

Definition at line 137 of file TtFullLepHypGenMatch.cc.

References TtGenEvtProducer_cfi::genEvt, edm::Event::getByLabel(), TtFullLepHypothesis::recNu, TtFullLepHypothesis::recNuBar, and mathSSE::sqrt().

Referenced by buildHypo().

138 {
139  // get genEvent
141  evt.getByLabel("genEvt", genEvt);
142 
143  if( genEvt->isTtBar() && genEvt->isFullLeptonic() && genEvt->neutrino() && genEvt->neutrinoBar() ){
144  double momXNu = genEvt->neutrino() ->px();
145  double momYNu = genEvt->neutrino() ->py();
146  double momXNuBar = genEvt->neutrinoBar()->px();
147  double momYNuBar = genEvt->neutrinoBar()->py();
148 
149  double momXMet = mets->at(0).px();
150  double momYMet = mets->at(0).py();
151 
152  double momXNeutrino = 0.5*(momXNu - momXNuBar + momXMet);
153  double momYNeutrino = 0.5*(momYNu - momYNuBar + momYMet);
154  double momXNeutrinoBar = momXMet - momXNeutrino;
155  double momYNeutrinoBar = momYMet - momYNeutrino;
156 
157  math::XYZTLorentzVector recNuFM(momXNeutrino,momYNeutrino,0,sqrt(momXNeutrino * momXNeutrino + momYNeutrino * momYNeutrino));
158  recNu = new reco::LeafCandidate(0,recNuFM);
159 
160  math::XYZTLorentzVector recNuBarFM(momXNeutrinoBar,momYNeutrinoBar,0,sqrt(momXNeutrinoBar * momXNeutrinoBar + momYNeutrinoBar * momYNeutrinoBar));
161  recNuBar = new reco::LeafCandidate(0,recNuBarFM);
162  }
163 }
reco::LeafCandidate * recNuBar
reco::LeafCandidate * recNu
candidates needed for the genmatch hypothesis
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:30
T sqrt(T t)
Definition: SSEVec.h:46
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
template<typename O >
int TtFullLepHypGenMatch::findMatchingLepton ( const reco::GenParticle genLep,
const edm::Handle< std::vector< O > > &  leps 
)
private

Definition at line 122 of file TtFullLepHypGenMatch.cc.

References deltaR(), PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi::dR, reco::LeafCandidate::eta(), i, and reco::LeafCandidate::phi().

Referenced by buildHypo().

123 {
124  int idx=-1;
125  double minDR = -1;
126  for(unsigned i=0; i<leps->size(); ++i){
127  double dR = deltaR(genLep->eta(), genLep->phi(), (*leps)[i].eta(), (*leps)[i].phi());
128  if(minDR<0 || dR<minDR){
129  minDR=dR;
130  idx=i;
131  }
132  }
133  return idx;
134 }
int i
Definition: DBlmapReader.cc:9
virtual double eta() const
momentum pseudorapidity
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
virtual double phi() const
momentum azimuthal angle